Bug 23731: Give staff detail/OPAC detail option to display LOC classification
[koha.git] / reserve / request.pl
blobc7832434a3db2ac85e27b9948a1b8cca7fab3039
1 #!/usr/bin/perl
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>.
23 =head1 request.pl
25 script to place reserves/requests
27 =cut
29 use Modern::Perl;
31 use CGI qw ( -utf8 );
32 use List::MoreUtils qw/uniq/;
33 use Date::Calc qw/Date_to_Days/;
34 use C4::Output;
35 use C4::Auth;
36 use C4::Reserves;
37 use C4::Biblio;
38 use C4::Items;
39 use C4::Koha;
40 use C4::Serials;
41 use C4::Circulation;
42 use Koha::DateUtils;
43 use C4::Utils::DataTables::Members;
44 use C4::Members;
45 use C4::Search; # enabled_staff_search_views
47 use Koha::Biblios;
48 use Koha::DateUtils;
49 use Koha::Checkouts;
50 use Koha::Holds;
51 use Koha::IssuingRules;
52 use Koha::Items;
53 use Koha::ItemTypes;
54 use Koha::Libraries;
55 use Koha::Patrons;
56 use Koha::Clubs;
58 my $dbh = C4::Context->dbh;
59 my $input = new CGI;
60 my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user(
62 template_name => "reserve/request.tt",
63 query => $input,
64 type => "intranet",
65 authnotrequired => 0,
66 flagsrequired => { reserveforothers => 'place_holds' },
70 my $showallitems = $input->param('showallitems');
71 my $pickup = $input->param('pickup') || C4::Context->userenv->{'branch'};
73 my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
75 # Select borrowers infos
76 my $findborrower = $input->param('findborrower');
77 $findborrower = '' unless defined $findborrower;
78 $findborrower =~ s|,| |g;
79 my $findclub = $input->param('findclub');
80 $findclub = '' unless defined $findclub && !$findborrower;
81 my $borrowernumber_hold = $input->param('borrowernumber') || '';
82 my $club_hold = $input->param('club')||'';
83 my $messageborrower;
84 my $messageclub;
85 my $warnings;
86 my $messages;
87 my $exceeded_maxreserves;
88 my $exceeded_holds_per_record;
90 my $date = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
91 my $action = $input->param('action');
92 $action ||= q{};
94 if ( $action eq 'move' ) {
95 my $where = $input->param('where');
96 my $reserve_id = $input->param('reserve_id');
97 my $prev_priority = $input->param('prev_priority');
98 my $next_priority = $input->param('next_priority');
99 my $first_priority = $input->param('first_priority');
100 my $last_priority = $input->param('last_priority');
101 my $hold_itemnumber = $input->param('itemnumber');
102 if ( $prev_priority == 0 && $next_priority == 1 ){
103 C4::Reserves::RevertWaitingStatus({ itemnumber => $hold_itemnumber });
104 } else {
105 AlterPriority( $where, $reserve_id, $prev_priority, $next_priority, $first_priority, $last_priority );
107 } elsif ( $action eq 'cancel' ) {
108 my $reserve_id = $input->param('reserve_id');
109 my $hold = Koha::Holds->find( $reserve_id );
110 $hold->cancel 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 );
120 if ($findborrower) {
121 my $patron = Koha::Patrons->find( { cardnumber => $findborrower } );
122 if ( $patron ) {
123 $borrowernumber_hold = $patron->borrowernumber;
124 } else {
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 );
137 } else {
138 $messageborrower = "'$findborrower'";
143 if($findclub) {
144 my $club = Koha::Clubs->find( { name => $findclub } );
145 if( $club ) {
146 $club_hold = $club->id;
147 } else {
148 my @clubs = Koha::Clubs->search( [
149 { name => { like => '%'.$findclub.'%' } },
150 { description => { like => '%'.$findclub.'%' } }
151 ] );
152 if( scalar @clubs == 1 ) {
153 $club_hold = $clubs[0]->id;
154 } elsif ( @clubs ) {
155 $template->param( clubs => \@clubs );
156 } else {
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;
167 } else {
168 push @biblionumbers, $input->multi_param('biblionumber');
171 my $multihold = scalar $input->param('multi_hold');
172 # FIXME multi_hold should not be a variable but depends on the number of elements in @biblionumbers
173 $template->param(multi_hold => scalar $input->param('multi_hold'));
175 # If we have the borrowernumber because we've performed an action, then we
176 # don't want to try to place another reserve.
177 if ($borrowernumber_hold && !$action) {
178 my $patron = Koha::Patrons->find( $borrowernumber_hold );
179 my $diffbranch;
181 # we check the reserves of the user, and if they can reserve a document
182 # FIXME At this time we have a simple count of reservs, but, later, we could improve the infos "title" ...
184 my $reserves_count = $patron->holds->count;
186 my $new_reserves_count = scalar( @biblionumbers );
188 my $maxreserves = C4::Context->preference('maxreserves');
189 if ( $maxreserves
190 && ( $reserves_count + $new_reserves_count > $maxreserves ) )
192 my $new_reserves_allowed =
193 $maxreserves - $reserves_count > 0
194 ? $maxreserves - $reserves_count
195 : 0;
196 $warnings = 1;
197 $exceeded_maxreserves = 1;
198 $template->param(
199 new_reserves_allowed => $new_reserves_allowed,
200 new_reserves_count => $new_reserves_count,
201 reserves_count => $reserves_count,
202 maxreserves => $maxreserves,
206 # we check the date expiry of the borrower (only if there is an expiry date, otherwise, set to 1 (warn)
207 my $expiry_date = $patron->dateexpiry;
208 my $expiry = 0; # flag set if patron account has expired
209 if ($expiry_date and $expiry_date ne '0000-00-00' and
210 Date_to_Days(split /-/,$date) > Date_to_Days(split /-/,$expiry_date)) {
211 $expiry = 1;
214 # check if the borrower make the reserv in a different branch
215 if ( $patron->branchcode ne C4::Context->userenv->{'branch'} ) {
216 $diffbranch = 1;
219 my $amount_outstanding = $patron->account->balance;
220 $template->param(
221 patron => $patron,
222 expiry => $expiry,
223 diffbranch => $diffbranch,
224 messages => $messages,
225 warnings => $warnings,
226 amount_outstanding => $amount_outstanding,
230 if ($club_hold && !$borrowernumber_hold && !$action) {
231 my $club = Koha::Clubs->find($club_hold);
233 my $enrollments = $club->club_enrollments;
235 my $maxreserves = C4::Context->preference('maxreserves');
236 my $new_reserves_count = scalar( @biblionumbers );
238 my @members;
240 while(my $enrollment = $enrollments->next) {
241 next if $enrollment->is_canceled;
242 my $member = { patron => $enrollment->patron->unblessed };
243 my $reserves_count = $enrollment->patron->holds->count;
244 if ( $maxreserves
245 && ( $reserves_count + $new_reserves_count > $maxreserves ) )
247 $member->{new_reserves_allowed} = $maxreserves - $reserves_count > 0
248 ? $maxreserves - $reserves_count
249 : 0;
250 $member->{exceeded_maxreserves} = 1;
252 my $expiry_date = $enrollment->patron->dateexpiry;
253 $member->{expiry} = 0; # flag set if patron account has expired
254 if ($expiry_date and $expiry_date ne '0000-00-00' and
255 Date_to_Days(split /-/,$date) > Date_to_Days(split /-/,$expiry_date)) {
256 $member->{expiry} = 1;
258 $member->{amount_outstanding} = $enrollment->patron->account->balance;
259 if ( $enrollment->patron->branchcode ne C4::Context->userenv->{'branch'} ) {
260 $member->{diffbranch} = 1;
263 push @members, $member;
266 $template->param(
267 club => $club,
268 members => \@members,
269 maxreserves => $maxreserves,
270 new_reserves_count => $new_reserves_count
274 $template->param(
275 messageborrower => $messageborrower,
276 messageclub => $messageclub
279 # FIXME launch another time GetMember perhaps until (Joubu: Why?)
280 my $patron = Koha::Patrons->find( $borrowernumber_hold );
282 my $logged_in_patron = Koha::Patrons->find( $borrowernumber );
284 my $wants_check;
285 if ($patron) {
286 $wants_check = $patron->wants_check_for_previous_checkout;
288 my $itemdata_enumchron = 0;
289 my $itemdata_ccode = 0;
290 my @biblioloop = ();
291 foreach my $biblionumber (@biblionumbers) {
292 next unless $biblionumber =~ m|^\d+$|;
294 my %biblioloopiter = ();
296 my $biblio = Koha::Biblios->find( $biblionumber );
298 my $force_hold_level;
299 if ( $patron ) {
300 { # CanBookBeReserved
301 my $canReserve = CanBookBeReserved( $patron->borrowernumber, $biblionumber, $pickup );
302 if ( $canReserve->{status} eq 'OK' ) {
304 #All is OK and we can continue
306 elsif ( $canReserve->{status} eq 'tooManyReserves' ) {
307 $exceeded_maxreserves = 1;
308 $template->param( maxreserves => $canReserve->{limit} );
310 elsif ( $canReserve->{status} eq 'tooManyHoldsForThisRecord' ) {
311 $exceeded_holds_per_record = 1;
312 $biblioloopiter{ $canReserve->{status} } = 1;
314 elsif ( $canReserve->{status} eq 'ageRestricted' ) {
315 $template->param( $canReserve->{status} => 1 );
316 $biblioloopiter{ $canReserve->{status} } = 1;
318 else {
319 $biblioloopiter{ $canReserve->{status} } = 1;
323 # For multiple holds per record, if a patron has previously placed a hold,
324 # the patron can only place more holds of the same type. That is, if the
325 # patron placed a record level hold, all the holds the patron places must
326 # be record level. If the patron placed an item level hold, all holds
327 # the patron places must be item level
328 my $holds = Koha::Holds->search(
330 borrowernumber => $patron->borrowernumber,
331 biblionumber => $biblionumber,
332 found => undef,
335 $force_hold_level = $holds->forced_hold_level();
336 $biblioloopiter{force_hold_level} = $force_hold_level;
337 $template->param( force_hold_level => $force_hold_level );
339 # For a librarian to be able to place multiple record holds for a patron for a record,
340 # we must find out what the maximum number of holds they can place for the patron is
341 my $max_holds_for_record = GetMaxPatronHoldsForRecord( $patron->borrowernumber, $biblionumber );
342 my $remaining_holds_for_record = $max_holds_for_record - $holds->count();
343 $biblioloopiter{remaining_holds_for_record} = $max_holds_for_record;
344 $template->param( max_holds_for_record => $max_holds_for_record );
345 $template->param( remaining_holds_for_record => $remaining_holds_for_record );
347 { # alreadypossession
348 # Check to see if patron is allowed to place holds on records where the
349 # patron already has an item from that record checked out
350 if ( !C4::Context->preference('AllowHoldsOnPatronsPossessions')
351 && CheckIfIssuedToPatron( $patron->borrowernumber, $biblionumber ) )
353 $template->param( alreadypossession => 1, );
359 my $count = Koha::Holds->search( { biblionumber => $biblionumber } )->count();
360 my $totalcount = $count;
362 # FIXME think @optionloop, is maybe obsolete, or must be switchable by a systeme preference fixed rank or not
363 # make priorities options
365 my @optionloop;
366 for ( 1 .. $count + 1 ) {
367 push(
368 @optionloop,
370 num => $_,
371 selected => ( $_ == $count + 1 ),
375 # adding a fixed value for priority options
376 my $fixedRank = $count+1;
378 my %itemnumbers_of_biblioitem;
380 my @hostitems = get_hostitemnumbers_of($biblionumber);
381 my @itemnumbers;
382 if (@hostitems){
383 $template->param('hostitemsflag' => 1);
384 push(@itemnumbers, @hostitems);
387 my $items = Koha::Items->search({ -or => { biblionumber => $biblionumber, itemnumber => { in => \@itemnumbers } } });
389 unless ( $items->count ) {
390 # FIXME Then why do we continue?
391 $template->param('noitems' => 1);
392 $biblioloopiter{noitems} = 1;
395 ## Here we go backwards again to create hash of biblioitemnumber to itemnumbers,
396 ## when by definition all of the itemnumber have the same biblioitemnumber
397 my ( $iteminfos_of );
398 while ( my $item = $items->next ) {
399 $item = $item->unblessed;
400 my $biblioitemnumber = $item->{biblioitemnumber};
401 my $itemnumber = $item->{itemnumber};
402 push( @{ $itemnumbers_of_biblioitem{$biblioitemnumber} }, $itemnumber );
403 $iteminfos_of->{$itemnumber} = $item;
406 ## Should be same as biblionumber
407 my @biblioitemnumbers = keys %itemnumbers_of_biblioitem;
409 my $biblioiteminfos_of = {
410 map {
411 my $biblioitem = $_;
412 ( $biblioitem->{biblioitemnumber} => $biblioitem )
413 } @{ Koha::Biblioitems->search(
414 { biblioitemnumber => { -in => \@biblioitemnumbers } },
415 { select => ['biblioitemnumber', 'publicationyear', 'itemtype']}
416 )->unblessed
420 my @bibitemloop;
422 my @available_itemtypes;
423 foreach my $biblioitemnumber (@biblioitemnumbers) {
424 my $biblioitem = $biblioiteminfos_of->{$biblioitemnumber};
425 my $num_available = 0;
426 my $num_override = 0;
427 my $hiddencount = 0;
429 $biblioitem->{force_hold_level} = $force_hold_level;
431 if ( $biblioitem->{biblioitemnumber} ne $biblionumber ) {
432 $biblioitem->{hostitemsflag} = 1;
435 $biblioloopiter{description} = $biblioitem->{description};
436 $biblioloopiter{itypename} = $biblioitem->{description};
437 if ( $biblioitem->{itemtype} ) {
439 $biblioitem->{description} =
440 $itemtypes->{ $biblioitem->{itemtype} }{description};
442 $biblioloopiter{imageurl} =
443 getitemtypeimagelocation( 'intranet',
444 $itemtypes->{ $biblioitem->{itemtype} }{imageurl} );
447 foreach my $itemnumber ( @{ $itemnumbers_of_biblioitem{$biblioitemnumber} } ) {
448 my $item = $iteminfos_of->{$itemnumber};
449 my $do_check;
450 if ( $patron ) {
451 $do_check = $patron->do_check_for_previous_checkout($item) if $wants_check;
452 if ( $do_check && $wants_check ) {
453 $item->{checked_previously} = $do_check;
454 if ( $multihold ) {
455 $biblioloopiter{checked_previously} = $do_check;
456 } else {
457 $template->param( checked_previously => $do_check );
461 $item->{force_hold_level} = $force_hold_level;
463 unless (C4::Context->preference('item-level_itypes')) {
464 $item->{itype} = $biblioitem->{itemtype};
467 $item->{itypename} = $itemtypes->{ $item->{itype} }{description};
468 $item->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtypes->{ $item->{itype} }{imageurl} );
469 $item->{homebranch} = $item->{homebranch};
471 # if the holdingbranch is different than the homebranch, we show the
472 # holdingbranch of the document too
473 if ( $item->{homebranch} ne $item->{holdingbranch} ) {
474 $item->{holdingbranch} = $item->{holdingbranch};
477 if($item->{biblionumber} ne $biblionumber){
478 $item->{hostitemsflag} = 1;
479 $item->{hosttitle} = Koha::Biblios->find( $item->{biblionumber} )->title;
482 # if the item is currently on loan, we display its return date and
483 # change the background color
484 my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } );
485 if ( $issue ) {
486 $item->{date_due} = $issue->date_due;
487 $item->{backgroundcolor} = 'onloan';
490 # checking reserve
491 my $item_object = Koha::Items->find( $itemnumber );
492 my $holds = $item_object->current_holds;
493 if ( my $first_hold = $holds->next ) {
494 my $p = Koha::Patrons->find( $first_hold->borrowernumber );
496 $item->{backgroundcolor} = 'reserved';
497 $item->{reservedate} = output_pref({ dt => dt_from_string( $first_hold->reservedate ), dateonly => 1 }); # FIXME Should be formatted in the template
498 $item->{ReservedFor} = $p;
499 $item->{ExpectedAtLibrary} = $first_hold->branchcode;
500 $item->{waitingdate} = $first_hold->waitingdate;
503 # Management of the notforloan document
504 if ( $item->{notforloan} ) {
505 $item->{backgroundcolor} = 'other';
508 # Management of lost or long overdue items
509 if ( $item->{itemlost} ) {
510 $item->{backgroundcolor} = 'other';
511 if ($logged_in_patron->category->hidelostitems && !$showallitems) {
512 $item->{hide} = 1;
513 $hiddencount++;
517 # Check the transit status
518 my ( $transfertwhen, $transfertfrom, $transfertto ) =
519 GetTransfers($itemnumber);
521 if ( defined $transfertwhen && $transfertwhen ne '' ) {
522 $item->{transfertwhen} = output_pref({ dt => dt_from_string( $transfertwhen ), dateonly => 1 });
523 $item->{transfertfrom} = $transfertfrom;
524 $item->{transfertto} = $transfertto;
525 $item->{nocancel} = 1;
528 # If there is no loan, return and transfer, we show a checkbox.
529 $item->{notforloan} ||= 0;
531 # if independent branches is on we need to check if the person can reserve
532 # for branches they arent logged in to
533 if ( C4::Context->preference("IndependentBranches") ) {
534 if (! C4::Context->preference("canreservefromotherbranches")){
535 # can't reserve items so need to check if item homebranch and userenv branch match if not we can't reserve
536 my $userenv = C4::Context->userenv;
537 unless ( C4::Context->IsSuperLibrarian ) {
538 $item->{cantreserve} = 1 if ( $item->{homebranch} ne $userenv->{branch} );
543 if ( $patron ) {
544 my $patron_unblessed = $patron->unblessed;
545 my $branch = C4::Circulation::_GetCircControlBranch($item, $patron_unblessed);
547 my $branchitemrule = GetBranchItemRule( $branch, $item->{'itype'} );
549 $item->{'holdallowed'} = $branchitemrule->{'holdallowed'};
551 my $can_item_be_reserved = CanItemBeReserved( $patron->borrowernumber, $itemnumber, $pickup );
552 $item->{not_holdable} = $can_item_be_reserved->{status} unless ( $can_item_be_reserved->{status} eq 'OK' );
554 $item->{item_level_holds} = Koha::IssuingRules->get_opacitemholds_policy( { item => $item_object, patron => $patron } );
556 if (
557 !$item->{cantreserve}
558 && !$exceeded_maxreserves
559 && IsAvailableForItemLevelRequest($item_object, $patron)
560 && $can_item_be_reserved->{status} eq 'OK'
563 $item->{available} = 1;
564 $num_available++;
566 push( @available_itemtypes, $item->{itype} );
568 elsif ( C4::Context->preference('AllowHoldPolicyOverride') ) {
569 # If AllowHoldPolicyOverride is set, it should override EVERY restriction, not just branch item rules
570 # with the exception of itemAlreadyOnHold because, you know, the item is already on hold
571 if ( $can_item_be_reserved ne 'itemAlreadyOnHold' ) {
572 $item->{override} = 1;
573 $num_override++;
576 push( @available_itemtypes, $item->{itype} );
579 # If none of the conditions hold true, then neither override nor available is set and the item cannot be checked
581 # Show serial enumeration when needed
582 if ($item->{enumchron}) {
583 $itemdata_enumchron = 1;
585 # Show collection when needed
586 if ($item->{ccode}) {
587 $itemdata_ccode = 1;
591 push @{ $biblioitem->{itemloop} }, $item;
594 if ( $num_override == scalar( @{ $biblioitem->{itemloop} } ) ) { # That is, if all items require an override
595 $template->param( override_required => 1 );
596 } elsif ( $num_available == 0 ) {
597 $template->param( none_available => 1 );
598 $biblioloopiter{warn} = 1;
599 $biblioloopiter{none_avail} = 1;
601 $template->param( hiddencount => $hiddencount);
603 push @bibitemloop, $biblioitem;
606 @available_itemtypes = uniq( @available_itemtypes );
607 $template->param( available_itemtypes => \@available_itemtypes );
609 # existingreserves building
610 my @reserveloop;
611 my @reserves = Koha::Holds->search( { biblionumber => $biblionumber }, { order_by => 'priority' } );
612 foreach my $res (
613 sort {
614 my $a_found = $a->found() || '';
615 my $b_found = $a->found() || '';
616 $a_found cmp $b_found;
617 } @reserves
620 my $priority = $res->priority();
621 my %reserve;
622 my @optionloop;
623 for ( my $i = 1 ; $i <= $totalcount ; $i++ ) {
624 push(
625 @optionloop,
627 num => $i,
628 selected => ( $i == $priority ),
633 if ( $res->is_found() ) {
634 $reserve{'holdingbranch'} = $res->item()->holdingbranch();
635 $reserve{'biblionumber'} = $res->item()->biblionumber();
636 $reserve{'barcodenumber'} = $res->item()->barcode();
637 $reserve{'wbrcode'} = $res->branchcode();
638 $reserve{'itemnumber'} = $res->itemnumber();
639 $reserve{'wbrname'} = $res->branch()->branchname();
641 if ( $reserve{'holdingbranch'} eq $reserve{'wbrcode'} ) {
643 # Just because the holdingbranch matches the reserve branch doesn't mean the item
644 # has arrived at the destination, check for an open transfer for the item as well
645 my ( $transfertwhen, $transfertfrom, $transferto ) =
646 C4::Circulation::GetTransfers( $res->itemnumber() );
647 if ( not $transferto or $transferto ne $res->branchcode() ) {
648 $reserve{'atdestination'} = 1;
652 # set found to 1 if reserve is waiting for patron pickup
653 $reserve{'found'} = $res->is_found();
654 $reserve{'intransit'} = $res->is_in_transit();
656 elsif ( $res->priority() > 0 ) {
657 if ( my $item = $res->item() ) {
658 $reserve{'itemnumber'} = $item->id();
659 $reserve{'barcodenumber'} = $item->barcode();
660 $reserve{'item_level_hold'} = 1;
664 $reserve{'expirationdate'} = output_pref( { dt => dt_from_string( $res->expirationdate ), dateonly => 1 } )
665 unless ( !defined( $res->expirationdate ) || $res->expirationdate eq '0000-00-00' );
666 $reserve{'date'} = output_pref( { dt => dt_from_string( $res->reservedate ), dateonly => 1 } );
667 $reserve{'borrowernumber'} = $res->borrowernumber();
668 $reserve{'biblionumber'} = $res->biblionumber();
669 $reserve{'patron'} = $res->borrower;
670 $reserve{'notes'} = $res->reservenotes();
671 $reserve{'waiting_date'} = $res->waitingdate();
672 $reserve{'ccode'} = $res->item() ? $res->item()->ccode() : undef;
673 $reserve{'barcode'} = $res->item() ? $res->item()->barcode() : undef;
674 $reserve{'priority'} = $res->priority();
675 $reserve{'lowestPriority'} = $res->lowestPriority();
676 $reserve{'optionloop'} = \@optionloop;
677 $reserve{'suspend'} = $res->suspend();
678 $reserve{'suspend_until'} = $res->suspend_until();
679 $reserve{'reserve_id'} = $res->reserve_id();
680 $reserve{itemtype} = $res->itemtype();
681 $reserve{branchcode} = $res->branchcode();
682 $reserve{object} = $res;
684 push( @reserveloop, \%reserve );
687 # get the time for the form name...
688 my $time = time();
690 $template->param(
691 time => $time,
692 fixedRank => $fixedRank,
695 # display infos
696 $template->param(
697 optionloop => \@optionloop,
698 bibitemloop => \@bibitemloop,
699 itemdata_enumchron => $itemdata_enumchron,
700 itemdata_ccode => $itemdata_ccode,
701 date => $date,
702 biblionumber => $biblionumber,
703 findborrower => $findborrower,
704 biblio => $biblio,
705 holdsview => 1,
706 C4::Search::enabled_staff_search_views,
709 $biblioloopiter{biblionumber} = $biblionumber;
710 $biblioloopiter{title} = $biblio->title;
711 $biblioloopiter{rank} = $fixedRank;
712 $biblioloopiter{reserveloop} = \@reserveloop;
714 if (@reserveloop) {
715 $template->param( reserveloop => \@reserveloop );
718 push @biblioloop, \%biblioloopiter;
721 $template->param( biblioloop => \@biblioloop );
722 $template->param( biblionumbers => $biblionumbers );
723 $template->param( exceeded_maxreserves => $exceeded_maxreserves );
724 $template->param( exceeded_holds_per_record => $exceeded_holds_per_record );
725 $template->param( subscriptionsnumber => CountSubscriptionFromBiblionumber($biblionumber));
726 $template->param( pickup => $pickup );
728 if ( C4::Context->preference( 'AllowHoldDateInFuture' ) ) {
729 $template->param( reserve_in_future => 1 );
732 $template->param(
733 SuspendHoldsIntranet => C4::Context->preference('SuspendHoldsIntranet'),
734 AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds'),
737 # printout the page
738 output_html_with_http_headers $input, $cookie, $template->output;
740 sub sort_borrowerlist {
741 my $borrowerslist = shift;
742 my $ref = [];
743 push @{$ref}, sort {
744 uc( $a->{surname} . $a->{firstname} ) cmp
745 uc( $b->{surname} . $b->{firstname} )
746 } @{$borrowerslist};
747 return $ref;