diff --git a/public/list.php b/public/list.php index e51166c..b822356 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/check_in.php b/public/refile/check_in.php index b5e6dd1..5391a47 100755 --- a/public/refile/check_in.php +++ b/public/refile/check_in.php @@ -1,74 +1,173 @@ + false, + 'status' => 0, + 'body' => '', + 'error' => 'Unable to initialize cURL.' + ); + } + + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($ch, CURLOPT_MAXREDIRS, 5); + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $connectTimeout); + curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); + + if ($method === 'POST') { + curl_setopt($ch, CURLOPT_POST, true); + if ($body !== null) { + curl_setopt($ch, CURLOPT_POSTFIELDS, $body); + } + } elseif ($method === 'PUT') { + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); + if ($body !== null) { + curl_setopt($ch, CURLOPT_POSTFIELDS, $body); + } + } + + if (!empty($headers)) { + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + } + + $responseBody = curl_exec($ch); + $lastError = curl_error($ch); + $lastStatus = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE); + $lastBody = ($responseBody !== false) ? $responseBody : ''; + + curl_close($ch); + + if ($responseBody !== false && $lastStatus >= 200 && $lastStatus < 300) { + return array( + 'ok' => true, + 'status' => $lastStatus, + 'body' => $responseBody, + 'error' => '' + ); + } + + $shouldRetry = false; + + if ($responseBody === false) { + $shouldRetry = true; + } elseif (in_array($lastStatus, array(408, 429, 500, 502, 503, 504), true)) { + $shouldRetry = true; + } + + if (!$shouldRetry || $attempt === $retries) { + break; + } + + usleep($retryDelayMs * 1000); + $retryDelayMs *= 2; + $attempt++; + } - $headers = [ - 'Accept: application/xml', - ]; + return array( + 'ok' => false, + 'status' => $lastStatus, + 'body' => $lastBody, + 'error' => $lastError !== '' ? $lastError : 'Request failed.' + ); +} - if (!empty($api_key)) { - $headers[] = 'Authorization: apikey ' . $api_key; +function loadXmlFromResponse($response) +{ + if (!is_array($response) || empty($response['ok']) || trim((string)$response['body']) === '') { + return false; } - if ($method === 'POST' || $method === 'PUT') { - $headers[] = 'Content-Type: application/xml'; - } + return @simplexml_load_string($response['body']); +} - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); - curl_setopt($ch, CURLOPT_MAXREDIRS, 5); - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); - curl_setopt($ch, CURLOPT_TIMEOUT, 15); - curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); - curl_setopt($ch, CURLOPT_HEADER, false); - - if ($method === 'POST') { - curl_setopt($ch, CURLOPT_POST, true); - } elseif ($method === 'PUT') { - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); +function findItemXmlByBarcode($barcodeInput, $apiKey, $apiKeyHeader, $prefix) +{ + $barcodeInput = trim((string)$barcodeInput); + + if ($barcodeInput === '') { + return array( + 'ok' => false, + 'url' => '', + 'xml' => false, + 'response' => null, + 'error' => 'Blank barcode.' + ); } - if ($body !== null) { - curl_setopt($ch, CURLOPT_POSTFIELDS, $body); - } + $candidateBarcodes = array(); - $response = curl_exec($ch); - $error = curl_error($ch); - $errno = curl_errno($ch); - $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); - $final_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); - - curl_close($ch); - - return [ - 'response' => $response, - 'error' => $error, - 'errno' => $errno, - 'httpcode' => $httpcode, - 'final_url' => $final_url, - 'ok' => ($errno === 0 && $response !== false), - ]; -} + $barcodeWithX = $barcodeInput; + if (substr($barcodeWithX, -1) !== 'X') { + $barcodeWithX .= 'X'; + } + $candidateBarcodes[] = $barcodeWithX; -function normalizeBarcode($barcode) -{ - $barcode = trim($barcode); + if (strtolower(substr($barcodeInput, 0, 1)) === 'p' && strlen($barcodeInput) === 6) { + $candidateBarcodes[] = $barcodeInput . 'X'; + } - if (substr($barcode, -1) !== 'X') { - $barcode .= 'X'; + $barcodeWithoutX = str_replace('X', '', $barcodeWithX); + if ($barcodeWithoutX !== '') { + $candidateBarcodes[] = $barcodeWithoutX; } - if (strtolower(substr($barcode, 0, 1)) === 'p' && strlen($barcode) === 6) { - $barcode .= 'X'; + $candidateBarcodes = array_values(array_unique($candidateBarcodes)); + + foreach ($candidateBarcodes as $candidateBarcode) { + $url = $prefix . 'items?item_barcode=' . rawurlencode($candidateBarcode) . '&apikey=' . rawurlencode($apiKey); + + $response = almaRequest( + $url, + 'GET', + null, + array($apiKeyHeader, 'Accept: application/xml'), + 12, + 5, + 2, + 400 + ); + + $xml = loadXmlFromResponse($response); + + if ($xml !== false && isset($xml->item_data->barcode)) { + return array( + 'ok' => true, + 'url' => $url, + 'xml' => $xml, + 'response' => $response, + 'error' => '' + ); + } } - return $barcode; + return array( + 'ok' => false, + 'url' => '', + 'xml' => false, + 'response' => null, + 'error' => 'Item record does not exist.' + ); } -?> +?> + @@ -84,20 +183,17 @@ function normalizeBarcode($barcode)
-

Step 1: Check-in Returns and place on Hold Shelf -

+

Step 1: Check-in Returns and place on Hold Shelf -

Barcode Entry

- -
- + +
@@ -111,115 +207,90 @@ function normalizeBarcode($barcode)
- API key is not configured.
"; - exit; - } - - $candidateBarcodes = [$barcode]; - $barcodeWithoutX = str_replace('X', '', $barcode); - - if ($barcodeWithoutX !== $barcode) { - $candidateBarcodes[] = $barcodeWithoutX; - } - - $itemLookup = null; - $resolvedBarcode = null; - - foreach ($candidateBarcodes as $candidate) { - $item_by_barc_url = $prefix . 'items?item_barcode=' . urlencode($candidate) . '&apikey=' . urlencode($api_key); - $result = almaRequest($item_by_barc_url, 'GET', $api_key); - - if ($result['ok'] && $result['httpcode'] === 200 && !empty($result['response'])) { - $itemLookup = $result; - $resolvedBarcode = $candidate; - break; - } - } - - if ($itemLookup === null) { - echo "
Item record does not exist or Alma lookup timed out.
"; - exit; - } - - $barcode = $resolvedBarcode; - $response = $itemLookup['response']; - $httpcode = $itemLookup['httpcode']; - - $xml = simplexml_load_string($response); - - if ($xml === false) { - echo "
Failed to parse item XML response.
"; - exit; - } - - $internalNote3 = (string)($xml->item_data->internal_note_3 ?? ''); - $internalNote1 = (string)($xml->item_data->internal_note_1 ?? ''); - $acn = (string)($xml->item_data->alternative_call_number ?? ''); - $holding_id = (string)($xml->holding_data->holding_id ?? ''); - $pid = (string)($xml->item_data->pid ?? ''); - $mms_id = (string)($xml->bib_data->mms_id ?? ''); - $title = (string)($xml->bib_data->title ?? ''); - $process_type = (string)($xml->item_data->process_type ?? ''); - - $item_api_url = "https://api-na.hosted.exlibrisgroup.com/almaws/v1/bibs/" . rawurlencode($mms_id) - . "/holdings/" . rawurlencode($holding_id) - . "/items/" . rawurlencode($pid) - . "?apikey=" . urlencode($api_key); - - if (!empty($internalNote3) && $internalNote3 !== 'SCF Hold Shelf') { - echo "
-

Barcode " . htmlspecialchars($barcode) . "

- Internal note 3 message: " . htmlspecialchars($internalNote3) . "

- This item has not been checked in. Please give it to your supervisor. -
"; - exit; - } - - $loan_url = "https://api-na.hosted.exlibrisgroup.com/almaws/v1/bibs/" . rawurlencode($mms_id) . "/holdings/" . rawurlencode($holding_id) . "/items/" . rawurlencode($pid) . "/loans?apikey=" . urlencode($api_key); - - $loanResult = almaRequest($loan_url, 'GET', $api_key); - - if (!$loanResult['ok']) { - echo "
Loan lookup failed: " . htmlspecialchars($loanResult['error']) . "
"; - exit; - } - - if ($loanResult['httpcode'] !== 200) { - echo "
Loan lookup returned HTTP " . (int)$loanResult['httpcode'] . ".
"; - exit; - } +Failed to parse loan XML response."; - exit; - } + if (strtolower(substr($barcode, 0, 1)) === 'p' && strlen($barcode) === 6) { + $barcode .= 'X'; + } - $total_record_count = (int)($loan_xml['total_record_count'] ?? 0); - $alreadyCheckedIn = ($total_record_count === 0); - $status = $alreadyCheckedIn ? 'Already Checked In' : 'Item In Place'; + $library = 'SCF'; + $circ_desk = 'DEFAULT_CIRC_DESK'; + $prefix = 'https://api-na.hosted.exlibrisgroup.com/almaws/v1/'; + + include 'include/apikey.php'; + + $itemLookup = findItemXmlByBarcode($barcode, $api_key, $api_key_header, $prefix); + + if (!$itemLookup['ok'] || $itemLookup['xml'] === false) { + echo "
Item record does not exist
"; + } else { + $item_url = $itemLookup['url']; + $httpcode = (int)$itemLookup['response']['status']; + $xml = $itemLookup['xml']; + + $title = isset($xml->bib_data->title) ? (string)$xml->bib_data->title : ''; + $internalNote3 = isset($xml->item_data->internal_note_3) ? (string)$xml->item_data->internal_note_3 : ''; + $internalNote1 = isset($xml->item_data->internal_note_1) ? (string)$xml->item_data->internal_note_1 : ''; + $acn = isset($xml->item_data->alternative_call_number) ? (string)$xml->item_data->alternative_call_number : ''; + $holding_id = isset($xml->holding_data->holding_id) ? (string)$xml->holding_data->holding_id : ''; + $pid = isset($xml->item_data->pid) ? (string)$xml->item_data->pid : ''; + $mms_id = isset($xml->bib_data->mms_id) ? (string)$xml->bib_data->mms_id : ''; + $process_type = isset($xml->item_data->process_type) ? (string)$xml->item_data->process_type : ''; + + if (!empty($internalNote3) && $internalNote3 !== 'SCF Hold Shelf') { + echo "
+

Barcode " . h($barcode) . "

+ Internal note 3 message: " . h($internalNote3) . "

+ This item has not been checked in. Please give it to your supervisor. +
"; + } else { + $loan_url = $prefix . 'bibs/' . rawurlencode($mms_id) . '/holdings/' . rawurlencode($holding_id) . '/items/' . rawurlencode($pid) . '/loans?apikey=' . rawurlencode($api_key); + + $loanResponse = almaRequest( + $loan_url, + 'GET', + null, + array($api_key_header, 'Accept: application/xml'), + 15, + 5, + 3, + 700 + ); + + $loan_xml = loadXmlFromResponse($loanResponse); + $total_record_count = 0; + $due_date = ''; + $loan_status = ''; + $process_status = ''; + $user_id = ''; + $alreadyCheckedIn = false; + $scanSucceeded = false; + $status = "Item Not In Place"; + + if ($loan_xml === false) { + echo "
Loan lookup failed: " . h($loanResponse['error']) . "
"; + } else { + $total_record_count = isset($loan_xml['total_record_count']) ? (int)$loan_xml['total_record_count'] : 0; - if ($alreadyCheckedIn) { + if ($total_record_count === 0) { + $alreadyCheckedIn = true; echo '

Item Already Checked In.

Please give it to your supervisor for review.

'; } else { - $item_loan = $loan_xml->item_loan; + $item_loan = isset($loan_xml->item_loan) ? $loan_xml->item_loan : null; if ($item_loan) { - $user_id = (string)($item_loan->user_id ?? ''); + $due_date = isset($item_loan->due_date) ? (string)$item_loan->due_date : ''; + $loan_status = isset($item_loan->loan_status) ? (string)$item_loan->loan_status : ''; + $process_status = isset($item_loan->process_status) ? (string)$item_loan->process_status : ''; + $user_id = isset($item_loan->user_id) ? (string)$item_loan->user_id : ''; - $deliverToMapping = [ + $deliverToMapping = array( "01WRLC_AMU-UNIV_LIB" => "AU", "01WRLC_AMULAW-PLL" => "AULAW", "01WRLC_CAA-CUMULLEN" => "CU", @@ -257,14 +328,14 @@ function normalizeBarcode($barcode) "01WRLC_GWALAW-GWALAW" => "JB", "01WRLC_MAR-main" => "MU", "01WRLC_MAR-bcle" => "MUB", - "01WRLC_SCF-Sheehan Library" => "TR", - ]; + "01WRLC_SCF-Sheehan Library" => "TR" + ); if (isset($deliverToMapping[$user_id])) { - echo "
Patron: Deliver To: " . htmlspecialchars($deliverToMapping[$user_id]) . "
"; + echo "
Patron: Deliver To: " . h($deliverToMapping[$user_id]) . "
"; } else { if ($user_id !== '') { - echo "
Patron: " . htmlspecialchars($user_id) . ".
"; + echo "
Patron: " . h($user_id) . ".
"; } else { echo '
Patron field is blank. Set Item aside for Supervisor.
'; } @@ -274,179 +345,206 @@ function normalizeBarcode($barcode) if ($httpcode !== 200) { echo "

Barcode error. Please check with Supervisor.

"; - exit; - } - - if (!$alreadyCheckedIn) { - $scan_in_url = $item_api_url . '&op=scan&library=' . urlencode($library) . '&circ_desk=' . urlencode($circ_desk); - - $scanResult = almaRequest($scan_in_url, 'POST', $api_key, ''); - - if (!$scanResult['ok']) { - echo "
Scan-in failed: " . htmlspecialchars($scanResult['error']) . "
"; - exit; - } - - $post_response = $scanResult['response']; - $post_httpcode = $scanResult['httpcode']; - - if ($post_httpcode !== 200) { - echo "
Scan-in API Response:
"; - echo "
HTTP Status Code: " . htmlspecialchars((string)$post_httpcode) . "
"; - echo "
" . htmlspecialchars((string)$post_response) . "
"; - echo "
"; - exit; + } else { + if (!$alreadyCheckedIn) { + $scan_in_url = $item_url + . '&op=scan' + . '&library=' . urlencode($library) + . '&circ_desk=' . urlencode($circ_desk); + + $scanResponse = almaRequest( + $scan_in_url, + 'POST', + '', + array( + 'Content-Type: application/xml', + 'Authorization: apikey ' . $api_key, + 'Accept: application/xml' + ), + 15, + 5, + 2, + 500 + ); + + $post_response = $scanResponse['body']; + $post_httpcode = (int)$scanResponse['status']; + + if ($post_httpcode === 200) { + echo '

Barcode ' . h($barcode) . ' has been checked in.

'; + $status = "Item In Place"; + $scanSucceeded = true; + } else { + $status = "Item Not In Place"; + echo "
Scan-in API Response:
"; + echo "
HTTP Status Code: " . h($post_httpcode) . "
"; + echo "
" . h($post_response) . "
"; + } } if (empty($internalNote1) && empty($acn)) { - echo '

Barcode ' . htmlspecialchars($barcode) . ' has been checked in.

'; - echo "
-

Barcode " . htmlspecialchars($barcode) . "

+ echo "
+

Barcode " . h($barcode) . "

Possible New Book - Additional Processing Needed.
This item has been checked in but do not place on hold shelf.
"; - exit; - } - - $reloadResult = null; - - for ($i = 0; $i < 3; $i++) { - $reloadResult = almaRequest($item_api_url, 'GET', $api_key); - - if ($reloadResult['ok'] && $reloadResult['httpcode'] === 200 && !empty($reloadResult['response'])) { - break; - } - - usleep(500000); - } - - if (!$reloadResult['ok'] || $reloadResult['httpcode'] !== 200) { - echo "
Failed to reload item record for update.
"; - echo "
HTTP Status Code: " . htmlspecialchars((string)$reloadResult['httpcode']) . "
"; - echo "
cURL Error: " . htmlspecialchars((string)$reloadResult['error']) . "
"; - exit; - } - - $xml = simplexml_load_string($reloadResult['response']); - - if ($xml === false) { - echo "
Failed to parse item record for update.
"; - exit; - } - - $title = (string)($xml->bib_data->title ?? ''); - $internal_note_1 = (string)($xml->item_data->internal_note_1 ?? ''); - $process_type = (string)($xml->item_data->process_type ?? ''); - - $xml->item_data->internal_note_3 = 'SCF Hold Shelf'; - $xml->holding_data->in_temp_location = 'true'; - $xml->holding_data->temp_library = 'SCF'; - $xml->holding_data->temp_location = 'SCF_Hold'; + } else { + $getItemResponse = almaRequest( + $item_url, + 'GET', + null, + array($api_key_header, 'Accept: application/xml'), + 12, + 5, + 2, + 400 + ); + + $itemXml = loadXmlFromResponse($getItemResponse); + + if ($itemXml === false) { + echo '

Exception found: Return Item to Supervisor

'; + } else { + $displayTitle = isset($itemXml->bib_data->title) ? (string)$itemXml->bib_data->title : $title; + $displayInternalNote1 = isset($itemXml->item_data->internal_note_1) ? (string)$itemXml->item_data->internal_note_1 : $internalNote1; + $displayMmsId = isset($itemXml->bib_data->mms_id) ? (string)$itemXml->bib_data->mms_id : $mms_id; + $displayProcessType = isset($itemXml->item_data->process_type) ? (string)$itemXml->item_data->process_type : $process_type; + + if (!$alreadyCheckedIn && $scanSucceeded) { + $itemXml->item_data->internal_note_3 = 'SCF Hold Shelf'; + $itemXml->holding_data->in_temp_location = 'true'; + $itemXml->holding_data->temp_library = 'SCF'; + $itemXml->holding_data->temp_location = 'SCF_Hold'; + + $modified_xml = $itemXml->asXML(); + + $putResponse = almaRequest( + $item_url, + 'PUT', + $modified_xml, + array( + 'Content-Type: application/xml', + 'Authorization: apikey ' . $api_key, + 'Accept: application/xml' + ), + 15, + 5, + 2, + 500 + ); + + if (!$putResponse['ok']) { + echo '

Exception found: Return Item to Supervisor

' . h($putResponse['body']) . '

'; + } + } - $modified_xml = $xml->asXML(); + echo '
'; - $putResult = almaRequest($item_api_url, 'PUT', $api_key, $modified_xml); + if ($alreadyCheckedIn) { + echo '

Barcode ' . h($barcode) . ' was already checked in.

'; + } elseif ($scanSucceeded) { + echo '

Barcode ' . h($barcode) . ' has been checked in.

'; + } - if (!$putResult['ok'] || $putResult['httpcode'] >= 400) { - echo '

Exception found: Return Item to Supervisor

'; - echo '
' . htmlspecialchars($putResult['response'] ?: $putResult['error']) . '
'; - echo '
Clear Form
'; - exit; - } + echo '

' . h($displayTitle) . '

'; + + $formatted_note = preg_replace_callback( + '/(R\d{2})|(M\d{2})|(S\d{2})|(T\d{2})/', + function ($matches) { + if (!empty($matches[1])) { + return '' . $matches[1] . ''; + } elseif (!empty($matches[2])) { + return '' . $matches[2] . ''; + } elseif (!empty($matches[3])) { + return '' . $matches[3] . ''; + } elseif (!empty($matches[4])) { + return '' . $matches[4] . ''; + } + return ''; + }, + $displayInternalNote1 + ); + + echo '

Tray Barcode: ' . $formatted_note . '

'; + echo '

Be sure to write down and include the tray barcode with the item.

'; + + if ($displayProcessType !== '') { + echo "
This item has a processing type of '" . h($displayProcessType) . "'.
"; + } - echo '

Barcode ' . htmlspecialchars($barcode) . ' has been checked in.

'; - } else { - echo '

Barcode ' . htmlspecialchars($barcode) . ' has been checked in.

'; - } + if ($alreadyCheckedIn) { + echo "
Item was already checked in. Review before placing on Hold Shelf.
"; + } else { + echo "
Item is ready to be placed on Hold Shelf
"; + } - echo '

' . htmlspecialchars($title) . '

'; - - $displayTrayBarcode = $alreadyCheckedIn ? $internalNote1 : $internal_note_1; - - $formatted_note = preg_replace_callback( - '/(R\d{2})|(M\d{2})|(S\d{2})|(T\d{2})/', - function ($matches) { - if (!empty($matches[1])) { - return '' . htmlspecialchars($matches[1]) . ''; - } elseif (!empty($matches[2])) { - return '' . htmlspecialchars($matches[2]) . ''; - } elseif (!empty($matches[3])) { - return '' . htmlspecialchars($matches[3]) . ''; - } elseif (!empty($matches[4])) { - return '' . htmlspecialchars($matches[4]) . ''; + echo "

"; + echo 'View Check-In XML'; + echo 'View Record XML'; + echo '

Clear Form
'; + echo '
'; + + if (!$alreadyCheckedIn && $scanSucceeded) { + $file = __DIR__ . '/refile.ndjson'; + + if ($displayProcessType !== '') { + $process_type_full = $status . ' - ' . $displayProcessType; + } else { + $process_type_full = $status; + } + + $jsonDate = date('Y-m-d H:i:s'); + $jsonName = isset($name) ? $name : ''; + $jsonBarcode = $barcode; + $jsonTrayBarcode = $displayInternalNote1; + $jsonStatus = $process_type_full; + $jsonStep = '1'; + + $newEntry = array( + 'date' => $jsonDate, + 'name' => $jsonName, + 'barcode' => $jsonBarcode, + 'tray barcode' => $jsonTrayBarcode, + 'status' => $jsonStatus, + 'step' => $jsonStep + ); + + $jsonLine = json_encode($newEntry, JSON_UNESCAPED_SLASHES); + if ($jsonLine === false) { + die('Error: JSON encoding failed. ' . json_last_error_msg()); + } + + if (file_put_contents($file, $jsonLine . "\n", FILE_APPEND | LOCK_EX) === false) { + die('Error: Unable to write to the JSON file.'); + } + } } - return ''; - }, - $displayTrayBarcode - ); - - echo '

Tray Barcode: ' . $formatted_note . '

'; - echo '

Be sure to write down and include the tray barcode with the item.

'; - - if ($process_type !== '') { - echo "
This item has a processing type of '" . htmlspecialchars($process_type) . "'.
"; - } - - echo "
Item is ready to be placed on Hold Shelf


"; - echo "
"; - echo 'View Check-In XML '; - echo 'View Record XML
'; - - $file = __DIR__ . '/refile.ndjson'; - - if ($process_type !== '') { - $process_type_full = $status . ' - ' . $process_type; - } else { - $process_type_full = $status; - } - - if (!$alreadyCheckedIn) { - $jsonDate = date('Y-m-d H:i:s'); - $jsonName = $name ?? ''; - $jsonBarcode = $barcode; - $jsonTrayBarcode = $displayTrayBarcode; - $jsonStatus = $process_type_full; - $jsonStep = '1'; - - $newEntry = [ - 'date' => $jsonDate, - 'name' => $jsonName, - 'barcode' => $jsonBarcode, - 'tray barcode' => $jsonTrayBarcode, - 'status' => $jsonStatus, - 'step' => $jsonStep, - ]; - - $jsonLine = json_encode($newEntry, JSON_UNESCAPED_SLASHES); - if ($jsonLine === false) { - die('Error: JSON encoding failed. ' . json_last_error_msg()); } - if (file_put_contents($file, $jsonLine . "\n", FILE_APPEND | LOCK_EX) === false) { - die('Error: Unable to write to the JSON file.'); - } - } - - echo '
Clear Form
'; - echo '
'; - } else { - if ($_SERVER["REQUEST_METHOD"] === "POST") { - echo "

No barcode submitted.

"; + echo '
'; } - echo '
'; } - ?> - + } + } +} else { + if ($_SERVER['REQUEST_METHOD'] === 'POST') { + echo "

No barcode submitted.

"; + } + echo '
'; +} +?>
- - + \ 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"}