Initial revision
[wip/koha-chris_n.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
9 use strict;
10 use C4::Output;
11 use CGI;
12 use C4::Search;
13 use Date::Manip;
14 use C4::Reserves2;
15 use C4::Circulation::Renewals2;
16 my $input = new CGI;
17 my $bornum=$input->param('bornum');
18
19 my %env;
20 print $input->header;
21 #start the page and read in includes
22 print startpage();
23 print startmenu('member');
24 my $data=borrdata('',$bornum);
25 my @temp=split('-',$data->{'dateenrolled'});
26 $data->{'dateenrolled'}="$temp[2]/$temp[1]/$temp[0]";
27 @temp=split('-',$data->{'expiry'});
28 $data->{'expiry'}="$temp[2]/$temp[1]/$temp[0]";
29 @temp=split('-',$data->{'dateofbirth'});
30 $data->{'dateofbirth'}="$temp[2]/$temp[1]/$temp[0]";
31 if ($data->{'ethnicity'} eq 'maori'){
32   $data->{'ethnicity'} = 'Maori';
33 }
34 if ($data->{'ethnicity'}eq 'european'){
35   $data->{'ethnicity'} = 'European/Pakeha';
36 }
37 if ($data->{'ethnicity'}eq 'pi'){
38   $data->{'ethnicity'} = 'Pacific Islander';
39 }
40 if ($data->{'ethnicity'}eq 'asian'){
41   $data->{'ethnicity'} = 'Asian';
42 }
43 print <<printend
44 <FONT SIZE=6><em>$data->{'firstname'} $data->{'surname'}</em></FONT><P>
45 <p>
46 <form action=/cgi-bin/koha/jmemberentry.pl method=post>
47 <TABLE  CELLSPACING=0  CELLPADDING=5 border=1 align=left width=270>
48 <TR VALIGN=TOP>
49 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>MEMBERSHIP RECORD</TD></TR>
50 <tr VALIGN=TOP  >       
51 <TD>
52 <p align=right><INPUT TYPE="image" name="submit"  VALUE="add-child" height=42  WIDTH=120 BORDER=0 src="/images/add-child.gif">          
53 <input type=hidden name=type value=Add>
54 <input type=hidden name=bornum value=$data->{'borrowernumber'}>
55 </form>
56 </P><br>
57 <FONT SIZE=2  face="arial, helvetica">$data->{'title'} $data->{'othernames'}  $data->{'surname'} ($data->{'firstname'}, $data->{'initials'})<p>
58
59 Card Number: $data->{'cardnumber'}<BR>
60 Postal Address: $data->{'streetaddress'}, $data->{'city'}<BR>
61 Home Address: $data->{'physstreet'}, $data->{'streetcity'}<BR>
62 Phone (Home): $data->{'phone'}<BR>
63 Phone (Daytime): $data->{'phoneday'}<BR>
64 Fax: $data->{'faxnumber'}<BR>
65 E-mail: <a href="mailto:$data->{'emailaddress'}">$data->{'emailaddress'}</a><P>
66 Membership Number: $data->{'borrowernumber'}<BR>
67 Membership: $data->{'categorycode'}<BR>
68 Area: $data->{'area'}<BR>
69 Fee:$30/year, Paid<BR>
70 Joined: $data->{'dateenrolled'},  Expires: $data->{'expiry'} <BR>
71 Joining Branch: $data->{'homebranch'}<P>
72 Ethnicity: $data->{'ethnicity'}, $data->{'ethnotes'}<BR>
73 DoB: $data->{'dateofbirth'}<BR>
74 Sex: $data->{'sex'}<P>
75
76 Alternative Contact:$data->{'contactname'}<BR>
77 Phone: $data->{'altphone'}<BR>
78 Relationship: $data->{'altrelationship'}<BR>
79 Notes: $data->{'altnotes'}<P>
80 Guarantees:
81 printend
82 ;
83 my ($count,$guarantees)=findguarantees($data->{'borrowernumber'});
84 for (my $i=0;$i<$count;$i++){
85   print "<A HREF=\"/cgi-bin/koha/moremember.pl?bornum=$guarantees->[$i]->{'borrowernumber'}\">$guarantees->[$i]->{'cardnumber'}</a><br>";
86 }
87 print <<printend
88
89
90 <P>
91
92 General Notes: <A HREF="popbox.html" onclick="messenger(200,250,'Form that lets you add to and delete notes.'); return false">
93 $data->{'borrowernotes'}</a>
94 <p align=right>
95 <form action=/cgi-bin/koha/memberentry.pl method=post>
96 <input type=hidden name=bornum value=$bornum>
97 <INPUT TYPE="image" name="submit"  VALUE="modify" height=42  WIDTH=93 BORDER=0 src="/images/modify-mem.gif"> 
98
99 <INPUT TYPE="image" name="submit"  VALUE="delete" height=42  WIDTH=93 BORDER=0 src="/images/delete-mem.gif"> 
100 </p>
101
102 </TD>
103 </TR>
104 </TABLE>
105 </FORM>
106 <img src="/images/holder.gif" width=16 height=800 align=left>
107 <TABLE  CELLSPACING=0  CELLPADDING=5 border=1 >
108 <TR VALIGN=TOP>
109 <td  bgcolor="99cc33" background="/images/background-mem.gif" colspan=4><B>FINES & CHARGES</TD></TR>
110 printend
111 ;
112 my %bor;
113 $bor{'borrowernumber'}=$bornum;
114 my ($numaccts,$accts,$total)=getboracctrecord('',\%bor);
115 #if ($numaccts > 10){
116 #  $numaccts=10;
117 #}
118 for (my$i=0;$i<$numaccts;$i++){
119 #if ($accts->[$i]{'accounttype'} ne 'Pay'){
120   my $amount= $accts->[$i]{'amount'} + 0.00;
121     my $amount2= $accts->[$i]{'amountoutstanding'} + 0.00;
122   if ($amount2 > 0){
123     print "<tr VALIGN=TOP  >";
124     my $item=" &nbsp; ";
125     @temp=split('-',$accts->[$i]{'date'});
126     $accts->[$i]{'date'}="$temp[2]/$temp[1]/$temp[0]";
127     if ($accts->[$i]{'accounttype'} ne 'Res'){
128     #get item data
129     #$item=
130     }
131     print "<td>$accts->[$i]{'date'}</td>";
132 #  print "<TD>$accts->[$i]{'accounttype'}</td>";
133     print "<TD>$accts->[$i]{'description'} $accts->[$i]{'title'}</td>
134     <TD>$amount</td><td>$amount2</td>
135     </tr>";
136   }
137 }
138 print <<printend
139
140 <tr VALIGN=TOP  >
141 <TD colspan=3 align=right>
142 <nobr>
143 <a href=/cgi-bin/koha/boraccount.pl?bornum=$bornum><img height=42  WIDTH=187 BORDER=0 src="/images/view-account.gif"></a>
144 <a href=/cgi-bin/koha/pay.pl?bornum=$bornum><img height=42  WIDTH=187 BORDER=0 src="/images/pay-fines.gif"></a></nobr>
145 </td>
146
147 </tr>
148
149
150 </table>
151
152 <p>
153 <form action="renewscript.pl" method=post>
154 <input type=hidden name=bornum value=$bornum>
155 <TABLE  CELLSPACING=0  CELLPADDING=5 border=1 >
156
157 <TR VALIGN=TOP>
158
159 <td  bgcolor="99cc33" background="/images/background-mem.gif" colspan=6><B>ITEMS CURRENTLY ON ISSUE</b></TD>
160 </TR>
161
162 <TR VALIGN=TOP>
163 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Title</b></TD>
164 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Due</b></TD>
165 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Itemtype</b></TD>
166 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Charge</b></TD>
167 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Renew</b></TD>
168 </TR>
169 printend
170 ;
171 my ($count,$issue)=borrissues($bornum);
172 my $today=ParseDate('today');
173 for (my $i=0;$i<$count;$i++){
174   print "<tr VALIGN=TOP  >
175   <TD>";
176     my $datedue=ParseDate($issue->[$i]{'date_due'});
177   @temp=split('-',$issue->[$i]{'date_due'});
178   $issue->[$i]{'date_due'}="$temp[2]/$temp[1]/$temp[0]";
179   if ($datedue < $today){  
180     print "<font color=red>";
181   }
182   print "$issue->[$i]{'title'} $issue->[$i]{'barcode'}</td>
183   <TD>$issue->[$i]{'date_due'}</td>";
184   #find the charge for an item
185   my ($charge,$itemtype)=calc_charges(\%env,$issue->[$i]{'itemnumber'},$bornum);
186   print "<TD>$itemtype</td>";
187   print "<TD>$charge</td>";
188
189 #  if ($datedue < $today){
190 #    print "<td>Overdue</td>";
191 #  } else {
192 #    print "<td> &nbsp; </td>";
193 #  }
194   #check item is not reserved
195   my ($rescount,$reserves)=FindReserves($issue->[$i]{'biblionumber'},'');
196   if ($rescount >0){
197     print "<TD>On Request";
198   } else {
199     print "<TD>";
200   }
201     print "<input type=radio name=\"renew_item_$issue->[$i]{'itemnumber'}\" value=y>Y
202     <input type=radio name=\"renew_item_$issue->[$i]{'itemnumber'}\" value=n>N</td>
203     </tr>
204     ";
205   
206 }
207 print <<printend
208
209 <tr VALIGN=TOP  >
210 <TD colspan=5 align=right>
211 <INPUT TYPE="image" name="submit"  VALUE="update" height=42  WIDTH=187 BORDER=0 src="/images/update-renewals.gif">
212 </td>
213 </form>
214 </tr>
215
216
217 </table>
218
219
220 <P>
221
222 <TABLE  CELLSPACING=0  CELLPADDING=5 border=1 >
223
224 <TR VALIGN=TOP>
225
226 <td  bgcolor="99cc33" background="/images/background-mem.gif" colspan=5><B>ITEMS REQUESTED</b></TD>
227 </TR>
228
229 <TR VALIGN=TOP>
230
231 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Title</b></TD>
232 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Requested</b></TD>
233
234
235 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Charge</b></TD>
236
237 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Remove</b></TD>
238 </TR>
239 <form action=/cgi-bin/koha/modrequest.pl method=post>
240 <input type=hidden name=from value=borrower>
241 printend
242 ;
243 my ($rescount,$reserves)=FindReserves('',$bornum); #From C4::Reserves2
244 for (my $i=0;$i<$rescount;$i++){
245   @temp=split('-',$reserves->[$i]{'reservedate'});
246   $reserves->[$i]{'reservedate'}="$temp[2]/$temp[1]/$temp[0]";
247   print "<tr VALIGN=TOP  >
248   <TD><a href=\"/cgi-bin/koha/request.pl?bib=$reserves->[$i]{'biblionumber'}\">$reserves->[$i]{'title'}</a></td>
249   <TD>$reserves->[$i]{'reservedate'}</td>
250   <input type=hidden name=biblio value=$reserves->[$i]{'biblionumber'}>
251   <input type=hidden name=borrower value=$bornum>
252   <TD></td>
253   <TD><select name=\"rank-request\">
254   <option value=n>No
255   <option value=del>Yes
256   </select>
257   </tr>
258   ";
259 }
260 print <<printend
261
262 <tr VALIGN=TOP  >
263 <TD colspan=5 align=right>
264 <INPUT TYPE="image" name="submit"  VALUE="update" height=42  WIDTH=187 BORDER=0 src="/images/cancel-requests.gif"></td>
265 </tr>
266 </table>
267 </form>
268 <p align=right>
269 <a href=/cgi-bin/koha/readingrec.pl?bornum=$bornum><img height=42  WIDTH=187 BORDER=0 src="/images/reading-record.gif"></a>
270 </p>
271 printend
272 ;
273
274
275 print endmenu('member');
276 print endpage();