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 += `
`
buttons += `
`
return `
${buttons}
`;
},
},
{
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 `
${row?.patient?.name} (${age} Tahun)
`;
}
},
{
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,
},
],
});