Penambahan Filter P1 Perbandingan
This commit is contained in:
@@ -148,6 +148,7 @@
|
||||
'actionButton' => '
|
||||
<a href="#" class="btn btn-sm btn-outline-success export"><i class="uil-file-download-alt"></i> Export Excel</a>
|
||||
<a href="#" class="btn btn-sm btn-outline-success export-selisih"><i class="uil-file-download-alt"></i> Export Excel</a>
|
||||
<a href="#" class="btn btn-sm btn-outline-success export-perbandingan"><i class="uil-file-download-alt"></i> Export Excel</a>
|
||||
'
|
||||
])
|
||||
|
||||
@@ -240,6 +241,7 @@
|
||||
<tr>
|
||||
<th>Pegawai</th>
|
||||
<th>Unit Kerja</th>
|
||||
<th class="d-none">NIP</th>
|
||||
<th>Jabatan Fungsional</th>
|
||||
<th>Jabatan Tugas Tambahan</th>
|
||||
<th class="text-center">Bruto</th>
|
||||
@@ -267,6 +269,7 @@
|
||||
<tr>
|
||||
<th>Pegawai</th>
|
||||
<th>Unit Kerja</th>
|
||||
<th class="d-none">NIP</th>
|
||||
<th>Keterangan</th>
|
||||
<th class="text-center">Selisih Bruto</th>
|
||||
<th class="text-center">Selisih Pajak</th>
|
||||
@@ -293,6 +296,7 @@
|
||||
<tr>
|
||||
<th>Pegawai</th>
|
||||
<th>Unit Kerja</th>
|
||||
<th class="d-none">NIP</th>
|
||||
<th class="text-center">Selisih Bruto</th>
|
||||
<th class="text-center">Selisih Pajak</th>
|
||||
<th class="text-center">Selisih Netto</th>
|
||||
@@ -417,8 +421,9 @@
|
||||
var table, tableSelisih, tablePerbandingan;
|
||||
var hideUnitKerja = {{ ($team && isset($team->unit_kerja_id) && $team->unit_kerja_id >= 1 && $team->unit_kerja_id <= 9) ? 'true' : 'false' }};
|
||||
|
||||
// Tab Main aktif secara default, jadi sembunyikan tombol export Selisih di awal
|
||||
// Tab Main aktif secara default, jadi sembunyikan tombol export Selisih & Perbandingan di awal
|
||||
$('a.export-selisih').hide();
|
||||
$('a.export-perbandingan').hide();
|
||||
|
||||
function renderRupiah(data, differs) {
|
||||
var diffClass = differs ? ' nominal-diff' : '';
|
||||
@@ -475,6 +480,7 @@
|
||||
var isMain = tabId === 'main-tab';
|
||||
$('a.export').toggle(isMain);
|
||||
$('a.export-selisih').toggle(tabId === 'selisih-tab');
|
||||
$('a.export-perbandingan').toggle(tabId === 'perbandingan-tab');
|
||||
if (isMain && table) { table.columns.adjust().draw(); }
|
||||
if (tabId === 'selisih-tab' && tableSelisih) { tableSelisih.columns.adjust().draw(); }
|
||||
if (tabId === 'perbandingan-tab' && tablePerbandingan) { tablePerbandingan.columns.adjust().draw(); }
|
||||
@@ -516,6 +522,7 @@
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{ data: 'nip', name: 'nip', orderable: false, visible: false },
|
||||
{ data: 'nama_jafung', name: 'nama_jafung', orderable: false, searchable: false, visible: false },
|
||||
{ data: 'nama_jtt', name: 'nama_jtt', orderable: false, searchable: false, visible: false },
|
||||
{
|
||||
@@ -664,6 +671,7 @@
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{ data: 'nip', name: 'nip', orderable: false, visible: false },
|
||||
{
|
||||
data: 'jenis_selisih', name: 'jenis_selisih', orderable: false, searchable: false, width: '18%',
|
||||
render: function(data, type, row) {
|
||||
@@ -724,6 +732,7 @@
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{ data: 'nip', name: 'nip', orderable: false, visible: false },
|
||||
{ data: 'selisih_bruto', name: 'selisih_bruto', orderable: false, searchable: false, width: '14%', render: function(data) { return renderRupiah(data); } },
|
||||
{ data: 'selisih_pajak', name: 'selisih_pajak', orderable: false, searchable: false, width: '14%', render: function(data) { return renderRupiah(data); } },
|
||||
{ data: 'selisih_netto', name: 'selisih_netto', orderable: false, searchable: false, width: '14%', render: function(data) { return renderRupiah(data); } }
|
||||
@@ -964,6 +973,69 @@
|
||||
showError('Gagal', 'Terjadi kesalahan saat export Excel');
|
||||
});
|
||||
});
|
||||
|
||||
$('a.export-perbandingan').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
var button = $(this);
|
||||
var originalHtml = button.html();
|
||||
var tahun = $('select#tahun').val();
|
||||
var bulan = $('select#bulan').val();
|
||||
var jenisPegawai = $('select#jenis_pegawai').val();
|
||||
var arah = $('#arah_perbandingan').val();
|
||||
@if (!$team || !isset($team->unit_kerja_id) || $team->unit_kerja_id === null || $team->unit_kerja_id === 0)
|
||||
var unitKerja = $('select#unit_kerja').val();
|
||||
@else
|
||||
var unitKerja = '{{ $team->unit_kerja_id ?? "" }}';
|
||||
@endif
|
||||
|
||||
if (!tahun) { showWarning('Perhatian', 'Silakan pilih tahun terlebih dahulu.'); return; }
|
||||
|
||||
button.addClass('disabled').html('<span class="spinner-border spinner-border-sm me-1"></span> Exporting...');
|
||||
|
||||
$.ajax({
|
||||
url: "{{ route('remunerasi.p1.logs') }}",
|
||||
method: 'POST',
|
||||
data: { _token: '{{ csrf_token() }}', nip: $('#userId').val(), nama: $('#username').val(), tahun: tahun, bulan: bulan, jenis_pegawai: jenisPegawai, unit_kerja: unitKerja, status: 'success', message: 'Export Excel Perbandingan berhasil' },
|
||||
});
|
||||
|
||||
var exportUrl = "{{ route('remunerasi.p1.export-perbandingan') }}"
|
||||
+ '?tahun=' + encodeURIComponent(tahun)
|
||||
+ '&bulan=' + encodeURIComponent(bulan)
|
||||
+ '&jenis_pegawai=' + encodeURIComponent(jenisPegawai)
|
||||
+ '&unit_kerja=' + encodeURIComponent(unitKerja)
|
||||
+ '&arah=' + encodeURIComponent(arah);
|
||||
|
||||
fetch(exportUrl)
|
||||
.then(function(response) {
|
||||
if (!response.ok) { throw new Error('gagal'); }
|
||||
var filename = 'p1_perbandingan_export.xlsx';
|
||||
var disposition = response.headers.get('Content-Disposition');
|
||||
if (disposition) {
|
||||
var match = disposition.match(/filename[^;=\n]*=['"]?([^'"\n]+)['"]?/);
|
||||
if (match) { filename = match[1]; }
|
||||
}
|
||||
return response.blob().then(function(blob) {
|
||||
return { blob: blob, filename: filename };
|
||||
});
|
||||
})
|
||||
.then(function(data) {
|
||||
var url = URL.createObjectURL(data.blob);
|
||||
var a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = data.filename;
|
||||
a.style.display = 'none';
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
URL.revokeObjectURL(url);
|
||||
button.removeClass('disabled').html(originalHtml);
|
||||
showSuccess('Berhasil!', 'File Excel berhasil didownload');
|
||||
})
|
||||
.catch(function() {
|
||||
button.removeClass('disabled').html(originalHtml);
|
||||
showError('Gagal', 'Terjadi kesalahan saat export Excel');
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
|
||||
Reference in New Issue
Block a user