feat(laporan): tambahkan format tanggal dan perhitungan due date SLA
- Menambahkan fungsi formatDate untuk menampilkan tanggal dalam format Indonesia. - Menambahkan logika perhitungan due date SLA berdasarkan tujuan penilaian dan tipe laporan. - Memperbarui render tanggal survei dan due date SLA di tabel laporan.
This commit is contained in:
@@ -93,6 +93,24 @@
|
|||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@push('scripts')
|
@push('scripts')
|
||||||
|
<script type="text/javascript">
|
||||||
|
function formatDate(date) {
|
||||||
|
const day = date.getDate().toString().padStart(2, '0');
|
||||||
|
const month = (date.getMonth() + 1).toString().padStart(2, '0');
|
||||||
|
// Months are 0-indexed
|
||||||
|
const year = date.getFullYear();
|
||||||
|
|
||||||
|
return `${day} ${getIndonesianMonth(month)} ${year}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getIndonesianMonth(month) {
|
||||||
|
const months = ['Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni',
|
||||||
|
'Juli', 'Agustus', 'September', 'Oktober', 'November', 'Desember'
|
||||||
|
];
|
||||||
|
return months[month -
|
||||||
|
1];
|
||||||
|
}
|
||||||
|
</script>
|
||||||
<script type="module">
|
<script type="module">
|
||||||
const element = document.querySelector('#laporan-table');
|
const element = document.querySelector('#laporan-table');
|
||||||
const searchInput = document.getElementById('search');
|
const searchInput = document.getElementById('search');
|
||||||
@@ -168,14 +186,40 @@
|
|||||||
tanggal_survei: {
|
tanggal_survei: {
|
||||||
title: 'Tanggal Survei',
|
title: 'Tanggal Survei',
|
||||||
render: (item, data) => {
|
render: (item, data) => {
|
||||||
return '-';
|
if(data.penilaian.waktu_penilaian){
|
||||||
}
|
return `${formatDate(new Date(data.penilaian.waktu_penilaian))}`;
|
||||||
|
}
|
||||||
|
return `${formatDate(new Date(data.penilaian.created_at))}`;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
due_date_sla: {
|
due_date_sla: {
|
||||||
title: 'Due Date SLA',
|
title: 'Due Date SLA',
|
||||||
render: (item, data) => {
|
render: (item, data) => {
|
||||||
return '-';
|
const tujuan_penilaian = data.tujuan_penilaian.name;
|
||||||
}
|
const tipe_laporan = data.penilai?.type;
|
||||||
|
const nilai_plafond = data.penilaian.nilaiPlafond?.name;
|
||||||
|
let waktu_penilaian = new Date(data.penilaian.created_at);
|
||||||
|
if(data.penilaian.waktu_penilaian){
|
||||||
|
waktu_penilaian = new Date(data.penilaian.waktu_penilaian);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(tujuan_penilaian.name==="RAP"){
|
||||||
|
waktu_penilaian.setDate(waktu_penilaian.getDate() + 3);
|
||||||
|
} else {
|
||||||
|
if(tipe_laporan==="sederhana"){
|
||||||
|
waktu_penilaian.setDate(waktu_penilaian.getDate() + 2);
|
||||||
|
} else if(tipe_laporan==="standar"){
|
||||||
|
if(nilai_plafond==="2 M - 5 M"){
|
||||||
|
waktu_penilaian.setDate(waktu_penilaian.getDate() + 3);
|
||||||
|
} else if(nilai_plafond==="< 2M"){
|
||||||
|
waktu_penilaian.setDate(waktu_penilaian.getDate() + 3);
|
||||||
|
} else {
|
||||||
|
waktu_penilaian.setDate(waktu_penilaian.getDate() + 5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return formatDate(waktu_penilaian);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
status: {
|
status: {
|
||||||
title: 'Status',
|
title: 'Status',
|
||||||
|
|||||||
Reference in New Issue
Block a user