95 lines
3.0 KiB
JavaScript
95 lines
3.0 KiB
JavaScript
dataTable.bootstrapTable({
|
|
url:'datatable/transaksi',
|
|
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-danger ml-2" onclick="deleteData('${row?.uid}', '${row?.register?.patient?.name}')" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-title="Delete">
|
|
<i class="far fa-trash-can fa-fw"></i>
|
|
</button>
|
|
`
|
|
buttons += `
|
|
<a class="btn btn-datatable btn-icon btn-success ml-2" href="/invoice/${row?.uid}" target="_blank" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-title="Invoice">
|
|
<i class="fa-solid fa-file"></i>
|
|
</a>
|
|
`
|
|
return `
|
|
<div class="d-flex space-x">
|
|
${buttons}
|
|
</div>
|
|
`;
|
|
},
|
|
},
|
|
{
|
|
title: "Name",
|
|
field: "name",
|
|
sortable: true,
|
|
formatter: function(value, row, index) {
|
|
|
|
if (!row?.register?.patient?.birth) return '-';
|
|
|
|
const birthDate = new Date(row?.register?.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?.register?.patient?.name} <strong>(${age} Tahun)</strong>
|
|
</div>
|
|
`;
|
|
}
|
|
},
|
|
|
|
{
|
|
title: "Asuransi",
|
|
field:"register.asuransi.name",
|
|
sortable: true,
|
|
},
|
|
{
|
|
title: "Tindakan",
|
|
field:"tindakan.name",
|
|
sortable: true,
|
|
},
|
|
{
|
|
title: "Tarif",
|
|
field: "price",
|
|
sortable: true,
|
|
formatter: function(value, row, index) {
|
|
if (!value) return '0';
|
|
return 'Rp ' + new Intl.NumberFormat('id-ID').format(value);
|
|
}
|
|
|
|
},
|
|
{
|
|
title: "Pegawai",
|
|
field:"pegawai.name",
|
|
sortable: true,
|
|
},
|
|
|
|
],
|
|
});
|