Bug 6405: added enumchron to reserve copy list
[koha.git] / reserve / request.pl
1 #!/usr/bin/perl
2
3
4 #writen 2/1/00 by chris@katipo.oc.nz
5 # Copyright 2000-2002 Katipo Communications
6 # Parts Copyright 2011 Catalyst IT
7 #
8 # This file is part of Koha.
9 #
10 # Koha is free software; you can redistribute it and/or modify it under the
11 # terms of the GNU General Public License as published by the Free Software
12 # Foundation; either version 2 of the License, or (at your option) any later
13 # version.
14 #
15 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
16 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License along
20 # with Koha; if not, write to the Free Software Foundation, Inc.,
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22
23 =head1 request.pl
24
25 script to place reserves/requests
26
27 =cut
28
29 use strict;
30 use warnings;
31 use C4::Branch; # GetBranches get_branchinfos_of
32 use CGI;
33 use List::MoreUtils qw/uniq/;
34 use Date::Calc qw/Date_to_Days/;
35 use C4::Output;
36 use C4::Auth;
37 use C4::Reserves;
38 use C4::Biblio;
39 use C4::Items;
40 use C4::Koha;
41 use C4::Circulation;
42 use C4::Dates qw/format_date/;
43 use C4::Members;
44 use C4::Search;         # enabled_staff_search_views
45
46 my $dbh = C4::Context->dbh;
47 my $sth;
48 my $input = new CGI;
49 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
50     {
51         template_name   => "reserve/request.tmpl",
52         query           => $input,
53         type            => "intranet",
54         authnotrequired => 0,
55         flagsrequired   => { reserveforothers => 'place_holds' },
56     }
57 );
58
59 my $multihold = $input->param('multi_hold');
60 $template->param(multi_hold => $multihold);
61 my $showallitems = $input->param('showallitems');
62
63 # get Branches and Itemtypes
64 my $branches = GetBranches();
65 my $itemtypes = GetItemTypes();
66
67 my $default = C4::Context->userenv->{branch};
68 my @values;
69 my %label_of;
70
71 foreach my $branchcode (sort keys %{$branches} ) {
72     push @values, $branchcode;
73     $label_of{$branchcode} = $branches->{$branchcode}->{branchname};
74 }
75 my $CGIbranch = CGI::scrolling_list(
76                                     -name     => 'pickup',
77                                     -id          => 'pickup',
78                                     -values   => \@values,
79                                     -default  => $default,
80                                     -labels   => \%label_of,
81                                     -size     => 1,
82                                     -multiple => 0,
83                                    );
84
85 # Select borrowers infos
86 my $findborrower = $input->param('findborrower');
87 $findborrower = '' unless defined $findborrower;
88 $findborrower =~ s|,| |g;
89 my $borrowernumber_hold = $input->param('borrowernumber') || '';
90 my $borrowerslist;
91 my $messageborrower;
92 my $warnings;
93 my $messages;
94
95 my $date = C4::Dates->today('iso');
96 my $action = $input->param('action');
97 $action ||= q{};
98
99 if ( $action eq 'move' ) {
100   my $where = $input->param('where');
101   my $borrowernumber = $input->param('borrowernumber');
102   my $biblionumber = $input->param('biblionumber');
103   AlterPriority( $where, $borrowernumber, $biblionumber );
104 } elsif ( $action eq 'cancel' ) {
105   my $borrowernumber = $input->param('borrowernumber');
106   my $biblionumber = $input->param('biblionumber');
107   CancelReserve( $biblionumber, '', $borrowernumber );
108 } elsif ( $action eq 'setLowestPriority' ) {
109   my $borrowernumber = $input->param('borrowernumber');
110   my $biblionumber   = $input->param('biblionumber');
111   ToggleLowestPriority( $borrowernumber, $biblionumber );
112 }
113
114 if ($findborrower) {
115     my ( $count, $borrowers ) =
116       SearchMember($findborrower, 'cardnumber', 'web' );
117
118     my @borrowers = @$borrowers;
119
120     if ( !@borrowers ) {
121         $messageborrower = "'$findborrower'";
122     }
123     elsif ( @borrowers == 1 ) {
124         $borrowernumber_hold = $borrowers[0]->{'borrowernumber'};
125     }
126     else {
127         $borrowerslist = \@borrowers;
128     }
129 }
130
131 # If we have the borrowernumber because we've performed an action, then we
132 # don't want to try to place another reserve.
133 if ($borrowernumber_hold && !$action) {
134     my $borrowerinfo = GetMemberDetails( $borrowernumber_hold );
135     my $diffbranch;
136     my @getreservloop;
137     my $count_reserv = 0;
138     my $maxreserves;
139
140 #   we check the reserves of the borrower, and if he can reserv a document
141 # FIXME At this time we have a simple count of reservs, but, later, we could improve the infos "title" ...
142
143     my $number_reserves =
144       GetReserveCount( $borrowerinfo->{'borrowernumber'} );
145
146     if ( C4::Context->preference('maxreserves') && ($number_reserves >= C4::Context->preference('maxreserves')) ) {
147                 $warnings = 1;
148         $maxreserves = 1;
149     }
150
151     # we check the date expiry of the borrower (only if there is an expiry date, otherwise, set to 1 (warn)
152     my $expiry_date = $borrowerinfo->{dateexpiry};
153     my $expiry = 0; # flag set if patron account has expired
154     if ($expiry_date and $expiry_date ne '0000-00-00' and
155             Date_to_Days(split /-/,$date) > Date_to_Days(split /-/,$expiry_date)) {
156                 $messages = $expiry = 1;
157     }
158
159     # check if the borrower make the reserv in a different branch
160     if ( $borrowerinfo->{'branchcode'} ne C4::Context->userenv->{'branch'} ) {
161                 $messages = 1;
162         $diffbranch = 1;
163     }
164
165     $template->param(
166                 borrowernumber      => $borrowerinfo->{'borrowernumber'},
167                 borrowersurname     => $borrowerinfo->{'surname'},
168                 borrowerfirstname   => $borrowerinfo->{'firstname'},
169                 borrowerstreetaddress   => $borrowerinfo->{'address'},
170                 borrowercity        => $borrowerinfo->{'city'},
171                 borrowerphone       => $borrowerinfo->{'phone'},
172                 borrowermobile      => $borrowerinfo->{'mobile'},
173                 borrowerfax         => $borrowerinfo->{'fax'},
174                 borrowerphonepro    => $borrowerinfo->{'phonepro'},
175                 borroweremail       => $borrowerinfo->{'email'},
176                 borroweremailpro    => $borrowerinfo->{'emailpro'},
177                 borrowercategory    => $borrowerinfo->{'category'},
178                 borrowerreservs     => $count_reserv,
179                 cardnumber          => $borrowerinfo->{'cardnumber'},
180                 maxreserves         => $maxreserves,
181                 expiry              => $expiry,
182                 diffbranch          => $diffbranch,
183                                 messages            => $messages,
184                                 warnings            => $warnings
185     );
186 }
187
188 $template->param( messageborrower => $messageborrower );
189
190 my $CGIselectborrower;
191 if ($borrowerslist) {
192     my @values;
193     my %labels;
194
195     foreach my $borrower (
196         sort {
197                 $a->{surname}
198               . $a->{firstname} cmp $b->{surname}
199               . $b->{firstname}
200         } @{$borrowerslist}
201       )
202     {
203         push @values, $borrower->{borrowernumber};
204
205         $labels{ $borrower->{borrowernumber} } = sprintf(
206             '%s, %s ... (%s - %s) ... %s',
207             $borrower->{surname} ||'',    $borrower->{firstname} || '',
208             $borrower->{cardnumber} || '', $borrower->{categorycode} || '',
209             $borrower->{address} || '',
210         );
211     }
212
213     $CGIselectborrower = CGI::scrolling_list(
214         -name     => 'borrowernumber',
215         -values   => \@values,
216         -labels   => \%labels,
217         -size     => 7,
218         -multiple => 0,
219     );
220 }
221
222 # FIXME launch another time GetMemberDetails perhaps until
223 my $borrowerinfo = GetMemberDetails( $borrowernumber_hold );
224
225 my @biblionumbers = ();
226 my $biblionumbers = $input->param('biblionumbers');
227 if ($multihold) {
228     @biblionumbers = split '/', $biblionumbers;
229 } else {
230     push @biblionumbers, $input->param('biblionumber');
231 }
232
233 my $itemdata_enumchron = 0;
234 my @biblioloop = ();
235 foreach my $biblionumber (@biblionumbers) {
236
237     my %biblioloopiter = ();
238         my $maxreserves;
239
240     my $dat          = GetBiblioData($biblionumber);
241
242     unless ( CanBookBeReserved($borrowerinfo->{borrowernumber}, $biblionumber) ) {
243                 $warnings = 1;
244         $maxreserves = 1;
245     }
246     # get existing reserves .....
247     my ( $count, $reserves ) = GetReservesFromBiblionumber($biblionumber,1);
248     my $totalcount = $count;
249     my $alreadyreserved;
250
251     foreach my $res (@$reserves) {
252         if ( defined $res->{found} && $res->{found} eq 'W' ) {
253             $count--;
254         }
255
256         if ( defined $borrowerinfo && ($borrowerinfo->{borrowernumber} eq $res->{borrowernumber}) ) {
257             $warnings = 1;
258             $alreadyreserved = 1;
259             $biblioloopiter{warn} = 1;
260             $biblioloopiter{alreadyres} = 1;
261         }
262     }
263
264     $template->param( alreadyreserved => $alreadyreserved,
265                       messages => $messages,
266                       warnings => $warnings,
267                                           maxreserves=>$maxreserves
268                                           );
269
270
271     # FIXME think @optionloop, is maybe obsolete, or  must be switchable by a systeme preference fixed rank or not
272     # make priorities options
273
274     my @optionloop;
275     for ( 1 .. $count + 1 ) {
276         push(
277              @optionloop,
278              {
279               num      => $_,
280               selected => ( $_ == $count + 1 ),
281              }
282             );
283     }
284     # adding a fixed value for priority options
285     my $fixedRank = $count+1;
286
287     my @branchcodes;
288     my %itemnumbers_of_biblioitem;
289     my @itemnumbers;
290
291     ## $items is array of 'item' table numbers
292     if (my $items = get_itemnumbers_of($biblionumber)->{$biblionumber}){
293         @itemnumbers  = @$items;
294     }
295     else {
296         $template->param('noitems' => 1);
297         $biblioloopiter{noitems} = 1;
298     }
299
300     ## Hash of item number to 'item' table fields
301     my $iteminfos_of = GetItemInfosOf(@itemnumbers);
302
303     ## Here we go backwards again to create hash of biblioitemnumber to itemnumbers,
304     ## when by definition all of the itemnumber have the same biblioitemnumber
305     foreach my $itemnumber (@itemnumbers) {
306         my $biblioitemnumber = $iteminfos_of->{$itemnumber}->{biblioitemnumber};
307         push( @{ $itemnumbers_of_biblioitem{$biblioitemnumber} }, $itemnumber );
308     }
309
310     ## Should be same as biblionumber
311     my @biblioitemnumbers = keys %itemnumbers_of_biblioitem;
312
313     my $notforloan_label_of = get_notforloan_label_of();
314
315     ## Hash of biblioitemnumber to 'biblioitem' table records
316     my $biblioiteminfos_of  = GetBiblioItemInfosOf(@biblioitemnumbers);
317
318     my @bibitemloop;
319
320     foreach my $biblioitemnumber (@biblioitemnumbers) {
321         my $biblioitem = $biblioiteminfos_of->{$biblioitemnumber};
322         my $num_available = 0;
323         my $num_override  = 0;
324         my $hiddencount   = 0;
325
326         $biblioitem->{description} =
327           $itemtypes->{ $biblioitem->{itemtype} }{description};
328         $biblioloopiter{description} = $biblioitem->{description};
329         $biblioloopiter{itypename} = $biblioitem->{description};
330         $biblioloopiter{imageurl} =
331           getitemtypeimagelocation('intranet', $itemtypes->{$biblioitem->{itemtype}}{imageurl});
332
333         foreach my $itemnumber ( @{ $itemnumbers_of_biblioitem{$biblioitemnumber} } )    {
334             my $item = $iteminfos_of->{$itemnumber};
335
336             unless (C4::Context->preference('item-level_itypes')) {
337                 $item->{itype} = $biblioitem->{itemtype};
338             }
339
340             $item->{itypename} = $itemtypes->{ $item->{itype} }{description};
341             $item->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtypes->{ $item->{itype} }{imageurl} );
342             $item->{homebranchname} = $branches->{ $item->{homebranch} }{branchname};
343
344             # if the holdingbranch is different than the homebranch, we show the
345             # holdingbranch of the document too
346             if ( $item->{homebranch} ne $item->{holdingbranch} ) {
347                 $item->{holdingbranchname} =
348                   $branches->{ $item->{holdingbranch} }{branchname};
349             }
350
351             #   add information
352             $item->{itemcallnumber} = $item->{itemcallnumber};
353
354             # if the item is currently on loan, we display its return date and
355             # change the background color
356             my $issues= GetItemIssue($itemnumber);
357             if ( $issues->{'date_due'} ) {
358                 $item->{date_due} = format_date($issues->{'date_due'});
359                 $item->{backgroundcolor} = 'onloan';
360             }
361
362             # checking reserve
363             my ($reservedate,$reservedfor,$expectedAt) = GetReservesFromItemnumber($itemnumber);
364             my $ItemBorrowerReserveInfo = GetMemberDetails( $reservedfor, 0);
365
366             if ( defined $reservedate ) {
367                 $item->{backgroundcolor} = 'reserved';
368                 $item->{reservedate}     = format_date($reservedate);
369                 $item->{ReservedForBorrowernumber}     = $reservedfor;
370                 $item->{ReservedForSurname}     = $ItemBorrowerReserveInfo->{'surname'};
371                 $item->{ReservedForFirstname}     = $ItemBorrowerReserveInfo->{'firstname'};
372                 $item->{ExpectedAtLibrary}     = $branches->{$expectedAt}{branchname};
373
374             }
375
376             # Management of the notforloan document
377             if ( $item->{notforloan} ) {
378                 $item->{backgroundcolor} = 'other';
379                 $item->{notforloanvalue} =
380                   $notforloan_label_of->{ $item->{notforloan} };
381             }
382
383             # Management of lost or long overdue items
384             if ( $item->{itemlost} ) {
385
386                 # FIXME localized strings should never be in Perl code
387                 $item->{message} =
388                   $item->{itemlost} == 1 ? "(lost)"
389                     : $item->{itemlost} == 2 ? "(long overdue)"
390                       : "";
391                 $item->{backgroundcolor} = 'other';
392                 if (GetHideLostItemsPreference($borrowernumber) && !$showallitems) {
393                     $item->{hide} = 1;
394                     $hiddencount++;
395                 }
396             }
397
398             # Check the transit status
399             my ( $transfertwhen, $transfertfrom, $transfertto ) =
400               GetTransfers($itemnumber);
401
402             if ( defined $transfertwhen && $transfertwhen ne '' ) {
403                 $item->{transfertwhen} = format_date($transfertwhen);
404                 $item->{transfertfrom} =
405                   $branches->{$transfertfrom}{branchname};
406                 $item->{transfertto} = $branches->{$transfertto}{branchname};
407                 $item->{nocancel} = 1;
408             }
409
410             # If there is no loan, return and transfer, we show a checkbox.
411             $item->{notforloan} = $item->{notforloan} || 0;
412
413             # if independent branches is on we need to check if the person can reserve
414             # for branches they arent logged in to
415             if ( C4::Context->preference("IndependantBranches") ) {
416                 if (! C4::Context->preference("canreservefromotherbranches")){
417                     # cant reserve items so need to check if item homebranch and userenv branch match if not we cant reserve
418                     my $userenv = C4::Context->userenv;
419                     if ( ($userenv) && ( $userenv->{flags} % 2 != 1 ) ) {
420                         $item->{cantreserve} = 1 if ( $item->{homebranch} ne $userenv->{branch} );
421                     }
422                 }
423             }
424
425             my $branch = C4::Circulation::_GetCircControlBranch($item, $borrowerinfo);
426
427             my $branchitemrule = GetBranchItemRule( $branch, $item->{'itype'} );
428             my $policy_holdallowed = 1;
429
430             $item->{'holdallowed'} = $branchitemrule->{'holdallowed'};
431
432             if ( $branchitemrule->{'holdallowed'} == 0 ||
433                  ( $branchitemrule->{'holdallowed'} == 1 &&
434                      $borrowerinfo->{'branchcode'} ne $item->{'homebranch'} ) ) {
435                 $policy_holdallowed = 0;
436             }
437             
438             if (
439                    $policy_holdallowed
440                 && !$item->{cantreserve}
441                 && IsAvailableForItemLevelRequest($itemnumber)
442                 && CanItemBeReserved(
443                     $borrowerinfo->{borrowernumber}, $itemnumber
444                 )
445               )
446             {
447                 $item->{available} = 1;
448                 $num_available++;
449             }
450             elsif ( C4::Context->preference('AllowHoldPolicyOverride') ) {
451
452 # If AllowHoldPolicyOverride is set, it should override EVERY restriction, not just branch item rules
453                 $item->{override} = 1;
454                 $num_override++;
455             }
456
457             # If none of the conditions hold true, then neither override nor available is set and the item cannot be checked
458
459             # FIXME: move this to a pm
460             my $sth2 = $dbh->prepare("SELECT * FROM reserves WHERE borrowernumber=? AND itemnumber=? AND found='W'");
461             $sth2->execute($item->{ReservedForBorrowernumber},$item->{itemnumber});
462             while (my $wait_hashref = $sth2->fetchrow_hashref) {
463                 $item->{waitingdate} = format_date($wait_hashref->{waitingdate});
464             }
465
466             # Show serial enumeration when needed
467             if ($item->{enumchron}) {
468                 $itemdata_enumchron = 1;
469             }
470
471             push @{ $biblioitem->{itemloop} }, $item;
472         }
473
474         if ( $num_override == scalar( @{ $biblioitem->{itemloop} } ) ) { # That is, if all items require an override
475             $template->param( override_required => 1 );
476         } elsif ( $num_available == 0 ) {
477             $template->param( none_available => 1 );
478             $template->param( warnings => 1 );
479             $biblioloopiter{warn} = 1;
480             $biblioloopiter{none_avail} = 1;
481         }
482         $template->param( hiddencount => $hiddencount);
483
484         push @bibitemloop, $biblioitem;
485     }
486
487     # existingreserves building
488     my @reserveloop;
489     ( $count, $reserves ) = GetReservesFromBiblionumber($biblionumber,1);
490     foreach my $res ( sort {
491             my $a_found = $a->{found} || '';
492             my $b_found = $a->{found} || '';
493             $a_found cmp $b_found;
494         } @$reserves ) {
495         my %reserve;
496         my @optionloop;
497         for ( my $i = 1 ; $i <= $totalcount ; $i++ ) {
498             push(
499                  @optionloop,
500                  {
501                   num      => $i,
502                   selected => ( $i == $res->{priority} ),
503                  }
504                 );
505         }
506
507         if ( defined $res->{'found'} && $res->{'found'} eq 'W' || $res->{'found'} eq 'T' ) {
508             my $item = $res->{'itemnumber'};
509             $item = GetBiblioFromItemNumber($item,undef);
510             $reserve{'wait'}= 1;
511             $reserve{'holdingbranch'}=$item->{'holdingbranch'};
512             $reserve{'biblionumber'}=$item->{'biblionumber'};
513             $reserve{'barcodenumber'}   = $item->{'barcode'};
514             $reserve{'wbrcode'} = $res->{'branchcode'};
515             $reserve{'itemnumber'}  = $res->{'itemnumber'};
516             $reserve{'wbrname'} = $branches->{$res->{'branchcode'}}->{'branchname'};
517             if($reserve{'holdingbranch'} eq $reserve{'wbrcode'}){
518                 $reserve{'atdestination'} = 1;
519             }
520             # set found to 1 if reserve is waiting for patron pickup
521             $reserve{'found'} = 1 if $res->{'found'} eq 'W';
522             $reserve{'intransit'} = 1 if $res->{'found'} eq 'T';
523         } elsif ($res->{priority} > 0) {
524             if (defined($res->{itemnumber})) {
525                 my $item = GetItem($res->{itemnumber});
526                 $reserve{'itemnumber'}  = $res->{'itemnumber'};
527                 $reserve{'barcodenumber'}   = $item->{'barcode'};
528                 $reserve{'item_level_hold'} = 1;
529             }
530         }
531
532         #     get borrowers reserve info
533         my $reserveborrowerinfo = GetMemberDetails( $res->{'borrowernumber'}, 0);
534         if (C4::Context->preference('HidePatronName')){
535             $reserve{'hidename'} = 1;
536             $reserve{'cardnumber'} = $reserveborrowerinfo->{'cardnumber'};
537         }
538         $reserve{'expirationdate'} = format_date( $res->{'expirationdate'} )
539             unless ( !defined($res->{'expirationdate'}) || $res->{'expirationdate'} eq '0000-00-00' );
540         $reserve{'date'}           = format_date( $res->{'reservedate'} );
541         $reserve{'borrowernumber'} = $res->{'borrowernumber'};
542         $reserve{'biblionumber'}   = $res->{'biblionumber'};
543         $reserve{'borrowernumber'} = $res->{'borrowernumber'};
544         $reserve{'firstname'}      = $reserveborrowerinfo->{'firstname'};
545         $reserve{'surname'}        = $reserveborrowerinfo->{'surname'};
546         $reserve{'notes'}          = $res->{'reservenotes'};
547         $reserve{'wait'}           =
548           ( ( defined $res->{'found'} and $res->{'found'} eq 'W' ) or ( $res->{'priority'} eq '0' ) );
549         $reserve{'constrainttypea'} = ( $res->{'constrainttype'} eq 'a' );
550         $reserve{'constrainttypeo'} = ( $res->{'constrainttype'} eq 'o' );
551         $reserve{'voldesc'}         = $res->{'volumeddesc'};
552         $reserve{'ccode'}           = $res->{'ccode'};
553         $reserve{'barcode'}         = $res->{'barcode'};
554         $reserve{'priority'}    = $res->{'priority'};
555         $reserve{'lowestPriority'}    = $res->{'lowestPriority'};
556         $reserve{'branchloop'} = GetBranchesLoop($res->{'branchcode'});
557         $reserve{'optionloop'} = \@optionloop;
558
559         push( @reserveloop, \%reserve );
560     }
561
562     # get the time for the form name...
563     my $time = time();
564
565     $template->param(
566                      CGIbranch   => $CGIbranch,
567
568                      time        => $time,
569                      fixedRank   => $fixedRank,
570                     );
571
572     # display infos
573     $template->param(
574                      optionloop        => \@optionloop,
575                      bibitemloop       => \@bibitemloop,
576                      itemdata_enumchron => $itemdata_enumchron,
577                      date              => $date,
578                      biblionumber      => $biblionumber,
579                      findborrower      => $findborrower,
580                      title             => $dat->{title},
581                      author            => $dat->{author},
582                      holdsview => 1,
583                      C4::Search::enabled_staff_search_views,
584                     );
585     if (defined $borrowerinfo && exists $borrowerinfo->{'branchcode'}) {
586         $template->param(
587                      borrower_branchname => $branches->{$borrowerinfo->{'branchcode'}}->{'branchname'},
588                      borrower_branchcode => $borrowerinfo->{'branchcode'},
589         );
590     }
591     $template->param(CGIselectborrower => $CGIselectborrower) if defined $CGIselectborrower;
592
593     $biblioloopiter{biblionumber} = $biblionumber;
594     $biblioloopiter{title} = $dat->{title};
595     $biblioloopiter{rank} = $fixedRank;
596     $biblioloopiter{reserveloop} = \@reserveloop;
597
598     if (@reserveloop) {
599         $template->param( reserveloop => \@reserveloop );
600     }
601
602     push @biblioloop, \%biblioloopiter;
603 }
604
605 $template->param( biblioloop => \@biblioloop );
606 $template->param( biblionumbers => $biblionumbers );
607 $template->param( DHTMLcalendar_dateformat  => C4::Dates->DHTMLcalendar() );
608
609 if ($multihold) {
610     $template->param( multi_hold => 1 );
611 }
612
613 if ( C4::Context->preference( 'AllowHoldDateInFuture' ) ) {
614     $template->param( reserve_in_future => 1 );
615 }
616
617 # printout the page
618 output_html_with_http_headers $input, $cookie, $template->output;