Bug 30847: Don't get biblio/item info when placing holds
[koha.git] / opac / opac-reserve.pl
1 #!/usr/bin/perl
2
3
4 # Copyright Katipo Communications 2002
5 # Copyright Koha Development team 2012
6 #
7 # This file is part of Koha.
8 #
9 # Koha is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 3 of the License, or
12 # (at your option) any later version.
13 #
14 # Koha is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with Koha; if not, see <http://www.gnu.org/licenses>.
21
22 use Modern::Perl;
23
24 use CGI qw ( -utf8 );
25 use C4::Auth qw( get_template_and_user );
26 use C4::Koha qw( getitemtypeimagelocation getitemtypeimagesrc );
27 use C4::Circulation qw( GetBranchItemRule );
28 use C4::Reserves qw( CanItemBeReserved CanBookBeReserved AddReserve GetReservesControlBranch ItemsAnyAvailableAndNotRestricted IsAvailableForItemLevelRequest );
29 use C4::Biblio qw( GetBiblioData GetFrameworkCode );
30 use C4::Output qw( output_html_with_http_headers );
31 use C4::Context;
32 use C4::Members;
33 use C4::Overdues;
34
35 use Koha::AuthorisedValues;
36 use Koha::Biblios;
37 use Koha::CirculationRules;
38 use Koha::Items;
39 use Koha::ItemTypes;
40 use Koha::Checkouts;
41 use Koha::Libraries;
42 use Koha::Patrons;
43 use List::MoreUtils qw( uniq );
44
45 my $maxreserves = C4::Context->preference("maxreserves");
46
47 my $query = CGI->new;
48
49 # if OPACHoldRequests (for placing holds) is disabled, leave immediately
50 if ( ! C4::Context->preference('OPACHoldRequests') ) {
51     print $query->redirect("/cgi-bin/koha/errors/404.pl");
52     exit;
53 }
54
55 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
56     {
57         template_name   => "opac-reserve.tt",
58         query           => $query,
59         type            => "opac",
60     }
61 );
62
63 my $patron = Koha::Patrons->find( $borrowernumber, { prefetch => ['categorycode'] } );
64 my $category = $patron->category;
65
66 my $can_place_hold_if_available_at_pickup = C4::Context->preference('OPACHoldsIfAvailableAtPickup');
67 unless ( $can_place_hold_if_available_at_pickup ) {
68     my @patron_categories = split ',', C4::Context->preference('OPACHoldsIfAvailableAtPickupExceptions');
69     if ( @patron_categories ) {
70         my $categorycode = $patron->categorycode;
71         $can_place_hold_if_available_at_pickup = grep { $_ eq $categorycode } @patron_categories;
72     }
73 }
74
75 # check if this user can place a reserve, -1 means use sys pref, 0 means dont block, 1 means block
76 if ( $category->effective_BlockExpiredPatronOpacActions ) {
77
78     if ( $patron->is_expired ) {
79
80         # cannot reserve, their card has expired and the rules set mean this is not allowed
81         $template->param( message => 1, expired_patron => 1 );
82         output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
83         exit;
84     }
85 }
86
87 # Pass through any reserve charge
88 my $reservefee = $category->reservefee;
89 if ( $reservefee > 0){
90     $template->param( RESERVE_CHARGE => $reservefee);
91 }
92
93 my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
94
95 # There are two ways of calling this script, with a single biblio num
96 # or multiple biblio nums.
97 my $biblionumbers = $query->param('biblionumbers');
98 my $reserveMode = $query->param('reserve_mode');
99 if ($reserveMode && ($reserveMode eq 'single')) {
100     my $bib = $query->param('single_bib');
101     $biblionumbers = "$bib/";
102 }
103 if (! $biblionumbers) {
104     $biblionumbers = $query->param('biblionumber');
105 }
106
107 if ((! $biblionumbers) && (! $query->param('place_reserve'))) {
108     $template->param(message=>1, no_biblionumber=>1);
109     output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
110     exit;
111 }
112
113 # Pass the numbers to the page so they can be fed back
114 # when the hold is confirmed. TODO: Not necessary?
115 $template->param( biblionumbers => $biblionumbers );
116
117 # Each biblio number is suffixed with '/', e.g. "1/2/3/"
118 my @biblionumbers = split /\//, $biblionumbers;
119 if (($#biblionumbers < 0) && (! $query->param('place_reserve'))) {
120     # TODO: New message?
121     $template->param(message=>1, no_biblionumber=>1);
122     output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
123     exit;
124 }
125
126
127 # pass the pickup branch along....
128 my $branch = $query->param('branch') || $patron->branchcode || C4::Context->userenv->{branch} || '' ;
129 $template->param( branch => $branch );
130
131 #
132 #
133 # Here we are carrying out the hold request, possibly
134 # with a specific item for each biblionumber.
135 #
136 #
137 if ( $query->param('place_reserve') ) {
138     my $reserve_cnt = 0;
139     if ($maxreserves) {
140         $reserve_cnt = $patron->holds->count;
141     }
142
143     # List is composed of alternating biblio/item/branch
144     my $selectedItems = $query->param('selecteditems');
145
146     if ($query->param('reserve_mode') eq 'single') {
147         # This indicates non-JavaScript mode, so there was
148         # only a single biblio number selected.
149         my $bib = $query->param('single_bib');
150         my $item = $query->param("checkitem_$bib");
151         if ($item eq 'any') {
152             $item = '';
153         }
154         my $branch = $query->param('branch');
155         $selectedItems = "$bib/$item/$branch/";
156     }
157
158     $selectedItems =~ s!/$!!;
159     my @selectedItems = split /\//, $selectedItems, -1;
160
161     # Make sure there is a biblionum/itemnum/branch triplet for each item.
162     # The itemnum can be 'any', meaning next available.
163     my $selectionCount = @selectedItems;
164     if (($selectionCount == 0) || (($selectionCount % 3) != 0)) {
165         $template->param(message=>1, bad_data=>1);
166         output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
167         exit;
168     }
169
170     my $failed_holds = 0;
171     while (@selectedItems) {
172         my $biblioNum = shift(@selectedItems);
173         my $itemNum   = shift(@selectedItems);
174         my $branch    = shift(@selectedItems);    # i.e., branch code, not name
175
176         my $canreserve = 0;
177
178         my $singleBranchMode = Koha::Libraries->search->count == 1;
179         if ( $singleBranchMode || ! C4::Context->preference("OPACAllowUserToChooseBranch") )
180         {    # single branch mode or disabled user choosing
181             $branch = $patron->branchcode;
182         }
183
184         # FIXME We shouldn't need to fetch the item here
185         my $item = $itemNum ? Koha::Items->find( $itemNum ) : undef;
186         # When choosing a specific item, the default pickup library should be dictated by the default hold policy
187         if ( ! C4::Context->preference("OPACAllowUserToChooseBranch") && $item ) {
188             my $type = $item->effective_itemtype;
189             my $rule = GetBranchItemRule( $patron->branchcode, $type );
190
191             if ( $rule->{hold_fulfillment_policy} eq 'any' || $rule->{hold_fulfillment_policy} eq 'patrongroup' ) {
192                 $branch = $patron->branchcode;
193             } elsif ( $rule->{hold_fulfillment_policy} eq 'holdgroup' ){
194                 $branch = $item->homebranch;
195             } else {
196                 my $policy = $rule->{hold_fulfillment_policy};
197                 $branch = $item->$policy;
198             }
199         }
200
201         # if we have an item, we are placing the hold on the item's bib, in case of analytics
202         if ( $item ) {
203             $biblioNum = $item->biblionumber;
204         }
205
206         # Check for user supplied reserve date
207         my $startdate;
208         if (   C4::Context->preference('AllowHoldDateInFuture')
209             && C4::Context->preference('OPACAllowHoldDateInFuture') )
210         {
211             $startdate = $query->param("reserve_date_$biblioNum");
212         }
213
214         my $patron_expiration_date = $query->param("expiration_date_$biblioNum");
215
216         my $itemtype = $query->param('itemtype') || undef;
217         $itemtype = undef if $itemNum;
218
219         my $biblio = Koha::Biblios->find($biblioNum);
220         my $rank = $biblio->holds->search( { found => [ { "!=" => "W" }, undef ] } )->count + 1;
221         if ( $item ) {
222             $canreserve = 1 if CanItemBeReserved( $patron, $item, $branch )->{status} eq 'OK';
223         }
224         else {
225             $canreserve = 1
226               if CanBookBeReserved( $borrowernumber, $biblioNum, $branch, { itemtype => $itemtype } )->{status} eq 'OK';
227
228             # Inserts a null into the 'itemnumber' field of 'reserves' table.
229             $itemNum = undef;
230         }
231         my $notes = $query->param('notes_'.$biblioNum)||'';
232
233         if (   $maxreserves
234             && $reserve_cnt >= $maxreserves )
235         {
236             $canreserve = 0;
237         }
238
239         unless ( $can_place_hold_if_available_at_pickup ) {
240             my $items_in_this_library = Koha::Items->search({ biblionumber => $biblioNum, holdingbranch => $branch });
241             my $nb_of_items_issued = $items_in_this_library->search({ 'issue.itemnumber' => { not => undef }}, { join => 'issue' })->count;
242             my $nb_of_items_unavailable = $items_in_this_library->search({ -or => { lost => { '!=' => 0 }, damaged => { '!=' => 0 }, } });
243             if ( $items_in_this_library->count > $nb_of_items_issued + $nb_of_items_unavailable ) {
244                 $canreserve = 0
245             }
246         }
247
248         # Here we actually do the reserveration. Stage 3.
249         if ($canreserve) {
250             my $reserve_id = AddReserve(
251                 {
252                     branchcode       => $branch,
253                     borrowernumber   => $borrowernumber,
254                     biblionumber     => $biblioNum,
255                     priority         => $rank,
256                     reservation_date => $startdate,
257                     expiration_date  => $patron_expiration_date,
258                     notes            => $notes,
259                     title            => $biblio->title,
260                     itemnumber       => $itemNum,
261                     found            => undef,
262                     itemtype         => $itemtype,
263                 }
264             );
265             $failed_holds++ unless $reserve_id;
266             ++$reserve_cnt;
267         }
268     }
269
270     print $query->redirect("/cgi-bin/koha/opac-user.pl?" . ( $failed_holds ? "failed_holds=$failed_holds" : q|| ) . "#opac-user-holds");
271     exit;
272 }
273
274 #
275 #
276 # Build hashes of the requested biblio(item)s and items.
277 #
278 #
279
280 my %biblioDataHash; # Hash of biblionumber to biblio/biblioitems record.
281 foreach my $biblioNumber (@biblionumbers) {
282
283     my $biblioData = GetBiblioData($biblioNumber);
284     $biblioDataHash{$biblioNumber} = $biblioData;
285
286     my $biblio = Koha::Biblios->find( $biblioNumber );
287     next unless $biblio;
288
289     my $marcrecord = $biblio->metadata->record;
290
291     my $items = Koha::Items->search_ordered(
292         [
293             biblionumber => $biblioNumber,
294             'me.itemnumber' => {
295                 -in => [
296                     $biblio->host_items->get_column('itemnumber')
297                 ]
298             }
299         ],
300         { prefetch => [ 'issue', 'homebranch', 'holdingbranch' ] }
301     )->filter_by_visible_in_opac({ patron => $patron });
302
303     $biblioData->{items} = [$items->as_list]; # FIXME Potentially a lot in memory here!
304
305     # Compute the priority rank.
306     $biblioData->{object} = $biblio;
307     my $reservecount = $biblio->holds->search({ found => [ {"!=" => "W"},undef] })->count;
308     $biblioData->{reservecount} = $reservecount;
309     $biblioData->{rank} = $reservecount + 1;
310 }
311
312 #
313 #
314 # Here we check that the borrower can actually make reserves Stage 1.
315 #
316 #
317 my $noreserves     = 0;
318 my $maxoutstanding = C4::Context->preference("maxoutstanding");
319 my $amountoutstanding = $patron->account->balance;
320 if ( $amountoutstanding && ($amountoutstanding > $maxoutstanding) ) {
321     my $amount = sprintf "%.02f", $amountoutstanding;
322     $template->param( message => 1 );
323     $noreserves = 1;
324     $template->param( too_much_oweing => $amount );
325 }
326
327 if ( $patron->gonenoaddress && ($patron->gonenoaddress == 1) ) {
328     $noreserves = 1;
329     $template->param(
330         message => 1,
331         GNA     => 1
332     );
333 }
334
335 if ( $patron->lost && ($patron->lost == 1) ) {
336     $noreserves = 1;
337     $template->param(
338         message => 1,
339         lost    => 1
340     );
341 }
342
343 if ( $patron->is_debarred ) {
344     $noreserves = 1;
345     $template->param(
346         message          => 1,
347         debarred         => 1,
348         debarred_comment => $patron->debarredcomment,
349         debarred_date    => $patron->debarred,
350     );
351 }
352
353 my $holds = $patron->holds;
354 my $reserves_count = $holds->count;
355 $template->param( RESERVES => $holds->unblessed );
356 if ( $maxreserves && ( $reserves_count >= $maxreserves ) ) {
357     $template->param( message => 1 );
358     $noreserves = 1;
359     $template->param( too_many_reserves => $holds->count );
360 }
361
362 unless ( $noreserves ) {
363     my $requested_reserves_count = scalar( @biblionumbers );
364     if ( $maxreserves && ( $reserves_count + $requested_reserves_count > $maxreserves ) ) {
365         $template->param( new_reserves_allowed => $maxreserves - $reserves_count );
366     }
367 }
368
369 unless ($noreserves) {
370     $template->param( select_item_types => 1 );
371 }
372
373
374 #
375 #
376 # Build the template parameters that will show the info
377 # and items for each biblionumber.
378 #
379 #
380
381 my $biblioLoop = [];
382 my $numBibsAvailable = 0;
383 my $itemdata_enumchron = 0;
384 my $itemdata_ccode = 0;
385 my $anyholdable = 0;
386 my $itemLevelTypes = C4::Context->preference('item-level_itypes');
387 my $pickup_locations = Koha::Libraries->search({ pickup_location => 1 });
388 $template->param('item_level_itypes' => $itemLevelTypes);
389
390 my $patron_unblessed = $patron->unblessed;
391 foreach my $biblioNum (@biblionumbers) {
392
393     # Init the bib item with the choices for branch pickup
394     my %biblioLoopIter;
395
396     # Get relevant biblio data.
397     my $biblioData = $biblioDataHash{$biblioNum};
398     if (! $biblioData) {
399         $template->param(message=>1, bad_biblionumber=>$biblioNum);
400         output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
401         exit;
402     }
403
404     my @not_available_at = ();
405     my $biblio = $biblioData->{object};
406     foreach my $library ( $pickup_locations->as_list ) {
407         push( @not_available_at, $library->branchcode ) unless $biblio->can_be_transferred({ to => $library });
408     }
409
410     my $frameworkcode = GetFrameworkCode( $biblioData->{biblionumber} );
411     $biblioLoopIter{biblionumber} = $biblioData->{biblionumber};
412     $biblioLoopIter{title} = $biblioData->{title};
413     $biblioLoopIter{subtitle} = $biblioData->{'subtitle'};
414     $biblioLoopIter{medium} = $biblioData->{medium};
415     $biblioLoopIter{part_number} = $biblioData->{part_number};
416     $biblioLoopIter{part_name} = $biblioData->{part_name};
417     $biblioLoopIter{author} = $biblioData->{author};
418     $biblioLoopIter{rank} = $biblioData->{rank};
419     $biblioLoopIter{reservecount} = $biblioData->{reservecount};
420     $biblioLoopIter{already_reserved} = $biblioData->{already_reserved};
421     $biblioLoopIter{reqholdnotes}=0; #TODO: For future use
422
423     if (!$itemLevelTypes && $biblioData->{itemtype}) {
424         $biblioLoopIter{translated_description} = $itemtypes->{$biblioData->{itemtype}}{translated_description};
425         $biblioLoopIter{imageurl} = getitemtypeimagesrc() . "/". $itemtypes->{$biblioData->{itemtype}}{imageurl};
426     }
427
428
429
430     $biblioLoopIter{itemLoop} = [];
431     my $numCopiesAvailable = 0;
432     my $numCopiesOPACAvailable = 0;
433     # iterating through all items first to check if any of them available
434     # to pass this value further inside down to IsAvailableForItemLevelRequest to
435     # it's complicated logic to analyse.
436     # (before this loop was inside that sub loop so it was O(n^2) )
437     my $items_any_available;
438     $items_any_available = ItemsAnyAvailableAndNotRestricted( { biblionumber => $biblioNum, patron => $patron }) if $patron;
439     foreach my $item (@{$biblioData->{items}}) {
440
441         my $item_info = $item->unblessed;
442         $item_info->{holding_branch} = $item->holding_branch;
443         $item_info->{home_branch}    = $item->home_branch;
444         if ($itemLevelTypes) {
445             my $itemtype = $item->itemtype;
446             $item_info->{'imageurl'} = getitemtypeimagelocation( 'opac',
447                 $itemtypes->{ $itemtype->itemtype }->{'imageurl'} );
448             $item_info->{'translated_description'} =
449               $itemtypes->{ $itemtype->itemtype }->{translated_description};
450         }
451
452         # checking for holds
453         my $holds = $item->current_holds;
454         if ( my $first_hold = $holds->next ) {
455             $item_info->{first_hold} = $first_hold;
456         }
457
458         $item_info->{checkout} = $item->checkout;
459
460         # Check of the transferred documents
461         my $transfer = $item->get_transfer;
462         if ( $transfer && $transfer->in_transit ) {
463             $item_info->{transfertwhen} = $transfer->datesent;
464             $item_info->{transfertfrom} = $transfer->frombranch;
465             $item_info->{transfertto} = $transfer->tobranch;
466             $item_info->{nocancel} = 1;
467         }
468
469         # if the items belongs to a host record, show link to host record
470         if ( $item_info->{biblionumber} ne $biblioNum ) {
471             $item_info->{hostbiblionumber} = $item->biblionumber;
472             $item_info->{hosttitle}        = Koha::Biblios->find( $item_info->{biblionumber} )->title;
473         }
474
475         my $branch = GetReservesControlBranch( $item_info, $patron_unblessed );
476
477         # items_any_available defined outside of the current loop,
478         # so we avoiding loop inside IsAvailableForItemLevelRequest:
479         my $policy_holdallowed =
480             CanItemBeReserved( $patron, $item )->{status} eq 'OK' &&
481             IsAvailableForItemLevelRequest($item, $patron, undef, $items_any_available);
482
483         if ($policy_holdallowed) {
484             my $opac_hold_policy = Koha::CirculationRules->get_opacitemholds_policy( { item => $item, patron => $patron } );
485             if ( $opac_hold_policy ne 'N' ) { # If Y or F
486                 $item_info->{available} = 1;
487                 $numCopiesOPACAvailable++;
488                 $biblioLoopIter{force_hold} = 1 if $opac_hold_policy eq 'F';
489             }
490             $numCopiesAvailable++;
491
492             unless ( $can_place_hold_if_available_at_pickup ) {
493                 my $items_in_this_library = Koha::Items->search({ biblionumber => $item->biblionumber, holdingbranch => $item->holdingbranch });
494                 my $nb_of_items_issued = $items_in_this_library->search({ 'issue.itemnumber' => { not => undef }}, { join => 'issue' })->count;
495                 if ( $items_in_this_library->count > $nb_of_items_issued ) {
496                     push @not_available_at, $item->holdingbranch;
497                 }
498             }
499         }
500
501         # Show serial enumeration when needed
502         if ($item_info->{enumchron}) {
503             $itemdata_enumchron = 1;
504         }
505         # Show collection when needed
506         if ($item_info->{ccode}) {
507             $itemdata_ccode = 1;
508         }
509
510         push @{$biblioLoopIter{itemLoop}}, $item_info;
511     }
512     $template->param(
513         itemdata_enumchron => $itemdata_enumchron,
514         itemdata_ccode     => $itemdata_ccode,
515     );
516
517     if ($numCopiesAvailable > 0) {
518         $numBibsAvailable++;
519         $biblioLoopIter{bib_available} = 1;
520         $biblioLoopIter{holdable} = 1;
521         $biblioLoopIter{itemholdable} = 1 if $numCopiesOPACAvailable;
522     }
523     if ($biblioLoopIter{already_reserved}) {
524         $biblioLoopIter{holdable} = undef;
525         $biblioLoopIter{itemholdable} = undef;
526     }
527     if ( $biblioLoopIter{holdable} ) {
528         @not_available_at = uniq @not_available_at;
529         $biblioLoopIter{not_available_at} = \@not_available_at ;
530     }
531
532     unless ( $can_place_hold_if_available_at_pickup ) {
533         @not_available_at = uniq @not_available_at;
534         $biblioLoopIter{not_available_at} = \@not_available_at ;
535         # The record is not holdable is not available at any of the libraries
536         if ( Koha::Libraries->search->count == @not_available_at ) {
537             $biblioLoopIter{holdable} = 0;
538         }
539     }
540
541     my $status = CanBookBeReserved( $borrowernumber, $biblioNum )->{status};
542     $biblioLoopIter{holdable} &&= $status eq 'OK';
543     $biblioLoopIter{$status} = 1;
544
545     if ( $biblioLoopIter{holdable} and C4::Context->preference('AllowHoldItemTypeSelection') ) {
546         # build the allowed item types loop
547         my $rs = $biblio->items->search_ordered(
548             undef,
549             {   select => [ { distinct => 'itype' } ],
550                 as     => 'item_type'
551             }
552         );
553
554         my @item_types =
555           grep { CanBookBeReserved( $borrowernumber, $biblioNum, $branch, { itemtype => $_ } )->{status} eq 'OK' }
556           $rs->get_column('item_type');
557
558         $biblioLoopIter{allowed_item_types} = \@item_types;
559     }
560
561     if ( $status eq 'recall' ) {
562         $biblioLoopIter{recall} = 1;
563     }
564
565     # For multiple holds per record, if a patron has previously placed a hold,
566     # the patron can only place more holds of the same type. That is, if the
567     # patron placed a record level hold, all the holds the patron places must
568     # be record level. If the patron placed an item level hold, all holds
569     # the patron places must be item level
570     my $forced_hold_level = Koha::Holds->search(
571         {
572             borrowernumber => $borrowernumber,
573             biblionumber   => $biblioNum,
574             found          => undef,
575         }
576     )->forced_hold_level();
577     if ($forced_hold_level) {
578         $biblioLoopIter{force_hold}   = 1 if $forced_hold_level eq 'item';
579         $biblioLoopIter{itemholdable} = 0 if $forced_hold_level eq 'record';
580         $biblioLoopIter{forced_hold_level} = $forced_hold_level;
581     }
582
583
584     push @$biblioLoop, \%biblioLoopIter;
585
586     $anyholdable = 1 if $biblioLoopIter{holdable};
587 }
588
589 unless ($pickup_locations->count) {
590     $numBibsAvailable = 0;
591     $anyholdable = 0;
592     $template->param(
593         message => 1,
594         no_pickup_locations => 1
595     );
596 }
597
598 if ( $numBibsAvailable == 0 || $anyholdable == 0) {
599     $template->param( none_available => 1 );
600 }
601
602 if (scalar @biblionumbers > 1) {
603     $template->param( multi_hold => 1);
604 }
605
606 my $show_notes=C4::Context->preference('OpacHoldNotes');
607 $template->param(OpacHoldNotes=>$show_notes);
608
609 # display infos
610 $template->param(bibitemloop => $biblioLoop);
611 # can set reserve date in future
612 if (
613     C4::Context->preference( 'AllowHoldDateInFuture' ) &&
614     C4::Context->preference( 'OPACAllowHoldDateInFuture' )
615     ) {
616     $template->param(
617             reserve_in_future         => 1,
618     );
619 }
620
621 output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };