From 8cb3f4a56aaff5fd16963eaea9d6eb4699f3ea56 Mon Sep 17 00:00:00 2001 From: Ere Maijala <ere.maijala@helsinki.fi> Date: Wed, 1 Mar 2017 15:21:52 +0200 Subject: [PATCH] =?UTF-8?q?Voyager:=20fetch=20return=20date=20only=20for?= =?UTF-8?q?=20items=20that=20have=20the=20=E2=80=99Discharged=E2=80=99=20s?= =?UTF-8?q?tatus=20and=20simplify=20the=20date/time=20handling.=20(#935)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VuFind/src/VuFind/ILS/Driver/Voyager.php | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/module/VuFind/src/VuFind/ILS/Driver/Voyager.php b/module/VuFind/src/VuFind/ILS/Driver/Voyager.php index 2176bd7861b..f93be7a2581 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Voyager.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Voyager.php @@ -604,6 +604,13 @@ class Voyager extends AbstractBase protected function getHoldingItemsSQL($id) { // Expressions + $returnDate = <<<EOT +CASE WHEN ITEM_STATUS_TYPE.ITEM_STATUS_DESC = 'Discharged' THEN ( + SELECT TO_CHAR(MAX(CIRC_TRANS_ARCHIVE.DISCHARGE_DATE), 'MM-DD-YY HH24:MI') + FROM $this->dbName.CIRC_TRANS_ARCHIVE + WHERE CIRC_TRANS_ARCHIVE.ITEM_ID = ITEM.ITEM_ID +) ELSE NULL END RETURNDATE +EOT; $sqlExpressions = [ "BIB_ITEM.BIB_ID", "MFHD_ITEM.MFHD_ID", "ITEM_BARCODE.ITEM_BARCODE", "ITEM.ITEM_ID", @@ -617,9 +624,7 @@ class Voyager extends AbstractBase "ITEM.PERM_LOCATION", "MFHD_MASTER.DISPLAY_CALL_NO as callnumber", "to_char(CIRC_TRANSACTIONS.CURRENT_DUE_DATE, 'MM-DD-YY') as duedate", - "(SELECT TO_CHAR(MAX(CIRC_TRANS_ARCHIVE.DISCHARGE_DATE), " . - "'MM-DD-YY HH24:MI') FROM $this->dbName.CIRC_TRANS_ARCHIVE " . - "WHERE CIRC_TRANS_ARCHIVE.ITEM_ID = ITEM.ITEM_ID) RETURNDATE", + $returnDate, "ITEM.ITEM_SEQUENCE_NUMBER", $this->getItemSortSequenceSQL('ITEM.PERM_LOCATION') ]; @@ -764,6 +769,11 @@ class Voyager extends AbstractBase if (!in_array($row['STATUS'], $record['STATUS_ARRAY'])) { $record['STATUS_ARRAY'][] = $row['STATUS']; } + + // If we have a return date for this status, take it + if (null !== $row['RETURNDATE']) { + $record['RETURNDATE'] = $row['RETURNDATE']; + } } else { // This is the first time we've encountered this row number -- // initialize the row and start an array of statuses. @@ -1039,18 +1049,11 @@ class Voyager extends AbstractBase } $returnDate = false; if (!empty($row['RETURNDATE'])) { - $returnDate = $this->dateFormat->convertToDisplayDate( - "m-d-y H:i", $row['RETURNDATE'] + $returnDate = $this->dateFormat->convertToDisplayDateAndTime( + 'm-d-y H:i', $row['RETURNDATE'] ); - $returnTime = $this->dateFormat->convertToDisplayTime( - "m-d-y H:i", $row['RETURNDATE'] - ); - $returnDate .= " " . $returnTime; } - $returnDate = (in_array("Discharged", $row['STATUS_ARRAY'])) - ? $returnDate : false; - $requests_placed = isset($row['HOLDS_PLACED']) ? $row['HOLDS_PLACED'] : 0; if (isset($row['RECALLS_PLACED'])) { -- GitLab