Browse Source

Bug 28338: Default to holding branch to save clicks

This patch makes request.pl pass the holding library object to the
template, if it is a valid pickup location for the item. This way, the
template can set a good default to save clicks.

To test:
1. Have "Hold pickup library match" set to "Item's home library"
2. Have a record with items in three different branches. For example:
   - item1: homebranch: MPL, holdingbranch: MPL
   - item2: homebranch: FPL, holdingbranch: FPL
   - item3: homebranch: CPL, holdingbranch: IPT
3. Have FPL marked as 'No' for pickup location
4. On the record, open the page for placing a hold for a patron
   (acevedo?)
=> SUCCESS: You are presented the regular hold placing page, with an
extra column on the items for pickup location setting
=> SUCCESS: The item2 (on FPL) cannot be selected, there's a clear message
about not having valid pickup locations
=> FAIL: The other ones don't have anything pre-selected on the
dropdowns
5. Apply this patch
6. Repeat 4 (go back to the record, etc)
=> SUCCESS: Nothing changed BUT the item with holding branch = MPL has
it set by default in the dropdown.
=> SUCCESS: IPT is not a valid pickup location for item3, so not set by
default in this case.
7. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
21.05.x
Tomás Cohen Arazi 3 years ago
committed by Kyle M Hall
parent
commit
ff2010cb50
  1. 8
      koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt
  2. 7
      reserve/placerequest.pl
  3. 6
      reserve/request.pl

8
koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt

@ -731,9 +731,13 @@
</td>
<td>
[% IF (itemloo.pickup_locations_count > 0) %]
<select name="item_pickup" class="pickup_locations"
<select name="item_pickup_[% itemloo.itemnumber | html %]" class="pickup_locations"
data-item-id="[% itemloo.itemnumber | html %]"
data-patron-id="[% patron.borrowernumber | html %]"></select>
data-patron-id="[% patron.borrowernumber | html %]">
[% IF (itemloo.default_pickup_location) %]
<option value="[% itemloo.default_pickup_location.branchcode | html %]" selected="selected">[% itemloo.default_pickup_location.branchname | html %]</option>
[% END %]
</select>
[% END %]
</td>
</tr>

7
reserve/placerequest.pl

@ -45,7 +45,6 @@ my $biblionumber = $input->param('biblionumber');
my $borrowernumber = $input->param('borrowernumber');
my $notes = $input->param('notes');
my $branch = $input->param('pickup');
my $item_pickup = $input->param('item_pickup');
my $startdate = $input->param('reserve_date') || '';
my @rank = $input->multi_param('rank-request');
my $type = $input->param('type');
@ -95,18 +94,20 @@ if ( $type eq 'str8' && $borrower ) {
my $can_override = C4::Context->preference('AllowHoldPolicyOverride');
if ( defined $checkitem && $checkitem ne '' ) {
my $item_pickup_location = $input->param("item_pickup_$checkitem");
my $item = Koha::Items->find($checkitem);
if ( $item->biblionumber ne $biblionumber ) {
$biblionumber = $item->biblionumber;
}
my $can_item_be_reserved = CanItemBeReserved($borrower->{'borrowernumber'}, $item->itemnumber, $item_pickup)->{status};
my $can_item_be_reserved = CanItemBeReserved($borrower->{'borrowernumber'}, $item->itemnumber, $item_pickup_location)->{status};
if ( $can_item_be_reserved eq 'OK' || ( $can_item_be_reserved ne 'itemAlreadyOnHold' && $can_override ) ) {
AddReserve(
{
branchcode => $item_pickup,
branchcode => $item_pickup_location,
borrowernumber => $borrower->{'borrowernumber'},
biblionumber => $biblionumber,
priority => $rank[0],

6
reserve/request.pl

@ -585,10 +585,14 @@ foreach my $biblionumber (@biblionumbers) {
)
{
# Send the pickup locations count to the UI, the pickup locations will be pulled using the API
$item->{pickup_locations_count} = $item_object->pickup_locations({ patron => $patron })->count;
my $pickup_locations = $item_object->pickup_locations({ patron => $patron });
$item->{pickup_locations_count} = $pickup_locations->count;
if ( $item->{pickup_locations_count} > 0 ) {
$num_available++;
$item->{available} = 1;
# pass the holding branch for use as default
my $default_pickup_location = $pickup_locations->search({ branchcode => $item->{holdingbranch} })->next;
$item->{default_pickup_location} = $default_pickup_location;
}
else {
$item->{available} = 0;

Loading…
Cancel
Save