Folder reorganize 1
This commit is contained in:
93
rfid.php
Normal file
93
rfid.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php // phpcs:ignoreFile
|
||||
|
||||
require __DIR__ . '/session.php';
|
||||
require __DIR__ . '/userAccess.php';
|
||||
|
||||
$serverName = 'SQLSERVER';
|
||||
$uid = 'crw';
|
||||
$pwd = 'rp02751';
|
||||
$connectionInfo = [
|
||||
'UID' => $uid,
|
||||
'PWD' => $pwd,
|
||||
'ReturnDatesAsStrings' => true,
|
||||
'CharacterSet' => 'utf-8',
|
||||
'Database' => 'TruckTracking',
|
||||
];
|
||||
|
||||
if (!function_exists('sqlsrv_connect')) {
|
||||
throw new RuntimeException('SQLSRV extension is required for the RFID dashboard.');
|
||||
}
|
||||
|
||||
if (!defined('SQLSRV_FETCH_ASSOC')) {
|
||||
define('SQLSRV_FETCH_ASSOC', 2);
|
||||
}
|
||||
|
||||
$conn = call_user_func('sqlsrv_connect', $serverName, $connectionInfo);
|
||||
|
||||
if ($conn === false) {
|
||||
die(print_r(call_user_func('sqlsrv_errors'), true));
|
||||
}
|
||||
|
||||
$sql = 'SELECT * FROM DumpHistory ORDER BY ScanDate DESC';
|
||||
$stmt = call_user_func('sqlsrv_query', $conn, $sql);
|
||||
|
||||
if ($stmt === false) {
|
||||
die(print_r(call_user_func('sqlsrv_errors'), true));
|
||||
}
|
||||
|
||||
$totalsQuery = 'SELECT SUM(NetWt) AS totalwt, SUM(CASE WHEN DumpLocation = \'Truck Dump\' THEN NetWt END) AS truckwt FROM DumpHistory';
|
||||
$totalsStmt = call_user_func('sqlsrv_query', $conn, $totalsQuery);
|
||||
$totals = $totalsStmt ? call_user_func('sqlsrv_fetch_array', $totalsStmt, SQLSRV_FETCH_ASSOC) : ['totalwt' => 0, 'truckwt' => 0];
|
||||
|
||||
$pageTitle = 'RFID Truck Log';
|
||||
$pageSubtitle = 'Recent dumps and weight totals';
|
||||
$pageDescription = 'RFID scan history for vehicle loads including dump locations and crop days.';
|
||||
|
||||
require __DIR__ . '/includes/layout/header.php';
|
||||
require __DIR__ . '/menuinclude.php';
|
||||
?>
|
||||
|
||||
<div class="app-content">
|
||||
<section class="data-panel">
|
||||
<header class="table-actions">
|
||||
<span class="status-pill">West Table Total: <?php echo number_format(($totals['totalwt'] ?? 0) - ($totals['truckwt'] ?? 0)); ?> lbs</span>
|
||||
<span class="status-pill">Truck Dump Total: <?php echo number_format($totals['truckwt'] ?? 0); ?> lbs</span>
|
||||
</header>
|
||||
<div class="table-scroll">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Load Number</th>
|
||||
<th>Vehicle ID</th>
|
||||
<th>Dump Location</th>
|
||||
<th>Scan Date</th>
|
||||
<th>Net Weight</th>
|
||||
<th>Crop Day</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php while ($row = call_user_func('sqlsrv_fetch_array', $stmt, SQLSRV_FETCH_ASSOC)) : ?>
|
||||
<tr>
|
||||
<td><?php echo htmlspecialchars((string) $row['LoadNo']); ?></td>
|
||||
<td><?php echo htmlspecialchars((string) $row['VehicleId']); ?></td>
|
||||
<td><?php echo htmlspecialchars((string) $row['DumpLocation']); ?></td>
|
||||
<td><?php echo htmlspecialchars((string) $row['ScanDate']); ?></td>
|
||||
<td><?php echo number_format((float) $row['NetWt']); ?></td>
|
||||
<td><?php echo htmlspecialchars((string) $row['CropDay']); ?></td>
|
||||
</tr>
|
||||
<?php endwhile; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
if ($totalsStmt) {
|
||||
call_user_func('sqlsrv_free_stmt', $totalsStmt);
|
||||
}
|
||||
call_user_func('sqlsrv_free_stmt', $stmt);
|
||||
call_user_func('sqlsrv_close', $conn);
|
||||
|
||||
require __DIR__ . '/includes/layout/footer.php';
|
||||
?>
|
||||
Reference in New Issue
Block a user