From 24be54b0bd694ad11a0ff1f6e12d3a0a34e7847a Mon Sep 17 00:00:00 2001
From: Hajo Seng <hajoseng@sub.uni-hamburg.de>
Date: Thu, 22 Aug 2019 09:24:24 +0200
Subject: [PATCH] Making the mapping of status to
 Hold/StorageRetrievalRequests/Transactions configurable. This is due to the
 fact that these status might be interpreted differently by different
 libraries.

---
 config/vufind/PAIA.ini                       | 25 ++++++++++++++++++++
 module/VuFind/src/VuFind/ILS/Driver/PAIA.php | 15 +++++++-----
 2 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/config/vufind/PAIA.ini b/config/vufind/PAIA.ini
index 38f6e661c4d..bb45d469ca9 100644
--- a/config/vufind/PAIA.ini
+++ b/config/vufind/PAIA.ini
@@ -31,6 +31,13 @@ baseUrl = ""
 ; during form processing. Most users should not need to change this setting.
 HMACKeys = "id:item_id:doc_id"
 
+; PAIA status which should be mapped to Holds
+; status are:   1 = reserved (not available yet but later)
+;               2 = ordered (and not yet ready to be picked up)
+;               3 = held by patron
+;               4 = provided (and ready to be picked up)
+status = "1:4"
+
 ; Without customization the PAIA driver will offer to place a storageretrievalrequest
 ; for items with available service loan and set href for loan. The
 ; storageretrievalrequest will be performed via PAIA request (technically the same as
@@ -43,6 +50,24 @@ HMACKeys = "id:item_id:doc_id"
 ; during form processing. Most users should not need to change this setting.
 HMACKeys = id:item_id:doc_id
 
+; PAIA status which should be mapped to StorageRetrievalRequests
+; status are:   1 = reserved (not available yet but later)
+;               2 = ordered (and not yet ready to be picked up)
+;               3 = held by patron
+;               4 = provided (and ready to be picked up)
+status = "2"
+
+; All kinds of transactions by a specific patron. Transactions are eg checked out
+; items
+[Transactions]
+; PAIA status which should be mapped to Transactions
+; status are:   1 = reserved (not available yet but later)
+;               2 = ordered (and not yet ready to be picked up)
+;               3 = held by patron
+;               4 = provided (and ready to be picked up)
+status = "3"
+
+
 ; The PAIA driver supports renewals in MyResearch views. The renewal will be
 ; performed via PAIA renew.
 ; The pre-defined HMACKeys (id:item_id:doc_id) should suffice to renew an item. No
diff --git a/module/VuFind/src/VuFind/ILS/Driver/PAIA.php b/module/VuFind/src/VuFind/ILS/Driver/PAIA.php
index 35a7429cd81..b61780ee826 100644
--- a/module/VuFind/src/VuFind/ILS/Driver/PAIA.php
+++ b/module/VuFind/src/VuFind/ILS/Driver/PAIA.php
@@ -707,11 +707,12 @@ class PAIA extends DAIA
      */
     public function getMyHolds($patron)
     {
-        // filters for getMyHolds are:
+        // filters for getMyHolds are by default configuration:
         // status = 1 - reserved (the document is not accessible for the patron yet,
         //              but it will be)
         //          4 - provided (the document is ready to be used by the patron)
-        $filter = ['status' => [1, 4]];
+        $status = $this->config['Holds']['status'] ?? '1:4';
+        $filter = ['status' => explode(':', $status)];
         // get items-docs for given filters
         $items = $this->paiaGetItems($patron, $filter);
         return $this->mapPaiaItems($items, 'myHoldsMapping');
@@ -785,9 +786,10 @@ class PAIA extends DAIA
      */
     public function getMyTransactions($patron)
     {
-        // filters for getMyTransactions are:
+        // filters for getMyTransactions are by default configuration:
         // status = 3 - held (the document is on loan by the patron)
-        $filter = ['status' => [3]];
+        $status = $this->config['Transactions']['status'] ?? '3';
+        $filter = ['status' => explode(':', $status)];
         // get items-docs for given filters
         $items = $this->paiaGetItems($patron, $filter);
         return $this->mapPaiaItems($items, 'myTransactionsMapping');
@@ -805,9 +807,10 @@ class PAIA extends DAIA
      */
     public function getMyStorageRetrievalRequests($patron)
     {
-        // filters for getMyStorageRetrievalRequests are:
+        // filters for getMyStorageRetrievalRequests are by default configuration:
         // status = 2 - ordered (the document is ordered by the patron)
-        $filter = ['status' => [2]];
+        $status = $this->config['StorageRetrievalRequests']['status'] ?? '2';
+        $filter = ['status' => explode(':', $status)];
         // get items-docs for given filters
         $items = $this->paiaGetItems($patron, $filter);
         return $this->mapPaiaItems($items, 'myStorageRetrievalRequestsMapping');
-- 
GitLab