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