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