[add] Sending new work day data to backend
This commit is contained in:
parent
e9f80a9989
commit
93099d316f
@ -93,7 +93,7 @@
|
||||
</div>
|
||||
<div class="row col-md-offset-6">
|
||||
<div class="form-group">
|
||||
<a href="#" class="btn btn-lg btn-success " onclick="updateEmployee();">Update</a>
|
||||
<a href="#" class="btn btn-lg btn-success " onclick="saveNewWorkDay();">Save</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -177,3 +177,43 @@ function validateEmployeeCanDoOtherRoles(code){
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
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) {
|
||||
$('#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');
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
@ -577,5 +577,9 @@ class EmployeeApplication{
|
||||
|
||||
return $matches;
|
||||
}
|
||||
|
||||
function SaveNewWorkDay($requestData){
|
||||
return array('status' => 'success', 'message' => 'Saved...', 'data' => $requestData);
|
||||
}
|
||||
}
|
||||
?>
|
@ -96,3 +96,11 @@ $app->get('/api/employee/code/{code}', function (Request $request, Response $res
|
||||
->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)));
|
||||
});
|
Loading…
Reference in New Issue
Block a user