From ba4a5079bbcd8ceca1730a8a17e7441e1620bb3a Mon Sep 17 00:00:00 2001 From: shieldss Date: Tue, 7 Apr 2026 13:11:34 -0400 Subject: [PATCH] Update billing.php remove dropdown display. --- public/billing.php | 494 +++++++++++++++++++++++---------------------- 1 file changed, 251 insertions(+), 243 deletions(-) diff --git a/public/billing.php b/public/billing.php index 3c1ed5c..b3d7ba2 100644 --- a/public/billing.php +++ b/public/billing.php @@ -1,5 +1,6 @@ 0.75, - 'oversized' => 0.75, - 'boxes' => 2.65, - 'clamshells' => 1.50, - 'flat_boxes' => 2.65, - 'long_boxes' => 2.65, - 'shelf' => 2.00, - 'deaccession' => 1.70, -]; - -$totals = [ - 'volumes' => 0, - 'oversized' => 0, - 'boxes' => 0, - 'clamshells' => 0, - 'flat_boxes' => 0, - 'long_boxes' => 0, - 'shelf' => 0, - 'deaccession' => 0, -]; - -$libraries = []; -$rowsByLibrary = []; - -/** - * Fetch library list - */ -$librarySql = 'SELECT university FROM LibraryLocations'; -$params = []; -$types = ''; +/* +|-------------------------------------------------------------------------- +| Helpers +|-------------------------------------------------------------------------- +*/ +function h(string $value): string +{ + return htmlspecialchars($value, ENT_QUOTES, 'UTF-8'); +} -if ($selectedLibrary !== '') { - $librarySql .= ' WHERE university = ?'; - $params[] = $selectedLibrary; - $types .= 's'; +function displayCount(int $value): string +{ + return $value > 0 ? number_format($value) : ''; } -$librarySql .= ' ORDER BY university ASC'; +/* +|-------------------------------------------------------------------------- +| Library list for datalist +|-------------------------------------------------------------------------- +*/ +$libraries = []; -$stmt = $conn->prepare($librarySql); -if (!$stmt) { - throw new RuntimeException('Prepare failed: ' . $conn->error); -} +$libraryListSql = "SELECT university FROM LibraryLocations ORDER BY university ASC"; +$libraryListResult = mysqli_query($conn, $libraryListSql); -if ($types !== '') { - $stmt->bind_param($types, ...$params); +if ($libraryListResult instanceof mysqli_result) { + while ($row = mysqli_fetch_assoc($libraryListResult)) { + $libraries[] = (string)$row['university']; + } + mysqli_free_result($libraryListResult); } -$stmt->execute(); -$result = $stmt->get_result(); +/* +|-------------------------------------------------------------------------- +| Report data +|-------------------------------------------------------------------------- +*/ +$rates = [ + 'volumes' => 0.75, + 'oversized' => 0.75, + 'boxes' => 2.65, + 'clamshells' => 1.50, + 'flat_boxes' => 2.65, + 'long_boxes' => 2.65, + 'shelf' => 2.00, + 'deaccessioned'=> 1.70, +]; -while ($row = $result->fetch_assoc()) { - $libraries[] = $row['university']; -} +$totals = [ + 'volumes' => 0, + 'oversized' => 0, + 'boxes' => 0, + 'clamshells' => 0, + 'flat_boxes' => 0, + 'long_boxes' => 0, + 'shelf' => 0, + 'deaccessioned' => 0, +]; -$stmt->close(); +$rowsByLibrary = []; -/** - * Aggregate all counts in one query - */ -$reportSql = " +$sql = " SELECT plibrary, COALESCE(SUM(CASE WHEN pcode NOT IN ('BX','SR','RB','XX','CB','GB','LB','WD') THEN cccount ELSE 0 END), 0) AS volumes, @@ -115,174 +115,203 @@ COALESCE(SUM(CASE WHEN pcode = 'GB' THEN cccount ELSE 0 END), 0) AS flat_boxes, COALESCE(SUM(CASE WHEN pcode = 'LB' THEN cccount ELSE 0 END), 0) AS long_boxes, COALESCE(SUM(CASE WHEN pcode = 'SR' THEN cccount ELSE 0 END), 0) AS shelf, - COALESCE(SUM(CASE WHEN pcode = 'WD' THEN cccount ELSE 0 END), 0) AS deaccession + COALESCE(SUM(CASE WHEN pcode = 'WD' THEN cccount ELSE 0 END), 0) AS deaccessioned FROM ProcessingAll WHERE plibrary <> 'WRLC Books (OUP)' "; -$reportParams = []; -$reportTypes = ''; +$params = []; +$types = ''; if ($selectedLibrary !== '') { - $reportSql .= " AND plibrary = ?"; - $reportParams[] = $selectedLibrary; - $reportTypes .= 's'; + $sql .= " AND plibrary = ?"; + $params[] = $selectedLibrary; + $types .= 's'; } if ($hasDateRange) { - $reportSql .= " AND cctimestamp BETWEEN ? AND ?"; - $reportParams[] = $beginFormatted . ' 00:00:00'; - $reportParams[] = $endFormatted . ' 23:59:59'; - $reportTypes .= 'ss'; + $sql .= " AND cctimestamp BETWEEN ? AND ?"; + $params[] = $beginFormatted . ' 00:00:00'; + $params[] = $endFormatted . ' 23:59:59'; + $types .= 'ss'; } -$reportSql .= " GROUP BY plibrary ORDER BY plibrary ASC"; +$sql .= " GROUP BY plibrary ORDER BY plibrary ASC"; + +$stmt = mysqli_prepare($conn, $sql); -$stmt = $conn->prepare($reportSql); if (!$stmt) { - throw new RuntimeException('Prepare failed: ' . $conn->error); + die('Query preparation failed.'); } -if ($reportTypes !== '') { - $stmt->bind_param($reportTypes, ...$reportParams); +if ($types !== '') { + mysqli_stmt_bind_param($stmt, $types, ...$params); } -$stmt->execute(); -$result = $stmt->get_result(); - -while ($row = $result->fetch_assoc()) { - $library = $row['plibrary']; - - $rowsByLibrary[$library] = [ - 'volumes' => (int) $row['volumes'], - 'oversized' => (int) $row['oversized'], - 'boxes' => (int) $row['boxes'], - 'clamshells' => (int) $row['clamshells'], - 'flat_boxes' => (int) $row['flat_boxes'], - 'long_boxes' => (int) $row['long_boxes'], - 'shelf' => (int) $row['shelf'], - 'deaccession' => (int) $row['deaccession'], - ]; - - foreach ($totals as $key => $value) { - $totals[$key] += $rowsByLibrary[$library][$key]; +mysqli_stmt_execute($stmt); +$result = mysqli_stmt_get_result($stmt); + +if ($result instanceof mysqli_result) { + while ($row = mysqli_fetch_assoc($result)) { + $library = (string)$row['plibrary']; + + $rowsByLibrary[$library] = [ + 'volumes' => (int)$row['volumes'], + 'oversized' => (int)$row['oversized'], + 'boxes' => (int)$row['boxes'], + 'clamshells' => (int)$row['clamshells'], + 'flat_boxes' => (int)$row['flat_boxes'], + 'long_boxes' => (int)$row['long_boxes'], + 'shelf' => (int)$row['shelf'], + 'deaccessioned' => (int)$row['deaccessioned'], + ]; + + foreach ($totals as $key => $value) { + $totals[$key] += $rowsByLibrary[$library][$key]; + } } + + mysqli_free_result($result); } -$stmt->close(); +mysqli_stmt_close($stmt); $values = []; $grandTotal = 0.00; foreach ($totals as $key => $count) { - $values[$key] = $count * $rateMap[$key]; + $values[$key] = $count * $rates[$key]; $grandTotal += $values[$key]; } +?> -function displayCell(int $value): string -{ - return $value > 0 ? number_format($value) : ''; +



-
-
-
    -
  • -
    - date_range - business - FILTER -
    -
    - -
    -
    - date_range - - -
    - -
    - date_range - - -
    - -
    -
    - business - - -
    -
    - -
    - - - Clear clear - - - - -
    -
    - -


    -
    -
    -
  • -
+ +
+
+
+ + + + + + + + + + + + + + Clear + +
+
- SCF Billing Counts Report + SCF Billing Counts Report - + -
- - - +
+ + - +
@@ -303,53 +332,48 @@ class="validate" $counts): ?> - + - - - - - - - - - + + + + + + + + + Total Count: - - - - - - - - + + + + + + + + Value: - $ - $ - $ - $ - $ - $ - $ - $ + $ + $ + $ + $ + $ + $ + $ + $

-

Total: $

+

Total: $

@@ -357,22 +381,6 @@ class="validate"
- - - - + \ No newline at end of file