141 lines
5.8 KiB
PHP
141 lines
5.8 KiB
PHP
<style>
|
|
.table th,
|
|
.table td {
|
|
padding: 8px;
|
|
}
|
|
|
|
table.dataTable tbody td {
|
|
padding: 4px 4px !important;
|
|
}
|
|
|
|
.col-12 {
|
|
max-width: 98% !important;
|
|
}
|
|
|
|
.dataTables_filter {
|
|
position: absolute;
|
|
}
|
|
|
|
.right-align-input {
|
|
text-align: right;
|
|
}
|
|
.dataTables_length label {height: 21px !important;}
|
|
</style>
|
|
|
|
|
|
<div class="col-12" id="second_page">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<div class="row" style="padding-bottom: 10px;">
|
|
<div class="col-6" style="align-self: center;">
|
|
<h4 style="position: relative;"><?= $page_title ?></h4>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="table-responsive">
|
|
<table data-custom-table-css="table" id="scroll-horizontal-datatable" class="table w-100 nowrap">
|
|
<thead>
|
|
<tr>
|
|
<?php
|
|
// Get headers dynamically
|
|
$headers = array_keys($data[0]);
|
|
foreach ($headers as $header): ?>
|
|
<th><?= esc(str_replace('_', ' ', $header)) ?></th>
|
|
<?php endforeach; ?>
|
|
<th>TOTAL</th>
|
|
</tr>
|
|
</thead>
|
|
|
|
<tbody>
|
|
<?php
|
|
// Initialize column-wise totals
|
|
$columnTotals = array_fill_keys($headers, 0);
|
|
foreach ($data as $row):
|
|
$rowTotal = 0; // Initialize row total
|
|
?>
|
|
<tr>
|
|
<?php foreach ($row as $key => $value):
|
|
$numValue = is_numeric($value) ? (int) $value : 0;
|
|
if ($key != 'TAT_Category') {
|
|
$columnTotals[$key] += $numValue;
|
|
$rowTotal += $numValue;
|
|
}
|
|
?>
|
|
<td><?= esc($value) ?></td>
|
|
<?php endforeach; ?>
|
|
<td><strong><?= esc($rowTotal) ?></strong></td> <!-- Row Total -->
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
|
|
<tfoot>
|
|
<tr>
|
|
<?php foreach ($columnTotals as $key => $total): ?>
|
|
<th><?= ($key == "TAT_Category" || $key == 'ACM_Name') ? "TOTAL" : esc($total) ?></th>
|
|
<?php endforeach; ?>
|
|
<th><strong><?= array_sum(array_filter($columnTotals, 'is_numeric')) ?></strong></th> <!-- Grand Total -->
|
|
</tr>
|
|
</tfoot>
|
|
</table>
|
|
</div>
|
|
|
|
</div> <!-- end card-body -->
|
|
</div> <!-- end card -->
|
|
</div> <!-- end col-12 -->
|
|
|
|
<script>
|
|
$(document).ready(function() {
|
|
var ticketsTable = $('#scroll-horizontal-datatable');
|
|
|
|
if (ticketsTable.length) {
|
|
ticketsTable.DataTable({
|
|
scrollX: true,
|
|
// dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" +
|
|
// "<'row'<'col-sm-12'tr>>" +
|
|
// "<'row'<'col-sm-5'i><'col-sm-7'p>>",
|
|
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" +
|
|
"<'row'<'col-sm-12'tr>>" +
|
|
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
|
|
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
|
|
buttons: [
|
|
{
|
|
extend: 'collection',
|
|
text: '<span class=" btn-custom"> Export </span><i class="mdi mdi-menu-down"></i>',
|
|
className: 'btn app-btn-secondary ',
|
|
buttons: [
|
|
{
|
|
extend: 'csv',
|
|
text: '<i class="mdi mdi-file-delimited " ></i><span class=" btn-custom"> CSV </span>',
|
|
title: 'BDS TAT BAND WISE DATA',
|
|
},
|
|
{
|
|
extend: 'excel',
|
|
text: '<i class="mdi mdi-file-excel " ></i><span class=" btn-custom"> EXCEL </span>',
|
|
title: 'BDS TAT BAND WISE DATA',
|
|
sheetName: 'BDS TAT BAND WISE DATA',
|
|
},
|
|
]
|
|
}
|
|
],
|
|
language: {
|
|
search: `
|
|
<div class="datatable-search-wrapper" style="position:relative; display:inline-block;">
|
|
_INPUT_
|
|
<i class="mdi mdi-magnify datatable-search-icon"
|
|
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666;"></i>
|
|
<i class="mdi mdi-close-circle datatable-clear-icon"
|
|
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666; display:none;"></i>
|
|
</div>`,
|
|
searchPlaceholder: "Search",
|
|
emptyTable: '<div class="text-center text-muted">No Data found</div>'
|
|
},
|
|
paging: true,
|
|
pageLength: 10,
|
|
ordering: false
|
|
});
|
|
} else {
|
|
console.error("Table not found.");
|
|
}
|
|
});
|
|
</script>
|