Untitled
unknown
plain_text
22 days ago
3.3 kB
6
Indexable
Never
function custom_datatable(tableTag, endpoint, colums, button = false, message = false){ $(tableTag).DataTable({ "ajax": { "url": endpoint, "type": "POST", }, "style": 'multi', "processing": true, "serverSide": false, "footer": true, "searching": true, "pageLength": 26, "lengthChange": true, "oLanguage": { "sZeroRecords": "Data tidak ditemukan !" }, "language": { url: '//cdn.datatables.net/plug-ins/1.13.5/i18n/id.json', }, dom: "<'row'<'col-lg-6 col-md-6 col-sm-12'B><'col-lg-6 col-md-6 col-sm-12 text-end'f>>" + "<'row'<'col-sm-12'tr>>" + "<'row'<'col-sm-5'i><'col-sm-7'p>>", buttons: button == true ? [{ extend: 'excelHtml5', text: ' <span class="fa fa-file-excel"></span> Download Excel', className: 'btn btn-success btn-sm', messageTop: message, exportOptions: { modifier: { page: "all", }, }, }] : [], "order": false, 'columns': colums, rowCallback: function(row, data, index) { var api = this.api(); $('td:eq(0)', row).html('<center>'+(index + 1 + (api.page() * api.page.len())) + '.'+'</center>'); $('td:eq(8)', row).html('<strong>'+(formatRibuan(data.totalHarga)) +'</strong>'); $('td:eq(9)', row).html(`<strong class="text-danger">${formatRibuan(data.admin)}</strong>`); $('td:eq(10)', row).html(`<strong class="text-danger">${formatRibuan(data.ppn_pph)}</strong>`); $('td:eq(12)', row).html(`<strong class="text-danger">${formatRibuan(data.expense)}</strong>`); }, footerCallback: function (row, data, start, end, display) { var api = this.api(); // Remove the formatting to get integer data for summation var intVal = function (i) { return typeof i === 'string' ? i.replace(/[\$,]/g, '') * 1 : typeof i === 'number' ? i : 0; }; // Total over all pages const total_trx = display.length; const totalHarga = api.column(8).data().reduce(function (a, b) { return intVal(a) + intVal(b) }, 0); const admin = api.column(9).data().reduce(function (a, b) { return intVal(a) + intVal(b) }, 0); const pajak = api.column(10).data().reduce(function (a, b) { return intVal(a) + intVal(b) }, 0); const expense = api.column(12).data().reduce(function (a, b) { return intVal(a) + intVal(b) }, 0); data_accumulation(total_trx, totalHarga, admin, pajak, expense) }, }); } function data_accumulation(total_trx, totalHarga, admin, pajak, expense) { $('#total-pax').text(formatRibuan(total_trx)); $('#total-harga').text(formatRibuan(totalHarga)); $('#admin-pajak').text(formatRibuan(admin + pajak)); $('#admin-api').text(formatRibuan(expense)); $('#grand-total').text(formatRibuan(totalHarga - (admin + pajak))); const last_result = (totalHarga - (admin + pajak)) - expense; $('#last-result').text(formatRibuan(last_result)); }
Leave a Comment