make counts on main table link to SummaryLogs page - WIP

This commit is contained in:
Brian Read 2024-06-30 15:38:42 +01:00
parent ce1db0a31b
commit ae0e133918
2 changed files with 12 additions and 3 deletions

View File

@ -31,6 +31,7 @@ if ($hour == 99){
} }
$stmt->execute(); $stmt->execute();
$result = $stmt->get_result(); $result = $stmt->get_result();
$result_count = $result->num_rows;
function generateLogDataTable($logData) { function generateLogDataTable($logData) {
$data = json_decode($logData, true); $data = json_decode($logData, true);
@ -73,7 +74,7 @@ function generateLogDataTable($logData) {
$keys = array_keys($mergedData); $keys = array_keys($mergedData);
$values = array_values($mergedData); $values = array_values($mergedData);
$output = '<table class="stripes" style="border-collapse: collapse; width:80%;overflow-x:auto; margin:2%"><tbody>'; $output = '<table class="stripes" style="border-collapse: collapse; width:95%;overflow-x:auto; margin:2%"><tbody>';
// Divide keys and values into sets of 6 // Divide keys and values into sets of 6
$chunks = array_chunk($keys, 6); $chunks = array_chunk($keys, 6);
@ -124,6 +125,7 @@ function generateLogDataTable($logData) {
<body> <body>
<div style="width:100%;overflow-x:auto;font-size:0.726cqw">" <div style="width:100%;overflow-x:auto;font-size:0.726cqw">"
<h1>Summary Logs for Date: <?= htmlspecialchars($date) ?> <?= $hour == 99 ? 'for All Hours' : 'and Hour: ' . htmlspecialchars($hour) ?></h1> <h1>Summary Logs for Date: <?= htmlspecialchars($date) ?> <?= $hour == 99 ? 'for All Hours' : 'and Hour: ' . htmlspecialchars($hour) ?></h1>
<h3>Found <?= $result_count ?> records.</h3>
<table style="border-collapse:collapse;width:98%"> <table style="border-collapse:collapse;width:98%">
<thead> <thead>
<tr> <tr>

View File

@ -59,7 +59,14 @@
<td tal:condition="repeat.row.index == 24" tal:attributes="class python:'col-total'" tal:content="'TOTALS'">Totals</td> <td tal:condition="repeat.row.index == 24" tal:attributes="class python:'col-total'" tal:content="'TOTALS'">Totals</td>
<td tal:condition="repeat.row.index == 25" tal:attributes="class python:'col-percent'" tal:content="'PERCENT'">Percent</td> <td tal:condition="repeat.row.index == 25" tal:attributes="class python:'col-percent'" tal:content="'PERCENT'">Percent</td>
<td tal:condition="repeat.row.index < 24" tal:content="string:${reporting_date}, ${repeat.row.index}">Hour</td> <td tal:condition="repeat.row.index < 24" tal:content="string:${reporting_date}, ${repeat.row.index}">Hour</td>
<td tal:repeat="cell row" tal:attributes="class python: 'col-' + str(repeat.cell.index)" tal:content="cell">Cell</td> <td tal:repeat="cell row" tal:attributes="class python: 'col-' + str(repeat.cell.index)">
<!-- Exclude the PERCENT column from generating links and apply the logic to rows 0 to 23 -->
<tal:condition tal:condition="repeat.row.index >= 0 and repeat.row.index < 24 and repeat.cell.index != 16">
<a tal:attributes="href string:./showSummaryLogs.php?hour=${repeat.row.index}" tal:content="cell">Cell</a>
</tal:condition>
<!-- For PERCENT column or other rows, just display the cell content -->
<tal:condition tal:condition="not (repeat.row.index >= 0 and repeat.row.index < 24 and repeat.cell.index != 16)" tal:content="cell">Cell</tal:condition>
</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>