Compare commits

...

26 Commits

Author SHA1 Message Date
abd8168dbf [add] Asserting email type 2018-08-12 17:15:39 -06:00
79059fb91b [mod] Updated html and css references 2018-08-12 16:59:46 -06:00
1b2484fbf2 [fix] Phone number length in database 2018-08-12 16:27:05 -06:00
168a6a352e [add] Displaying data post save 2018-08-12 16:25:23 -06:00
8185a42331 [add] Saving new employee 2018-08-12 15:54:56 -06:00
64a6ddafb5 [add] Datepicker 2018-08-12 15:38:09 -06:00
54ef088fe0 [add] New employee form layout 2018-08-12 14:39:47 -06:00
b829f09330 [fix] Reference to view body 2018-08-12 11:36:17 -06:00
b03d152f11 [add] Loading views 2018-08-12 11:32:48 -06:00
0ec20a4c67 [add] Logout uses generic error messages
Refactored some messages from the generic modals
2018-08-12 10:39:44 -06:00
1605b1cea3 Merge pull request #17 from PootisPenserHere/interactionBetweenLoginAndPanel
Interaction between login and panel
2018-08-12 10:08:54 -06:00
d4fadf08bc [add] Logout
Also made general fixes to the css
2018-08-12 10:03:25 -06:00
de84da4482 [add] Mapping enter key 2018-08-12 09:13:00 -06:00
697d0fe769 [mod] getBaseUrl moved to its own file 2018-08-12 09:07:48 -06:00
cb5d30b4e0 [add] Verifying session 2018-08-12 08:51:22 -06:00
6c91cad46c Merge pull request #16 from PootisPenserHere/qualityChangesToDocker
Quality changes to docker
2018-08-11 20:07:07 -06:00
ccd9e10351 Merge pull request #15 from PootisPenserHere/landingPage
Landing page
2018-08-11 20:06:13 -06:00
231e7fe2e6 [add] Access config 2018-08-12 01:43:37 +00:00
f820a22a4f [add] Volumes directory 2018-08-12 01:25:11 +00:00
0cdfd21fa2 [mod] Config files moved to a directory 2018-08-12 01:06:40 +00:00
fee3db486f [add] Composer decoupled from prod build 2018-08-12 00:58:12 +00:00
87181696e1 [add] Looks of the dockerfile 2018-08-12 00:49:03 +00:00
8b22c0db9c [add] Composer compileed in multi stagre 2018-08-12 00:38:39 +00:00
18ee0ad333 [add] Downloading composer dependencies 2018-08-10 06:53:13 +00:00
4928481f72 [add] Empty log file with permisions 2018-08-10 03:51:17 +00:00
Jose Pablo Domingo Aramburo Sanchez
2d11218076 [fix] php volume 2018-08-09 13:42:13 -06:00
23 changed files with 452 additions and 131 deletions

View File

@@ -1 +1,2 @@
Options -Indexes
Deny from all

View File

@@ -1,10 +1,29 @@
# Stage 1 - the build process
FROM composer:1.7.1 as build-deps
ENV COMPOSER_ALLOW_SUPERUSER 1
WORKDIR /root
COPY . .
RUN composer install
RUN composer test
# Stage 2 - the production environment
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
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
# Enable apache mods
RUN a2enmod php7.0
@@ -20,24 +39,14 @@ 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
COPY --from=build-deps /root .
# Testing permisions
RUN chmod 777 -R .
RUN touch logs/app.log
RUN chmod 777 logs/app.log
# Installing dependencies
RUN composer install
# Update the default apache site
ADD docker/apache-config.conf /etc/apache2/sites-enabled/000-default.conf
# 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
# By default start up apache in the foreground
CMD /usr/sbin/apache2ctl -D FOREGROUND

0
api-payroll/logs/app.log Executable file
View File

View File

@@ -1,3 +1,5 @@
allow from all
<IfModule mod_rewrite.c>
RewriteEngine On

File diff suppressed because one or more lines are too long

View File

@@ -1,24 +1,13 @@
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{
#newViewBody{
top:17%;
left:1%;
width:98%;
@@ -34,51 +23,47 @@ body {
}
#cuerpo .modal-body{
#newViewBody .modal-body{
color: #000;
border:none;
}
#cuerpo .panel-default{
#newViewBody .panel-default{
border: 3px solid #4A89A5;
border-radius: 5px;
}
#cuerpo .panel > .panel-heading {
#newViewBody .panel > .panel-heading {
background-image: none;
background-color: #4A89A5;
color: white;
border-radius: 0;
}
#cuerpo .btn-default{
#newViewBody .btn-default{
border: 2px solid #62655F;
background: #F9DFAF;
}
#cuerpo .btn-default:hover{
#newViewBody .btn-default:hover{
border: 2px solid #62655F;
background: #F9DFAF;
}
#cuerpo .alert-success{
#newViewBody .alert-success{
background: #C6E97C;
}
#modal_header_error{
.modalHeaderError{
background-color: #d9534f;
}
#modal_header_respuesa_servidor_error{
background-color: #d9534f;
}
#modal_header_respuesa_servidor_success{
.modalHeaderSuccess{
background-color: #5bc0de;
}
/* botoner<65>a panel principal */
.metro{
width:auto;
height:auto;
@@ -199,7 +184,7 @@ body {
}
}
/* FORMATO PARA TEXTO CUSTOM */
.formato_texto_custom{
width: 97%;
float: left;

View File

@@ -18,7 +18,7 @@ body {
padding: 20px;
background: #fff;
border-radius: 5px;
border-top: 5px solid #bdb035;
border-top: 5px solid #5bc0de;
margin: 0 auto;
}
.login-block h1 {
@@ -58,15 +58,15 @@ body {
background-size: 16px 80px;
}
.login-block input:active, .login-block input:focus {
border: 1px solid #bdb035;
border: 1px solid #5bc0de;
}
.login-block #loginButon {
width: 100%;
height: 40px;
background: #bdb035;
background: #009bad;
box-sizing: border-box;
border-radius: 5px;
border: 1px solid #6d661c;
border: 1px solid #000;
color: #fff;
font-weight: bold;
text-transform: uppercase;
@@ -75,7 +75,7 @@ body {
outline: none;
cursor: pointer;
}
.login-block button:hover {
background: #c7b935;
border: 1px solid #6d661c;
}
#modalLoginErrorHeader{
background-color: #d9534f;
}

View File

@@ -0,0 +1,93 @@
<script src="../js/NewEmployee.js"></script>
<script src="../js/getBaseUrl.js"></script>
<form class="form-horizontal" id="newEmployeeForm">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">New employee</h3>
</div>
<div class="panel-body">
<div class="col-md-6">
<div class="row">
<div class="form-group">
<label class="col-md-4 control-label" for="newEmployeeFirstName">First name</label>
<div class="col-md-5">
<input id="newEmployeeFirstName" name="newEmployeeFirstName" type="text" class="form-control input-md">
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<label class="col-md-4 control-label" for="newEmployeeMiddleName">Middle name</label>
<div class="col-md-5">
<input id="newEmployeeMiddleName" name="newEmployeeMiddleName" type="text" class="form-control input-md">
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<label class="col-md-4 control-label" for="newEmployeeLastName">Last name</label>
<div class="col-md-5">
<input id="newEmployeeLastName" name="newEmployeeLastName" type="text" class="form-control input-md">
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<label class="col-md-4 control-label" for="newEmployeeBirthDate">Birth date</label>
<div class="col-md-5">
<input id="newEmployeeBirthDate" name="newEmployeeBirthDate" type="text" class="form-control input-md datepicker">
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="row">
<div class="form-group">
<label class="col-md-4 control-label" for="newEmployeeEmail">Email</label>
<div class="col-md-5">
<input id="newEmployeeEmail" name="newEmployeeEmail" type="text" class="form-control input-md">
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<label class="col-md-4 control-label" for="newEmployeePhone">Phone</label>
<div class="col-md-5">
<input id="newEmployeePhone" name="newEmployeePhone" type="text" class="form-control input-md">
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<label class="col-md-4 control-label" for="newEmployeeType">Rol</label>
<div class="col-md-5">
<select class="form-control input-md" name="newEmployeeType" id="newEmployeeType">
<option>Employee type</option>
</select>
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<label class="col-md-4 control-label" for="NewEmpployyContractType">Contract type</label>
<div class="col-md-5">
<select class="form-control input-md" name="NewEmpployyContractType" id="NewEmpployyContractType">
<option>Contract type</option>
<option value="INTERNO">interno</option>
<option value="EXTERNO">Externo</option>
</select>
</div>
</div>
</div>
</div>
<div class="row col-md-offset-6">
<div class="form-group">
<a href="#" class="btn btn-lg btn-success " onclick="saveNewEmployee();">Create</a>
</div>
</div>
</div>
</div>
</div>
</form>

View File

@@ -1,3 +1,12 @@
<?php
session_start();
if(!isset($_SESSION['userName'])){
header("Location: ./login.php");
exit();
}
?>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="../css/bootstrap.min.css">
@@ -17,28 +26,28 @@
</button>
</div>
<div class="collapse navbar-collapse navbar-menubuilder">
<ul class="nav navbar-nav navbar-left">
<ul class="nav navbar-nav navbar-left" id="nevatation-options">
<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>
<li><a href="#" data-nav_accion="NewEmployee.php"> New employee</a></li>
<li><a href="#" data-nav_accion="EditEmployee.php"> Modify employee</a></li>
</ul>
</li>
<li>
<a href="#" onclick="vista_calendario();"><span class="glyphicon glyphicon-tasks"></span> Management</a>
<a href="#" onclick="loadView();"><span class="glyphicon glyphicon-tasks"></span> Management</a>
</li>
<li>
<a href="#" onclick="vista_calendario();"><span class="glyphicon glyphicon-wrench"></span> Change password</a>
<a href="#" onclick="loadView();"><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>
<a href="#" onclick="logout();"><span class="fa fa-fw fa-power-off"></span> logout</a>
</li>
</ul>
@@ -46,26 +55,25 @@
</div>
</div>
</div>
<div class="col-md-12" id="cuerpo"></div>
<div class="col-md-12" id="newViewBody"></div>
<!--
=================================================================================
Errores en query de AJAX
Modals for errors encountered by ajax
=================================================================================
-->
<!-- Fallo en la conexion de internet -->
<div id="modal_error_internet" class="modal fade" role="dialog">
<div id="modalErrorInternetConnection" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header" id="modal_header_error">
<div class="modal-header modalHeaderError">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title"><center>Ha ocurrido un error</center></h4>
<h4 class="modal-title">An error has occurred</h4>
</div>
<div class="modal-body">
<p>Por favor revise su conexión a internet.</p>
<p>Please verify your internet connection and try again.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
@@ -75,18 +83,16 @@
</div>
</div>
<!-- El recurso solicitado no existe -->
<div id="modal_error_404" class="modal fade" role="dialog">
<div id="modalError404" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header" id="modal_header_error">
<div class="modal-header modalHeaderError">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title"><center>Ha ocurrido un error</center></h4>
<h4 class="modal-title">An error has occurred</h4>
</div>
<div class="modal-body">
<p>El URL del formulario no pudo ser encontrado en el servidor.</p>
<p>Unable to find the requested url in the sever.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
@@ -96,18 +102,16 @@
</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 id="modalError500" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header" id="modal_header_error">
<div class="modal-header modalHeaderError">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title"><center>Ha ocurrido un error</center></h4>
<h4 class="modal-title">An error has occurred</h4>
</div>
<div class="modal-body">
<p>Error interno del servidor.</p>
<p>The server has encountered an internal error, please try again later.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
@@ -117,18 +121,16 @@
</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 id="modalErrorParsererror" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header" id="modal_header_error">
<div class="modal-header modalHeaderError">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title"><center>Ha ocurrido un error</center></h4>
<h4 class="modal-title">An error has occurred</h4>
</div>
<div class="modal-body">
<p>Fallo al procesar el JSON enviado por el servidor.</p>
<p>The response from the sever wasn't a proper JSON format</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
@@ -138,18 +140,16 @@
</div>
</div>
<!-- El servidortardo demasiado en responder -->
<div id="modal_error_timeout" class="modal fade" role="dialog">
<div id="modalErrorTimeout" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header" id="modal_header_error">
<div class="modal-header modalHeaderError">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title"><center>Ha ocurrido un error</center></h4>
<h4 class="modal-title">An error has occurred</h4>
</div>
<div class="modal-body">
<p>La petición excedió el limite de tiempo.</p>
<p>The request timeout, please try again or verify your connection.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
@@ -159,18 +159,16 @@
</div>
</div>
<!-- Si el request AJAX falla por alguna razon no listada -->
<div id="modal_error_otro" class="modal fade" role="dialog">
<div id="modalErrorOther" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header" id="modal_header_error">
<div class="modal-header modalHeaderError">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title"><center>Ha ocurrido un error</center></h4>
<h4 class="modal-title">An error has occurred</h4>
</div>
<div class="modal-body">
<p>Ha ocurrido un error desconocido.</p>
<p>An unknown error occurred.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
@@ -182,22 +180,20 @@
<!--
=================================================================================
Respuesta del servidor
Generic response modals
=================================================================================
-->
<!-- Si el request AJAX falla por alguna razon no listada -->
<div id="modal_respuesa_servidor_error" class="modal fade" role="dialog">
<div id="modalServerResponseError" 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">
<div class="modal-header modalHeaderError">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title"><center>Ha ocurrido un error</center></h4>
<h4 class="modal-title">An error has occurred</h4>
</div>
<div class="modal-body">
<p id="respuesa_servidor_error"></p>
<p id="modalResponseError"></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
@@ -207,18 +203,16 @@
</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 id="modalServerResponseSuccess" 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">
<div class="modal-header modalHeaderSuccess" id="modalHeaderServerResponseSuccess">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title"><center>El almacenado ha sido exitoso</center></h4>
<h4 class="modal-title">Success</h4>
</div>
<div class="modal-body">
<p id="respuesa_servidor_success"></p>
<p id="serverResponseSuccess"></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
@@ -229,4 +223,9 @@
</div>
</body>
<link href="../css/panel.css" rel="stylesheet">
<script src="../js/getBaseUrl.js"></script>
<script src="../js/landing.js"></script>
<script src="../js/bootstrap-datepicker.min.js"></script>
<link href="../css/bootstrap-datepicker.min.css" rel="stylesheet">
<link href="../css/landing.css" rel="stylesheet">

View File

@@ -1,3 +1,12 @@
<?php
session_start();
if(isset($_SESSION['userName'])){
header("Location: ./landing.php");
exit();
}
?>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="../css/bootstrap.min.css">
@@ -41,4 +50,5 @@
</div>
<script src="../js/login.js"></script>
<script src="../js/getBaseUrl.js"></script>
<link href="../css/login.css" rel="stylesheet">

View File

@@ -0,0 +1,94 @@
/**
* Bootstrapping the starting actions for the module
*/
$(document).ready(function(){
loadEmployeeTypes();
$('.datepicker').datepicker({
format: "yyyy/mm/dd",
autoclose: true
});
});
/**
* Loads the the enmployee types into their select option
*/
function loadEmployeeTypes(){
let baseUrl = getbaseUrl();
$.ajax({
url: baseUrl + '/api/employee/types',
type: 'GET',
dataType: 'json',
success:function(data){
$(data).each(function(i,v){
$('#newEmployeeType').append(
'<option value="' + v.id + '">'+ v.name + '</option>'
);
});
},
error:function(x,e) {
let responseText = $.parseJSON(x["responseText"]);
if (x.status==0) {
$('#modalErrorInternetConnection').modal('show');
} else if(x.status==404) {
$('#modalError404').modal('show');
} else if(x.status==500) {
$('#modalServerResponseError').modal('show');
document.getElementById('modalResponseError').innerHTML = responseText['message'];
} else if(e=='parsererror') {
$('#modalErrorParsererror').modal('show');
} else if(e=='timeout'){
$('#modalErrorTimeout').modal('show');
} else {
$('#modalErrorOther').modal('show');
}
},
});
}
function saveNewEmployee(){
let baseUrl = getbaseUrl();
let parameters = {
"firstName":$('#newEmployeeFirstName').val(),
"middleName":$('#newEmployeeMiddleName').val(),
"lastName":$('#newEmployeeLastName').val(),
"birthDate":$('#newEmployeeBirthDate').val(),
"email":$('#newEmployeeEmail').val(),
"phone":$('#newEmployeePhone').val(),
"idEmployeeType":$('#newEmployeeType').val(),
"contractType":$('#NewEmpployyContractType').val()
};
$.ajax({
url: baseUrl + '/api/employee',
type: 'POST',
dataType: 'json',
data: parameters,
success:function(data){
$('#modalServerResponseSuccess').modal('show');
document.getElementById('serverResponseSuccess').innerHTML = 'The employee ' + data['fullName'] + ' has been created with the code ' + data['employeeCode'];
},
error:function(x,e) {
let responseText = $.parseJSON(x["responseText"]);
if (x.status==0) {
$('#modalErrorInternetConnection').modal('show');
} else if(x.status==404) {
$('#modalError404').modal('show');
} else if(x.status==500) {
$('#modalServerResponseError').modal('show');
document.getElementById('modalResponseError').innerHTML = responseText['message'];
} else if(e=='parsererror') {
$('#modalErrorParsererror').modal('show');
} else if(e=='timeout'){
$('#modalErrorTimeout').modal('show');
} else {
$('#modalErrorOther').modal('show');
}
},
});
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,10 @@
/**
* Returns the entry point url for the system, this url will be used
* to access both the api and the static resources
*
* @returns {string}
*/
function getbaseUrl(){
var url = window.location.href;
return url.substring(0, url.indexOf('/html/'));
}

View File

@@ -0,0 +1,77 @@
/**
* Destorys the session for the current user and redirects
* back to the login form
*/
function logout() {
let baseUrl = getbaseUrl();
$.ajax({
url: baseUrl + '/api/session/logout',
type: 'GET',
dataType: 'json',
success:function(data){
window.location.replace(baseUrl + '/html/login.php');
},
error:function(x,e) {
if (x.status==0) {
$('#modalErrorInternetConnection').modal('show');
} else if(x.status==404) {
$('#modalError404').modal('show');
} else if(x.status==500) {
$('#modalError500').modal('show');
} else if(e=='parsererror') {
$('#modalErrorParsererror').modal('show');
} else if(e=='timeout'){
$('#modalErrorTimeout').modal('show');
} else {
$('#modal_error_otro').modal('show');
}
},
});
}
/**
* Entry point for loading elements from the navatation var, this functuion
* will filter the junk clicks that have landed in a dropdown menu and pass
* only the ones containing an action to the actual view loader
*/
$('#nevatation-options li a').click(function(){
let view = $(this).data('nav_accion');
if (view != "#" && view != undefined) {
loadView(view);
}
});
/**
* Will fetch the html of the desired view and load it into the landing page
*
* @param requestedView string
*/
function loadView(requestedView){
let baseUrl = getbaseUrl();
$.ajax({
url: baseUrl + '/html/' + requestedView,
type: 'get',
success:function(data){
$("#newViewBody").hide().html(data).show('slow');
},
error:function(x,e) {
if (x.status==0) {
$('#modalErrorInternetConnection').modal('show');
} else if(x.status==404) {
$('#modalError404').modal('show');
} else if(x.status==500) {
$('#modalError500').modal('show');
} else if(e=='parsererror') {
$('#modalErrorParsererror').modal('show');
} else if(e=='timeout'){
$('#modalErrorTimeout').modal('show');
} else {
$('#modal_error_otro').modal('show');
}
},
});
}

View File

@@ -1,25 +1,37 @@
function getbaseUrl(uriPath){
var url = window.location.href;
return url.substring(0, url.indexOf(uriPath));
}
/**
* Maps the enter key to the login action
*/
$(document).keypress(function(e) {
if(e.which == 13) {
processLogin();
}
});
/**
* Takes the input from the username and password fields and send theem to the backend
* to be validated
*
* The response from the api will contain a status that will determine if the login was
* successful or not and a message that will contain feedback which can be used to
* display errors to the user
*/
function processLogin() {
var baseUrl = getbaseUrl('/html/');
let baseUrl = getbaseUrl();
var parametros = {
let parameters = {
"userName":$('#userName').val(),
"password":$('#password').val()
};
$.ajax({
url: baseUrl + '/index.php/api/session/login',
url: baseUrl + '/api/session/login',
type: 'POST',
dataType: 'json',
data: parametros,
data: parameters,
success:function(data){
console.log(JSON.stringify(data));
if(data["status"] == "success"){
redirect(baseUrl + '/html/landing.php');
window.location.replace(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.";
@@ -32,8 +44,4 @@ function processLogin() {
}
},
});
}
function redirect(url){
window.location.replace(url);
}

View File

@@ -138,6 +138,7 @@ class EmployeeApplication{
$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.");
$this->asserts->isEmail($email, "The email isn't in a correct format");
$phone = $requestData['phone'];
$this->asserts->isNotEmpty($phone, "The phone number can't be empty.");
@@ -409,6 +410,7 @@ class EmployeeApplication{
$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.");
$this->asserts->isEmail($email, "The email isn't in a correct format");
$phone = $requestData['phone'];
$this->asserts->isNotEmpty($phone, "The phone number can't be empty.");

View File

@@ -117,12 +117,12 @@ class SessionApplication{
}
/**
* @return string
* @return array
*/
function destroySession(){
session_destroy();
return "Sucessfully logged out.";
return array('status' => 'success', 'message' => 'Successfully logged out.');
}
}
?>

View File

@@ -56,5 +56,18 @@ class Asserts{
throw new Exception($errorMessage);
}
}
/**
* Compares a string against a regex to determine if it's an email
*
* @param $string string
* @param $errorMessage string
* @throws Exception
*/
function isEmail($string, $errorMessage){
if(!filter_var($string, FILTER_VALIDATE_EMAIL)){
throw new Exception($errorMessage);
}
}
}
?>

View File

@@ -11,7 +11,7 @@ CREATE TABLE IF NOT EXISTS `persons` (
`lastName` varbinary(500) comment 'The last name of the person',
`birthDate` DATE NOT NULL DEFAULT '1900-01-01' comment 'Date of birth of the person',
`email` varbinary(500) NOT NULL comment 'The email adress of the person',
`phone` INT(10) UNSIGNED NOT NULL comment 'The phone number of the person should be the mobile one but leaves room for home ones',
`phone` BIGINT(10) UNSIGNED NOT NULL comment 'The phone number of the person should be the mobile one but leaves room for home ones',
`status` ENUM('ACTIVE', 'INACTIVE') NOT NULL DEFAULT 'ACTIVE',
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP comment 'The date on which the registry was created',
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment 'The date of the last time the row was modified',

View File

@@ -6,7 +6,7 @@ services:
ports:
- "8085:80"
volumes:
- api-payroll:/var/www/site
- ./volumes/apache-logs:/var/log/apache2
depends_on:
- mysql
mysql:
@@ -18,11 +18,11 @@ services:
ports:
- "3307:3307"
volumes:
- my-datavolume:/var/lib/mysql
- ./volumes/mysql-data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: '12345678'
MYSQL_USER: 'sloth'
MYSQL_PASS: '12345678'
volumes:
api-payroll:
my-datavolume:
mysql-data:
apache-logs:

2
volumes/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
mysql-data/
apache-logs/

1
volumes/README.md Normal file
View File

@@ -0,0 +1 @@
# Do not delete this directory, it'll contain the volumes created by the containers