diff --git a/api-payroll/public/html/registerWorkDays.php b/api-payroll/public/html/registerWorkDays.php index c53af9f..5bdd05d 100644 --- a/api-payroll/public/html/registerWorkDays.php +++ b/api-payroll/public/html/registerWorkDays.php @@ -93,7 +93,7 @@
diff --git a/api-payroll/public/js/registerWorkDays.js b/api-payroll/public/js/registerWorkDays.js index aa5acce..e2f03b2 100644 --- a/api-payroll/public/js/registerWorkDays.js +++ b/api-payroll/public/js/registerWorkDays.js @@ -160,6 +160,46 @@ function validateEmployeeCanDoOtherRoles(code){ 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 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 = '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) { diff --git a/api-payroll/src/application/EmployeeApplication.php b/api-payroll/src/application/EmployeeApplication.php index cc52e32..9c2c628 100644 --- a/api-payroll/src/application/EmployeeApplication.php +++ b/api-payroll/src/application/EmployeeApplication.php @@ -577,5 +577,9 @@ class EmployeeApplication{ return $matches; } + + function SaveNewWorkDay($requestData){ + return array('status' => 'success', 'message' => 'Saved...', 'data' => $requestData); + } } ?> \ No newline at end of file diff --git a/api-payroll/src/routes.php b/api-payroll/src/routes.php index 6a2fc5b..3a34c82 100644 --- a/api-payroll/src/routes.php +++ b/api-payroll/src/routes.php @@ -95,4 +95,12 @@ $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->SaveNewWorkDay($requestData))); }); \ No newline at end of file