Compare commits
43 Commits
newEmploye
...
landingPag
| Author | SHA1 | Date | |
|---|---|---|---|
| 30f755c0b2 | |||
| 7feb3a6f5d | |||
| e5d90bc32d | |||
| 1500aef977 | |||
| 112f78c1de | |||
| 08702b2cdf | |||
| 21013cf6ac | |||
| 59a4d6e4a5 | |||
| 7cf083a612 | |||
| d4135188bd | |||
| 6d29ac3f23 | |||
| 0449f202ef | |||
| 23868b60ee | |||
| 8a2d5b2afa | |||
| 7ceb2aad93 | |||
| 3902435690 | |||
| f16e9fe72c | |||
| d2b9163537 | |||
| 403541580d | |||
| 663ea7cc3e | |||
| f93b41f14e | |||
| 24f1ce1ed7 | |||
| b25346e3d5 | |||
| f2237d9209 | |||
| 7fc9ca8c75 | |||
| 97fca1d7d3 | |||
| 058e19a49a | |||
| bffeb6e9f4 | |||
| 9a3e876afe | |||
| dadea504d0 | |||
| 1390427ec0 | |||
| 6c4e42e337 | |||
| f4d1ce1ab7 | |||
| ba307555f0 | |||
| 57ee1fbd72 | |||
| 63a7186464 | |||
| 4a8df33184 | |||
| 0deb89ed53 | |||
| f441696b96 | |||
| 666b17c0dc | |||
| 30420975c4 | |||
| 2d3f52372c | |||
| 3d7a574396 |
5
api-payroll/.dockerignore
Normal file
5
api-payroll/.dockerignore
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
Dockerfile
|
||||||
|
README.md
|
||||||
|
buildspec.yml
|
||||||
|
CONTRIBUTING.md
|
||||||
|
docker-compose.yml
|
||||||
1
api-payroll/.htaccess
Normal file
1
api-payroll/.htaccess
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Options -Indexes
|
||||||
43
api-payroll/Dockerfile
Normal file
43
api-payroll/Dockerfile
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
FROM ubuntu:16.04
|
||||||
|
|
||||||
|
# Updating
|
||||||
|
RUN apt-get -y update && apt-get -y upgrade
|
||||||
|
|
||||||
|
# Installing php, apache and supplementary software
|
||||||
|
RUN apt-get -y install apache2 php7.0 libapache2-mod-php7.0 php7.0-cli php7.0-common php7.0-mbstring php7.0-gd php7.0-intl php7.0-xml php7.0-mysql php7.0-mcrypt php7.0-zip curl git unzip composer
|
||||||
|
|
||||||
|
# Enable apache mods
|
||||||
|
RUN a2enmod php7.0
|
||||||
|
RUN a2enmod rewrite
|
||||||
|
|
||||||
|
# Update the PHP.ini file, enable <? ?> tags and quieten logging
|
||||||
|
RUN sed -i "s/short_open_tag = Off/short_open_tag = On/" /etc/php/7.0/apache2/php.ini
|
||||||
|
RUN sed -i "s/error_reporting = .*$/error_reporting = E_ERROR | E_WARNING | E_PARSE/" /etc/php/7.0/apache2/php.ini
|
||||||
|
|
||||||
|
# Manually set up the apache environment variables
|
||||||
|
ENV APACHE_RUN_USER www-data
|
||||||
|
ENV APACHE_RUN_GROUP www-data
|
||||||
|
ENV APACHE_LOG_DIR /var/log/apache2
|
||||||
|
ENV APACHE_LOCK_DIR /var/lock/apache2
|
||||||
|
|
||||||
|
# Expose apache
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
# Copy this repo into place.
|
||||||
|
ADD . /var/www/site
|
||||||
|
WORKDIR /var/www/site
|
||||||
|
|
||||||
|
# Testing permisions
|
||||||
|
RUN chmod 777 -R .
|
||||||
|
|
||||||
|
# Installing dependencies
|
||||||
|
RUN composer install
|
||||||
|
|
||||||
|
# Unit tests
|
||||||
|
RUN composer test
|
||||||
|
|
||||||
|
# Update the default apache site with the config we created.
|
||||||
|
ADD apache-config.conf /etc/apache2/sites-enabled/000-default.conf
|
||||||
|
|
||||||
|
# By default start up apache in the foreground, override with /bin/bash for interative
|
||||||
|
CMD /usr/sbin/apache2ctl -D FOREGROUND
|
||||||
15
api-payroll/apache-config.conf
Normal file
15
api-payroll/apache-config.conf
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<VirtualHost *:80>
|
||||||
|
ServerAdmin me@mydomain.com
|
||||||
|
DocumentRoot /var/www/site
|
||||||
|
|
||||||
|
<Directory /var/www/site/>
|
||||||
|
Options Indexes FollowSymLinks MultiViews
|
||||||
|
AllowOverride All
|
||||||
|
Order deny,allow
|
||||||
|
Allow from all
|
||||||
|
</Directory>
|
||||||
|
|
||||||
|
ErrorLog ${APACHE_LOG_DIR}/error.log
|
||||||
|
CustomLog ${APACHE_LOG_DIR}/access.log combined
|
||||||
|
|
||||||
|
</VirtualHost>
|
||||||
@@ -14,8 +14,9 @@ phases:
|
|||||||
- echo Entered the build phase...
|
- echo Entered the build phase...
|
||||||
- echo Build started on `date`
|
- echo Build started on `date`
|
||||||
- composer test
|
- composer test
|
||||||
|
- sudo docker-compose up --build -d
|
||||||
post_build:
|
post_build:
|
||||||
commands:
|
commands:
|
||||||
- echo Entered the post_build phase...
|
- echo Entered the post_build phase...
|
||||||
|
- sudo docker-compose down --rmi all -v
|
||||||
- echo Build completed on `date`
|
- echo Build completed on `date`
|
||||||
|
|
||||||
|
|||||||
6
api-payroll/public/css/bootstrap.min.css
vendored
Normal file
6
api-payroll/public/css/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
81
api-payroll/public/css/login.css
Normal file
81
api-payroll/public/css/login.css
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
body {
|
||||||
|
background: url(../imagenes/grey_background.jpg);
|
||||||
|
background-size: cover;
|
||||||
|
font-family: Montserrat;
|
||||||
|
}
|
||||||
|
@media only screen and (min-device-width: 480px) {
|
||||||
|
body {
|
||||||
|
background: url('../imagenes/grey_background.jpg') no-repeat fixed center center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.logo {
|
||||||
|
width: 213px;
|
||||||
|
height: 60px;
|
||||||
|
margin: 30px auto;
|
||||||
|
}
|
||||||
|
.login-block {
|
||||||
|
width: 320px;
|
||||||
|
padding: 20px;
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 5px;
|
||||||
|
border-top: 5px solid #bdb035;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
.login-block h1 {
|
||||||
|
text-align: center;
|
||||||
|
color: #000;
|
||||||
|
font-size: 18px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
margin-top: 0;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
.login-block input {
|
||||||
|
width: 100%;
|
||||||
|
height: 42px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border-radius: 5px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
font-size: 14px;
|
||||||
|
font-family: Montserrat;
|
||||||
|
padding: 0 20px 0 50px;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
.login-block input#user {
|
||||||
|
background: #fff url('../imagenes/login_username.png') 20px top no-repeat;
|
||||||
|
background-size: 16px 80px;
|
||||||
|
}
|
||||||
|
.login-block input#user:focus {
|
||||||
|
background: #fff url('../imagenes/login_username.png') 20px bottom no-repeat;
|
||||||
|
background-size: 16px 80px;
|
||||||
|
}
|
||||||
|
.login-block input#password {
|
||||||
|
background: #fff url('../imagenes/login_password.png') 20px top no-repeat;
|
||||||
|
background-size: 16px 80px;
|
||||||
|
}
|
||||||
|
.login-block input#password:focus {
|
||||||
|
background: #fff url('../imagenes/login_password.png') 20px bottom no-repeat;
|
||||||
|
background-size: 16px 80px;
|
||||||
|
}
|
||||||
|
.login-block input:active, .login-block input:focus {
|
||||||
|
border: 1px solid #bdb035;
|
||||||
|
}
|
||||||
|
.login-block #loginButon {
|
||||||
|
width: 100%;
|
||||||
|
height: 40px;
|
||||||
|
background: #bdb035;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border-radius: 5px;
|
||||||
|
border: 1px solid #6d661c;
|
||||||
|
color: #fff;
|
||||||
|
font-weight: bold;
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-size: 14px;
|
||||||
|
font-family: Montserrat;
|
||||||
|
outline: none;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.login-block button:hover {
|
||||||
|
background: #c7b935;
|
||||||
|
border: 1px solid #6d661c;
|
||||||
|
}
|
||||||
258
api-payroll/public/css/panel.css
Normal file
258
api-payroll/public/css/panel.css
Normal file
@@ -0,0 +1,258 @@
|
|||||||
|
body {
|
||||||
|
background-color: #e3e3e3;
|
||||||
|
/* Se agrego color blanco a letra en panel en general*/
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*Cambia el color del date picker a negro para permitir su visibilidad*/
|
||||||
|
.datepicker{
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*El color con el que se muestra el peso del archivo en la carga masiva se imagenes*/
|
||||||
|
.size{
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.calendar{
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
#cuerpo{
|
||||||
|
top:17%;
|
||||||
|
left:1%;
|
||||||
|
width:98%;
|
||||||
|
float:left;
|
||||||
|
}
|
||||||
|
|
||||||
|
#navigation_spot{
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#footer {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#cuerpo .modal-body{
|
||||||
|
color: #000;
|
||||||
|
border:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#cuerpo .panel-default{
|
||||||
|
border: 3px solid #4A89A5;
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#cuerpo .panel > .panel-heading {
|
||||||
|
background-image: none;
|
||||||
|
background-color: #4A89A5;
|
||||||
|
color: white;
|
||||||
|
border-radius: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#cuerpo .btn-default{
|
||||||
|
border: 2px solid #62655F;
|
||||||
|
background: #F9DFAF;
|
||||||
|
}
|
||||||
|
|
||||||
|
#cuerpo .btn-default:hover{
|
||||||
|
border: 2px solid #62655F;
|
||||||
|
background: #F9DFAF;
|
||||||
|
}
|
||||||
|
|
||||||
|
#cuerpo .alert-success{
|
||||||
|
background: #C6E97C;
|
||||||
|
}
|
||||||
|
|
||||||
|
#modal_header_error{
|
||||||
|
background-color: #d9534f;
|
||||||
|
}
|
||||||
|
|
||||||
|
#modal_header_respuesa_servidor_error{
|
||||||
|
background-color: #d9534f;
|
||||||
|
}
|
||||||
|
|
||||||
|
#modal_header_respuesa_servidor_success{
|
||||||
|
background-color: #5bc0de;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* botoner<65>a panel principal */
|
||||||
|
.metro{
|
||||||
|
width:auto;
|
||||||
|
height:auto;
|
||||||
|
}
|
||||||
|
.metroBox{
|
||||||
|
margin: 0 auto;
|
||||||
|
width:100%;
|
||||||
|
padding: 0;
|
||||||
|
height:auto;
|
||||||
|
display:table;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.metroBox h3{
|
||||||
|
margin-bottom: 0;
|
||||||
|
padding-bottom: 0;
|
||||||
|
}
|
||||||
|
.metroBox a{
|
||||||
|
text-decoration: none;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
.boxElement{
|
||||||
|
color: #fff;
|
||||||
|
height:210px;
|
||||||
|
width: 318px;
|
||||||
|
float:left;
|
||||||
|
margin:0 5px 5px 0;
|
||||||
|
padding:0 1% 0 1%;
|
||||||
|
}
|
||||||
|
.boxElement:hover{
|
||||||
|
color: #fff;
|
||||||
|
background: #483D8B;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
.amarelo{
|
||||||
|
background:#f4c20d;
|
||||||
|
}
|
||||||
|
.vermelho{
|
||||||
|
background:#da542d;
|
||||||
|
}
|
||||||
|
.azul{
|
||||||
|
background:#009bad;
|
||||||
|
}
|
||||||
|
.azulFuerte{
|
||||||
|
background:#5636b0;
|
||||||
|
}
|
||||||
|
.verde{
|
||||||
|
background-color: #009f00;
|
||||||
|
}
|
||||||
|
.violet{
|
||||||
|
background-color: #a400ab;
|
||||||
|
}
|
||||||
|
.iconPanel{
|
||||||
|
font-size: 130px;
|
||||||
|
}
|
||||||
|
@media (max-width: 310px){
|
||||||
|
.boxElement{
|
||||||
|
width: 245px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media (min-width: 311px) and (max-width: 353px){
|
||||||
|
.boxElement{
|
||||||
|
width: 265px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media (min-width: 354px) and (max-width: 365px){
|
||||||
|
.boxElement{
|
||||||
|
width: 320px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media (min-width: 366px) and (max-width: 520px){
|
||||||
|
.boxElement{
|
||||||
|
width: 320px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media (min-width: 521px) and (max-width: 549px){
|
||||||
|
.boxElement{
|
||||||
|
width: 235px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media (min-width: 550px) and (max-width: 590px){
|
||||||
|
.boxElement{
|
||||||
|
width: 250px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media (min-width: 591px) and (max-width: 610px){
|
||||||
|
.boxElement{
|
||||||
|
width: 265px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media (min-width: 611px) and (max-width: 630px){
|
||||||
|
.boxElement{
|
||||||
|
width: 275px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media (min-width: 631px) and (max-width: 655px){
|
||||||
|
.boxElement{
|
||||||
|
width: 280px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media (min-width: 656px) and (max-width: 699px){
|
||||||
|
.boxElement{
|
||||||
|
width: 300px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media (min-width: 700px) and (max-width: 739px){
|
||||||
|
.boxElement{
|
||||||
|
width: 320px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media (min-width: 740px) and (max-width: 769px){
|
||||||
|
.boxElement{
|
||||||
|
width: 340px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media (min-width: 770px) and (max-width: 1230px){
|
||||||
|
.boxElement{
|
||||||
|
width: 280px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* FORMATO PARA TEXTO CUSTOM */
|
||||||
|
.formato_texto_custom{
|
||||||
|
width: 97%;
|
||||||
|
float: left;
|
||||||
|
border: 1px solid #222;
|
||||||
|
padding: 1%;
|
||||||
|
margin: .5%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cliente_muestra_producto{
|
||||||
|
width: 96%;
|
||||||
|
padding: 1%;
|
||||||
|
margin: 0 1% 2% 1%;
|
||||||
|
}
|
||||||
|
|
||||||
|
textarea{
|
||||||
|
resize: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#custom-bootstrap-menu.navbar-default .navbar-brand {
|
||||||
|
color: rgba(255, 255, 255, 1);
|
||||||
|
}
|
||||||
|
#custom-bootstrap-menu.navbar-default {
|
||||||
|
font-size: 14px;
|
||||||
|
background-color: rgba(27, 35, 78, 1);
|
||||||
|
border-width: 1px;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
#custom-bootstrap-menu.navbar-default .navbar-nav>li>a {
|
||||||
|
color: rgba(255, 255, 255, 1);
|
||||||
|
background-color: rgba(27, 35, 78, 1);
|
||||||
|
}
|
||||||
|
#custom-bootstrap-menu.navbar-default .navbar-nav>li>a:hover,
|
||||||
|
#custom-bootstrap-menu.navbar-default .navbar-nav>li>a:focus {
|
||||||
|
color: rgba(106, 171, 232, 1);
|
||||||
|
background-color: rgba(27, 35, 78, 1);
|
||||||
|
}
|
||||||
|
#custom-bootstrap-menu.navbar-default .navbar-nav>.active>a,
|
||||||
|
#custom-bootstrap-menu.navbar-default .navbar-nav>.active>a:hover,
|
||||||
|
#custom-bootstrap-menu.navbar-default .navbar-nav>.active>a:focus {
|
||||||
|
color: rgba(255, 255, 255, 1);
|
||||||
|
background-color: rgba(27, 35, 78, 1);
|
||||||
|
}
|
||||||
|
#custom-bootstrap-menu.navbar-default .navbar-toggle {
|
||||||
|
border-color: #1b234e;
|
||||||
|
}
|
||||||
|
#custom-bootstrap-menu.navbar-default .navbar-toggle:hover,
|
||||||
|
#custom-bootstrap-menu.navbar-default .navbar-toggle:focus {
|
||||||
|
background-color: #1b234e;
|
||||||
|
}
|
||||||
|
#custom-bootstrap-menu.navbar-default .navbar-toggle .icon-bar {
|
||||||
|
background-color: #1b234e;
|
||||||
|
}
|
||||||
|
#custom-bootstrap-menu.navbar-default .navbar-toggle:hover .icon-bar,
|
||||||
|
#custom-bootstrap-menu.navbar-default .navbar-toggle:focus .icon-bar {
|
||||||
|
background-color: #1b234e;
|
||||||
|
}
|
||||||
BIN
api-payroll/public/fonts/glyphicons-halflings-regular.ttf
Normal file
BIN
api-payroll/public/fonts/glyphicons-halflings-regular.ttf
Normal file
Binary file not shown.
BIN
api-payroll/public/fonts/glyphicons-halflings-regular.woff
Normal file
BIN
api-payroll/public/fonts/glyphicons-halflings-regular.woff
Normal file
Binary file not shown.
BIN
api-payroll/public/fonts/glyphicons-halflings-regular.woff2
Normal file
BIN
api-payroll/public/fonts/glyphicons-halflings-regular.woff2
Normal file
Binary file not shown.
232
api-payroll/public/html/landing.php
Normal file
232
api-payroll/public/html/landing.php
Normal file
@@ -0,0 +1,232 @@
|
|||||||
|
<!-- Latest compiled and minified CSS -->
|
||||||
|
<link rel="stylesheet" href="../css/bootstrap.min.css">
|
||||||
|
|
||||||
|
<!-- jQuery library -->
|
||||||
|
<script src="../js/jquery.min.js"></script>
|
||||||
|
|
||||||
|
<!-- Latest compiled JavaScript -->
|
||||||
|
<script src="../js/bootstrap.min.js"></script>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="col-md-12" id="navigation_spot">
|
||||||
|
<!-- NavBar-->
|
||||||
|
<div id="custom-bootstrap-menu" class="navbar navbar-default " role="navigation">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="navbar-header"><a class="navbar-brand" href="#"></a>
|
||||||
|
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-menubuilder"><span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="collapse navbar-collapse navbar-menubuilder">
|
||||||
|
<ul class="nav navbar-nav navbar-left">
|
||||||
|
|
||||||
|
<li class="dropdown">
|
||||||
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="glyphicon glyphicon-user"></span> Employees<span class="caret"></span></a>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
<li><a href="#" data-nav_accion="views/cliente.php" onclick="vista_crear_nuevo_salon_evento();"> New employee</a></li>
|
||||||
|
<li><a href="#" data-nav_accion="views/clientess.php" onclick="vista_crear_nuevo_coach();"> Modify employee</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<a href="#" onclick="vista_calendario();"><span class="glyphicon glyphicon-tasks"></span> Management</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<a href="#" onclick="vista_calendario();"><span class="glyphicon glyphicon-wrench"></span> Change password</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<ul class="nav navbar-nav navbar-right">
|
||||||
|
<li>
|
||||||
|
<a href="../logout.php"><span class="fa fa-fw fa-power-off"></span> Cerrar Sesión</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-12" id="cuerpo"></div>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
=================================================================================
|
||||||
|
Errores en query de AJAX
|
||||||
|
=================================================================================
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- Fallo en la conexion de internet -->
|
||||||
|
<div id="modal_error_internet" class="modal fade" role="dialog">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
|
||||||
|
<!-- Modal content-->
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header" id="modal_header_error">
|
||||||
|
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||||
|
<h4 class="modal-title"><center>Ha ocurrido un error</center></h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p>Por favor revise su conexión a internet.</p>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- El recurso solicitado no existe -->
|
||||||
|
<div id="modal_error_404" class="modal fade" role="dialog">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
|
||||||
|
<!-- Modal content-->
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header" id="modal_header_error">
|
||||||
|
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||||
|
<h4 class="modal-title"><center>Ha ocurrido un error</center></h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p>El URL del formulario no pudo ser encontrado en el servidor.</p>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Error interno del servidor donde no es posible detectar la causa especifica -->
|
||||||
|
<div id="modal_error_500" class="modal fade" role="dialog">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
|
||||||
|
<!-- Modal content-->
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header" id="modal_header_error">
|
||||||
|
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||||
|
<h4 class="modal-title"><center>Ha ocurrido un error</center></h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p>Error interno del servidor.</p>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- El servidor respone con un string que no esta en formato JSON o contiene caracteres adicionales al JSON -->
|
||||||
|
<div id="modal_error_parsererror" class="modal fade" role="dialog">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
|
||||||
|
<!-- Modal content-->
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header" id="modal_header_error">
|
||||||
|
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||||
|
<h4 class="modal-title"><center>Ha ocurrido un error</center></h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p>Fallo al procesar el JSON enviado por el servidor.</p>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- El servidortardo demasiado en responder -->
|
||||||
|
<div id="modal_error_timeout" class="modal fade" role="dialog">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
|
||||||
|
<!-- Modal content-->
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header" id="modal_header_error">
|
||||||
|
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||||
|
<h4 class="modal-title"><center>Ha ocurrido un error</center></h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p>La petición excedió el limite de tiempo.</p>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Si el request AJAX falla por alguna razon no listada -->
|
||||||
|
<div id="modal_error_otro" class="modal fade" role="dialog">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
|
||||||
|
<!-- Modal content-->
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header" id="modal_header_error">
|
||||||
|
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||||
|
<h4 class="modal-title"><center>Ha ocurrido un error</center></h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p>Ha ocurrido un error desconocido.</p>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
=================================================================================
|
||||||
|
Respuesta del servidor
|
||||||
|
=================================================================================
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- Si el request AJAX falla por alguna razon no listada -->
|
||||||
|
<div id="modal_respuesa_servidor_error" class="modal fade" role="dialog">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
|
||||||
|
<!-- Modal content-->
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header" id="modal_header_respuesa_servidor_error">
|
||||||
|
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||||
|
<h4 class="modal-title"><center>Ha ocurrido un error</center></h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p id="respuesa_servidor_error"></p>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Si el request AJAX recibe un success en la variable pasasa por el servidor -->
|
||||||
|
<div id="modal_respuesa_servidor_success" class="modal fade" role="dialog">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
|
||||||
|
<!-- Modal content-->
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header" id="modal_header_respuesa_servidor_success">
|
||||||
|
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||||
|
<h4 class="modal-title"><center>El almacenado ha sido exitoso</center></h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p id="respuesa_servidor_success"></p>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
<link href="../css/panel.css" rel="stylesheet">
|
||||||
44
api-payroll/public/html/login.php
Normal file
44
api-payroll/public/html/login.php
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<!-- Latest compiled and minified CSS -->
|
||||||
|
<link rel="stylesheet" href="../css/bootstrap.min.css">
|
||||||
|
|
||||||
|
<!-- jQuery library -->
|
||||||
|
<script src="../js/jquery.min.js"></script>
|
||||||
|
|
||||||
|
<!-- Latest compiled JavaScript -->
|
||||||
|
<script src="../js/bootstrap.min.js"></script>
|
||||||
|
|
||||||
|
<link href='http://fonts.googleapis.com/css?family=Montserrat:400,700' rel='stylesheet' type='text/css'>
|
||||||
|
<div class="container">
|
||||||
|
<div class="logo"></div>
|
||||||
|
<div class="login-block">
|
||||||
|
<form action="" method="post" name="Login_Form" class="login">
|
||||||
|
<h1>Login</h1>
|
||||||
|
<input type="text" value="" placeholder="User" id="userName" name="user" required="" autofocus=""/>
|
||||||
|
<input type="password" value="" placeholder="Password" id="password" name="password" required=""/>
|
||||||
|
<a href="#" class="btn btn-lg btn-warning btn-default" id="loginButon" name="login" value="Login" onclick="processLogin();">Login</a>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="modalLoginError" class="modal fade" role="dialog">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
|
||||||
|
<!-- Modal content-->
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header" id="modalLoginErrorHeader">
|
||||||
|
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||||
|
<h4 class="modal-title"><center>Ha ocurrido un error</center></h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p id="modalLoginErrorBody"></p>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="../js/login.js"></script>
|
||||||
|
<link href="../css/login.css" rel="stylesheet">
|
||||||
BIN
api-payroll/public/imagenes/grey_background.jpg
Normal file
BIN
api-payroll/public/imagenes/grey_background.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
BIN
api-payroll/public/imagenes/login_password.png
Normal file
BIN
api-payroll/public/imagenes/login_password.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
BIN
api-payroll/public/imagenes/login_username.png
Normal file
BIN
api-payroll/public/imagenes/login_username.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
7
api-payroll/public/js/bootstrap.min.js
vendored
Normal file
7
api-payroll/public/js/bootstrap.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2
api-payroll/public/js/jquery.min.js
vendored
Normal file
2
api-payroll/public/js/jquery.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
39
api-payroll/public/js/login.js
Normal file
39
api-payroll/public/js/login.js
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
function getbaseUrl(uriPath){
|
||||||
|
var url = window.location.href;
|
||||||
|
return url.substring(0, url.indexOf(uriPath));
|
||||||
|
}
|
||||||
|
|
||||||
|
function processLogin() {
|
||||||
|
var baseUrl = getbaseUrl('/html/');
|
||||||
|
|
||||||
|
var parametros = {
|
||||||
|
"userName":$('#userName').val(),
|
||||||
|
"password":$('#password').val()
|
||||||
|
};
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: baseUrl + '/index.php/api/session/login',
|
||||||
|
type: 'POST',
|
||||||
|
dataType: 'json',
|
||||||
|
data: parametros,
|
||||||
|
success:function(data){
|
||||||
|
console.log(JSON.stringify(data));
|
||||||
|
if(data["status"] == "success"){
|
||||||
|
redirect(baseUrl + '/html/landing.php');
|
||||||
|
}else if(data["status"] == "success" || (data["status"] === undefined)){
|
||||||
|
$('#modalLoginError').modal('show');
|
||||||
|
document.getElementById('modalLoginErrorBody').innerHTML = "The server didn't respond in time, please try again or refresh this page.";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error:function(x) {
|
||||||
|
if (x.status==500){
|
||||||
|
$('#modalLoginError').modal('show');
|
||||||
|
document.getElementById('modalLoginErrorBody').innerHTML = "The user or password didnt match, please try again";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function redirect(url){
|
||||||
|
window.location.replace(url);
|
||||||
|
}
|
||||||
@@ -1,10 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Application;
|
namespace App\Application;
|
||||||
|
|
||||||
|
use phpDocumentor\Reflection\Types\Integer;
|
||||||
|
|
||||||
class EmployeeApplication{
|
class EmployeeApplication{
|
||||||
private $pdo;
|
private $pdo;
|
||||||
private $cryptographyService;
|
private $cryptographyService;
|
||||||
private $asserts;
|
private $asserts;
|
||||||
|
private $settings;
|
||||||
|
|
||||||
function __construct($employeeSettings, $mysql, $cryptographyService, $asserts){
|
function __construct($employeeSettings, $mysql, $cryptographyService, $asserts){
|
||||||
$this->settings = $employeeSettings;
|
$this->settings = $employeeSettings;
|
||||||
@@ -20,7 +23,12 @@ class EmployeeApplication{
|
|||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function listEmployeeTypes(){
|
function listEmployeeTypes(){
|
||||||
$stmt = $this->pdo->prepare("SELECT id, name FROM employeeType WHERE status = 'ACTIVE'");
|
$stmt = $this->pdo->prepare("SELECT
|
||||||
|
id, name
|
||||||
|
FROM
|
||||||
|
employeeType
|
||||||
|
WHERE
|
||||||
|
status = 'ACTIVE'");
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$results = $stmt->fetchAll();
|
$results = $stmt->fetchAll();
|
||||||
@@ -30,24 +38,29 @@ class EmployeeApplication{
|
|||||||
}
|
}
|
||||||
$stmt = null;
|
$stmt = null;
|
||||||
|
|
||||||
return $results;
|
$employeeTypes = array();
|
||||||
|
foreach($results as $row){
|
||||||
|
$employeeTypes[] = array('id' => (int)$row['id'], 'name' => $row['name']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $employeeTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $firstName varbinary
|
* @param $firstName binary
|
||||||
* @param $middleName varbinary
|
* @param $middleName binary
|
||||||
* @param $lastName varbinary or null
|
* @param $lastName binary or null
|
||||||
* @param $birthDate date yyyy-mm-dd
|
* @param $birthDate date yyyy-mm-dd
|
||||||
* @param $email string
|
* @param $email string
|
||||||
* @param $phone string
|
* @param $phone string
|
||||||
* @return integer
|
* @return integer
|
||||||
*/
|
*/
|
||||||
function saveNewPerson($firstName, $middleName, $lastName, $birthDate, $email, $phone){
|
function saveNewPerson($firstName, $middleName, $lastName, $birthDate, $email, $phone){
|
||||||
$this->asserts->firstName($firstName);
|
$this->asserts->isNotEmpty($firstName, "The first name can't be empty.");
|
||||||
$this->asserts->middleName($middleName);
|
$this->asserts->isNotEmpty($middleName, "The middle name can't be empty.");
|
||||||
$this->asserts->birthDate($birthDate);
|
$this->asserts->isNotEmpty($birthDate, "The birth date can't be empty.");
|
||||||
$this->asserts->email($email);
|
$this->asserts->isNotEmpty($email, "The email can't be empty.");
|
||||||
$this->asserts->phone($phone);
|
$this->asserts->isNotEmpty($phone, "The phone number can't be empty.");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$stmt = $this->pdo->prepare("INSERT INTO persons (firstName, middleName, lastName, birthDate, email, phone)
|
$stmt = $this->pdo->prepare("INSERT INTO persons (firstName, middleName, lastName, birthDate, email, phone)
|
||||||
@@ -76,6 +89,10 @@ class EmployeeApplication{
|
|||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
function savePersonAsEmployee($idEmployeeType, $idPerson, $code, $contractType){
|
function savePersonAsEmployee($idEmployeeType, $idPerson, $code, $contractType){
|
||||||
|
$this->asserts->higherThanZero($idEmployeeType, "idEmployeeType must be higher than 0");
|
||||||
|
$this->asserts->higherThanZero($idPerson, "idPerson must be higher than 0");
|
||||||
|
$this->asserts->isNotEmpty($code, "The code can't be empty.");
|
||||||
|
$this->asserts->isNotEmpty($contractType, "The contract type can't be empty.");
|
||||||
try {
|
try {
|
||||||
$stmt = $this->pdo->prepare("INSERT INTO employees (idEmployeeType, idPerson, code, contractType)
|
$stmt = $this->pdo->prepare("INSERT INTO employees (idEmployeeType, idPerson, code, contractType)
|
||||||
VALUES (:idEmployeeType, :idPerson, :code, :contractType)");
|
VALUES (:idEmployeeType, :idPerson, :code, :contractType)");
|
||||||
@@ -102,21 +119,29 @@ class EmployeeApplication{
|
|||||||
function saveNewEmployee($requestData){
|
function saveNewEmployee($requestData){
|
||||||
// Getting and validating the data
|
// Getting and validating the data
|
||||||
$firstName = $requestData['firstName'];
|
$firstName = $requestData['firstName'];
|
||||||
$this->asserts->firstName($firstName);
|
$this->asserts->isNotEmpty($firstName, "The first name can't be empty.");
|
||||||
|
$this->asserts->isString($firstName, "The first name must be a string.");
|
||||||
|
$this->asserts->betweenLength($firstName, 1, 50, "The first name must have a length between 1 and 50 characters.");
|
||||||
|
|
||||||
$middleName = $requestData['middleName'];
|
$middleName = $requestData['middleName'];
|
||||||
$this->asserts->middleName($middleName);
|
$this->asserts->isNotEmpty($middleName, "The middle name can't be empty.");
|
||||||
|
$this->asserts->isString($middleName, "The middle name must be a string.");
|
||||||
|
$this->asserts->betweenLength($middleName, 1, 50, "The middle name must have a length between 1 and 50 characters.");
|
||||||
|
|
||||||
$lastName = isset($requestData['lastName']) ? $requestData['lastName'] : null;
|
$lastName = isset($requestData['lastName'])
|
||||||
|
? $requestData['lastName']
|
||||||
|
: null;
|
||||||
|
|
||||||
$birthDate = $requestData['birthDate'];
|
$birthDate = $requestData['birthDate'];
|
||||||
$this->asserts->birthDate($birthDate);
|
$this->asserts->isNotEmpty($birthDate, "The birth date can't be empty.");
|
||||||
|
|
||||||
$email = $requestData['email'];
|
$email = $requestData['email'];
|
||||||
$this->asserts->email($email);
|
$this->asserts->isNotEmpty($email, "The email can't be empty.");
|
||||||
|
$this->asserts->betweenLength($email, 1, 100, "The middle name must have a length between 1 and 100 characters.");
|
||||||
|
|
||||||
$phone = $requestData['phone'];
|
$phone = $requestData['phone'];
|
||||||
$this->asserts->phone($phone);
|
$this->asserts->isNotEmpty($phone, "The phone number can't be empty.");
|
||||||
|
$this->asserts->betweenLength($phone, 10, 10, "The phone number must be 10 digits without special characters.");
|
||||||
|
|
||||||
$idEmployeeType = $requestData{'idEmployeeType'};
|
$idEmployeeType = $requestData{'idEmployeeType'};
|
||||||
$contractType = $requestData{'contractType'};
|
$contractType = $requestData{'contractType'};
|
||||||
@@ -150,5 +175,341 @@ class EmployeeApplication{
|
|||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $idEmployee
|
||||||
|
* @return Integer
|
||||||
|
*/
|
||||||
|
function getIdPersonByIdEmployee($idEmployee){
|
||||||
|
$this->asserts->higherThanZero($idEmployee, "idEmployee must be higher than 0");
|
||||||
|
|
||||||
|
$stmt = $this->pdo->prepare("SELECT
|
||||||
|
COALESCE((SELECT
|
||||||
|
idPerson
|
||||||
|
FROM
|
||||||
|
employees
|
||||||
|
WHERE
|
||||||
|
id = :idEmployee),
|
||||||
|
0) AS id");
|
||||||
|
|
||||||
|
$stmt->execute(array(':idEmployee' => $idEmployee));
|
||||||
|
$results = $stmt->fetchAll();
|
||||||
|
if(!$results){
|
||||||
|
exit($this->databaseSelectQueryErrorMessage);
|
||||||
|
}
|
||||||
|
$stmt = null;
|
||||||
|
|
||||||
|
return $results[0]['id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $code string
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
function getIdEmployeeTypeByCode($code){
|
||||||
|
$this->asserts->isNotEmpty($code, "The code can't be empty.");
|
||||||
|
|
||||||
|
$stmt = $this->pdo->prepare("SELECT COALESCE((SELECT
|
||||||
|
et.id
|
||||||
|
FROM
|
||||||
|
employees e
|
||||||
|
INNER JOIN
|
||||||
|
employeeType et ON et.id = e.idEmployeeType
|
||||||
|
WHERE
|
||||||
|
e.code = :code), 0) AS id");
|
||||||
|
|
||||||
|
$stmt->execute(array(':code' => $code));
|
||||||
|
$results = $stmt->fetchAll();
|
||||||
|
if(!$results){
|
||||||
|
exit($this->databaseSelectQueryErrorMessage);
|
||||||
|
}
|
||||||
|
$stmt = null;
|
||||||
|
|
||||||
|
return $results[0]['id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the data associated with the employee
|
||||||
|
*
|
||||||
|
* @param $idEmployee
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function getEmployeeDataById($idEmployee){
|
||||||
|
$this->asserts->higherThanZero($idEmployee, "idEmployee must be higher than 0");
|
||||||
|
|
||||||
|
$stmt = $this->pdo->prepare("SELECT
|
||||||
|
p.id AS idPerson,
|
||||||
|
p.firstName,
|
||||||
|
p.middleName,
|
||||||
|
IFNULL(p.lastName, '') AS lastName,
|
||||||
|
p.email,
|
||||||
|
p.phone,
|
||||||
|
e.code,
|
||||||
|
e.contractType
|
||||||
|
FROM
|
||||||
|
employees e
|
||||||
|
INNER JOIN
|
||||||
|
persons p ON p.id = e.idPerson
|
||||||
|
WHERE
|
||||||
|
e.id = :idEmployee");
|
||||||
|
|
||||||
|
$stmt->execute(array(':idEmployee' => $idEmployee));
|
||||||
|
$results = $stmt->fetchAll();
|
||||||
|
if(!$results){
|
||||||
|
exit($this->databaseSelectQueryErrorMessage);
|
||||||
|
}
|
||||||
|
$stmt = null;
|
||||||
|
|
||||||
|
return $results[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Acts as a man in the middle for the getEmployeeDataById method to decrypt the contents
|
||||||
|
* and make the necesary data manipulations
|
||||||
|
*
|
||||||
|
* @param $idEmployee
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function proxyGetEmployeeDataById($idEmployee){
|
||||||
|
$this->asserts->higherThanZero($idEmployee, "idEmployee must be higher than 0");
|
||||||
|
|
||||||
|
$employeeData = $this->getEmployeeDataById($idEmployee);
|
||||||
|
|
||||||
|
$response = array(
|
||||||
|
"idPerson" => (int)$employeeData['idPerson'],
|
||||||
|
"firstName" => $this->cryptographyService->decryptString($employeeData['firstName']),
|
||||||
|
"middleName" => $this->cryptographyService->decryptString($employeeData['middleName']),
|
||||||
|
|
||||||
|
"lastName" => strlen($employeeData['lastName']) > 0
|
||||||
|
? $this->cryptographyService->decryptString($employeeData['lastName'])
|
||||||
|
: '',
|
||||||
|
|
||||||
|
"email" => $this->cryptographyService->decryptString($employeeData['email']),
|
||||||
|
"phone" => $employeeData['phone'],
|
||||||
|
"code" => $employeeData['code'],
|
||||||
|
"contractType" => $employeeData['contractType']
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $code string
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function getEmployeeDataByCode($code){
|
||||||
|
$this->asserts->isNotEmpty($code, "The code can't be empty.");
|
||||||
|
|
||||||
|
$idEmployee = $this->getIdEmployeeTypeByCode($code);
|
||||||
|
|
||||||
|
return $this->proxyGetEmployeeDataById($idEmployee);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $idPerson integer
|
||||||
|
* @param $firstName binary
|
||||||
|
* @param $middleName binary
|
||||||
|
* @param $lastName binary
|
||||||
|
* @param $birthDate date
|
||||||
|
* @param $email binary
|
||||||
|
* @param $phone string
|
||||||
|
*/
|
||||||
|
function updatePerson($idPerson, $firstName, $middleName, $lastName, $birthDate, $email, $phone){
|
||||||
|
$this->asserts->higherThanZero($idPerson, "idPerson must be higher than 0");
|
||||||
|
$this->asserts->isNotEmpty($firstName, "The first name can't be empty.");
|
||||||
|
$this->asserts->isNotEmpty($middleName, "The middle name can't be empty.");
|
||||||
|
$this->asserts->isNotEmpty($birthDate, "The birth date can't be empty.");
|
||||||
|
$this->asserts->isNotEmpty($email, "The email can't be empty.");
|
||||||
|
$this->asserts->isNotEmpty($phone, "The phone number can't be empty.");
|
||||||
|
|
||||||
|
try {
|
||||||
|
$stmt = $this->pdo->prepare("UPDATE persons
|
||||||
|
SET
|
||||||
|
firstName = :firstName,
|
||||||
|
middleName = :middleName,
|
||||||
|
lastName = :lastName,
|
||||||
|
birthDate = :birthDate,
|
||||||
|
email = :email,
|
||||||
|
phone = :phone
|
||||||
|
WHERE
|
||||||
|
id = :idPerson");
|
||||||
|
$this->pdo->beginTransaction();
|
||||||
|
$stmt->execute(array(':firstName' => $firstName, ':middleName' => $middleName, ':lastName' => $lastName,
|
||||||
|
':birthDate' => $birthDate, ':email' => $email, ':phone' => $phone, ':idPerson' => $idPerson));
|
||||||
|
$this->pdo->commit();
|
||||||
|
|
||||||
|
$stmt = null;
|
||||||
|
} catch( PDOExecption $e ) {
|
||||||
|
$this->pdo->rollback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $idEmployee integer
|
||||||
|
* @param $code string
|
||||||
|
* @param $idEmployeeType integer
|
||||||
|
* @param $contractType string
|
||||||
|
*/
|
||||||
|
function updateEmployee($idEmployee, $code, $idEmployeeType, $contractType){
|
||||||
|
$this->asserts->higherThanZero($idEmployee, "idEmployee must be higher than 0");
|
||||||
|
$this->asserts->isNotEmpty($code, "The code can't be empty.");
|
||||||
|
$this->asserts->higherThanZero($idEmployeeType, "idEmployeeType must be higher than 0");
|
||||||
|
$this->asserts->isNotEmpty($contractType, "The contract type can't be empty.");
|
||||||
|
|
||||||
|
try {
|
||||||
|
$stmt = $this->pdo->prepare("UPDATE employees
|
||||||
|
SET
|
||||||
|
idEmployeeType = :idEmployeeType,
|
||||||
|
code = :code,
|
||||||
|
contractType = :contractType
|
||||||
|
WHERE
|
||||||
|
id = :idEmployee");
|
||||||
|
$this->pdo->beginTransaction();
|
||||||
|
$stmt->execute(array(':idEmployeeType' => $idEmployeeType, ':code' => $code, ':contractType' => $contractType,
|
||||||
|
':idEmployee' => $idEmployee));
|
||||||
|
$this->pdo->commit();
|
||||||
|
|
||||||
|
$stmt = null;
|
||||||
|
} catch( PDOExecption $e ) {
|
||||||
|
$this->pdo->rollback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $requestData object
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function updateEmployeeData($requestData){
|
||||||
|
// Getting and validating the data
|
||||||
|
$idEmployee = $requestData['idEmployee'];
|
||||||
|
$this->asserts->higherThanZero($idEmployee, "idEmployee must be higher than 0");
|
||||||
|
|
||||||
|
$idPerson = $this->getIdPersonByIdEmployee($idEmployee);
|
||||||
|
$this->asserts->higherThanZero($idPerson, "idPerson must be higher than 0");
|
||||||
|
|
||||||
|
$code = $requestData['code'];
|
||||||
|
$this->asserts->isNotEmpty($code, "The code can't be empty.");
|
||||||
|
|
||||||
|
$firstName = $requestData['firstName'];
|
||||||
|
$this->asserts->isNotEmpty($firstName, "The first name can't be empty.");
|
||||||
|
$this->asserts->isString($firstName, "The first name must be a string.");
|
||||||
|
$this->asserts->betweenLength($firstName, 1, 50, "The first name must have a length between 1 and 50 characters.");
|
||||||
|
|
||||||
|
$middleName = $requestData['middleName'];
|
||||||
|
$this->asserts->isNotEmpty($middleName, "The middle name can't be empty.");
|
||||||
|
$this->asserts->isString($middleName, "The middle name must be a string.");
|
||||||
|
$this->asserts->betweenLength($middleName, 1, 50, "The middle name must have a length between 1 and 50 characters.");
|
||||||
|
|
||||||
|
$lastName = isset($requestData['lastName']) ? $requestData['lastName'] : null;
|
||||||
|
|
||||||
|
$birthDate = $requestData['birthDate'];
|
||||||
|
$this->asserts->isNotEmpty($birthDate, "The birth date can't be empty.");
|
||||||
|
|
||||||
|
$email = $requestData['email'];
|
||||||
|
$this->asserts->isNotEmpty($email, "The email can't be empty.");
|
||||||
|
$this->asserts->betweenLength($email, 1, 100, "The middle name must have a length between 1 and 100 characters.");
|
||||||
|
|
||||||
|
$phone = $requestData['phone'];
|
||||||
|
$this->asserts->isNotEmpty($phone, "The phone number can't be empty.");
|
||||||
|
$this->asserts->betweenLength($phone, 10, 10, "The phone number must be 10 digits without special characters.");
|
||||||
|
|
||||||
|
$idEmployeeType = $requestData{'idEmployeeType'};
|
||||||
|
$this->asserts->higherThanZero($idEmployeeType, "idEmployeeType must be higher than 0");
|
||||||
|
|
||||||
|
$contractType = $requestData{'contractType'};
|
||||||
|
$this->asserts->isNotEmpty($contractType, "The contract type can't be empty.");
|
||||||
|
|
||||||
|
// Encrypting the sensitive data
|
||||||
|
$securedFirstName = $this->cryptographyService->encryptString($firstName);
|
||||||
|
$securedMiddleName = $this->cryptographyService->encryptString($middleName);
|
||||||
|
|
||||||
|
if (isset($lastName)) {
|
||||||
|
$securedLastName = $this->cryptographyService->encryptString($lastName);
|
||||||
|
} else {
|
||||||
|
$securedLastName = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$securedEmail = $this->cryptographyService->encryptString($email);
|
||||||
|
|
||||||
|
// Update process
|
||||||
|
$this->updatePerson($idPerson, $securedFirstName, $securedMiddleName, $securedLastName,
|
||||||
|
$birthDate, $securedEmail, $phone);
|
||||||
|
|
||||||
|
$this->updateEmployee($idEmployee, $code, $idEmployeeType, $contractType);
|
||||||
|
|
||||||
|
$response = array(
|
||||||
|
"fullName" => "$firstName $middleName $lastName",
|
||||||
|
"idEmployee" => $idEmployee,
|
||||||
|
"email" => $email,
|
||||||
|
"phone" => $phone,
|
||||||
|
"birthDate" => $birthDate,
|
||||||
|
"idEmployeeType" => $idEmployeeType,
|
||||||
|
"contractType" => $contractType
|
||||||
|
);
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
function disableEmployeeRecord($idEmployee){
|
||||||
|
$this->asserts->higherThanZero($idEmployee, "idEmployee must be higher than 0");
|
||||||
|
|
||||||
|
try {
|
||||||
|
$stmt = $this->pdo->prepare("UPDATE employees
|
||||||
|
SET
|
||||||
|
status = 'INACTIVE'
|
||||||
|
WHERE
|
||||||
|
id = :idEmployee");
|
||||||
|
$this->pdo->beginTransaction();
|
||||||
|
$stmt->execute(array(':idEmployee' => $idEmployee));
|
||||||
|
$this->pdo->commit();
|
||||||
|
|
||||||
|
$stmt = null;
|
||||||
|
} catch( PDOExecption $e ) {
|
||||||
|
$this->pdo->rollback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Intended for internal use
|
||||||
|
*
|
||||||
|
* This method will bring a list of ids of all the employees that are
|
||||||
|
* currently active in the system
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function getIdEmployeeFromAllActiveEmployees(){
|
||||||
|
$stmt = $this->pdo->prepare("SELECT
|
||||||
|
id
|
||||||
|
FROM
|
||||||
|
employees
|
||||||
|
WHERE
|
||||||
|
status = 'ACTIVE';");
|
||||||
|
$stmt->execute();
|
||||||
|
|
||||||
|
$results = $stmt->fetchAll();
|
||||||
|
|
||||||
|
if(!$results){
|
||||||
|
exit($this->databaseSelectQueryErrorMessage);
|
||||||
|
}
|
||||||
|
$stmt = null;
|
||||||
|
|
||||||
|
return $results;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function listAllActiveEmployees(){
|
||||||
|
$ids = $this->getIdEmployeeFromAllActiveEmployees();
|
||||||
|
|
||||||
|
$result = array();
|
||||||
|
|
||||||
|
foreach($ids as $row){
|
||||||
|
$result[] = $this->proxyGetEmployeeDataById($row['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -41,15 +41,18 @@ class SessionApplication{
|
|||||||
/**
|
/**
|
||||||
* @param $userName string
|
* @param $userName string
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
function getPassword($userName){
|
function getPassword($userName){
|
||||||
$this->asserts->userName($userName);
|
$this->asserts->isNotEmpty($userName, "The username can't be empty");
|
||||||
|
$this->asserts->isString($userName, "The username must be a string.");
|
||||||
|
$this->asserts->betweenLength($userName, 1, 50, "The username must have a length between 1 and 50 characters.");
|
||||||
|
|
||||||
$stmt = $this->pdo->prepare("SELECT password FROM users WHERE name = :userName");
|
$stmt = $this->pdo->prepare("SELECT password FROM users WHERE name = :userName");
|
||||||
$stmt->execute(array(':userName' => $userName));
|
$stmt->execute(array(':userName' => $userName));
|
||||||
$results = $stmt->fetchAll();
|
$results = $stmt->fetchAll();
|
||||||
if(!$results){
|
if(!$results){
|
||||||
exit($this->databaseSelectQueryErrorMessage);
|
throw new Exception('The user or password didnt match, please try again.');
|
||||||
}
|
}
|
||||||
$stmt = null;
|
$stmt = null;
|
||||||
return $results[0]['password'];
|
return $results[0]['password'];
|
||||||
@@ -62,14 +65,18 @@ class SessionApplication{
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
function newSession($userName, $password){
|
function newSession($userName, $password){
|
||||||
$this->asserts->userName($userName);
|
$this->asserts->isNotEmpty($userName, "The username can't be empty");
|
||||||
$this->asserts->password($password);
|
$this->asserts->isString($userName, "The username must be a string.");
|
||||||
|
$this->asserts->betweenLength($userName, 1, 50, "The username must have a length between 1 and 50 characters.");
|
||||||
|
$this->asserts->isNotEmpty($password, "The password can't be empty");
|
||||||
|
$this->asserts->isString($password, "The password must be a string.");
|
||||||
|
$this->asserts->betweenLength($password, 1, 50, "The password must have a length between 1 and 50 characters.");
|
||||||
|
|
||||||
$storedPassword = $this->getPassword($userName);
|
$storedPassword = $this->getPassword($userName);
|
||||||
|
|
||||||
// If the credentials don't match anything in the the records
|
// If the credentials don't match anything in the the records
|
||||||
if(!isset($storedPassword)){
|
if(!isset($storedPassword)){
|
||||||
throw new Exception('The user or password didnt match, please try again.');
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Already has a session
|
// Already has a session
|
||||||
@@ -82,7 +89,30 @@ class SessionApplication{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
return false;
|
throw new Exception('The user or password didnt match, please try again.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $userName
|
||||||
|
* @param $password
|
||||||
|
* @return array
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
function login($userName, $password){
|
||||||
|
$this->asserts->isNotEmpty($userName, "The username can't be empty");
|
||||||
|
$this->asserts->isString($userName, "The username must be a string.");
|
||||||
|
$this->asserts->betweenLength($userName, 1, 50, "The username must have a length between 1 and 50 characters.");
|
||||||
|
$this->asserts->isNotEmpty($password, "The password can't be empty");
|
||||||
|
$this->asserts->isString($password, "The password must be a string.");
|
||||||
|
$this->asserts->betweenLength($password, 1, 50, "The password must have a length between 1 and 50 characters.");
|
||||||
|
|
||||||
|
|
||||||
|
if($this->newSession($userName, $password)){
|
||||||
|
return array('status' => 'success', 'message' => 'Logged in successfully.');
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
throw new Exception('The user or password didnt match, please try again.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ $container['mysql'] = function ($c) {
|
|||||||
|
|
||||||
// The database parameters
|
// The database parameters
|
||||||
$host = $mysqlSettings['host'];
|
$host = $mysqlSettings['host'];
|
||||||
|
$port = $mysqlSettings['port'];
|
||||||
$database = $mysqlSettings['database'];
|
$database = $mysqlSettings['database'];
|
||||||
$user = $mysqlSettings['user'];
|
$user = $mysqlSettings['user'];
|
||||||
$password = $mysqlSettings['password'];
|
$password = $mysqlSettings['password'];
|
||||||
@@ -34,7 +35,7 @@ $container['mysql'] = function ($c) {
|
|||||||
$databaseConnectionErrorMessage = $mysqlSettings['databaseConnectionErrorMessage'];
|
$databaseConnectionErrorMessage = $mysqlSettings['databaseConnectionErrorMessage'];
|
||||||
|
|
||||||
// Initiate the connection
|
// Initiate the connection
|
||||||
$dsn = "mysql:host=$host;dbname=$database;charset=$charset";
|
$dsn = "mysql:host=$host;port=$port;dbname=$database;charset=$charset";
|
||||||
try {
|
try {
|
||||||
$pdo = new PDO($dsn, $user, $password, $pdoConnectionOptions);
|
$pdo = new PDO($dsn, $user, $password, $pdoConnectionOptions);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
@@ -69,4 +70,4 @@ $container['employeeApplication'] = function ($c) {
|
|||||||
$employeeApplication = new App\Application\EmployeeApplication($employeeSettings,
|
$employeeApplication = new App\Application\EmployeeApplication($employeeSettings,
|
||||||
$c['mysql'], $c['cryptographyService'], $c['asserts']);
|
$c['mysql'], $c['cryptographyService'], $c['asserts']);
|
||||||
return $employeeApplication;
|
return $employeeApplication;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -22,14 +22,14 @@ $app->get('/api/session', function (Request $request, Response $response, array
|
|||||||
$app->post('/api/session/login', function ($request, $response) {
|
$app->post('/api/session/login', function ($request, $response) {
|
||||||
$requestData = $request->getParsedBody();
|
$requestData = $request->getParsedBody();
|
||||||
|
|
||||||
$data = $this->sessionApplication->newSession($requestData['userName'], $requestData['password']);
|
$data = $this->sessionApplication->login($requestData['userName'], $requestData['password']);
|
||||||
|
|
||||||
return $response->withStatus(200)
|
return $response->withStatus(200)
|
||||||
->withHeader('Content-Type', 'application/json')
|
->withHeader('Content-Type', 'application/json')
|
||||||
->write(json_encode($data));
|
->write(json_encode($data));
|
||||||
});
|
});
|
||||||
|
|
||||||
$app->post('/api/session/logout', function (Request $request, Response $response, array $args) {
|
$app->get('/api/session/logout', function (Request $request, Response $response, array $args) {
|
||||||
return $response->withStatus(200)
|
return $response->withStatus(200)
|
||||||
->withHeader('Content-Type', 'application/json')
|
->withHeader('Content-Type', 'application/json')
|
||||||
->write(json_encode($this->sessionApplication->destroySession()));
|
->write(json_encode($this->sessionApplication->destroySession()));
|
||||||
@@ -41,6 +41,12 @@ $app->get('/api/employee/types', function (Request $request, Response $response,
|
|||||||
->write(json_encode($this->employeeApplication->listEmployeeTypes()));
|
->write(json_encode($this->employeeApplication->listEmployeeTypes()));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$app->get('/api/employee/all', function (Request $request, Response $response, array $args) {
|
||||||
|
return $response->withStatus(200)
|
||||||
|
->withHeader('Content-Type', 'application/json')
|
||||||
|
->write(json_encode($this->employeeApplication->listAllActiveEmployees()));
|
||||||
|
});
|
||||||
|
|
||||||
$app->post('/api/employee', function ($request, $response) {
|
$app->post('/api/employee', function ($request, $response) {
|
||||||
$requestData = $request->getParsedBody();
|
$requestData = $request->getParsedBody();
|
||||||
|
|
||||||
@@ -48,3 +54,43 @@ $app->post('/api/employee', function ($request, $response) {
|
|||||||
->withHeader('Content-Type', 'application/json')
|
->withHeader('Content-Type', 'application/json')
|
||||||
->write(json_encode($this->employeeApplication->saveNewEmployee($requestData)));
|
->write(json_encode($this->employeeApplication->saveNewEmployee($requestData)));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$app->put('/api/employee', function ($request, $response) {
|
||||||
|
$requestData = $request->getParsedBody();
|
||||||
|
|
||||||
|
return $response->withStatus(200)
|
||||||
|
->withHeader('Content-Type', 'application/json')
|
||||||
|
->write(json_encode($this->employeeApplication->updateEmployeeData($requestData)));
|
||||||
|
});
|
||||||
|
|
||||||
|
$app->DELETE('/api/employee/{idEmployee}', function (Request $request, Response $response, array $args) {
|
||||||
|
$idEmployee = $args['idEmployee'];
|
||||||
|
|
||||||
|
return $response->withStatus(200)
|
||||||
|
->withHeader('Content-Type', 'application/json')
|
||||||
|
->write(json_encode($this->employeeApplication->disableEmployeeRecord($idEmployee)));
|
||||||
|
});
|
||||||
|
|
||||||
|
$app->get('/api/employee/type/{code}', function (Request $request, Response $response, array $args) {
|
||||||
|
$code = $args['code'];
|
||||||
|
|
||||||
|
return $response->withStatus(200)
|
||||||
|
->withHeader('Content-Type', 'application/json')
|
||||||
|
->write(json_encode($this->employeeApplication->getIdEmployeeTypeByCode($code)));
|
||||||
|
});
|
||||||
|
|
||||||
|
$app->get('/api/employee/id/{idEmployee}', function (Request $request, Response $response, array $args) {
|
||||||
|
$idEmployee = $args['idEmployee'];
|
||||||
|
|
||||||
|
return $response->withStatus(200)
|
||||||
|
->withHeader('Content-Type', 'application/json')
|
||||||
|
->write(json_encode($this->employeeApplication->proxyGetEmployeeDataById($idEmployee)));
|
||||||
|
});
|
||||||
|
|
||||||
|
$app->get('/api/employee/code/{code}', function (Request $request, Response $response, array $args) {
|
||||||
|
$code = $args['code'];
|
||||||
|
|
||||||
|
return $response->withStatus(200)
|
||||||
|
->withHeader('Content-Type', 'application/json')
|
||||||
|
->write(json_encode($this->employeeApplication->getEmployeeDataByCode($code)));
|
||||||
|
});
|
||||||
@@ -6,78 +6,54 @@ use Respect\Validation\Validator as v;
|
|||||||
|
|
||||||
class Asserts{
|
class Asserts{
|
||||||
/**
|
/**
|
||||||
* @param $string
|
* @param $string string
|
||||||
|
* @param $errorMessage string
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
function userName($string){
|
function isString($string, $errorMessage){
|
||||||
$validateFirstName = v::stringType()->notEmpty()->length(1, 50)->validate($string);
|
$validation = v::stringType()->validate($string);
|
||||||
|
|
||||||
if(!$validateFirstName){
|
if(!$validation){
|
||||||
throw new Exception('The user name must be a string between 1 and 50 characters');
|
throw new Exception($errorMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $string
|
* @param $string string
|
||||||
|
* @param $errorMessage string
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
function password($string){
|
function isNotEmpty($string, $errorMessage){
|
||||||
$validateFirstName = v::stringType()->notEmpty()->length(1, 50)->validate($string);
|
$validation = v::notEmpty()->validate($string);
|
||||||
|
|
||||||
if(!$validateFirstName){
|
if(!$validation){
|
||||||
throw new Exception('The password must be a string between 1 and 50 characters');
|
throw new Exception($errorMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $string
|
* @param $string string
|
||||||
|
* @param $min integer
|
||||||
|
* @param $max integer
|
||||||
|
* @param $errorMessage string
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
function firstName($string){
|
function betweenLength($string, $min, $max, $errorMessage){
|
||||||
$validateFirstName = v::stringType()->notEmpty()->length(1, 100)->validate($string);
|
$validation = v::length($min, $max)->validate($string);
|
||||||
|
|
||||||
if(!$validateFirstName){
|
if(!$validation){
|
||||||
throw new Exception('The first name must be a string between 1 and 100 characters');
|
throw new Exception($errorMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $string
|
* @param $number integer
|
||||||
|
* @param $errorMessage string
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
function middleName($string){
|
function higherThanZero($number, $errorMessage){
|
||||||
if(!v::stringType()->notEmpty()->length(1, 100)->validate($string)){
|
if($number <= 0){
|
||||||
throw new Exception('The middle name must be a string between 1 and 100 characters');
|
throw new Exception($errorMessage);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $string
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
function birthDate($string){
|
|
||||||
if(!v::date('Y-m-d')->notEmpty()->validate($string)){
|
|
||||||
throw new Exception('The birth date must be in the yyyy-mm-dd format');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $string
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
function email($string){
|
|
||||||
if(!v::stringType()->notEmpty()->length(1, 100)->validate($string)){
|
|
||||||
throw new Exception('The email must be a string between 1 and 100 characters');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $string
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
function phone($string){
|
|
||||||
if(!v::digit()->notEmpty()->length(10, 10)->validate($string)){
|
|
||||||
throw new Exception('The phone must be a numeric value of 10 digits');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ return [
|
|||||||
|
|
||||||
// Datanase settings
|
// Datanase settings
|
||||||
'mysql' => [
|
'mysql' => [
|
||||||
'host' => 'localhost',
|
'host' => 'mysql',
|
||||||
|
'port' => '3307',
|
||||||
'database' => 'payroll',
|
'database' => 'payroll',
|
||||||
'user' => 'root',
|
'user' => 'root',
|
||||||
'password' => '12345678',
|
'password' => '12345678',
|
||||||
@@ -43,7 +44,7 @@ return [
|
|||||||
|
|
||||||
// Employee settings
|
// Employee settings
|
||||||
'employee' => [
|
'employee' => [
|
||||||
'codeLength' => '5',
|
'codeLength' => '3',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|||||||
1
database/.dockerignore
Normal file
1
database/.dockerignore
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Dockerfile
|
||||||
7
database/Dockerfile
Normal file
7
database/Dockerfile
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
FROM mysql:5.7
|
||||||
|
|
||||||
|
# Starting scripts
|
||||||
|
ADD . /docker-entrypoint-initdb.d
|
||||||
|
|
||||||
|
# Config
|
||||||
|
ADD my.cnf /etc/mysql
|
||||||
20
database/my.cnf
Normal file
20
database/my.cnf
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; version 2 of the License.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
[mysqld]
|
||||||
|
port = 3307
|
||||||
|
|
||||||
|
!includedir /etc/mysql/conf.d/
|
||||||
|
!includedir /etc/mysql/mysql.conf.d/
|
||||||
28
docker-compose.yml
Normal file
28
docker-compose.yml
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
version: '3'
|
||||||
|
services:
|
||||||
|
api:
|
||||||
|
container_name: payroll_api
|
||||||
|
build: api-payroll/
|
||||||
|
ports:
|
||||||
|
- "8085:80"
|
||||||
|
volumes:
|
||||||
|
- api-payroll:/var/www/site
|
||||||
|
depends_on:
|
||||||
|
- mysql
|
||||||
|
mysql:
|
||||||
|
container_name: payroll_mysql
|
||||||
|
restart: always
|
||||||
|
build: database
|
||||||
|
expose:
|
||||||
|
- "3307"
|
||||||
|
ports:
|
||||||
|
- "3307:3307"
|
||||||
|
volumes:
|
||||||
|
- my-datavolume:/var/lib/mysql
|
||||||
|
environment:
|
||||||
|
MYSQL_ROOT_PASSWORD: '12345678'
|
||||||
|
MYSQL_USER: 'sloth'
|
||||||
|
MYSQL_PASS: '12345678'
|
||||||
|
volumes:
|
||||||
|
api-payroll:
|
||||||
|
my-datavolume:
|
||||||
Reference in New Issue
Block a user