Skip to content
Snippets Groups Projects
Commit 59ca295e authored by Theodoros Theodoropoulos's avatar Theodoros Theodoropoulos Committed by Demian Katz
Browse files

Default pickup location behavior (#820)

* Set pickupLocation=homebranch(es) when neither defaultPickupLocation nor pickupLocation[] is set in KohaILSDI.ini
parent 9bd3ccc8
Branches
Tags
No related merge requests found
...@@ -43,6 +43,9 @@ extraHoldFields = comments:pickUpLocation:requiredByDate ...@@ -43,6 +43,9 @@ extraHoldFields = comments:pickUpLocation:requiredByDate
; available. The default of 'false' will force users to pick a pickup ; available. The default of 'false' will force users to pick a pickup
; location. By setting this to a Koha location code (e.g. '"MAIN"'), ; location. By setting this to a Koha location code (e.g. '"MAIN"'),
; Vufind will default to that location. ; Vufind will default to that location.
; If no defaultPickUpLocation and no pickupLocations are defined,
; the driver will try to use the actual holdingbranch(es) of the item/title
; as a fallback.
defaultPickUpLocation = "MAIN" defaultPickUpLocation = "MAIN"
; branchcodes for libraries avalaible as pickup locations ; branchcodes for libraries avalaible as pickup locations
......
...@@ -463,6 +463,45 @@ class KohaILSDI extends \VuFind\ILS\Driver\AbstractBase implements ...@@ -463,6 +463,45 @@ class KohaILSDI extends \VuFind\ILS\Driver\AbstractBase implements
if (!$this->db) { if (!$this->db) {
$this->initDb(); $this->initDb();
} }
if (!$this->pickupEnableBranchcodes) {
// No defaultPickupLocation is defined in config
// AND no pickupLocations are defined either
if (isset($holdDetails['item_id']) && (empty($holdDetails['level'])
|| $holdDetails['level'] == 'item')
) {
// We try to get the actual branchcode the item is found at
$item_id = $holdDetails['item_id'];
$sql = "SELECT holdingbranch
FROM items
WHERE itemnumber=($item_id)";
try {
$sqlSt = $this->db->prepare($sql);
$sqlSt->execute();
$this->pickupEnableBranchcodes = $sqlSt->fetch();
} catch (PDOException $e) {
$this->debug('Connection failed: ' . $e->getMessage());
throw new ILSException($e->getMessage());
}
} elseif (!empty($holdDetails['level'])
&& $holdDetails['level'] == 'title'
) {
// We try to get the actual branchcodes the title is found at
$id = $holdDetails['id'];
$sql = "SELECT DISTINCT holdingbranch
FROM items
WHERE biblionumber=($id)";
try {
$sqlSt = $this->db->prepare($sql);
$sqlSt->execute();
foreach ($sqlSt->fetchAll() as $row) {
$this->pickupEnableBranchcodes[] = $row['holdingbranch'];
}
} catch (PDOException $e) {
$this->debug('Connection failed: ' . $e->getMessage());
throw new ILSException($e->getMessage());
}
}
}
$branchcodes = "'" . implode( $branchcodes = "'" . implode(
"','", $this->pickupEnableBranchcodes "','", $this->pickupEnableBranchcodes
) . "'"; ) . "'";
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment