Perbaikan Selisih Beta 1.0 dan Export

This commit is contained in:
Ariyutta
2026-08-21 10:55:13 +07:00
parent 5a0ee5cfcf
commit 78678752d5
19 changed files with 2175 additions and 1208 deletions
@@ -72,34 +72,39 @@
width: 15%;
}
.step-item {
display: flex;
align-items: flex-start;
gap: 0.75rem;
padding: 0.6rem 0.75rem;
border-left: 3px solid #0d6efd;
background-color: #f8f9ff;
border-radius: 0 6px 6px 0;
margin-bottom: 0.4rem;
font-size: 0.85rem;
color: #212529;
.formula-steps {
list-style: disc;
padding-left: 18px;
margin: 0;
font-size: 12px;
color: #000;
line-height: 1.8;
}
.step-item .step-badge {
flex-shrink: 0;
color: #0d6efd;
font-size: 1rem;
.formula-result {
color: #1565c0 !important;
font-weight: 700;
margin-top: 1px;
}
.step-item code {
background: none;
padding: 0;
font-size: 0.83rem;
color: #1a1a2e;
font-family: 'Courier New', Courier, monospace;
word-break: break-word;
.formula-section-box {
border: 1px solid #dee2e6;
border-radius: 6px;
padding: 10px 12px;
margin-bottom: 10px;
}
.formula-section-box:last-child {
margin-bottom: 0;
}
.formula-label {
color: #0f766e;
font-weight: 600;
}
.formula-number {
color: #b45309;
font-weight: 600;
}
</style>
@endsection
@@ -213,6 +218,14 @@
<!-- Selisih Tab Pane -->
<div class="tab-pane fade" id="selisih-tab-pane" role="tabpanel" aria-labelledby="selisih-tab"
tabindex="0">
<div class="d-flex gap-2 mb-3">
<select name="jenis_selisih" id="jenis_selisih" class="form-select select2"
data-placeholder="Pilih Jenis Selisih" style="max-width: 250px;">
<option value=""></option>
<option value="kekurangan">Kekurangan</option>
<option value="kelebihan">Kelebihan</option>
</select>
</div>
<!-- Tabel Data Selisih -->
<div class="table-responsive">
<table class="table table-bordered w-100 dt-styled" id="thr-selisih">
@@ -220,9 +233,10 @@
<tr>
<th>Pegawai</th>
<th>Unit Kerja</th>
<th class="text-center">THR</th>
<th class="text-center">Pajak</th>
<th class="text-center">Total</th>
<th>Keterangan</th>
<th class="text-center">Selisih Bruto</th>
<th class="text-center">Selisih Pajak</th>
<th class="text-center">Selisih Netto</th>
</tr>
</thead>
</table>
@@ -238,9 +252,9 @@
<div class="modal fade" id="detailThrModal" tabindex="-1" aria-labelledby="detailThrModalLabel" aria-hidden="true" data-bs-backdrop="static">
<div class="modal-dialog modal-lg modal-dialog-scrollable">
<div class="modal-content">
<div class="modal-header">
<div class="modal-header bg-primary text-white">
<h5 class="modal-title" id="detailThrModalLabel">Detail THR Pegawai</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<!-- Info Pegawai -->
@@ -331,6 +345,75 @@
return '<div class="d-flex justify-content-between gap-1 nominal-cell"><span>Rp.</span><span>' + number + '</span></div>';
}
function escapeHtml(str) {
return String(str)
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;');
}
function renderFormulaStepHtml(step) {
var text = String(step);
var colonIdx = text.indexOf(':');
var label = null;
var rest = text;
if (colonIdx > -1) {
label = text.slice(0, colonIdx);
rest = text.slice(colonIdx + 1);
}
var restHtml = escapeHtml(rest).replace(/-?\d+(?:[.,]\d+)?/g, '<span class="formula-number">$&</span>');
if (label !== null) {
return '<span class="formula-label">' + escapeHtml(label) + '</span>:' + restHtml;
}
return restHtml;
}
function renderFormulaSteps(container, steps) {
container.empty();
if (!steps.length) {
container.append('<p class="text-muted fst-italic mb-0">Tidak ada langkah perhitungan.</p>');
return;
}
var groups = [];
var currentGroup = [];
steps.forEach(function(step, index) {
if (!step || !String(step).trim()) {
if (currentGroup.length) {
groups.push(currentGroup);
currentGroup = [];
}
return;
}
currentGroup.push({ step: step, isLast: index === steps.length - 1 });
});
if (currentGroup.length) {
groups.push(currentGroup);
}
groups.forEach(function(group) {
var box = $('<div class="formula-section-box"></div>');
var ul = $('<ul class="formula-steps"></ul>');
group.forEach(function(item) {
var li;
if (item.isLast) {
li = $('<li class="formula-result"></li>').text(item.step);
} else {
li = $('<li></li>').html(renderFormulaStepHtml(item.step));
}
ul.append(li);
});
box.append(ul);
container.append(box);
});
}
function renderJenisPegawaiTag(jenis) {
var config = {
'Dosen': { color: 'var(--ct-primary)', rgb: 'var(--ct-primary-rgb)', icon: 'uil-user-graduate' },
@@ -356,6 +439,16 @@
'</div>';
}
function renderJenisSelisihBadge(jenis) {
if (jenis === 'Kekurangan') {
return '<span class="text-danger fw-semibold">Kekurangan</span>';
}
if (jenis === 'Kelebihan') {
return '<span class="text-warning fw-semibold">Kelebihan</span>';
}
return '<span class="text-muted">-</span>';
}
// Toggle export buttons based on active tab
$('#thrTabs button[data-bs-toggle="tab"]').on('shown.bs.tab', function(e) {
if ($(e.target).attr('id') === 'main-tab') {
@@ -475,20 +568,7 @@
$('#detail-thr-p2').text(formatRupiah(thrP2.harga_thr_p2));
$('#detail-thr-p2-pajak').text(formatRupiah(thrP2.harga_thr_p2_setelah_pajak));
var stepsList = $('#detail-steps').empty();
var steps = detail.steps || [];
if (steps.length > 0) {
steps.forEach(function(step, index) {
stepsList.append(
'<div class="step-item">' +
'<span class="step-badge">&#9658;</span>' +
'<code>' + step + '</code>' +
'</div>'
);
});
} else {
stepsList.append('<p class="text-muted fst-italic mb-0">Tidak ada langkah perhitungan.</p>');
}
renderFormulaSteps($('#detail-steps'), detail.steps || []);
$('#detailThrModal').modal('show');
});
@@ -505,6 +585,7 @@
@endif
d.jenis_pegawai = $('select#jenis_pegawai').val();
d.tahun = $('select#tahun').val();
d.jenis_selisih = $('select#jenis_selisih').val();
}
},
columns: [{
@@ -528,6 +609,17 @@
return data;
}
},
{
data: 'jenis_selisih',
name: 'jenis_selisih',
orderable: false,
searchable: false,
width: '12%',
render: function(data, type) {
if (type !== 'display') { return data; }
return renderJenisSelisihBadge(data);
}
},
{
data: 'selisih_thr_formatted',
name: 'selisih_thr_formatted',
@@ -587,20 +679,7 @@
$('#detail-thr-p2').text(formatRupiah(thrP2.harga_thr_p2));
$('#detail-thr-p2-pajak').text(formatRupiah(thrP2.harga_thr_p2_setelah_pajak));
var stepsList = $('#detail-steps').empty();
var steps = detail.steps || [];
if (steps.length > 0) {
steps.forEach(function(step, index) {
stepsList.append(
'<div class="step-item">' +
'<span class="step-badge">&#9658;</span>' +
'<code>' + step + '</code>' +
'</div>'
);
});
} else {
stepsList.append('<p class="text-muted fst-italic mb-0">Tidak ada langkah perhitungan.</p>');
}
renderFormulaSteps($('#detail-steps'), detail.steps || []);
$('#detailThrModal').modal('show');
});
@@ -611,6 +690,11 @@
tableSelisih.ajax.reload();
});
// Filter Jenis Selisih hanya berlaku untuk tabel Selisih
$('select#jenis_selisih').on('change', function() {
tableSelisih.ajax.reload();
});
// Export Main
$('a.export').on('click', function(e) {
e.preventDefault();