Returns module lists recently returned items, cookies used to store branch
[srvgit] / circ / circulation.pl
1 #!/usr/bin/perl
2
3 use CGI qw/:standard/;
4 use C4::Circulation::Circ2;
5 use C4::Output;
6 use DBI;
7
8
9 my %env;
10 my $headerbackgroundcolor='#990000';
11 my $query=new CGI;
12 my $branches=getbranches(\%env);
13 my $printers=getprinters(\%env);
14 my $branch=$query->param('branch');
15 my $printer=$query->param('printer');
16 ($branch) || ($branch=$query->cookie('branch'));
17 ($printer) || ($printer=$query->cookie('printer'));
18 my ($oldbranch, $oldprinter);
19 if ($query->param('selectnewbranchprinter')) {
20     $oldbranch=$branch;
21     $oldprinter=$printer;
22     $branch='';
23     $printer='';
24 }
25 $env{'branchcode'}=$branch;
26 $env{'printer'}=$printer;
27 my $branchcount=0;
28 my $printercount=0;
29 my $branchoptions;
30 my $printeroptions;
31 foreach (keys %$branches) {
32     (next) unless ($_);
33     $branchcount++;
34     my $selected='';
35     ($selected='selected') if ($_ eq $oldbranch);
36     $branchoptions.="<option value=$_ $selected>$branches->{$_}->{'branchname'}\n";
37 }
38 foreach (keys %$printers) {
39     (next) unless ($_);
40     $printercount++;
41     my $selected='';
42     ($selected='selected') if ($_ eq $oldprinter);
43     $printeroptions.="<option value=$_ $selected>$printers->{$_}->{'printername'}\n";
44 }
45 if ($printercount==1) {
46     ($printer)=keys %$printers;
47 }
48 if ($branchcount==1) {
49     ($branch)=keys %$branches;
50 }
51
52
53 my $branchname='';
54 my $printername='';
55 if ($branch && $printer) {
56     $branchname=$branches->{$branch}->{'branchname'};
57     $printername=$printers->{$printer}->{'printername'};
58 }
59
60
61 my $branchcookie=$query->cookie(-name=>'branch', -value=>"$branch", -expires=>'+1y');
62 my $printercookie=$query->cookie(-name=>'printer', -value=>"$printer", -expires=>'+1y');
63
64 print $query->header(-type=>'text/html',-expires=>'now', -cookie=>[$branchcookie,$printercookie]);
65 print startpage();
66 print startmenu('circulation');
67
68
69 print << "EOF";
70 <center>
71 <p>
72 <table border=0 width=100%>
73 <tr>
74 <td width=5%></td>
75 <td align=right width=30%><table border=1 bgcolor=$headerbackgroundcolor width=100%><tr><th><font color=white>$branchname</font></th></tr></table></td>
76 <td align=center width=20%>
77 <a href=circulation.pl?module=issues&branch=$branch&printer=$printer><img src=/images/issues.gif border=0 width=60></a>
78 <a href=circulation.pl?module=returns&branch=$branch&printer=$printer><img src=/images/returns.gif border=0 width=60></a>
79 <br>
80 <a href=circulation.pl?selectnewbranchprinter=1>Set Branch/Printer</a>
81 </td><td align=left width=30%>
82 <table border=1 bgcolor=$headerbackgroundcolor width=100%><tr><th><font color=white>$printername</font></th></tr></table>
83 </td>
84 <td width=5%></td>
85 </tr>
86 </table>
87 <br>
88 EOF
89
90
91 if ($printer && $branch) {
92
93     SWITCH: {
94         if ($query->param('module') eq 'issues') { issues(); last SWITCH; }
95         if ($query->param('module') eq 'returns') { returns(); last SWITCH; }
96         issues();
97     }
98 } else {
99     my ($printerform, $branchform);
100     if ($printercount>1) {
101         $printerform=<<"EOF";
102 <table border=1>
103 <tr><th bgcolor=$headerbackgroundcolor><font color=white>Choose a Printer</font></td></tr>
104 <tr><td>
105 <select name=printer>
106 $printeroptions
107 </select>
108 </td></tr>
109 </table>
110 EOF
111     } else {
112         my ($printer) = keys %$printers;
113         $printerform=<<"EOF";
114         <input type=hidden name=printer value=$printer>
115 EOF
116     }
117
118     if ($branchcount>1) {
119         $branchform=<<"EOF";
120 <table border=1>
121 <tr><th bgcolor=$headerbackgroundcolor><font color=white>Choose a Branch</font></td></tr>
122 <tr><td>
123 <select name=branch>
124 $branchoptions
125 </select>
126 </td></tr>
127 </table>
128 EOF
129     }
130     print << "EOF";
131     Select a branch and a printer
132     <form method=get>
133     <table border=0>
134     <tr><td>
135     $branchform
136     </td><td>
137     $printerform
138     </td></tr>
139     </table>
140     <input type=submit>
141     </form>
142 EOF
143 }
144
145
146 print endmenu('circulation');
147 print endpage();
148 sub default {
149 print << "EOF";
150 <a href=circulation.pl?module=issues&branch=$branch&printer=$printer>Issues</a>
151 <a href=circulation.pl?module=returns&branch=$branch&printer=$printer>Returns</a>
152 EOF
153 }
154
155
156 sub returns {
157     my %returneditems;
158     foreach ($query->param) {
159         (next) unless (/ri-(\d*)/);
160         my $counter=$1;
161         (next) if ($counter>20);
162         my $barcode=$query->param("ri-$counter");
163         $counter++;
164         $returneditems{$counter}=$barcode;
165         $ritext.="<input type=hidden name=ri-$counter value=$barcode>\n";
166     }
167     if (my $barcode=$query->param('barcode')) {
168         $ritext.="<input type=hidden name=ri-0 value=$barcode>\n";
169         $returneditems{0}=$barcode;
170     }
171         
172     print << "EOF";
173     <form method=get>
174     <table border=3 bgcolor=#dddddd>
175         <tr><td colspan=2 bgcolor=$headerbackgroundcolor align=center><font color=white><b><font size=+1>Returns</font><br>Enter Book Barcode</b></font></td></tr>
176         <tr><td>Item Barcode:</td><td><input name=barcode size=10></td></tr>
177     </table>
178     <input type=hidden name=module value=returns>
179     <input type=hidden name=branch value=$branch>
180     <input type=hidden name=printer value=$printer>
181     $ritext
182     </form>
183 EOF
184     if (my $barcode=$query->param('barcode')) {
185         my ($iteminformation, $borrower, $messages, $overduecharge) = returnbook(\%env, $barcode);
186         (my $nosuchitem=1) unless ($iteminformation);
187         my $itemtable=<<"EOF";
188 <table border=1 bgcolor=#dddddd>
189 <tr><th bgcolor=$headerbackgroundcolor><font color=white>Item Information</font></th></tr>
190 <tr><td>
191 Title: $iteminformation->{'title'}<br>
192 Author: $iteminformation->{'author'}<br>
193 Barcode: <a href=/cgi-bin/koha/detail.pl?bib=$iteminformation->{'biblionumber'}&type=intra onClick="openWindow(this, 'Item', 480, 640)">$iteminformation->{'barcode'}</a><br>
194 Date Due: $iteminformation->{'date_due'}
195 </td></tr>
196 </table>
197 EOF
198         if ($nosuchitem) {
199             print << "EOF";
200             <table border=1 bgcolor=#dddddd>
201             <tr><th bgcolor=$headerbackgroundcolor><font color=white>Error</font></th></tr>
202             <tr><td>
203             <table border=0 cellpadding=5>
204             <tr><td>
205             $barcode is not a valid barcode.
206             </td></tr>
207             </table>
208             </td></tr>
209             </table>
210 EOF
211         } else {
212             if ($borrower) {
213                 my ($patrontable, $flaginfotext) = patrontable($borrower);
214                 print "<hr><p><table border=0><tr><td valign=top align=center>$patrontable</td><td valign=top align=center>$flaginfotext</td></tr><tr><td colspan=2 align=center>$itemtable</td></tr></table><br>\n";
215             } else {
216                 print << "EOF";
217                 <table border=1 bgcolor=#dddddd>
218                 <tr><th bgcolor=$headerbackgroundcolor><font color=white>Error</font></th></tr>
219                 <tr><td>
220                 <table border=0 cellpadding=5>
221                 <tr><td>
222                 $iteminformation->{'title'} by $iteminformation->{'author'} was not loaned out.
223                 </td></tr>
224                 </table>
225                 </td></tr>
226                 </table>
227 EOF
228             }
229         }
230         print << "EOF";
231         <p>
232         <hr>
233         <p>
234         <table border=1 bgcolor=#dddddd>
235         <tr><th colspan=4 bgcolor=$headerbackgroundcolor><font color=white>Returned Items</font></th></tr>
236         <tr><th>Bar Code</th><th>Title</th><th>Author</th><th>Class</th></tr>
237 EOF
238         foreach (sort {$a <=> $b} keys %returneditems) {
239             my $barcode=$returneditems{$_};
240             my ($iteminformation) = getiteminformation(\$env, 0, $barcode);
241             print "<tr><td align=center><a href=/cgi-bin/koha/detail.pl?bib=$iteminformation->{'biblionumber'}&type=intra onClick=\"openWindow(this, 'Item', 480, 640)\">$barcode</a></td><td>$iteminformation->{'title'}</td><td>$iteminformation->{'author'}</td><td align=center>$iteminformation->{'dewey'} $iteminformation->{'subclass'}</td></tr>\n";
242         }
243         print "</table>\n";
244     }
245 }
246
247 sub issues {
248     if (my $borrnumber=$query->param('borrnumber')) {
249         my ($borrower, $flags) = getpatroninformation(\%env,$borrnumber,0);
250         my ($borrower, $flags) = getpatroninformation(\%env,$borrnumber,0);
251         my $year=$query->param('year');
252         my $month=$query->param('month');
253         my $day=$query->param('day');
254         if (my $barcode=$query->param('barcode')) {
255             my $invalidduedate=0;
256             $env{'datedue'}='';
257             if (($year eq 0) && ($month eq 0) && ($year eq 0)) {
258                 $env{'datedue'}='';
259             } else {
260                 if (($year eq 0) || ($month eq 0) || ($year eq 0)) {
261                     print "Invalid Due Date Specified. Book was not issued.<p>\n";
262                     $invalidduedate=1;
263                 } else {
264                     if (($day>30) && (($month==4) || ($month==6) || ($month==9) || ($month==11))) {
265                         print "Invalid Due Date Specified. Book was not issued.<p>\n";
266                         $invalidduedate=1;
267                     } elsif (($day>29) && ($month==2)) {
268                         print "Invalid Due Date Specified. Book was not issued.<p>\n";
269                         $invalidduedate=1;
270                     } elsif (($day>28) && (($year%4) && ((!($year%100) || ($year%400))))) {
271                         print "Invalid Due Date Specified. Book was not issued.<p>\n";
272                         $invalidduedate=1;
273                     } else {
274                         $env{'datedue'}="$year-$month-$day";
275                     }
276                 }
277             }
278             my %responses;
279             foreach (sort $query->param) {
280                 if ($_ =~ /response-(\d*)/) {
281                     $responses{$1}=$query->param($_);
282                 }
283             }
284             if (my $qnumber=$query->param('questionnumber')) {
285                 $responses{$qnumber}=$query->param('answer');
286             }
287             unless ($invalidduedate) {
288                 my ($iteminformation, $duedate, $rejected, $question, $questionnumber, $defaultanswer, $message) = issuebook(\%env, $borrower, $barcode, \%responses);
289                 unless ($iteminformation) {
290                     print << "EOF";
291                     <table border=1 bgcolor=#dddddd>
292                     <tr><th bgcolor=$headerbackgroundcolor><font color=white>Error</font></th></tr>
293                     <tr><td>
294                     <table border=0 cellpadding=5>
295                     <tr><td>
296                     $barcode is not a valid barcode.
297                     </td></tr>
298                     </table>
299                     </td></tr>
300                     </table>
301 EOF
302                 }
303                 if ($rejected) {
304                     if ($rejected == -1) {
305                     } else {
306                         print << "EOF"
307                         <table border=1 bgcolor=#dddddd>
308                         <tr><th bgcolor=$headerbackgroundcolor><font color=white>Error Issuing Book</font></th></tr>
309                         <tr><td><font color=red>$rejected</font></td></tr>
310                         </table>
311                         <br>
312 EOF
313                     }
314                 }
315                 my $responsesform='';
316                 foreach (keys %responses) {
317                     $responsesform.="<input type=hidden name=response-$_ value=$responses{$_}>\n";
318                 }
319                 if ($question) {
320                     my $stickyduedate=$query->param('stickyduedate');
321                     print << "EOF";
322                     <table border=1 bgcolor=#dddddd>
323                     <tr><th bgcolor=$headerbackgroundcolor><font color=white><b>Issuing Question</b></font></td></tr>
324                     <tr><td>
325                     <table border=0 cellpadding=10>
326                     <tr><td>
327                     Attempting to issue $iteminformation->{'title'} by $iteminformation->{'author'} to $borrower->{'firstname'} $borrower->{'surname'}.
328                     <p>
329                     $question
330                     </td></tr>
331                     </table>
332                     </td></tr>
333
334                     <tr><td align=center>
335                     <table border=0>
336                     <tr><td>
337                     <form method=get>
338                     <input type=hidden name=module value=issues>
339                     <input type=hidden name=borrnumber value=$borrnumber>
340                     <input type=hidden name=barcode value=$barcode>
341                     <input type=hidden name=questionnumber value=$questionnumber>
342                     <input type=hidden name=day value=$day>
343                     <input type=hidden name=month value=$month>
344                     <input type=hidden name=year value=$year>
345                     <input type=hidden name=stickyduedate value=$stickyduedate>
346                     <input type=hidden name=branch value=$branch>
347                     <input type=hidden name=printer value=$printer>
348                     $responsesform
349                     <input type=hidden name=answer value=Y>
350                     <input type=submit value=Yes>
351                     </form>
352                     </td>
353                     <td>
354                     <form method=get>
355                     <input type=hidden name=module value=issues>
356                     <input type=hidden name=borrnumber value=$borrnumber>
357                     <input type=hidden name=barcode value=$barcode>
358                     <input type=hidden name=questionnumber value=$questionnumber>
359                     <input type=hidden name=day value=$day>
360                     <input type=hidden name=month value=$month>
361                     <input type=hidden name=year value=$year>
362                     <input type=hidden name=stickyduedate value=$stickyduedate>
363                     <input type=hidden name=branch value=$branch>
364                     <input type=hidden name=printer value=$printer>
365                     $responsesform
366                     <input type=hidden name=answer value=N>
367                     <input type=submit value=No>
368                     </form>
369                     </td>
370                     </tr>
371                     </table>
372                     </td></tr>
373                     </table>
374 EOF
375                     return;
376                 }
377                 if ($message) {
378                     print << "EOF";
379                     <table border=1 bgcolor=#dddddd>
380                     <tr><th bgcolor=$headerbackgroundcolor><font color=white>Message</font></th></tr>
381                     <tr><td>$message</td></tr>
382                     </table>
383                     <p>
384 EOF
385                 }
386             }
387         }
388         my $issueid=$query->param('issueid');
389         ($issueid) || ($issueid=int(rand()*1000000000));
390         my $flag='';
391         my $flagtext='';
392         my $flaginfotext='';
393         foreach $flag (sort keys %$flags) {
394             if ($flags->{$flag}->{'noissues'}) {
395                 $flagtext.="<font color=red>$flag</font> ";
396             } else {
397                 $flagtext.="$flag ";
398             }
399             $flags->{$flag}->{'message'}=~s/\n/<br>/g;
400             if ($flags->{$flag}->{'noissues'}) {
401                 $flaginfotext.="<tr><td bgcolor=red valign=top><font color=white><b>$flag</b></font></td><td bgcolor=red><font color=white><b>$flags->{$flag}->{'message'}</b></font></td></tr>\n";
402             } else {
403                 $flaginfotext.="<tr><td valign=top>$flag</td><td>$flags->{$flag}->{'message'}</td></tr>\n";
404             }
405         }
406         if ($flaginfotext) {
407             $flaginfotext="<table border=1 width=70% bgcolor=#dddddd><tr><th bgcolor=$headerbackgroundcolor colspan=2><font color=white>Patron Flags</font></th></tr>$flaginfotext</table>\n";
408         }
409         $env{'nottodaysissues'}=1;
410         my ($borrowerissues) = currentissues(\%env, $borrower);
411         $env{'nottodaysissues'}=0;
412         $env{'todaysissues'}=1;
413         my ($today) = currentissues(\%env, $borrower);
414         $env{'todaysissues'}=0;
415         my $previssues='';
416         my @datearr = localtime(time());
417         my $todaysdate = (1900+$datearr[5]).sprintf ("%0.2d", ($datearr[4]+1)).sprintf ("%0.2d", $datearr[3]);
418         foreach (sort keys %$borrowerissues) {
419             my $bookissue=$borrowerissues->{$_};
420             my $bgcolor='';
421             my $datedue=$bookissue->{'date_due'};
422             $datedue=~s/-//g;
423             if ($datedue < $todaysdate) {
424                 $bgcolor="bgcolor=red";
425             }
426             #$previssues.="<tr $bgcolor><td>$bookissue->{'date_due'}</td><td>$bookissue->{'barcode'}</td><td>$bookissue->{'title'}</td><td>$bookissue->{'author'}</td><td>$bookissue->{'dewey'} $bookissue->{'subclass'}</td></tr>\n";
427             $previssues.="<tr><td align=center>$bookissue->{'date_due'}</td><td align=center><a href=/cgi-bin/koha/detail.pl?bib=$bookissue->{'biblionumber'}&type=intra onClick=\"openWindow(this, 'Item', 480, 640)\">$bookissue->{'barcode'}</a></td><td>$bookissue->{'title'}</td><td>$bookissue->{'author'}</td><td align=center>$bookissue->{'dewey'} $bookissue->{'subclass'}</td></tr>\n";
428         }
429         my $todaysissues='';
430         foreach (sort keys %$today) {
431             my $bookissue=$today->{$_};
432             $todaysissues.="<tr><td align=center>$bookissue->{'date_due'}</td><td align=center><a href=/cgi-bin/koha/detail.pl?bib=$bookissue->{'biblionumber'}&type=intra onClick=\"openWindow(this, 'Item', 480, 640)\">$bookissue->{'barcode'}</a></td><td>$bookissue->{'title'}</td><td>$bookissue->{'author'}</td><td align=center>$bookissue->{'dewey'} $bookissue->{'subclass'}</td></tr>\n";
433         }
434         for ($i=1; $i<32; $i++) {
435             my $selected='';
436             if (($query->param('stickyduedate')) && ($day==$i)) {
437                 $selected='selected';
438             }
439             $dayoptions.="<option value=$i $selected>$i";
440         }
441         my $counter=1;
442         foreach (('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec')) {
443             my $selected='';
444             if (($query->param('stickyduedate')) && ($month==$counter)) {
445                 $selected='selected';
446             }
447             $monthoptions.="<option value=$counter $selected>$_";
448             $counter++;
449         }
450         for ($i=$datearr[5]+1900; $i<$datearr[5]+1905; $i++) {
451             my $selected='';
452             if (($query->param('stickyduedate')) && ($year==$i)) {
453                 $selected='selected';
454             }
455             $yearoptions.="<option value=$i $selected>$i";
456         }
457
458         my $selected='';
459         ($query->param('stickyduedate')) && ($selected='checked');
460         my ($borrower, $flags) = getpatroninformation(\%env,$borrnumber,0);
461         my ($patrontable, $flaginfotable) = patrontable($borrower);
462         print << "EOF";
463         <form method=get>
464     <table border=0 cellpadding=5 width=90%>
465     <tr>
466         <td align=center valign=top>
467             <table border=1 bgcolor=#dddddd width=100%>
468                 <tr><td align=center bgcolor=$headerbackgroundcolor><font color=white><b>Enter Book Barcode</b></font></td></tr>
469                 <tr><td align=center>
470                 <table border=0 bgcolor=#dddddd>
471                 <tr><td>Item Barcode:</td><td><input name=barcode size=10></td><td><input type=submit value=Issue></tr>
472                 <tr><td colspan=3 align=center>
473                 <select name=day><option value=0>Day$dayoptions</select><select name=month><option value=0>Month$monthoptions</select><select name=year><option value=0>Year$yearoptions</select>
474                 <br>
475                 <input type=checkbox name=stickyduedate $selected> Sticky Due Date
476                 </td></tr>
477                 </table>
478                 </td></tr>
479             </table>
480         <input type=hidden name=module value=issues>
481         <input type=hidden name=borrnumber value=$borrnumber>
482         <input type=hidden name=branch value=$branch>
483         <input type=hidden name=printer value=$printer>
484         </form>
485         </td>
486         <td align=center valign=top>
487         $patrontable
488         <br>
489         $flaginfotable
490         </td>
491     </tr>
492     <tr>
493         <td colspan=2 align=center>
494         <table border=1 width=100% bgcolor=#dddddd>
495             <tr><th colspan=5 bgcolor=$headerbackgroundcolor><font color=white><b>Issues Today</b></font></th></tr>
496             <tr><th>Due Date</th><th>Bar Code</th><th>Title</th><th>Author</th><th>Class</th></tr>
497             $todaysissues
498         </table>
499         </td>
500     </tr>
501     <tr>
502         <td colspan=2 align=center>
503         <table border=1 width=100% bgcolor=#dddddd>
504             <tr><th colspan=5 bgcolor=$headerbackgroundcolor><font color=white><b>Previous Issues</b></font></th></tr>
505             <tr><th>Due Date</th><th>Bar Code</th><th>Title</th><th>Author</th><th>Class</th></tr>
506             $previssues
507         </table>
508         </td>
509     </tr>
510 </table>
511 <p>
512 EOF
513     } else {
514         if (my $findborrower=$query->param('findborrower')) {
515             my ($borrowers, $flags) = findborrower(\%env, $findborrower);
516             my @borrowers=@$borrowers;
517             if ($#borrowers == -1) {
518                 $query->param('findborrower', '');
519                 print "No borrower matched '$findborrower'<p>\n";
520                 issues();
521                 return;
522             }
523             if ($#borrowers == 0) {
524                 $query->param('borrnumber', $borrowers[0]->{'borrowernumber'});
525                 issues();
526                 return;
527             } else {
528                 print "<form method=get>\n";
529                 print "<input type=hidden name=module value=issues>\n";
530                 print "<input type=hidden name=branch value=$branch>\n";
531                 print "<input type=hidden name=printer value=$printer>\n";
532                 print "<table border=1 cellpadding=5 bgcolor=#dddddd>";
533                 print "<tr><th bgcolor=$headerbackgroundcolor><font color=white><b><font size=+1>Issues</font><br>Select a borrower</b></font></th></tr>\n";
534                 print "<tr><td align=center>\n";
535                 print "<select name=borrnumber size=7>\n";
536                 foreach (sort {$a->{'surname'}.$a->{'firstname'} cmp $b->{'surname'}.$b->{'firstname'}} @$borrowers) {
537                     print "<option value=$_->{'borrowernumber'}>$_->{'surname'}, $_->{'firstname'} ($_->{'cardnumber'})\n";
538                 }
539                 print "</select><br>";
540                 print "<input type=submit>\n";
541                 print "</td></tr></table>\n";
542             }
543         } else {
544             print << "EOF";
545 <form method=get>
546 <table border=1 bgcolor=#dddddd>
547 <tr><th bgcolor=$headerbackgroundcolor><font color=white><b><font size=+1>Issues</font><br>Enter borrower card number<br> or partial last name</b></font></td></tr>
548 <tr><td><input name=findborrower></td></tr>
549 </table>
550 <input type=hidden name=module value=issues>
551 <input type=hidden name=branch value=$branch>
552 <input type=hidden name=printer value=$printer>
553 </form>
554 EOF
555         }
556     }
557 }
558
559
560 sub patrontable {
561     my ($borrower) = @_;
562     my $flags=$borrower->{'flags'};
563     my $flagtext='';
564     my $flaginfotable='';
565     my $flaginfotext='';
566     my $flag;
567     foreach $flag (sort keys %$flags) {
568         if ($flags->{$flag}->{'noissues'}) {
569             $flagtext.="<font color=red>$flag</font> ";
570         } else {
571             $flagtext.="$flag ";
572         }
573         $flags->{$flag}->{'message'}=~s/\n/<br>/g;
574         if ($flags->{$flag}->{'noissues'}) {
575             if ($flag eq 'CHARGES') {
576                 $flaginfotext.="<tr><td bgcolor=red valign=top><font color=white><b>$flag</b></font></td><td><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";
577             } else {
578                 $flaginfotext.="<tr><td bgcolor=red valign=top><font color=white><b>$flag</b></font></td><td bgcolor=red><font color=white><b>$flags->{$flag}->{'message'}</b></font></td></tr>\n";
579             }
580         } else {
581             if ($flag eq 'CHARGES') {
582                 $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";
583             } else {
584                 $flaginfotext.="<tr><td valign=top>$flag</td><td>$flags->{$flag}->{'message'}</td></tr>\n";
585             }
586         }
587     }
588     ($flaginfotext) && ($flaginfotext="<table border=1 bgcolor=#dddddd><tr><th bgcolor=$headerbackgroundcolor colspan=2><font color=white>Patron Flags</font></th></tr>$flaginfotext</table>\n");
589     my $patrontable= << "EOF";
590     <table border=1 bgcolor=#dddddd>
591     <tr><th bgcolor=$headerbackgroundcolor><font color=white><b>Patron Information</b></font></td></tr>
592     <tr><td>
593     <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>
594     $borrower->{'streetaddress'} $borrower->{'city'}<br>
595     $borrower->{'categorycode'} $flagtext
596     </td></tr>
597     </table>
598 EOF
599     return($patrontable, $flaginfotext);
600 }