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