From 032a9a2611b1d991d81f7a7532369d700f1819b5 Mon Sep 17 00:00:00 2001 From: shieldss Date: Tue, 7 Apr 2026 16:10:38 -0400 Subject: [PATCH] refactoring for log error management refactoring for log error management --- public/all_processing_submit.php | 162 ++++++++++---- public/index.php | 229 ++++++++++--------- public/login.php | 12 +- public/processing.php | 372 ++++++++++++++++++------------- 4 files changed, 471 insertions(+), 304 deletions(-) diff --git a/public/all_processing_submit.php b/public/all_processing_submit.php index 0d55480..d7dea65 100644 --- a/public/all_processing_submit.php +++ b/public/all_processing_submit.php @@ -1,60 +1,132 @@ 0) - -header( 'Location: processing.php?submit=false' ) ; - -else { - - -$Count = filter_var($_POST['Count'], FILTER_SANITIZE_STRING); -$Full = filter_var($_POST['Full'], FILTER_SANITIZE_STRING); -$Full = !empty($Full) ? "'$Full'" : "NULL"; -$Verify = filter_var($_POST['Verify'], FILTER_SANITIZE_STRING); -$Checked = filter_var($_POST['Checked'], FILTER_SANITIZE_STRING); -$Library = filter_var($_POST['Library'], FILTER_SANITIZE_STRING); +$Name = trim((string)($_POST['Name'] ?? '')); +$traytemp = trim((string)($_POST['TrayLocation'] ?? '')); +$Count = trim((string)($_POST['Count'] ?? '')); +$Full = trim((string)($_POST['Full'] ?? '')); +$Verify = trim((string)($_POST['Verify'] ?? '')); +$Checked = trim((string)($_POST['Checked'] ?? '')); +$Library = trim((string)($_POST['Library'] ?? '')); + +if ($Library === '' || $traytemp === '' || $Count === '' || $Checked === '' || $Verify === '') { + header('Location: processing.php?submit=blank'); + exit; +} $PCode = substr($traytemp, -2); +$timestamp = date('Y-m-d H:i:s'); + +/* +|-------------------------------------------------------------------------- +| Check for duplicate tray/shelf barcode +|-------------------------------------------------------------------------- +*/ +$checkSql = "SELECT 1 FROM ProcessingAll WHERE ptraylocation = ? LIMIT 1"; +$checkStmt = $conn->prepare($checkSql); + +if (!$checkStmt) { + die('Prepare failed: ' . $conn->error); +} +$checkStmt->bind_param('s', $traytemp); +$checkStmt->execute(); +$checkResult = $checkStmt->get_result(); +$isDuplicate = $checkResult instanceof mysqli_result && $checkResult->num_rows > 0; +$checkStmt->close(); -if($Library =='' OR $traytemp =='' OR $Count =='' OR $Checked =='' OR $Verify =='') -header( 'Location: processing.php?submit=blank' ) ; - -else { - - -$sql = "INSERT INTO ProcessingAll (ProcessingKey, ptimestamp, pname, ptraylocation, pcode, pcount, pfull, pverify, pchecked, plibrary, cctimestamp, ccname, cccount, ccverify, ccchecked) VALUES (NULL, CURRENT_TIMESTAMP, '$Name', $TrayLocation, '$PCode', '$Count', $Full, '$Verify', '$Checked', '$Library', NULL, NULL, NULL, NULL, NULL)"; - -if ($conn->query($sql) === TRUE) { - header( 'Location: processing.php?submit=true' ) ; - -} else { - echo "Error: " . $sql . "
" . $conn->error; -} +if ($isDuplicate) { + header('Location: processing.php?submit=false'); + exit; } + +/* +|-------------------------------------------------------------------------- +| Normalize nullable fields +|-------------------------------------------------------------------------- +*/ +$fullValue = ($Full !== '') ? $Full : null; + +/* +|-------------------------------------------------------------------------- +| Insert record +|-------------------------------------------------------------------------- +*/ +$insertSql = " + INSERT INTO ProcessingAll ( + ProcessingKey, + ptimestamp, + pname, + ptraylocation, + pcode, + pcount, + pfull, + pverify, + pchecked, + plibrary, + cctimestamp, + ccname, + cccount, + ccverify, + ccchecked, + updated + ) VALUES ( + NULL, + ?, + ?, + ?, + ?, + ?, + ?, + ?, + ?, + ?, + NULL, + NULL, + NULL, + NULL, + NULL, + ? + ) +"; + +$insertStmt = $conn->prepare($insertSql); + +if (!$insertStmt) { + die('Prepare failed: ' . $conn->error); } -$conn->close(); -mysqli_close($conn); +$insertStmt->bind_param( + 'ssssssssss', + $timestamp, // ptimestamp + $Name, // pname + $traytemp, // ptraylocation + $PCode, // pcode + $Count, // pcount + $fullValue, // pfull + $Verify, // pverify + $Checked, // pchecked + $Library, // plibrary + $timestamp // updated +); + +if ($insertStmt->execute()) { + $insertStmt->close(); + $conn->close(); + header('Location: processing.php?submit=true'); + exit; +} +$error = $insertStmt->error; +$insertStmt->close(); +$conn->close(); -?> \ No newline at end of file +echo 'Error: ' . htmlspecialchars($error, ENT_QUOTES, 'UTF-8'); \ No newline at end of file diff --git a/public/index.php b/public/index.php index 77b89e1..053bece 100644 --- a/public/index.php +++ b/public/index.php @@ -1,134 +1,159 @@ (int)$_SESSION['expire']) { + session_destroy(); + header('Location: login.php'); + exit; +} - if ($now > $_SESSION['expire']) { - session_destroy(); - header("Location: login.php"); - } +include 'header.php'; -} else { - // Redirect them to the login page - header("Location: login.php"); +if (!isset($conn) || !($conn instanceof mysqli)) { + die('Database connection not available.'); +} + +$userId = (string)($_SESSION['user_id'] ?? ''); +$working = isset($working) ? (string)$working : 'false'; +$account = isset($account) ? (string)$account : 'false'; + +$pendingCrossChecks = 0; + +$sql = "SELECT COUNT(*) AS pending_count FROM ProcessingAll WHERE ccname IS NULL OR ccname = ''"; +$result = mysqli_query($conn, $sql); + +if ($result instanceof mysqli_result) { + $row = mysqli_fetch_assoc($result); + $pendingCrossChecks = isset($row['pending_count']) ? (int)$row['pending_count'] : 0; + mysqli_free_result($result); } ?> - + .no-shadow { + box-shadow: none !important; + } + + .btn-large .badge { + position: static; /* remove floating behavior */ + display: inline-flex; + align-items: center; + justify-content: center; + margin-left: 10px; + vertical-align: middle; + height: 22px; + min-width: 22px; + line-height: 22px; + padding: 0 6px; + font-size: 12px; + border-radius:4px; + color: #fff; + margin-top: 16px; +} + + +
-

settings_applicationsSCF Tools

- - -
- - -
+

+ settings_applications + SCF Tools +

+ +
+ +
+
Time Card

Be sure to clock in to your time card before beginning work.

-
- +
+ timerTime Card - -

-
'; -} ?> - - - - - - - - - -
-
- Refile Processing -

Tools for Processing of Refile Items

-
- Home arrow_forward - -

-
- - - - - + +

+
+ +
+
+ SCF Processing Utilities +
-
- + + library_add Add Item Call Number + + + speaker_notes Add Internal Note 1 + + + speaker_notes Add ICN/IN1 + +


+
- -
+
+
+ Refile Processing +

Tools for Processing of Refile Items

+
+ + Home arrow_forward + +

+
+
- + - - -
-
- Projects Tracker -

Manage ongoing special project and track time spent working on Deaccessions.

-
- developer_boardProjects
- timerTrack Time -
- +
+
+ Projects Tracker +

Manage ongoing special project and track time spent working on Deaccessions.

+
+ + developer_boardProjects + +
-
+ + timerTrack Time + +
+
+
- - + + \ No newline at end of file diff --git a/public/login.php b/public/login.php index 2532861..3a2382d 100644 --- a/public/login.php +++ b/public/login.php @@ -14,7 +14,7 @@ @@ -24,7 +24,14 @@
Staff Login Login failed. Please try again.'; + $login = $_GET['login'] ?? ''; + + if ($login === 'false') { + echo '

Login failed. Please try again.

'; + } + + + ?>
@@ -80,6 +87,7 @@ +