From 0dd1fb48ecc8e1d6594ffd20c117feb721e5ca07 Mon Sep 17 00:00:00 2001 From: shieldss Date: Wed, 8 Apr 2026 13:48:05 -0400 Subject: [PATCH] refactor refactor of list.php --- public/list.php | 608 ++++++++++++++++++++++-------------- public/refile/refile.ndjson | 28 ++ 2 files changed, 398 insertions(+), 238 deletions(-) diff --git a/public/list.php b/public/list.php index e51166c..88af9ee 100644 --- a/public/list.php +++ b/public/list.php @@ -1,279 +1,411 @@ $_SESSION['expire']) { - session_destroy(); - header("Location: login.php"); - exit; - } -} else { - header("Location: login.php"); + +if (!isset($_SESSION['user_id'], $_SESSION['admin']) || $_SESSION['admin'] !== 'yes') { + header('Location: login.php'); + exit; +} + +if (!isset($_SESSION['expire']) || time() > (int)$_SESSION['expire']) { + session_destroy(); + header('Location: login.php'); exit; } include 'header.php'; -// Get & sanitize inputs -$beginurl = $_GET['begin'] ?? ''; -$endurl = $_GET['end'] ?? ''; -$search = isset($_GET['search']) ? htmlspecialchars(trim($_GET['search'])) : ''; -$order = $_GET['order'] ?? 'ptraylocation'; -$sort = $_GET['sort'] ?? 'ASC'; -$date = $_GET['date'] ?? ''; -$sort2 = $sort === 'ASC' ? 'DESC' : 'ASC'; -$searchurl= $search ? "&search={$search}" : ''; - -// Date-range SQL -if ($beginurl && $endurl) { - $b = date("Y-m-d", strtotime($beginurl)) . ' 00:00:00'; - $e = date("Y-m-d", strtotime($endurl)) . ' 23:59:59'; - $daterange = " AND (ptimestamp BETWEEN \"$b\" AND \"$e\") "; -} else { - $daterange = ''; +if (!isset($conn) || !($conn instanceof mysqli)) { + die('Database connection not available.'); } -// WHERE-clause -if ($search) { - $searchstring = "WHERE ptraylocation LIKE '%{$search}%' "; -} elseif ($date) { - $searchstring = "WHERE ptimestamp >= DATE_SUB(CURRENT_DATE, INTERVAL 1 {$date}) "; -} else { - $searchstring = ''; +date_default_timezone_set('America/New_York'); + +function h($value) +{ + return htmlspecialchars((string)($value ?? ''), ENT_QUOTES, 'UTF-8'); } -// Run query -$sql = "SELECT * FROM ProcessingAll {$searchstring} {$daterange} ORDER BY {$order} {$sort}"; -$query = mysqli_query($conn, $sql); -$row_cnt = mysqli_num_rows($query); -?> - - - +$beginurl = isset($_GET['begin']) ? trim((string)$_GET['begin']) : ''; +$endurl = isset($_GET['end']) ? trim((string)$_GET['end']) : ''; +$search = isset($_GET['search']) ? trim((string)$_GET['search']) : ''; +$order = isset($_GET['order']) ? trim((string)$_GET['order']) : 'ptraylocation'; +$sort = isset($_GET['sort']) ? strtoupper(trim((string)$_GET['sort'])) : 'ASC'; +$date = isset($_GET['date']) ? strtoupper(trim((string)$_GET['date'])) : ''; - +} + +$sql .= " ORDER BY {$order} {$sort}"; +$stmt = mysqli_prepare($conn, $sql); +if (!$stmt) { + die('Query preparation failed: ' . h($conn->error)); +} + +if ($types !== '') { + mysqli_stmt_bind_param($stmt, $types, ...$params); +} + +mysqli_stmt_execute($stmt); +$result = mysqli_stmt_get_result($stmt); +$row_cnt = ($result instanceof mysqli_result) ? mysqli_num_rows($result) : 0; +?> + + + +
-

SCF Tray Processing List

- - -
- -
-
-
    -
  • -
    - date_rangeDate Filter +

    SCF Tray Processing List

    + +
    +
    +
    +
      +
    • +
      + date_rangeDate Filter +
      +
      +
      +
      + date_range + + +
      +
      + date_range + + +
      + + + + + +
      + + + clearClear + + + +
      +
      +
      +
    • +
    -
    -
    -
    - date_range - - -
    -
    - date_range - - -
    - - -
    - - - clearClear - - - -
    -
    +
    + +
    +
    +
      +
    • +
      + searchSearch Tray/Shelf +
      +
      +
      +
      + search + + +
      + + + + + + + + +
      + + + clear + + + +
      +
      +
      +
    • +
    -
  • -
-
+
- -
-
- -
-
-
- - -
- -
- - -
-
-
-
- 0): ?> -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - 0) echo ''; else echo ''; ?> - - - - - - - - - - - - - - -
ProcessingCross Checkwarning
- Tray Number - - Library - - Name - - Time - - Count - - Full - - Name - - Time - - Count - - Match -
0): ?>
+
+
+
+
+ 0): ?> +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + 0 ? ' class="red lighten-4"' : ''; ?>> + + + + + + + + + + + + + + + +
ProcessingCross Checkwarning
+ Tray Number + + Library + + Name + + Time + + Count + + Full + + Name + + Time + + Count + + Match +
+ + + + + + + + + + + 0): ?> + + +
+ +
+
-
-
- + \ No newline at end of file +}); + + + \ No newline at end of file diff --git a/public/refile/refile.ndjson b/public/refile/refile.ndjson index 29c3ad1..3567096 100644 --- a/public/refile/refile.ndjson +++ b/public/refile/refile.ndjson @@ -28161,3 +28161,31 @@ {"date":"2026-02-20 09:24:12","name":"Sarah Concepcion","barcode":"32882012869783X","tray barcode":"R31M04S09T12 BC","status":"Item In Place","step":"1"} {"date":"2026-02-20 09:24:27","name":"Sarah Concepcion","barcode":"32777011286973X","tray barcode":"R32M23S13T13 BJ","status":"Item In Place","step":"1"} {"date":"2026-02-20 09:24:54","name":"Sarah Concepcion","barcode":"32882019481103X","tray barcode":"R22M25S25T09 BC","status":"Item In Place","step":"1"} +{"date":"2026-04-08 13:23:12","name":"Katy Puccio","barcode":"32777007121788X","tray barcode":"R35M23S14T02 BJ","status":"Item In Place","step":"1"} +{"date":"2026-04-08 13:23:49","name":"Katy Puccio","barcode":"32883001189423X","tray barcode":"R25M09S09T06 BC","status":"Item In Place","step":"1"} +{"date":"2026-04-08 13:24:38","name":"Katy Puccio","barcode":"31194002525107X","tray barcode":"R20M20S09T08 BC","status":"Item In Place","step":"1"} +{"date":"2026-04-08 13:25:01","name":"Katy Puccio","barcode":"32882014544624X","tray barcode":"R33M27S06T11 AB","status":"Item In Place","step":"1"} +{"date":"2026-04-08 13:25:36","name":"Katy Puccio","barcode":"32882006817236X","tray barcode":"R34M28S08T08 AB","status":"Item In Place","step":"1"} +{"date":"2026-04-08 13:26:05","name":"Katy Puccio","barcode":"39020019063216X","tray barcode":"R22M14S05T04 BC","status":"Item In Place","step":"1"} +{"date":"2026-04-08 13:26:33","name":"Katy Puccio","barcode":"32882002631615X","tray barcode":"R25M21S26T09 BC","status":"Item In Place","step":"1"} +{"date":"2026-04-08 13:27:01","name":"Katy Puccio","barcode":"32884003105581X","tray barcode":"R34M09S08T11 AB","status":"Item In Place","step":"1"} +{"date":"2026-04-08 13:27:25","name":"Katy Puccio","barcode":"32884003094199X","tray barcode":"R34M04S07T16 AB","status":"Item In Place","step":"1"} +{"date":"2026-04-08 13:27:54","name":"Katy Puccio","barcode":"32882014584174X","tray barcode":"R35M20S29T16 AA","status":"Item In Place","step":"1"} +{"date":"2026-04-08 13:28:19","name":"Katy Puccio","barcode":"39020019355646X","tray barcode":"R02M28S2AT13 AB","status":"Item In Place","step":"1"} +{"date":"2026-04-08 13:29:12","name":"Katy Puccio","barcode":"31194003145079X","tray barcode":"R29M21S25T10 CC","status":"Item In Place","step":"1"} +{"date":"2026-04-08 13:29:37","name":"Katy Puccio","barcode":"32882017945638X","tray barcode":"R22M07S06T06 DD","status":"Item In Place","step":"1"} +{"date":"2026-04-08 13:30:04","name":"Katy Puccio","barcode":"39020015612909X","tray barcode":"R25M08S17T03 BC","status":"Item In Place","step":"1"} +{"date":"2026-04-08 13:30:34","name":"Katy Puccio","barcode":"39020027120446X","tray barcode":"R14M04S07T08 CD","status":"Item In Place","step":"1"} +{"date":"2026-04-08 13:31:04","name":"Katy Puccio","barcode":"32882021865830X","tray barcode":"R25M11S22T05 CC","status":"Item In Place","step":"1"} +{"date":"2026-04-08 13:31:34","name":"Katy Puccio","barcode":"39020007545414X","tray barcode":"R14M27S26T08 BC","status":"Item In Place","step":"1"} +{"date":"2026-04-08 13:32:02","name":"Katy Puccio","barcode":"39020020283951X","tray barcode":"R34M04S28T04 AJ","status":"Item In Place","step":"1"} +{"date":"2026-04-08 13:32:30","name":"Katy Puccio","barcode":"39020003459511X","tray barcode":"R25M27S09T09 BC","status":"Item In Place","step":"1"} +{"date":"2026-04-08 13:32:55","name":"Katy Puccio","barcode":"39020007624722X","tray barcode":"R26M11S16T07 AJ","status":"Item In Place","step":"1"} +{"date":"2026-04-08 13:33:22","name":"Katy Puccio","barcode":"32884003253340X","tray barcode":"R27M25S06T01 BC","status":"Item In Place","step":"1"} +{"date":"2026-04-08 13:33:50","name":"Katy Puccio","barcode":"30530002448686X","tray barcode":"R20M09S02T06 CC","status":"Item In Place","step":"1"} +{"date":"2026-04-08 13:34:15","name":"Katy Puccio","barcode":"32884000630524X","tray barcode":"R30M13S03T11 BJ","status":"Item In Place","step":"1"} +{"date":"2026-04-08 13:34:38","name":"Katy Puccio","barcode":"32777020970989X","tray barcode":"R20M22S28T07 CC","status":"Item In Place","step":"1"} +{"date":"2026-04-08 13:35:03","name":"Katy Puccio","barcode":"32884003123261X","tray barcode":"R36M02S28T09 AA","status":"Item In Place","step":"1"} +{"date":"2026-04-08 13:35:31","name":"Katy Puccio","barcode":"32777007200145X","tray barcode":"R32M11S13T14 AJ","status":"Item In Place","step":"1"} +{"date":"2026-04-08 13:36:01","name":"Katy Puccio","barcode":"32777020854167X","tray barcode":"R13M09S02T03 DE","status":"Item In Place","step":"1"} +{"date":"2026-04-08 13:36:36","name":"Katy Puccio","barcode":"32883002719434X","tray barcode":"R19M24S06T08 DD","status":"Item In Place","step":"1"}