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