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