Files
controls-web/data/truckdump.php
2026-02-17 12:44:37 -06:00

134 lines
5.2 KiB
PHP

<?php
date_default_timezone_set('America/Chicago');
$curDate = date('l, M j, Y h:i:s a');
require "../includes/items.php";
// Read cached truck dump stats (refreshed every 60s by cron)
$con = mysqli_connect('192.168.0.10', 'corey', '41945549', 'controls');
$cache = null;
if ($con) {
$result = mysqli_query($con, "SELECT * FROM truckdump_stats_cache WHERE id = 1");
if ($result) {
$cache = mysqli_fetch_assoc($result);
}
mysqli_close($con);
}
// Fallback values if cache is empty
$eastSinceLast = $cache['east_since_last'] ?? '--:--:--';
$eastBetween = $cache['east_between_dumps'] ?? '--:--:--';
$eastAvg = $cache['east_avg_10'] ?? '--:--:--';
$west1SinceLast = $cache['west1_since_last'] ?? '--:--:--';
$west1Between = $cache['west1_between_dumps'] ?? '--:--:--';
$west1Avg = $cache['west1_avg_10'] ?? '--:--:--';
$west2SinceLast = $cache['west2_since_last'] ?? '--:--:--';
$west2Between = $cache['west2_between_dumps'] ?? '--:--:--';
$west2Avg = $cache['west2_avg_10'] ?? '--:--:--';
$updated_at = $cache['updated_at'] ?? 'Unknown';
?>
<table width="100%" border="1" cellspacing="0" cellpadding="2">
<tr >
<td id="datetime" colspan="4">
<?php echo $curDate; ?>
</td>
</tr>
<?php require __DIR__ . '/../includes/alerts.php'; ?>
<tr>
<td id="vtitle" id="padded">Last Update:</a></td>
<td id="sum-count"colspan="2"><?php echo $updated_at; ?></td>
</tr>
<tr>
<td colspan="3" id="title">Dumps Combined Totals</td>
</tr>
<tr>
<td id="vtitle" id="padded">24hr Total Dumps:</a></td>
<td id="sum-count"colspan="2"><?php echo (($value['24hrnorth'])+($value['24hrsouth'])+($value['24hrwest2'])); ?></td>
</tr>
<tr>
<td id="vtitle" id="padded">YTD Total Dumps:</a></td>
<td id="sum-count" colspan="2"><?php echo (($value['totnorth'])+($value['totsouth'])+($value['totwest2'])); ?></td>
</tr>
<tr>
<tr>
<td colspan="3" id="title">East Truck Dump</td>
</tr>
<tr>
<td id="vtitle" id="padded">24hr Total Dumps:</a></td>
<td id="sum-count"colspan="2"><?php echo $value['24hrnorth']; ?></td>
</tr>
<tr>
<td id="vtitle" id="padded">YTD Total Dumps:</a></td>
<td id="sum-count" colspan="2"><?php echo $value['totnorth']; ?></td>
</tr>
<tr>
<td id="vtitle" id="padded">Time Since Last Dump:</a></td>
<td id="sum-count" colspan="2"><?php echo $eastSinceLast; ?></td>
</tr>
<tr>
<td id="vtitle" id="padded">Average Between Last 10 Dumps</a></td>
<td id="sum-count" colspan="2"><?php echo $eastAvg; ?></td>
</tr>
<tr>
<td id="vtitle" id="padded">Time Between Dumps:</a></td>
<td id="sum-count" colspan="2"><?php echo $eastBetween; ?></td>
</tr>
<tr>
<td colspan="3" id="title"> West Truck Dump 1</td>
</tr>
<tr>
<td id="vtitle" id="padded">24hr Total Dumps:</a></td>
<td id="sum-count" colspan="2"><?php echo $value['24hrsouth']; ?></td>
</tr>
<tr>
<td id="vtitle" id="padded">YTD Total Dumps:</a></td>
<td id="sum-count" colspan="2"><?php echo $value['totsouth']; ?></td>
</tr>
<tr>
<td id="vtitle" id="padded">Time Since Last Dump:</a></td>
<td id="sum-count" colspan="2"><?php echo $west1SinceLast; ?></td>
</tr>
<tr>
<td id="vtitle" id="padded">Average Between Last 10 Dumps</a></td>
<td id="sum-count" colspan="2"><?php echo $west1Avg; ?></td>
</tr>
<tr>
<td id="vtitle" id="padded">Time Between Dumps:</a></td>
<td id="sum-count" colspan="2"><?php echo $west1Between; ?></td>
</tr><tr>
<td colspan="3" id="title"> West Truck Dump 2</td>
</tr>
<tr>
<td id="vtitle" id="padded">24hr Total Dumps:</a></td>
<td id="sum-count" colspan="2"><?php echo $value['24hrwest2']; ?></td>
</tr>
<tr>
<td id="vtitle" id="padded">YTD Total Dumps:</a></td>
<td id="sum-count" colspan="2"><?php echo $value['totwest2']; ?></td>
</tr>
<tr>
<td id="vtitle" id="padded">Time Since Last Dump:</a></td>
<td id="sum-count" colspan="2"><?php echo $west2SinceLast; ?></td>
</tr>
<tr>
<td id="vtitle" id="padded">Average Between Last 10 Dumps</a></td>
<td id="sum-count" colspan="2"><?php echo $west2Avg; ?></td>
</tr>
<tr>
<td id="vtitle" id="padded">Time Between Dumps:</a></td>
<td id="sum-count" colspan="2"><?php echo $west2Between; ?></td>
</tr>
</table>