hr dan payroll
This commit is contained in:
@@ -6,6 +6,21 @@
|
||||
<h5>Jurnal Umum</h5>
|
||||
<button class="btn btn-warning btn-add">Tambah Jurnal</button>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<div class="col-sm-6 col-md-4 col-lg-3">
|
||||
<label for="journalStatusFilter" class="form-label">Status</label>
|
||||
<select id="journalStatusFilter" class="form-select">
|
||||
<option value="">Semua Status</option>
|
||||
<option value="draft">Draft</option>
|
||||
<option value="submitted">Diajukan</option>
|
||||
<option value="approved">Disetujui</option>
|
||||
<option value="posted">Terposting</option>
|
||||
<option value="rejected">Ditolak</option>
|
||||
<option value="reversed">Reversal</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--<form id="filterForm" class="row mb-3">-->
|
||||
|
||||
@@ -63,7 +78,7 @@
|
||||
<div class="modal-content">
|
||||
|
||||
<div class="modal-header bg-warning text-white">
|
||||
<h5>Tambah Jurnal</h5>
|
||||
<h5 id="journalModalTitle">Tambah Jurnal</h5>
|
||||
<button class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
|
||||
@@ -140,7 +155,8 @@
|
||||
<strong>No Ref:</strong> <span id="d_noref"></span><br>
|
||||
<strong>Keterangan:</strong> <span id="d_keterangan"></span><br>
|
||||
<strong>Dibuat oleh:</strong> <span id="d_createdby"></span><br>
|
||||
<strong>Status:</strong> <span id="d_status"></span>
|
||||
<strong>Status:</strong> <span id="d_status"></span>
|
||||
<div id="d_rejection" class="alert alert-danger mt-3 d-none"></div>
|
||||
</div>
|
||||
|
||||
<table class="table table-bordered">
|
||||
@@ -183,6 +199,7 @@ $(function(){
|
||||
|
||||
let accounts = [];
|
||||
let mode = 'manual';
|
||||
let editJournalId = 0;
|
||||
|
||||
// ================= LOAD ACCOUNTS
|
||||
function loadAccounts(){
|
||||
@@ -374,6 +391,27 @@ $('.btn-add').click(async function(){
|
||||
$('#formTotalKredit').text('0');
|
||||
|
||||
$('#modeManual').click(); // default jurnal manual dengan dua akun
|
||||
editJournalId = 0;
|
||||
$('#journalModalTitle').text('Tambah Jurnal');
|
||||
$('#btnSimpan').text('Simpan');
|
||||
});
|
||||
|
||||
$(document).on('click','.btn-edit-rejected',async function(){
|
||||
const id=$(this).data('id');
|
||||
await loadAccounts();
|
||||
await loadBaseJurnal();
|
||||
$('#modeManual').click();
|
||||
$.get("<?= base_url('jurnal/detail/'); ?>"+id,function(res){
|
||||
editJournalId=id;
|
||||
$('#journalModalTitle').text('Koreksi Jurnal Ditolak');
|
||||
$('#btnSimpan').text('Simpan Koreksi');
|
||||
$('#tanggal').val(res.header.tanggal);
|
||||
$('#keterangan').val(res.header.keterangan);
|
||||
$('#tableDetail tbody').empty();
|
||||
(res.detail||[]).forEach(function(row){addRow({account_id:row.account_id,debit:Number(row.debit)>0?row.debit:'',kredit:Number(row.kredit)>0?row.kredit:''});});
|
||||
hitungTotalForm();
|
||||
$('#modalJurnal').modal('show');
|
||||
},'json').fail(function(xhr){Swal.fire('Error',xhr.responseJSON?.message||'Jurnal tidak dapat dimuat.','error');});
|
||||
});
|
||||
|
||||
$('#btnSimpan').click(function(){
|
||||
@@ -426,7 +464,10 @@ $('#btnSimpan').click(function(){
|
||||
return;
|
||||
}
|
||||
// lanjut simpan
|
||||
$.post("<?= base_url('jurnal/save'); ?>", {
|
||||
const saveUrl=editJournalId
|
||||
? "<?= base_url('jurnal/update_rejected/'); ?>"+editJournalId
|
||||
: "<?= base_url('jurnal/save'); ?>";
|
||||
$.post(saveUrl, {
|
||||
tanggal: $('#tanggal').val(),
|
||||
keterangan: $('#keterangan').val(),
|
||||
account_id: account_id,
|
||||
@@ -436,6 +477,7 @@ $('#btnSimpan').click(function(){
|
||||
|
||||
if(res.status){
|
||||
$('#modalJurnal').modal('hide');
|
||||
editJournalId=0;
|
||||
$('#tableJurnal').DataTable().ajax.reload(null,false);
|
||||
Swal.fire('Sukses',res.message,'success');
|
||||
} else {
|
||||
@@ -454,7 +496,10 @@ let table = $('#tableJurnal').DataTable({
|
||||
order:[[1,'desc']],
|
||||
ajax:{
|
||||
url:"<?= base_url('jurnal/get_data'); ?>",
|
||||
type:"POST"
|
||||
type:"POST",
|
||||
data:function(d){
|
||||
d.status = $('#journalStatusFilter').val();
|
||||
}
|
||||
},
|
||||
columnDefs:[
|
||||
{ targets:[4,5], className:'text-end' }
|
||||
@@ -476,6 +521,10 @@ let table = $('#tableJurnal').DataTable({
|
||||
}
|
||||
});
|
||||
|
||||
$('#journalStatusFilter').on('change', function(){
|
||||
table.ajax.reload(null, true);
|
||||
});
|
||||
|
||||
// DELETE
|
||||
$(document).on('click','.btn-delete',function(){
|
||||
let id = $(this).data('id');
|
||||
@@ -520,10 +569,7 @@ let table = $('#tableJurnal').DataTable({
|
||||
});
|
||||
|
||||
// DETAIL
|
||||
$(document).on('click','.btn-detail',function(){
|
||||
|
||||
let id = $(this).data('id');
|
||||
|
||||
function openJournalDetail(id){
|
||||
$.get("<?= base_url('jurnal/detail/'); ?>" + id, function(res){
|
||||
|
||||
$('#d_tanggal').text(res.header.tanggal);
|
||||
@@ -531,6 +577,7 @@ $(document).on('click','.btn-detail',function(){
|
||||
$('#d_keterangan').text(res.header.keterangan);
|
||||
$('#d_createdby').text(res.user ? res.user.nama : '-');
|
||||
$('#d_status').text(String(res.header.status || '').toUpperCase());
|
||||
if(res.header.rejection_reason){$('#d_rejection').removeClass('d-none').html('<strong>Alasan penolakan sebelumnya</strong><br>'+String(res.header.rejection_reason).replace(/[&<>'"]/g,function(c){return{'&':'&','<':'<','>':'>',"'":''','"':'"'}[c];}));}else{$('#d_rejection').addClass('d-none').empty();}
|
||||
let history=(res.history||[]).map(h=>`${h.from_status||'-'} → ${h.to_status} oleh ${h.changed_by_name||'-'} (${h.changed_at})${h.notes?' — '+h.notes:''}`).join('<br>');
|
||||
$('#statusHistory').html(history || 'Belum ada perubahan status.');
|
||||
|
||||
@@ -558,9 +605,11 @@ $(document).on('click','.btn-detail',function(){
|
||||
|
||||
$('#modalDetail').modal('show');
|
||||
|
||||
},'json');
|
||||
},'json').fail(function(xhr){Swal.fire('Error',xhr.responseJSON?.message||'Detail jurnal tidak dapat dimuat.','error');});
|
||||
}
|
||||
|
||||
});
|
||||
$(document).on('click','.btn-detail',function(){openJournalDetail($(this).data('id'));});
|
||||
$(function(){const focus=Number(new URLSearchParams(window.location.search).get('focus')||0);if(focus>0)openJournalDetail(focus);});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user