FIX_TOTAL_TAT : RV
This commit is contained in:
parent
66dedc24e7
commit
9ce63504c0
@ -1,25 +1,25 @@
|
||||
<style>
|
||||
.table th,
|
||||
.table td {
|
||||
padding: 8px;
|
||||
}
|
||||
.table th,
|
||||
.table td {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
table.dataTable tbody td {
|
||||
padding: 4px 4px !important;
|
||||
}
|
||||
table.dataTable tbody td {
|
||||
padding: 4px 4px !important;
|
||||
}
|
||||
|
||||
.col-12 {
|
||||
.col-12 {
|
||||
|
||||
max-width: 98% !important;
|
||||
}
|
||||
max-width: 98% !important;
|
||||
}
|
||||
|
||||
.dataTables_filter {
|
||||
position: absolute;
|
||||
}
|
||||
.dataTables_filter {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.right-align-input {
|
||||
text-align: right;
|
||||
}
|
||||
.right-align-input {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="col-12" id="second_page">
|
||||
@ -35,20 +35,51 @@ table.dataTable tbody td {
|
||||
<table id="scroll-horizontal-datatable" class="table w-100 nowrap">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php foreach (array_keys($data[0]) as $header): ?>
|
||||
<th><?= esc($header) ?></th>
|
||||
<?php
|
||||
// Get headers dynamically
|
||||
$headers = array_keys($data[0]);
|
||||
?>
|
||||
<?php foreach ($headers as $header): ?>
|
||||
<th><?= esc($header) ?></th>
|
||||
<?php endforeach; ?>
|
||||
<th>TOTAL</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
// Initialize column-wise totals
|
||||
$columnTotals = array_fill_keys($headers, 0);
|
||||
?>
|
||||
<?php foreach ($data as $row): ?>
|
||||
<tr>
|
||||
<?php foreach ($row as $value): ?>
|
||||
<td class="right-align-input"><?= esc($value) ?></td>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
<tr>
|
||||
<?php
|
||||
$rowTotal = 0; // Initialize row total
|
||||
foreach ($row as $key => $value):
|
||||
// Convert numeric values to integer (ignore 'tat_category')
|
||||
$numValue = is_numeric($value) ? (int) $value : 0;
|
||||
|
||||
if ($key != 'TAT_Category') {
|
||||
$columnTotals[$key] += $numValue; // Add to column total
|
||||
$rowTotal += $numValue; // Add to row total
|
||||
}
|
||||
?>
|
||||
<td><?= esc($value) ?></td>
|
||||
<?php endforeach; ?>
|
||||
<td><strong><?= esc($rowTotal) ?></strong></td> <!-- Display row total -->
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<?php foreach ($columnTotals as $key => $total): ?>
|
||||
<th><?= ($key == "TAT_Category") ? "TOTAL" : esc($total) ?></th>
|
||||
<?php endforeach; ?>
|
||||
<th><strong><?= array_sum(array_filter($columnTotals, 'is_numeric')) ?></strong></th>
|
||||
<!-- Grand Total -->
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
</table>
|
||||
|
||||
<div>
|
||||
@ -61,41 +92,41 @@ table.dataTable tbody td {
|
||||
<!-------------------------------------------------------------------------------------------------->
|
||||
|
||||
<script>
|
||||
// Datatable document ready
|
||||
$(document).ready(function() {
|
||||
// Datatable document ready
|
||||
$(document).ready(function() {
|
||||
|
||||
var ticketsTable = $('#scroll-horizontal-datatable');
|
||||
var ticketsTable = $('#scroll-horizontal-datatable');
|
||||
|
||||
if (ticketsTable.length) {
|
||||
ticketsTable.DataTable({
|
||||
scrollX: true,
|
||||
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right
|
||||
"<'row'<'col-sm-12'tr>>" +
|
||||
"<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
|
||||
buttons: [{
|
||||
extend: 'csv',
|
||||
text: 'CSV',
|
||||
title: 'TAT BAND WISE DATA',
|
||||
if (ticketsTable.length) {
|
||||
ticketsTable.DataTable({
|
||||
scrollX: true,
|
||||
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right
|
||||
"<'row'<'col-sm-12'tr>>" +
|
||||
"<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
|
||||
buttons: [{
|
||||
extend: 'csv',
|
||||
text: 'CSV',
|
||||
title: 'TAT BAND WISE DATA',
|
||||
},
|
||||
{
|
||||
extend: 'excel',
|
||||
text: 'Excel',
|
||||
title: 'TAT BAND WISE DATA',
|
||||
}
|
||||
|
||||
],
|
||||
language: {
|
||||
search: "_INPUT_",
|
||||
searchPlaceholder: "Search..."
|
||||
},
|
||||
{
|
||||
extend: 'excel',
|
||||
text: 'Excel',
|
||||
title: 'TAT BAND WISE DATA',
|
||||
}
|
||||
paging: true, // Enable pagination
|
||||
pageLength: 10, // Set default number of rows per page (optional)
|
||||
ordering: false,
|
||||
});
|
||||
} else {
|
||||
console.error("Table atet found.");
|
||||
}
|
||||
});
|
||||
|
||||
],
|
||||
language: {
|
||||
search: "_INPUT_",
|
||||
searchPlaceholder: "Search..."
|
||||
},
|
||||
paging: true, // Enable pagination
|
||||
pageLength: 10, // Set default number of rows per page (optional)
|
||||
ordering: false,
|
||||
});
|
||||
} else {
|
||||
console.error("Table atet found.");
|
||||
}
|
||||
});
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------------------------------
|
||||
</script>
|
||||
Loading…
Reference in New Issue
Block a user