4 #written 2/1/00 by chris@katipo.oc.nz
5 # Copyright 2000-2002 Katipo Communications
6 # Parts Copyright 2011 Catalyst IT
8 # This file is part of Koha.
10 # Koha is free software; you can redistribute it and/or modify it
11 # under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 3 of the License, or
13 # (at your option) any later version.
15 # Koha is distributed in the hope that it will be useful, but
16 # WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with Koha; if not, see <http://www.gnu.org/licenses>.
25 script to place reserves/requests
32 use List::MoreUtils qw( uniq );
33 use Date::Calc qw( Date_to_Days );
34 use C4::Output qw( output_html_with_http_headers );
35 use C4::Auth qw( get_template_and_user );
36 use C4::Reserves qw( RevertWaitingStatus AlterPriority ToggleLowestPriority ToggleSuspend CanBookBeReserved GetMaxPatronHoldsForRecord ItemsAnyAvailableAndNotRestricted CanItemBeReserved IsAvailableForItemLevelRequest );
37 use C4::Items qw( get_hostitemnumbers_of );
38 use C4::Koha qw( getitemtypeimagelocation );
39 use C4::Serials qw( CountSubscriptionFromBiblionumber );
40 use C4::Circulation qw( GetTransfers _GetCircControlBranch GetBranchItemRule );
41 use Koha::DateUtils qw( dt_from_string output_pref );
42 use C4::Utils::DataTables::Members;
43 use C4::Search qw( enabled_staff_search_views );
46 use Koha::DateUtils qw( dt_from_string output_pref );
49 use Koha::CirculationRules;
56 my $dbh = C4::Context->dbh;
58 my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user(
60 template_name => "reserve/request.tt",
63 flagsrequired => { reserveforothers => 'place_holds' },
67 my $showallitems = $input->param('showallitems');
68 my $pickup = $input->param('pickup');
70 my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
72 # Select borrowers infos
73 my $findborrower = $input->param('findborrower');
74 $findborrower = '' unless defined $findborrower;
75 $findborrower =~ s|,| |g;
76 my $findclub = $input->param('findclub');
77 $findclub = '' unless defined $findclub && !$findborrower;
78 my $borrowernumber_hold = $input->param('borrowernumber') || '';
79 my $club_hold = $input->param('club')||'';
84 my $exceeded_maxreserves;
85 my $exceeded_holds_per_record;
87 my $date = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
88 my $action = $input->param('action');
91 if ( $action eq 'move' ) {
92 my $where = $input->param('where');
93 my $reserve_id = $input->param('reserve_id');
94 my $prev_priority = $input->param('prev_priority');
95 my $next_priority = $input->param('next_priority');
96 my $first_priority = $input->param('first_priority');
97 my $last_priority = $input->param('last_priority');
98 my $hold_itemnumber = $input->param('itemnumber');
99 if ( $prev_priority == 0 && $next_priority == 1 ){
100 C4::Reserves::RevertWaitingStatus({ itemnumber => $hold_itemnumber });
102 AlterPriority( $where, $reserve_id, $prev_priority, $next_priority, $first_priority, $last_priority );
104 } elsif ( $action eq 'cancel' ) {
105 my $reserve_id = $input->param('reserve_id');
106 my $cancellation_reason = $input->param("cancellation-reason");
107 my $hold = Koha::Holds->find( $reserve_id );
108 $hold->cancel({ cancellation_reason => $cancellation_reason }) if $hold;
109 } elsif ( $action eq 'setLowestPriority' ) {
110 my $reserve_id = $input->param('reserve_id');
111 ToggleLowestPriority( $reserve_id );
112 } elsif ( $action eq 'toggleSuspend' ) {
113 my $reserve_id = $input->param('reserve_id');
114 my $suspend_until = $input->param('suspend_until');
115 ToggleSuspend( $reserve_id, $suspend_until );
119 my $patron = Koha::Patrons->find( { cardnumber => $findborrower } );
121 $borrowernumber_hold = $patron->borrowernumber;
123 my $dt_params = { iDisplayLength => -1 };
124 my $results = C4::Utils::DataTables::Members::search(
126 searchmember => $findborrower,
127 dt_params => $dt_params,
130 my $borrowers = $results->{patrons};
131 if ( scalar @$borrowers == 1 ) {
132 $borrowernumber_hold = $borrowers->[0]->{borrowernumber};
133 } elsif ( @$borrowers ) {
134 $template->param( borrowers => $borrowers );
136 $messageborrower = "'$findborrower'";
142 my $club = Koha::Clubs->find( { name => $findclub } );
144 $club_hold = $club->id;
146 my @clubs = Koha::Clubs->search( [
147 { name => { like => '%'.$findclub.'%' } },
148 { description => { like => '%'.$findclub.'%' } }
150 if( scalar @clubs == 1 ) {
151 $club_hold = $clubs[0]->id;
153 $template->param( clubs => \@clubs );
155 $messageclub = "'$findclub'";
160 my @biblionumbers = ();
161 my $biblionumber = $input->param('biblionumber');
162 my $biblionumbers = $input->param('biblionumbers');
163 if ( $biblionumbers ) {
164 @biblionumbers = split '/', $biblionumbers;
166 push @biblionumbers, $input->multi_param('biblionumber');
169 my $multi_hold = @biblionumbers > 1;
171 multi_hold => $multi_hold,
174 # If we have the borrowernumber because we've performed an action, then we
175 # don't want to try to place another reserve.
176 if ($borrowernumber_hold && !$action) {
177 my $patron = Koha::Patrons->find( $borrowernumber_hold );
180 # we check the reserves of the user, and if they can reserve a document
181 # FIXME At this time we have a simple count of reservs, but, later, we could improve the infos "title" ...
183 my $reserves_count = $patron->holds->count;
185 my $new_reserves_count = scalar( @biblionumbers );
187 my $maxreserves = C4::Context->preference('maxreserves');
188 $template->param( maxreserves => $maxreserves );
191 && ( $reserves_count + $new_reserves_count > $maxreserves ) )
193 my $new_reserves_allowed =
194 $maxreserves - $reserves_count > 0
195 ? $maxreserves - $reserves_count
198 $exceeded_maxreserves = 1;
200 new_reserves_allowed => $new_reserves_allowed,
201 new_reserves_count => $new_reserves_count,
202 reserves_count => $reserves_count,
203 maxreserves => $maxreserves,
207 # we check the date expiry of the borrower (only if there is an expiry date, otherwise, set to 1 (warn)
208 my $expiry_date = $patron->dateexpiry;
209 my $expiry = 0; # flag set if patron account has expired
211 Date_to_Days(split /-/,$date) > Date_to_Days(split /-/,$expiry_date)) {
215 # check if the borrower make the reserv in a different branch
216 if ( $patron->branchcode ne C4::Context->userenv->{'branch'} ) {
220 my $amount_outstanding = $patron->account->balance;
224 diffbranch => $diffbranch,
225 messages => $messages,
226 warnings => $warnings,
227 amount_outstanding => $amount_outstanding,
231 if ($club_hold && !$borrowernumber_hold && !$action) {
232 my $club = Koha::Clubs->find($club_hold);
234 my $enrollments = $club->club_enrollments;
236 my $maxreserves = C4::Context->preference('maxreserves');
237 my $new_reserves_count = scalar( @biblionumbers );
241 while(my $enrollment = $enrollments->next) {
242 next if $enrollment->is_canceled;
243 my $member = { patron => $enrollment->patron->unblessed };
244 my $reserves_count = $enrollment->patron->holds->count;
246 && ( $reserves_count + $new_reserves_count > $maxreserves ) )
248 $member->{new_reserves_allowed} = $maxreserves - $reserves_count > 0
249 ? $maxreserves - $reserves_count
251 $member->{exceeded_maxreserves} = 1;
253 my $expiry_date = $enrollment->patron->dateexpiry;
254 $member->{expiry} = 0; # flag set if patron account has expired
256 Date_to_Days(split /-/,$date) > Date_to_Days(split /-/,$expiry_date)) {
257 $member->{expiry} = 1;
259 $member->{amount_outstanding} = $enrollment->patron->account->balance;
260 if ( $enrollment->patron->branchcode ne C4::Context->userenv->{'branch'} ) {
261 $member->{diffbranch} = 1;
264 push @members, $member;
269 members => \@members,
270 maxreserves => $maxreserves,
271 new_reserves_count => $new_reserves_count
275 unless ( $club_hold or $borrowernumber_hold ) {
276 $template->param( clubcount => Koha::Clubs->search->count );
280 messageborrower => $messageborrower,
281 messageclub => $messageclub
284 # FIXME launch another time GetMember perhaps until (Joubu: Why?)
285 my $patron = Koha::Patrons->find( $borrowernumber_hold );
287 if ( $patron && $multi_hold ) {
288 my @multi_pickup_locations =
289 Koha::Biblios->search( { biblionumber => \@biblionumbers } )
290 ->pickup_locations( { patron => $patron } );
291 $template->param( multi_pickup_locations => \@multi_pickup_locations );
294 my $logged_in_patron = Koha::Patrons->find( $borrowernumber );
298 $wants_check = $patron->wants_check_for_previous_checkout;
300 my $itemdata_enumchron = 0;
301 my $itemdata_ccode = 0;
303 my $no_reserves_allowed = 0;
304 foreach my $biblionumber (@biblionumbers) {
305 next unless $biblionumber =~ m|^\d+$|;
307 my %biblioloopiter = ();
309 my $biblio = Koha::Biblios->find( $biblionumber );
311 $biblioloopiter{noitems} = 1;
312 $template->param('nobiblio' => 1);
316 my $force_hold_level;
318 { # CanBookBeReserved
319 my $canReserve = CanBookBeReserved( $patron->borrowernumber, $biblionumber );
320 if ( $canReserve->{status} eq 'OK' ) {
322 #All is OK and we can continue
324 elsif ( $canReserve->{status} eq 'noReservesAllowed' || $canReserve->{status} eq 'notReservable' ) {
325 $no_reserves_allowed = 1;
327 elsif ( $canReserve->{status} eq 'tooManyReserves' ) {
328 $exceeded_maxreserves = 1;
329 $template->param( maxreserves => $canReserve->{limit} );
331 elsif ( $canReserve->{status} eq 'tooManyHoldsForThisRecord' ) {
332 $exceeded_holds_per_record = 1;
333 $biblioloopiter{ $canReserve->{status} } = 1;
335 elsif ( $canReserve->{status} eq 'ageRestricted' ) {
336 $template->param( $canReserve->{status} => 1 );
337 $biblioloopiter{ $canReserve->{status} } = 1;
339 elsif ( $canReserve->{status} eq 'alreadypossession' ) {
340 $template->param( $canReserve->{status} => 1);
341 $biblioloopiter{ $canReserve->{status} } = 1;
344 $biblioloopiter{ $canReserve->{status} } = 1;
348 # For multiple holds per record, if a patron has previously placed a hold,
349 # the patron can only place more holds of the same type. That is, if the
350 # patron placed a record level hold, all the holds the patron places must
351 # be record level. If the patron placed an item level hold, all holds
352 # the patron places must be item level
353 my $holds = Koha::Holds->search(
355 borrowernumber => $patron->borrowernumber,
356 biblionumber => $biblionumber,
360 $force_hold_level = $holds->forced_hold_level();
361 $biblioloopiter{force_hold_level} = $force_hold_level;
362 $template->param( force_hold_level => $force_hold_level );
364 # For a librarian to be able to place multiple record holds for a patron for a record,
365 # we must find out what the maximum number of holds they can place for the patron is
366 my $max_holds_for_record = GetMaxPatronHoldsForRecord( $patron->borrowernumber, $biblionumber );
367 my $remaining_holds_for_record = $max_holds_for_record - $holds->count();
368 $biblioloopiter{remaining_holds_for_record} = $max_holds_for_record;
369 $template->param( max_holds_for_record => $max_holds_for_record );
370 $template->param( remaining_holds_for_record => $remaining_holds_for_record );
374 my $count = Koha::Holds->search( { biblionumber => $biblionumber } )->count();
375 my $totalcount = $count;
377 # adding a fixed value for priority options
378 my $fixedRank = $count+1;
380 my %itemnumbers_of_biblioitem;
382 my @hostitems = get_hostitemnumbers_of($biblionumber);
385 $template->param('hostitemsflag' => 1);
386 push(@itemnumbers, @hostitems);
389 my $items = Koha::Items->search({ -or => { biblionumber => $biblionumber, itemnumber => { in => \@itemnumbers } } });
391 unless ( $items->count ) {
392 # FIXME Then why do we continue?
393 $template->param('noitems' => 1) unless ( $multi_hold );
394 $biblioloopiter{noitems} = 1;
397 ## Here we go backwards again to create hash of biblioitemnumber to itemnumbers
398 ## this is important when we have analytic items which may be on another record
399 my ( $iteminfos_of );
400 while ( my $item = $items->next ) {
401 $item = $item->unblessed;
402 my $biblioitemnumber = $item->{biblioitemnumber};
403 my $itemnumber = $item->{itemnumber};
404 push( @{ $itemnumbers_of_biblioitem{$biblioitemnumber} }, $itemnumber );
405 $iteminfos_of->{$itemnumber} = $item;
408 my @biblioitemnumbers = keys %itemnumbers_of_biblioitem;
410 my $biblioiteminfos_of = {
413 ( $biblioitem->{biblioitemnumber} => $biblioitem )
414 } @{ Koha::Biblioitems->search(
415 { biblioitemnumber => { -in => \@biblioitemnumbers } },
416 { select => ['biblionumber', 'biblioitemnumber', 'publicationyear', 'itemtype']}
423 my @available_itemtypes;
424 foreach my $biblioitemnumber (@biblioitemnumbers) {
425 my $biblioitem = $biblioiteminfos_of->{$biblioitemnumber};
426 my $num_available = 0;
427 my $num_override = 0;
429 my $num_alreadyheld = 0;
431 $biblioitem->{force_hold_level} = $force_hold_level;
433 if ( $biblioitem->{biblioitemnumber} ne $biblionumber ) {
434 $biblioitem->{hostitemsflag} = 1;
437 $biblioloopiter{description} = $biblioitem->{description};
438 $biblioloopiter{itypename} = $biblioitem->{description};
439 if ( $biblioitem->{itemtype} ) {
441 $biblioitem->{description} =
442 $itemtypes->{ $biblioitem->{itemtype} }{description};
444 $biblioloopiter{imageurl} =
445 getitemtypeimagelocation( 'intranet',
446 $itemtypes->{ $biblioitem->{itemtype} }{imageurl} );
449 # iterating through all items first to check if any of them available
450 # to pass this value further inside down to IsAvailableForItemLevelRequest to
451 # it's complicated logic to analyse.
452 # (before this loop was inside that sub loop so it was O(n^2) )
453 my $items_any_available;
454 $items_any_available = ItemsAnyAvailableAndNotRestricted( { biblionumber => $biblioitem->{biblionumber}, patron => $patron })
457 foreach my $itemnumber ( @{ $itemnumbers_of_biblioitem{$biblioitemnumber} } ) {
458 my $item = $iteminfos_of->{$itemnumber};
461 $do_check = $patron->do_check_for_previous_checkout($item) if $wants_check;
462 if ( $do_check && $wants_check ) {
463 $item->{checked_previously} = $do_check;
465 $biblioloopiter{checked_previously} = $do_check;
467 $template->param( checked_previously => $do_check );
471 $item->{force_hold_level} = $force_hold_level;
473 unless (C4::Context->preference('item-level_itypes')) {
474 $item->{itype} = $biblioitem->{itemtype};
477 $item->{itypename} = $itemtypes->{ $item->{itype} }{description};
478 $item->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtypes->{ $item->{itype} }{imageurl} );
479 $item->{homebranch} = $item->{homebranch};
481 # if the holdingbranch is different than the homebranch, we show the
482 # holdingbranch of the document too
483 if ( $item->{homebranch} ne $item->{holdingbranch} ) {
484 $item->{holdingbranch} = $item->{holdingbranch};
487 if($item->{biblionumber} ne $biblionumber){
488 $item->{hostitemsflag} = 1;
489 $item->{hosttitle} = Koha::Biblios->find( $item->{biblionumber} )->title;
492 # if the item is currently on loan, we display its return date and
493 # change the background color
494 my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } );
496 $item->{date_due} = $issue->date_due;
497 $item->{backgroundcolor} = 'onloan';
501 my $item_object = Koha::Items->find( $itemnumber );
502 my $holds = $item_object->current_holds;
503 if ( my $first_hold = $holds->next ) {
504 my $p = Koha::Patrons->find( $first_hold->borrowernumber );
506 $item->{backgroundcolor} = 'reserved';
507 $item->{reservedate} = output_pref({ dt => dt_from_string( $first_hold->reservedate ), dateonly => 1 }); # FIXME Should be formatted in the template
508 $item->{ReservedFor} = $p;
509 $item->{ExpectedAtLibrary} = $first_hold->branchcode;
510 $item->{waitingdate} = $first_hold->waitingdate;
513 # Management of the notforloan document
514 if ( $item->{notforloan} ) {
515 $item->{backgroundcolor} = 'other';
518 # Management of lost or long overdue items
519 if ( $item->{itemlost} ) {
520 $item->{backgroundcolor} = 'other';
521 if ($logged_in_patron->category->hidelostitems && !$showallitems) {
527 # Check the transit status
528 my ( $transfertwhen, $transfertfrom, $transfertto ) =
529 GetTransfers($itemnumber);
531 if ( defined $transfertwhen && $transfertwhen ne '' ) {
532 $item->{transfertwhen} = output_pref({ dt => dt_from_string( $transfertwhen ), dateonly => 1 });
533 $item->{transfertfrom} = $transfertfrom;
534 $item->{transfertto} = $transfertto;
535 $item->{nocancel} = 1;
538 # If there is no loan, return and transfer, we show a checkbox.
539 $item->{notforloan} ||= 0;
541 # if independent branches is on we need to check if the person can reserve
542 # for branches they arent logged in to
543 if ( C4::Context->preference("IndependentBranches") ) {
544 if (! C4::Context->preference("canreservefromotherbranches")){
545 # can't reserve items so need to check if item homebranch and userenv branch match if not we can't reserve
546 my $userenv = C4::Context->userenv;
547 unless ( C4::Context->IsSuperLibrarian ) {
548 $item->{cantreserve} = 1 if ( $item->{homebranch} ne $userenv->{branch} );
554 my $patron_unblessed = $patron->unblessed;
555 my $branch = C4::Circulation::_GetCircControlBranch($item, $patron_unblessed);
557 my $branchitemrule = GetBranchItemRule( $branch, $item->{'itype'} );
559 $item->{'holdallowed'} = $branchitemrule->{'holdallowed'};
561 my $can_item_be_reserved = CanItemBeReserved( $patron->borrowernumber, $itemnumber )->{status};
562 $item->{not_holdable} = $can_item_be_reserved unless ( $can_item_be_reserved eq 'OK' );
564 $item->{item_level_holds} = Koha::CirculationRules->get_opacitemholds_policy( { item => $item_object, patron => $patron } );
567 !$item->{cantreserve}
568 && !$exceeded_maxreserves
569 && $can_item_be_reserved eq 'OK'
570 # items_any_available defined outside of the current loop,
571 # so we avoiding loop inside IsAvailableForItemLevelRequest:
572 && IsAvailableForItemLevelRequest($item_object, $patron, undef, $items_any_available)
575 # Send the pickup locations count to the UI, the pickup locations will be pulled using the API
576 my $pickup_locations = $item_object->pickup_locations({ patron => $patron });
577 $item->{pickup_locations_count} = $pickup_locations->count;
578 if ( $item->{pickup_locations_count} > 0 ) {
580 $item->{available} = 1;
581 # pass the holding branch for use as default
582 my $default_pickup_location = $pickup_locations->search({ branchcode => $item->{holdingbranch} })->next;
583 $item->{default_pickup_location} = $default_pickup_location;
586 $item->{available} = 0;
587 $item->{not_holdable} = "no_valid_pickup_location";
590 push( @available_itemtypes, $item->{itype} );
592 elsif ( C4::Context->preference('AllowHoldPolicyOverride') ) {
593 # If AllowHoldPolicyOverride is set, it should override EVERY restriction, not just branch item rules
594 # with the exception of itemAlreadyOnHold because, you know, the item is already on hold
595 if ( $can_item_be_reserved ne 'itemAlreadyOnHold' ) {
596 $item->{override} = 1;
598 } else { $num_alreadyheld++ }
600 push( @available_itemtypes, $item->{itype} );
603 # If none of the conditions hold true, then neither override nor available is set and the item cannot be checked
605 # Show serial enumeration when needed
606 if ($item->{enumchron}) {
607 $itemdata_enumchron = 1;
609 # Show collection when needed
610 if ($item->{ccode}) {
615 push @{ $biblioitem->{itemloop} }, $item;
618 # While we can't override an alreay held item, we should be able to override the others
619 # Unless all items are already held
620 if ( $num_override > 0 && ($num_override + $num_alreadyheld) == scalar( @{ $biblioitem->{itemloop} } ) ) {
621 # That is, if all items require an override
622 $template->param( override_required => 1 );
623 } elsif ( $num_available == 0 ) {
624 $template->param( none_available => 1 );
625 $biblioloopiter{warn} = 1;
626 $biblioloopiter{none_avail} = 1;
628 $template->param( hiddencount => $hiddencount);
630 push @bibitemloop, $biblioitem;
633 @available_itemtypes = uniq( @available_itemtypes );
634 $template->param( available_itemtypes => \@available_itemtypes );
636 # existingreserves building
638 my @reserves = Koha::Holds->search( { biblionumber => $biblionumber }, { order_by => 'priority' } );
641 my $a_found = $a->found() || '';
642 my $b_found = $a->found() || '';
643 $a_found cmp $b_found;
648 if ( $res->is_found() ) {
649 $reserve{'holdingbranch'} = $res->item()->holdingbranch();
650 $reserve{'biblionumber'} = $res->item()->biblionumber();
651 $reserve{'barcodenumber'} = $res->item()->barcode();
652 $reserve{'wbrcode'} = $res->branchcode();
653 $reserve{'itemnumber'} = $res->itemnumber();
654 $reserve{'wbrname'} = $res->branch()->branchname();
655 $reserve{'atdestination'} = $res->is_at_destination();
656 $reserve{'desk_name'} = ( $res->desk() ) ? $res->desk()->desk_name() : '' ;
657 $reserve{'found'} = $res->is_found();
658 $reserve{'inprocessing'} = $res->is_in_processing();
659 $reserve{'intransit'} = $res->is_in_transit();
661 elsif ( $res->priority() > 0 ) {
662 if ( my $item = $res->item() ) {
663 $reserve{'itemnumber'} = $item->id();
664 $reserve{'barcodenumber'} = $item->barcode();
665 $reserve{'item_level_hold'} = 1;
669 $reserve{'expirationdate'} = $res->expirationdate;
670 $reserve{'date'} = $res->reservedate;
671 $reserve{'borrowernumber'} = $res->borrowernumber();
672 $reserve{'biblionumber'} = $res->biblionumber();
673 $reserve{'patron'} = $res->borrower;
674 $reserve{'notes'} = $res->reservenotes();
675 $reserve{'waiting_date'} = $res->waitingdate();
676 $reserve{'ccode'} = $res->item() ? $res->item()->ccode() : undef;
677 $reserve{'barcode'} = $res->item() ? $res->item()->barcode() : undef;
678 $reserve{'priority'} = $res->priority();
679 $reserve{'lowestPriority'} = $res->lowestPriority();
680 $reserve{'suspend'} = $res->suspend();
681 $reserve{'suspend_until'} = $res->suspend_until();
682 $reserve{'reserve_id'} = $res->reserve_id();
683 $reserve{itemtype} = $res->itemtype();
684 $reserve{branchcode} = $res->branchcode();
685 $reserve{non_priority} = $res->non_priority();
686 $reserve{object} = $res;
688 push( @reserveloop, \%reserve );
691 # get the time for the form name...
696 fixedRank => $fixedRank,
701 bibitemloop => \@bibitemloop,
702 itemdata_enumchron => $itemdata_enumchron,
703 itemdata_ccode => $itemdata_ccode,
705 biblionumber => $biblionumber,
706 findborrower => $findborrower,
709 C4::Search::enabled_staff_search_views,
712 $biblioloopiter{biblionumber} = $biblionumber;
713 $biblioloopiter{title} = $biblio->title;
714 $biblioloopiter{rank} = $fixedRank;
715 $biblioloopiter{reserveloop} = \@reserveloop;
718 $template->param( reserveloop => \@reserveloop );
722 # Add the valid pickup locations
723 my @pickup_locations = $biblio->pickup_locations({ patron => $patron });
724 $biblioloopiter{pickup_locations} = \@pickup_locations;
725 $biblioloopiter{pickup_locations_codes} = [ map { $_->branchcode } @pickup_locations ];
728 push @biblioloop, \%biblioloopiter;
731 $template->param( biblioloop => \@biblioloop );
732 $template->param( no_reserves_allowed => $no_reserves_allowed );
733 $template->param( biblionumbers => join('/', @biblionumbers) );
734 $template->param( exceeded_maxreserves => $exceeded_maxreserves );
735 $template->param( exceeded_holds_per_record => $exceeded_holds_per_record );
736 $template->param( subscriptionsnumber => CountSubscriptionFromBiblionumber($biblionumber));
738 # pass the userenv branch if no pickup location selected
739 $template->param( pickup => $pickup || C4::Context->userenv->{branch} );
741 if ( C4::Context->preference( 'AllowHoldDateInFuture' ) ) {
742 $template->param( reserve_in_future => 1 );
746 SuspendHoldsIntranet => C4::Context->preference('SuspendHoldsIntranet'),
747 AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds'),
751 output_html_with_http_headers $input, $cookie, $template->output;
753 sub sort_borrowerlist {
754 my $borrowerslist = shift;
757 uc( $a->{surname} . $a->{firstname} ) cmp
758 uc( $b->{surname} . $b->{firstname} )