111 lines
3.7 KiB
JavaScript
111 lines
3.7 KiB
JavaScript
dataTable.bootstrapTable({
|
|
url:'datatable/registrasi',
|
|
showColumns: true,
|
|
showColumnsToggleAll: true,
|
|
showRefresh: true,
|
|
sortable: true,
|
|
search: true,
|
|
searchOnEnterKey: false,
|
|
searchHighlight: false,
|
|
pagination: true,
|
|
pageSize: 10,
|
|
pageList: [25, 50, 100, 200],
|
|
cookie: true,
|
|
icons: {
|
|
refresh: "fas fa-sync",
|
|
columns: "fas fa-th-list",
|
|
},
|
|
columns: [
|
|
{
|
|
title: "Action",
|
|
field: "uid",
|
|
sortable: true,
|
|
formatter: (value, row) => {
|
|
let buttons = "";
|
|
buttons += `
|
|
<button class="btn btn-datatable btn-icon btn-primary my-auto" onclick="editData(this)" data-uid="${row.uid}" data-pasien_uid="${row.pasien_uid}" data-asuransi_uid="${row.asuransi_uid}" data-no_card_asuransi="${row.no_card_asuransi}" data-ruang_pelayanan_uid="${row.ruang_pelayanan_uid}" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-title="Edit">
|
|
<i class="far fa-edit fa-fw"></i>
|
|
</button>
|
|
`
|
|
buttons += `
|
|
<button class="btn btn-datatable btn-icon btn-danger ml-2" onclick="deleteData('${row?.uid}', '${row?.patient?.name}')" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-title="Delete">
|
|
<i class="far fa-trash-can fa-fw"></i>
|
|
</button>
|
|
`
|
|
return `
|
|
<div class="d-flex space-x">
|
|
${buttons}
|
|
</div>
|
|
`;
|
|
},
|
|
},
|
|
{
|
|
title: "Name",
|
|
field: "name",
|
|
sortable: true,
|
|
formatter: function(value, row, index) {
|
|
if (!row?.patient?.birth) return '-';
|
|
|
|
const birthDate = new Date(row?.patient?.birth);
|
|
const today = new Date();
|
|
let age = today.getFullYear() - birthDate.getFullYear();
|
|
const m = today.getMonth() - birthDate.getMonth();
|
|
|
|
if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) {
|
|
age--;
|
|
}
|
|
|
|
return `
|
|
<div style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
|
|
${row?.patient?.name} <strong>(${age} Tahun)</strong>
|
|
</div>
|
|
`;
|
|
}
|
|
},
|
|
|
|
|
|
{
|
|
title: "Asuransi",
|
|
field:"asuransi.name",
|
|
sortable: true,
|
|
},
|
|
{
|
|
title: "No.Card Asuransi",
|
|
field:"no_card_asuransi",
|
|
sortable: true,
|
|
},
|
|
{
|
|
title: "Tanggal Registrasi",
|
|
field: "created_at",
|
|
sortable: true,
|
|
formatter: function(value, row, index) {
|
|
console.log(row);
|
|
|
|
if (!value) return '-';
|
|
|
|
const date = new Date(value);
|
|
const options = { year: 'numeric', month: 'short', day: 'numeric' };
|
|
const formattedDate = date.toLocaleDateString('id-ID', options);
|
|
|
|
const hours = String(date.getHours()).padStart(2, '0');
|
|
const minutes = String(date.getMinutes()).padStart(2, '0');
|
|
|
|
return `${formattedDate} ${hours}:${minutes}`;
|
|
}
|
|
},
|
|
|
|
{
|
|
title: "Ruang Pelayanan",
|
|
field:'room_service.name',
|
|
sortable: true,
|
|
},
|
|
|
|
{
|
|
title: "Pegawai",
|
|
field:'pegawai.name',
|
|
sortable: true,
|
|
},
|
|
|
|
],
|
|
});
|