added the book title and author to the reserve messages.
[koha.git] / circ / circulation.pl
1 #!/usr/bin/perl
2
3 #written 8/5/2002 by Finlay
4 #script to execute issuing of books
5
6 use strict;
7 use CGI;
8 use C4::Circulation::Circ2;
9 use C4::Search;
10 use C4::Output;
11 use C4::Print;
12
13 my %env;
14 my $headerbackgroundcolor='#99cc33';
15 my $circbackgroundcolor='#ffffcc';
16 my $circbackgroundcolor='white';
17 my $linecolor1='#ffffcc';
18 my $linecolor2='white';
19 my $backgroundimage="/images/background-mem.gif";
20
21 my $branches = getbranches();
22 my $printers = getprinters(\%env);
23
24 my $query = new CGI;
25
26 my $branch = $query->param("branch");
27 my $printer = $query->param("printer");
28
29 ($branch) || ($branch=$query->cookie('branch')) ;
30 ($printer) || ($printer=$query->cookie('printer')) ;
31
32 #set up cookie.....
33 my $info = '';
34 my $branchcookie;
35 my $printercookie;
36 if ($query->param('setcookies')) {
37     $branchcookie = $query->cookie(-name=>'branch', -value=>"$branch", -expires=>'+1y');
38     $printercookie = $query->cookie(-name=>'printer', -value=>"$printer", -expires=>'+1y');
39 }
40
41 $env{'branchcode'}=$branch;
42 $env{'printer'}=$printer;
43 $env{'queue'}=$printer;
44
45 my @datearr = localtime(time());
46 my $todaysdate = (1900+$datearr[5]).sprintf ("%0.2d", ($datearr[4]+1)).sprintf ("%0.2d", $datearr[3]);
47 #warn $todaysdate;
48
49
50 my $message;
51 my $borrowerslist;
52 # if there is a list of find borrowers....
53 my $findborrower = $query->param('findborrower');
54 if ($findborrower) {
55     my ($borrowers, $flags) = findborrower(\%env, $findborrower);
56     my @borrowers=@$borrowers;
57     if ($#borrowers == -1) {
58         $query->param('findborrower', '');
59         $message =  "No borrower matched '$findborrower'";
60     } elsif ($#borrowers == 0) {
61         $query->param('borrnumber', $borrowers[0]->{'borrowernumber'});
62         $query->param('barcode','');
63     } else {
64         $borrowerslist = \@borrowers;
65     }
66 }
67
68 my $borrowernumber = $query->param('borrnumber');    
69 my $bornum = $query->param('borrnumber');    
70 # check and see if we should print
71 my $print=$query->param('print');
72 my $barcode = $query->param('barcode');
73 if ($barcode eq ''  && $print eq 'maybe'){
74     $print = 'yes';
75 }
76 if ($print eq 'yes' && $borrowernumber ne ''){
77     printslip(\%env,$borrowernumber);    
78     $query->param('borrnumber','');
79     $borrowernumber='';
80 }
81     
82
83
84 # get the currently issued books......
85 my $borrower;
86 my $flags;
87 if ($borrowernumber) {
88     ($borrower, $flags) = getpatroninformation(\%env,$borrowernumber,0);
89 }
90
91 # get the responses to any questions.....
92 my %responses;
93 foreach (sort $query->param) {
94     if ($_ =~ /response-(\d*)/) {
95         $responses{$1} = $query->param($_);
96     }
97 }
98 if (my $qnumber = $query->param('questionnumber')) {
99     $responses{$qnumber} = $query->param('answer');
100 }
101
102
103 # if the barcode is set
104 my ($iteminformation, $duedate, $rejected, $question, $questionnumber, $defaultanswer);
105
106 my $year=$query->param('year');
107 my $month=$query->param('month');
108 my $day=$query->param('day');
109
110
111 if ($barcode) {
112     $barcode = cuecatbarcodedecode($barcode);
113     my ($datedue, $invalidduedate) = fixdate($year, $month, $day);
114
115     unless ($invalidduedate) {
116         $env{'datedue'}=$datedue;
117         my @time=localtime(time);
118         my $date= (1900+$time[5])."-".($time[4]+1)."-".$time[3];
119         ($iteminformation, $duedate, $rejected, $question, $questionnumber, $defaultanswer, $message) 
120                      = issuebook(\%env, $borrower, $barcode, \%responses, $date);
121     }
122 }
123
124
125 ##################################################################################
126 # HTML code....
127
128
129 my $rejectedtext;
130 if ($rejected) {
131     if ($rejected == -1) {
132     } else {
133         $rejectedtext = << "EOF";
134 <table border=1 cellpadding=5 cellspacing=0 bgcolor="#dddddd">
135 <tr><th><font color=black size=5>Error Issuing Book</font></th></tr>
136 <tr><td><font color=red size=5>$rejected</font></td></tr>
137 </table>
138 <br>
139 EOF
140     }
141 }
142
143 my $selectborrower;
144 if ($borrowerslist) {
145     $selectborrower = <<"EOF";
146 <form method=post action=/cgi-bin/koha/circ/circulation.pl>
147 <input type=hidden name=branch value=$branch>
148 <input type=hidden name=printer value=$printer>
149 <table border=1 cellspacing=0 cellpadding=5 bgcolor="#dddddd">
150 <tr><th bgcolor=$headerbackgroundcolor background=$backgroundimage>
151 <font color=black><b>Select a borrower</b></font></th></tr>\n
152 <tr><td align=center>
153 <select name=borrnumber size=7>
154 EOF
155     foreach (sort {$a->{'surname'}.$a->{'firstname'} cmp $b->{'surname'}.$b->{'firstname'}} @$borrowerslist){
156         $selectborrower .= <<"EOF";
157 <option value=$_->{'borrowernumber'}>$_->{'surname'}, $_->{'firstname'} ($_->{'cardnumber'})
158 EOF
159     }
160     $selectborrower .= <<"EOF";
161 </select><br>
162 <input type=submit>
163 </td></tr></table>
164 EOF
165 }
166
167 # title....
168 my $title = <<"EOF";
169 <table align="right"><tr><td>
170 <a href=circulation.pl?borrnumber=$borrowernumber&branch=$branch&printer=$printer&print=yes>
171 <img src="/images/button-next-borrower.gif" width="171" height="42" border="0" alt="Next Borrower"></a> &nbsp
172 <a href=returns.pl>
173 <img src="/images/button-returns.gif" width="110" height="42" border="0" alt="Returns"></a>
174 &nbsp<a href=branchtransfers.pl>
175 <img src="/images/button-transfers.gif" width="127" height="42" border="0" alt="Transfers">
176 </a>
177 </td></tr></table>
178 <FONT SIZE=6><em>Circulation: Issues</em></FONT><br>
179 <b>Branch:</b> $branches->{$branch}->{'branchname'} &nbsp 
180 <b>Printer:</b> $printers->{$printer}->{'printername'} <br>
181 <a href=selectbranchprinter.pl>Change Settings</a></td>
182 <input type=hidden name=branch value=$branch>
183 <input type=hidden name=printer value=$printer>
184 <p>
185 EOF
186
187 my $titlenoborrower = <<"EOF";
188 <table align="right"><tr><td>
189 <a href=returns.pl>
190 <img src="/images/button-returns.gif" width="110" height="42" border="0" alt="Returns"></a>
191 &nbsp<a href=branchtransfers.pl>
192 <img src="/images/button-transfers.gif" width="127" height="42" border="0" alt="Transfers">
193 </a>
194 </td></tr></table>
195 <FONT SIZE=6><em>Circulation: Issues</em></FONT><br>
196 <b>Branch:</b> $branches->{$branch}->{'branchname'} &nbsp 
197 <b>Printer:</b> $printers->{$printer}->{'printername'} <br>
198 <a href=selectbranchprinter.pl>Change Settings</a></td>
199 <input type=hidden name=branch value=$branch>
200 <input type=hidden name=printer value=$printer>
201 <p>
202 EOF
203
204
205
206 my $cardnumberinput = << "EOF";
207 <form method=post action=/cgi-bin/koha/circ/circulation.pl>
208 <table border=1 cellpadding=5 cellspacing=0 bgcolor="#dddddd">
209 <tr><th bgcolor=$headerbackgroundcolor background=$backgroundimage>
210 <font color=black><b>Enter borrower card number<br> or partial last name</b></font></td></tr>
211 <tr><td><input name=findborrower></td></tr>
212   <input type=hidden name=branch value=$branch>
213 <input type=hidden name=printer value=$printer>
214 </table>
215 </form>
216 EOF
217
218 my $responsesform = '';
219 foreach (keys %responses) {
220     $responsesform.="<input type=hidden name=response-$_ value=$responses{$_}>\n";
221 }
222 my $questionform;
223 if ($question) {
224     my $stickyduedate=$query->param('stickyduedate');
225     $questionform = <<"EOF";
226 <table border=1 cellpadding=5 cellspacing=0 bgcolor="#dddddd">
227 <tr><th bgcolor=$headerbackgroundcolor background=$backgroundimage>
228 <font color=black><b>Issuing Question</b></font></th></tr>
229 <tr><td><table border=0 cellpadding=10><tr><td> 
230 Attempting to issue $iteminformation->{'title'} 
231 by $iteminformation->{'author'} to $borrower->{'firstname'} $borrower->{'surname'}.
232 <p>
233 $question
234 </td></tr></table></td></tr>
235 <tr><td align=center>
236 <table border=0>
237 <tr><td>
238 <form method=get>
239 <input type=hidden name=borrnumber value=$borrowernumber>
240 <input type=hidden name=barcode value=$barcode>
241 <input type=hidden name=questionnumber value=$questionnumber>
242 <input type=hidden name=day value=$day>
243 <input type=hidden name=month value=$month>
244 <input type=hidden name=year value=$year>
245 <input type=hidden name=stickyduedate value=$stickyduedate>
246 <input type=hidden name=branch value=$branch>
247 <input type=hidden name=printer value=$printer>
248 $responsesform
249 <input type=hidden name=answer value=Y>
250 <input type=submit value=Yes>
251 </form>
252 </td>
253 <td>
254 <form method=get>
255 <input type=hidden name=borrnumber value=$borrowernumber>
256 <input type=hidden name=barcode value=$barcode>
257 <input type=hidden name=questionnumber value=$questionnumber>
258 <input type=hidden name=day value=$day>
259 <input type=hidden name=month value=$month>
260 <input type=hidden name=year value=$year>
261 <input type=hidden name=stickyduedate value=$stickyduedate>
262 <input type=hidden name=branch value=$branch>
263 <input type=hidden name=printer value=$printer>
264 $responsesform
265 <input type=hidden name=answer value=N>
266 <input type=submit value=No>
267 </form>
268 </td>
269 </tr>
270 </table>
271 </td></tr>
272 </table>
273 </td></tr>
274 </table>
275 EOF
276 }
277
278
279 # Barcode entry box, with hidden inputs attached....
280 my $counter = 1;
281 my $dayoptions = '';
282 my $monthoptions = '';
283 my $yearoptions = '';
284 for (my $i=1; $i<32; $i++) {
285     my $selected='';
286     if (($query->param('stickyduedate')) && ($day==$i)) {
287         $selected='selected';
288     }
289     $dayoptions.="<option value=$i $selected>$i";
290 }
291 foreach (('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec')) {
292     my $selected='';
293     if (($query->param('stickyduedate')) && ($month==$counter)) {
294         $selected='selected';
295     }
296     $monthoptions.="<option value=$counter $selected>$_";
297     $counter++;
298 }
299 for (my $i=$datearr[5]+1900; $i<$datearr[5]+1905; $i++) {
300     my $selected='';
301     if (($query->param('stickyduedate')) && ($year==$i)) {
302         $selected='selected';
303     }
304     $yearoptions.="<option value=$i $selected>$i";
305 }
306 my $selected='';
307 ($query->param('stickyduedate')) && ($selected='checked');
308
309
310 my $barcodeentrytext = <<"EOF";
311 <form method=post action=/cgi-bin/koha/circ/circulation.pl>
312 <table border=1 cellpadding=5>
313 <tr>
314 <td align=center valign=top>
315 <table border=0 cellspacing=0 cellpadding=5>
316 <tr><th align=center background=$backgroundimage>
317 <font color=black><b>Enter Book Barcode</b></font></th></tr>
318 <tr><td align=center>
319 <table border=0>
320 <tr><td>Item Barcode:</td><td><input name=barcode size=10></td><td><input type=submit value=Issue></td></tr>
321 <tr><td colspan=3 align=center>
322 <table border=0 cellpadding=0 cellspacing=0>
323 <tr><td>
324 <select name=day><option value=0>Day$dayoptions</select>
325 </td><td>
326 <select name=month><option value=0>Month$monthoptions</select>
327 </td><td>
328 <select name=year><option value=0>Year$yearoptions</select>
329 </td></tr>
330 </table>
331 <input type=checkbox name=stickyduedate $selected> Sticky Due Date
332 </td></tr>
333 </table>
334 <input type=hidden name=borrnumber value=$borrowernumber>
335 <input type=hidden name=branch value=$branch>
336 <input type=hidden name=printer value=$printer>
337 <input type=hidden name=print value=maybe>
338 EOF
339 if ($flags->{'CHARGES'}){
340     $barcodeentrytext.="<input type=hidden name=charges value=yes>";
341 }
342 my $amountold=$flags->{'CHARGES'}->{'message'};
343 my @temp=split(/\$/,$amountold);
344 $amountold=$temp[1];
345 $barcodeentrytext.="<input type=hidden name=oldamount value=$amountold>";
346 $barcodeentrytext.=<<"EOF";
347 </td></tr></table>
348 </td></tr></table>
349 </form>
350 EOF
351
352
353 # collect the messages and put into message table....
354 my $messagetable;
355 if ($message) {
356     $messagetable = << "EOF";
357 <table border=1 cellpadding=5 cellspacing=0 bgcolor='#dddddd'>
358 <tr><th bgcolor=$headerbackgroundcolor background=$backgroundimage><font>Messages</font></th></tr>
359 <tr><td> $message </td></tr></table>
360 EOF
361 }
362
363
364
365 # make the issued books table.....
366 my $todaysissues='';
367 my $previssues='';
368 if ($borrower) {
369     my $issueslist = getissues($borrower);
370     my $tcolor = '';
371     my $pcolor = '';
372     foreach my $it (sort keys %$issueslist) {
373         my $dd = $issueslist->{$it}->{'date_due'};
374         my $issuedate = $issueslist->{$it}->{'timestamp'};
375         $issuedate = substr($issuedate, 0, 8);
376
377         my $bookissue = $issueslist->{$it};
378         my $bgcolor='';
379         my $datedue = $bookissue->{'date_due'};
380         #convert to nz style dates
381         #this should be set with some kinda config variable         
382         my @tempdate=split(/-/,$dd);
383         $dd="$tempdate[2]/$tempdate[1]/$tempdate[0]";
384         $datedue=~s/-//g;
385         if ($datedue < $todaysdate) {
386             $dd="<font color=red>$dd</font>\n";
387         }
388         if ($todaysdate == $issuedate) {
389             ($tcolor eq $linecolor1) ? ($tcolor=$linecolor2) : ($tcolor=$linecolor1);
390             $todaysissues .=<< "EOF";
391 <tr><td bgcolor=$tcolor align=center>$dd</td>
392 <td bgcolor=$tcolor align=center>
393 <a href=/cgi-bin/koha/detail.pl?bib=$bookissue->{'biblionumber'}&type=intra onClick=\"openWindow(this, 'Item', 480, 640)\">$bookissue->{'barcode'}</a></td>
394 <td bgcolor=$tcolor>$bookissue->{'title'}</td>
395 <td bgcolor=$tcolor>$bookissue->{'author'}</td>
396 <td bgcolor=$tcolor align=center>$bookissue->{'dewey'} $bookissue->{'subclass'}</td></tr>
397 EOF
398         } else {
399             ($pcolor eq $linecolor1) ? ($pcolor=$linecolor2) : ($pcolor=$linecolor1);
400             $previssues .= << "EOF";
401 <tr><td bgcolor=$pcolor align=center>$dd</td>
402 <td bgcolor=$pcolor align=center>
403 <a href=/cgi-bin/koha/detail.pl?bib=$bookissue->{'biblionumber'}&type=intra onClick=\"openWindow(this, 'Item', 480, 640)\">$bookissue->{'barcode'}</a></td>
404 <td bgcolor=$pcolor>$bookissue->{'title'}</td>
405 <td bgcolor=$pcolor>$bookissue->{'author'}</td>
406 <td bgcolor=$pcolor align=center>$bookissue->{'dewey'} $bookissue->{'subclass'}</td></tr>
407 EOF
408         }
409     }
410 }
411
412 my $issuedbookstable;
413 if ($todaysissues) {
414     $issuedbookstable .= <<"EOF";
415 <table border=1 cellpadding=5 cellspacing=0 width=80%>
416 <tr><th colspan=5 bgcolor=$headerbackgroundcolor background=$backgroundimage><font color=black>
417 <b>Todays Issues</b></font></th></tr>
418 <tr><th>Due Date</th><th>Bar Code</th><th>Title</th><th>Author</th><th>Class</th></tr>
419 $todaysissues
420 </table>
421 EOF
422 }
423 if ($previssues) {
424     $issuedbookstable .= <<"EOF";
425 <table border=1 cellpadding=5 cellspacing=0 width=80%>
426 <tr><th colspan=5 bgcolor=$headerbackgroundcolor background=$backgroundimage><font color=black>
427 <b>Previous Issues</b></font></th></tr>
428 <tr><th>Due Date</th><th>Bar Code</th><th>Title</th><th>Author</th><th>Class</th></tr>
429 $previssues
430 </table>
431 EOF
432 }
433
434
435
436
437
438 # actually print the page!
439
440
441 if ($branchcookie && $printercookie) {
442     print $query->header(-type=>'text/html',-expires=>'now', -cookie=>[$branchcookie,$printercookie]);
443 } else {
444     print $query->header();
445 }
446
447 print startpage();
448 my @inp=startmenu('circulation');
449 if ($query->param('barcode') eq '' && $query->param('charges') eq 'yes'){
450     my $count=@inp;
451      for (my $i=0;$i<$count;$i++){
452          $inp[$i]=~ s/onLoad=focusinput\(\)/onLoad=focusinput\(\)\;messenger\(\"\/cgi-bin\/koha\/pay.pl?bornum=$bornum\",700,600\)\;window1.focus\(\)/;
453      }
454 }
455
456 print @inp;
457
458
459 #print startmenu('circulation');
460 if ($borrower) {
461     print $title;
462 } else {
463     print $titlenoborrower;
464 }
465
466
467 print $info;
468
469 if ($question) {
470     print $questionform;
471 }
472
473 print $rejectedtext;
474 print $messagetable;
475
476
477 unless ($borrower) {
478     if ($borrowerslist) {
479         print $selectborrower;
480     } else {
481         print $cardnumberinput;
482     }
483 }
484
485
486
487 if ($borrower) {
488     my ($patrontable, $flaginfotable) = patrontable($borrower);
489     print $patrontable;
490     print $flaginfotable;
491     print $barcodeentrytext;
492     print "<p clear=all><br><br>";
493     print $issuedbookstable;
494 }
495
496
497
498
499 print endmenu('circulation');
500 print endpage();
501
502
503 ####################################################################
504 # Extra subroutines,,,
505
506 sub cuecatbarcodedecode {
507     my ($barcode) = @_;
508     chomp($barcode);
509     my @fields = split(/\./,$barcode);
510     my @results = map(decode($_), @fields[1..$#fields]);
511     if ($#results == 2){
512         return $results[2];
513     } else {
514         return $barcode;
515     } 
516
517
518 sub fixdate {
519     my ($year, $month, $day) = @_;
520     my $invalidduedate;
521     my $date;
522     if (($year eq 0) && ($month eq 0) && ($year eq 0)) {
523         $env{'datedue'}='';
524     } else {
525         if (($year eq 0) || ($month eq 0) || ($year eq 0)) {
526             $invalidduedate="Invalid Due Date Specified. Book was not issued.<p>\n";
527         } else {
528             if (($day>30) && (($month==4) || ($month==6) || ($month==9) || ($month==11))) {
529                 $invalidduedate = "Invalid Due Date Specified. Book was not issued. Only 30 days in $month month.<p>\n";
530             } elsif (($day > 29) && ($month == 2)) {
531                 $invalidduedate="Invalid Due Date Specified. Book was not issued.  Never that many days in February!<p>\n";
532             } elsif (($month == 2) && ($day > 28) && (($year%4) && ((!($year%100) || ($year%400))))) {
533                 $invalidduedate="Invalid Due Date Specified. Book was not issued.  $year is not a leap year.<p>\n";
534             } else {
535                 $date="$year-$month-$day";
536             }
537         }
538     }
539     return ($date, $invalidduedate);
540 }
541
542
543 sub patrontable {
544     my ($borrower) = @_;
545     my $flags = $borrower->{'flags'};
546     my $flaginfotable='';
547     my $flaginfotext='';
548     my $flag;
549     my $color='';
550     foreach $flag (sort keys %$flags) {
551         ($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1);
552         $flags->{$flag}->{'message'}=~s/\n/<br>/g;
553         if ($flags->{$flag}->{'noissues'}) {
554             if ($flag eq 'CHARGES') {
555                 $flaginfotext.="<tr><td valign=top><font color=red>$flag</font></td><td bgcolor=$color><b>$flags->{$flag}->{'message'}</b> <a href=/cgi-bin/koha/pay.pl?bornum=$borrower->{'borrowernumber'} onClick=\"openWindow(this, 'Payment', 480,640)\">Payment</a></td></tr>\n";
556             } else {
557                 $flaginfotext.="<tr><td valign=top><font color=red>$flag</font></td><td bgcolor=$color>$flags->{$flag}->{'message'}</td></tr>\n";
558             }
559         } else {
560             if ($flag eq 'CHARGES') {
561                 $flaginfotext.="<tr><td valign=top>$flag</td><td> $flags->{$flag}->{'message'} <a href=/cgi-bin/koha/pay.pl?bornum=$borrower->{'borrowernumber'} onClick=\"openWindow(this, 'Payment', 480,640)\">Payment</a></td></tr>\n";
562             } elsif ($flag eq 'WAITING') {
563                 my $itemswaiting='';
564                 my $items=$flags->{$flag}->{'itemlist'};
565                 foreach my $item (@$items) {
566                     my ($iteminformation) = getiteminformation(\%env, $item->{'itemnumber'}, 0);
567                     $itemswaiting.="<a href=/cgi-bin/koha/detail.pl?bib=$iteminformation->{'biblionumber'}&type=intra onClick=\"openWindow(this, 'Item', 480, 640)\">$iteminformation->{'barcode'}</a> $iteminformation->{'title'} ($branches->{$iteminformation->{'holdingbranch'}}->{'branchname'})<br>\n";
568                 }
569                 $flaginfotext.="<tr><td valign=top>$flag</td><td>$itemswaiting</td></tr>\n";
570             } elsif ($flag eq 'ODUES') {
571                 my $items=$flags->{$flag}->{'itemlist'};
572                 my $itemswaiting="<table border=1 cellspacing=0 cellpadding=2>\n";
573                 my $currentcolor=$color;
574                 {
575                     my $color=$currentcolor;
576                     foreach my $item (@$items) {
577                         ($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1);
578                         my ($iteminformation) = getiteminformation(\%env, $item->{'itemnumber'}, 0);
579                         $itemswaiting.="<tr><td><font color=red>$iteminformation->{'date_due'}</font></td><td bgcolor=$color><a href=/cgi-bin/koha/detail.pl?bib=$iteminformation->{'biblionumber'}&type=intra onClick=\"openWindow(this, 'Item', 480, 640)\">$iteminformation->{'barcode'}</a></td><td>$iteminformation->{'title'}</td></tr>\n";
580                     }               
581                 }
582                 $itemswaiting.="</table>\n";
583                 if ($query->param('module') ne 'returns'){
584                   $flaginfotext.="<tr><td valign=top>$flag</td><td>$flags->{$flag}->{'message'}, See below</td></tr>\n";
585                 } else {
586                   $flaginfotext.="<tr><td valign=top>$flag</td><td>$flags->{$flag}->{'message'}</td></tr>\n"; 
587                 }
588             } else {
589                 $flaginfotext.="<tr><td valign=top>$flag</td><td>$flags->{$flag}->{'message'}</td></tr>\n";
590             }
591         }
592     }
593     ($flaginfotext) && ($flaginfotext="<tr><td bgcolor=$headerbackgroundcolor background=$backgroundimage colspan=2><b>Flags</b></td></tr>$flaginfotext\n");
594     $flaginfotext.="</table>";
595     my $patrontable= << "EOF";
596 <br><p>
597     <table border=1 cellpadding=5 cellspacing=0 align=right>
598     <tr><td bgcolor=$headerbackgroundcolor background=$backgroundimage colspan=2><font color=black><b>Patron Information</b></font></td></tr>
599     <tr><td colspan=2>
600     <a href=/cgi-bin/koha/moremember.pl?bornum=$borrower->{'borrowernumber'} onClick="openWindow(this,'Member', 480, 640)">$borrower->{'cardnumber'}</a> $borrower->{'surname'}, $borrower->{'title'} $borrower->{'firstname'}<br>$borrower->{'streetaddress'} $borrower->{'city'} Cat: $borrower->{'categorycode'} </td></tr>
601 EOF
602     return($patrontable, $flaginfotext);
603 }
604
605
606
607 sub printslip {
608     my ($env,$borrowernumber)=@_;
609     my ($borrower, $flags) = getpatroninformation($env,$borrowernumber,0);
610     $env->{'todaysissues'}=1;
611     my ($borrowerissues) = currentissues($env, $borrower);
612     $env->{'nottodaysissues'}=1;
613     $env->{'todaysissues'}=0;
614     my ($borroweriss2)=currentissues($env, $borrower);
615     $env->{'nottodaysissues'}=0;
616     my $i=0;
617     my @issues;
618     foreach (sort keys %$borrowerissues) {
619         $issues[$i]=$borrowerissues->{$_};
620         my $dd=$issues[$i]->{'date_due'};
621         #convert to nz style dates
622         #this should be set with some kinda config variable
623         my @tempdate=split(/-/,$dd);
624         $issues[$i]->{'date_due'}="$tempdate[2]/$tempdate[1]/$tempdate[0]";
625         $i++;
626     }
627     foreach (sort keys %$borroweriss2) {
628         $issues[$i]=$borroweriss2->{$_};
629         my $dd=$issues[$i]->{'date_due'};
630         #convert to nz style dates
631         #this should be set with some kinda config variable
632         my @tempdate=split(/-/,$dd);
633         $issues[$i]->{'date_due'}="$tempdate[2]/$tempdate[1]/$tempdate[0]";
634         $i++;
635     }
636     remoteprint($env,\@issues,$borrower);
637 }