Changing the front page search of the intranet site to just be a keyword search
[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'} $issue->[$i]{'barcode'}</td>
184   <TD>$issue->[$i]{'date_due'}</td>";
185   #find the charge for an item
186   my ($charge,$itemtype)=calc_charges(\%env,$issue->[$i]{'itemnumber'},$bornum);
187   print "<TD>$itemtype</td>";
188   print "<TD>$charge</td>";
189
190 #  if ($datedue < $today){
191 #    print "<td>Overdue</td>";
192 #  } else {
193 #    print "<td> &nbsp; </td>";
194 #  }
195   #check item is not reserved
196   my ($rescount,$reserves)=FindReserves($issue->[$i]{'biblionumber'},'');
197   if ($rescount >0){
198     print "<TD><a href=/cgi-bin/koha/request.pl?bib=$issue->[$i]{'biblionumber'}>On Request - no renewals</a></td></tr>";
199   } else {
200     print "<TD>";
201   
202     print "<input type=radio name=\"renew_item_$issue->[$i]{'itemnumber'}\" value=y>Y
203     <input type=radio name=\"renew_item_$issue->[$i]{'itemnumber'}\" value=n>N</td>
204     </tr>
205     ";
206   }
207 }
208 print <<printend
209
210 <tr VALIGN=TOP  >
211 <TD colspan=5 align=right>
212 <INPUT TYPE="image" name="submit"  VALUE="update" height=42  WIDTH=187 BORDER=0 src="/images/update-renewals.gif">
213 </td>
214 </form>
215 </tr>
216
217
218 </table>
219
220
221 <P>
222
223 <TABLE  CELLSPACING=0  CELLPADDING=5 border=1 >
224
225 <TR VALIGN=TOP>
226
227 <td  bgcolor="99cc33" background="/images/background-mem.gif" colspan=5><B>ITEMS REQUESTED</b></TD>
228 </TR>
229
230 <TR VALIGN=TOP>
231
232 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Title</b></TD>
233 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Requested</b></TD>
234
235
236 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Charge</b></TD>
237
238 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Remove</b></TD>
239 </TR>
240 <form action=/cgi-bin/koha/modrequest.pl method=post>
241 <input type=hidden name=from value=borrower>
242 printend
243 ;
244 my ($rescount,$reserves)=FindReserves('',$bornum); #From C4::Reserves2
245 for (my $i=0;$i<$rescount;$i++){
246   @temp=split('-',$reserves->[$i]{'reservedate'});
247   $reserves->[$i]{'reservedate'}="$temp[2]/$temp[1]/$temp[0]";
248   print "<tr VALIGN=TOP  >
249   <TD><a href=\"/cgi-bin/koha/request.pl?bib=$reserves->[$i]{'biblionumber'}\">$reserves->[$i]{'title'}</a></td>
250   <TD>$reserves->[$i]{'reservedate'}</td>
251   <input type=hidden name=biblio value=$reserves->[$i]{'biblionumber'}>
252   <input type=hidden name=borrower value=$bornum>
253   <TD></td>
254   <TD><select name=\"rank-request\">
255   <option value=n>No
256   <option value=del>Yes
257   </select>
258   </tr>
259   ";
260 }
261 print <<printend
262
263 <tr VALIGN=TOP  >
264 <TD colspan=5 align=right>
265 <INPUT TYPE="image" name="submit"  VALUE="update" height=42  WIDTH=187 BORDER=0 src="/images/cancel-requests.gif"></td>
266 </tr>
267 </table>
268 </form>
269 <p align=right>
270 <a href=/cgi-bin/koha/readingrec.pl?bornum=$bornum><img height=42  WIDTH=187 BORDER=0 src="/images/reading-record.gif"></a>
271 </p>
272 printend
273 ;
274
275
276 print endmenu('member');
277 print endpage();