FIX_TOTAL_TAT : RV

This commit is contained in:
VENKATESHWARAN 2025-02-04 16:14:54 +05:30
parent 66dedc24e7
commit 9ce63504c0

View File

@ -35,20 +35,51 @@ table.dataTable tbody td {
<table id="scroll-horizontal-datatable" class="table w-100 nowrap"> <table id="scroll-horizontal-datatable" class="table w-100 nowrap">
<thead> <thead>
<tr> <tr>
<?php foreach (array_keys($data[0]) as $header): ?> <?php
// Get headers dynamically
$headers = array_keys($data[0]);
?>
<?php foreach ($headers as $header): ?>
<th><?= esc($header) ?></th> <th><?= esc($header) ?></th>
<?php endforeach; ?> <?php endforeach; ?>
<th>TOTAL</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php
// Initialize column-wise totals
$columnTotals = array_fill_keys($headers, 0);
?>
<?php foreach ($data as $row): ?> <?php foreach ($data as $row): ?>
<tr> <tr>
<?php foreach ($row as $value): ?> <?php
<td class="right-align-input"><?= esc($value) ?></td> $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; ?> <?php endforeach; ?>
<td><strong><?= esc($rowTotal) ?></strong></td> <!-- Display row total -->
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </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> </table>
<div> <div>