Bug 2889: Removed toggle variable from member.pl and .tmpl
[koha.git] / members / member.pl
index 99e8340..b43b30b 100755 (executable)
@@ -1,8 +1,7 @@
 #!/usr/bin/perl
 
-# $Id$
 
-#script to do a borrower enquiery/brin up borrower details etc
+#script to do a borrower enquiry/bring up borrower details etc
 #written 20/12/99 by chris@katipo.co.nz
 
 
@@ -32,6 +31,9 @@ use C4::Members;
 
 my $input = new CGI;
 my $quicksearch = $input->param('quicksearch');
+my $startfrom = $input->param('startfrom')||1;
+my $resultsperpage = $input->param('resultsperpage')||C4::Context->preference("PatronsPerPage")||20;
+
 my ($template, $loggedinuser, $cookie);
 if($quicksearch){
     ($template, $loggedinuser, $cookie)
@@ -53,6 +55,16 @@ if($quicksearch){
                  });
 }
 my $theme = $input->param('theme') || "default";
+
+
+$template->param( 
+        "AddPatronLists_".C4::Context->preference("AddPatronLists")=> "1",
+            );
+if (C4::Context->preference("AddPatronLists")=~/code/){
+    my $categories=GetBorrowercategoryList;
+    $categories->[0]->{'first'}=1;
+    $template->param(categories=>$categories);  
+}  
             # only used if allowthemeoverride is set
 #my %tmpldata = pathtotemplate ( template => 'member.tmpl', theme => $theme, language => 'fi' );
     # FIXME - Error-checking
@@ -60,7 +72,6 @@ my $theme = $input->param('theme') || "default";
 #                   die_on_bad_params => 0,
 #                   loop_context_vars => 1 );
 
-
 my $member=$input->param('member');
 my $orderby=$input->param('orderby');
 $orderby = "surname,firstname" unless $orderby;
@@ -80,13 +91,12 @@ else
 
 
 my @resultsdata;
-my $background = 0;
-for (my $i=0; $i < $count; $i++){
+my $to=($count>($startfrom*$resultsperpage)?$startfrom*$resultsperpage:$count);
+for (my $i=($startfrom-1)*$resultsperpage; $i < $to; $i++){
   #find out stats
   my ($od,$issue,$fines)=GetMemberIssuesAndFines($results->[$i]{'borrowernumber'});
 
   my %row = (
-    background => $background,
     count => $i+1,
     borrowernumber => $results->[$i]{'borrowernumber'},
     cardnumber => $results->[$i]{'cardnumber'},
@@ -95,8 +105,10 @@ for (my $i=0; $i < $count; $i++){
     categorycode => $results->[$i]{'categorycode'},
     category_type => $results->[$i]{'category_type'},
     category_description => $results->[$i]{'description'},
-    streetaddress => $results->[$i]{'streetaddress'},
+    address => $results->[$i]{'address'},
+       address2 => $results->[$i]{'address2'},
     city => $results->[$i]{'city'},
+       zipcode => $results->[$i]{'zipcode'},
     branchcode => $results->[$i]{'branchcode'},
     overdues => $od,
     issues => $issue,
@@ -105,19 +117,38 @@ for (my $i=0; $i < $count; $i++){
     borrowernotes => $results->[$i]{'borrowernotes'},
     sort1 => $results->[$i]{'sort1'},
     sort2 => $results->[$i]{'sort2'},
+    dateexpiry => C4::Dates->new($results->[$i]{'dateexpiry'},'iso')->output('syspref'),
     );
-  if ( $background ) { $background = 0; } else {$background = 1; }
   push(@resultsdata, \%row);
 }
+my $base_url =
+    'member.pl?&amp;'
+  . join(
+    '&amp;',
+    map { $_->{term} . '=' . $_->{val} } (
+        { term => 'member', val => $member},
+        { term => 'orderby', val => $orderby },
+        { term => 'resultsperpage', val => $resultsperpage },
+        { term => 'type',           val => 'intranet' },
+    )
+  );
+
+$template->param(
+    paginationbar => pagination_bar(
+        $base_url,  int( $count / $resultsperpage ) + 1,
+        $startfrom, 'startfrom'
+    ),
+    startfrom => $startfrom,
+    from      => ($startfrom-1)*$resultsperpage+1,  
+    to        => $to,
+    multipage => ($count != $to || $startfrom!=1),
+);
 
 $template->param( 
         searching       => "1",
         member          => $member,
         numresults      => $count,
         resultsloop     => \@resultsdata,
-        intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
-        intranetstylesheet => C4::Context->preference("intranetstylesheet"),
-        IntranetNav => C4::Context->preference("IntranetNav"),
             );
 
 output_html_with_http_headers $input, $cookie, $template->output;