fixed redefined itemtype_count variable .
[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_loop;  # huh?
451 $issueqty_sth->execute("*");
452 while ( my $data = $issueqty_sth->fetchrow_hashref() ) {
453
454     # subtract how many of each this borrower has
455     $data->{'count'} = $issued_itemtypes_count->{ $data->{'description'} };  
456     $data->{'left'}  =
457       ( $data->{'maxissueqty'} -
458           $issued_itemtypes_count->{ $data->{'description'} } );
459
460     # can't have a negative number of remaining
461     if ( $data->{'left'} < 0 ) { $data->{'left'} = "0" }
462     $data->{'flag'} = 1 unless ( $data->{'maxissueqty'} > $data->{'count'} );
463     unless ( ( $data->{'maxissueqty'} < 1 )
464         || ( $data->{'itemtype'} eq "*" )
465         || ( $data->{'itemtype'} eq "CIRC" ) )
466     {
467         push @issued_itemtypes_count_loop, $data;
468     }
469 }
470 $issued_itemtypes_loop = \@issued_itemtypes_count_loop;
471
472 #### / JF
473
474 my @values;
475 my %labels;
476 my $CGIselectborrower;
477 if ($borrowerslist) {
478     foreach (
479         sort {
480                 $a->{'surname'}
481               . $a->{'firstname'} cmp $b->{'surname'}
482               . $b->{'firstname'}
483         } @$borrowerslist
484       )
485     {
486         push @values, $_->{'borrowernumber'};
487         $labels{ $_->{'borrowernumber'} } =
488 "$_->{'surname'}, $_->{'firstname'} ... ($_->{'cardnumber'} - $_->{'categorycode'}) ...  $_->{'address'} ";
489     }
490     $CGIselectborrower = CGI::scrolling_list(
491         -name     => 'borrowernumber',
492                 -class     => 'focus',
493                 -id          => 'borrowernumber',
494         -values   => \@values,
495         -labels   => \%labels,
496         -size     => 7,
497         -tabindex => '',
498         -multiple => 0
499     );
500 }
501
502 #title
503 my $flags = $borrower->{'flags'};
504 my $flag;
505
506 foreach $flag ( sort keys %$flags ) {
507
508     $flags->{$flag}->{'message'} =~ s/\n/<br>/g;
509     if ( $flags->{$flag}->{'noissues'} ) {
510         $template->param(
511             flagged  => 1,
512             noissues => 'true',
513         );
514         if ( $flag eq 'GNA' ) {
515             $template->param( gna => 'true' );
516         }
517         if ( $flag eq 'LOST' ) {
518             $template->param( lost => 'true' );
519         }
520         if ( $flag eq 'DBARRED' ) {
521             $template->param( dbarred => 'true' );
522         }
523         if ( $flag eq 'CHARGES' ) {
524             $template->param(
525                 charges    => 'true',
526                 chargesmsg => $flags->{'CHARGES'}->{'message'}
527             );
528         }
529         if ( $flag eq 'CREDITS' ) {
530             $template->param(
531                 credits    => 'true',
532                 creditsmsg => $flags->{'CREDITS'}->{'message'}
533             );
534         }
535     }
536     else {
537         if ( $flag eq 'CHARGES' ) {
538             $template->param(
539                 charges    => 'true',
540                 flagged    => 1,
541                 chargesmsg => $flags->{'CHARGES'}->{'message'}
542             );
543         }
544         if ( $flag eq 'CREDITS' ) {
545             $template->param(
546                 credits    => 'true',
547                 creditsmsg => $flags->{'CREDITS'}->{'message'}
548             );
549         }
550         if ( $flag eq 'ODUES' ) {
551             $template->param(
552                 odues    => 'true',
553                 flagged  => 1,
554                 oduesmsg => $flags->{'ODUES'}->{'message'}
555             );
556
557             my $items = $flags->{$flag}->{'itemlist'};
558 # useless ???
559 #             {
560 #                 my @itemswaiting;
561 #                 foreach my $item (@$items) {
562 #                     my ($iteminformation) =
563 #                         getiteminformation( $item->{'itemnumber'}, 0 );
564 #                     push @itemswaiting, $iteminformation;
565 #                 }
566 #             }
567             if ( $query->param('module') ne 'returns' ) {
568                 $template->param( nonreturns => 'true' );
569             }
570         }
571         if ( $flag eq 'NOTES' ) {
572             $template->param(
573                 notes    => 'true',
574                 flagged  => 1,
575                 notesmsg => $flags->{'NOTES'}->{'message'}
576             );
577         }
578     }
579 }
580
581 my $amountold = $borrower->{flags}->{'CHARGES'}->{'message'} || 0;
582 my @temp = split( /\$/, $amountold );
583
584 my $CGIorganisations;
585 my $member_of_institution;
586 if ( C4::Context->preference("memberofinstitution") ) {
587     my $organisations = get_institutions();
588     my @orgs;
589     my %org_labels;
590     foreach my $organisation ( keys %$organisations ) {
591         push @orgs, $organisation;
592         $org_labels{$organisation} =
593           $organisations->{$organisation}->{'surname'};
594     }
595     $member_of_institution = 1;
596     $CGIorganisations      = CGI::popup_menu(
597         -id     => 'organisations',
598         -name   => 'organisations',
599         -labels => \%org_labels,
600         -values => \@orgs,
601     );
602 }
603
604 $amountold = $temp[1];
605
606 $template->param(
607     issued_itemtypes_count_loop => $issued_itemtypes_loop,
608     findborrower                => $findborrower,
609     borrower                    => $borrower,
610     borrowernumber              => $borrowernumber,
611     branch                      => $branch,
612     printer                     => $printer,
613     printername                 => $printer,
614     firstname                   => $borrower->{'firstname'},
615     surname                     => $borrower->{'surname'},
616     expiry                      =>
617       $borrower->{'dateexpiry'},    #format_date($borrower->{'dateexpiry'}),
618     categorycode      => $borrower->{'categorycode'},
619     address     => $borrower->{'address'},
620     address2     => $borrower->{'address2'},
621     email      => $borrower->{'email'},
622         emailpro           => $borrower->{'emailpro'},
623     borrowernotes     => $borrower->{'borrowernotes'},
624     city              => $borrower->{'city'},
625     phone             => $borrower->{'phone'} || $borrower->{'mobile'},
626     cardnumber        => $borrower->{'cardnumber'},
627     amountold         => $amountold,
628     barcode           => $barcode,
629     stickyduedate     => $stickyduedate,
630     message           => $message,
631     CGIselectborrower => $CGIselectborrower,
632     todayissues       => \@todaysissues,
633     previssues        => \@previousissues,
634     inprocess         => $inprocess,
635     memberofinstution => $member_of_institution,
636     CGIorganisations  => $CGIorganisations,
637 );
638
639 # set return date if stickyduedate
640 if ($stickyduedate) {
641     my $t_year  = "year" . $year;
642     my $t_month = "month" . $month;
643     my $t_day   = "day" . $day;
644     $template->param(
645         $t_year  => 1,
646         $t_month => 1,
647         $t_day   => 1,
648     );
649 }
650
651 #if ($branchcookie) {
652 #$cookie=[$cookie, $branchcookie, $printercookie];
653 #}
654
655 $template->param(
656     SpecifyDueDate     => C4::Context->preference("SpecifyDueDate")
657 );
658 $template->param( CircAutocompl => C4::Context->preference("CircAutocompl") );
659 output_html_with_http_headers $query, $cookie, $template->output;