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/;
43 use C4::Utils::DataTables::Members;
45 use C4::Search; # enabled_staff_search_views
51 use Koha::CirculationRules;
58 my $dbh = C4::Context->dbh;
60 my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user(
62 template_name => "reserve/request.tt",
65 flagsrequired => { reserveforothers => 'place_holds' },
69 my $showallitems = $input->param('showallitems');
70 my $pickup = $input->param('pickup');
72 my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
74 # Select borrowers infos
75 my $findborrower = $input->param('findborrower');
76 $findborrower = '' unless defined $findborrower;
77 $findborrower =~ s|,| |g;
78 my $findclub = $input->param('findclub');
79 $findclub = '' unless defined $findclub && !$findborrower;
80 my $borrowernumber_hold = $input->param('borrowernumber') || '';
81 my $club_hold = $input->param('club')||'';
86 my $exceeded_maxreserves;
87 my $exceeded_holds_per_record;
89 my $date = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
90 my $action = $input->param('action');
93 if ( $action eq 'move' ) {
94 my $where = $input->param('where');
95 my $reserve_id = $input->param('reserve_id');
96 my $prev_priority = $input->param('prev_priority');
97 my $next_priority = $input->param('next_priority');
98 my $first_priority = $input->param('first_priority');
99 my $last_priority = $input->param('last_priority');
100 my $hold_itemnumber = $input->param('itemnumber');
101 if ( $prev_priority == 0 && $next_priority == 1 ){
102 C4::Reserves::RevertWaitingStatus({ itemnumber => $hold_itemnumber });
104 AlterPriority( $where, $reserve_id, $prev_priority, $next_priority, $first_priority, $last_priority );
106 } elsif ( $action eq 'cancel' ) {
107 my $reserve_id = $input->param('reserve_id');
108 my $cancellation_reason = $input->param("cancellation-reason");
109 my $hold = Koha::Holds->find( $reserve_id );
110 $hold->cancel({ cancellation_reason => $cancellation_reason }) if $hold;
111 } elsif ( $action eq 'setLowestPriority' ) {
112 my $reserve_id = $input->param('reserve_id');
113 ToggleLowestPriority( $reserve_id );
114 } elsif ( $action eq 'toggleSuspend' ) {
115 my $reserve_id = $input->param('reserve_id');
116 my $suspend_until = $input->param('suspend_until');
117 ToggleSuspend( $reserve_id, $suspend_until );
121 my $patron = Koha::Patrons->find( { cardnumber => $findborrower } );
123 $borrowernumber_hold = $patron->borrowernumber;
125 my $dt_params = { iDisplayLength => -1 };
126 my $results = C4::Utils::DataTables::Members::search(
128 searchmember => $findborrower,
129 dt_params => $dt_params,
132 my $borrowers = $results->{patrons};
133 if ( scalar @$borrowers == 1 ) {
134 $borrowernumber_hold = $borrowers->[0]->{borrowernumber};
135 } elsif ( @$borrowers ) {
136 $template->param( borrowers => $borrowers );
138 $messageborrower = "'$findborrower'";
144 my $club = Koha::Clubs->find( { name => $findclub } );
146 $club_hold = $club->id;
148 my @clubs = Koha::Clubs->search( [
149 { name => { like => '%'.$findclub.'%' } },
150 { description => { like => '%'.$findclub.'%' } }
152 if( scalar @clubs == 1 ) {
153 $club_hold = $clubs[0]->id;
155 $template->param( clubs => \@clubs );
157 $messageclub = "'$findclub'";
162 my @biblionumbers = ();
163 my $biblionumber = $input->param('biblionumber');
164 my $biblionumbers = $input->param('biblionumbers');
165 if ( $biblionumbers ) {
166 @biblionumbers = split '/', $biblionumbers;
168 push @biblionumbers, $input->multi_param('biblionumber');
171 my $multi_hold = @biblionumbers > 1;
173 multi_hold => $multi_hold,
176 # If we have the borrowernumber because we've performed an action, then we
177 # don't want to try to place another reserve.
178 if ($borrowernumber_hold && !$action) {
179 my $patron = Koha::Patrons->find( $borrowernumber_hold );
182 # we check the reserves of the user, and if they can reserve a document
183 # FIXME At this time we have a simple count of reservs, but, later, we could improve the infos "title" ...
185 my $reserves_count = $patron->holds->count;
187 my $new_reserves_count = scalar( @biblionumbers );
189 my $maxreserves = C4::Context->preference('maxreserves');
190 $template->param( maxreserves => $maxreserves );
193 && ( $reserves_count + $new_reserves_count > $maxreserves ) )
195 my $new_reserves_allowed =
196 $maxreserves - $reserves_count > 0
197 ? $maxreserves - $reserves_count
200 $exceeded_maxreserves = 1;
202 new_reserves_allowed => $new_reserves_allowed,
203 new_reserves_count => $new_reserves_count,
204 reserves_count => $reserves_count,
205 maxreserves => $maxreserves,
209 # we check the date expiry of the borrower (only if there is an expiry date, otherwise, set to 1 (warn)
210 my $expiry_date = $patron->dateexpiry;
211 my $expiry = 0; # flag set if patron account has expired
213 Date_to_Days(split /-/,$date) > Date_to_Days(split /-/,$expiry_date)) {
217 # check if the borrower make the reserv in a different branch
218 if ( $patron->branchcode ne C4::Context->userenv->{'branch'} ) {
222 my $amount_outstanding = $patron->account->balance;
226 diffbranch => $diffbranch,
227 messages => $messages,
228 warnings => $warnings,
229 amount_outstanding => $amount_outstanding,
233 if ($club_hold && !$borrowernumber_hold && !$action) {
234 my $club = Koha::Clubs->find($club_hold);
236 my $enrollments = $club->club_enrollments;
238 my $maxreserves = C4::Context->preference('maxreserves');
239 my $new_reserves_count = scalar( @biblionumbers );
243 while(my $enrollment = $enrollments->next) {
244 next if $enrollment->is_canceled;
245 my $member = { patron => $enrollment->patron->unblessed };
246 my $reserves_count = $enrollment->patron->holds->count;
248 && ( $reserves_count + $new_reserves_count > $maxreserves ) )
250 $member->{new_reserves_allowed} = $maxreserves - $reserves_count > 0
251 ? $maxreserves - $reserves_count
253 $member->{exceeded_maxreserves} = 1;
255 my $expiry_date = $enrollment->patron->dateexpiry;
256 $member->{expiry} = 0; # flag set if patron account has expired
258 Date_to_Days(split /-/,$date) > Date_to_Days(split /-/,$expiry_date)) {
259 $member->{expiry} = 1;
261 $member->{amount_outstanding} = $enrollment->patron->account->balance;
262 if ( $enrollment->patron->branchcode ne C4::Context->userenv->{'branch'} ) {
263 $member->{diffbranch} = 1;
266 push @members, $member;
271 members => \@members,
272 maxreserves => $maxreserves,
273 new_reserves_count => $new_reserves_count
277 unless ( $club_hold or $borrowernumber_hold ) {
278 $template->param( clubcount => Koha::Clubs->search->count );
282 messageborrower => $messageborrower,
283 messageclub => $messageclub
286 # FIXME launch another time GetMember perhaps until (Joubu: Why?)
287 my $patron = Koha::Patrons->find( $borrowernumber_hold );
289 if ( $patron && $multi_hold ) {
290 my @multi_pickup_locations =
291 Koha::Biblios->search( { biblionumber => \@biblionumbers } )
292 ->pickup_locations( { patron => $patron } );
293 $template->param( multi_pickup_locations => \@multi_pickup_locations );
296 my $logged_in_patron = Koha::Patrons->find( $borrowernumber );
300 $wants_check = $patron->wants_check_for_previous_checkout;
302 my $itemdata_enumchron = 0;
303 my $itemdata_ccode = 0;
305 my $no_reserves_allowed = 0;
306 foreach my $biblionumber (@biblionumbers) {
307 next unless $biblionumber =~ m|^\d+$|;
309 my %biblioloopiter = ();
311 my $biblio = Koha::Biblios->find( $biblionumber );
313 $biblioloopiter{noitems} = 1;
314 $template->param('nobiblio' => 1);
318 my $force_hold_level;
320 { # CanBookBeReserved
321 my $canReserve = CanBookBeReserved( $patron->borrowernumber, $biblionumber );
322 if ( $canReserve->{status} eq 'OK' ) {
324 #All is OK and we can continue
326 elsif ( $canReserve->{status} eq 'noReservesAllowed' || $canReserve->{status} eq 'notReservable' ) {
327 $no_reserves_allowed = 1;
329 elsif ( $canReserve->{status} eq 'tooManyReserves' ) {
330 $exceeded_maxreserves = 1;
331 $template->param( maxreserves => $canReserve->{limit} );
333 elsif ( $canReserve->{status} eq 'tooManyHoldsForThisRecord' ) {
334 $exceeded_holds_per_record = 1;
335 $biblioloopiter{ $canReserve->{status} } = 1;
337 elsif ( $canReserve->{status} eq 'ageRestricted' ) {
338 $template->param( $canReserve->{status} => 1 );
339 $biblioloopiter{ $canReserve->{status} } = 1;
341 elsif ( $canReserve->{status} eq 'alreadypossession' ) {
342 $template->param( $canReserve->{status} => 1);
343 $biblioloopiter{ $canReserve->{status} } = 1;
346 $biblioloopiter{ $canReserve->{status} } = 1;
350 # For multiple holds per record, if a patron has previously placed a hold,
351 # the patron can only place more holds of the same type. That is, if the
352 # patron placed a record level hold, all the holds the patron places must
353 # be record level. If the patron placed an item level hold, all holds
354 # the patron places must be item level
355 my $holds = Koha::Holds->search(
357 borrowernumber => $patron->borrowernumber,
358 biblionumber => $biblionumber,
362 $force_hold_level = $holds->forced_hold_level();
363 $biblioloopiter{force_hold_level} = $force_hold_level;
364 $template->param( force_hold_level => $force_hold_level );
366 # For a librarian to be able to place multiple record holds for a patron for a record,
367 # we must find out what the maximum number of holds they can place for the patron is
368 my $max_holds_for_record = GetMaxPatronHoldsForRecord( $patron->borrowernumber, $biblionumber );
369 my $remaining_holds_for_record = $max_holds_for_record - $holds->count();
370 $biblioloopiter{remaining_holds_for_record} = $max_holds_for_record;
371 $template->param( max_holds_for_record => $max_holds_for_record );
372 $template->param( remaining_holds_for_record => $remaining_holds_for_record );
376 my $count = Koha::Holds->search( { biblionumber => $biblionumber } )->count();
377 my $totalcount = $count;
379 # adding a fixed value for priority options
380 my $fixedRank = $count+1;
382 my %itemnumbers_of_biblioitem;
384 my @hostitems = get_hostitemnumbers_of($biblionumber);
387 $template->param('hostitemsflag' => 1);
388 push(@itemnumbers, @hostitems);
391 my $items = Koha::Items->search({ -or => { biblionumber => $biblionumber, itemnumber => { in => \@itemnumbers } } });
393 unless ( $items->count ) {
394 # FIXME Then why do we continue?
395 $template->param('noitems' => 1) unless ( $multi_hold );
396 $biblioloopiter{noitems} = 1;
399 ## Here we go backwards again to create hash of biblioitemnumber to itemnumbers
400 ## this is important when we have analytic items which may be on another record
401 my ( $iteminfos_of );
402 while ( my $item = $items->next ) {
403 $item = $item->unblessed;
404 my $biblioitemnumber = $item->{biblioitemnumber};
405 my $itemnumber = $item->{itemnumber};
406 push( @{ $itemnumbers_of_biblioitem{$biblioitemnumber} }, $itemnumber );
407 $iteminfos_of->{$itemnumber} = $item;
410 my @biblioitemnumbers = keys %itemnumbers_of_biblioitem;
412 my $biblioiteminfos_of = {
415 ( $biblioitem->{biblioitemnumber} => $biblioitem )
416 } @{ Koha::Biblioitems->search(
417 { biblioitemnumber => { -in => \@biblioitemnumbers } },
418 { select => ['biblionumber', 'biblioitemnumber', 'publicationyear', 'itemtype']}
425 my @available_itemtypes;
426 foreach my $biblioitemnumber (@biblioitemnumbers) {
427 my $biblioitem = $biblioiteminfos_of->{$biblioitemnumber};
428 my $num_available = 0;
429 my $num_override = 0;
431 my $num_alreadyheld = 0;
433 $biblioitem->{force_hold_level} = $force_hold_level;
435 if ( $biblioitem->{biblioitemnumber} ne $biblionumber ) {
436 $biblioitem->{hostitemsflag} = 1;
439 $biblioloopiter{description} = $biblioitem->{description};
440 $biblioloopiter{itypename} = $biblioitem->{description};
441 if ( $biblioitem->{itemtype} ) {
443 $biblioitem->{description} =
444 $itemtypes->{ $biblioitem->{itemtype} }{description};
446 $biblioloopiter{imageurl} =
447 getitemtypeimagelocation( 'intranet',
448 $itemtypes->{ $biblioitem->{itemtype} }{imageurl} );
451 # iterating through all items first to check if any of them available
452 # to pass this value further inside down to IsAvailableForItemLevelRequest to
453 # it's complicated logic to analyse.
454 # (before this loop was inside that sub loop so it was O(n^2) )
455 my $items_any_available;
456 $items_any_available = ItemsAnyAvailableAndNotRestricted( { biblionumber => $biblioitem->{biblionumber}, patron => $patron })
459 foreach my $itemnumber ( @{ $itemnumbers_of_biblioitem{$biblioitemnumber} } ) {
460 my $item = $iteminfos_of->{$itemnumber};
463 $do_check = $patron->do_check_for_previous_checkout($item) if $wants_check;
464 if ( $do_check && $wants_check ) {
465 $item->{checked_previously} = $do_check;
467 $biblioloopiter{checked_previously} = $do_check;
469 $template->param( checked_previously => $do_check );
473 $item->{force_hold_level} = $force_hold_level;
475 unless (C4::Context->preference('item-level_itypes')) {
476 $item->{itype} = $biblioitem->{itemtype};
479 $item->{itypename} = $itemtypes->{ $item->{itype} }{description};
480 $item->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtypes->{ $item->{itype} }{imageurl} );
481 $item->{homebranch} = $item->{homebranch};
483 # if the holdingbranch is different than the homebranch, we show the
484 # holdingbranch of the document too
485 if ( $item->{homebranch} ne $item->{holdingbranch} ) {
486 $item->{holdingbranch} = $item->{holdingbranch};
489 if($item->{biblionumber} ne $biblionumber){
490 $item->{hostitemsflag} = 1;
491 $item->{hosttitle} = Koha::Biblios->find( $item->{biblionumber} )->title;
494 # if the item is currently on loan, we display its return date and
495 # change the background color
496 my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } );
498 $item->{date_due} = $issue->date_due;
499 $item->{backgroundcolor} = 'onloan';
503 my $item_object = Koha::Items->find( $itemnumber );
504 my $holds = $item_object->current_holds;
505 if ( my $first_hold = $holds->next ) {
506 my $p = Koha::Patrons->find( $first_hold->borrowernumber );
508 $item->{backgroundcolor} = 'reserved';
509 $item->{reservedate} = output_pref({ dt => dt_from_string( $first_hold->reservedate ), dateonly => 1 }); # FIXME Should be formatted in the template
510 $item->{ReservedFor} = $p;
511 $item->{ExpectedAtLibrary} = $first_hold->branchcode;
512 $item->{waitingdate} = $first_hold->waitingdate;
515 # Management of the notforloan document
516 if ( $item->{notforloan} ) {
517 $item->{backgroundcolor} = 'other';
520 # Management of lost or long overdue items
521 if ( $item->{itemlost} ) {
522 $item->{backgroundcolor} = 'other';
523 if ($logged_in_patron->category->hidelostitems && !$showallitems) {
529 # Check the transit status
530 my ( $transfertwhen, $transfertfrom, $transfertto ) =
531 GetTransfers($itemnumber);
533 if ( defined $transfertwhen && $transfertwhen ne '' ) {
534 $item->{transfertwhen} = output_pref({ dt => dt_from_string( $transfertwhen ), dateonly => 1 });
535 $item->{transfertfrom} = $transfertfrom;
536 $item->{transfertto} = $transfertto;
537 $item->{nocancel} = 1;
540 # If there is no loan, return and transfer, we show a checkbox.
541 $item->{notforloan} ||= 0;
543 # if independent branches is on we need to check if the person can reserve
544 # for branches they arent logged in to
545 if ( C4::Context->preference("IndependentBranches") ) {
546 if (! C4::Context->preference("canreservefromotherbranches")){
547 # can't reserve items so need to check if item homebranch and userenv branch match if not we can't reserve
548 my $userenv = C4::Context->userenv;
549 unless ( C4::Context->IsSuperLibrarian ) {
550 $item->{cantreserve} = 1 if ( $item->{homebranch} ne $userenv->{branch} );
556 my $patron_unblessed = $patron->unblessed;
557 my $branch = C4::Circulation::_GetCircControlBranch($item, $patron_unblessed);
559 my $branchitemrule = GetBranchItemRule( $branch, $item->{'itype'} );
561 $item->{'holdallowed'} = $branchitemrule->{'holdallowed'};
563 my $can_item_be_reserved = CanItemBeReserved( $patron->borrowernumber, $itemnumber )->{status};
564 $item->{not_holdable} = $can_item_be_reserved unless ( $can_item_be_reserved eq 'OK' );
566 $item->{item_level_holds} = Koha::CirculationRules->get_opacitemholds_policy( { item => $item_object, patron => $patron } );
569 !$item->{cantreserve}
570 && !$exceeded_maxreserves
571 && $can_item_be_reserved eq 'OK'
572 # items_any_available defined outside of the current loop,
573 # so we avoiding loop inside IsAvailableForItemLevelRequest:
574 && IsAvailableForItemLevelRequest($item_object, $patron, undef, $items_any_available)
577 # Send the pickup locations count to the UI, the pickup locations will be pulled using the API
578 my $pickup_locations = $item_object->pickup_locations({ patron => $patron });
579 $item->{pickup_locations_count} = $pickup_locations->count;
580 if ( $item->{pickup_locations_count} > 0 ) {
582 $item->{available} = 1;
583 # pass the holding branch for use as default
584 my $default_pickup_location = $pickup_locations->search({ branchcode => $item->{holdingbranch} })->next;
585 $item->{default_pickup_location} = $default_pickup_location;
588 $item->{available} = 0;
589 $item->{not_holdable} = "no_valid_pickup_location";
592 push( @available_itemtypes, $item->{itype} );
594 elsif ( C4::Context->preference('AllowHoldPolicyOverride') ) {
595 # If AllowHoldPolicyOverride is set, it should override EVERY restriction, not just branch item rules
596 # with the exception of itemAlreadyOnHold because, you know, the item is already on hold
597 if ( $can_item_be_reserved ne 'itemAlreadyOnHold' ) {
598 # Send the pickup locations count to the UI, the pickup locations will be pulled using the API
599 my $pickup_locations = $item_object->pickup_locations({ patron => $patron });
600 $item->{pickup_locations_count} = $pickup_locations->count;
601 if ( $item->{pickup_locations_count} > 0 ) {
602 $item->{override} = 1;
604 # pass the holding branch for use as default
605 my $default_pickup_location = $pickup_locations->search({ branchcode => $item->{holdingbranch} })->next;
606 $item->{default_pickup_location} = $default_pickup_location;
609 $item->{available} = 0;
610 $item->{not_holdable} = "no_valid_pickup_location";
612 } else { $num_alreadyheld++ }
614 push( @available_itemtypes, $item->{itype} );
617 # If none of the conditions hold true, then neither override nor available is set and the item cannot be checked
619 # Show serial enumeration when needed
620 if ($item->{enumchron}) {
621 $itemdata_enumchron = 1;
623 # Show collection when needed
624 if ($item->{ccode}) {
629 push @{ $biblioitem->{itemloop} }, $item;
632 # While we can't override an alreay held item, we should be able to override the others
633 # Unless all items are already held
634 if ( $num_override > 0 && ($num_override + $num_alreadyheld) == scalar( @{ $biblioitem->{itemloop} } ) ) {
635 # That is, if all items require an override
636 $template->param( override_required => 1 );
637 } elsif ( $num_available == 0 ) {
638 $template->param( none_available => 1 );
639 $biblioloopiter{warn} = 1;
640 $biblioloopiter{none_avail} = 1;
642 $template->param( hiddencount => $hiddencount);
644 push @bibitemloop, $biblioitem;
647 @available_itemtypes = uniq( @available_itemtypes );
648 $template->param( available_itemtypes => \@available_itemtypes );
650 # existingreserves building
652 my @reserves = Koha::Holds->search( { biblionumber => $biblionumber }, { order_by => 'priority' } );
655 my $a_found = $a->found() || '';
656 my $b_found = $a->found() || '';
657 $a_found cmp $b_found;
662 if ( $res->is_found() ) {
663 $reserve{'holdingbranch'} = $res->item()->holdingbranch();
664 $reserve{'biblionumber'} = $res->item()->biblionumber();
665 $reserve{'barcodenumber'} = $res->item()->barcode();
666 $reserve{'wbrcode'} = $res->branchcode();
667 $reserve{'itemnumber'} = $res->itemnumber();
668 $reserve{'wbrname'} = $res->branch()->branchname();
669 $reserve{'atdestination'} = $res->is_at_destination();
670 $reserve{'desk_name'} = ( $res->desk() ) ? $res->desk()->desk_name() : '' ;
671 $reserve{'found'} = $res->is_found();
672 $reserve{'inprocessing'} = $res->is_in_processing();
673 $reserve{'intransit'} = $res->is_in_transit();
675 elsif ( $res->priority() > 0 ) {
676 if ( my $item = $res->item() ) {
677 $reserve{'itemnumber'} = $item->id();
678 $reserve{'barcodenumber'} = $item->barcode();
679 $reserve{'item_level_hold'} = 1;
683 $reserve{'expirationdate'} = $res->expirationdate;
684 $reserve{'date'} = $res->reservedate;
685 $reserve{'borrowernumber'} = $res->borrowernumber();
686 $reserve{'biblionumber'} = $res->biblionumber();
687 $reserve{'patron'} = $res->borrower;
688 $reserve{'notes'} = $res->reservenotes();
689 $reserve{'waiting_date'} = $res->waitingdate();
690 $reserve{'ccode'} = $res->item() ? $res->item()->ccode() : undef;
691 $reserve{'barcode'} = $res->item() ? $res->item()->barcode() : undef;
692 $reserve{'priority'} = $res->priority();
693 $reserve{'lowestPriority'} = $res->lowestPriority();
694 $reserve{'suspend'} = $res->suspend();
695 $reserve{'suspend_until'} = $res->suspend_until();
696 $reserve{'reserve_id'} = $res->reserve_id();
697 $reserve{itemtype} = $res->itemtype();
698 $reserve{branchcode} = $res->branchcode();
699 $reserve{non_priority} = $res->non_priority();
700 $reserve{object} = $res;
702 push( @reserveloop, \%reserve );
705 # get the time for the form name...
710 fixedRank => $fixedRank,
715 bibitemloop => \@bibitemloop,
716 itemdata_enumchron => $itemdata_enumchron,
717 itemdata_ccode => $itemdata_ccode,
719 biblionumber => $biblionumber,
720 findborrower => $findborrower,
723 C4::Search::enabled_staff_search_views,
726 $biblioloopiter{biblionumber} = $biblionumber;
727 $biblioloopiter{title} = $biblio->title;
728 $biblioloopiter{rank} = $fixedRank;
729 $biblioloopiter{reserveloop} = \@reserveloop;
732 $template->param( reserveloop => \@reserveloop );
736 # Add the valid pickup locations
737 my @pickup_locations = $biblio->pickup_locations({ patron => $patron });
738 $biblioloopiter{pickup_locations} = \@pickup_locations;
739 $biblioloopiter{pickup_locations_codes} = [ map { $_->branchcode } @pickup_locations ];
742 push @biblioloop, \%biblioloopiter;
745 $template->param( biblioloop => \@biblioloop );
746 $template->param( no_reserves_allowed => $no_reserves_allowed );
747 $template->param( biblionumbers => join('/', @biblionumbers) );
748 $template->param( exceeded_maxreserves => $exceeded_maxreserves );
749 $template->param( exceeded_holds_per_record => $exceeded_holds_per_record );
750 $template->param( subscriptionsnumber => CountSubscriptionFromBiblionumber($biblionumber));
752 # pass the userenv branch if no pickup location selected
753 $template->param( pickup => $pickup || C4::Context->userenv->{branch} );
755 if ( C4::Context->preference( 'AllowHoldDateInFuture' ) ) {
756 $template->param( reserve_in_future => 1 );
760 SuspendHoldsIntranet => C4::Context->preference('SuspendHoldsIntranet'),
761 AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds'),
765 output_html_with_http_headers $input, $cookie, $template->output;
767 sub sort_borrowerlist {
768 my $borrowerslist = shift;
771 uc( $a->{surname} . $a->{firstname} ) cmp
772 uc( $b->{surname} . $b->{firstname} )