taking out some warn statements....
[koha_fer] / moremember.pl
index 7e1ed58..04b7031 100755 (executable)
@@ -1,12 +1,15 @@
 #!/usr/bin/perl
 
-#script to do a borrower enquiery/brin up borrower details etc
-#written 20/12/99 by chris@katipo.co.nz
-#Displays all the detailas about a borrower
-#needs html removed and to use the C4::Output more, but its tricky
-#last modified 21/1/2000 by chris@katipo.co.nz
-#modifiecd 31/1/2001 by chris@katipo.co.nz to not allow items on request
-#to be renewed
+# script to do a borrower enquiry/bring up borrower details etc
+# Displays all the details about a borrower
+# written 20/12/99 by chris@katipo.co.nz
+# last modified 21/1/2000 by chris@katipo.co.nz
+# modified 31/1/2001 by chris@katipo.co.nz 
+#   to not allow items on request to be renewed
+#
+# needs html removed and to use the C4::Output more, but its tricky
+#
+
 use strict;
 use C4::Output;
 use CGI;
@@ -15,33 +18,26 @@ use Date::Manip;
 use C4::Reserves2;
 use C4::Circulation::Renewals2;
 use C4::Circulation::Circ2;
+use C4::Koha;
+
 my $input = new CGI;
 my $bornum=$input->param('bornum');
 
-my %env;
+
 print $input->header;
+
 #start the page and read in includes
 print startpage();
 print startmenu('member');
 my $data=borrdata('',$bornum);
-my @temp=split('-',$data->{'dateenrolled'});
-$data->{'dateenrolled'}="$temp[2]/$temp[1]/$temp[0]";
-@temp=split('-',$data->{'expiry'});
-$data->{'expiry'}="$temp[2]/$temp[1]/$temp[0]";
-@temp=split('-',$data->{'dateofbirth'});
-$data->{'dateofbirth'}="$temp[2]/$temp[1]/$temp[0]";
-if ($data->{'ethnicity'} eq 'maori'){
-  $data->{'ethnicity'} = 'Maori';
-}
-if ($data->{'ethnicity'}eq 'european'){
-  $data->{'ethnicity'} = 'European/Pakeha';
-}
-if ($data->{'ethnicity'}eq 'pi'){
-  $data->{'ethnicity'} = 'Pacific Islander';
-}
-if ($data->{'ethnicity'}eq 'asian'){
-  $data->{'ethnicity'} = 'Asian';
-}
+
+
+$data->{'dateenrolled'} = slashifyDate($data->{'dateenrolled'});
+$data->{'expiry'} = slashifyDate($data->{'expiry'});
+$data->{'dateofbirth'} = slashifyDate($data->{'dateofbirth'});
+
+$data->{'ethnicity'} = fixEthnicity($data->{'ethnicity'});
+
 print <<printend
 <FONT SIZE=6><em>$data->{'firstname'} $data->{'surname'}</em></FONT><P>
 <p>
@@ -70,6 +66,10 @@ if ($data->{'categorycode'} eq 'C'){
     $data->{'phone'}=$data2->{'phone'};
     $data->{'phoneday'}=$data2->{'phoneday'};
 }
+my $ethnicityline='';
+if ($data->{'ethnicity'} || $data->{'ethnotes'}) {
+       $ethnicityline="Ethnicity: $data->{'ethnicity'}, $data->{'ethnotes'}<br>";
+}
 print <<printend
 Postal Address: $data->{'streetaddress'}, $data->{'city'}<BR>
 Home Address: $data->{'physstreet'}, $data->{'streetcity'}<BR>
@@ -84,7 +84,7 @@ Area: $data->{'area'}<BR>
 Fee:$30/year, Paid<BR>
 Joined: $data->{'dateenrolled'},  Expires: $data->{'expiry'} <BR>
 Joining Branch: $data->{'homebranch'}<P>
-Ethnicity: $data->{'ethnicity'}, $data->{'ethnotes'}<BR>
+$ethnicityline
 DoB: $data->{'dateofbirth'}<BR>
 Sex: $data->{'sex'}<P>
 
@@ -97,6 +97,10 @@ printend
 
 if ($data->{'categorycode'} ne 'C'){
   print " Guarantees:";
+  # FIXME
+  # It looks like the $i is only being returned to handle walking through
+  # the array, which is probably better done as a foreach loop.
+  #
   my ($count,$guarantees)=findguarantees($data->{'borrowernumber'});
   for (my $i=0;$i<$count;$i++){
     print "<A HREF=\"/cgi-bin/koha/moremember.pl?bornum=$guarantees->[$i]->{'borrowernumber'}\">$guarantees->[$i]->{'cardnumber'}</a><br>";
@@ -137,6 +141,12 @@ printend
 ;
 my %bor;
 $bor{'borrowernumber'}=$bornum;
+
+# FIXME
+# it looks like $numaccts is a temp variable and that the 
+# for (my $i;$i<$numaccts;$i+++) 
+# can be turned into a foreach loop instead
+#
 my ($numaccts,$accts,$total)=getboracctrecord('',\%bor);
 #if ($numaccts > 10){
 #  $numaccts=10;
@@ -148,8 +158,9 @@ for (my$i=0;$i<$numaccts;$i++){
   if ($amount2 != 0){
     print "<tr VALIGN=TOP  >";
     my $item=" &nbsp; ";
-    @temp=split('-',$accts->[$i]{'date'});
-    $accts->[$i]{'date'}="$temp[2]/$temp[1]/$temp[0]";
+    
+    $accts->[$i]{'date'} = slashifyDate($accts->[$i]{'date'});
+
     if ($accts->[$i]{'accounttype'} ne 'Res'){
     #get item data
     #$item=
@@ -157,6 +168,10 @@ for (my$i=0;$i<$numaccts;$i++){
     print "<td>$accts->[$i]{'date'}</td>";
 #  print "<TD>$accts->[$i]{'accounttype'}</td>";
     print "<TD>";
+
+    # FIXME
+    # why set this variable if it's not going to be used?
+    #
     my $env;
     if ($accts->[$i]{'accounttype'} ne 'Res'){
       my $iteminfo=C4::Circulation::Circ2::getiteminformation($env,$accts->[$i]->{'itemnumber'},'');
@@ -206,8 +221,9 @@ for (my $i=0;$i<$count;$i++){
   print "<tr VALIGN=TOP  >
   <TD>";
     my $datedue=ParseDate($issue->[$i]{'date_due'});
-  @temp=split('-',$issue->[$i]{'date_due'});
-  $issue->[$i]{'date_due'}="$temp[2]/$temp[1]/$temp[0]";
+
+  $issue->[$i]{'date_due'} = slashifyDate($issue->[$i]{'date_due'});
+
   if ($datedue < $today){  
     print "<font color=red>";
   }
@@ -216,7 +232,7 @@ for (my $i=0;$i<$count;$i++){
   $issue->[$i]{'barcode'}</a></td>
   <TD>$issue->[$i]{'date_due'}</td>";
   #find the charge for an item
-  my ($charge,$itemtype)=calc_charges(\%env,$issue->[$i]{'itemnumber'},$bornum);
+  my ($charge,$itemtype)=calc_charges(undef,$issue->[$i]{'itemnumber'},$bornum);
   print "<TD>$itemtype</td>";
   print "<TD>$charge</td>";
 
@@ -226,7 +242,7 @@ for (my $i=0;$i<$count;$i++){
 #    print "<td> &nbsp; </td>";
 #  }
   #check item is not reserved
-  my ($rescount,$reserves)=Findgroupreserve($issue->[$i]{'biblionumber'},'');
+  my ($rescount,$reserves)=Findgroupreserve($issue->[$i]{'biblioitemnumber'},$issue->[$i]{'biblionumber'});
   if ($rescount >0){
     print "<TD><a href=/cgi-bin/koha/request.pl?bib=$issue->[$i]{'biblionumber'}>On Request - no renewals</a></td></tr>";
 #  } elsif ($issue->[$i]->{'renewals'} > 0) {
@@ -276,10 +292,16 @@ print <<printend
 <input type=hidden name=from value=borrower>
 printend
 ;
+
 my ($rescount,$reserves)=FindReserves('',$bornum); #From C4::Reserves2
+
+# FIXME
+# does it make sense to turn this into a foreach my $i (0..$rescount) 
+# kind of loop? 
+#
 for (my $i=0;$i<$rescount;$i++){
-  @temp=split('-',$reserves->[$i]{'reservedate'});
-  $reserves->[$i]{'reservedate'}="$temp[2]/$temp[1]/$temp[0]";
+  $reserves->[$i]{'reservedate'} = slashifyDate($reserves->[$i]{'reservedate'});
+
   print "<tr VALIGN=TOP  >
   <TD><a href=\"/cgi-bin/koha/request.pl?bib=$reserves->[$i]{'biblionumber'}\">$reserves->[$i]{'btitle'}</a></td>
   <TD>$reserves->[$i]{'reservedate'}</td>
@@ -310,3 +332,5 @@ printend
 
 print endmenu('member');
 print endpage();
+
+