@@ -, +, @@ pick up locations have a record with multiple copies 2- Change the user library (set it to library C) and save 3- Click on “Search to hold” 6- Check the “pickup at” field in the top section and those in the column “Allowed pickup locations” 7- Change the library of the top “pickup at” field 8- Check the “Allowed pickup locations” of each item 9- Notice that the “Allowed pickup locations” columns are not adjusted --- .../prog/en/modules/reserve/request.tt | 55 +++++++++++++++++-- 1 file changed, 50 insertions(+), 5 deletions(-) --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt @@ -1330,6 +1330,8 @@ $.fn.select2.defaults.set("width", "100%" ); $.fn.select2.defaults.set("dropdownAutoWidth", true ); + var pickup_locations_by_item = {}; + $(document).ready(function() { $('#cancellation-reason-fieldset').hide(); $('.rank-request').on('change', function() { @@ -1366,15 +1368,57 @@ ToggleHoldsToPlace(); }); - [% IF Koha.Preference('UseBranchTransferLimits') %] - $("#pickup").on('change', function(){ - var pickup = $("#pickup").val(); + function setPickupLocation (select) { + var item_id = select.data('item-id'); + var url = '/api/v1/items/' + encodeURIComponent(item_id) + '/pickup_locations'; + + $.ajax({ + dataType: 'json', + url: url, + data: { + "q": JSON.stringify({ + "name": { + "-like":'%'+(($.param().term === undefined) ? '' : $.param().term)+'%' + } + }), + "_order_by": "name", + "_page": $.param().page, + "patron_id": select.data('patron-id') + }, + success: function(data) { + pickup_locations_by_item[`${item_id}`] = []; + data.forEach(function (pickup_location) { + pickup_locations_by_item[`${item_id}`].push({ + "id": pickup_location.library_id, + "name": pickup_location.name + }); + }); + } + }); + } + + $("#pickup").on('change', function() { + var pickup = $("#pickup").val(); + [% IF Koha.Preference('UseBranchTransferLimits') %] var url = "?pickup=" + pickup; url += "&borrowernumber=" + borrowernumber; url += "&biblionumber=" + biblionumbers[0]; window.location.replace(url); - }); - [% END %] + [% ELSE %] + $(".pickup_locations").each(function () { + const pickup_locations = pickup_locations_by_item[$(this).data('item-id')]; + if (pickup_locations) { + const location = pickup_locations.find((pickup_location) => pickup_location.id === pickup); + if (location) { + var option = $("