[add] Updating work days from front end
This commit is contained in:
parent
b233346795
commit
ee168bd637
@ -133,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>
|
||||||
|
@ -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();
|
||||||
|
|
||||||
@ -254,12 +269,52 @@ 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
|
* 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
|
* load the data of the given work day and enable the update mode
|
||||||
*/
|
*/
|
||||||
$('#workDaysSearchByDate').on("change", function(data){
|
$('#workDaysSearchByDate').on("change", function(data){
|
||||||
console.log($(this).val());
|
|
||||||
let baseUrl = getbaseUrl();
|
let baseUrl = getbaseUrl();
|
||||||
let date = $(this).val();
|
let date = $(this).val();
|
||||||
let code = $('#hidenEmployeeCodeForWorkDaysCode').val();
|
let code = $('#hidenEmployeeCodeForWorkDaysCode').val();
|
||||||
|
Loading…
Reference in New Issue
Block a user