[add] Sending new work day data to backend
This commit is contained in:
parent
e9f80a9989
commit
93099d316f
@ -93,7 +93,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="updateEmployee();">Update</a>
|
<a href="#" class="btn btn-lg btn-success " onclick="saveNewWorkDay();">Save</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -160,6 +160,46 @@ function validateEmployeeCanDoOtherRoles(code){
|
|||||||
error:function(x,e) {
|
error:function(x,e) {
|
||||||
let responseText = $.parseJSON(x["responseText"]);
|
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) {
|
if (x.status==0) {
|
||||||
$('#modalErrorInternetConnection').modal('show');
|
$('#modalErrorInternetConnection').modal('show');
|
||||||
} else if(x.status==404) {
|
} else if(x.status==404) {
|
||||||
|
@ -577,5 +577,9 @@ class EmployeeApplication{
|
|||||||
|
|
||||||
return $matches;
|
return $matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function SaveNewWorkDay($requestData){
|
||||||
|
return array('status' => 'success', 'message' => 'Saved...', 'data' => $requestData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
@ -95,4 +95,12 @@ $app->get('/api/employee/code/{code}', function (Request $request, Response $res
|
|||||||
return $response->withStatus(200)
|
return $response->withStatus(200)
|
||||||
->withHeader('Content-Type', 'application/json')
|
->withHeader('Content-Type', 'application/json')
|
||||||
->write(json_encode($this->employeeApplication->getEmployeeDataByCode($code)));
|
->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