Compare commits
16 Commits
retrieving
...
sessionMid
| Author | SHA1 | Date | |
|---|---|---|---|
| 839be59ac5 | |||
| a05a602954 | |||
| e490f6aed1 | |||
| df33525a4b | |||
| 86a0540da7 | |||
| ee168bd637 | |||
| b233346795 | |||
| ca80abc389 | |||
| e3dfaf9f26 | |||
| 477ac28212 | |||
| 3ad687f797 | |||
| b84b9fa2fb | |||
| f2851ec56a | |||
| 03cbcce59f | |||
| f864e74247 | |||
| c97421df32 |
@@ -17,7 +17,8 @@
|
|||||||
"slim/php-view": "^2.0",
|
"slim/php-view": "^2.0",
|
||||||
"monolog/monolog": "^1.17",
|
"monolog/monolog": "^1.17",
|
||||||
"respect/validation": "^1.1",
|
"respect/validation": "^1.1",
|
||||||
"tuupola/cors-middleware": "^0.5.2"
|
"tuupola/cors-middleware": "^0.5.2",
|
||||||
|
"adbario/slim-secure-session-middleware": "^1.3"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": ">=4.8 < 6.0"
|
"phpunit/phpunit": ">=4.8 < 6.0"
|
||||||
|
|||||||
140
api-payroll/composer.lock
generated
140
api-payroll/composer.lock
generated
@@ -4,9 +4,96 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"hash": "93a9656f4e6eb0e25be1bad59ac6f487",
|
"hash": "19bc193d641803843178e87bf0465afe",
|
||||||
"content-hash": "a3fc18885cc45d2733b77fa2081bdc72",
|
"content-hash": "9eb8d110ad374a60767f92d76018504a",
|
||||||
"packages": [
|
"packages": [
|
||||||
|
{
|
||||||
|
"name": "adbario/php-dot-notation",
|
||||||
|
"version": "1.2.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/adbario/php-dot-notation.git",
|
||||||
|
"reference": "5e4b1fe29a8ae1140e370d520ed8b85dd5130a1f"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/adbario/php-dot-notation/zipball/5e4b1fe29a8ae1140e370d520ed8b85dd5130a1f",
|
||||||
|
"reference": "5e4b1fe29a8ae1140e370d520ed8b85dd5130a1f",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.4"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Adbar\\": "src"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Riku Särkinen",
|
||||||
|
"email": "riku@adbar.io"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "PHP dot notation array access",
|
||||||
|
"homepage": "https://github.com/adbario/php-dot-notation",
|
||||||
|
"keywords": [
|
||||||
|
"ArrayAccess",
|
||||||
|
"dotnotation",
|
||||||
|
"php"
|
||||||
|
],
|
||||||
|
"time": "2017-03-26 17:44:47"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "adbario/slim-secure-session-middleware",
|
||||||
|
"version": "1.3.4",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/adbario/slim-secure-session-middleware.git",
|
||||||
|
"reference": "f107191506b2c362f06f201f998891f315d6aaec"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/adbario/slim-secure-session-middleware/zipball/f107191506b2c362f06f201f998891f315d6aaec",
|
||||||
|
"reference": "f107191506b2c362f06f201f998891f315d6aaec",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"adbario/php-dot-notation": "~1.2.0",
|
||||||
|
"paragonie/random_compat": "^2.0",
|
||||||
|
"php": ">=5.5",
|
||||||
|
"slim/slim": "~3.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Adbar\\": "src"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Riku Särkinen",
|
||||||
|
"email": "riku@adbar.io"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Secure session middleware for Slim 3 framework",
|
||||||
|
"homepage": "https://github.com/adbario/slim-secure-session-middleware",
|
||||||
|
"keywords": [
|
||||||
|
"middleware",
|
||||||
|
"session",
|
||||||
|
"slim"
|
||||||
|
],
|
||||||
|
"time": "2017-08-04 13:51:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "container-interop/container-interop",
|
"name": "container-interop/container-interop",
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
@@ -217,6 +304,55 @@
|
|||||||
],
|
],
|
||||||
"time": "2018-02-13 20:26:39"
|
"time": "2018-02-13 20:26:39"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "paragonie/random_compat",
|
||||||
|
"version": "v2.0.17",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/paragonie/random_compat.git",
|
||||||
|
"reference": "29af24f25bab834fcbb38ad2a69fa93b867e070d"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/paragonie/random_compat/zipball/29af24f25bab834fcbb38ad2a69fa93b867e070d",
|
||||||
|
"reference": "29af24f25bab834fcbb38ad2a69fa93b867e070d",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.2.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "4.*|5.*"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes."
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"lib/random.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Paragon Initiative Enterprises",
|
||||||
|
"email": "security@paragonie.com",
|
||||||
|
"homepage": "https://paragonie.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7",
|
||||||
|
"keywords": [
|
||||||
|
"csprng",
|
||||||
|
"polyfill",
|
||||||
|
"pseudorandom",
|
||||||
|
"random"
|
||||||
|
],
|
||||||
|
"time": "2018-07-04 16:31:37"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "pimple/pimple",
|
"name": "pimple/pimple",
|
||||||
"version": "v3.2.3",
|
"version": "v3.2.3",
|
||||||
|
|||||||
@@ -1,12 +1,3 @@
|
|||||||
<?php
|
|
||||||
session_start();
|
|
||||||
|
|
||||||
if(!isset($_SESSION['userName'])){
|
|
||||||
header("Location: ./login.php");
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
||||||
<!-- Latest compiled and minified CSS -->
|
<!-- Latest compiled and minified CSS -->
|
||||||
<link rel="stylesheet" href="../css/bootstrap.min.css">
|
<link rel="stylesheet" href="../css/bootstrap.min.css">
|
||||||
|
|
||||||
@@ -40,10 +31,6 @@ if(!isset($_SESSION['userName'])){
|
|||||||
<li>
|
<li>
|
||||||
<a href="#" data-nav_accion="registerWorkDays.php" ><span class="glyphicon glyphicon-tasks"></span> Management</a>
|
<a href="#" data-nav_accion="registerWorkDays.php" ><span class="glyphicon glyphicon-tasks"></span> Management</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li>
|
|
||||||
<a href="#" onclick="loadView();"><span class="glyphicon glyphicon-wrench"></span> Change password</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="nav navbar-nav navbar-right">
|
<ul class="nav navbar-nav navbar-right">
|
||||||
<li>
|
<li>
|
||||||
|
|||||||
@@ -1,12 +1,3 @@
|
|||||||
<?php
|
|
||||||
session_start();
|
|
||||||
|
|
||||||
if(isset($_SESSION['userName'])){
|
|
||||||
header("Location: ./landing.php");
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
||||||
<!-- Latest compiled and minified CSS -->
|
<!-- Latest compiled and minified CSS -->
|
||||||
<link rel="stylesheet" href="../css/bootstrap.min.css">
|
<link rel="stylesheet" href="../css/bootstrap.min.css">
|
||||||
|
|
||||||
|
|||||||
@@ -10,12 +10,20 @@
|
|||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-md-4 control-label" for="workDaysSearchEmployee">Employee</label>
|
<label class="col-md-4 control-label" for="workDaysSearchEmployee">Search employee</label>
|
||||||
<div class="col-md-5">
|
<div class="col-md-5">
|
||||||
<input id="workDaysSearchEmployee" name="workDaysSearchEmployee" type="text" class="form-control input-md">
|
<input id="workDaysSearchEmployee" name="workDaysSearchEmployee" type="text" class="form-control input-md">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</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>
|
||||||
|
|
||||||
<div id="registerWorkDaysEmployeeInfo" class="col-md-6">
|
<div id="registerWorkDaysEmployeeInfo" class="col-md-6">
|
||||||
@@ -125,7 +133,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="row col-md-offset-6">
|
<div class="row col-md-offset-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<a href="#" class="btn btn-lg btn-success " onclick="saveNewWorkDay();">Save</a>
|
<a href="#" class="btn btn-lg btn-success " onclick="processSaveActionWorkDay();">Save</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ if (PHP_SAPI == 'cli-server') {
|
|||||||
|
|
||||||
require __DIR__ . '/../vendor/autoload.php';
|
require __DIR__ . '/../vendor/autoload.php';
|
||||||
|
|
||||||
session_start();
|
|
||||||
|
|
||||||
// Instantiate the app
|
// Instantiate the app
|
||||||
$settings = require __DIR__ . '/../src/settings.php';
|
$settings = require __DIR__ . '/../src/settings.php';
|
||||||
$app = new \Slim\App($settings);
|
$app = new \Slim\App($settings);
|
||||||
|
|||||||
@@ -13,12 +13,15 @@ function logout() {
|
|||||||
window.location.replace(baseUrl + '/html/login.php');
|
window.location.replace(baseUrl + '/html/login.php');
|
||||||
},
|
},
|
||||||
error:function(x,e) {
|
error:function(x,e) {
|
||||||
|
let responseText = $.parseJSON(x["responseText"]);
|
||||||
|
|
||||||
if (x.status==0) {
|
if (x.status==0) {
|
||||||
$('#modalErrorInternetConnection').modal('show');
|
$('#modalErrorInternetConnection').modal('show');
|
||||||
} else if(x.status==404) {
|
} else if(x.status==404) {
|
||||||
$('#modalError404').modal('show');
|
$('#modalError404').modal('show');
|
||||||
} else if(x.status==500) {
|
} else if(x.status==500) {
|
||||||
$('#modalError500').modal('show');
|
$('#modalServerResponseError').modal('show');
|
||||||
|
document.getElementById('modalResponseError').innerHTML = responseText['message'];
|
||||||
} else if(e=='parsererror') {
|
} else if(e=='parsererror') {
|
||||||
$('#modalErrorParsererror').modal('show');
|
$('#modalErrorParsererror').modal('show');
|
||||||
} else if(e=='timeout'){
|
} else if(e=='timeout'){
|
||||||
@@ -59,12 +62,15 @@ function loadView(requestedView){
|
|||||||
$("#newViewBody").hide().html(data).show('slow');
|
$("#newViewBody").hide().html(data).show('slow');
|
||||||
},
|
},
|
||||||
error:function(x,e) {
|
error:function(x,e) {
|
||||||
|
let responseText = $.parseJSON(x["responseText"]);
|
||||||
|
|
||||||
if (x.status==0) {
|
if (x.status==0) {
|
||||||
$('#modalErrorInternetConnection').modal('show');
|
$('#modalErrorInternetConnection').modal('show');
|
||||||
} else if(x.status==404) {
|
} else if(x.status==404) {
|
||||||
$('#modalError404').modal('show');
|
$('#modalError404').modal('show');
|
||||||
} else if(x.status==500) {
|
} else if(x.status==500) {
|
||||||
$('#modalError500').modal('show');
|
$('#modalServerResponseError').modal('show');
|
||||||
|
document.getElementById('modalResponseError').innerHTML = responseText['message'];
|
||||||
} else if(e=='parsererror') {
|
} else if(e=='parsererror') {
|
||||||
$('#modalErrorParsererror').modal('show');
|
$('#modalErrorParsererror').modal('show');
|
||||||
} else if(e=='timeout'){
|
} else if(e=='timeout'){
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ $(document).ready(function(){
|
|||||||
loadEmployeeTypesForWorkDays();
|
loadEmployeeTypesForWorkDays();
|
||||||
|
|
||||||
$('.datepicker').datepicker({
|
$('.datepicker').datepicker({
|
||||||
format: "yyyy/mm/dd",
|
format: "yyyy-mm-dd",
|
||||||
autoclose: true
|
autoclose: true
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -213,6 +213,21 @@ function loadSalaryDetails(code){
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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(){
|
function saveNewWorkDay(){
|
||||||
let baseUrl = getbaseUrl();
|
let baseUrl = getbaseUrl();
|
||||||
|
|
||||||
@@ -253,3 +268,92 @@ function saveNewWorkDay(){
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -9,21 +9,35 @@ class EmployeeApplication{
|
|||||||
private $cryptographyService;
|
private $cryptographyService;
|
||||||
private $asserts;
|
private $asserts;
|
||||||
private $settings;
|
private $settings;
|
||||||
|
private $session;
|
||||||
|
|
||||||
function __construct($employeeSettings, $mysql, $cryptographyService, $asserts){
|
/**
|
||||||
|
* EmployeeApplication constructor.
|
||||||
|
* @param $employeeSettings
|
||||||
|
* @param $mysql
|
||||||
|
* @param $cryptographyService
|
||||||
|
* @param $asserts
|
||||||
|
* @param $session
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
function __construct($employeeSettings, $mysql, $cryptographyService, $asserts, $session){
|
||||||
$this->settings = $employeeSettings;
|
$this->settings = $employeeSettings;
|
||||||
|
|
||||||
$this->cryptographyService = $cryptographyService;
|
$this->cryptographyService = $cryptographyService;
|
||||||
$this->pdo = $mysql;
|
$this->pdo = $mysql;
|
||||||
$this->asserts = $asserts;
|
$this->asserts = $asserts;
|
||||||
|
$this->session = $session;
|
||||||
|
|
||||||
$this->databaseSelectQueryErrorMessage = 'There was an error inserting the record.';
|
if(!$this->session->verifySession()){
|
||||||
|
throw new Exception('A session is requited to access this resouerce.');
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list of the types of employee used in the system
|
* A list of the types of employee used in the system
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
function listEmployeeTypes(){
|
function listEmployeeTypes(){
|
||||||
$stmt = $this->pdo->prepare("SELECT
|
$stmt = $this->pdo->prepare("SELECT
|
||||||
@@ -37,7 +51,7 @@ class EmployeeApplication{
|
|||||||
$results = $stmt->fetchAll();
|
$results = $stmt->fetchAll();
|
||||||
|
|
||||||
if(!$results){
|
if(!$results){
|
||||||
exit($this->databaseSelectQueryErrorMessage);
|
throw new Exception("The types of employees could not be found..");
|
||||||
}
|
}
|
||||||
$stmt = null;
|
$stmt = null;
|
||||||
|
|
||||||
@@ -63,6 +77,7 @@ class EmployeeApplication{
|
|||||||
$this->asserts->isNotEmpty($firstName, "The first name can't be empty.");
|
$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($middleName, "The middle name can't be empty.");
|
||||||
$this->asserts->isNotEmpty($birthDate, "The birth date can't be empty.");
|
$this->asserts->isNotEmpty($birthDate, "The birth date can't be empty.");
|
||||||
|
$this->asserts->dateIsNotInTheFuture($birthDate, "The birth date can't be in the future.");
|
||||||
$this->asserts->isNotEmpty($email, "The email 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.");
|
$this->asserts->isNotEmpty($phone, "The phone number can't be empty.");
|
||||||
|
|
||||||
@@ -81,7 +96,6 @@ class EmployeeApplication{
|
|||||||
} catch( PDOExecption $e ) {
|
} catch( PDOExecption $e ) {
|
||||||
$this->pdo->rollback();
|
$this->pdo->rollback();
|
||||||
throw new Exception('There was an error while trying to save a new person.');
|
throw new Exception('There was an error while trying to save a new person.');
|
||||||
$this->logger->warning("There was an error in the EmployeeApplication->saveNewPerson caused by: $e ");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,6 +154,7 @@ class EmployeeApplication{
|
|||||||
|
|
||||||
$birthDate = $requestData['birthDate'];
|
$birthDate = $requestData['birthDate'];
|
||||||
$this->asserts->isNotEmpty($birthDate, "The birth date can't be empty.");
|
$this->asserts->isNotEmpty($birthDate, "The birth date can't be empty.");
|
||||||
|
$this->asserts->dateIsNotInTheFuture($birthDate, "The birth date can't be in the future.");
|
||||||
|
|
||||||
$email = $requestData['email'];
|
$email = $requestData['email'];
|
||||||
$this->asserts->isNotEmpty($email, "The email can't be empty.");
|
$this->asserts->isNotEmpty($email, "The email can't be empty.");
|
||||||
@@ -190,6 +205,7 @@ class EmployeeApplication{
|
|||||||
/**
|
/**
|
||||||
* @param $idEmployee
|
* @param $idEmployee
|
||||||
* @return Integer
|
* @return Integer
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
function getIdPersonByIdEmployee($idEmployee){
|
function getIdPersonByIdEmployee($idEmployee){
|
||||||
$this->asserts->higherThanZero($idEmployee, "idEmployee must be higher than 0");
|
$this->asserts->higherThanZero($idEmployee, "idEmployee must be higher than 0");
|
||||||
@@ -206,7 +222,7 @@ class EmployeeApplication{
|
|||||||
$stmt->execute(array(':idEmployee' => $idEmployee));
|
$stmt->execute(array(':idEmployee' => $idEmployee));
|
||||||
$results = $stmt->fetchAll();
|
$results = $stmt->fetchAll();
|
||||||
if(!$results){
|
if(!$results){
|
||||||
exit($this->databaseSelectQueryErrorMessage);
|
throw new Exception("An error occurred while trying to find the person associated with the employee..");
|
||||||
}
|
}
|
||||||
$stmt = null;
|
$stmt = null;
|
||||||
|
|
||||||
@@ -216,6 +232,7 @@ class EmployeeApplication{
|
|||||||
/**
|
/**
|
||||||
* @param $code string
|
* @param $code string
|
||||||
* @return integer
|
* @return integer
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
function getIdEmployeeTypeByCode($code){
|
function getIdEmployeeTypeByCode($code){
|
||||||
$this->asserts->isNotEmpty($code, "The code can't be empty.");
|
$this->asserts->isNotEmpty($code, "The code can't be empty.");
|
||||||
@@ -232,7 +249,7 @@ class EmployeeApplication{
|
|||||||
$stmt->execute(array(':code' => $code));
|
$stmt->execute(array(':code' => $code));
|
||||||
$results = $stmt->fetchAll();
|
$results = $stmt->fetchAll();
|
||||||
if(!$results){
|
if(!$results){
|
||||||
exit($this->databaseSelectQueryErrorMessage);
|
throw new Exception("The employee could not be found.");
|
||||||
}
|
}
|
||||||
$stmt = null;
|
$stmt = null;
|
||||||
|
|
||||||
@@ -242,6 +259,7 @@ class EmployeeApplication{
|
|||||||
/**
|
/**
|
||||||
* @param $code string
|
* @param $code string
|
||||||
* @return integer
|
* @return integer
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
function getIdEmployeeByCode($code){
|
function getIdEmployeeByCode($code){
|
||||||
$this->asserts->isNotEmpty($code, "The code can't be empty.");
|
$this->asserts->isNotEmpty($code, "The code can't be empty.");
|
||||||
@@ -259,7 +277,7 @@ class EmployeeApplication{
|
|||||||
$stmt->execute(array(':code' => $code));
|
$stmt->execute(array(':code' => $code));
|
||||||
$results = $stmt->fetchAll();
|
$results = $stmt->fetchAll();
|
||||||
if(!$results){
|
if(!$results){
|
||||||
exit($this->databaseSelectQueryErrorMessage);
|
throw new Exception("The employee could not be found.");
|
||||||
}
|
}
|
||||||
$stmt = null;
|
$stmt = null;
|
||||||
|
|
||||||
@@ -271,6 +289,7 @@ class EmployeeApplication{
|
|||||||
*
|
*
|
||||||
* @param $idEmployee
|
* @param $idEmployee
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
function getEmployeeDataById($idEmployee){
|
function getEmployeeDataById($idEmployee){
|
||||||
$this->asserts->higherThanZero($idEmployee, "idEmployee must be higher than 0");
|
$this->asserts->higherThanZero($idEmployee, "idEmployee must be higher than 0");
|
||||||
@@ -297,7 +316,7 @@ class EmployeeApplication{
|
|||||||
$stmt->execute(array(':idEmployee' => $idEmployee));
|
$stmt->execute(array(':idEmployee' => $idEmployee));
|
||||||
$results = $stmt->fetchAll();
|
$results = $stmt->fetchAll();
|
||||||
if(!$results){
|
if(!$results){
|
||||||
exit($this->databaseSelectQueryErrorMessage);
|
throw new Exception("The employee could not be found.");
|
||||||
}
|
}
|
||||||
$stmt = null;
|
$stmt = null;
|
||||||
|
|
||||||
@@ -310,6 +329,7 @@ class EmployeeApplication{
|
|||||||
*
|
*
|
||||||
* @param $idEmployee
|
* @param $idEmployee
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
function proxyGetEmployeeDataById($idEmployee){
|
function proxyGetEmployeeDataById($idEmployee){
|
||||||
$this->asserts->higherThanZero($idEmployee, "idEmployee must be higher than 0");
|
$this->asserts->higherThanZero($idEmployee, "idEmployee must be higher than 0");
|
||||||
@@ -341,6 +361,7 @@ class EmployeeApplication{
|
|||||||
/**
|
/**
|
||||||
* @param $code string
|
* @param $code string
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
function getEmployeeDataByCode($code){
|
function getEmployeeDataByCode($code){
|
||||||
$this->asserts->isNotEmpty($code, "The code can't be empty.");
|
$this->asserts->isNotEmpty($code, "The code can't be empty.");
|
||||||
@@ -364,6 +385,7 @@ class EmployeeApplication{
|
|||||||
$this->asserts->isNotEmpty($firstName, "The first name can't be empty.");
|
$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($middleName, "The middle name can't be empty.");
|
||||||
$this->asserts->isNotEmpty($birthDate, "The birth date can't be empty.");
|
$this->asserts->isNotEmpty($birthDate, "The birth date can't be empty.");
|
||||||
|
$this->asserts->dateIsNotInTheFuture($birthDate, "The birth date can't be in the future.");
|
||||||
$this->asserts->isNotEmpty($email, "The email 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.");
|
$this->asserts->isNotEmpty($phone, "The phone number can't be empty.");
|
||||||
|
|
||||||
@@ -423,6 +445,7 @@ class EmployeeApplication{
|
|||||||
/**
|
/**
|
||||||
* @param $requestData object
|
* @param $requestData object
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
function updateEmployeeData($requestData){
|
function updateEmployeeData($requestData){
|
||||||
// Getting and validating the data
|
// Getting and validating the data
|
||||||
@@ -446,6 +469,7 @@ class EmployeeApplication{
|
|||||||
|
|
||||||
$birthDate = $requestData['birthDate'];
|
$birthDate = $requestData['birthDate'];
|
||||||
$this->asserts->isNotEmpty($birthDate, "The birth date can't be empty.");
|
$this->asserts->isNotEmpty($birthDate, "The birth date can't be empty.");
|
||||||
|
$this->asserts->dateIsNotInTheFuture($birthDate, "The birth date can't be in the future.");
|
||||||
|
|
||||||
$email = $requestData['email'];
|
$email = $requestData['email'];
|
||||||
$this->asserts->isNotEmpty($email, "The email can't be empty.");
|
$this->asserts->isNotEmpty($email, "The email can't be empty.");
|
||||||
@@ -520,6 +544,7 @@ class EmployeeApplication{
|
|||||||
* currently active in the system
|
* currently active in the system
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
function getIdEmployeeFromAllActiveEmployees(){
|
function getIdEmployeeFromAllActiveEmployees(){
|
||||||
$stmt = $this->pdo->prepare("SELECT
|
$stmt = $this->pdo->prepare("SELECT
|
||||||
@@ -533,7 +558,7 @@ class EmployeeApplication{
|
|||||||
$results = $stmt->fetchAll();
|
$results = $stmt->fetchAll();
|
||||||
|
|
||||||
if(!$results){
|
if(!$results){
|
||||||
exit($this->databaseSelectQueryErrorMessage);
|
throw new Exception("The employee could not be found.");
|
||||||
}
|
}
|
||||||
$stmt = null;
|
$stmt = null;
|
||||||
|
|
||||||
@@ -545,6 +570,7 @@ class EmployeeApplication{
|
|||||||
* all currently active employees
|
* all currently active employees
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
function listAllActiveEmployees(){
|
function listAllActiveEmployees(){
|
||||||
$ids = $this->getIdEmployeeFromAllActiveEmployees();
|
$ids = $this->getIdEmployeeFromAllActiveEmployees();
|
||||||
@@ -571,6 +597,7 @@ class EmployeeApplication{
|
|||||||
*
|
*
|
||||||
* @param $partialName string
|
* @param $partialName string
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
function findEmployeeByFullName($partialName){
|
function findEmployeeByFullName($partialName){
|
||||||
$fullList = $this->listAllActiveEmployees();
|
$fullList = $this->listAllActiveEmployees();
|
||||||
@@ -584,6 +611,39 @@ class EmployeeApplication{
|
|||||||
return $matches;
|
return $matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $idEmployee integer
|
||||||
|
* @param $date date
|
||||||
|
* @return integer
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
function findIdPaymentPerDayByEmployeeAndDate($idEmployee, $date){
|
||||||
|
$this->asserts->isNotEmpty($idEmployee, "The code can't be empty.");
|
||||||
|
$this->asserts->higherThanZero($idEmployee, "idEmployee must be higher than 0");
|
||||||
|
|
||||||
|
$this->asserts->isNotEmpty($date, "The code can't be empty.");
|
||||||
|
$this->asserts->dateIsNotInTheFuture($date, "The date can't be in the future.");
|
||||||
|
|
||||||
|
$stmt = $this->pdo->prepare("SELECT
|
||||||
|
COALESCE((SELECT
|
||||||
|
id
|
||||||
|
FROM
|
||||||
|
paymentsPerEmployeePerDay
|
||||||
|
WHERE
|
||||||
|
date = :date AND idEmployee = :idEmployee),
|
||||||
|
0) AS id;
|
||||||
|
");
|
||||||
|
|
||||||
|
$stmt->execute(array(':date' => $date, ':idEmployee' => $idEmployee));
|
||||||
|
$results = $stmt->fetchAll();
|
||||||
|
if(!$results){
|
||||||
|
throw new Exception("The registry of the worked day could not be found.");
|
||||||
|
}
|
||||||
|
$stmt = null;
|
||||||
|
|
||||||
|
return $results[0]['id'];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper to determine if the date has already been saved as a worked day for
|
* Helper to determine if the date has already been saved as a worked day for
|
||||||
* an employee, so long as it's currently active in the database
|
* an employee, so long as it's currently active in the database
|
||||||
@@ -598,6 +658,7 @@ class EmployeeApplication{
|
|||||||
$this->asserts->higherThanZero($idEmployee, "idEmployee must be higher than 0");
|
$this->asserts->higherThanZero($idEmployee, "idEmployee must be higher than 0");
|
||||||
|
|
||||||
$this->asserts->isNotEmpty($date, "The code can't be empty.");
|
$this->asserts->isNotEmpty($date, "The code can't be empty.");
|
||||||
|
$this->asserts->dateIsNotInTheFuture($date, "The date can't be in the future.");
|
||||||
|
|
||||||
$stmt = $this->pdo->prepare("SELECT
|
$stmt = $this->pdo->prepare("SELECT
|
||||||
COALESCE((SELECT
|
COALESCE((SELECT
|
||||||
@@ -612,7 +673,7 @@ class EmployeeApplication{
|
|||||||
$stmt->execute(array(':date' => $date, ':idEmployee' => $idEmployee));
|
$stmt->execute(array(':date' => $date, ':idEmployee' => $idEmployee));
|
||||||
$results = $stmt->fetchAll();
|
$results = $stmt->fetchAll();
|
||||||
if(!$results){
|
if(!$results){
|
||||||
throw new Exception('Unable to determine the usage of date for the worked days.');
|
throw new Exception('Unable to find the date of the worked days.');
|
||||||
}
|
}
|
||||||
$stmt = null;
|
$stmt = null;
|
||||||
|
|
||||||
@@ -633,6 +694,7 @@ class EmployeeApplication{
|
|||||||
function saveWorkedDay($idEmployee, $date, $baseAmount, $bonusTime, $deliveries){
|
function saveWorkedDay($idEmployee, $date, $baseAmount, $bonusTime, $deliveries){
|
||||||
$this->asserts->isNotEmpty($idEmployee, "The idEmployee can't be empty.");
|
$this->asserts->isNotEmpty($idEmployee, "The idEmployee can't be empty.");
|
||||||
$this->asserts->isNotEmpty($date, "The date can't be empty.");
|
$this->asserts->isNotEmpty($date, "The date can't be empty.");
|
||||||
|
$this->asserts->dateIsNotInTheFuture($date, "The date can't be in the future.");
|
||||||
$this->asserts->isNotEmpty($baseAmount, "The base payment per day can't be empty.");
|
$this->asserts->isNotEmpty($baseAmount, "The base payment per day can't be empty.");
|
||||||
$this->asserts->isNotEmpty($bonusTime, "The bonus per worked hours can't be empty.");
|
$this->asserts->isNotEmpty($bonusTime, "The bonus per worked hours can't be empty.");
|
||||||
$this->asserts->isNotEmpty($deliveries, "The payment for deliveries can't be empty.");
|
$this->asserts->isNotEmpty($deliveries, "The payment for deliveries can't be empty.");
|
||||||
@@ -657,14 +719,77 @@ class EmployeeApplication{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Takes the data from the front end for the new worked day for a
|
* Changes the status in the detail table for the registry of worked days so
|
||||||
* employee and saves it
|
* that it behaves as if deleted
|
||||||
|
* @param $idEmployee
|
||||||
|
* @param $date
|
||||||
|
*/
|
||||||
|
function dissablePaymentPerDayDetailsByEmployeeAndDate($idEmployee, $date){
|
||||||
|
$this->asserts->higherThanZero($idEmployee, "idEmployee must be higher than 0");
|
||||||
|
$this->asserts->isNotEmpty($date, "The worked date cannot be empty.");
|
||||||
|
$this->asserts->dateIsNotInTheFuture($date, "The date can't be in the future.");
|
||||||
|
|
||||||
|
try {
|
||||||
|
$stmt = $this->pdo->prepare("UPDATE paymentsPerEmployeePerDayDetail a
|
||||||
|
INNER JOIN
|
||||||
|
paymentsPerEmployeePerDay b ON b.id = a.idPaymentPerEmployeePerDay
|
||||||
|
SET
|
||||||
|
a.status = 'INACTIVE'
|
||||||
|
WHERE
|
||||||
|
b.date = :date AND b.idEmployee = :idEmployee");
|
||||||
|
$this->pdo->beginTransaction();
|
||||||
|
$stmt->execute(array(':date' => $date, ':idEmployee' => $idEmployee));
|
||||||
|
$this->pdo->commit();
|
||||||
|
|
||||||
|
$stmt = null;
|
||||||
|
} catch( PDOExecption $e ) {
|
||||||
|
$this->pdo->rollback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $id integer - references paymentsPerEmployeePerDay
|
||||||
|
* @param $baseAmount double
|
||||||
|
* @param $bonusTime double
|
||||||
|
* @param $deliveries double
|
||||||
|
*/
|
||||||
|
function updateWorkedDayPayments($id, $baseAmount, $bonusTime, $deliveries){
|
||||||
|
$this->asserts->higherThanZero($id, "id payment must be higher than 0");
|
||||||
|
$this->asserts->higherThanZero($baseAmount, "baseAmount must be higher than 0");
|
||||||
|
$this->asserts->higherThanZero($bonusTime, "bonusTime must be higher than 0");
|
||||||
|
$this->asserts->higherThanZero($deliveries, "deliveries must be higher than 0");
|
||||||
|
|
||||||
|
try {
|
||||||
|
$stmt = $this->pdo->prepare("UPDATE paymentsPerEmployeePerDay
|
||||||
|
SET
|
||||||
|
baseAmount = :baseAmount,
|
||||||
|
bonusTime = :bonusTime,
|
||||||
|
deliveries = :deliveries
|
||||||
|
WHERE
|
||||||
|
id = :id");
|
||||||
|
$this->pdo->beginTransaction();
|
||||||
|
$stmt->execute(array(':baseAmount' => $baseAmount, ':bonusTime' => $bonusTime, ':deliveries' => $deliveries,
|
||||||
|
':id' => $id));
|
||||||
|
$this->pdo->commit();
|
||||||
|
|
||||||
|
$stmt = null;
|
||||||
|
} catch( PDOExecption $e ) {
|
||||||
|
$this->pdo->rollback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Takes the data from the front end for the work day, this coulld be
|
||||||
|
* for an update or a creation of a new registry
|
||||||
|
*
|
||||||
|
* The function will take the request body, validate it and pass the
|
||||||
|
* processed data back to the wrapper method
|
||||||
*
|
*
|
||||||
* @param $requestData object
|
* @param $requestData object
|
||||||
* @return array
|
* @return array
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
function SaveNewWorkDay($requestData){
|
function validateDataForStorageWorkDay($requestData){
|
||||||
$code = $requestData['code'];
|
$code = $requestData['code'];
|
||||||
$this->asserts->isNotEmpty($code, "The code can't be empty.");
|
$this->asserts->isNotEmpty($code, "The code can't be empty.");
|
||||||
|
|
||||||
@@ -683,10 +808,7 @@ class EmployeeApplication{
|
|||||||
|
|
||||||
$date = $requestData['date'];
|
$date = $requestData['date'];
|
||||||
$this->asserts->isNotEmpty($date, "The worked date cannot be empty.");
|
$this->asserts->isNotEmpty($date, "The worked date cannot be empty.");
|
||||||
|
$this->asserts->dateIsNotInTheFuture($date, "The date can't be in the future.");
|
||||||
if($this->checkDateNotUsedWorkDayPerEmployee($idEmployee, $date) > 0){
|
|
||||||
throw new Exception("This date has already been saved as a worked day.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// The emplpoyee can't take that rol
|
// The emplpoyee can't take that rol
|
||||||
if($idEmployeeType != 3 and $idEmployeeType != $idEmployeeTypePerformed){
|
if($idEmployeeType != 3 and $idEmployeeType != $idEmployeeTypePerformed){
|
||||||
@@ -714,11 +836,74 @@ class EmployeeApplication{
|
|||||||
$bonusTime = $perHourBonus * $this->settings['hoursPerWorkDay'];
|
$bonusTime = $perHourBonus * $this->settings['hoursPerWorkDay'];
|
||||||
$bonusDeliveries = $deliveries * $this->settings['bonusPerDelivery'];
|
$bonusDeliveries = $deliveries * $this->settings['bonusPerDelivery'];
|
||||||
|
|
||||||
$this->saveWorkedDay($idEmployee, $date, $baseAmountPaid, $bonusTime, $bonusDeliveries);
|
$contractType = $this->getContractTypeByEmployee($idEmployee);
|
||||||
|
|
||||||
|
$result = array(
|
||||||
|
'idEmployee' => (int)$idEmployee,
|
||||||
|
'date' => $date,
|
||||||
|
'baseAmountPaid' => $baseAmountPaid,
|
||||||
|
'bonusTime' => $bonusTime,
|
||||||
|
'bonusDeliveries' => $bonusDeliveries,
|
||||||
|
'contractType' => $contractType,
|
||||||
|
'idEmployeeType' => (int)$idEmployeeType,
|
||||||
|
'idEmployeeTypePerformed' => (int)$idEmployeeTypePerformed,
|
||||||
|
'hoursPerWorkDay' => $this->settings['hoursPerWorkDay'],
|
||||||
|
'paymentPerHour' => $this->settings['paymentPerHour'],
|
||||||
|
'perHourBonus' => $perHourBonus,
|
||||||
|
'deliveries' => $deliveries,
|
||||||
|
'bonusPerDelivery' => $this->settings['bonusPerDelivery']
|
||||||
|
);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper function to store a new day that has been worked by an employee
|
||||||
|
*
|
||||||
|
* @param $requestData object
|
||||||
|
* @return array
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
function newWorkedDay($requestData){
|
||||||
|
$data = $this->validateDataForStorageWorkDay($requestData);
|
||||||
|
|
||||||
|
if($this->checkDateNotUsedWorkDayPerEmployee($data['idEmployee'], $data['date']) > 0){
|
||||||
|
throw new Exception("This date has already been saved as a worked day.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$idPaymentPerEmployeePerDay = $this->saveWorkedDay($data['idEmployee'], $data['date'],
|
||||||
|
$data['baseAmountPaid'], $data['bonusTime'], $data['bonusDeliveries']);
|
||||||
|
|
||||||
|
$this->storeWorkDayDetails($idPaymentPerEmployeePerDay, $data['idEmployeeType'],
|
||||||
|
$data['idEmployeeTypePerformed'], $data['contractType'], $data['hoursPerWorkDay'],
|
||||||
|
$data['paymentPerHour'], $data['perHourBonus'], $data['deliveries'], $data['bonusPerDelivery']);
|
||||||
|
|
||||||
return array('status' => 'success', 'message' => 'The worked day has been saved.', 'data' => $requestData);
|
return array('status' => 'success', 'message' => 'The worked day has been saved.', 'data' => $requestData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper method to update a worked day for an employee
|
||||||
|
*
|
||||||
|
* @param $requestData object
|
||||||
|
* @return array
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
function updateWorkDay($requestData){
|
||||||
|
$data = $this->validateDataForStorageWorkDay($requestData);
|
||||||
|
|
||||||
|
$this->dissablePaymentPerDayDetailsByEmployeeAndDate($data['idEmployee'], $data['date']);
|
||||||
|
|
||||||
|
$idPaymentPerEmployeePerDay = $this->findIdPaymentPerDayByEmployeeAndDate($data['idEmployee'], $data['date']);
|
||||||
|
|
||||||
|
$this->updateWorkedDayPayments($idPaymentPerEmployeePerDay, $data['baseAmountPaid'], $data['bonusTime'], $data['bonusDeliveries']);
|
||||||
|
|
||||||
|
$this->storeWorkDayDetails($idPaymentPerEmployeePerDay, $data['idEmployeeType'],
|
||||||
|
$data['idEmployeeTypePerformed'], $data['contractType'], $data['hoursPerWorkDay'],
|
||||||
|
$data['paymentPerHour'], $data['perHourBonus'], $data['deliveries'], $data['bonusPerDelivery']);
|
||||||
|
|
||||||
|
return array('status' => 'success', 'message' => 'The worked day has been updated.', 'data' => $requestData);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of days the employee has worked for a given year and month only
|
* The number of days the employee has worked for a given year and month only
|
||||||
* taking into accout the active ones
|
* taking into accout the active ones
|
||||||
@@ -815,6 +1000,121 @@ class EmployeeApplication{
|
|||||||
return $results[0]['contractType'];
|
return $results[0]['contractType'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a backup of the information used to calculate the amount that the employee
|
||||||
|
* will be paid for the submitted day
|
||||||
|
*
|
||||||
|
* @param $idPaymentPerEmployeePerDay integer
|
||||||
|
* @param $idEmployeeType integer
|
||||||
|
* @param $idEmployeeTypePerformed integer
|
||||||
|
* @param $contractType string
|
||||||
|
* @param $hoursWorked double
|
||||||
|
* @param $paymentPerHour double
|
||||||
|
* @param $bonusPerHour double
|
||||||
|
* @param $deliveries integer
|
||||||
|
* @param $paymentPerDelivery double
|
||||||
|
* @return integer
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
function storeWorkDayDetails($idPaymentPerEmployeePerDay, $idEmployeeType, $idEmployeeTypePerformed, $contractType, $hoursWorked,
|
||||||
|
$paymentPerHour, $bonusPerHour, $deliveries, $paymentPerDelivery){
|
||||||
|
$this->asserts->isNotEmpty($idPaymentPerEmployeePerDay, "The idPaymentPerEmployeePerDay can't be empty.");
|
||||||
|
$this->asserts->isNotEmpty($idEmployeeType, "The idEmployeeType can't be empty.");
|
||||||
|
$this->asserts->isNotEmpty($idEmployeeTypePerformed, "The idEmployeeTypePerformed can't be empty.");
|
||||||
|
$this->asserts->isNotEmpty($contractType, "The contractType can't be empty.");
|
||||||
|
$this->asserts->isNotEmpty($hoursWorked, "The hoursWorked can't be empty.");
|
||||||
|
$this->asserts->isNotEmpty($paymentPerHour, "The paymentPerHour can't be empty.");
|
||||||
|
$this->asserts->isNotEmpty($bonusPerHour, "The bonusPerHour can't be empty.");
|
||||||
|
$this->asserts->isNotEmpty($deliveries, "The deliveries can't be empty.");
|
||||||
|
$this->asserts->isNotEmpty($paymentPerDelivery, "The paymentPerDelivery can't be empty.");
|
||||||
|
|
||||||
|
try {
|
||||||
|
$stmt = $this->pdo->prepare("INSERT INTO paymentsPerEmployeePerDayDetail
|
||||||
|
(idPaymentPerEmployeePerDay, idEmployeeType, idEmployeeTypePerformed,
|
||||||
|
contractType, hoursWorked, paymentPerHour, bonusPerHour, deliveries, paymentPerDelivery)
|
||||||
|
VALUES
|
||||||
|
(:idPaymentPerEmployeePerDay, :idEmployeeType, :idEmployeeTypePerformed,
|
||||||
|
:contractType, :hoursWorked, :paymentPerHour, :bonusPerHour, :deliveries, :paymentPerDelivery)");
|
||||||
|
$this->pdo->beginTransaction();
|
||||||
|
$stmt->execute(array(':idPaymentPerEmployeePerDay' => $idPaymentPerEmployeePerDay,
|
||||||
|
':idEmployeeType' => $idEmployeeType,
|
||||||
|
':idEmployeeTypePerformed' => $idEmployeeTypePerformed,
|
||||||
|
':contractType' => $contractType,
|
||||||
|
':hoursWorked' => $hoursWorked,
|
||||||
|
':paymentPerHour' => $paymentPerHour,
|
||||||
|
':bonusPerHour' => $bonusPerHour,
|
||||||
|
':deliveries' => $deliveries,
|
||||||
|
':paymentPerDelivery' => $paymentPerDelivery)
|
||||||
|
);
|
||||||
|
$id = $this->pdo->lastInsertId();
|
||||||
|
$this->pdo->commit();
|
||||||
|
|
||||||
|
return $id;
|
||||||
|
|
||||||
|
$stmt = null;
|
||||||
|
} catch( PDOExecption $e ) {
|
||||||
|
$this->pdo->rollback();
|
||||||
|
throw new Exception("An error occured while saving the work day details.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $date date
|
||||||
|
* @param $code string
|
||||||
|
* @return array
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
function getDataWorkDayByDateAndCode($date, $code){
|
||||||
|
$idEmployee = $this->getIdEmployeeByCode($code);
|
||||||
|
$this->asserts->dateIsNotInTheFuture($date, "The date can't be in the future.");
|
||||||
|
|
||||||
|
$stmt = $this->pdo->prepare("SELECT
|
||||||
|
b.idPaymentPerEmployeePerDay,
|
||||||
|
b.idEmployeeType,
|
||||||
|
b.idEmployeeTypePerformed,
|
||||||
|
b.contractType,
|
||||||
|
b.hoursWorked,
|
||||||
|
b.paymentPerHour,
|
||||||
|
b.bonusPerHour,
|
||||||
|
b.deliveries,
|
||||||
|
b.paymentPerDelivery
|
||||||
|
FROM
|
||||||
|
paymentsPerEmployeePerDay a
|
||||||
|
INNER JOIN
|
||||||
|
paymentsPerEmployeePerDayDetail b ON b.idPaymentPerEmployeePerDay = a.id
|
||||||
|
WHERE
|
||||||
|
a.idEmployee = :idEmployee
|
||||||
|
AND a.date = :date
|
||||||
|
AND a.status = 'ACTIVE'
|
||||||
|
AND b.status = 'ACTIVE'
|
||||||
|
ORDER BY b.id DESC
|
||||||
|
LIMIT 1");
|
||||||
|
$stmt->execute(array(':idEmployee' => $idEmployee, ':date' => $date));
|
||||||
|
|
||||||
|
$results = $stmt->fetchAll();
|
||||||
|
|
||||||
|
if(!$results){
|
||||||
|
throw new Exception("No data of the work day was found.");
|
||||||
|
}
|
||||||
|
$stmt = null;
|
||||||
|
|
||||||
|
foreach($results as $row){
|
||||||
|
$data = array(
|
||||||
|
'idPaymentPerEmployeePerDay' => (int)$row['idPaymentPerEmployeePerDay'],
|
||||||
|
'idEmployeeType' => (int)$row['idEmployeeType'],
|
||||||
|
'idEmployeeTypePerformed' => (int)$row['idEmployeeTypePerformed'],
|
||||||
|
'contractType' => $row['contractType'],
|
||||||
|
'hoursWorked' => (int)$row['hoursWorked'],
|
||||||
|
'paymentPerHour' => (int)$row['paymentPerHour'],
|
||||||
|
'bonusPerHour' => (int)$row['bonusPerHour'],
|
||||||
|
'deliveries' => (int)$row['deliveries'],
|
||||||
|
'paymentPerDelivery' => (int)$row['paymentPerDelivery']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all the worked days for an employee and determines how much they're
|
* Gets all the worked days for an employee and determines how much they're
|
||||||
* getting paid
|
* getting paid
|
||||||
|
|||||||
@@ -4,23 +4,24 @@ namespace App\Application;
|
|||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
class SessionApplication{
|
class SessionApplication{
|
||||||
|
private $session;
|
||||||
private $pdo;
|
private $pdo;
|
||||||
private $cryptographyService;
|
private $cryptographyService;
|
||||||
private $asserts;
|
private $asserts;
|
||||||
|
|
||||||
function __construct($mysql, $cryptographyService, $asserts){
|
function __construct($session, $mysql, $cryptographyService, $asserts){
|
||||||
|
$this->session = $session;
|
||||||
$this->cryptographyService = $cryptographyService;
|
$this->cryptographyService = $cryptographyService;
|
||||||
$this->pdo = $mysql;
|
$this->pdo = $mysql;
|
||||||
$this->asserts = $asserts;
|
$this->asserts = $asserts;
|
||||||
|
|
||||||
$this->databaseSelectQueryErrorMessage = 'There was an error inserting the record.';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function verifySession(){
|
function verifySession(){
|
||||||
return isset($_SESSION['userName']);
|
$userName = $this->session->get('userName');
|
||||||
|
return isset($userName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,7 +33,7 @@ class SessionApplication{
|
|||||||
$session['loggedIn'] = $this->verifySession();
|
$session['loggedIn'] = $this->verifySession();
|
||||||
|
|
||||||
if($this->verifySession()){
|
if($this->verifySession()){
|
||||||
$session['userName'] = $_SESSION['userName'];
|
$session['userName'] = $this->session->get('userName');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $session;
|
return $session;
|
||||||
@@ -85,7 +86,12 @@ class SessionApplication{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($this->cryptographyService->decryptPassword($password, $storedPassword)){
|
if($this->cryptographyService->decryptPassword($password, $storedPassword)){
|
||||||
$_SESSION['userName'] = $userName;
|
$this->session->set('userName', $userName);
|
||||||
|
|
||||||
|
if(!$this->verifySession()){
|
||||||
|
throw new Exception('An error occurred while trying to create the session.');
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@@ -118,9 +124,14 @@ class SessionApplication{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
function destroySession(){
|
function destroySession(){
|
||||||
session_destroy();
|
$this->session->clear();
|
||||||
|
|
||||||
|
if($this->verifySession()){
|
||||||
|
throw new Exception('An error occurred while trying to end the session.');
|
||||||
|
}
|
||||||
|
|
||||||
return array('status' => 'success', 'message' => 'Successfully logged out.');
|
return array('status' => 'success', 'message' => 'Successfully logged out.');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,13 @@ $container['logger'] = function ($c) {
|
|||||||
return $logger;
|
return $logger;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Session handler
|
||||||
|
$container['session'] = function ($container) {
|
||||||
|
return new \Adbar\Session(
|
||||||
|
$container->get('settings')['session']['namespace']
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
// Mysql connection
|
// Mysql connection
|
||||||
$container['mysql'] = function ($c) {
|
$container['mysql'] = function ($c) {
|
||||||
$mysqlSettings = $c->get('settings')['mysql'];
|
$mysqlSettings = $c->get('settings')['mysql'];
|
||||||
@@ -60,7 +67,8 @@ $container['asserts'] = function ($c) {
|
|||||||
|
|
||||||
// The session application
|
// The session application
|
||||||
$container['sessionApplication'] = function ($c) {
|
$container['sessionApplication'] = function ($c) {
|
||||||
$sessionApplication = new App\Application\SessionApplication($c['mysql'], $c['cryptographyService'], $c['asserts']);
|
$sessionApplication = new App\Application\SessionApplication($c['session'], $c['mysql'],
|
||||||
|
$c['cryptographyService'], $c['asserts']);
|
||||||
return $sessionApplication;
|
return $sessionApplication;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -68,6 +76,6 @@ $container['sessionApplication'] = function ($c) {
|
|||||||
$container['employeeApplication'] = function ($c) {
|
$container['employeeApplication'] = function ($c) {
|
||||||
$employeeSettings = $c->get('settings')['employee'];
|
$employeeSettings = $c->get('settings')['employee'];
|
||||||
$employeeApplication = new App\Application\EmployeeApplication($employeeSettings,
|
$employeeApplication = new App\Application\EmployeeApplication($employeeSettings,
|
||||||
$c['mysql'], $c['cryptographyService'], $c['asserts']);
|
$c['mysql'], $c['cryptographyService'], $c['asserts'], $c['sessionApplication']);
|
||||||
return $employeeApplication;
|
return $employeeApplication;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -20,3 +20,5 @@ $app->add(new \Tuupola\Middleware\Cors([
|
|||||||
->write(json_encode($data, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
|
->write(json_encode($data, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
|
||||||
}
|
}
|
||||||
]));
|
]));
|
||||||
|
|
||||||
|
$app->add(new \Adbar\SessionMiddleware($app->getContainer()->get('settings')['session']));
|
||||||
@@ -102,7 +102,15 @@ $app->post('/api/employee/workday', function ($request, $response) {
|
|||||||
|
|
||||||
return $response->withStatus(200)
|
return $response->withStatus(200)
|
||||||
->withHeader('Content-Type', 'application/json')
|
->withHeader('Content-Type', 'application/json')
|
||||||
->write(json_encode($this->employeeApplication->SaveNewWorkDay($requestData)));
|
->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) {
|
$app->get('/api/employee/salary/{code}', function (Request $request, Response $response, array $args) {
|
||||||
@@ -112,3 +120,12 @@ $app->get('/api/employee/salary/{code}', function (Request $request, Response $r
|
|||||||
->withHeader('Content-Type', 'application/json')
|
->withHeader('Content-Type', 'application/json')
|
||||||
->write(json_encode($this->employeeApplication->calculateSalaryByCode($code)));
|
->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)));
|
||||||
|
});
|
||||||
|
|||||||
@@ -95,5 +95,16 @@ class Asserts{
|
|||||||
throw new Exception($errorMessage);
|
throw new Exception($errorMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $date
|
||||||
|
* @param $errorMessage
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
function dateIsNotInTheFuture($date, $errorMessage){
|
||||||
|
if ($date > date('Y-m-d')){
|
||||||
|
throw new Exception($errorMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -16,6 +16,35 @@ return [
|
|||||||
'level' => \Monolog\Logger::DEBUG,
|
'level' => \Monolog\Logger::DEBUG,
|
||||||
],
|
],
|
||||||
|
|
||||||
|
// Session handle settings
|
||||||
|
'session' => [
|
||||||
|
// Session cookie settings
|
||||||
|
'name' => 'payroll-laziness-rocks',
|
||||||
|
'lifetime' => 10,
|
||||||
|
'path' => '/',
|
||||||
|
'domain' => null,
|
||||||
|
'secure' => false,
|
||||||
|
'httponly' => true,
|
||||||
|
|
||||||
|
// Set session cookie path, domain and secure automatically
|
||||||
|
'cookie_autoset' => true,
|
||||||
|
|
||||||
|
// Path where session files are stored, PHP's default path will be used if set null
|
||||||
|
'save_path' => null,
|
||||||
|
|
||||||
|
// Session cache limiter
|
||||||
|
'cache_limiter' => 'nocache',
|
||||||
|
|
||||||
|
// Extend session lifetime after each user activity
|
||||||
|
'autorefresh' => true,
|
||||||
|
|
||||||
|
// Encrypt session data if string is set
|
||||||
|
'encryption_key' => '7de431684c34cf2c898268cff71392f38c4175dde050c9ee69502b81571484e0',
|
||||||
|
|
||||||
|
// Session namespace
|
||||||
|
'namespace' => 'slim'
|
||||||
|
],
|
||||||
|
|
||||||
// Cryptography settings
|
// Cryptography settings
|
||||||
'cryptography' => [
|
'cryptography' => [
|
||||||
'encryptionAlgorithm' => 'AES-256-CBC',
|
'encryptionAlgorithm' => 'AES-256-CBC',
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class BaseTestCase extends \PHPUnit_Framework_TestCase
|
|||||||
*
|
*
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
protected $withMiddleware = true;
|
protected $withMiddleware = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process the application given a request method and URI
|
* Process the application given a request method and URI
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ CREATE TABLE IF NOT EXISTS `employees` (
|
|||||||
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP comment 'The date on which the registry was created',
|
`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',
|
`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`),
|
PRIMARY KEY (`id`),
|
||||||
|
INDEX `idx_contractType` (`contractType`),
|
||||||
UNIQUE (`code`)
|
UNIQUE (`code`)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -89,3 +90,25 @@ CREATE TABLE IF NOT EXISTS `paymentsPerEmployeePerDay` (
|
|||||||
FOREIGN KEY (idEmployee) REFERENCES employees(id),
|
FOREIGN KEY (idEmployee) REFERENCES employees(id),
|
||||||
UNIQUE (`idEmployee`, `date`, `status`)
|
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)
|
||||||
|
);
|
||||||
Reference in New Issue
Block a user