Fixing issues which i broke just before ... perhaps one more commit today.
[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
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
189
190 my $cardnumberinput = << "EOF";
191 <form method=post action=/cgi-bin/koha/circ/circulation.pl>
192 <table border=1 cellpadding=5 cellspacing=0 bgcolor="#dddddd">
193 <tr><th bgcolor=$headerbackgroundcolor background=$backgroundimage>
194 <font color=black><b>Enter borrower card number<br> or partial last name</b></font></td></tr>
195 <tr><td><input name=findborrower></td></tr>
196   <input type=hidden name=branch value=$branch>
197 <input type=hidden name=printer value=$printer>
198 </table>
199 </form>
200 EOF
201
202 my $responsesform = '';
203 foreach (keys %responses) {
204     $responsesform.="<input type=hidden name=response-$_ value=$responses{$_}>\n";
205 }
206 my $questionform;
207 if ($question) {
208     my $stickyduedate=$query->param('stickyduedate');
209     $questionform = <<"EOF";
210 <table border=1 cellpadding=5 cellspacing=0 bgcolor="#dddddd">
211 <tr><th bgcolor=$headerbackgroundcolor background=$backgroundimage>
212 <font color=black><b>Issuing Question</b></font></th></tr>
213 <tr><td><table border=0 cellpadding=10><tr><td> 
214 Attempting to issue $iteminformation->{'title'} 
215 by $iteminformation->{'author'} to $borrower->{'firstname'} $borrower->{'surname'}.
216 <p>
217 $question
218 </td></tr></table></td></tr>
219 <tr><td align=center>
220 <table border=0>
221 <tr><td>
222 <form method=get>
223 <input type=hidden name=borrnumber value=$borrowernumber>
224 <input type=hidden name=barcode value=$barcode>
225 <input type=hidden name=questionnumber value=$questionnumber>
226 <input type=hidden name=day value=$day>
227 <input type=hidden name=month value=$month>
228 <input type=hidden name=year value=$year>
229 <input type=hidden name=stickyduedate value=$stickyduedate>
230 <input type=hidden name=branch value=$branch>
231 <input type=hidden name=printer value=$printer>
232 $responsesform
233 <input type=hidden name=answer value=Y>
234 <input type=submit value=Yes>
235 </form>
236 </td>
237 <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=N>
250 <input type=submit value=No>
251 </form>
252 </td>
253 </tr>
254 </table>
255 </td></tr>
256 </table>
257 </td></tr>
258 </table>
259 EOF
260 }
261
262
263 # Barcode entry box, with hidden inputs attached....
264 my $counter = 1;
265 my $dayoptions = '';
266 my $monthoptions = '';
267 my $yearoptions = '';
268 for (my $i=1; $i<32; $i++) {
269     my $selected='';
270     if (($query->param('stickyduedate')) && ($day==$i)) {
271         $selected='selected';
272     }
273     $dayoptions.="<option value=$i $selected>$i";
274 }
275 foreach (('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec')) {
276     my $selected='';
277     if (($query->param('stickyduedate')) && ($month==$counter)) {
278         $selected='selected';
279     }
280     $monthoptions.="<option value=$counter $selected>$_";
281     $counter++;
282 }
283 for (my $i=$datearr[5]+1900; $i<$datearr[5]+1905; $i++) {
284     my $selected='';
285     if (($query->param('stickyduedate')) && ($year==$i)) {
286         $selected='selected';
287     }
288     $yearoptions.="<option value=$i $selected>$i";
289 }
290 my $selected='';
291 ($query->param('stickyduedate')) && ($selected='checked');
292
293
294 my $barcodeentrytext = <<"EOF";
295 <form method=post action=/cgi-bin/koha/circ/circulation.pl>
296 <table border=1 cellpadding=5>
297 <tr>
298 <td align=center valign=top>
299 <table border=0 cellspacing=0 cellpadding=5>
300 <tr><th align=center background=$backgroundimage>
301 <font color=black><b>Enter Book Barcode</b></font></th></tr>
302 <tr><td align=center>
303 <table border=0>
304 <tr><td>Item Barcode:</td><td><input name=barcode size=10></td><td><input type=submit value=Issue></td></tr>
305 <tr><td colspan=3 align=center>
306 <table border=0 cellpadding=0 cellspacing=0>
307 <tr><td>
308 <select name=day><option value=0>Day$dayoptions</select>
309 </td><td>
310 <select name=month><option value=0>Month$monthoptions</select>
311 </td><td>
312 <select name=year><option value=0>Year$yearoptions</select>
313 </td></tr>
314 </table>
315 <input type=checkbox name=stickyduedate $selected> Sticky Due Date
316 </td></tr>
317 </table>
318 <input type=hidden name=borrnumber value=$borrowernumber>
319 <input type=hidden name=branch value=$branch>
320 <input type=hidden name=printer value=$printer>
321 <input type=hidden name=print value=maybe>
322 </td></tr></table>
323 </td></tr></table>
324 </form>
325 EOF
326
327
328 # collect the messages and put into message table....
329 my $messagetable;
330 if ($message) {
331     $messagetable = << "EOF";
332 <table border=1 cellpadding=5 cellspacing=0 bgcolor='#dddddd'>
333 <tr><th bgcolor=$headerbackgroundcolor background=$backgroundimage><font>Messages</font></th></tr>
334 <tr><td> $message </td></tr></table>
335 EOF
336 }
337
338
339
340 # make the issued books table.....
341 my $todaysissues='';
342 my $previssues='';
343 if ($borrower) {
344     my $issueslist = getissues($borrower);
345     my $tcolor = '';
346     my $pcolor = '';
347     foreach my $it (sort keys %$issueslist) {
348         my $dd = $issueslist->{$it}->{'date_due'};
349         my $issuedate = $issueslist->{$it}->{'timestamp'};
350         $issuedate = substr($issuedate, 0, 8);
351
352         my $bookissue = $issueslist->{$it};
353         my $bgcolor='';
354         my $datedue = $bookissue->{'date_due'};
355         #convert to nz style dates
356         #this should be set with some kinda config variable         
357         my @tempdate=split(/-/,$dd);
358         $dd="$tempdate[2]/$tempdate[1]/$tempdate[0]";
359         $datedue=~s/-//g;
360         if ($datedue < $todaysdate) {
361             $dd="<font color=red>$dd</font>\n";
362         }
363         if ($todaysdate == $issuedate) {
364             ($tcolor eq $linecolor1) ? ($tcolor=$linecolor2) : ($tcolor=$linecolor1);
365             $todaysissues .=<< "EOF";
366 <tr><td bgcolor=$tcolor align=center>$dd</td>
367 <td bgcolor=$tcolor align=center>
368 <a href=/cgi-bin/koha/detail.pl?bib=$bookissue->{'biblionumber'}&type=intra onClick=\"openWindow(this, 'Item', 480, 640)\">$bookissue->{'barcode'}</a></td>
369 <td bgcolor=$tcolor>$bookissue->{'title'}</td>
370 <td bgcolor=$tcolor>$bookissue->{'author'}</td>
371 <td bgcolor=$tcolor align=center>$bookissue->{'dewey'} $bookissue->{'subclass'}</td></tr>
372 EOF
373         } else {
374             ($pcolor eq $linecolor1) ? ($pcolor=$linecolor2) : ($pcolor=$linecolor1);
375             $previssues .= << "EOF";
376 <tr><td bgcolor=$pcolor align=center>$dd</td>
377 <td bgcolor=$pcolor align=center>
378 <a href=/cgi-bin/koha/detail.pl?bib=$bookissue->{'biblionumber'}&type=intra onClick=\"openWindow(this, 'Item', 480, 640)\">$bookissue->{'barcode'}</a></td>
379 <td bgcolor=$pcolor>$bookissue->{'title'}</td>
380 <td bgcolor=$pcolor>$bookissue->{'author'}</td>
381 <td bgcolor=$pcolor align=center>$bookissue->{'dewey'} $bookissue->{'subclass'}</td></tr>
382 EOF
383         }
384     }
385 }
386
387 my $issuedbookstable;
388 if ($todaysissues) {
389     $issuedbookstable .= <<"EOF";
390 <table border=1 cellpadding=5 cellspacing=0 width=80%>
391 <tr><th colspan=5 bgcolor=$headerbackgroundcolor background=$backgroundimage><font color=black>
392 <b>Todays Issues</b></font></th></tr>
393 <tr><th>Due Date</th><th>Bar Code</th><th>Title</th><th>Author</th><th>Class</th></tr>
394 $todaysissues
395 </table>
396 EOF
397 }
398 if ($previssues) {
399     $issuedbookstable .= <<"EOF";
400 <table border=1 cellpadding=5 cellspacing=0 width=80%>
401 <tr><th colspan=5 bgcolor=$headerbackgroundcolor background=$backgroundimage><font color=black>
402 <b>Previous Issues</b></font></th></tr>
403 <tr><th>Due Date</th><th>Bar Code</th><th>Title</th><th>Author</th><th>Class</th></tr>
404 $previssues
405 </table>
406 EOF
407 }
408
409
410
411
412
413 # actually print the page!
414
415
416 if ($branchcookie && $printercookie) {
417     print $query->header(-type=>'text/html',-expires=>'now', -cookie=>[$branchcookie,$printercookie]);
418 } else {
419     print $query->header();
420 }
421
422 print startpage();
423 print startmenu('circulation');
424
425 print $title;
426
427
428 print $info;
429
430 if ($question) {
431     print $questionform;
432 }
433
434 print $rejectedtext;
435 print $messagetable;
436
437
438 unless ($borrower) {
439     if ($borrowerslist) {
440         print $selectborrower;
441     } else {
442         print $cardnumberinput;
443     }
444 }
445
446
447
448 if ($borrower) {
449     my ($patrontable, $flaginfotable) = patrontable($borrower);
450     print $patrontable;
451     print $flaginfotable;
452     print $barcodeentrytext;
453     print "<p clear=all><br><br>";
454     print $issuedbookstable;
455 }
456
457
458
459
460 print endmenu('circulation');
461 print endpage();
462
463
464 ####################################################################
465 # Extra subroutines,,,
466
467 sub cuecatbarcodedecode {
468     my ($barcode) = @_;
469     chomp($barcode);
470     my @fields = split(/\./,$barcode);
471     my @results = map(decode($_), @fields[1..$#fields]);
472     if ($#results == 2){
473         return $results[2];
474     } else {
475         return $barcode;
476     } 
477
478
479 sub fixdate {
480     my ($year, $month, $day) = @_;
481     my $invalidduedate;
482     my $date;
483     if (($year eq 0) && ($month eq 0) && ($year eq 0)) {
484         $env{'datedue'}='';
485     } else {
486         if (($year eq 0) || ($month eq 0) || ($year eq 0)) {
487             $invalidduedate="Invalid Due Date Specified. Book was not issued.<p>\n";
488         } else {
489             if (($day>30) && (($month==4) || ($month==6) || ($month==9) || ($month==11))) {
490                 $invalidduedate = "Invalid Due Date Specified. Book was not issued. Only 30 days in $month month.<p>\n";
491             } elsif (($day > 29) && ($month == 2)) {
492                 $invalidduedate="Invalid Due Date Specified. Book was not issued.  Never that many days in February!<p>\n";
493             } elsif (($month == 2) && ($day > 28) && (($year%4) && ((!($year%100) || ($year%400))))) {
494                 $invalidduedate="Invalid Due Date Specified. Book was not issued.  $year is not a leap year.<p>\n";
495             } else {
496                 $date="$year-$month-$day";
497             }
498         }
499     }
500     return ($date, $invalidduedate);
501 }
502
503
504 sub patrontable {
505     my ($borrower) = @_;
506     my $flags = $borrower->{'flags'};
507     my $flaginfotable='';
508     my $flaginfotext='';
509     my $flag;
510     my $color='';
511     foreach $flag (sort keys %$flags) {
512         ($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1);
513         $flags->{$flag}->{'message'}=~s/\n/<br>/g;
514         if ($flags->{$flag}->{'noissues'}) {
515             if ($flag eq 'CHARGES') {
516                 $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";
517             } else {
518                 $flaginfotext.="<tr><td valign=top><font color=red>$flag</font></td><td bgcolor=$color>$flags->{$flag}->{'message'}</td></tr>\n";
519             }
520         } else {
521             if ($flag eq 'CHARGES') {
522                 $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";
523             } elsif ($flag eq 'WAITING') {
524                 my $itemswaiting='';
525                 my $items=$flags->{$flag}->{'itemlist'};
526                 foreach my $item (@$items) {
527                     my ($iteminformation) = getiteminformation(\%env, $item->{'itemnumber'}, 0);
528                     $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";
529                 }
530                 $flaginfotext.="<tr><td valign=top>$flag</td><td>$itemswaiting</td></tr>\n";
531             } elsif ($flag eq 'ODUES') {
532                 my $items=$flags->{$flag}->{'itemlist'};
533                 my $itemswaiting="<table border=1 cellspacing=0 cellpadding=2>\n";
534                 my $currentcolor=$color;
535                 {
536                     my $color=$currentcolor;
537                     foreach my $item (@$items) {
538                         ($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1);
539                         my ($iteminformation) = getiteminformation(\%env, $item->{'itemnumber'}, 0);
540                         $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";
541                     }               
542                 }
543                 $itemswaiting.="</table>\n";
544                 if ($query->param('module') ne 'returns'){
545                   $flaginfotext.="<tr><td valign=top>$flag</td><td>$flags->{$flag}->{'message'}, See below</td></tr>\n";
546                 } else {
547                   $flaginfotext.="<tr><td valign=top>$flag</td><td>$flags->{$flag}->{'message'}</td></tr>\n"; 
548                 }
549             } else {
550                 $flaginfotext.="<tr><td valign=top>$flag</td><td>$flags->{$flag}->{'message'}</td></tr>\n";
551             }
552         }
553     }
554     ($flaginfotext) && ($flaginfotext="<tr><td bgcolor=$headerbackgroundcolor background=$backgroundimage colspan=2><b>Flags</b></td></tr>$flaginfotext\n");
555     $flaginfotext.="</table>";
556     my $patrontable= << "EOF";
557 <br><p>
558     <table border=1 cellpadding=5 cellspacing=0 align=right>
559     <tr><td bgcolor=$headerbackgroundcolor background=$backgroundimage colspan=2><font color=black><b>Patron Information</b></font></td></tr>
560     <tr><td colspan=2>
561     <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>
562 EOF
563     return($patrontable, $flaginfotext);
564 }
565
566
567
568 sub printslip {
569     my ($env,$borrowernumber)=@_;
570     my ($borrower, $flags) = getpatroninformation($env,$borrowernumber,0);
571     $env->{'todaysissues'}=1;
572     my ($borrowerissues) = currentissues($env, $borrower);
573     $env->{'nottodaysissues'}=1;
574     $env->{'todaysissues'}=0;
575     my ($borroweriss2)=currentissues($env, $borrower);
576     $env->{'nottodaysissues'}=0;
577     my $i=0;
578     my @issues;
579     foreach (sort keys %$borrowerissues) {
580         $issues[$i]=$borrowerissues->{$_};
581         my $dd=$issues[$i]->{'date_due'};
582         #convert to nz style dates
583         #this should be set with some kinda config variable
584         my @tempdate=split(/-/,$dd);
585         $issues[$i]->{'date_due'}="$tempdate[2]/$tempdate[1]/$tempdate[0]";
586         $i++;
587     }
588     foreach (sort keys %$borroweriss2) {
589         $issues[$i]=$borroweriss2->{$_};
590         my $dd=$issues[$i]->{'date_due'};
591         #convert to nz style dates
592         #this should be set with some kinda config variable
593         my @tempdate=split(/-/,$dd);
594         $issues[$i]->{'date_due'}="$tempdate[2]/$tempdate[1]/$tempdate[0]";
595         $i++;
596     }
597     remoteprint($env,\@issues,$borrower);
598 }