Skip to content

Commit

Permalink
Merge branch '25.01.00' into 25.02.00
Browse files Browse the repository at this point in the history
  • Loading branch information
mdnoble73 committed Jan 8, 2025
2 parents 7643cbc + 13182ee commit bfe5f0d
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 48 deletions.
8 changes: 4 additions & 4 deletions code/web/CatalogConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -889,11 +889,11 @@ public function getHolds(User $user): array {
*
* @param User $patron The User to place a hold for
* @param string $recordId The id of the bib record
* @param string $pickupBranch The branch where the user wants to pickup the item when available
* @param string $cancelDate
* @param string $pickupSublocation The sublocation where the user wants to pickup the item when available
* @param string $pickupBranch The branch where the user wants to pick up the item when available
* @param ?string $cancelDate
* @param ?string $pickupSublocation The sublocation within the location where the user wants to pick up the item
* @return mixed True if successful, false if unsuccessful
* If an error occurs, return a AspenError
* If an error occurs, return an AspenError
* @access public
*/
function placeHold(User $patron, string $recordId, string $pickupBranch, ?string $cancelDate = null, ?string $pickupSublocation = null) : array {
Expand Down
3 changes: 3 additions & 0 deletions code/web/Drivers/Polaris.php
Original file line number Diff line number Diff line change
Expand Up @@ -1427,6 +1427,9 @@ function changeHoldPickupLocation(User $patron, $recordId, $itemToUpdateId, $new
// Todo: Add HoldPickupAreaID value to update hold area ($newPickupSublocation) ??
$staffInfo = $this->getStaffUserInfo();
$polarisUrl = "/PAPIService/REST/public/v1/1033/100/1/patron/{$patron->getBarcode()}/holdrequests/$itemToUpdateId/pickupbranch?wsid={$this->getWorkstationID($patron)}&userid={$staffInfo['polarisId']}&pickupbranchid=$newPickupLocation";
if (!empty($newPickupSublocation)) {
$polarisUrl .= "&holdpickupareaid=$newPickupSublocation";
}
$body = new stdClass();
$body->UserID = $staffInfo['polarisId'];
$response = $this->getWebServiceResponse($polarisUrl, 'PUT', $this->getAccessToken($patron->getBarcode(), $patron->getPasswordOrPin()), false, UserAccount::isUserMasquerading());
Expand Down
4 changes: 1 addition & 3 deletions code/web/Drivers/Sierra.php
Original file line number Diff line number Diff line change
Expand Up @@ -1167,9 +1167,7 @@ public function placeHold($patron, $recordId, $pickupBranch = null, $cancelDate
}

public function placeItemHold($patron, $recordId, $itemId, $pickupBranch, $cancelDate = null, $pickupSublocation = null) {
//return parent::placeItemHold($patron, $recordId, $itemId, $pickupBranch, $cancelDate);
return $this->placeHold($patron, $itemId, $pickupBranch, $cancelDate, $pickupSublocation);
//return $this->placeHold($patron, $itemId, $pickupBranch, $cancelDate);
return $this->placeHold($patron, $itemId, $pickupBranch, $cancelDate);
}

public function placeVolumeHold(User $patron, $recordId, $volumeId, $pickupBranch, $pickupSublocation = null) {
Expand Down
2 changes: 1 addition & 1 deletion code/web/RecordDrivers/MarcRecordDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct($recordData, $groupedWork = null) {
//Full MARC record
$this->marcRecord = $recordData;
$this->valid = true;
} elseif (is_string($recordData)) {
} elseif (is_string($recordData) || is_numeric($recordData)) {
//Just the id
require_once ROOT_DIR . '/sys/MarcLoader.php';
if (strpos($recordData, ':') !== false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,25 @@
<input type="hidden" name="currentLocation" value="{$currentLocation}" id="currentLocation"/>
<div class="rateTitle form-group">
<label for="newPickupLocation">{translate text="Select a new branch to pickup your hold" isPublicFacing=true}</label>
<select name="newPickupLocation" id="newPickupLocation" class="form-control"
onchange="AspenDiscovery.Account.generateChangeSublocationSelect();">
{if count($pickupLocations) > 0}
{foreach from=$pickupLocations item=location key=locationCode}
{if $location->code}
<option value="{$location->code}"
{if is_object($location) && ($location->locationId == $currentLocation)}selected="selected"{/if}>{$location->displayName|escape}</option>
{/if}
{/foreach}
{else}
<select name="newPickupLocation" id="newPickupLocation" class="form-control" onchange="AspenDiscovery.Account.generateChangeSublocationSelect();">
{if count($pickupLocations) > 0}
{foreach from=$pickupLocations item=location key=locationCode}
{if $location->code}
<option value="{$location->code}" {if is_object($location) && ($location->locationId == $currentLocation)}selected="selected"{/if}>{$location->displayName|escape}</option>
{/if}
{/foreach}
{else}
<option>{translate text="placeholder" isPublicFacing=true inAttribute=true}</option>
{/if}
{/if}
</select>
</div>
<div class="rateTitle form-group">
<div id="pickupSublocationOptions" style="margin-top:15px">
<div id="sublocationSelectPlaceHolder"></div>
</div>
</div>
<script>
AspenDiscovery.Account.generateChangeSublocationSelect();
</script>
</form>
{/strip}
{/strip}
3 changes: 1 addition & 2 deletions code/web/interface/themes/responsive/js/aspen.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions code/web/interface/themes/responsive/js/aspen/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -2838,11 +2838,10 @@ AspenDiscovery.Account = (function () {
locationCode: locationCode,
context: 'updatePickupLocation'
};
selectPlaceholder.innerHTML = '';
$.getJSON(url, params, function (data) {
if (data.success) {
selectPlaceholder.innerHTML = data.selectHtml;
} else {
selectPlaceholder.innerHTML = '';
}
});
return false;
Expand Down
38 changes: 17 additions & 21 deletions code/web/services/MyAccount/AJAX.php
Original file line number Diff line number Diff line change
Expand Up @@ -1971,7 +1971,7 @@ function endMasquerade() {
}

/** @noinspection PhpUnused */
function getChangeHoldLocationForm() {
function getChangeHoldLocationForm() : array {
global $interface;
/** @var $interface UInterface
* @var $user User
Expand Down Expand Up @@ -2097,14 +2097,24 @@ function changeHoldLocation() {
$holdId = $_REQUEST['holdId'];
$newPickupLocation = $_REQUEST['newLocation'];
$newPickupSublocation = $_REQUEST['newSublocation'] ?? null;
$pickupSublocation = null;
if (!empty($newPickupSublocation)) {
//In the form this is set as the id of the sublocation in Aspen, but we want to pass the ILS ID
require_once ROOT_DIR . '/sys/LibraryLocation/Sublocation.php';
$pickupSublocationObject = new Sublocation();
$pickupSublocationObject->id = $newPickupSublocation;
if ($pickupSublocationObject->find(true)) {
$pickupSublocation = $pickupSublocationObject->ilsId;
}
}

if (UserAccount::isLoggedIn()) {
$user = UserAccount::getLoggedInUser();
$patronId = $_REQUEST['patronId'];
$patronOwningHold = $user->getUserReferredTo($patronId);
if ($patronOwningHold != false) {
if ($patronOwningHold->validatePickupBranch($newPickupLocation)) {
return $patronOwningHold->changeHoldPickUpLocation($holdId, $newPickupLocation, $newPickupSublocation);
return $patronOwningHold->changeHoldPickUpLocation($holdId, $newPickupLocation, $pickupSublocation);
} else {
return [
'result' => false,
Expand Down Expand Up @@ -8996,14 +9006,12 @@ function getYearInReviewSlideImage() {
}

/** @noinspection PhpUnused */
function getSublocationsSelect() {
global $interface;
function getSublocationsSelect() : array {
$html = '';
$success = false;
$context = $_REQUEST['context'] ?? '';
if (UserAccount::isLoggedIn()) {
$patron = UserAccount::getActiveUserObj();
$patronType = $patron->getPTypeObj();
if (isset($_REQUEST['locationCode'])) {
$location = new Location();
if ($context === 'myPreferences') {
Expand All @@ -9013,24 +9021,12 @@ function getSublocationsSelect() {
}
if ($location->find(true)) {
$sublocations = [];
require_once ROOT_DIR . '/sys/LibraryLocation/Sublocation.php';
require_once ROOT_DIR . '/sys/LibraryLocation/SublocationPatronType.php';
$object = new Sublocation();
$object->locationId = $location->locationId;
$object->isValidHoldPickupAreaILS = 1;
$object->isValidHoldPickupAreaAspen = 1;
$object->orderBy('weight');
$object->find();
while ($object->fetch()) {
$sublocationPType = new SublocationPatronType();
$sublocationPType->patronTypeId = $patronType->id;
$sublocationPType->sublocationId = $object->id;
if ($sublocationPType->find(true)) {
$sublocations[$object->id] = $object->name;
}
$allSublocations = $location->getPickupSublocations($patron);
foreach ($allSublocations as $sublocation) {
$sublocations[$sublocation->id] = $sublocation->name;
}

if (count($sublocations) > 0) {
if (count($sublocations) > 1) {
$success = true;
if ($context === 'myPreferences') {
$labelText = 'Preferred Pickup Location';
Expand Down
25 changes: 22 additions & 3 deletions code/web/sys/LibraryLocation/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -1631,10 +1631,10 @@ function getPickupBranches(User|bool|null $patronProfile, bool $isLinkedUser = f

/**
* Get a list of sublocations where a user can pick up from
**
* @param ?User $patron The patron to filter valid sublocations by
* @return Sublocation[]
*/
function getPickupSublocations(): array {
function getPickupSublocations(?User $patron = null): array {
require_once ROOT_DIR . '/sys/LibraryLocation/Sublocation.php';
$sublocations = [];
$object = new Sublocation();
Expand All @@ -1643,8 +1643,27 @@ function getPickupSublocations(): array {
$object->isValidHoldPickupAreaAspen = 1;
$object->orderBy('weight');
$object->find();

if ($patron != null) {
$patronPType = $patron->getPTypeObj();
}else{
$patronPType = null;
}

while ($object->fetch()) {
$sublocations[$object->id] = clone($object);
$isValid = true;
if ($patron != null && $patronPType != null) {
require_once ROOT_DIR . '/sys/LibraryLocation/SublocationPatronType.php';
$sublocationPType = new SublocationPatronType();
$sublocationPType->patronTypeId = $patronPType->id;
$sublocationPType->sublocationId = $object->id;
if ($sublocationPType->find(true)) {
$isValid = true;
}
}
if ($isValid) {
$sublocations[$object->id] = clone($object);
}
}

return $sublocations;
Expand Down

0 comments on commit bfe5f0d

Please sign in to comment.