updating unimarc zebra config file
[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(undef,$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                          itemhomebranch => $getmessageiteminfo->{'homebranch'} ,        
269             day   => $day,
270             month => $month,
271             year  => $year
272         );
273         if ( $noerror && ( $noquestion || $issueconfirmed ) ) {
274             AddIssue( $borrower, $barcode, $datedue );
275             $inprocess = 1;
276         }
277     }
278     
279 # FIXME If the issue is confirmed, we launch another time borrdata2, now display the issue count after issue 
280         my ( $od, $issue, $fines ) = GetMemberIssuesAndFines( $borrowernumber );
281         $template->param(
282         issuecount   => $issue,
283         );
284 }
285
286 # reload the borrower info for the sake of reseting the flags.....
287 if ($borrowernumber) {
288     $borrower = GetMemberDetails( $borrowernumber, 0 );
289 }
290
291 ##################################################################################
292 # BUILD HTML
293 # show all reserves of this borrower, and the position of the reservation ....
294 if ($borrowernumber) {
295
296     # new op dev
297     # now we show the status of the borrower's reservations
298     my @borrowerreserv = GetReservesFromBorrowernumber($borrowernumber );
299     my @reservloop;
300     my @WaitingReserveLoop;
301     
302     foreach my $num_res (@borrowerreserv) {
303         my %getreserv;
304         my %getWaitingReserveInfo;
305         my $getiteminfo  = GetBiblioFromItemNumber( $num_res->{'itemnumber'} );
306         my $itemtypeinfo = getitemtypeinfo( (C4::Context->preference('item-level_itype')) ? $getiteminfo->{'itype'} : $getiteminfo->{'itemtype'} );
307         my ( $transfertwhen, $transfertfrom, $transfertto ) =
308           GetTransfers( $num_res->{'itemnumber'} );
309
310         $getreserv{waiting}       = 0;
311         $getreserv{transfered}    = 0;
312         $getreserv{nottransfered} = 0;
313
314         $getreserv{reservedate}    = format_date( $num_res->{'reservedate'} );
315         $getreserv{title}          = $getiteminfo->{'title'};
316         $getreserv{itemtype}       = $itemtypeinfo->{'description'};
317         $getreserv{author}         = $getiteminfo->{'author'};
318         $getreserv{barcodereserv}  = $getiteminfo->{'barcode'};
319         $getreserv{itemcallnumber} = $getiteminfo->{'itemcallnumber'};
320                 $getreserv{biblionumber}   = $getiteminfo->{'biblionumber'};
321
322         #         check if we have a waiting status for reservations
323         if ( $num_res->{'found'} eq 'W' ) {
324             $getreserv{color}   = 'reserved';
325             $getreserv{waiting} = 1;
326 #     genarate information displaying only waiting reserves
327         $getWaitingReserveInfo{title}        = $getiteminfo->{'title'};
328         $getWaitingReserveInfo{biblionumber}   = $getiteminfo->{'biblionumber'};
329         $getWaitingReserveInfo{itemtype}    = $itemtypeinfo->{'description'};
330         $getWaitingReserveInfo{author}        = $getiteminfo->{'author'};
331         $getWaitingReserveInfo{reservedate}    = format_date( $num_res->{'reservedate'} );
332         if ($getiteminfo->{'holdingbranch'} ne $num_res->{'branchcode'} ) {
333         $getWaitingReserveInfo{waitingat}    = GetBranchName( $num_res->{'branchcode'} );
334         }
335     
336         }
337         #         check transfers with the itemnumber foud in th reservation loop
338         if ($transfertwhen) {
339             $getreserv{color}      = 'transfered';
340             $getreserv{transfered} = 1;
341             $getreserv{datesent}   = format_date($transfertwhen);
342             $getreserv{frombranch} = GetBranchName($transfertfrom);
343         }
344
345         if ( ( $getiteminfo->{'holdingbranch'} ne $num_res->{'branchcode'} )
346             and not $transfertwhen )
347         {
348             $getreserv{nottransfered}   = 1;
349             $getreserv{nottransferedby} =
350               GetBranchName( $getiteminfo->{'holdingbranch'} );
351         }
352
353 #         if we don't have a reserv on item, we put the biblio infos and the waiting position
354         if ( $getiteminfo->{'title'} eq '' ) {
355             my $getbibinfo = GetBiblioData( $num_res->{'biblionumber'} );
356             my $getbibtype = getitemtypeinfo( $getbibinfo->{'itemtype'} );  # fixme - we should have item-level reserves here ?
357             $getreserv{color}           = 'inwait';
358             $getreserv{title}           = $getbibinfo->{'title'};
359             $getreserv{waitingposition} = $num_res->{'priority'};
360             $getreserv{nottransfered}   = 0;
361             $getreserv{itemtype}        = $getbibtype->{'description'};
362             $getreserv{author}          = $getbibinfo->{'author'};
363             $getreserv{itemcallnumber}  = '----------';
364                 $getreserv{biblionumber}    = $num_res->{'biblionumber'};
365         }
366         push( @reservloop, \%getreserv );
367
368 #         if we have a reserve waiting, initiate waitingreserveloop
369         if ($getreserv{waiting} eq 1) {
370         push (@WaitingReserveLoop, \%getWaitingReserveInfo)
371         }
372       
373     }
374
375     # return result to the template
376     $template->param( 
377         countreserv => scalar @reservloop,
378         reservloop  => \@reservloop ,
379         WaitingReserveLoop  => \@WaitingReserveLoop,
380     );
381 }
382
383 # make the issued books table.
384 my $todaysissues = '';
385 my $previssues   = '';
386 my @todaysissues;
387 my @previousissues;
388 my $allowborrow;
389 ## ADDED BY JF: new itemtype issuingrules counter stuff
390 my $issued_itemtypes_loop;
391 my $issued_itemtypes_count;
392 my $issued_itemtypes_allowed_count;    # hashref with total allowed by itemtype
393 my $issued_itemtypes_remaining;        # hashref with remaining
394 my $issued_itemtypes_flags;            #hashref that stores flags
395 my @issued_itemtypes_count_loop;
396
397 if ($borrower) {
398
399 # get each issue of the borrower & separate them in todayissues & previous issues
400     my ($countissues,$issueslist) = GetPendingIssues($borrower->{'borrowernumber'});
401
402     # split in 2 arrays for today & previous
403     foreach my $it ( @$issueslist ) {
404         my $issuedate = $it->{'issuedate'};
405         $issuedate =~ s/-//g;
406         $issuedate = substr( $issuedate, 0, 8 );
407                 ($it->{'charge'}, $it->{'itemtype_charge'}) = GetIssuingCharges(
408                                                 $it->{'itemnumber'}, $borrower->{'borrowernumber'}
409                 );
410                 $it->{'charge'} = sprintf("%.2f", $it->{'charge'});
411         ($it->{'can_renew'}, $it->{'can_renew_error'}) = CanBookBeRenewed( 
412                                                 $borrower->{'borrowernumber'},$it->{'itemnumber'}
413                 );
414                 my ($restype, $reserves) = CheckReserves($it->{'itemnumber'});
415                 ($restype) and $it->{'can_renew'} = 0;
416
417                 $it->{'dd'} = format_date($it->{'date_due'});
418         my $datedue = $it->{'date_due'};
419         $datedue =~ s/-//g;
420                 $it->{'od'} = ($datedue < $todaysdate) ? 1 : 0 ;
421         ($it->{'author'} eq '') and $it->{'author'} = ' ';
422         $it->{'renew_failed'} = $renew_failed[$it->{'itemnumber'}];
423         # ADDED BY JF: NEW ITEMTYPE COUNT DISPLAY
424         $issued_itemtypes_count->{ $it->{'itemtype'} }++;
425
426         if ( $todaysdate == $issuedate ) {
427             push @todaysissues, $it;
428         } else {
429             push @previousissues, $it;
430         }
431     }
432     @todaysissues   = sort { $b->{'timestamp'} <=> $a->{'timestamp'} } @todaysissues;
433     @previousissues = sort { $b->{'date_due' } <=> $a->{'date_due' } } @previousissues;
434     my $i = 1;
435         foreach my $book (@todaysissues) {
436         $book->{'togglecolor'} = (++$i % 2) ? 0 : 1 ;
437     }
438     $i = 1;
439         foreach my $book (@previousissues) {
440         $book->{'togglecolor'} = (++$i % 2) ? 0 : 1 ;
441     }
442 }
443
444 #### ADDED BY JF FOR COUNTS BY ITEMTYPE RULES
445 # FIXME: This should utilize all the issuingrules options rather than just the defaults
446 # and it should be moved to a module
447 my $dbh = C4::Context->dbh;
448
449 # how many of each is allowed?
450 my $issueqty_sth = $dbh->prepare( "
451 SELECT itemtypes.description AS description,issuingrules.itemtype,maxissueqty
452 FROM issuingrules
453   LEFT JOIN itemtypes ON (itemtypes.itemtype=issuingrules.itemtype)
454   WHERE categorycode=?
455 " );
456 #my @issued_itemtypes_count;  # huh?
457 $issueqty_sth->execute("*");
458
459 while ( my $data = $issueqty_sth->fetchrow_hashref() ) {
460
461     # subtract how many of each this borrower has
462     $data->{'count'} = $issued_itemtypes_count->{ $data->{'description'} };  
463     $data->{'left'}  =
464       ( $data->{'maxissueqty'} -
465           $issued_itemtypes_count->{ $data->{'description'} } );
466
467     # can't have a negative number of remaining
468     if ( $data->{'left'} < 0 ) { $data->{'left'} = "0" }
469     $data->{'flag'} = 1 unless ( $data->{'maxissueqty'} > $data->{'count'} );
470     unless ( ( $data->{'maxissueqty'} < 1 )
471         || ( $data->{'itemtype'} eq "*" )
472         || ( $data->{'itemtype'} eq "CIRC" ) )
473     {
474         push @issued_itemtypes_count_loop, $data;
475     }
476 }
477 $issued_itemtypes_loop = \@issued_itemtypes_count_loop;
478
479 #### / JF
480
481 my @values;
482 my %labels;
483 my $CGIselectborrower;
484 if ($borrowerslist) {
485     foreach (
486         sort {
487                 $a->{'surname'}
488               . $a->{'firstname'} cmp $b->{'surname'}
489               . $b->{'firstname'}
490         } @$borrowerslist
491       )
492     {
493         push @values, $_->{'borrowernumber'};
494         $labels{ $_->{'borrowernumber'} } =
495 "$_->{'surname'}, $_->{'firstname'} ... ($_->{'cardnumber'} - $_->{'categorycode'}) ...  $_->{'address'} ";
496     }
497     $CGIselectborrower = CGI::scrolling_list(
498         -name     => 'borrowernumber',
499                 -class     => 'focus',
500                 -id          => 'borrowernumber',
501         -values   => \@values,
502         -labels   => \%labels,
503         -size     => 7,
504         -tabindex => '',
505         -multiple => 0
506     );
507 }
508
509 #title
510 my $flags = $borrower->{'flags'};
511 my $flag;
512
513 foreach $flag ( sort keys %$flags ) {
514
515     $flags->{$flag}->{'message'} =~ s/\n/<br>/g;
516     if ( $flags->{$flag}->{'noissues'} ) {
517         $template->param(
518             flagged  => 1,
519             noissues => 'true',
520         );
521         if ( $flag eq 'GNA' ) {
522             $template->param( gna => 'true' );
523         }
524         if ( $flag eq 'LOST' ) {
525             $template->param( lost => 'true' );
526         }
527         if ( $flag eq 'DBARRED' ) {
528             $template->param( dbarred => 'true' );
529         }
530         if ( $flag eq 'CHARGES' ) {
531             $template->param(
532                 charges    => 'true',
533                 chargesmsg => $flags->{'CHARGES'}->{'message'}
534             );
535         }
536         if ( $flag eq 'CREDITS' ) {
537             $template->param(
538                 credits    => 'true',
539                 creditsmsg => $flags->{'CREDITS'}->{'message'}
540             );
541         }
542     }
543     else {
544         if ( $flag eq 'CHARGES' ) {
545             $template->param(
546                 charges    => 'true',
547                 flagged    => 1,
548                 chargesmsg => $flags->{'CHARGES'}->{'message'}
549             );
550         }
551         if ( $flag eq 'CREDITS' ) {
552             $template->param(
553                 credits    => 'true',
554                 creditsmsg => $flags->{'CREDITS'}->{'message'}
555             );
556         }
557         if ( $flag eq 'ODUES' ) {
558             $template->param(
559                 odues    => 'true',
560                 flagged  => 1,
561                 oduesmsg => $flags->{'ODUES'}->{'message'}
562             );
563
564             my $items = $flags->{$flag}->{'itemlist'};
565 # useless ???
566 #             {
567 #                 my @itemswaiting;
568 #                 foreach my $item (@$items) {
569 #                     my ($iteminformation) =
570 #                         getiteminformation( $item->{'itemnumber'}, 0 );
571 #                     push @itemswaiting, $iteminformation;
572 #                 }
573 #             }
574             if ( $query->param('module') ne 'returns' ) {
575                 $template->param( nonreturns => 'true' );
576             }
577         }
578         if ( $flag eq 'NOTES' ) {
579             $template->param(
580                 notes    => 'true',
581                 flagged  => 1,
582                 notesmsg => $flags->{'NOTES'}->{'message'}
583             );
584         }
585     }
586 }
587
588 my $amountold = $borrower->{flags}->{'CHARGES'}->{'message'} || 0;
589 my @temp = split( /\$/, $amountold );
590
591 my $CGIorganisations;
592 my $member_of_institution;
593 if ( C4::Context->preference("memberofinstitution") ) {
594     my $organisations = get_institutions();
595     my @orgs;
596     my %org_labels;
597     foreach my $organisation ( keys %$organisations ) {
598         push @orgs, $organisation;
599         $org_labels{$organisation} =
600           $organisations->{$organisation}->{'surname'};
601     }
602     $member_of_institution = 1;
603     $CGIorganisations      = CGI::popup_menu(
604         -id     => 'organisations',
605         -name   => 'organisations',
606         -labels => \%org_labels,
607         -values => \@orgs,
608     );
609 }
610
611 $amountold = $temp[1];
612
613 $template->param(
614     issued_itemtypes_count_loop => $issued_itemtypes_loop,
615     findborrower                => $findborrower,
616     borrower                    => $borrower,
617     borrowernumber              => $borrowernumber,
618     branch                      => $branch,
619     printer                     => $printer,
620     printername                 => $printer,
621     firstname                   => $borrower->{'firstname'},
622     surname                     => $borrower->{'surname'},
623     expiry                      =>
624       $borrower->{'dateexpiry'},    #format_date($borrower->{'dateexpiry'}),
625     categorycode      => $borrower->{'categorycode'},
626     address     => $borrower->{'address'},
627     address2     => $borrower->{'address2'},
628     email      => $borrower->{'email'},
629         emailpro           => $borrower->{'emailpro'},
630     borrowernotes     => $borrower->{'borrowernotes'},
631     city              => $borrower->{'city'},
632     phone             => $borrower->{'phone'} || $borrower->{'mobile'},
633     cardnumber        => $borrower->{'cardnumber'},
634     amountold         => $amountold,
635     barcode           => $barcode,
636     stickyduedate     => $stickyduedate,
637     message           => $message,
638     CGIselectborrower => $CGIselectborrower,
639     todayissues       => \@todaysissues,
640     previssues        => \@previousissues,
641     inprocess         => $inprocess,
642     memberofinstution => $member_of_institution,
643     CGIorganisations  => $CGIorganisations,
644 );
645
646 # set return date if stickyduedate
647 if ($stickyduedate) {
648     my $t_year  = "year" . $year;
649     my $t_month = "month" . $month;
650     my $t_day   = "day" . $day;
651     $template->param(
652         $t_year  => 1,
653         $t_month => 1,
654         $t_day   => 1,
655     );
656 }
657
658 #if ($branchcookie) {
659 #$cookie=[$cookie, $branchcookie, $printercookie];
660 #}
661
662 $template->param(
663     SpecifyDueDate     => C4::Context->preference("SpecifyDueDate")
664 );
665 $template->param( CircAutocompl => C4::Context->preference("CircAutocompl") );
666 output_html_with_http_headers $query, $cookie, $template->output;