From 61eb80920431f531c744f0cf980a15c826d724c6 Mon Sep 17 00:00:00 2001 From: Jose Pabl Domingo Aramburo Sanchez Date: Mon, 13 Aug 2018 22:58:49 -0600 Subject: [PATCH 1/8] [add] Database and settings --- api-payroll/src/settings.php | 12 ++++++++++++ database/database.sql | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/api-payroll/src/settings.php b/api-payroll/src/settings.php index 4a54cdd..23e7d09 100644 --- a/api-payroll/src/settings.php +++ b/api-payroll/src/settings.php @@ -46,6 +46,18 @@ return [ 'employee' => [ 'codeLength' => '3', 'contractTypes' => array('INTERNO', 'EXTERNO'), + 'hoursPerWorkDay' => 8, + 'paymentperHour' => 30, + 'bonusPerDelivery' => 5, + 'perHourBonusDriver' => 10, + 'perHourBonusLoader' => 5, + 'perHourBonusAux' => 0, + 'BaseIsr' => 9, + 'extraIsr' => 3, + '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' => 4, ], ], ]; diff --git a/database/database.sql b/database/database.sql index 7163d96..b6466e0 100644 --- a/database/database.sql +++ b/database/database.sql @@ -73,3 +73,21 @@ CREATE TABLE IF NOT EXISTS `employees` ( PRIMARY KEY (`id`), 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', + `taxes` DOUBLE(10,2) NOT NULL DEFAULT 0.0 comment 'Substracted amout for taxes', + `vouchers` DOUBLE(10,2) NOT NULL DEFAULT 0.0 comment 'Amout given in vouchers', + `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`) +); -- 2.45.2 From 1ee650e0205e91e443970602a6c3f4b339735ad9 Mon Sep 17 00:00:00 2001 From: Jose Pabl Domingo Aramburo Sanchez Date: Mon, 13 Aug 2018 23:20:37 -0600 Subject: [PATCH 2/8] [add] Instantiating the new view --- api-payroll/public/html/landing.php | 2 +- api-payroll/public/html/registerWorkDays.php | 28 ++++++++++++++++++++ api-payroll/public/js/registerWorkDays.js | 0 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 api-payroll/public/html/registerWorkDays.php create mode 100644 api-payroll/public/js/registerWorkDays.js diff --git a/api-payroll/public/html/landing.php b/api-payroll/public/html/landing.php index 7d12330..eddf31b 100644 --- a/api-payroll/public/html/landing.php +++ b/api-payroll/public/html/landing.php @@ -38,7 +38,7 @@ if(!isset($_SESSION['userName'])){
  • - Management + Management
  • diff --git a/api-payroll/public/html/registerWorkDays.php b/api-payroll/public/html/registerWorkDays.php new file mode 100644 index 0000000..6551418 --- /dev/null +++ b/api-payroll/public/html/registerWorkDays.php @@ -0,0 +1,28 @@ + + + +
    +
    +
    +
    +

    Managing work days

    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    +
    +
    + Update +
    +
    +
    +
    +
    + diff --git a/api-payroll/public/js/registerWorkDays.js b/api-payroll/public/js/registerWorkDays.js new file mode 100644 index 0000000..e69de29 -- 2.45.2 From 69e3a31d528c5f7f12b17f1fe95ed10a31ae26dc Mon Sep 17 00:00:00 2001 From: Jose Pabl Domingo Aramburo Sanchez Date: Tue, 14 Aug 2018 00:00:47 -0600 Subject: [PATCH 3/8] [add] Layout new work day --- api-payroll/public/html/registerWorkDays.php | 74 +++++++++++++++ api-payroll/public/js/editEmployee.js | 2 +- api-payroll/public/js/registerWorkDays.js | 96 ++++++++++++++++++++ 3 files changed, 171 insertions(+), 1 deletion(-) diff --git a/api-payroll/public/html/registerWorkDays.php b/api-payroll/public/html/registerWorkDays.php index 6551418..b036ef5 100644 --- a/api-payroll/public/html/registerWorkDays.php +++ b/api-payroll/public/html/registerWorkDays.php @@ -17,6 +17,80 @@ + +
    +
    +
    + +
    + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    + +
    + + +
    +
    + +
    + +
    +
    +
    Update diff --git a/api-payroll/public/js/editEmployee.js b/api-payroll/public/js/editEmployee.js index c51e545..2416684 100644 --- a/api-payroll/public/js/editEmployee.js +++ b/api-payroll/public/js/editEmployee.js @@ -52,7 +52,7 @@ $(document).ready(function(){ }); /** - * Loads the the enmployee types into their select option + * Loads the the employee types into their select option */ function loadEmployeeTypes(){ let baseUrl = getbaseUrl(); diff --git a/api-payroll/public/js/registerWorkDays.js b/api-payroll/public/js/registerWorkDays.js index e69de29..5ebbf45 100644 --- a/api-payroll/public/js/registerWorkDays.js +++ b/api-payroll/public/js/registerWorkDays.js @@ -0,0 +1,96 @@ +/** + * 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); + console.log(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( + '' + ); + + $('#workDaysEmployeePerformedRol').append( + '' + ); + }); + }, + 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'); + } + }, + }); +} \ No newline at end of file -- 2.45.2 From 6ce90bd318e503b1bb85454a2207a0107d3ee3a0 Mon Sep 17 00:00:00 2001 From: Jose Pabl Domingo Aramburo Sanchez Date: Tue, 14 Aug 2018 00:08:05 -0600 Subject: [PATCH 4/8] [add] Loading basic employee data --- api-payroll/public/html/registerWorkDays.php | 4 +- api-payroll/public/js/registerWorkDays.js | 45 +++++++++++++++++++- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/api-payroll/public/html/registerWorkDays.php b/api-payroll/public/html/registerWorkDays.php index b036ef5..c53af9f 100644 --- a/api-payroll/public/html/registerWorkDays.php +++ b/api-payroll/public/html/registerWorkDays.php @@ -23,13 +23,13 @@
    - +
    - +