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>.
24 use C4
::Auth
; # checkauth, getborrowernumber.
36 use Koha
::AuthorisedValues
;
39 use Koha
::CirculationRules
;
45 use Date
::Calc qw
/Today Date_to_Days/;
46 use List
::MoreUtils qw
/uniq/;
48 my $maxreserves = C4
::Context
->preference("maxreserves");
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");
58 my ( $template, $borrowernumber, $cookie ) = get_template_and_user
(
60 template_name
=> "opac-reserve.tt",
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 };
97 # Pass through any reserve charge
98 my $reservefee = $patron->category->reservefee;
99 if ( $reservefee > 0){
100 $template->param( RESERVE_CHARGE
=> $reservefee);
103 my $itemtypes = { map { $_->{itemtype
} => $_ } @
{ Koha
::ItemTypes
->search_with_localization->unblessed } };
105 # There are two ways of calling this script, with a single biblio num
106 # or multiple biblio nums.
107 my $biblionumbers = $query->param('biblionumbers');
108 my $reserveMode = $query->param('reserve_mode');
109 if ($reserveMode && ($reserveMode eq 'single')) {
110 my $bib = $query->param('single_bib');
111 $biblionumbers = "$bib/";
113 if (! $biblionumbers) {
114 $biblionumbers = $query->param('biblionumber');
117 if ((! $biblionumbers) && (! $query->param('place_reserve'))) {
118 $template->param(message
=>1, no_biblionumber
=>1);
119 output_html_with_http_headers
$query, $cookie, $template->output, undef, { force_no_caching
=> 1 };
123 # Pass the numbers to the page so they can be fed back
124 # when the hold is confirmed. TODO: Not necessary?
125 $template->param( biblionumbers
=> $biblionumbers );
127 # Each biblio number is suffixed with '/', e.g. "1/2/3/"
128 my @biblionumbers = split /\//, $biblionumbers;
129 if (($#biblionumbers < 0) && (! $query->param('place_reserve'))) {
131 $template->param(message
=>1, no_biblionumber
=>1);
132 output_html_with_http_headers
$query, $cookie, $template->output, undef, { force_no_caching
=> 1 };
137 # pass the pickup branch along....
138 my $branch = $query->param('branch') || $patron->branchcode || C4
::Context
->userenv->{branch
} || '' ;
139 $template->param( branch
=> $branch );
143 # Build hashes of the requested biblio(item)s and items.
147 my %biblioDataHash; # Hash of biblionumber to biblio/biblioitems record.
148 my %itemInfoHash; # Hash of itemnumber to item info.
149 foreach my $biblioNumber (@biblionumbers) {
151 my $biblioData = GetBiblioData
($biblioNumber);
152 $biblioDataHash{$biblioNumber} = $biblioData;
154 my @itemInfos = GetItemsInfo
($biblioNumber);
156 my $marcrecord= GetMarcBiblio
({ biblionumber
=> $biblioNumber });
158 # flag indicating existence of at least one item linked via a host record
160 # adding items linked via host biblios
161 my @hostitemInfos = GetHostItemsInfo
($marcrecord);
164 push (@itemInfos,@hostitemInfos);
167 $biblioData->{itemInfos
} = \
@itemInfos;
168 foreach my $itemInfo (@itemInfos) {
169 $itemInfoHash{$itemInfo->{itemnumber
}} = $itemInfo;
172 # Compute the priority rank.
173 my $biblio = Koha
::Biblios
->find( $biblioNumber );
174 $biblioData->{object
} = $biblio;
175 my $holds = $biblio->holds;
176 my $rank = $holds->count;
177 $biblioData->{reservecount
} = 1; # new reserve
178 while ( my $hold = $holds->next ) {
179 if ( $hold->is_waiting ) {
183 $biblioData->{reservecount
}++;
186 $biblioData->{rank
} = $rank + 1;
191 # If this is the second time through this script, it
192 # means we are carrying out the hold request, possibly
193 # with a specific item for each biblionumber.
196 if ( $query->param('place_reserve') ) {
199 $reserve_cnt = $patron->holds->count;
202 # List is composed of alternating biblio/item/branch
203 my $selectedItems = $query->param('selecteditems');
205 if ($query->param('reserve_mode') eq 'single') {
206 # This indicates non-JavaScript mode, so there was
207 # only a single biblio number selected.
208 my $bib = $query->param('single_bib');
209 my $item = $query->param("checkitem_$bib");
210 if ($item eq 'any') {
213 my $branch = $query->param('branch');
214 $selectedItems = "$bib/$item/$branch/";
217 $selectedItems =~ s!/$!!;
218 my @selectedItems = split /\//, $selectedItems, -1;
220 # Make sure there is a biblionum/itemnum/branch triplet for each item.
221 # The itemnum can be 'any', meaning next available.
222 my $selectionCount = @selectedItems;
223 if (($selectionCount == 0) || (($selectionCount % 3) != 0)) {
224 $template->param(message
=>1, bad_data
=>1);
225 output_html_with_http_headers
$query, $cookie, $template->output, undef, { force_no_caching
=> 1 };
229 my $failed_holds = 0;
230 while (@selectedItems) {
231 my $biblioNum = shift(@selectedItems);
232 my $itemNum = shift(@selectedItems);
233 my $branch = shift(@selectedItems); # i.e., branch code, not name
237 my $singleBranchMode = Koha
::Libraries
->search->count == 1;
238 if ( $singleBranchMode || ! C4
::Context
->preference("OPACAllowUserToChooseBranch") )
239 { # single branch mode or disabled user choosing
240 $branch = $patron->branchcode;
243 # When choosing a specific item, the default pickup library should be dictated by the default hold policy
244 if ( ! C4
::Context
->preference("OPACAllowUserToChooseBranch") && $itemNum ) {
245 my $item = Koha
::Items
->find( $itemNum );
246 my $type = $item->effective_itemtype;
247 my $rule = GetBranchItemRule
( $patron->branchcode, $type );
249 if ( $rule->{hold_fulfillment_policy
} eq 'any' ) {
250 $branch = $patron->branchcode;
252 my $policy = $rule->{hold_fulfillment_policy
};
253 $branch = $item->$policy;
257 #item may belong to a host biblio, if yes change biblioNum to hosts bilbionumber
258 if ( $itemNum ne '' ) {
259 my $item = Koha
::Items
->find( $itemNum );
260 my $hostbiblioNum = $item->biblio->biblionumber;
261 if ( $hostbiblioNum ne $biblioNum ) {
262 $biblioNum = $hostbiblioNum;
266 my $biblioData = $biblioDataHash{$biblioNum};
269 # Check for user supplied reserve date
271 if ( C4
::Context
->preference('AllowHoldDateInFuture')
272 && C4
::Context
->preference('OPACAllowHoldDateInFuture') )
274 $startdate = $query->param("reserve_date_$biblioNum");
277 my $expiration_date = $query->param("expiration_date_$biblioNum");
279 my $rank = $biblioData->{rank
};
280 if ( $itemNum ne '' ) {
281 $canreserve = 1 if CanItemBeReserved
( $borrowernumber, $itemNum, $branch )->{status
} eq 'OK';
284 $canreserve = 1 if CanBookBeReserved
( $borrowernumber, $biblioNum, $branch )->{status
} eq 'OK';
286 # Inserts a null into the 'itemnumber' field of 'reserves' table.
289 my $notes = $query->param('notes_'.$biblioNum)||'';
292 && $reserve_cnt >= $maxreserves )
297 unless ( $can_place_hold_if_available_at_pickup ) {
298 my $items_in_this_library = Koha
::Items
->search({ biblionumber
=> $biblioNum, holdingbranch
=> $branch });
299 my $nb_of_items_issued = $items_in_this_library->search({ 'issue.itemnumber' => { not => undef }}, { join => 'issue' })->count;
300 my $nb_of_items_unavailable = $items_in_this_library->search({ -or => { lost
=> { '!=' => 0 }, damaged
=> { '!=' => 0 }, } });
301 if ( $items_in_this_library->count > $nb_of_items_issued + $nb_of_items_unavailable ) {
306 my $itemtype = $query->param('itemtype') || undef;
307 $itemtype = undef if $itemNum;
309 # Here we actually do the reserveration. Stage 3.
311 my $reserve_id = AddReserve
(
312 $branch, $borrowernumber, $biblioNum,
313 [$biblioNum], $rank, $startdate,
314 $expiration_date, $notes, $biblioData->{title
},
315 $itemNum, $found, $itemtype,
317 $failed_holds++ unless $reserve_id;
322 print $query->redirect("/cgi-bin/koha/opac-user.pl?" . ( $failed_holds ?
"failed_holds=$failed_holds" : q
|| ) . "#opac-user-holds");
328 # Here we check that the borrower can actually make reserves Stage 1.
332 my $maxoutstanding = C4
::Context
->preference("maxoutstanding");
333 $template->param( noreserve
=> 1 ) unless $maxoutstanding;
334 my $amountoutstanding = $patron->account->balance;
335 if ( $amountoutstanding && ($amountoutstanding > $maxoutstanding) ) {
336 my $amount = sprintf "%.02f", $amountoutstanding;
337 $template->param( message
=> 1 );
339 $template->param( too_much_oweing
=> $amount );
342 if ( $patron->gonenoaddress && ($patron->gonenoaddress == 1) ) {
350 if ( $patron->lost && ($patron->lost == 1) ) {
358 if ( $patron->is_debarred ) {
363 debarred_comment
=> $patron->debarredcomment,
364 debarred_date
=> $patron->debarred,
368 my $holds = $patron->holds;
369 my $reserves_count = $holds->count;
370 $template->param( RESERVES
=> $holds->unblessed );
371 if ( $maxreserves && ( $reserves_count >= $maxreserves ) ) {
372 $template->param( message
=> 1 );
374 $template->param( too_many_reserves
=> $holds->count );
377 unless ( $noreserves ) {
378 my $requested_reserves_count = scalar( @biblionumbers );
379 if ( $maxreserves && ( $reserves_count + $requested_reserves_count > $maxreserves ) ) {
380 $template->param( new_reserves_allowed
=> $maxreserves - $reserves_count );
384 unless ($noreserves) {
385 $template->param( select_item_types
=> 1 );
391 # Build the template parameters that will show the info
392 # and items for each biblionumber.
397 my $numBibsAvailable = 0;
398 my $itemdata_enumchron = 0;
399 my $itemdata_ccode = 0;
401 my $itemLevelTypes = C4
::Context
->preference('item-level_itypes');
402 my $pickup_locations = Koha
::Libraries
->search({ pickup_location
=> 1 });
403 $template->param('item_level_itypes' => $itemLevelTypes);
405 foreach my $biblioNum (@biblionumbers) {
407 # Init the bib item with the choices for branch pickup
410 # Get relevant biblio data.
411 my $biblioData = $biblioDataHash{$biblioNum};
413 $template->param(message
=>1, bad_biblionumber
=>$biblioNum);
414 output_html_with_http_headers
$query, $cookie, $template->output, undef, { force_no_caching
=> 1 };
418 my @not_available_at = ();
419 my $biblio = $biblioData->{object
};
420 foreach my $library ( $pickup_locations->as_list ) {
421 push( @not_available_at, $library->branchcode ) unless $biblio->can_be_transferred({ to
=> $library });
424 my $frameworkcode = GetFrameworkCode
( $biblioData->{biblionumber
} );
425 $biblioLoopIter{biblionumber
} = $biblioData->{biblionumber
};
426 $biblioLoopIter{title
} = $biblioData->{title
};
427 $biblioLoopIter{subtitle
} = $biblioData->{'subtitle'};
428 $biblioLoopIter{medium
} = $biblioData->{medium
};
429 $biblioLoopIter{part_number
} = $biblioData->{part_number
};
430 $biblioLoopIter{part_name
} = $biblioData->{part_name
};
431 $biblioLoopIter{author
} = $biblioData->{author
};
432 $biblioLoopIter{rank
} = $biblioData->{rank
};
433 $biblioLoopIter{reservecount
} = $biblioData->{reservecount
};
434 $biblioLoopIter{already_reserved
} = $biblioData->{already_reserved
};
435 $biblioLoopIter{reqholdnotes
}=0; #TODO: For future use
437 if (!$itemLevelTypes && $biblioData->{itemtype
}) {
438 $biblioLoopIter{translated_description
} = $itemtypes->{$biblioData->{itemtype
}}{translated_description
};
439 $biblioLoopIter{imageurl
} = getitemtypeimagesrc
() . "/". $itemtypes->{$biblioData->{itemtype
}}{imageurl
};
442 foreach my $itemInfo (@
{$biblioData->{itemInfos
}}) {
443 if ($itemLevelTypes && $itemInfo->{itype
}) {
444 $itemInfo->{translated_description
} = $itemtypes->{$itemInfo->{itype
}}{translated_description
};
445 $itemInfo->{imageurl
} = getitemtypeimagesrc
() . "/". $itemtypes->{$itemInfo->{itype
}}{imageurl
};
448 if (!$itemInfo->{'notforloan'} && !($itemInfo->{'itemnotforloan'} > 0)) {
449 $biblioLoopIter{forloan
} = 1;
453 my @notforloan_avs = Koha
::AuthorisedValues
->search_by_koha_field({ kohafield
=> 'items.notforloan', frameworkcode
=> $frameworkcode });
454 my $notforloan_label_of = { map { $_->authorised_value => $_->opac_description } @notforloan_avs };
456 $biblioLoopIter{itemLoop
} = [];
457 my $numCopiesAvailable = 0;
458 my $numCopiesOPACAvailable = 0;
459 foreach my $itemInfo (@
{$biblioData->{itemInfos
}}) {
460 my $itemNum = $itemInfo->{itemnumber
};
461 my $item = Koha
::Items
->find( $itemNum );
462 my $itemLoopIter = {};
464 $itemLoopIter->{itemnumber
} = $itemNum;
465 $itemLoopIter->{barcode
} = $itemInfo->{barcode
};
466 $itemLoopIter->{homeBranchName
} = $itemInfo->{homebranch
};
467 $itemLoopIter->{callNumber
} = $itemInfo->{itemcallnumber
};
468 $itemLoopIter->{enumchron
} = $itemInfo->{enumchron
};
469 $itemLoopIter->{ccode
} = $itemInfo->{ccode
};
470 $itemLoopIter->{copynumber
} = $itemInfo->{copynumber
};
471 if ($itemLevelTypes) {
472 $itemLoopIter->{translated_description
} = $itemInfo->{translated_description
};
473 $itemLoopIter->{itype
} = $itemInfo->{itype
};
474 $itemLoopIter->{imageurl
} = $itemInfo->{imageurl
};
477 # If the holdingbranch is different than the homebranch, we show the
478 # holdingbranch of the document too.
479 if ( $itemInfo->{homebranch
} ne $itemInfo->{holdingbranch
} ) {
480 $itemLoopIter->{holdingBranchName
} = $itemInfo->{holdingbranch
};
483 # If the item is currently on loan, we display its return date and
484 # change the background color.
485 my $issue = Koha
::Checkouts
->find( { itemnumber
=> $itemNum } );
487 $itemLoopIter->{dateDue
} = output_pref
({ dt
=> dt_from_string
($issue->date_due, 'sql'), as_due_date
=> 1 });
488 $itemLoopIter->{backgroundcolor
} = 'onloan';
492 my $holds = $item->current_holds;
494 if ( my $first_hold = $holds->next ) {
495 $itemLoopIter->{backgroundcolor
} = 'reserved';
496 $itemLoopIter->{reservedate
} = output_pref
({ dt
=> dt_from_string
($first_hold->reservedate), dateonly
=> 1 }); # FIXME Should be formatted in the template
497 $itemLoopIter->{ExpectedAtLibrary
} = $first_hold->branchcode;
498 $itemLoopIter->{waitingdate
} = $first_hold->waitingdate;
501 $itemLoopIter->{notforloan
} = $itemInfo->{notforloan
};
502 $itemLoopIter->{itemnotforloan
} = $itemInfo->{itemnotforloan
};
504 # Management of the notforloan document
505 if ( $itemLoopIter->{notforloan
} || $itemLoopIter->{itemnotforloan
}) {
506 $itemLoopIter->{backgroundcolor
} = 'other';
507 $itemLoopIter->{notforloanvalue
} =
508 $notforloan_label_of->{ $itemLoopIter->{notforloan
} };
511 # Management of lost or long overdue items
512 if ( $itemInfo->{itemlost
} ) {
514 # FIXME localized strings should never be in Perl code
515 $itemLoopIter->{message
} =
516 $itemInfo->{itemlost
} == 1 ?
"(lost)"
517 : $itemInfo->{itemlost
} == 2 ?
"(long overdue)"
519 $itemInfo->{backgroundcolor
} = 'other';
522 # Check of the transferred documents
523 my ( $transfertwhen, $transfertfrom, $transfertto ) =
524 GetTransfers
($itemNum);
525 if ( $transfertwhen && ($transfertwhen ne '') ) {
526 $itemLoopIter->{transfertwhen
} = output_pref
({ dt
=> dt_from_string
($transfertwhen), dateonly
=> 1 });
527 $itemLoopIter->{transfertfrom
} = $transfertfrom;
528 $itemLoopIter->{transfertto
} = $transfertto;
529 $itemLoopIter->{nocancel
} = 1;
532 # if the items belongs to a host record, show link to host record
533 if ( $itemInfo->{biblionumber
} ne $biblioNum ) {
534 $biblioLoopIter{hostitemsflag
} = 1;
535 $itemLoopIter->{hostbiblionumber
} = $itemInfo->{biblionumber
};
536 $itemLoopIter->{hosttitle
} = Koha
::Biblios
->find( $itemInfo->{biblionumber
} )->title;
539 # If there is no loan, return and transfer, we show a checkbox.
540 $itemLoopIter->{notforloan
} = $itemLoopIter->{notforloan
} || 0;
542 my $patron_unblessed = $patron->unblessed;
543 my $branch = GetReservesControlBranch
( $itemInfo, $patron_unblessed );
545 my $policy_holdallowed = !$itemLoopIter->{already_reserved
};
546 $policy_holdallowed &&=
547 IsAvailableForItemLevelRequest
($item, $patron) &&
548 CanItemBeReserved
( $borrowernumber, $itemNum )->{status
} eq 'OK';
550 if ($policy_holdallowed) {
551 my $opac_hold_policy = Koha
::CirculationRules
->get_opacitemholds_policy( { item
=> $item, patron
=> $patron } );
552 if ( $opac_hold_policy ne 'N' ) { # If Y or F
553 $itemLoopIter->{available
} = 1;
554 $numCopiesOPACAvailable++;
555 $biblioLoopIter{force_hold
} = 1 if $opac_hold_policy eq 'F';
557 $numCopiesAvailable++;
559 unless ( $can_place_hold_if_available_at_pickup ) {
560 my $items_in_this_library = Koha
::Items
->search({ biblionumber
=> $itemInfo->{biblionumber
}, holdingbranch
=> $itemInfo->{holdingbranch
} });
561 my $nb_of_items_issued = $items_in_this_library->search({ 'issue.itemnumber' => { not => undef }}, { join => 'issue' })->count;
562 if ( $items_in_this_library->count > $nb_of_items_issued ) {
563 push @not_available_at, $itemInfo->{holdingbranch
};
568 $itemLoopIter->{imageurl
} = getitemtypeimagelocation
( 'opac', $itemtypes->{ $itemInfo->{itype
} }{imageurl
} );
570 # Show serial enumeration when needed
571 if ($itemLoopIter->{enumchron
}) {
572 $itemdata_enumchron = 1;
574 # Show collection when needed
575 if ($itemLoopIter->{ccode
}) {
579 push @
{$biblioLoopIter{itemLoop
}}, $itemLoopIter;
582 itemdata_enumchron
=> $itemdata_enumchron,
583 itemdata_ccode
=> $itemdata_ccode,
586 if ($numCopiesAvailable > 0) {
588 $biblioLoopIter{bib_available
} = 1;
589 $biblioLoopIter{holdable
} = 1;
590 $biblioLoopIter{itemholdable
} = 1 if $numCopiesOPACAvailable;
592 if ($biblioLoopIter{already_reserved
}) {
593 $biblioLoopIter{holdable
} = undef;
594 $biblioLoopIter{itemholdable
} = undef;
596 if(not C4
::Context
->preference('AllowHoldsOnPatronsPossessions') and CheckIfIssuedToPatron
($borrowernumber,$biblioNum)) {
597 $biblioLoopIter{holdable
} = undef;
598 $biblioLoopIter{already_patron_possession
} = 1;
601 if ( $biblioLoopIter{holdable
} ) {
602 @not_available_at = uniq
@not_available_at;
603 $biblioLoopIter{not_available_at
} = \
@not_available_at ;
606 unless ( $can_place_hold_if_available_at_pickup ) {
607 @not_available_at = uniq
@not_available_at;
608 $biblioLoopIter{not_available_at
} = \
@not_available_at ;
609 # The record is not holdable is not available at any of the libraries
610 if ( Koha
::Libraries
->search->count == @not_available_at ) {
611 $biblioLoopIter{holdable
} = 0;
615 $biblioLoopIter{holdable
} &&= CanBookBeReserved
( $borrowernumber, $biblioNum )->{status
} eq 'OK';
617 # For multiple holds per record, if a patron has previously placed a hold,
618 # the patron can only place more holds of the same type. That is, if the
619 # patron placed a record level hold, all the holds the patron places must
620 # be record level. If the patron placed an item level hold, all holds
621 # the patron places must be item level
622 my $forced_hold_level = Koha
::Holds
->search(
624 borrowernumber
=> $borrowernumber,
625 biblionumber
=> $biblioNum,
628 )->forced_hold_level();
629 if ($forced_hold_level) {
630 $biblioLoopIter{force_hold
} = 1 if $forced_hold_level eq 'item';
631 $biblioLoopIter{itemholdable
} = 0 if $forced_hold_level eq 'record';
635 push @
$biblioLoop, \
%biblioLoopIter;
637 $anyholdable = 1 if $biblioLoopIter{holdable
};
640 unless ($pickup_locations->count) {
641 $numBibsAvailable = 0;
645 no_pickup_locations
=> 1
649 if ( $numBibsAvailable == 0 || $anyholdable == 0) {
650 $template->param( none_available
=> 1 );
653 if (scalar @biblionumbers > 1) {
654 $template->param( multi_hold
=> 1);
657 my $show_notes=C4
::Context
->preference('OpacHoldNotes');
658 $template->param(OpacHoldNotes
=>$show_notes);
661 $template->param(bibitemloop
=> $biblioLoop);
662 # can set reserve date in future
664 C4
::Context
->preference( 'AllowHoldDateInFuture' ) &&
665 C4
::Context
->preference( 'OPACAllowHoldDateInFuture' )
668 reserve_in_future
=> 1,
672 output_html_with_http_headers
$query, $cookie, $template->output, undef, { force_no_caching
=> 1 };