Compare commits

...

57 Commits

Author SHA1 Message Date
ee168bd637 [add] Updating work days from front end 2018-08-15 02:36:23 -06:00
b233346795 [add] Worked day modified through api 2018-08-15 02:26:41 -06:00
ca80abc389 [add] Validations for work day abstracted to their own method 2018-08-15 01:40:36 -06:00
e3dfaf9f26 [add] Validating future dates 2018-08-15 00:51:10 -06:00
477ac28212 [mod] Exits changed to exceptions 2018-08-15 00:38:05 -06:00
3ad687f797 [add] Data loaded to be edited 2018-08-15 00:31:18 -06:00
b84b9fa2fb [add] Returning details per pay day 2018-08-14 16:35:30 -06:00
f2851ec56a [add] Work day details 2018-08-14 15:39:55 -06:00
03cbcce59f [add] Basic endpoint for workday data 2018-08-14 11:52:57 -06:00
f864e74247 Merge pull request #22 from PootisPenserHere/retrievingrySalary
Retrievingry salary
2018-08-14 07:40:19 -06:00
6b22fc4694 [add] Loading salary data 2018-08-14 07:38:25 -06:00
caa31136f1 [add] Endpoint to calculate salary 2018-08-14 04:06:36 -06:00
c97421df32 Merge pull request #21 from PootisPenserHere/registeringNewWorkDay
Registering new work day
2018-08-14 02:31:46 -06:00
568c6d23a9 [add] Validating date isn't duplicated 2018-08-14 02:30:56 -06:00
15a7ea5ef5 [add] Saving worked day 2018-08-14 02:11:07 -06:00
93099d316f [add] Sending new work day data to backend 2018-08-14 00:26:25 -06:00
e9f80a9989 [add] Enabling covered rol for aux 2018-08-14 00:16:06 -06:00
6ce90bd318 [add] Loading basic employee data 2018-08-14 00:08:05 -06:00
69e3a31d52 [add] Layout new work day 2018-08-14 00:00:47 -06:00
1ee650e020 [add] Instantiating the new view 2018-08-13 23:20:37 -06:00
61eb809204 [add] Database and settings 2018-08-13 22:58:49 -06:00
b98b4077b4 Merge pull request #20 from PootisPenserHere/updatingEmployeeDataFromView
Updating employee data from view
2018-08-12 23:18:47 -06:00
a8148bbb93 [add] Employee updated 2018-08-12 23:17:20 -06:00
b0a19c6daa [add] Loading employee data 2018-08-12 22:55:00 -06:00
38d3466f16 [fix] Returning idEmployeeType instead of name type 2018-08-12 22:49:32 -06:00
68723e82fe [add] Searching for full employee data by code
Corrected a logical  error where the wrong method was being called to get data by code and also made it so the search function only returns names and codes
2018-08-12 22:22:33 -06:00
6615e5471a [add] Bloodhound in local files 2018-08-12 21:51:09 -06:00
49e114c18a [add] Bloodhoung search 2018-08-12 21:45:50 -06:00
e9effb7fcc [add] Finding employees by name 2018-08-12 21:01:46 -06:00
a5a1656518 [add] New asserts 2018-08-12 19:48:34 -06:00
19d1f57240 [mod] File naming 2018-08-12 19:28:50 -06:00
99a020024e Merge pull request #19 from PootisPenserHere/creatingNewEmployeeFromView
Creating new employee from view
2018-08-12 19:22:13 -06:00
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
dc45f02ad2 Merge pull request #18 from PootisPenserHere/loadingViews
Loading views
2018-08-12 11:36:52 -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
30f755c0b2 [fix] Misleading error when login 2018-08-11 20:03:28 -06:00
7feb3a6f5d [add] Landing page skeleton 2018-08-10 01:31:25 -06:00
e5d90bc32d Merge pull request #14 from PootisPenserHere/genericAsserts
Generic asserts
2018-08-09 23:29:58 -06:00
1500aef977 [add] Higher than zero asserting 2018-08-09 23:26:25 -06:00
112f78c1de [del] Old asserts 2018-08-09 22:48:42 -06:00
08702b2cdf [add] Generic assers in employee application 2018-08-09 22:47:19 -06:00
21013cf6ac [add] Generic asserts with custom errors 2018-08-09 21:55:39 -06:00
25 changed files with 4966 additions and 109 deletions

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,243 @@
body {
background-color: #e3e3e3;
color: #000;
}
.datepicker{
color: black;
}
#newViewBody{
top:17%;
left:1%;
width:98%;
float:left;
}
#navigation_spot{
margin: 0;
padding: 0;
}
#footer {
}
#newViewBody .modal-body{
color: #000;
border:none;
}
#newViewBody .panel-default{
border: 3px solid #4A89A5;
border-radius: 5px;
}
#newViewBody .panel > .panel-heading {
background-image: none;
background-color: #4A89A5;
color: white;
border-radius: 0;
}
#newViewBody .btn-default{
border: 2px solid #62655F;
background: #F9DFAF;
}
#newViewBody .btn-default:hover{
border: 2px solid #62655F;
background: #F9DFAF;
}
#newViewBody .alert-success{
background: #C6E97C;
}
.modalHeaderError{
background-color: #d9534f;
}
.modalHeaderSuccess{
background-color: #5bc0de;
}
.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_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;
}

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,111 @@
<script src="../js/getBaseUrl.js"></script>
<script src="../js/editEmployee.js"></script>
<form class="form-horizontal" id="editEmployee">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Edit employee</h3>
</div>
<div class="panel-body">
<div class="row">
<div class="form-group">
<label class="col-md-4 control-label" for="editEmploySearch">Employee</label>
<div class="col-md-5">
<input id="editEmploySearch" name="editEmploySearch" type="text" class="form-control input-md">
</div>
</div>
</div>
<div class="col-md-6">
<div class="row">
<div class="form-group">
<label class="col-md-4 control-label" for="editEmployeeFirstName">First name</label>
<div class="col-md-5">
<input id="editEmployeeFirstName" name="editEmployeeFirstName" 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="editEmployeeMiddleName">Middle name</label>
<div class="col-md-5">
<input id="editEmployeeMiddleName" name="editEmployeeMiddleName" 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="editEmployeeLastName">Last name</label>
<div class="col-md-5">
<input id="editEmployeeLastName" name="editEmployeeLastName" 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="editEmployeeBirthDate">Birth date</label>
<div class="col-md-5">
<input id="editEmployeeBirthDate" name="editEmployeeBirthDate" type="text" class="form-control input-md datepicker">
</div>
</div>
</div>
<div class="row" id="hidenEmployeeCode">
<div class="form-group">
<label class="col-md-4 control-label" for="editEmployeeCode">Code</label>
<div class="col-md-5">
<input id="editEmployeeCode" name="editEmployeeCode" type="text" class="form-control input-md">
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="row">
<div class="form-group">
<label class="col-md-4 control-label" for="editEmployeeEmail">Email</label>
<div class="col-md-5">
<input id="editEmployeeEmail" name="editEmployeeEmail" 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="editEmployeePhone">Phone</label>
<div class="col-md-5">
<input id="editEmployeePhone" name="editEmployeePhone" 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="editEmployeeType">Rol</label>
<div class="col-md-5">
<select class="form-control input-md" name="editEmployeeType" id="editEmployeeType">
<option>Employee type</option>
</select>
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<label class="col-md-4 control-label" for="editEmployeeContractType">Contract type</label>
<div class="col-md-5">
<select class="form-control input-md" name="editEmployeeContractType" id="editEmployeeContractType">
<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="updateEmployee();">Update</a>
</div>
</div>
</div>
</div>
</div>
</form>

View File

@@ -0,0 +1,232 @@
<?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">
<!-- 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" 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="newEmployee.php"> New employee</a></li>
<li><a href="#" data-nav_accion="editEmployee.php"> Modify employee</a></li>
</ul>
</li>
<li>
<a href="#" data-nav_accion="registerWorkDays.php" ><span class="glyphicon glyphicon-tasks"></span> Management</a>
</li>
<li>
<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="#" onclick="logout();"><span class="fa fa-fw fa-power-off"></span> logout</a>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="col-md-12" id="newViewBody"></div>
<!--
=================================================================================
Modals for errors encountered by ajax
=================================================================================
-->
<div id="modalErrorInternetConnection" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header modalHeaderError">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">An error has occurred</h4>
</div>
<div class="modal-body">
<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>
</div>
</div>
</div>
</div>
<div id="modalError404" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header modalHeaderError">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">An error has occurred</h4>
</div>
<div class="modal-body">
<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>
</div>
</div>
</div>
</div>
<div id="modalError500" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header modalHeaderError">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">An error has occurred</h4>
</div>
<div class="modal-body">
<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>
</div>
</div>
</div>
</div>
<div id="modalErrorParsererror" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header modalHeaderError">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">An error has occurred</h4>
</div>
<div class="modal-body">
<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>
</div>
</div>
</div>
</div>
<div id="modalErrorTimeout" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header modalHeaderError">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">An error has occurred</h4>
</div>
<div class="modal-body">
<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>
</div>
</div>
</div>
</div>
<div id="modalErrorOther" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header modalHeaderError">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">An error has occurred</h4>
</div>
<div class="modal-body">
<p>An unknown error occurred.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
</div>
</div>
</div>
</div>
<!--
=================================================================================
Generic response modals
=================================================================================
-->
<div id="modalServerResponseError" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header modalHeaderError">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">An error has occurred</h4>
</div>
<div class="modal-body">
<p id="modalResponseError"></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
</div>
</div>
</div>
</div>
<div id="modalServerResponseSuccess" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header modalHeaderSuccess" id="modalHeaderServerResponseSuccess">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Success</h4>
</div>
<div class="modal-body">
<p id="serverResponseSuccess"></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
</div>
</div>
</div>
</div>
</body>
<script src="../js/getBaseUrl.js"></script>
<script src="../js/landing.js"></script>
<script src="../js/bootstrap-datepicker.min.js"></script>
<script src="../js/typeahead.bundle.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,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

@@ -0,0 +1,142 @@
<script src="../js/getBaseUrl.js"></script>
<script src="../js/registerWorkDays.js"></script>
<form class="form-horizontal" id="workDaysForm">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Managing work days</h3>
</div>
<div class="panel-body">
<div class="row">
<div class="form-group">
<label class="col-md-4 control-label" for="workDaysSearchEmployee">Search employee</label>
<div class="col-md-5">
<input id="workDaysSearchEmployee" name="workDaysSearchEmployee" 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="workDaysSearchByDate">Search by date</label>
<div class="col-md-2">
<input id="workDaysSearchByDate" name="workDaysSearchByDate" type="text" class="form-control input-md datepicker">
</div>
</div>
</div>
</div>
<div id="registerWorkDaysEmployeeInfo" class="col-md-6">
<div class="row">
<div class="form-group">
<label class="col-md-4 control-label" for="workDaysEmployeeName">Name</label>
<div class="col-md-5">
<input id="workDaysEmployeeName" name="workDaysEmployeeName" type="text" class="form-control input-md" disabled>
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<label class="col-md-4 control-label" for="workDaysEmployeeRol">Rol</label>
<div class="col-md-5">
<select class="form-control input-md" name="workDaysEmployeeRol" id="workDaysEmployeeRol" disabled>
<option></option>
</select>
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<label class="col-md-4 control-label" for="workDaysEmployeeContractType">Contract type</label>
<div class="col-md-5">
<select class="form-control input-md" name="workDaysEmployeeContractType" id="workDaysEmployeeContractType" disabled>
<option>Contract type</option>
<option value="INTERNO">interno</option>
<option value="EXTERNO">Externo</option>
</select>
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<label class="col-md-4 control-label" for="workDaysEmployeeWorkedDay">Date</label>
<div class="col-md-5">
<input id="workDaysEmployeeWorkedDay" name="workDaysEmployeeWorkedDay" type="text" class="form-control input-md datepicker">
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<label class="col-md-4 control-label" for="workDaysEmployeeDeliveries">Deliveries</label>
<div class="col-md-5">
<input id="workDaysEmployeeDeliveries" name="workDaysEmployeeDeliveries" type="number" value="0" class="form-control input-md">
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<label class="col-md-4 control-label" for="workDaysEmployeePerformedRol">Performed rol</label>
<div class="col-md-5">
<select class="form-control input-md" name="workDaysEmployeePerformedRol" id="workDaysEmployeePerformedRol" disabled>
<option>Employee type</option>
</select>
</div>
</div>
</div>
</div>
<div id="registerWorkDaysEmployeeSalary" class="col-md-6">
<div class="row">
<div class="form-group">
<label class="col-md-4 control-label" for="workDaysEmployeeSalaryRaw">Raw</label>
<div class="col-md-5">
<input id="workDaysEmployeeSalaryRaw" name="workDaysEmployeeSalaryRaw" type="text" class="form-control input-md" disabled>
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<label class="col-md-4 control-label" for="workDaysEmployeeSalaryTaxes">Taxes</label>
<div class="col-md-5">
<input id="workDaysEmployeeSalaryTaxes" name="workDaysEmployeeSalaryTaxes" type="text" class="form-control input-md" disabled>
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<label class="col-md-4 control-label" for="workDaysEmployeeSalaryFinal">Final</label>
<div class="col-md-5">
<input id="workDaysEmployeeSalaryFinal" name="workDaysEmployeeSalaryFinal" type="text" class="form-control input-md" disabled>
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<label class="col-md-4 control-label" for="workDaysEmployeeSalaryVouchers">Vouchers</label>
<div class="col-md-5">
<input id="workDaysEmployeeSalaryVouchers" name="workDaysEmployeeSalaryVouchers" type="text" class="form-control input-md" disabled>
</div>
</div>
</div>
</div>
<div class="row" id="hidenEmployeeCodeForWorkDays">
<div class="form-group">
<label class="col-md-4 control-label" for="hidenEmployeeCodeForWorkDaysCode">Code</label>
<div class="col-md-5">
<input id="hidenEmployeeCodeForWorkDaysCode" name="hidenEmployeeCodeForWorkDaysCode" type="text" class="form-control input-md">
</div>
</div>
</div>
<div class="row col-md-offset-6">
<div class="form-group">
<a href="#" class="btn btn-lg btn-success " onclick="processSaveActionWorkDay();">Save</a>
</div>
</div>
</div>
</div>
</form>

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,180 @@
/**
* Bootstrapping the starting actions for the module
*/
$(document).ready(function(){
let baseUrl = getbaseUrl();
loadEmployeeTypes();
$('.datepicker').datepicker({
format: "yyyy/mm/dd",
autoclose: true
});
// Not to be edited
$("#hidenEmployeeCode").hide();
// Setting up bloodhound typeahead
let employeesList = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace("name"),
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
'cache': false,
url: baseUrl + '/api/employee/find',
replace: function(url, uriEncodedQuery) {
return url + '/' + uriEncodedQuery
},
wildcard: '%QUERY',
filter: function (data) {
return data;
}
}
});
employeesList.initialize();
$("#editEmploySearch").typeahead({
hint: true,
highlight: true,
minLength: 3
},
{
name: "result",
displayKey: "fullName",
source: employeesList.ttAdapter()
}).bind("typeahead:selected", function(obj, datum, name) {
$(this).data("id", datum.code);
loadEmployeeData(datum.code);
});
});
/**
* Loads the the employee 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){
$('#editEmployeeType').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');
}
},
});
}
/**
* Searches the employee data by its employee code and loads it
* into the form to be edited and updated
*
* @param code string
*/
function loadEmployeeData(code){
let baseUrl = getbaseUrl();
$.ajax({
url: baseUrl + '/api/employee/code/' + code,
type: 'GET',
dataType: 'json',
success:function(data){
$('#editEmployeeFirstName').val(data['firstName']);
$('#editEmployeeMiddleName').val(data['middleName']);
$('#editEmployeeLastName').val(data['lastName']);
$('#editEmployeeBirthDate').val(data['birthDate']);
$('#editEmployeeCode').val(data['code']);
$('#editEmployeeEmail').val(data['email']);
$('#editEmployeePhone').val(data['phone']);
$('#editEmployeeType').val(data['idEmployeeType']);
$('#editEmployeeContractType').val(data['contractType']);
},
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 updateEmployee(){
let baseUrl = getbaseUrl();
let parameters = {
"firstName":$('#editEmployeeFirstName').val(),
"middleName":$('#editEmployeeMiddleName').val(),
"lastName":$('#editEmployeeLastName').val(),
"birthDate":$('#editEmployeeBirthDate').val(),
"code":$('#editEmployeeCode').val(),
"email":$('#editEmployeeEmail').val(),
"phone":$('#editEmployeePhone').val(),
"idEmployeeType":$('#editEmployeeType').val(),
"contractType":$('#editEmployeeContractType').val()
};
$.ajax({
url: baseUrl + '/api/employee',
type: 'PUT',
dataType: 'json',
data: parameters,
success:function(data){
$('#modalServerResponseSuccess').modal('show');
document.getElementById('serverResponseSuccess').innerHTML = 'The employee ' + data['fullName'] + ' has been updated.';
},
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');
}
},
});
}

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,24 +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() {
console.log(getbaseUrl('html/'));
var parametros = {
let baseUrl = getbaseUrl();
let parameters = {
"userName":$('#userName').val(),
"password":$('#password').val()
};
$.ajax({
url: getbaseUrl('/html/') + '/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("http://stackoverflow.com");
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.";
@@ -31,8 +44,4 @@ console.log(getbaseUrl('html/'));
}
},
});
}
function redirect(url){
window.location.replace(url);
}

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');
}
},
});
}

View File

@@ -0,0 +1,359 @@
/**
* Bootstrapping the starting actions for the module
*/
$(document).ready(function(){
let baseUrl = getbaseUrl();
loadEmployeeTypesForWorkDays();
$('.datepicker').datepicker({
format: "yyyy-mm-dd",
autoclose: true
});
// Not to be edited
$("#hidenEmployeeCodeForWorkDays").hide();
// Setting up bloodhound typeahead
let employeesList = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace("name"),
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
'cache': false,
url: baseUrl + '/api/employee/find',
replace: function(url, uriEncodedQuery) {
return url + '/' + uriEncodedQuery
},
wildcard: '%QUERY',
filter: function (data) {
return data;
}
}
});
employeesList.initialize();
$("#workDaysSearchEmployee").typeahead({
hint: true,
highlight: true,
minLength: 3
},
{
name: "result",
displayKey: "fullName",
source: employeesList.ttAdapter()
}).bind("typeahead:selected", function(obj, datum, name) {
$(this).data("id", datum.code);
loadEmployeeDataForWorkDays(datum.code);
validateEmployeeCanDoOtherRoles(datum.code);
loadSalaryDetails(datum.code);
$('#hidenEmployeeCodeForWorkDaysCode').val(datum.code); // For future reference
});
});
/**
* Loads the the employee types into their select option
*/
function loadEmployeeTypesForWorkDays(){
let baseUrl = getbaseUrl();
$.ajax({
url: baseUrl + '/api/employee/types',
type: 'GET',
dataType: 'json',
success:function(data){
$(data).each(function(i,v){
$('#workDaysEmployeeRol').append(
'<option value="' + v.id + '">'+ v.name + '</option>'
);
$('#workDaysEmployeePerformedRol').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');
}
},
});
}
/**
* Searches the employee data by its employee code and loads it
* into the form to be edited and saved
*
* @param code string
*/
function loadEmployeeDataForWorkDays(code){
let baseUrl = getbaseUrl();
$.ajax({
url: baseUrl + '/api/employee/code/' + code,
type: 'GET',
dataType: 'json',
success:function(data){
let fullName = data['firstName'] + ' ' + data['middleName'] + ' ' + data['lastName'];
$('#workDaysEmployeeName').val(fullName);
$('#workDaysEmployeeRol').val(data['idEmployeeType']);
$('#workDaysEmployeePerformedRol').val(data['idEmployeeType']);
$('#workDaysEmployeeContractType').val(data['contractType']);
},
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');
}
},
});
}
/**
* Based on the employee code determines their type to decide if
* they should be able to cover for other roles or not
*
* @param code string
*/
function validateEmployeeCanDoOtherRoles(code){
let baseUrl = getbaseUrl();
$.ajax({
url: baseUrl + '/api/employee/type/' + code,
type: 'GET',
dataType: 'json',
success:function(data){
if(data == 3){
$("#workDaysEmployeePerformedRol").prop('disabled', false);
}
},
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 loadSalaryDetails(code){
let baseUrl = getbaseUrl();
$.ajax({
url: baseUrl + '/api/employee/salary/' + code,
type: 'GET',
dataType: 'json',
success:function(data){
$('#workDaysEmployeeSalaryRaw').val(data['raw']);
$('#workDaysEmployeeSalaryTaxes').val(data['taxes']);
$('#workDaysEmployeeSalaryFinal').val(data['real']);
$('#workDaysEmployeeSalaryVouchers').val(data['vouchers']);
},
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');
}
},
});
}
/**
* Bootstraper for the save action
*
* If the search by date function has been used it's then assumed that the
* desired action is to update else the function will attempt to create a new
* record for the worked day
*/
function processSaveActionWorkDay(){
if($('#workDaysSearchByDate').val() === ''){
saveNewWorkDay();
}else {
updateNewWorkDay();
}
}
function saveNewWorkDay(){
let baseUrl = getbaseUrl();
let parameters = {
"code":$('#hidenEmployeeCodeForWorkDaysCode').val(),
"idEmployeeTypePerformed":$('#workDaysEmployeePerformedRol').val(),
"deliveries":$('#workDaysEmployeeDeliveries').val(),
"date":$('#workDaysEmployeeWorkedDay').val(),
};
$.ajax({
url: baseUrl + '/api/employee/workday',
type: 'POST',
dataType: 'json',
data: parameters,
success:function(data){
$('#modalServerResponseSuccess').modal('show');
document.getElementById('serverResponseSuccess').innerHTML = data['message'];
loadSalaryDetails($('#hidenEmployeeCodeForWorkDaysCode').val());
},
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 updateNewWorkDay(){
let baseUrl = getbaseUrl();
let parameters = {
"code":$('#hidenEmployeeCodeForWorkDaysCode').val(),
"idEmployeeTypePerformed":$('#workDaysEmployeePerformedRol').val(),
"deliveries":$('#workDaysEmployeeDeliveries').val(),
"date":$('#workDaysEmployeeWorkedDay').val(),
};
$.ajax({
url: baseUrl + '/api/employee/workday',
type: 'PUT',
dataType: 'json',
data: parameters,
success:function(data){
$('#modalServerResponseSuccess').modal('show');
document.getElementById('serverResponseSuccess').innerHTML = data['message'];
loadSalaryDetails($('#hidenEmployeeCodeForWorkDaysCode').val());
},
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');
}
},
});
}
/**
* If the search by date field is changed from its default empty status it'll
* load the data of the given work day and enable the update mode
*/
$('#workDaysSearchByDate').on("change", function(data){
let baseUrl = getbaseUrl();
let date = $(this).val();
let code = $('#hidenEmployeeCodeForWorkDaysCode').val();
// The employee hasn't been picked
if (code === ''){
$('#modalServerResponseError').modal('show');
document.getElementById('modalResponseError').innerHTML = 'Please select an employee in the search form first.';
return false; // Exits the function
}
$.ajax({
url: baseUrl + '/api/employee/salary/date/' + date + '/code/' + code,
type: 'GET',
dataType: 'json',
success:function(data){
$('#workDaysEmployeeRol').val(data['idEmployeeType']);
$('#workDaysEmployeeContractType').val(data['contractType']);
$('#workDaysEmployeeWorkedDay').val(date);
$('#workDaysEmployeeDeliveries').val(data['deliveries']);
$('#workDaysEmployeePerformedRol').val(data['idEmployeeTypePerformed']);
},
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 it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -12,8 +12,6 @@ class SessionApplication{
$this->cryptographyService = $cryptographyService;
$this->pdo = $mysql;
$this->asserts = $asserts;
$this->databaseSelectQueryErrorMessage = 'There was an error inserting the record.';
}
/**
@@ -41,15 +39,18 @@ class SessionApplication{
/**
* @param $userName string
* @return mixed
* @throws Exception
*/
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->execute(array(':userName' => $userName));
$results = $stmt->fetchAll();
if(!$results){
exit($this->databaseSelectQueryErrorMessage);
throw new Exception('The user or password didnt match, please try again.');
}
$stmt = null;
return $results[0]['password'];
@@ -62,8 +63,12 @@ class SessionApplication{
* @throws Exception
*/
function newSession($userName, $password){
$this->asserts->userName($userName);
$this->asserts->password($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.");
$storedPassword = $this->getPassword($userName);
@@ -93,6 +98,14 @@ class SessionApplication{
* @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.');
}
@@ -102,12 +115,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

@@ -41,10 +41,12 @@ $app->get('/api/employee/types', function (Request $request, Response $response,
->write(json_encode($this->employeeApplication->listEmployeeTypes()));
});
$app->get('/api/employee/all', function (Request $request, Response $response, array $args) {
$app->get('/api/employee/find/{partialName}', function (Request $request, Response $response, array $args) {
$partialName = $args['partialName'];
return $response->withStatus(200)
->withHeader('Content-Type', 'application/json')
->write(json_encode($this->employeeApplication->listAllActiveEmployees()));
->write(json_encode($this->employeeApplication->findEmployeeByFullName($partialName)));
});
$app->post('/api/employee', function ($request, $response) {
@@ -93,4 +95,37 @@ $app->get('/api/employee/code/{code}', function (Request $request, Response $res
return $response->withStatus(200)
->withHeader('Content-Type', 'application/json')
->write(json_encode($this->employeeApplication->getEmployeeDataByCode($code)));
});
});
$app->post('/api/employee/workday', function ($request, $response) {
$requestData = $request->getParsedBody();
return $response->withStatus(200)
->withHeader('Content-Type', 'application/json')
->write(json_encode($this->employeeApplication->newWorkedDay($requestData)));
});
$app->put('/api/employee/workday', function ($request, $response) {
$requestData = $request->getParsedBody();
return $response->withStatus(200)
->withHeader('Content-Type', 'application/json')
->write(json_encode($this->employeeApplication->updateWorkDay($requestData)));
});
$app->get('/api/employee/salary/{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->calculateSalaryByCode($code)));
});
$app->get('/api/employee/salary/date/{date}/code/{code}', function (Request $request, Response $response, array $args) {
$date = $args['date'];
$code = $args['code'];
return $response->withStatus(200)
->withHeader('Content-Type', 'application/json')
->write(json_encode($this->employeeApplication->getDataWorkDayByDateAndCode($date, $code)));
});

View File

@@ -6,78 +6,104 @@ use Respect\Validation\Validator as v;
class Asserts{
/**
* @param $string
* @param $string string
* @param $errorMessage string
* @throws Exception
*/
function userName($string){
$validateFirstName = v::stringType()->notEmpty()->length(1, 50)->validate($string);
function isString($string, $errorMessage){
$validation = v::stringType()->validate($string);
if(!$validateFirstName){
throw new Exception('The user name must be a string between 1 and 50 characters');
if(!$validation){
throw new Exception($errorMessage);
}
}
/**
* @param $string
* @param $string string
* @param $errorMessage string
* @throws Exception
*/
function password($string){
$validateFirstName = v::stringType()->notEmpty()->length(1, 50)->validate($string);
function isNotEmpty($string, $errorMessage){
$validation = v::notEmpty()->validate($string);
if(!$validateFirstName){
throw new Exception('The password must be a string between 1 and 50 characters');
if(!$validation){
throw new Exception($errorMessage);
}
}
/**
* @param $string
* @param $string string
* @param $min integer
* @param $max integer
* @param $errorMessage string
* @throws Exception
*/
function firstName($string){
$validateFirstName = v::stringType()->notEmpty()->length(1, 100)->validate($string);
function betweenLength($string, $min, $max, $errorMessage){
$validation = v::length($min, $max)->validate($string);
if(!$validateFirstName){
throw new Exception('The first name must be a string between 1 and 100 characters');
if(!$validation){
throw new Exception($errorMessage);
}
}
/**
* @param $string
* @param $number integer
* @param $errorMessage string
* @throws Exception
*/
function middleName($string){
if(!v::stringType()->notEmpty()->length(1, 100)->validate($string)){
throw new Exception('The middle name must be a string between 1 and 100 characters');
function higherThanZero($number, $errorMessage){
if($number <= 0){
throw new Exception($errorMessage);
}
}
/**
* @param $string
* Compares a string against a regex to determine if it's an email
*
* @param $string string
* @param $errorMessage 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');
function isEmail($string, $errorMessage){
if(!filter_var($string, FILTER_VALIDATE_EMAIL)){
throw new Exception($errorMessage);
}
}
/**
* @param $string
* @param $string string
* @param $array array
* @param $errorMessage 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');
function existInArray($string, $array, $errorMessage){
if(!in_array($string, $array)){
throw new Exception($errorMessage);
}
}
/**
* @param $string
* Compares two dates to dertermine if they have the same month
*
* @param $firstDate date
* @param $secondDate date
* @param $errorMessage 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');
function datesHaveSameMonth($firstDate, $secondDate, $errorMessage){
if (date("m",strtotime($firstDate)) != date("m",strtotime($secondDate))){
throw new Exception($errorMessage);
}
}
/**
* @param $date
* @param $errorMessage
* @throws Exception
*/
function dateIsNotInTheFuture($date, $errorMessage){
if ($date > date('Y-m-d')){
throw new Exception($errorMessage);
}
}
}

View File

@@ -45,6 +45,19 @@ return [
// Employee settings
'employee' => [
'codeLength' => '3',
'contractTypes' => array('INTERNO', 'EXTERNO'),
'hoursPerWorkDay' => 8,
'paymentPerHour' => 30,
'bonusPerDelivery' => 5,
'perHourBonusDriver' => 10,
'perHourBonusLoader' => 5,
'perHourBonusAux' => 0,
'baseIsr' => .09,
'extraIsr' => .03,
'taxesAddUp' => true, // If true this will be total/(9 + 3) else they're subtracted separately
'amountForExtraTaxes' => 16000,
'vouchersForAllContractTypes' => false, // Outsourced personal won't get vouchers
'percentOfPaymentForVouchers' => .04,
],
],
];

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',
@@ -71,5 +71,44 @@ CREATE TABLE IF NOT EXISTS `employees` (
`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',
PRIMARY KEY (`id`),
INDEX `idx_contractType` (`contractType`),
UNIQUE (`code`)
);
DROP TABLE IF EXISTS paymentsPerEmployeePerDay;
CREATE TABLE IF NOT EXISTS `paymentsPerEmployeePerDay` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`idEmployee` INT UNSIGNED NOT NULL comment 'The employee to who this payment will be made',
`date` DATE NOT NULL DEFAULT '1900-01-01' comment 'Date of the worked day',
`baseAmount` DOUBLE(10,2) NOT NULL DEFAULT 0.0 comment 'Amount paid for the hours worked',
`bonusTime` DOUBLE(10,2) NOT NULL DEFAULT 0.0 comment 'Bonus paid for the hours worked',
`deliveries` DOUBLE(10,2) NOT NULL DEFAULT 0.0 comment 'Bonus for the number of deliveries',
`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',
PRIMARY KEY (`id`),
FOREIGN KEY (idEmployee) REFERENCES employees(id),
UNIQUE (`idEmployee`, `date`, `status`)
);
DROP TABLE IF EXISTS paymentsPerEmployeePerDayDetail;
CREATE TABLE IF NOT EXISTS `paymentsPerEmployeePerDayDetail` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`idPaymentPerEmployeePerDay` INT UNSIGNED NOT NULL comment 'References the payment for the work day',
`idEmployeeType` INT UNSIGNED NOT NULL comment 'The type of employee',
`idEmployeeTypePerformed` INT UNSIGNED NOT NULL comment 'The employee working for the day as',
`contractType` ENUM('INTERNO', 'EXTERNO') NOT NULL comment 'The type of contract',
`hoursWorked` DOUBLE(10,2) NOT NULL DEFAULT 0.0 comment 'Hours worked for the day',
`paymentPerHour` DOUBLE(10,2) NOT NULL DEFAULT 0.0 comment 'Payment per hour worked',
`bonusPerHour` DOUBLE(10,2) NOT NULL DEFAULT 0.0 comment 'Bonus payment per hour worked',
`deliveries` INT UNSIGNED NOT NULL DEFAULT 0 comment 'Total amount of deliveries for the day',
`paymentPerDelivery` DOUBLE(10,2) NOT NULL DEFAULT 0.0 comment 'Payment for each delivery done',
`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',
PRIMARY KEY (`id`),
FOREIGN KEY (idPaymentPerEmployeePerDay) REFERENCES paymentsPerEmployeePerDay(id),
FOREIGN KEY (idEmployeeType) REFERENCES employeeType(id),
FOREIGN KEY (idEmployeeTypePerformed) REFERENCES employeeType(id),
FOREIGN KEY (contractType) REFERENCES employees(contractType)
);