adding back my @issued_itemtypes_count_loop;
[koha.git] / circ / circulation.pl
1 #!/usr/bin/perl
2
3 # Please use 8-character tabs for this file (indents are every 4 characters)
4
5 # written 8/5/2002 by Finlay
6 # script to execute issuing of books
7
8 # Copyright 2000-2002 Katipo Communications
9 #
10 # This file is part of Koha.
11 #
12 # Koha is free software; you can redistribute it and/or modify it under the
13 # terms of the GNU General Public License as published by the Free Software
14 # Foundation; either version 2 of the License, or (at your option) any later
15 # version.
16 #
17 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
18 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
19 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License along with
22 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
23 # Suite 330, Boston, MA  02111-1307 USA
24
25 use strict;
26 use CGI;
27 use C4::Output;
28 use C4::Print;
29 use C4::Auth;
30 use C4::Date;
31 use C4::Branch; # GetBranches
32 use C4::Koha;   # GetPrinter
33 use C4::Circulation;
34 use C4::Members;
35 use C4::Biblio;
36 use C4::Reserves;
37 use C4::Context;
38 use CGI::Session;
39
40 use Date::Calc qw(
41   Today
42   Today_and_Now
43   Add_Delta_YM
44   Add_Delta_Days
45   Date_to_Days
46 );
47
48
49 #
50 # PARAMETERS READING
51 #
52 my $query = new CGI;
53
54 # new op dev the branch and the printer are now defined by the userenv
55 # but first we have to check if someone has tried to change them
56
57 my $branch = $query->param('branch');
58 if ($branch){
59     # update our session so the userenv is updated
60     my $dbh=C4::Context->dbh;
61     my $sessionID = $query->cookie("CGISESSID") ;
62     my $session = new CGI::Session("driver:MySQL", $sessionID, {Handle=>$dbh});
63     $session->param('branch',$branch);
64     my $branchname = GetBranchName($branch);
65     $session->param('branchname',$branchname);
66 }
67
68 my $printer = $query->param('printer');
69 if ($printer){
70     # update our session so the userenv is updated
71         my $dbh=C4::Context->dbh;
72         my $sessionID = $query->cookie("CGISESSID") ;
73         my $session = new CGI::Session("driver:MySQL", $sessionID, {Handle=>$dbh});
74         $session->param('branchprinter',$printer);
75
76 }
77
78
79 my ( $template, $loggedinuser, $cookie ) = get_template_and_user (
80     {
81         template_name   => 'circ/circulation.tmpl',
82         query           => $query,
83         type            => "intranet",
84         authnotrequired => 0,
85         flagsrequired   => { circulate => 1 },
86     }
87 );
88 my $branches = GetBranches();
89
90 my $printers = GetPrinters();
91
92
93 my $findborrower = $query->param('findborrower');
94 $findborrower =~ s|,| |g;
95 #$findborrower =~ s|'| |g;
96 my $borrowernumber = $query->param('borrowernumber');
97
98 $branch  = C4::Context->userenv->{'branch'};    
99 $printer = C4::Context->userenv->{'branchprinter'};
100
101
102 # If Autolocated is not activated, we show the Circulation Parameters to chage settings of librarian
103     if (C4::Context->preference("AutoLocation") ne 1)
104         {
105             $template->param(
106             ManualLocation => 1,
107             );
108         }
109
110 my $barcode        = $query->param('barcode') || '';
111 my $year           = $query->param('year');
112 my $month          = $query->param('month');
113 my $day            = $query->param('day');
114 my $stickyduedate  = $query->param('stickyduedate');
115 my $issueconfirmed = $query->param('issueconfirmed');
116 my $cancelreserve  = $query->param('cancelreserve');
117 my $organisation   = $query->param('organisations');
118 my $print          = $query->param('print');
119
120 #set up cookie.....
121 # my $branchcookie;
122 # my $printercookie;
123 # if ($query->param('setcookies')) {
124 #     $branchcookie = $query->cookie(-name=>'branch', -value=>"$branch", -expires=>'+1y');
125 #     $printercookie = $query->cookie(-name=>'printer', -value=>"$printer", -expires=>'+1y');
126 # }
127 #
128
129
130 my @datearr = localtime( time() );
131
132 # FIXME - Could just use POSIX::strftime("%Y%m%d", localtime);
133 my $todaysdate =
134     ( 1900 + $datearr[5] )
135   . sprintf( "%0.2d", ( $datearr[4] + 1 ) )
136   . sprintf( "%0.2d", ( $datearr[3] ) );
137
138 # check and see if we should print
139 if ( $barcode eq '' && $print eq 'maybe' ) {
140     $print = 'yes';
141 }
142
143 my $inprocess = ($barcode eq '') ? '' : $query->param('inprocess');
144
145 if ( $barcode eq '' && $query->param('charges') eq 'yes' ) {
146     $template->param(
147         PAYCHARGES     => 'yes',
148         borrowernumber => $borrowernumber
149     );
150 }
151
152 if ( $print eq 'yes' && $borrowernumber ne '' ) {
153     printslip( $borrowernumber );
154     $query->param( 'borrowernumber', '' );
155     $borrowernumber = '';
156 }
157
158 #
159 # STEP 2 : FIND BORROWER
160 # if there is a list of find borrowers....
161 #
162 my $borrowerslist;
163 my $message;
164 if ($findborrower) {
165     my ( $count, $borrowers ) =
166       SearchMember($findborrower, 'cardnumber', 'web' );
167     my @borrowers = @$borrowers;
168     if ( $#borrowers == -1 ) {
169         $query->param( 'findborrower', '' );
170         $message = "'$findborrower'";
171     }
172     elsif ( $#borrowers == 0 ) {
173         $query->param( 'borrowernumber', $borrowers[0]->{'borrowernumber'} );
174         $query->param( 'barcode',           '' );
175         $borrowernumber = $borrowers[0]->{'borrowernumber'};
176     }
177     else {
178         $borrowerslist = \@borrowers;
179     }
180 }
181
182 # get the borrower information.....
183 my $borrower;
184 my @lines;
185
186 if ($borrowernumber) {
187     $borrower = GetMemberDetails( $borrowernumber, 0 );
188     my ( $od, $issue, $fines ) = GetMemberIssuesAndFines( $borrowernumber );
189
190     # Warningdate is the date that the warning starts appearing
191     my ( $today_year,   $today_month,   $today_day )   = Today();
192     my ( $warning_year, $warning_month, $warning_day ) = split /-/,
193       $borrower->{'dateexpiry'};
194     my ( $enrol_year, $enrol_month, $enrol_day ) = split /-/,
195       $borrower->{'dateenrolled'};
196     # Renew day is calculated by adding the enrolment period to today
197     my ( $renew_year, $renew_month, $renew_day ) =
198       Add_Delta_YM( $enrol_year, $enrol_month, $enrol_day,
199         0 , $borrower->{'enrolmentperiod'}) if ($enrol_year*$enrol_month*$enrol_day>0);
200     # if the expiry date is before today
201     if ( $warning_year*$warning_month*$warning_day==0 
202       || Date_to_Days( $today_year, $today_month, $today_day ) 
203          > Date_to_Days( $warning_year, $warning_month, $warning_day ) )
204     {
205
206         #borrowercard expired or nearly expired, warn the librarian
207         $template->param(
208             flagged       => "1",
209             warndeparture => format_date($borrower->{dateexpiry}),
210             renewaldate   => format_date("$renew_year-$renew_month-$renew_day")
211         );
212     }
213     # check for NotifyBorrowerDeparture
214         if ($warning_year*$warning_month*$warning_day==0 
215       || (C4::Context->preference('NotifyBorrowerDeparture') &&
216             Date_to_Days(Add_Delta_Days($warning_year,$warning_month,$warning_day,- C4::Context->preference('NotifyBorrowerDeparture'))) <
217             Date_to_Days( $today_year, $today_month, $today_day )) ) 
218         {
219             $template->param("warndeparture" => format_date($borrower->{dateexpiry}));
220         }
221     $template->param(
222         overduecount => $od,
223         issuecount   => $issue,
224         finetotal    => $fines
225     );
226 }
227
228 #
229 # STEP 3 : ISSUING
230 #
231 #
232
233 if ($barcode) {
234     $barcode = cuecatbarcodedecode($barcode);
235     my ( $datedue, $invalidduedate ) = fixdate( $year, $month, $day );
236     if ($issueconfirmed) {
237         AddIssue( $borrower, $barcode, $datedue, $cancelreserve );
238         $inprocess = 1;
239     }
240     else {
241         my ( $error, $question ) =
242           CanBookBeIssued( $borrower, $barcode, $year, $month, $day,
243             $inprocess );
244         my $noerror    = 1;
245         my $noquestion = 1;
246 #         Get the item title for more information
247         my $getmessageiteminfo  = GetBiblioFromItemNumber($barcode);
248     
249         foreach my $impossible ( keys %$error ) {
250             $template->param(
251                 $impossible => $$error{$impossible},
252                 IMPOSSIBLE  => 1
253             );
254             $noerror = 0;
255         }
256         foreach my $needsconfirmation ( keys %$question ) {
257             $template->param(
258                 $needsconfirmation => $$question{$needsconfirmation},
259                 getTitleMessageIteminfo => $getmessageiteminfo->{'title'},
260                 NEEDSCONFIRMATION  => 1
261             );
262             $noquestion = 0;
263         }
264         $template->param(
265             day   => $day,
266             month => $month,
267             year  => $year
268         );
269         if ( $noerror && ( $noquestion || $issueconfirmed ) ) {
270             AddIssue( $borrower, $barcode, $datedue );
271             $inprocess = 1;
272         }
273     }
274     
275 # FIXME If the issue is confirmed, we launch another time borrdata2, now display the issue count after issue 
276         my ( $od, $issue, $fines ) = GetMemberIssuesAndFines( $borrowernumber );
277         $template->param(
278         issuecount   => $issue,
279         );
280 }
281
282 # reload the borrower info for the sake of reseting the flags.....
283 if ($borrowernumber) {
284     $borrower = GetMemberDetails( $borrowernumber, 0 );
285 }
286
287 ##################################################################################
288 # BUILD HTML
289 # show all reserves of this borrower, and the position of the reservation ....
290 if ($borrowernumber) {
291
292     # new op dev
293     # now we show the status of the borrower's reservations
294     my @borrowerreserv = GetReservesFromBorrowernumber($borrowernumber );
295     my @reservloop;
296     my @WaitingReserveLoop;
297     
298     foreach my $num_res (@borrowerreserv) {
299         my %getreserv;
300         my %getWaitingReserveInfo;
301         my $getiteminfo  = GetBiblioFromItemNumber( $num_res->{'itemnumber'} );
302         my $itemtypeinfo = getitemtypeinfo( (C4::Context->preference('item-level_itype')) ? $getiteminfo->{'ccode'} : $getiteminfo->{'itemtype'} );
303         my ( $transfertwhen, $transfertfrom, $transfertto ) =
304           GetTransfers( $num_res->{'itemnumber'} );
305
306         $getreserv{waiting}       = 0;
307         $getreserv{transfered}    = 0;
308         $getreserv{nottransfered} = 0;
309
310         $getreserv{reservedate}    = format_date( $num_res->{'reservedate'} );
311         $getreserv{title}          = $getiteminfo->{'title'};
312         $getreserv{itemtype}       = $itemtypeinfo->{'description'};
313         $getreserv{author}         = $getiteminfo->{'author'};
314         $getreserv{barcodereserv}  = $getiteminfo->{'barcode'};
315         $getreserv{itemcallnumber} = $getiteminfo->{'itemcallnumber'};
316
317         #         check if we have a waiting status for reservations
318         if ( $num_res->{'found'} eq 'W' ) {
319             $getreserv{color}   = 'reserved';
320             $getreserv{waiting} = 1;
321 #     genarate information displaying only waiting reserves
322         $getWaitingReserveInfo{title}        = $getiteminfo->{'title'};
323         $getWaitingReserveInfo{biblionumber}   = $getiteminfo->{'biblionumber'};
324         $getWaitingReserveInfo{itemtype}    = $itemtypeinfo->{'description'};
325         $getWaitingReserveInfo{author}        = $getiteminfo->{'author'};
326         $getWaitingReserveInfo{reservedate}    = format_date( $num_res->{'reservedate'} );
327         if ($getiteminfo->{'holdingbranch'} ne $num_res->{'branchcode'} ) {
328         $getWaitingReserveInfo{waitingat}    = GetBranchName( $num_res->{'branchcode'} );
329         }
330     
331         }
332         #         check transfers with the itemnumber foud in th reservation loop
333         if ($transfertwhen) {
334             $getreserv{color}      = 'transfered';
335             $getreserv{transfered} = 1;
336             $getreserv{datesent}   = format_date($transfertwhen);
337             $getreserv{frombranch} = GetBranchName($transfertfrom);
338         }
339
340         if ( ( $getiteminfo->{'holdingbranch'} ne $num_res->{'branchcode'} )
341             and not $transfertwhen )
342         {
343             $getreserv{nottransfered}   = 1;
344             $getreserv{nottransferedby} =
345               GetBranchName( $getiteminfo->{'holdingbranch'} );
346         }
347
348 #         if we don't have a reserv on item, we put the biblio infos and the waiting position
349         if ( $getiteminfo->{'title'} eq '' ) {
350             my $getbibinfo = GetBiblioItemData( $num_res->{'biblionumber'} );
351             my $getbibtype = getitemtypeinfo( $getbibinfo->{'itemtype'} );  # fixme - we should have item-level reserves here ?
352             $getreserv{color}           = 'inwait';
353             $getreserv{title}           = $getbibinfo->{'title'};
354             $getreserv{waitingposition} = $num_res->{'priority'};
355             $getreserv{nottransfered}   = 0;
356             $getreserv{itemtype}        = $getbibtype->{'description'};
357             $getreserv{author}          = $getbibinfo->{'author'};
358             $getreserv{itemcallnumber}  = '----------';
359
360         }
361         push( @reservloop, \%getreserv );
362
363 #         if we have a reserve waiting, initiate waitingreserveloop
364         if ($getreserv{waiting} eq 1) {
365         push (@WaitingReserveLoop, \%getWaitingReserveInfo)
366         }
367       
368     }
369
370     # return result to the template
371     $template->param( 
372         countreserv => scalar @reservloop,
373         reservloop  => \@reservloop ,
374         WaitingReserveLoop  => \@WaitingReserveLoop,
375     );
376 }
377
378 # make the issued books table.
379 my $todaysissues = '';
380 my $previssues   = '';
381 my @todaysissues;
382 my @previousissues;
383 my $allowborrow;
384 ## ADDED BY JF: new itemtype issuingrules counter stuff
385 my $issued_itemtypes_loop;
386 my $issued_itemtypes_count;
387 my $issued_itemtypes_allowed_count;    # hashref with total allowed by itemtype
388 my $issued_itemtypes_remaining;        # hashref with remaining
389 my $issued_itemtypes_flags;            #hashref that stores flags
390
391 if ($borrower) {
392
393 # get each issue of the borrower & separate them in todayissues & previous issues
394     my ($countissues,$issueslist) = GetPendingIssues($borrower->{'borrowernumber'});
395
396     # split in 2 arrays for today & previous
397     foreach my $it ( @$issueslist ) {
398         my $issuedate = $it->{'issuedate'};
399         $issuedate =~ s/-//g;
400         $issuedate = substr( $issuedate, 0, 8 );
401                 ($it->{'charge'}, $it->{'itemtype_charge'}) = GetIssuingCharges(
402                                                 $it->{'itemnumber'}, $borrower->{'borrowernumber'}
403                 );
404                 $it->{'charge'} = sprintf("%.2f", $it->{'charge'});
405         ($it->{'can_renew'}, $it->{'can_renew_error'}) = CanBookBeRenewed( 
406                                                 $borrower->{'borrowernumber'},$it->{'itemnumber'}
407                 );
408                 my ($restype, $reserves) = CheckReserves($it->{'itemnumber'});
409                 ($restype) and $it->{'can_renew'} = 0;
410
411                 $it->{'dd'} = format_date($it->{'date_due'});
412         my $datedue = $it->{'date_due'};
413         $datedue =~ s/-//g;
414                 $it->{'od'} = ($datedue < $todaysdate) ? 1 : 0 ;
415         ($it->{'author'} eq '') and $it->{'author'} = ' ';
416
417         # ADDED BY JF: NEW ITEMTYPE COUNT DISPLAY
418         $issued_itemtypes_count->{ $it->{'itemtype'} }++;
419
420         if ( $todaysdate == $issuedate ) {
421             push @todaysissues, $it;
422         } else {
423             push @previousissues, $it;
424         }
425     }
426     @todaysissues   = sort { $b->{'timestamp'} <=> $a->{'timestamp'} } @todaysissues;
427     @previousissues = sort { $b->{'date_due' } <=> $a->{'date_due' } } @previousissues;
428     my $i = 1;
429         foreach my $book (@todaysissues) {
430         $book->{'togglecolor'} = (++$i % 2) ? 0 : 1 ;
431     }
432     $i = 1;
433         foreach my $book (@previousissues) {
434         $book->{'togglecolor'} = (++$i % 2) ? 0 : 1 ;
435     }
436 }
437
438 #### ADDED BY JF FOR COUNTS BY ITEMTYPE RULES
439 # FIXME: This should utilize all the issuingrules options rather than just the defaults
440 # and it should be moved to a module
441 my $dbh = C4::Context->dbh;
442
443 # how many of each is allowed?
444 my $issueqty_sth = $dbh->prepare( "
445 SELECT itemtypes.description AS description,issuingrules.itemtype,maxissueqty
446 FROM issuingrules
447   LEFT JOIN itemtypes ON (itemtypes.itemtype=issuingrules.itemtype)
448   WHERE categorycode=?
449 " );
450 #my @issued_itemtypes_count;  # huh?
451 my @issued_itemtypes_count_loop;
452 $issueqty_sth->execute("*");
453 while ( my $data = $issueqty_sth->fetchrow_hashref() ) {
454
455     # subtract how many of each this borrower has
456     $data->{'count'} = $issued_itemtypes_count->{ $data->{'description'} };  
457     $data->{'left'}  =
458       ( $data->{'maxissueqty'} -
459           $issued_itemtypes_count->{ $data->{'description'} } );
460
461     # can't have a negative number of remaining
462     if ( $data->{'left'} < 0 ) { $data->{'left'} = "0" }
463     $data->{'flag'} = 1 unless ( $data->{'maxissueqty'} > $data->{'count'} );
464     unless ( ( $data->{'maxissueqty'} < 1 )
465         || ( $data->{'itemtype'} eq "*" )
466         || ( $data->{'itemtype'} eq "CIRC" ) )
467     {
468         push @issued_itemtypes_count_loop, $data;
469     }
470 }
471 $issued_itemtypes_loop = \@issued_itemtypes_count_loop;
472
473 #### / JF
474
475 my @values;
476 my %labels;
477 my $CGIselectborrower;
478 if ($borrowerslist) {
479     foreach (
480         sort {
481                 $a->{'surname'}
482               . $a->{'firstname'} cmp $b->{'surname'}
483               . $b->{'firstname'}
484         } @$borrowerslist
485       )
486     {
487         push @values, $_->{'borrowernumber'};
488         $labels{ $_->{'borrowernumber'} } =
489 "$_->{'surname'}, $_->{'firstname'} ... ($_->{'cardnumber'} - $_->{'categorycode'}) ...  $_->{'address'} ";
490     }
491     $CGIselectborrower = CGI::scrolling_list(
492         -name     => 'borrowernumber',
493                 -class     => 'focus',
494                 -id          => 'borrowernumber',
495         -values   => \@values,
496         -labels   => \%labels,
497         -size     => 7,
498         -tabindex => '',
499         -multiple => 0
500     );
501 }
502
503 #title
504 my $flags = $borrower->{'flags'};
505 my $flag;
506
507 foreach $flag ( sort keys %$flags ) {
508
509     $flags->{$flag}->{'message'} =~ s/\n/<br>/g;
510     if ( $flags->{$flag}->{'noissues'} ) {
511         $template->param(
512             flagged  => 1,
513             noissues => 'true',
514         );
515         if ( $flag eq 'GNA' ) {
516             $template->param( gna => 'true' );
517         }
518         if ( $flag eq 'LOST' ) {
519             $template->param( lost => 'true' );
520         }
521         if ( $flag eq 'DBARRED' ) {
522             $template->param( dbarred => 'true' );
523         }
524         if ( $flag eq 'CHARGES' ) {
525             $template->param(
526                 charges    => 'true',
527                 chargesmsg => $flags->{'CHARGES'}->{'message'}
528             );
529         }
530         if ( $flag eq 'CREDITS' ) {
531             $template->param(
532                 credits    => 'true',
533                 creditsmsg => $flags->{'CREDITS'}->{'message'}
534             );
535         }
536     }
537     else {
538         if ( $flag eq 'CHARGES' ) {
539             $template->param(
540                 charges    => 'true',
541                 flagged    => 1,
542                 chargesmsg => $flags->{'CHARGES'}->{'message'}
543             );
544         }
545         if ( $flag eq 'CREDITS' ) {
546             $template->param(
547                 credits    => 'true',
548                 creditsmsg => $flags->{'CREDITS'}->{'message'}
549             );
550         }
551         if ( $flag eq 'ODUES' ) {
552             $template->param(
553                 odues    => 'true',
554                 flagged  => 1,
555                 oduesmsg => $flags->{'ODUES'}->{'message'}
556             );
557
558             my $items = $flags->{$flag}->{'itemlist'};
559 # useless ???
560 #             {
561 #                 my @itemswaiting;
562 #                 foreach my $item (@$items) {
563 #                     my ($iteminformation) =
564 #                         getiteminformation( $item->{'itemnumber'}, 0 );
565 #                     push @itemswaiting, $iteminformation;
566 #                 }
567 #             }
568             if ( $query->param('module') ne 'returns' ) {
569                 $template->param( nonreturns => 'true' );
570             }
571         }
572         if ( $flag eq 'NOTES' ) {
573             $template->param(
574                 notes    => 'true',
575                 flagged  => 1,
576                 notesmsg => $flags->{'NOTES'}->{'message'}
577             );
578         }
579     }
580 }
581
582 my $amountold = $borrower->{flags}->{'CHARGES'}->{'message'} || 0;
583 my @temp = split( /\$/, $amountold );
584
585 my $CGIorganisations;
586 my $member_of_institution;
587 if ( C4::Context->preference("memberofinstitution") ) {
588     my $organisations = get_institutions();
589     my @orgs;
590     my %org_labels;
591     foreach my $organisation ( keys %$organisations ) {
592         push @orgs, $organisation;
593         $org_labels{$organisation} =
594           $organisations->{$organisation}->{'surname'};
595     }
596     $member_of_institution = 1;
597     $CGIorganisations      = CGI::popup_menu(
598         -id     => 'organisations',
599         -name   => 'organisations',
600         -labels => \%org_labels,
601         -values => \@orgs,
602     );
603 }
604
605 $amountold = $temp[1];
606
607 $template->param(
608     issued_itemtypes_count_loop => $issued_itemtypes_loop,
609     findborrower                => $findborrower,
610     borrower                    => $borrower,
611     borrowernumber              => $borrowernumber,
612     branch                      => $branch,
613     printer                     => $printer,
614     printername                 => $printer,
615     firstname                   => $borrower->{'firstname'},
616     surname                     => $borrower->{'surname'},
617     expiry                      =>
618       $borrower->{'dateexpiry'},    #format_date($borrower->{'dateexpiry'}),
619     categorycode      => $borrower->{'categorycode'},
620     address     => $borrower->{'address'},
621     address2     => $borrower->{'address2'},
622     email      => $borrower->{'email'},
623         emailpro           => $borrower->{'emailpro'},
624     borrowernotes     => $borrower->{'borrowernotes'},
625     city              => $borrower->{'city'},
626     phone             => $borrower->{'phone'} || $borrower->{'mobile'},
627     cardnumber        => $borrower->{'cardnumber'},
628     amountold         => $amountold,
629     barcode           => $barcode,
630     stickyduedate     => $stickyduedate,
631     message           => $message,
632     CGIselectborrower => $CGIselectborrower,
633     todayissues       => \@todaysissues,
634     previssues        => \@previousissues,
635     inprocess         => $inprocess,
636     memberofinstution => $member_of_institution,
637     CGIorganisations  => $CGIorganisations,
638 );
639
640 # set return date if stickyduedate
641 if ($stickyduedate) {
642     my $t_year  = "year" . $year;
643     my $t_month = "month" . $month;
644     my $t_day   = "day" . $day;
645     $template->param(
646         $t_year  => 1,
647         $t_month => 1,
648         $t_day   => 1,
649     );
650 }
651
652 #if ($branchcookie) {
653 #$cookie=[$cookie, $branchcookie, $printercookie];
654 #}
655
656 $template->param(
657     SpecifyDueDate     => C4::Context->preference("SpecifyDueDate")
658 );
659 $template->param( CircAutocompl => C4::Context->preference("CircAutocompl") );
660 output_html_with_http_headers $query, $cookie, $template->output;