perbaikan bug global loading HR dan Payroll

This commit is contained in:
Wian Drs
2026-09-14 12:05:53 +07:00
parent 63993ee76e
commit 5e1fd11410
9 changed files with 153 additions and 66 deletions
+55 -14
View File
@@ -401,6 +401,16 @@
</div>
<div class="col-md-4 mb-3">
<label>Tanggal Resign <span class="text-muted">(opsional)</span></label>
<input type="date"
id="resign_date"
class="form-control">
</div>
<?php if($can_manage_all_salary):?>
<div class="col-12 mb-3">
<div class="form-check salary-restricted-note">
@@ -566,6 +576,23 @@ const base_url = "<?= base_url(); ?>";
$(function(){
let action = 'add';
const employeeModal = bootstrap.Modal.getOrCreateInstance(document.getElementById('modalEmployee'));
const employeeDetailModal = bootstrap.Modal.getOrCreateInstance(document.getElementById('modalDetail'));
function addCsrf(formData){
if(window.APP_CSRF && window.APP_CSRF.name && !formData.has(window.APP_CSRF.name)){
formData.append(window.APP_CSRF.name, window.APP_CSRF.value);
}
return formData;
}
function ajaxError(xhr){
let message = 'Permintaan tidak dapat diproses.';
if(xhr && xhr.responseJSON && xhr.responseJSON.message) message = xhr.responseJSON.message;
else if(xhr && xhr.status === 403) message = 'Anda tidak memiliki izin untuk tindakan ini.';
else if(xhr && xhr.status === 401) message = 'Sesi telah berakhir. Silakan login kembali.';
Swal.fire('Error', message, 'error');
}
// =========================================
// DATATABLE
@@ -723,7 +750,7 @@ $(function(){
action = 'add';
$('#modalEmployee').modal('show');
employeeModal.show();
});
@@ -801,11 +828,11 @@ $(function(){
action = 'edit';
$('#modalEmployee').modal('show');
employeeModal.show();
},
'json'
);
).fail(ajaxError);
});
@@ -830,7 +857,7 @@ $(function(){
formData.append('address', $('#address').val());
formData.append('join_date', $('#join_date').val());
formData.append('resign_date', $('#resign_date').val());
formData.append('resign_date', $('#resign_date').val() || '');
formData.append('employment_status', $('#employment_status').val());
formData.append('marital_status', $('#marital_status').val());
@@ -860,6 +887,8 @@ $(function(){
formData.append('photo_file', photo);
}
addCsrf(formData);
if(
!$('#full_name').val() ||
!$('#join_date').val()
@@ -878,6 +907,9 @@ $(function(){
? base_url + 'employees/store'
: base_url + 'employees/update/' + $('#id').val();
const saveButton = $('#btnSimpan');
saveButton.prop('disabled', true);
$.ajax({
url:url,
@@ -891,7 +923,7 @@ $(function(){
if(res.status){
$('#modalEmployee').modal('hide');
employeeModal.hide();
table.ajax.reload(null,false);
@@ -910,7 +942,9 @@ $(function(){
);
}
}
},
error:ajaxError,
complete:function(){ saveButton.prop('disabled', false); }
});
@@ -1279,11 +1313,11 @@ $(function(){
`);
$('#modalDetail').modal('show');
employeeDetailModal.show();
},
'json'
);
).fail(ajaxError);
});
@@ -1305,9 +1339,16 @@ $(function(){
if(r.isConfirmed){
$.get(
base_url + 'employees/delete/' + id,
function(res){
const deleteData = new FormData();
addCsrf(deleteData);
$.ajax({
url:base_url + 'employees/delete/' + id,
type:'POST',
data:deleteData,
processData:false,
contentType:false,
dataType:'json',
success:function(res){
if(res.status){
@@ -1329,8 +1370,8 @@ $(function(){
}
},
'json'
);
error:ajaxError
});
}