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