Bugzilla – Attachment 120924 Details for
Bug 28273
Multi-holds allow invalid pickup locations
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28273: Multi-hold should not offer invalid pickup locations
Bug-28273-Multi-hold-should-not-offer-invalid-pick.patch (text/plain), 8.25 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-05-13 12:14:06 UTC
(
hide
)
Description:
Bug 28273: Multi-hold should not offer invalid pickup locations
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-05-13 12:14:06 UTC
Size:
8.25 KB
patch
obsolete
>From 0c1fc78095fcad694042db3d31e3e31be8dd18c9 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 3 May 2021 11:42:47 -0300 >Subject: [PATCH] Bug 28273: Multi-hold should not offer invalid pickup > locations > >This patch makes the multi-hold page offer only valid pickup locations >for the selected biblios. Prior to this, all system-wide pickup >locations were offered. > >To test: >1. Set 'Hold pickup library match' to 'Item's home branch' so we put a > constraint on the valid pickup locations for easier testing. >2. Choose two or more biblios from a search, which contain in total 2 > or 3 item home branches. >3. Click 'Place hold' >4. Choose a patron >=> FAIL: The dropdown offers all system's pickup locations >5. Apply this patches >6. Reload the page >=> SUCCESS: Only valid pickup locations are offered >7. Sign off :-D >--- > .../prog/en/modules/reserve/request.tt | 44 +++++++++++++++++-- > reserve/placerequest.pl | 7 +-- > reserve/request.pl | 14 ++++++ > 3 files changed, 59 insertions(+), 6 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >index 211b9904edc..73b50fc0bb5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >@@ -1,6 +1,7 @@ > [% USE raw %] > [% USE To %] > [% USE Asset %] >+[% USE JSON.Escape %] > [% USE Koha %] > [% USE KohaDates %] > [% USE Branches %] >@@ -414,6 +415,7 @@ > > [% IF ( multi_hold ) %] > <input type="hidden" name="biblionumbers" id="multi_hold_bibs" value="[% biblionumbers | html %]"/> >+ <input type="hidden" name="multi_holds" id="multi_holds" value="1" /> > <input type="hidden" name="bad_bibs" id="bad_bibs" value=""/> > <input type="hidden" name="request" value="any"/> > [% FOREACH biblioloo IN biblioloop %] >@@ -454,7 +456,10 @@ > [% PROCESS options_for_libraries libraries => Branches.pickup_locations({ search_params => { biblio => biblionumber, patron => patron }, selected => pickup }) %] > [% ELSE %] > <select name="pickup" id="pickup_multi" data-patron-id="[% patron.borrowernumber | html %]"> >- [% PROCESS options_for_libraries libraries => Branches.all({ selected => pickup, search_params => { pickup_location => 1 } }) %] >+ <option value="" selected="selected"></option> >+ [% FOREACH pickup_location IN multi_pickup_locations %] >+ <option value="[% pickup_location.branchcode | html %]">[% pickup_location.branchname | html %]</option> >+ [% END %] > [% END %] > </select> > </li> >@@ -759,6 +764,7 @@ > [% END %] > <th>Priority</th> > <th>Information</th> >+ <th>Pickup location</th> > </tr> > [% FOREACH biblioloo IN biblioloop %] > [% IF ( biblioloo.warn ) %] >@@ -822,6 +828,18 @@ > [% END %] > [% END %] > </td> >+ <td> >+ <select name="pickup_[% biblioloo.biblionumber | html %]" >+ class="multi_pickup_select" >+ data-biblio-id="[% biblioloo.biblionumber | html %]" >+ data-patron-id="[% patron.borrowernumber | html %]" >+ data-pickup-locations='[% biblioloo.pickup_locations_codes.json | $raw %]'> >+ <option value=""></option> >+ [% FOREACH pickup_location IN biblioloo.pickup_locations %] >+ <option value="[% pickup_location.branchcode | html %]">[% pickup_location.branchname | html %]</option> >+ [% END %] >+ </select> >+ </td> > </tr> > [% END # /FOREACH biblioloo %] > </table> <!-- /#requesttitles --> >@@ -1252,10 +1270,30 @@ > templateResult: display_pickup_location > }); > }); >+ > $("#pickup_multi").select2({ >- width: 'style', >- allowClear: false >+ width: '30%', >+ allowClear: true >+ }); >+ >+ $('.multi_pickup_select').select2({ >+ width: '100%', >+ allowClear: true > }); >+ >+ $("#pickup_multi").on("change", function() { >+ var selection = $(this).val(); >+ if ( selection != '' ) { >+ $(".multi_pickup_select").each(function() { >+ var valid_pickup_locations = $(this).data('pickup-locations'); >+ if ( valid_pickup_locations.includes(selection) ) { >+ $(this).val(selection); >+ $(this).trigger("change"); >+ } >+ }); >+ } >+ }); >+ > $("#pickup").each( function () { > var this_dropdown = $(this); > var patron_id = $(this).data('patron-id'); >diff --git a/reserve/placerequest.pl b/reserve/placerequest.pl >index 9e83661c337..63555944a59 100755 >--- a/reserve/placerequest.pl >+++ b/reserve/placerequest.pl >@@ -67,8 +67,9 @@ my %bibinfos = (); > my @biblionumbers = split '/', $biblionumbers; > foreach my $bibnum (@biblionumbers) { > my %bibinfo = (); >- $bibinfo{title} = $input->param("title_$bibnum"); >- $bibinfo{rank} = $input->param("rank_$bibnum"); >+ $bibinfo{title} = $input->param("title_$bibnum"); >+ $bibinfo{rank} = $input->param("rank_$bibnum"); >+ $bibinfo{pickup} = $input->param("pickup_$bibnum"); > $bibinfos{$bibnum} = \%bibinfo; > } > >@@ -128,7 +129,7 @@ if ( $type eq 'str8' && $borrower ) { > if ( $can_override || CanBookBeReserved($borrower->{'borrowernumber'}, $biblionumber)->{status} eq 'OK' ) { > AddReserve( > { >- branchcode => $branch, >+ branchcode => $bibinfo->{pickup}, > borrowernumber => $borrower->{'borrowernumber'}, > biblionumber => $biblionumber, > priority => $bibinfo->{rank}, >diff --git a/reserve/request.pl b/reserve/request.pl >index f9847ada773..bf13c3dfb2b 100755 >--- a/reserve/request.pl >+++ b/reserve/request.pl >@@ -286,6 +286,13 @@ $template->param( > # FIXME launch another time GetMember perhaps until (Joubu: Why?) > my $patron = Koha::Patrons->find( $borrowernumber_hold ); > >+if ( $patron && $multi_hold ) { >+ my @multi_pickup_locations = >+ Koha::Biblios->search( { biblionumber => \@biblionumbers } ) >+ ->pickup_locations( { patron => $patron } ); >+ $template->param( multi_pickup_locations => \@multi_pickup_locations ); >+} >+ > my $logged_in_patron = Koha::Patrons->find( $borrowernumber ); > > my $wants_check; >@@ -737,6 +744,13 @@ foreach my $biblionumber (@biblionumbers) { > $template->param( reserveloop => \@reserveloop ); > } > >+ if ( $patron ) { >+ # Add the valid pickup locations >+ my @pickup_locations = $biblio->pickup_locations({ patron => $patron }); >+ $biblioloopiter{pickup_locations} = \@pickup_locations; >+ $biblioloopiter{pickup_locations_codes} = [ map { $_->branchcode } @pickup_locations ]; >+ } >+ > push @biblioloop, \%biblioloopiter; > } > >-- >2.31.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 28273
:
120407
|
120408
|
120923
|
120924
|
120925
|
120926
|
120933
|
120934
|
120935
|
120936
|
120957
|
120958
|
120959
|
120960
|
120961