Regex to change the javascript to make cursor start in barcode box
[koha.git] / moremember.pl
1 #!/usr/bin/perl
2
3 # script to do a borrower enquiry/bring up borrower details etc
4 # Displays all the details about a borrower
5 # written 20/12/99 by chris@katipo.co.nz
6 # last modified 21/1/2000 by chris@katipo.co.nz
7 # modified 31/1/2001 by chris@katipo.co.nz 
8 #   to not allow items on request to be renewed
9 #
10 # needs html removed and to use the C4::Output more, but its tricky
11 #
12
13 use strict;
14 use C4::Output;
15 use CGI;
16 use C4::Search;
17 use Date::Manip;
18 use C4::Reserves2;
19 use C4::Circulation::Renewals2;
20 use C4::Circulation::Circ2;
21 use C4::Koha;
22
23 my $input = new CGI;
24 my $bornum=$input->param('bornum');
25
26
27 print $input->header;
28
29 #start the page and read in includes
30 print startpage();
31 print startmenu('member');
32 my $data=borrdata('',$bornum);
33
34
35 $data->{'dateenrolled'} = slashifyDate($data->{'dateenrolled'});
36 $data->{'expiry'} = slashifyDate($data->{'expiry'});
37 $data->{'dateofbirth'} = slashifyDate($data->{'dateofbirth'});
38
39 $data->{'ethnicity'} = fixEthnicity($data->{'ethnicity'});
40
41 print <<printend
42 <FONT SIZE=6><em>$data->{'firstname'} $data->{'surname'}</em></FONT><P>
43 <p>
44 <form action=/cgi-bin/koha/jmemberentry.pl method=post>
45 <TABLE  CELLSPACING=0  CELLPADDING=5 border=1 align=left width=270>
46 <TR VALIGN=TOP>
47 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>MEMBERSHIP RECORD</TD></TR>
48 <tr VALIGN=TOP  >       
49 <TD>
50 <p align=right><INPUT TYPE="image" name="submit"  VALUE="add-child" height=42  WIDTH=120 BORDER=0 src="/images/add-child.gif">          
51 <input type=hidden name=type value=Add>
52 <input type=hidden name=bornum value=$data->{'borrowernumber'}>
53 </form>
54 </P><br>
55 <FONT SIZE=2  face="arial, helvetica">$data->{'title'} $data->{'othernames'}  $data->{'surname'} ($data->{'firstname'}, $data->{'initials'})<p>
56
57 Card Number: $data->{'cardnumber'}<BR>
58 printend
59 ;
60 if ($data->{'categorycode'} eq 'C'){
61     my $data2=borrdata('',$data->{'guarantor'});
62     $data->{'streetaddress'}=$data2->{'streetaddress'};
63     $data->{'city'}=$data2->{'city'};
64     $data->{'physstreet'}=$data2->{'phystreet'};
65     $data->{'streetcity'}=$data2->{'streetcity'};
66     $data->{'phone'}=$data2->{'phone'};
67     $data->{'phoneday'}=$data2->{'phoneday'};
68 }
69 my $ethnicityline='';
70 if ($data->{'ethnicity'} || $data->{'ethnotes'}) {
71         $ethnicityline="Ethnicity: $data->{'ethnicity'}, $data->{'ethnotes'}<br>";
72 }
73 print <<printend
74 Postal Address: $data->{'streetaddress'}, $data->{'city'}<BR>
75 Home Address: $data->{'physstreet'}, $data->{'streetcity'}<BR>
76 Phone (Home): $data->{'phone'}<BR>
77 Phone (Daytime): $data->{'phoneday'}<BR>
78 Fax: $data->{'faxnumber'}<BR>
79 E-mail: <a href="mailto:$data->{'emailaddress'}">$data->{'emailaddress'}</a><br>
80 Textmessaging:$data->{'textmessaging'}<p>
81 Membership Number: $data->{'borrowernumber'}<BR>
82 Membership: $data->{'categorycode'}<BR>
83 Area: $data->{'area'}<BR>
84 Fee:$30/year, Paid<BR>
85 Joined: $data->{'dateenrolled'},  Expires: $data->{'expiry'} <BR>
86 Joining Branch: $data->{'homebranch'}<P>
87 $ethnicityline
88 DoB: $data->{'dateofbirth'}<BR>
89 Sex: $data->{'sex'}<P>
90
91 Alternative Contact:$data->{'contactname'}<BR>
92 Phone: $data->{'altphone'}<BR>
93 Relationship: $data->{'altrelationship'}<BR>
94 Notes: $data->{'altnotes'}<P>
95 printend
96 ;
97
98 if ($data->{'categorycode'} ne 'C'){
99   print " Guarantees:";
100   # FIXME
101   # It looks like the $i is only being returned to handle walking through
102   # the array, which is probably better done as a foreach loop.
103   #
104   my ($count,$guarantees)=findguarantees($data->{'borrowernumber'});
105   for (my $i=0;$i<$count;$i++){
106     print "<A HREF=\"/cgi-bin/koha/moremember.pl?bornum=$guarantees->[$i]->{'borrowernumber'}\">$guarantees->[$i]->{'cardnumber'}</a><br>";
107   }
108 } else {
109   print "Guarantor:";
110   my ($guarantor)=findguarantor($data->{'borrowernumber'});
111   if ($guarantor->{'borrowernumber'} == 0){
112       print "no guarantor<br>";
113   } else {
114     print "<A HREF=\"/cgi-bin/koha/moremember.pl?bornum=$guarantor->{'borrowernumber'}\">$guarantor->{'cardnumber'}</a><br>";
115   }
116 }
117 print <<printend
118
119
120 <P>
121
122 General Notes: <!--<A HREF="popbox.html" onclick="messenger(200,250,'Form that lets you add to and delete notes.'); return false">-->
123 $data->{'borrowernotes'}<!--</a>-->
124 <p align=right>
125 <form action=/cgi-bin/koha/memberentry.pl method=post>
126 <input type=hidden name=bornum value=$bornum>
127 <INPUT TYPE="image" name="modify"  VALUE="modify" height=42  WIDTH=93 BORDER=0 src="/images/modify-mem.gif"> 
128
129 <INPUT TYPE="image" name="delete"  VALUE="delete" height=42  WIDTH=93 BORDER=0 src="/images/delete-mem.gif"> 
130 </p>
131
132 </TD>
133 </TR>
134 </TABLE>
135 </FORM>
136 <img src="/images/holder.gif" width=16 height=800 align=left>
137 <TABLE  CELLSPACING=0  CELLPADDING=5 border=1 >
138 <TR VALIGN=TOP>
139 <td  bgcolor="99cc33" background="/images/background-mem.gif" colspan=4><B>FINES & CHARGES</TD></TR>
140 printend
141 ;
142 my %bor;
143 $bor{'borrowernumber'}=$bornum;
144
145 # FIXME
146 # it looks like $numaccts is a temp variable and that the 
147 # for (my $i;$i<$numaccts;$i+++) 
148 # can be turned into a foreach loop instead
149 #
150 my ($numaccts,$accts,$total)=getboracctrecord('',\%bor);
151 #if ($numaccts > 10){
152 #  $numaccts=10;
153 #}
154 for (my$i=0;$i<$numaccts;$i++){
155 #if ($accts->[$i]{'accounttype'} ne 'Pay'){
156   my $amount= $accts->[$i]{'amount'} + 0.00;
157     my $amount2= $accts->[$i]{'amountoutstanding'} + 0.00;
158   if ($amount2 != 0){
159     print "<tr VALIGN=TOP  >";
160     my $item=" &nbsp; ";
161     
162     $accts->[$i]{'date'} = slashifyDate($accts->[$i]{'date'});
163
164     if ($accts->[$i]{'accounttype'} ne 'Res'){
165     #get item data
166     #$item=
167     }
168     print "<td>$accts->[$i]{'date'}</td>";
169 #  print "<TD>$accts->[$i]{'accounttype'}</td>";
170     print "<TD>";
171
172     # FIXME
173     # why set this variable if it's not going to be used?
174     #
175     my $env;
176     if ($accts->[$i]{'accounttype'} ne 'Res'){
177       my $iteminfo=C4::Circulation::Circ2::getiteminformation($env,$accts->[$i]->{'itemnumber'},'');
178       print "<a href=/cgi-bin/koha/moredetail.pl?itemnumber=$accts->[$i]->{'itemnumber'}&bib=$iteminfo->{'biblionumber'}&bi=$iteminfo->{'biblioitemnumber'}>$accts->[$i]->{'description'} $accts->[$i]{'title'}</a>";
179     }
180     print "</td>
181     <TD>$amount</td><td>$amount2</td>
182     </tr>";
183   }
184 }
185 print <<printend
186
187 <tr VALIGN=TOP  >
188 <TD colspan=3 align=right>
189 <nobr>
190 <a href=/cgi-bin/koha/boraccount.pl?bornum=$bornum><img height=42  WIDTH=187 BORDER=0 src="/images/view-account.gif"></a>
191 <a href=/cgi-bin/koha/pay.pl?bornum=$bornum><img height=42  WIDTH=187 BORDER=0 src="/images/pay-fines.gif"></a></nobr>
192 </td>
193
194 </tr>
195
196
197 </table>
198
199 <p>
200 <form action="renewscript.pl" method=post>
201 <input type=hidden name=bornum value=$bornum>
202 <TABLE  CELLSPACING=0  CELLPADDING=5 border=1 >
203
204 <TR VALIGN=TOP>
205
206 <td  bgcolor="99cc33" background="/images/background-mem.gif" colspan=6><B>ITEMS CURRENTLY ON ISSUE</b></TD>
207 </TR>
208
209 <TR VALIGN=TOP>
210 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Title</b></TD>
211 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Due</b></TD>
212 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Itemtype</b></TD>
213 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Charge</b></TD>
214 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Renew</b></TD>
215 </TR>
216 printend
217 ;
218 my ($count,$issue)=borrissues($bornum);
219 my $today=ParseDate('today');
220 for (my $i=0;$i<$count;$i++){
221   print "<tr VALIGN=TOP  >
222   <TD>";
223     my $datedue=ParseDate($issue->[$i]{'date_due'});
224
225   $issue->[$i]{'date_due'} = slashifyDate($issue->[$i]{'date_due'});
226
227   if ($datedue < $today){  
228     print "<font color=red>";
229   }
230   print "$issue->[$i]{'title'} 
231   <a href=/cgi-bin/koha/moredetail.pl?item=$issue->[$i]->{'itemnumber'}&bib=$issue->[$i]->{'biblionumber'}&bi=$issue->[$i]->{'biblioitemnumber'}>
232   $issue->[$i]{'barcode'}</a></td>
233   <TD>$issue->[$i]{'date_due'}</td>";
234   #find the charge for an item
235   my ($charge,$itemtype)=calc_charges(undef,$issue->[$i]{'itemnumber'},$bornum);
236   print "<TD>$itemtype</td>";
237   print "<TD>$charge</td>";
238
239 #  if ($datedue < $today){
240 #    print "<td>Overdue</td>";
241 #  } else {
242 #    print "<td> &nbsp; </td>";
243 #  }
244   #check item is not reserved
245   my ($rescount,$reserves)=Findgroupreserve($issue->[$i]{'biblioitemnumber'},$issue->[$i]{'biblionumber'});
246   if ($rescount >0){
247     print "<TD><a href=/cgi-bin/koha/request.pl?bib=$issue->[$i]{'biblionumber'}>On Request - no renewals</a></td></tr>";
248 #  } elsif ($issue->[$i]->{'renewals'} > 0) {
249 #      print "<TD>Previously Renewed - no renewals</td></tr>";
250   } else {
251     print "<TD>";
252   
253     print "<input type=radio name=\"renew_item_$issue->[$i]{'itemnumber'}\" value=y>Y
254     <input type=radio name=\"renew_item_$issue->[$i]{'itemnumber'}\" value=n>N</td>
255     </tr>
256     ";
257   }
258 }
259 print <<printend
260
261 <tr VALIGN=TOP  >
262 <TD colspan=5 align=right>
263 <INPUT TYPE="image" name="submit"  VALUE="update" height=42  WIDTH=187 BORDER=0 src="/images/update-renewals.gif">
264 </td>
265 </form>
266 </tr>
267
268
269 </table>
270
271
272 <P>
273
274 <TABLE  CELLSPACING=0  CELLPADDING=5 border=1 >
275
276 <TR VALIGN=TOP>
277
278 <td  bgcolor="99cc33" background="/images/background-mem.gif" colspan=5><B>ITEMS REQUESTED</b></TD>
279 </TR>
280
281 <TR VALIGN=TOP>
282
283 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Title</b></TD>
284 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Requested</b></TD>
285
286
287 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Charge</b></TD>
288
289 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Remove</b></TD>
290 </TR>
291 <form action=/cgi-bin/koha/modrequest.pl method=post>
292 <input type=hidden name=from value=borrower>
293 printend
294 ;
295
296 my ($rescount,$reserves)=FindReserves('',$bornum); #From C4::Reserves2
297
298 # FIXME
299 # does it make sense to turn this into a foreach my $i (0..$rescount) 
300 # kind of loop? 
301 #
302 for (my $i=0;$i<$rescount;$i++){
303   $reserves->[$i]{'reservedate'} = slashifyDate($reserves->[$i]{'reservedate'});
304
305   print "<tr VALIGN=TOP  >
306   <TD><a href=\"/cgi-bin/koha/request.pl?bib=$reserves->[$i]{'biblionumber'}\">$reserves->[$i]{'btitle'}</a></td>
307   <TD>$reserves->[$i]{'reservedate'}</td>
308   <input type=hidden name=biblio value=$reserves->[$i]{'biblionumber'}>
309   <input type=hidden name=borrower value=$bornum>
310   <TD></td>
311   <TD><select name=\"rank-request\">
312   <option value=n>No
313   <option value=del>Yes
314   </select>
315   </tr>
316   ";
317 }
318 print <<printend
319
320 <tr VALIGN=TOP  >
321 <TD colspan=5 align=right>
322 <INPUT TYPE="image" name="submit"  VALUE="update" height=42  WIDTH=187 BORDER=0 src="/images/cancel-requests.gif"></td>
323 </tr>
324 </table>
325 </form>
326 <p align=right>
327 <a href=/cgi-bin/koha/readingrec.pl?bornum=$bornum><img height=42  WIDTH=187 BORDER=0 src="/images/reading-record.gif"></a>
328 </p>
329 printend
330 ;
331
332
333 print endmenu('member');
334 print endpage();
335
336