added database patchs to the updater/updatedatabase script
[koha.git] / moremember.pl
1 #!/usr/bin/perl
2
3 #script to do a borrower enquiery/brin up borrower details etc
4 #written 20/12/99 by chris@katipo.co.nz
5 #Displays all the detailas about a borrower
6 #needs html removed and to use the C4::Output more, but its tricky
7 #last modified 21/1/2000 by chris@katipo.co.nz
8 #modifiecd 31/1/2001 by chris@katipo.co.nz to not allow items on request
9 #to be renewed
10 use strict;
11 use C4::Output;
12 use CGI;
13 use C4::Search;
14 use Date::Manip;
15 use C4::Reserves2;
16 use C4::Circulation::Renewals2;
17 use C4::Circulation::Circ2;
18 my $input = new CGI;
19 my $bornum=$input->param('bornum');
20
21 my %env;
22 print $input->header;
23 #start the page and read in includes
24 print startpage();
25 print startmenu('member');
26 my $data=borrdata('',$bornum);
27 my @temp=split('-',$data->{'dateenrolled'});
28 $data->{'dateenrolled'}="$temp[2]/$temp[1]/$temp[0]";
29 @temp=split('-',$data->{'expiry'});
30 $data->{'expiry'}="$temp[2]/$temp[1]/$temp[0]";
31 @temp=split('-',$data->{'dateofbirth'});
32 $data->{'dateofbirth'}="$temp[2]/$temp[1]/$temp[0]";
33 if ($data->{'ethnicity'} eq 'maori'){
34   $data->{'ethnicity'} = 'Maori';
35 }
36 if ($data->{'ethnicity'}eq 'european'){
37   $data->{'ethnicity'} = 'European/Pakeha';
38 }
39 if ($data->{'ethnicity'}eq 'pi'){
40   $data->{'ethnicity'} = 'Pacific Islander';
41 }
42 if ($data->{'ethnicity'}eq 'asian'){
43   $data->{'ethnicity'} = 'Asian';
44 }
45 print <<printend
46 <FONT SIZE=6><em>$data->{'firstname'} $data->{'surname'}</em></FONT><P>
47 <p>
48 <form action=/cgi-bin/koha/jmemberentry.pl method=post>
49 <TABLE  CELLSPACING=0  CELLPADDING=5 border=1 align=left width=270>
50 <TR VALIGN=TOP>
51 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>MEMBERSHIP RECORD</TD></TR>
52 <tr VALIGN=TOP  >       
53 <TD>
54 <p align=right><INPUT TYPE="image" name="submit"  VALUE="add-child" height=42  WIDTH=120 BORDER=0 src="/images/add-child.gif">          
55 <input type=hidden name=type value=Add>
56 <input type=hidden name=bornum value=$data->{'borrowernumber'}>
57 </form>
58 </P><br>
59 <FONT SIZE=2  face="arial, helvetica">$data->{'title'} $data->{'othernames'}  $data->{'surname'} ($data->{'firstname'}, $data->{'initials'})<p>
60
61 Card Number: $data->{'cardnumber'}<BR>
62 printend
63 ;
64 if ($data->{'categorycode'} eq 'C'){
65     my $data2=borrdata('',$data->{'guarantor'});
66     $data->{'streetaddress'}=$data2->{'streetaddress'};
67     $data->{'city'}=$data2->{'city'};
68     $data->{'physstreet'}=$data2->{'phystreet'};
69     $data->{'streetcity'}=$data2->{'streetcity'};
70     $data->{'phone'}=$data2->{'phone'};
71     $data->{'phoneday'}=$data2->{'phoneday'};
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 Ethnicity: $data->{'ethnicity'}, $data->{'ethnotes'}<BR>
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   my ($count,$guarantees)=findguarantees($data->{'borrowernumber'});
101   for (my $i=0;$i<$count;$i++){
102     print "<A HREF=\"/cgi-bin/koha/moremember.pl?bornum=$guarantees->[$i]->{'borrowernumber'}\">$guarantees->[$i]->{'cardnumber'}</a><br>";
103   }
104 } else {
105   print "Guarantor:";
106   my ($guarantor)=findguarantor($data->{'borrowernumber'});
107   if ($guarantor->{'borrowernumber'} == 0){
108       print "no guarantor<br>";
109   } else {
110     print "<A HREF=\"/cgi-bin/koha/moremember.pl?bornum=$guarantor->{'borrowernumber'}\">$guarantor->{'cardnumber'}</a><br>";
111   }
112 }
113 print <<printend
114
115
116 <P>
117
118 General Notes: <!--<A HREF="popbox.html" onclick="messenger(200,250,'Form that lets you add to and delete notes.'); return false">-->
119 $data->{'borrowernotes'}<!--</a>-->
120 <p align=right>
121 <form action=/cgi-bin/koha/memberentry.pl method=post>
122 <input type=hidden name=bornum value=$bornum>
123 <INPUT TYPE="image" name="modify"  VALUE="modify" height=42  WIDTH=93 BORDER=0 src="/images/modify-mem.gif"> 
124
125 <INPUT TYPE="image" name="delete"  VALUE="delete" height=42  WIDTH=93 BORDER=0 src="/images/delete-mem.gif"> 
126 </p>
127
128 </TD>
129 </TR>
130 </TABLE>
131 </FORM>
132 <img src="/images/holder.gif" width=16 height=800 align=left>
133 <TABLE  CELLSPACING=0  CELLPADDING=5 border=1 >
134 <TR VALIGN=TOP>
135 <td  bgcolor="99cc33" background="/images/background-mem.gif" colspan=4><B>FINES & CHARGES</TD></TR>
136 printend
137 ;
138 my %bor;
139 $bor{'borrowernumber'}=$bornum;
140 my ($numaccts,$accts,$total)=getboracctrecord('',\%bor);
141 #if ($numaccts > 10){
142 #  $numaccts=10;
143 #}
144 for (my$i=0;$i<$numaccts;$i++){
145 #if ($accts->[$i]{'accounttype'} ne 'Pay'){
146   my $amount= $accts->[$i]{'amount'} + 0.00;
147     my $amount2= $accts->[$i]{'amountoutstanding'} + 0.00;
148   if ($amount2 != 0){
149     print "<tr VALIGN=TOP  >";
150     my $item=" &nbsp; ";
151     @temp=split('-',$accts->[$i]{'date'});
152     $accts->[$i]{'date'}="$temp[2]/$temp[1]/$temp[0]";
153     if ($accts->[$i]{'accounttype'} ne 'Res'){
154     #get item data
155     #$item=
156     }
157     print "<td>$accts->[$i]{'date'}</td>";
158 #  print "<TD>$accts->[$i]{'accounttype'}</td>";
159     print "<TD>";
160     my $env;
161     if ($accts->[$i]{'accounttype'} ne 'Res'){
162       my $iteminfo=C4::Circulation::Circ2::getiteminformation($env,$accts->[$i]->{'itemnumber'},'');
163       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>";
164     }
165     print "</td>
166     <TD>$amount</td><td>$amount2</td>
167     </tr>";
168   }
169 }
170 print <<printend
171
172 <tr VALIGN=TOP  >
173 <TD colspan=3 align=right>
174 <nobr>
175 <a href=/cgi-bin/koha/boraccount.pl?bornum=$bornum><img height=42  WIDTH=187 BORDER=0 src="/images/view-account.gif"></a>
176 <a href=/cgi-bin/koha/pay.pl?bornum=$bornum><img height=42  WIDTH=187 BORDER=0 src="/images/pay-fines.gif"></a></nobr>
177 </td>
178
179 </tr>
180
181
182 </table>
183
184 <p>
185 <form action="renewscript.pl" method=post>
186 <input type=hidden name=bornum value=$bornum>
187 <TABLE  CELLSPACING=0  CELLPADDING=5 border=1 >
188
189 <TR VALIGN=TOP>
190
191 <td  bgcolor="99cc33" background="/images/background-mem.gif" colspan=6><B>ITEMS CURRENTLY ON ISSUE</b></TD>
192 </TR>
193
194 <TR VALIGN=TOP>
195 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Title</b></TD>
196 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Due</b></TD>
197 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Itemtype</b></TD>
198 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Charge</b></TD>
199 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Renew</b></TD>
200 </TR>
201 printend
202 ;
203 my ($count,$issue)=borrissues($bornum);
204 my $today=ParseDate('today');
205 for (my $i=0;$i<$count;$i++){
206   print "<tr VALIGN=TOP  >
207   <TD>";
208     my $datedue=ParseDate($issue->[$i]{'date_due'});
209   @temp=split('-',$issue->[$i]{'date_due'});
210   $issue->[$i]{'date_due'}="$temp[2]/$temp[1]/$temp[0]";
211   if ($datedue < $today){  
212     print "<font color=red>";
213   }
214   print "$issue->[$i]{'title'} 
215   <a href=/cgi-bin/koha/moredetail.pl?item=$issue->[$i]->{'itemnumber'}&bib=$issue->[$i]->{'biblionumber'}&bi=$issue->[$i]->{'biblioitemnumber'}>
216   $issue->[$i]{'barcode'}</a></td>
217   <TD>$issue->[$i]{'date_due'}</td>";
218   #find the charge for an item
219   my ($charge,$itemtype)=calc_charges(\%env,$issue->[$i]{'itemnumber'},$bornum);
220   print "<TD>$itemtype</td>";
221   print "<TD>$charge</td>";
222
223 #  if ($datedue < $today){
224 #    print "<td>Overdue</td>";
225 #  } else {
226 #    print "<td> &nbsp; </td>";
227 #  }
228   #check item is not reserved
229   my ($rescount,$reserves)=Findgroupreserve($issue->[$i]{'biblioitemnumber'},$issue->[$i]{'biblionumber'});
230   if ($rescount >0){
231     print "<TD><a href=/cgi-bin/koha/request.pl?bib=$issue->[$i]{'biblionumber'}>On Request - no renewals</a></td></tr>";
232 #  } elsif ($issue->[$i]->{'renewals'} > 0) {
233 #      print "<TD>Previously Renewed - no renewals</td></tr>";
234   } else {
235     print "<TD>";
236   
237     print "<input type=radio name=\"renew_item_$issue->[$i]{'itemnumber'}\" value=y>Y
238     <input type=radio name=\"renew_item_$issue->[$i]{'itemnumber'}\" value=n>N</td>
239     </tr>
240     ";
241   }
242 }
243 print <<printend
244
245 <tr VALIGN=TOP  >
246 <TD colspan=5 align=right>
247 <INPUT TYPE="image" name="submit"  VALUE="update" height=42  WIDTH=187 BORDER=0 src="/images/update-renewals.gif">
248 </td>
249 </form>
250 </tr>
251
252
253 </table>
254
255
256 <P>
257
258 <TABLE  CELLSPACING=0  CELLPADDING=5 border=1 >
259
260 <TR VALIGN=TOP>
261
262 <td  bgcolor="99cc33" background="/images/background-mem.gif" colspan=5><B>ITEMS REQUESTED</b></TD>
263 </TR>
264
265 <TR VALIGN=TOP>
266
267 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Title</b></TD>
268 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Requested</b></TD>
269
270
271 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Charge</b></TD>
272
273 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Remove</b></TD>
274 </TR>
275 <form action=/cgi-bin/koha/modrequest.pl method=post>
276 <input type=hidden name=from value=borrower>
277 printend
278 ;
279 my ($rescount,$reserves)=FindReserves('',$bornum); #From C4::Reserves2
280 for (my $i=0;$i<$rescount;$i++){
281   @temp=split('-',$reserves->[$i]{'reservedate'});
282   $reserves->[$i]{'reservedate'}="$temp[2]/$temp[1]/$temp[0]";
283   print "<tr VALIGN=TOP  >
284   <TD><a href=\"/cgi-bin/koha/request.pl?bib=$reserves->[$i]{'biblionumber'}\">$reserves->[$i]{'btitle'}</a></td>
285   <TD>$reserves->[$i]{'reservedate'}</td>
286   <input type=hidden name=biblio value=$reserves->[$i]{'biblionumber'}>
287   <input type=hidden name=borrower value=$bornum>
288   <TD></td>
289   <TD><select name=\"rank-request\">
290   <option value=n>No
291   <option value=del>Yes
292   </select>
293   </tr>
294   ";
295 }
296 print <<printend
297
298 <tr VALIGN=TOP  >
299 <TD colspan=5 align=right>
300 <INPUT TYPE="image" name="submit"  VALUE="update" height=42  WIDTH=187 BORDER=0 src="/images/cancel-requests.gif"></td>
301 </tr>
302 </table>
303 </form>
304 <p align=right>
305 <a href=/cgi-bin/koha/readingrec.pl?bornum=$bornum><img height=42  WIDTH=187 BORDER=0 src="/images/reading-record.gif"></a>
306 </p>
307 printend
308 ;
309
310
311 print endmenu('member');
312 print endpage();