Bug 17168: (RM follow-up) Update for bug 14570
[koha.git] / opac / opac-reserve.pl
blob56c5bc26951614a4ca150a10f8a5a9d3093dd1ba
1 #!/usr/bin/perl
3 # Copyright Katipo Communications 2002
4 # Copyright Koha Development team 2012
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
13 # Koha is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with Koha; if not, see <http://www.gnu.org/licenses>.
21 use Modern::Perl;
23 use CGI qw ( -utf8 );
24 use C4::Auth; # checkauth, getborrowernumber.
25 use C4::Koha;
26 use C4::Circulation;
27 use C4::Reserves;
28 use C4::Biblio;
29 use C4::Items;
30 use C4::Output;
31 use C4::Context;
32 use C4::Members;
33 use C4::Overdues;
34 use C4::Debug;
36 use Koha::AuthorisedValues;
37 use Koha::Biblios;
38 use Koha::DateUtils;
39 use Koha::IssuingRules;
40 use Koha::Items;
41 use Koha::ItemTypes;
42 use Koha::Checkouts;
43 use Koha::Libraries;
44 use Koha::Patrons;
45 use Date::Calc qw/Today Date_to_Days/;
46 use List::MoreUtils qw/uniq/;
48 my $maxreserves = C4::Context->preference("maxreserves");
50 my $query = new CGI;
52 # if RequestOnOpac (for placing holds) is disabled, leave immediately
53 if ( ! C4::Context->preference('RequestOnOpac') ) {
54 print $query->redirect("/cgi-bin/koha/errors/404.pl");
55 exit;
58 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
60 template_name => "opac-reserve.tt",
61 query => $query,
62 type => "opac",
63 authnotrequired => 0,
64 debug => 1,
68 my ($show_holds_count, $show_priority);
69 for ( C4::Context->preference("OPACShowHoldQueueDetails") ) {
70 m/holds/o and $show_holds_count = 1;
71 m/priority/ and $show_priority = 1;
74 my $patron = Koha::Patrons->find( $borrowernumber );
76 my $can_place_hold_if_available_at_pickup = C4::Context->preference('OPACHoldsIfAvailableAtPickup');
77 unless ( $can_place_hold_if_available_at_pickup ) {
78 my @patron_categories = split '\|', C4::Context->preference('OPACHoldsIfAvailableAtPickupExceptions');
79 if ( @patron_categories ) {
80 my $categorycode = $patron->categorycode;
81 $can_place_hold_if_available_at_pickup = grep /^$categorycode$/, @patron_categories;
85 # check if this user can place a reserve, -1 means use sys pref, 0 means dont block, 1 means block
86 if ( $patron->category->effective_BlockExpiredPatronOpacActions ) {
88 if ( $patron->is_expired ) {
90 # cannot reserve, their card has expired and the rules set mean this is not allowed
91 $template->param( message => 1, expired_patron => 1 );
92 output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
96 # Pass through any reserve charge
97 my $reservefee = $patron->category->reservefee;
98 if ( $reservefee > 0){
99 $template->param( RESERVE_CHARGE => $reservefee);
102 my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
104 # There are two ways of calling this script, with a single biblio num
105 # or multiple biblio nums.
106 my $biblionumbers = $query->param('biblionumbers');
107 my $reserveMode = $query->param('reserve_mode');
108 if ($reserveMode && ($reserveMode eq 'single')) {
109 my $bib = $query->param('single_bib');
110 $biblionumbers = "$bib/";
112 if (! $biblionumbers) {
113 $biblionumbers = $query->param('biblionumber');
116 if ((! $biblionumbers) && (! $query->param('place_reserve'))) {
117 $template->param(message=>1, no_biblionumber=>1);
118 output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
121 # Pass the numbers to the page so they can be fed back
122 # when the hold is confirmed. TODO: Not necessary?
123 $template->param( biblionumbers => $biblionumbers );
125 # Each biblio number is suffixed with '/', e.g. "1/2/3/"
126 my @biblionumbers = split /\//, $biblionumbers;
127 if (($#biblionumbers < 0) && (! $query->param('place_reserve'))) {
128 # TODO: New message?
129 $template->param(message=>1, no_biblionumber=>1);
130 output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
134 # pass the pickup branch along....
135 my $branch = $query->param('branch') || $patron->branchcode || C4::Context->userenv->{branch} || '' ;
136 $template->param( branch => $branch );
140 # Build hashes of the requested biblio(item)s and items.
144 my %biblioDataHash; # Hash of biblionumber to biblio/biblioitems record.
145 my %itemInfoHash; # Hash of itemnumber to item info.
146 foreach my $biblioNumber (@biblionumbers) {
148 my $biblioData = GetBiblioData($biblioNumber);
149 $biblioDataHash{$biblioNumber} = $biblioData;
151 my @itemInfos = GetItemsInfo($biblioNumber);
153 my $marcrecord= GetMarcBiblio({ biblionumber => $biblioNumber });
155 # flag indicating existence of at least one item linked via a host record
156 my $hostitemsflag;
157 # adding items linked via host biblios
158 my @hostitemInfos = GetHostItemsInfo($marcrecord);
159 if (@hostitemInfos){
160 $hostitemsflag =1;
161 push (@itemInfos,@hostitemInfos);
164 $biblioData->{itemInfos} = \@itemInfos;
165 foreach my $itemInfo (@itemInfos) {
166 $itemInfoHash{$itemInfo->{itemnumber}} = $itemInfo;
169 # Compute the priority rank.
170 my $biblio = Koha::Biblios->find( $biblioNumber );
171 $biblioData->{object} = $biblio;
172 my $holds = $biblio->holds;
173 my $rank = $holds->count;
174 $biblioData->{reservecount} = 1; # new reserve
175 while ( my $hold = $holds->next ) {
176 if ( $hold->is_waiting ) {
177 $rank--;
179 else {
180 $biblioData->{reservecount}++;
183 $biblioData->{rank} = $rank + 1;
188 # If this is the second time through this script, it
189 # means we are carrying out the hold request, possibly
190 # with a specific item for each biblionumber.
193 if ( $query->param('place_reserve') ) {
194 my $reserve_cnt = 0;
195 if ($maxreserves) {
196 $reserve_cnt = $patron->holds->count;
199 # List is composed of alternating biblio/item/branch
200 my $selectedItems = $query->param('selecteditems');
202 if ($query->param('reserve_mode') eq 'single') {
203 # This indicates non-JavaScript mode, so there was
204 # only a single biblio number selected.
205 my $bib = $query->param('single_bib');
206 my $item = $query->param("checkitem_$bib");
207 if ($item eq 'any') {
208 $item = '';
210 my $branch = $query->param('branch');
211 $selectedItems = "$bib/$item/$branch/";
214 $selectedItems =~ s!/$!!;
215 my @selectedItems = split /\//, $selectedItems, -1;
217 # Make sure there is a biblionum/itemnum/branch triplet for each item.
218 # The itemnum can be 'any', meaning next available.
219 my $selectionCount = @selectedItems;
220 if (($selectionCount == 0) || (($selectionCount % 3) != 0)) {
221 $template->param(message=>1, bad_data=>1);
222 output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
225 my $failed_holds = 0;
226 while (@selectedItems) {
227 my $biblioNum = shift(@selectedItems);
228 my $itemNum = shift(@selectedItems);
229 my $branch = shift(@selectedItems); # i.e., branch code, not name
231 my $canreserve = 0;
233 my $singleBranchMode = Koha::Libraries->search->count == 1;
234 if ( $singleBranchMode || ! C4::Context->preference("OPACAllowUserToChooseBranch") )
235 { # single branch mode or disabled user choosing
236 $branch = $patron->branchcode;
239 # When choosing a specific item, the default pickup library should be dictated by the default hold policy
240 if ( ! C4::Context->preference("OPACAllowUserToChooseBranch") && $itemNum ) {
241 my $item = Koha::Items->find( $itemNum );
242 my $type = $item->effective_itemtype;
243 my $rule = GetBranchItemRule( $patron->branchcode, $type );
245 if ( $rule->{hold_fulfillment_policy} eq 'any' ) {
246 $branch = $patron->branchcode;
247 } else {
248 my $policy = $rule->{hold_fulfillment_policy};
249 $branch = $item->$policy;
253 #item may belong to a host biblio, if yes change biblioNum to hosts bilbionumber
254 if ( $itemNum ne '' ) {
255 my $item = Koha::Items->find( $itemNum );
256 my $hostbiblioNum = $item->biblio->biblionumber;
257 if ( $hostbiblioNum ne $biblioNum ) {
258 $biblioNum = $hostbiblioNum;
262 my $biblioData = $biblioDataHash{$biblioNum};
263 my $found;
265 # Check for user supplied reserve date
266 my $startdate;
267 if ( C4::Context->preference('AllowHoldDateInFuture')
268 && C4::Context->preference('OPACAllowHoldDateInFuture') )
270 $startdate = $query->param("reserve_date_$biblioNum");
273 my $expiration_date = $query->param("expiration_date_$biblioNum");
275 my $rank = $biblioData->{rank};
276 if ( $itemNum ne '' ) {
277 $canreserve = 1 if CanItemBeReserved( $borrowernumber, $itemNum )->{status} eq 'OK';
279 else {
280 $canreserve = 1 if CanBookBeReserved( $borrowernumber, $biblioNum )->{status} eq 'OK';
282 # Inserts a null into the 'itemnumber' field of 'reserves' table.
283 $itemNum = undef;
285 my $notes = $query->param('notes_'.$biblioNum)||'';
287 if ( $maxreserves
288 && $reserve_cnt >= $maxreserves )
290 $canreserve = 0;
293 unless ( $can_place_hold_if_available_at_pickup ) {
294 my $items_in_this_library = Koha::Items->search({ biblionumber => $biblioNum, holdingbranch => $branch });
295 my $nb_of_items_issued = $items_in_this_library->search({ 'issue.itemnumber' => { not => undef }}, { join => 'issue' })->count;
296 my $nb_of_items_unavailable = $items_in_this_library->search({ -or => { lost => { '!=' => 0 }, damaged => { '!=' => 0 }, } });
297 if ( $items_in_this_library->count > $nb_of_items_issued + $nb_of_items_unavailable ) {
298 $canreserve = 0
302 my $itemtype = $query->param('itemtype') || undef;
303 $itemtype = undef if $itemNum;
305 # Here we actually do the reserveration. Stage 3.
306 if ($canreserve) {
307 my $reserve_id = AddReserve(
308 $branch, $borrowernumber, $biblioNum,
309 [$biblioNum], $rank, $startdate,
310 $expiration_date, $notes, $biblioData->{title},
311 $itemNum, $found, $itemtype,
313 $failed_holds++ unless $reserve_id;
314 ++$reserve_cnt;
318 print $query->redirect("/cgi-bin/koha/opac-user.pl?" . ( $failed_holds ? "failed_holds=$failed_holds" : q|| ) . "#opac-user-holds");
319 exit;
324 # Here we check that the borrower can actually make reserves Stage 1.
327 my $noreserves = 0;
328 my $maxoutstanding = C4::Context->preference("maxoutstanding");
329 $template->param( noreserve => 1 ) unless $maxoutstanding;
330 my $amountoutstanding = $patron->account->balance;
331 if ( $amountoutstanding && ($amountoutstanding > $maxoutstanding) ) {
332 my $amount = sprintf "%.02f", $amountoutstanding;
333 $template->param( message => 1 );
334 $noreserves = 1;
335 $template->param( too_much_oweing => $amount );
338 if ( $patron->gonenoaddress && ($patron->gonenoaddress == 1) ) {
339 $noreserves = 1;
340 $template->param(
341 message => 1,
342 GNA => 1
346 if ( $patron->lost && ($patron->lost == 1) ) {
347 $noreserves = 1;
348 $template->param(
349 message => 1,
350 lost => 1
354 if ( $patron->is_debarred ) {
355 $noreserves = 1;
356 $template->param(
357 message => 1,
358 debarred => 1,
359 debarred_comment => $patron->debarredcomment,
360 debarred_date => $patron->debarred,
364 my $holds = $patron->holds;
365 my $reserves_count = $holds->count;
366 $template->param( RESERVES => $holds->unblessed );
367 if ( $maxreserves && ( $reserves_count >= $maxreserves ) ) {
368 $template->param( message => 1 );
369 $noreserves = 1;
370 $template->param( too_many_reserves => $holds->count );
373 unless ( $noreserves ) {
374 my $requested_reserves_count = scalar( @biblionumbers );
375 if ( $maxreserves && ( $reserves_count + $requested_reserves_count > $maxreserves ) ) {
376 $template->param( new_reserves_allowed => $maxreserves - $reserves_count );
380 unless ($noreserves) {
381 $template->param( select_item_types => 1 );
387 # Build the template parameters that will show the info
388 # and items for each biblionumber.
392 my $biblioLoop = [];
393 my $numBibsAvailable = 0;
394 my $itemdata_enumchron = 0;
395 my $itemdata_ccode = 0;
396 my $anyholdable = 0;
397 my $itemLevelTypes = C4::Context->preference('item-level_itypes');
398 my $pickup_locations = Koha::Libraries->search({ pickup_location => 1 });
399 $template->param('item_level_itypes' => $itemLevelTypes);
401 foreach my $biblioNum (@biblionumbers) {
403 # Init the bib item with the choices for branch pickup
404 my %biblioLoopIter;
406 # Get relevant biblio data.
407 my $biblioData = $biblioDataHash{$biblioNum};
408 if (! $biblioData) {
409 $template->param(message=>1, bad_biblionumber=>$biblioNum);
410 output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
413 my @not_available_at = ();
414 my $biblio = $biblioData->{object};
415 foreach my $library ( $pickup_locations->as_list ) {
416 push( @not_available_at, $library->branchcode ) unless $biblio->can_be_transferred({ to => $library });
419 my $frameworkcode = GetFrameworkCode( $biblioData->{biblionumber} );
420 $biblioLoopIter{biblionumber} = $biblioData->{biblionumber};
421 $biblioLoopIter{title} = $biblioData->{title};
422 $biblioLoopIter{subtitle} = $biblioData->{'subtitle'};
423 $biblioLoopIter{medium} = $biblioData->{medium};
424 $biblioLoopIter{part_number} = $biblioData->{part_number};
425 $biblioLoopIter{part_name} = $biblioData->{part_name};
426 $biblioLoopIter{author} = $biblioData->{author};
427 $biblioLoopIter{rank} = $biblioData->{rank};
428 $biblioLoopIter{reservecount} = $biblioData->{reservecount};
429 $biblioLoopIter{already_reserved} = $biblioData->{already_reserved};
430 $biblioLoopIter{reqholdnotes}=0; #TODO: For future use
432 if (!$itemLevelTypes && $biblioData->{itemtype}) {
433 $biblioLoopIter{translated_description} = $itemtypes->{$biblioData->{itemtype}}{translated_description};
434 $biblioLoopIter{imageurl} = getitemtypeimagesrc() . "/". $itemtypes->{$biblioData->{itemtype}}{imageurl};
437 foreach my $itemInfo (@{$biblioData->{itemInfos}}) {
438 if ($itemLevelTypes && $itemInfo->{itype}) {
439 $itemInfo->{translated_description} = $itemtypes->{$itemInfo->{itype}}{translated_description};
440 $itemInfo->{imageurl} = getitemtypeimagesrc() . "/". $itemtypes->{$itemInfo->{itype}}{imageurl};
443 if (!$itemInfo->{'notforloan'} && !($itemInfo->{'itemnotforloan'} > 0)) {
444 $biblioLoopIter{forloan} = 1;
448 my @notforloan_avs = Koha::AuthorisedValues->search_by_koha_field({ kohafield => 'items.notforloan', frameworkcode => $frameworkcode });
449 my $notforloan_label_of = { map { $_->authorised_value => $_->opac_description } @notforloan_avs };
451 $biblioLoopIter{itemLoop} = [];
452 my $numCopiesAvailable = 0;
453 my $numCopiesOPACAvailable = 0;
454 foreach my $itemInfo (@{$biblioData->{itemInfos}}) {
455 my $itemNum = $itemInfo->{itemnumber};
456 my $item = Koha::Items->find( $itemNum );
457 my $itemLoopIter = {};
459 $itemLoopIter->{itemnumber} = $itemNum;
460 $itemLoopIter->{barcode} = $itemInfo->{barcode};
461 $itemLoopIter->{homeBranchName} = $itemInfo->{homebranch};
462 $itemLoopIter->{callNumber} = $itemInfo->{itemcallnumber};
463 $itemLoopIter->{enumchron} = $itemInfo->{enumchron};
464 $itemLoopIter->{ccode} = $itemInfo->{ccode};
465 $itemLoopIter->{copynumber} = $itemInfo->{copynumber};
466 if ($itemLevelTypes) {
467 $itemLoopIter->{translated_description} = $itemInfo->{translated_description};
468 $itemLoopIter->{itype} = $itemInfo->{itype};
469 $itemLoopIter->{imageurl} = $itemInfo->{imageurl};
472 # If the holdingbranch is different than the homebranch, we show the
473 # holdingbranch of the document too.
474 if ( $itemInfo->{homebranch} ne $itemInfo->{holdingbranch} ) {
475 $itemLoopIter->{holdingBranchName} = $itemInfo->{holdingbranch};
478 # If the item is currently on loan, we display its return date and
479 # change the background color.
480 my $issue = Koha::Checkouts->find( { itemnumber => $itemNum } );
481 if ( $issue ) {
482 $itemLoopIter->{dateDue} = output_pref({ dt => dt_from_string($issue->date_due, 'sql'), as_due_date => 1 });
483 $itemLoopIter->{backgroundcolor} = 'onloan';
486 # checking reserve
487 my $holds = $item->current_holds;
489 if ( my $first_hold = $holds->next ) {
490 $itemLoopIter->{backgroundcolor} = 'reserved';
491 $itemLoopIter->{reservedate} = output_pref({ dt => dt_from_string($first_hold->reservedate), dateonly => 1 }); # FIXME Should be formatted in the template
492 $itemLoopIter->{ExpectedAtLibrary} = $first_hold->branchcode;
493 $itemLoopIter->{waitingdate} = $first_hold->waitingdate;
496 $itemLoopIter->{notforloan} = $itemInfo->{notforloan};
497 $itemLoopIter->{itemnotforloan} = $itemInfo->{itemnotforloan};
499 # Management of the notforloan document
500 if ( $itemLoopIter->{notforloan} || $itemLoopIter->{itemnotforloan}) {
501 $itemLoopIter->{backgroundcolor} = 'other';
502 $itemLoopIter->{notforloanvalue} =
503 $notforloan_label_of->{ $itemLoopIter->{notforloan} };
506 # Management of lost or long overdue items
507 if ( $itemInfo->{itemlost} ) {
509 # FIXME localized strings should never be in Perl code
510 $itemLoopIter->{message} =
511 $itemInfo->{itemlost} == 1 ? "(lost)"
512 : $itemInfo->{itemlost} == 2 ? "(long overdue)"
513 : "";
514 $itemInfo->{backgroundcolor} = 'other';
517 # Check of the transferred documents
518 my ( $transfertwhen, $transfertfrom, $transfertto ) =
519 GetTransfers($itemNum);
520 if ( $transfertwhen && ($transfertwhen ne '') ) {
521 $itemLoopIter->{transfertwhen} = output_pref({ dt => dt_from_string($transfertwhen), dateonly => 1 });
522 $itemLoopIter->{transfertfrom} = $transfertfrom;
523 $itemLoopIter->{transfertto} = $transfertto;
524 $itemLoopIter->{nocancel} = 1;
527 # if the items belongs to a host record, show link to host record
528 if ( $itemInfo->{biblionumber} ne $biblioNum ) {
529 $biblioLoopIter{hostitemsflag} = 1;
530 $itemLoopIter->{hostbiblionumber} = $itemInfo->{biblionumber};
531 $itemLoopIter->{hosttitle} = Koha::Biblios->find( $itemInfo->{biblionumber} )->title;
534 # If there is no loan, return and transfer, we show a checkbox.
535 $itemLoopIter->{notforloan} = $itemLoopIter->{notforloan} || 0;
537 my $patron_unblessed = $patron->unblessed;
538 my $branch = GetReservesControlBranch( $itemInfo, $patron_unblessed );
540 my $policy_holdallowed = !$itemLoopIter->{already_reserved};
541 $policy_holdallowed &&=
542 IsAvailableForItemLevelRequest($item, $patron) &&
543 CanItemBeReserved( $borrowernumber, $itemNum )->{status} eq 'OK';
545 if ($policy_holdallowed) {
546 my $opac_hold_policy = Koha::IssuingRules->get_opacitemholds_policy( { item => $item, patron => $patron } );
547 if ( $opac_hold_policy ne 'N' ) { # If Y or F
548 $itemLoopIter->{available} = 1;
549 $numCopiesOPACAvailable++;
550 $biblioLoopIter{force_hold} = 1 if $opac_hold_policy eq 'F';
552 $numCopiesAvailable++;
554 unless ( $can_place_hold_if_available_at_pickup ) {
555 my $items_in_this_library = Koha::Items->search({ biblionumber => $itemInfo->{biblionumber}, holdingbranch => $itemInfo->{holdingbranch} });
556 my $nb_of_items_issued = $items_in_this_library->search({ 'issue.itemnumber' => { not => undef }}, { join => 'issue' })->count;
557 if ( $items_in_this_library->count > $nb_of_items_issued ) {
558 push @not_available_at, $itemInfo->{holdingbranch};
563 $itemLoopIter->{imageurl} = getitemtypeimagelocation( 'opac', $itemtypes->{ $itemInfo->{itype} }{imageurl} );
565 # Show serial enumeration when needed
566 if ($itemLoopIter->{enumchron}) {
567 $itemdata_enumchron = 1;
569 # Show collection when needed
570 if ($itemLoopIter->{ccode}) {
571 $itemdata_ccode = 1;
574 push @{$biblioLoopIter{itemLoop}}, $itemLoopIter;
576 $template->param(
577 itemdata_enumchron => $itemdata_enumchron,
578 itemdata_ccode => $itemdata_ccode,
581 if ($numCopiesAvailable > 0) {
582 $numBibsAvailable++;
583 $biblioLoopIter{bib_available} = 1;
584 $biblioLoopIter{holdable} = 1;
585 $biblioLoopIter{itemholdable} = 1 if $numCopiesOPACAvailable;
587 if ($biblioLoopIter{already_reserved}) {
588 $biblioLoopIter{holdable} = undef;
589 $biblioLoopIter{itemholdable} = undef;
591 if(not C4::Context->preference('AllowHoldsOnPatronsPossessions') and CheckIfIssuedToPatron($borrowernumber,$biblioNum)) {
592 $biblioLoopIter{holdable} = undef;
593 $biblioLoopIter{already_patron_possession} = 1;
596 if ( $biblioLoopIter{holdable} ) {
597 @not_available_at = uniq @not_available_at;
598 $biblioLoopIter{not_available_at} = \@not_available_at ;
601 unless ( $can_place_hold_if_available_at_pickup ) {
602 @not_available_at = uniq @not_available_at;
603 $biblioLoopIter{not_available_at} = \@not_available_at ;
604 # The record is not holdable is not available at any of the libraries
605 if ( Koha::Libraries->search->count == @not_available_at ) {
606 $biblioLoopIter{holdable} = 0;
610 $biblioLoopIter{holdable} &&= CanBookBeReserved( $borrowernumber, $biblioNum )->{status} eq 'OK';
612 # For multiple holds per record, if a patron has previously placed a hold,
613 # the patron can only place more holds of the same type. That is, if the
614 # patron placed a record level hold, all the holds the patron places must
615 # be record level. If the patron placed an item level hold, all holds
616 # the patron places must be item level
617 my $forced_hold_level = Koha::Holds->search(
619 borrowernumber => $borrowernumber,
620 biblionumber => $biblioNum,
621 found => undef,
623 )->forced_hold_level();
624 if ($forced_hold_level) {
625 $biblioLoopIter{force_hold} = 1 if $forced_hold_level eq 'item';
626 $biblioLoopIter{itemholdable} = 0 if $forced_hold_level eq 'record';
630 push @$biblioLoop, \%biblioLoopIter;
632 $anyholdable = 1 if $biblioLoopIter{holdable};
635 unless ($pickup_locations->count) {
636 $numBibsAvailable = 0;
637 $anyholdable = 0;
638 $template->param(
639 message => 1,
640 no_pickup_locations => 1
644 if ( $numBibsAvailable == 0 || $anyholdable == 0) {
645 $template->param( none_available => 1 );
648 if (scalar @biblionumbers > 1) {
649 $template->param( multi_hold => 1);
652 my $show_notes=C4::Context->preference('OpacHoldNotes');
653 $template->param(OpacHoldNotes=>$show_notes);
655 # display infos
656 $template->param(bibitemloop => $biblioLoop);
657 # can set reserve date in future
658 if (
659 C4::Context->preference( 'AllowHoldDateInFuture' ) &&
660 C4::Context->preference( 'OPACAllowHoldDateInFuture' )
662 $template->param(
663 reserve_in_future => 1,
667 output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };