Removing +1y expiry time from cookies so that cookies expire when the browser
[koha.git] / moremember.pl
index f37893f..4fbd333 100755 (executable)
@@ -1,10 +1,12 @@
 #!/usr/bin/perl
 
+# $Id$
+
 # 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 
+# 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
 # Suite 330, Boston, MA  02111-1307 USA
 
 use strict;
+use C4::Auth;
+use C4::Context;
 use C4::Output;
+use C4::Interface::CGI::Output;
+use C4::Interface::CGI::Template;
 use CGI;
 use C4::Search;
 use Date::Manip;
@@ -37,16 +43,20 @@ use C4::Reserves2;
 use C4::Circulation::Renewals2;
 use C4::Circulation::Circ2;
 use C4::Koha;
-use C4::Database;
 use HTML::Template;
 
-my $dbh=C4Connect;
+my $dbh = C4::Context->dbh;
 
 my $input = new CGI;
 
-my $theme = $input->param('theme'); # only used if allowthemeoverride is set
-my %tmpldata = pathtotemplate ( template => 'moremember.tmpl', theme => $theme );
-my $template = HTML::Template->new(filename => $tmpldata{'path'}, die_on_bad_params => 0);
+my ($template, $loggedinuser, $cookie)
+    = get_template_and_user({template_name => "members/moremember.tmpl",
+                            query => $input,
+                            type => "intranet",
+                            authnotrequired => 0,
+                            flagsrequired => {borrowers => 1},
+                            debug => 1,
+                            });
 
 my $bornum=$input->param('bornum');
 
@@ -60,6 +70,8 @@ $data->{'dateofbirth'} = slashifyDate($data->{'dateofbirth'});
 
 $data->{'ethnicity'} = fixEthnicity($data->{'ethnicity'});
 
+$data->{&expand_sex_into_predicate($data->{'sex'})} = 1;
+
 if ($data->{'categorycode'} eq 'C'){
     my $data2=borrdata('',$data->{'guarantor'});
     $data->{'streetaddress'}=$data2->{'streetaddress'};
@@ -88,7 +100,7 @@ if ($data->{'categorycode'} ne 'C'){
                           cardnumber => $guarantees->[$i]->{'cardnumber'}});
   }
   $template->param(guaranteeloop => \@guaranteedata);
-  
+
 } else {
   my ($guarantor)=findguarantor($data->{'borrowernumber'});
   unless ($guarantor->{'borrowernumber'} == 0){
@@ -100,8 +112,8 @@ my %bor;
 $bor{'borrowernumber'}=$bornum;
 
 # FIXME
-# it looks like $numaccts is a temp variable and that the 
-# for (my $i;$i<$numaccts;$i+++) 
+# 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);
@@ -114,7 +126,7 @@ for (my$i=0;$i<$numaccts;$i++){
   my $amount2= $accts->[$i]{'amountoutstanding'} + 0.00;
   my %row = %$accts->[$i];
   if ($amount2 != 0){
-    my $item=" &nbsp; ";  
+    my $item=" &nbsp; ";
     $row{'date'} = slashifyDate($accts->[$i]{'date'});
 
     if ($accts->[$i]{'accounttype'} ne 'Res'){
@@ -141,11 +153,18 @@ my @issuedata;
 for (my $i=0;$i<$count;$i++){
   my $datedue=ParseDate($issue->[$i]{'date_due'});
   $issue->[$i]{'date_due'} = slashifyDate($issue->[$i]{'date_due'});
-  my %row = %$issue->[$i];
-  if ($datedue < $today){  
+  my %row = %{$issue->[$i]};
+  if ($datedue < $today){
     $row{'red'}=1; #print "<font color=red>";
   }
   #find the charge for an item
+  # FIXME - This is expecting
+  # &C4::Circulation::Renewals2::calc_charges, but it's getting
+  # &C4::Circulation::Circ2::calc_charges, which only returns one
+  # element, so itemtype isn't being set.
+  # But &C4::Circulation::Renewals2::calc_charges doesn't appear to
+  # return the correct item type either (or a properly-formatted
+  # charge, for that matter).
   my ($charge,$itemtype)=calc_charges(undef,$dbh,$issue->[$i]{'itemnumber'},$bornum);
   $row{'itemtype'}=$itemtype;
   $row{'charge'}=$charge;
@@ -165,8 +184,8 @@ for (my $i=0;$i<$count;$i++){
 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? 
+# does it make sense to turn this into a foreach my $i (0..$rescount)
+# kind of loop?
 #
 my @reservedata;
 for (my $i=0;$i<$rescount;$i++){
@@ -180,14 +199,11 @@ for (my $i=0;$i<$rescount;$i++){
   push (@reservedata, \%row);
 }
 
-$dbh->disconnect;
-
 $template->param($data);
-$template->param(startmenumember => join('', startmenu('member')),
-                endmenumember   => join('', endmenu('member')),
+$template->param(
                 bornum          => $bornum,
                 accountloop     => \@accountdata,
                 issueloop       => \@issuedata,
                 reserveloop     => \@reservedata);
 
-print "Content-Type: text/html\n\n", $template->output;
+output_html_with_http_headers $input, $cookie, $template->output;