From 01803a35223214aaed2e667e75c89928d28c63f9 Mon Sep 17 00:00:00 2001 From: Ere Maijala <ere.maijala@helsinki.fi> Date: Wed, 12 Mar 2014 13:10:54 +0200 Subject: [PATCH] Added support for default value of "Select Pick Up Location" when placing a hold or a storage retrieval request, and driver support for that in VoyagerRestful. --- config/vufind/VoyagerRestful.ini | 8 +++--- languages/en.ini | 1 + languages/fi.ini | 1 + languages/sv.ini | 1 + .../src/VuFind/ILS/Driver/VoyagerRestful.php | 26 ++++++++++++++----- themes/blueprint/templates/record/hold.phtml | 5 ++++ .../record/storageretrievalrequest.phtml | 5 ++++ themes/bootstrap/templates/record/hold.phtml | 5 ++++ .../record/storageretrievalrequest.phtml | 5 ++++ .../jquerymobile/templates/record/hold.phtml | 5 ++++ 10 files changed, 52 insertions(+), 10 deletions(-) diff --git a/config/vufind/VoyagerRestful.ini b/config/vufind/VoyagerRestful.ini index 46ff405127e..3325b06656c 100644 --- a/config/vufind/VoyagerRestful.ini +++ b/config/vufind/VoyagerRestful.ini @@ -96,9 +96,11 @@ defaultRequiredDate = 0:1:0 extraHoldFields = comments:requiredByDate:pickUpLocation ; A Pick Up Location Code used to pre-select the pick up location drop down list and -; provide a default option if others are not available. Must correspond with one of -; the Location IDs returned by getPickUpLocations() -defaultPickUpLocation = "1" +; provide a default option if others are not available. Must be one of the following: +; 1) empty string to indicate that the first location is default (default setting) +; 2) 0 to indicate that the user always has to choose the location +; 3) a value within the Location IDs returned by getPickUpLocations() +defaultPickUpLocation = "" ; The maximum number of holding items to generate request links for. The process of ; checking the API for a valid hold is intensive. Any hold items above this this diff --git a/languages/en.ini b/languages/en.ini index 686715cb57a..1633a258769 100644 --- a/languages/en.ini +++ b/languages/en.ini @@ -691,6 +691,7 @@ Select this record = "Select this record" Select your carrier = "Select your carrier" Selected = "Selected" select_page = "Select Page" +select_pickup_location = "Select Pick Up Location" Send = Send Send us your feedback! = "Send us your feedback!" Sensor Image = "Sensor Image" diff --git a/languages/fi.ini b/languages/fi.ini index dd18a0b5930..0ccb4f63e9b 100644 --- a/languages/fi.ini +++ b/languages/fi.ini @@ -693,6 +693,7 @@ Select this record = "Valitse tämä tietue" Select your carrier = "Valitse operaattori" Selected = "Valittu" select_page = "Valitse sivu" +select_pickup_location = "Valitse noutopaikka" Send = "Lähetä" Send us your feedback! = "Lähetä meille palautetta" Sensor Image = "Kaukokartoituskuva" diff --git a/languages/sv.ini b/languages/sv.ini index b1682c79e24..7efb219f82b 100644 --- a/languages/sv.ini +++ b/languages/sv.ini @@ -693,6 +693,7 @@ Select this record = "Välj denna post" Select your carrier = "Välj teleoperatör" Selected = "Vald" select_page = "Välj sida" +select_pickup_location = "Välj avhämtningsplats" Send = "Skicka" Send us your feedback! = "Skicka os din feedback" Sensor Image = "Fjärranalysbild" diff --git a/module/VuFind/src/VuFind/ILS/Driver/VoyagerRestful.php b/module/VuFind/src/VuFind/ILS/Driver/VoyagerRestful.php index 1126779d506..9d3001f823c 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/VoyagerRestful.php +++ b/module/VuFind/src/VuFind/ILS/Driver/VoyagerRestful.php @@ -197,7 +197,12 @@ class VoyagerRestful extends Voyager implements \VuFindHttp\HttpServiceAwareInte = (isset($this->config['pickUpLocations'])) ? $this->config['pickUpLocations'] : false; $this->defaultPickUpLocation - = $this->config['Holds']['defaultPickUpLocation']; + = isset($this->config['Holds']['defaultPickUpLocation']) + ? $this->config['Holds']['defaultPickUpLocation'] + : ''; + if ($this->defaultPickUpLocation == '0') { + $this->defaultPickUpLocation = false; + } $this->holdCheckLimit = isset($this->config['Holds']['holdCheckLimit']) ? $this->config['Holds']['holdCheckLimit'] : "15"; @@ -1692,8 +1697,15 @@ EOT; $mfhdId = isset($details['holdings_id']) ? $details['holdings_id'] : false; $comment = $details['comment']; $bibId = $details['id']; - $pickUpLocation = !empty($details['pickUpLocation']) - ? $details['pickUpLocation'] : ''; + + // Make Sure Pick Up Location is Valid + if (isset($details['pickUpLocation']) + && !$this->pickUpLocationIsValid( + $details['pickUpLocation'], $patron, $details + ) + ) { + return $this->holdError("hold_invalid_pickup"); + } // Attempt Request $hierarchy = array(); @@ -1723,18 +1735,18 @@ EOT; 'dbkey' => $this->ws_dbKey, 'mfhdId' => $mfhdId ); - if ($pickUpLocation) { + if (isset($details['pickUpLocation'])) { $xml['call-slip-title-parameters']['pickup-location'] - = $pickUpLocation; + = $details['pickUpLocation']; } } else { $xml['call-slip-parameters'] = array( 'comment' => $comment, 'dbkey' => $this->ws_dbKey ); - if ($pickUpLocation) { + if (isset($details['pickUpLocation'])) { $xml['call-slip-parameters']['pickup-location'] - = $pickUpLocation; + = $details['pickUpLocation']; } } diff --git a/themes/blueprint/templates/record/hold.phtml b/themes/blueprint/templates/record/hold.phtml index 3864e1310e0..0d5ec0b35d6 100644 --- a/themes/blueprint/templates/record/hold.phtml +++ b/themes/blueprint/templates/record/hold.phtml @@ -40,6 +40,11 @@ ?> <strong><?=$this->transEsc("pick_up_location")?>:</strong><br/> <select name="gatheredDetails[pickUpLocation]"> + <? if ($selected === false): ?> + <option value="" selected="selected"> + <?=$this->transEsc('select_pickup_location')?> + </option> + <? endif; ?> <? foreach ($this->pickup as $lib): ?> <option value="<?=$this->escapeHtml($lib['locationID'])?>"<?=($selected == $lib['locationID']) ? ' selected="selected"' : ''?>> <?=$this->escapeHtml($lib['locationDisplay'])?> diff --git a/themes/blueprint/templates/record/storageretrievalrequest.phtml b/themes/blueprint/templates/record/storageretrievalrequest.phtml index 866a1526bbe..ae4eeaba60e 100644 --- a/themes/blueprint/templates/record/storageretrievalrequest.phtml +++ b/themes/blueprint/templates/record/storageretrievalrequest.phtml @@ -51,6 +51,11 @@ ?> <strong><?=$this->transEsc("pick_up_location")?>:</strong><br/> <select name="gatheredDetails[pickUpLocation]"> + <? if ($selected === false): ?> + <option value="" selected="selected"> + <?=$this->transEsc('select_pickup_location')?> + </option> + <? endif; ?> <? foreach ($this->pickup as $lib): ?> <option value="<?=$this->escapeHtml($lib['locationID'])?>"<?=($selected == $lib['locationID']) ? ' selected="selected"' : ''?>> <?=$this->escapeHtml($lib['locationDisplay'])?> diff --git a/themes/bootstrap/templates/record/hold.phtml b/themes/bootstrap/templates/record/hold.phtml index 741be749a45..131362674bb 100644 --- a/themes/bootstrap/templates/record/hold.phtml +++ b/themes/bootstrap/templates/record/hold.phtml @@ -45,6 +45,11 @@ <label class="control-label"><?=$this->transEsc("pick_up_location")?>:</label> <div class="controls"> <select name="gatheredDetails[pickUpLocation]"> + <? if ($selected === false): ?> + <option value="" selected="selected"> + <?=$this->transEsc('select_pickup_location')?> + </option> + <? endif; ?> <? foreach ($this->pickup as $lib): ?> <option value="<?=$this->escapeHtml($lib['locationID'])?>"<?=($selected == $lib['locationID']) ? ' selected="selected"' : ''?>> <?=$this->escapeHtml($lib['locationDisplay'])?> diff --git a/themes/bootstrap/templates/record/storageretrievalrequest.phtml b/themes/bootstrap/templates/record/storageretrievalrequest.phtml index 00e36e93c2d..c4623895309 100644 --- a/themes/bootstrap/templates/record/storageretrievalrequest.phtml +++ b/themes/bootstrap/templates/record/storageretrievalrequest.phtml @@ -66,6 +66,11 @@ <label class="control-label"><?=$this->transEsc("pick_up_location")?>:</label> <div class="controls"> <select name="gatheredDetails[pickUpLocation]"> + <? if ($selected === false): ?> + <option value="" selected="selected"> + <?=$this->transEsc('select_pickup_location')?> + </option> + <? endif; ?> <? foreach ($this->pickup as $lib): ?> <option value="<?=$this->escapeHtml($lib['locationID'])?>"<?=($selected == $lib['locationID']) ? ' selected="selected"' : ''?>> <?=$this->escapeHtml($lib['locationDisplay'])?> diff --git a/themes/jquerymobile/templates/record/hold.phtml b/themes/jquerymobile/templates/record/hold.phtml index 8bd21e35d8f..b2e248d0b23 100644 --- a/themes/jquerymobile/templates/record/hold.phtml +++ b/themes/jquerymobile/templates/record/hold.phtml @@ -39,6 +39,11 @@ ?> <strong><?=$this->transEsc("pick_up_location")?>:</strong><br/> <select name="gatheredDetails[pickUpLocation]"> + <? if ($selected === false): ?> + <option value="" selected="selected"> + <?=$this->transEsc('select_pickup_location')?> + </option> + <? endif; ?> <? foreach ($this->pickup as $lib): ?> <option value="<?=$this->escapeHtml($lib['locationID'])?>"<?=($selected == $lib['locationID']) ? ' selected="selected"' : ''?>> <?=$this->escapeHtml($lib['locationDisplay'])?> -- GitLab