[Koha-patches] [PATCH] Bug 2889 Remove toggle in boraccount display

Colin Campbell colin.campbell at ptfs-europe.com
Fri Mar 26 17:41:28 CET 2010


Also remove the reverse column if no contents to be displayed
( otherwise looks like a markup error )
Rationalize the main loop now toggle not required
---
 .../prog/en/modules/members/boraccount.tmpl        |    6 ++-
 members/boraccount.pl                              |   60 +++++++------------
 2 files changed, 27 insertions(+), 39 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tmpl
index 8f649ad..fce5a4d 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tmpl
@@ -32,17 +32,20 @@
     <th>Description of charges</th>
     <th>Amount</th>
     <th>Outstanding</th>
+    <!-- TMPL_IF NAME="reverse_col" -->
     <th>&nbsp;</th>
+    <!-- /TMPL_IF -->
   </tr>
 
 	<!-- FIXME: Shouldn't hardcode dollar signs, since Euro or Pound might be needed -->
   <!-- TMPL_LOOP NAME="accounts" -->
 
-   <!-- TMPL_IF NAME="toggle" --> <tr><!-- TMPL_ELSE --><tr class="highlight"><!-- /TMPL_IF -->
+   <!-- TMPL_IF NAME="__odd__" --><tr><!-- TMPL_ELSE --><tr class="highlight"><!-- /TMPL_IF -->
       <td><!-- TMPL_VAR NAME="date" --></td>
       <td><!-- TMPL_VAR NAME="description" -->&nbsp;<!-- TMPL_IF NAME="itemnumber" --><a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;itemnumber=<!-- TMPL_VAR NAME="itemnumber" -->">View item</a>&nbsp;<!-- /TMPL_IF --><!-- TMPL_IF NAME="printtitle" --> <!-- TMPL_VAR NAME="title" escape="html" --><!-- /TMPL_IF --></td>
       <!-- TMPL_IF NAME="amountcredit" --><td class="credit"><!-- TMPL_ELSE --><td class="debit"><!-- /TMPL_IF --><!-- TMPL_VAR NAME="amount" --></td>
       <!-- TMPL_IF NAME="amountoutstandingcredit" --><td class="credit"><!-- TMPL_ELSE --><td class="debit"><!-- /TMPL_IF --><!-- TMPL_VAR NAME="amountoutstanding" --></td>
+    <!-- TMPL_IF NAME="reverse_col" -->
       <td>
 	<!-- TMPL_IF NAME="payment" -->
 		<a href="boraccount.pl?action=reverse&borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->&accountno=<!-- TMPL_VAR NAME="accountno" -->">Reverse</a>
@@ -50,6 +53,7 @@
 		&nbsp;
 	<!-- /TMPL_IF -->
       </td>
+	<!-- /TMPL_IF -->
     </tr>
 
   <!-- /TMPL_LOOP -->
diff --git a/members/boraccount.pl b/members/boraccount.pl
index 90986ea..5509f3d 100755
--- a/members/boraccount.pl
+++ b/members/boraccount.pl
@@ -63,49 +63,33 @@ if ( $data->{'category_type'} eq 'C') {
 }
 
 #get account details
-my ($total,$accts,$numaccts)=GetMemberAccountRecords($borrowernumber);
+my ($total,$accts,undef)=GetMemberAccountRecords($borrowernumber);
 my $totalcredit;
 if($total <= 0){
         $totalcredit = 1;
 }
-my @accountrows; # this is for the tmpl-loop
-
-my $toggle;
-for (my $i=0;$i<$numaccts;$i++){
-    if($i%2){
-            $toggle = 0;
-    } else {
-            $toggle = 1;
+
+my $reverse_col = 0; # Flag whether we need to show the reverse column
+foreach my $accountline ( @{$accts}) {
+    $accountline->{amount} += 0.00;
+    if ($accountline->{amount} <= 0 ) {
+        $accountline->{amountcredit} = 1;
     }
-    $accts->[$i]{'toggle'} = $toggle;
-    $accts->[$i]{'amount'}+=0.00;
-    if($accts->[$i]{'amount'} <= 0){
-        $accts->[$i]{'amountcredit'} = 1;
+    $accountline->{amountoutstanding} += 0.00;
+    if ( $accountline->{amountoutstanding} <= 0 ) {
+        $accountline->{amountoutstandingcredit} = 1;
     }
-    $accts->[$i]{'amountoutstanding'}+=0.00;
-    if($accts->[$i]{'amountoutstanding'} <= 0){
-        $accts->[$i]{'amountoutstandingcredit'} = 1;
+
+    $accountline->{date} = format_date($accountline->{date});
+    $accountline->{amount} = sprintf '%.2f', $accountline->{amount};
+    $accountline->{amountoutstanding} = sprintf '%.2f', $accountline->{amountoutstanding};
+    if ($accountline->{accounttype} eq 'Pay') {
+        $accountline->{payment} = 1;
+        $reverse_col = 1;
     }
-    my %row = ( 'date'              => format_date($accts->[$i]{'date'}),
-                'amountcredit' => $accts->[$i]{'amountcredit'},
-                'amountoutstandingcredit' => $accts->[$i]{'amountoutstandingcredit'},
-                'toggle' => $accts->[$i]{'toggle'},
-                'description'       => $accts->[$i]{'description'},
-				'itemnumber'       => $accts->[$i]{'itemnumber'},
-				'biblionumber'       => $accts->[$i]{'biblionumber'},
-                'amount'            => sprintf("%.2f",$accts->[$i]{'amount'}),
-                'amountoutstanding' => sprintf("%.2f",$accts->[$i]{'amountoutstanding'}),
-                'accountno' => $accts->[$i]{'accountno'},
-                'payment' => ( $accts->[$i]{'accounttype'} eq 'Pay' ),
-                
-                );
-    
-    if ($accts->[$i]{'accounttype'} ne 'F' && $accts->[$i]{'accounttype'} ne 'FU'){
-        $row{'printtitle'}=1;
-        $row{'title'} = $accts->[$i]{'title'};
+    if ($accountline->{accounttype} ne 'F' && $accountline->{accounttype} ne 'FU'){
+        $accountline->{printtitle} = 1;
     }
-    
-    push(@accountrows, \%row);
 }
 
 $template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' );
@@ -121,7 +105,6 @@ $template->param(
     cardnumber          => $data->{'cardnumber'},
     categorycode        => $data->{'categorycode'},
     category_type       => $data->{'category_type'},
- #   category_description => $data->{'description'},
     categoryname		 => $data->{'description'},
     address             => $data->{'address'},
     address2            => $data->{'address2'},
@@ -134,7 +117,8 @@ $template->param(
 	branchname			=> GetBranchName($data->{'branchcode'}),
     total               => sprintf("%.2f",$total),
     totalcredit         => $totalcredit,
-	is_child        => ($data->{'category_type'} eq 'C'),
-    accounts            => \@accountrows );
+    is_child            => ($data->{'category_type'} eq 'C'),
+    reverse_col         => $reverse_col,
+    accounts            => $accts );
 
 output_html_with_http_headers $input, $cookie, $template->output;
-- 
1.6.6.1




More information about the Koha-patches mailing list