Skip to content

Commit f00d65c

Browse files
committed
DIS-48 Polaris Pickup areas
- Allow non-numeric ILS IDs to be saved for sublocations. - Display an appropriate error message if the user attempts to change the sublocation for a hold without changing the main location since Polaris does not support this - If a location only has a single pickup area, pass the pickup area to Polaris when placing a hold. - Correctly bypass the pickup location prompt when a library has a preferred sublocation.
1 parent d26a871 commit f00d65c

File tree

6 files changed

+81
-25
lines changed

6 files changed

+81
-25
lines changed

code/web/Drivers/Polaris.php

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,17 @@ function placeItemHold($patron, $recordId, $itemId, $pickupBranch, $cancelDate =
798798

799799
if ($pickupSublocation) {
800800
$body->HoldPickupAreaID = (int)$pickupSublocation;
801+
}else{
802+
//Check to see if there is only 1 valid pickup area for the location. If so, pass that as the pickup area
803+
$location = new Location();
804+
$location->code = $pickupBranch;
805+
if ($location->find(true)) {
806+
$sublocations = $location->getPickupSublocations($patron);
807+
if (count($sublocations) == 1) {
808+
$firstSublocation = reset($sublocations);
809+
$body->HoldPickupAreaID = (int)$firstSublocation->ilsId;
810+
}
811+
}
801812
}
802813

803814
//Need to set the Workstation
@@ -1424,7 +1435,39 @@ function thawHold(User $patron, $recordId, $itemToThawId): array {
14241435
}
14251436

14261437
function changeHoldPickupLocation(User $patron, $recordId, $itemToUpdateId, $newPickupLocation, $newPickupSublocation = null): array {
1427-
// Todo: Add HoldPickupAreaID value to update hold area ($newPickupSublocation) ??
1438+
//Polaris is currently unable to change a pickup area unless the pickup location does as well.
1439+
// we will return a good message if this is the case.
1440+
$existingHolds = $this->getHolds($patron);
1441+
$allHolds = array_merge($existingHolds['available'], $existingHolds['unavailable']);
1442+
1443+
//Get the aspen pickup location id rather than polar
1444+
$location = new Location();
1445+
$location->code = $newPickupLocation;
1446+
if ($location->find(true)) {
1447+
/** @var Hold $hold */
1448+
foreach ($allHolds as $hold) {
1449+
if ($hold->sourceId == $itemToUpdateId) {
1450+
if ($hold->pickupLocationId == $location->locationId && !empty($newPickupSublocation)) {
1451+
$message = translate([
1452+
'text' => 'To change pickup location within the branch, please contact the library.',
1453+
'isPublicFacing' => true,
1454+
]);
1455+
$result['success'] = false;
1456+
$result['message'] = $message;
1457+
1458+
// Result for API or app use
1459+
$result['api']['title'] = translate([
1460+
'text' => 'Unable to update pickup location',
1461+
'isPublicFacing' => true,
1462+
]);
1463+
$result['api']['message'] = $message;
1464+
return $result;
1465+
}
1466+
break;
1467+
}
1468+
}
1469+
}
1470+
14281471
$staffInfo = $this->getStaffUserInfo();
14291472
$polarisUrl = "/PAPIService/REST/public/v1/1033/100/1/patron/{$patron->getBarcode()}/holdrequests/$itemToUpdateId/pickupbranch?wsid={$this->getWorkstationID($patron)}&userid={$staffInfo['polarisId']}&pickupbranchid=$newPickupLocation";
14301473
if (!empty($newPickupSublocation)) {
@@ -1459,7 +1502,7 @@ function changeHoldPickupLocation(User $patron, $recordId, $itemToUpdateId, $new
14591502
$message = translate([
14601503
'text' => 'Sorry, the pickup location of your hold could not be changed.',
14611504
'isPublicFacing' => true,
1462-
]) . " {$jsonResponse->ErrorMessage}";;
1505+
]) . " {$jsonResponse->ErrorMessage}";
14631506
$result['success'] = false;
14641507
$result['message'] = $message;
14651508

code/web/interface/themes/responsive/MyAccount/myPreferences.tpl

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -153,26 +153,26 @@
153153
{/if}
154154
</div>
155155
<div id="pickupSublocationOptions" class="form-group propertyRow">
156+
{assign var=activePickupLocationId value=$profile->pickupLocationId}
156157
{if $edit == true && !empty($allowPickupLocationUpdates)}
157-
{if $profile->pickupLocationId}
158-
<div id="sublocationSelectPlaceHolder">
159-
<label class="control-label" for="pickupSublocation">{translate text='Preferred Pickup Location' isPublicFacing=true}</label>
160-
<div class="controls">
161-
<select name="pickupSublocation" id="pickupSublocation" class="form-control">
162-
<option value="0default">{translate text='Please Select a Location' isPublicFacing=true}</option>
163-
{foreach from=$pickupSublocations item=sublocations key=key}
164-
{if $key == $profile->pickupLocationId}
165-
{foreach from=$sublocations item=sublocation}
166-
<option value="{$sublocation->id}" {if $sublocation->id == $profile->pickupSublocationId}selected="selected"{/if}>{$sublocation->name}</option>
167-
{/foreach}
168-
{/if}
169-
{/foreach}
170-
</select>
158+
{if $activePickupLocationId > 0 && count($pickupSublocations.$activePickupLocationId) > 1}
159+
{if $profile->pickupLocationId}
160+
<div id="sublocationSelectPlaceHolder">
161+
<label class="control-label" for="pickupSublocation">{translate text='Preferred Pickup Location' isPublicFacing=true}</label>
162+
<div class="controls">
163+
<select name="pickupSublocation" id="pickupSublocation" class="form-control">
164+
<option value="0default">{translate text='Please Select a Location' isPublicFacing=true}</option>
165+
{foreach from=$pickupSublocations.$activePickupLocationId item=sublocation}
166+
<option value="{$sublocation->id}" {if $sublocation->id == $profile->pickupSublocationId}selected="selected"{/if}>{$sublocation->name}</option>
167+
{/foreach}
168+
</select>
169+
</div>
171170
</div>
172-
</div>
173-
171+
{else}
172+
<div id="sublocationSelectPlaceHolder"></div>
173+
{/if}
174174
{else}
175-
<div id="sublocationSelectPlaceHolder"></div>
175+
<div id="sublocationSelectPlaceHolder"></div>
176176
{/if}
177177
{else}
178178
{$profile->getPickupSublocationName()|escape}
@@ -272,4 +272,4 @@
272272
</div>
273273
{/if}
274274
</div>
275-
{/strip}
275+
{/strip}

code/web/release_notes/25.01.01.MD

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
## Aspen Discovery Updates
2+
### Location Updates
3+
- Allow non-numeric ILS IDs to be saved for sublocations. (DIS-46) (*MDN*)
24

5+
### Polaris Updates
6+
- Display an appropriate error message if the user attempts to change the sublocation for a hold without changing the main location since Polaris does not support this. (DIS-46) (*MDN*)
7+
- If a location only has a single pickup area, pass the pickup area to Polaris when placing a hold. (DIS-46) (*MDN*)
8+
- Fixes for setting preferred pickup area within My Preferences. (DIS-46) (*MDN*)
9+
- Correctly bypass the pickup location prompt when a library has a preferred sublocation. (DIS-46) (*MDN*)
310

411
## This release includes code contributions from
12+
### Grove For LibrariesN
13+
- Mark Noble (MDN)
14+
15+
## Special Testing thanks to
16+
- Desiree Saunders (WYLD)
17+
- Sarah St. Martin (GMILCS)
18+
- Myranda Fuentes (Grove)
519

code/web/services/MyAccount/MyPreferences.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
require_once ROOT_DIR . '/services/MyAccount/MyAccount.php';
44

55
class MyAccount_MyPreferences extends MyAccount {
6-
function launch() {
6+
function launch() : void {
77
global $interface;
88
$user = UserAccount::getLoggedInUser();
99

1010
if ($user) {
1111
// Determine which user we are showing/updating settings for
1212
$linkedUsers = $user->getLinkedUsers();
13-
$patronId = isset($_REQUEST['patronId']) ? $_REQUEST['patronId'] : $user->id;
13+
$patronId = $_REQUEST['patronId'] ?? $user->id;
1414
/** @var User $patron */
1515
$patron = $user->getUserReferredTo($patronId);
1616

@@ -57,7 +57,7 @@ function launch() {
5757
$interface->assign('pickupLocations', $pickupLocations);
5858

5959
$pickupSublocations = [];
60-
foreach ($pickupLocations as $locationKey => $location) {
60+
foreach ($pickupLocations as $location) {
6161
if (is_object($location)) {
6262
$pickupSublocations[$location->locationId] = $patron->getValidSublocations($location->locationId);
6363
}

code/web/services/Record/AJAX.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1831,7 +1831,7 @@ function setupHoldForm(string $recordSource, ?bool &$rememberHoldPickupLocation,
18311831
require_once ROOT_DIR . '/sys/LibraryLocation/SublocationPatronType.php';
18321832
$patronType = $user->getPTypeObj();
18331833
$sublocationLookup = new Sublocation();
1834-
$sublocationLookup->locationId = $user->pickupSublocationId;
1834+
$sublocationLookup->id = $user->pickupSublocationId;
18351835
$sublocationLookup->isValidHoldPickupAreaILS = 1;
18361836
$sublocationLookup->isValidHoldPickupAreaAspen = 1;
18371837
if ($sublocationLookup->find(true)) {

code/web/sys/LibraryLocation/Sublocation.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ class Sublocation extends DataObject {
1616

1717
public function getNumericColumnNames(): array {
1818
return [
19-
'ilsId',
2019
'locationId',
2120
'isValidHoldPickupAreaAspen',
2221
'isValidHoldPickupAreaILS'

0 commit comments

Comments
 (0)