[Koha-patches] [PATCH] Translatability of two templates in acquisitions

Henri-Damien LAURENT henridamien.laurent at biblibre.com
Tue May 4 22:55:02 CEST 2010


aqbudgets and aqplan were not translatable owed to too confused templating stuff
This patch makes the styling "hardcoded" in template.
I donot have time for better patch.
I should be replaced by jquery usage. But this works.
---
 admin/aqbudgets.pl                                 |    4 ++--
 admin/aqplan.pl                                    |   11 ++++++-----
 .../prog/en/modules/admin/aqbudgets.tmpl           |    4 +---
 .../prog/en/modules/admin/aqplan.tmpl              |   17 ++++-------------
 4 files changed, 13 insertions(+), 23 deletions(-)

diff --git a/admin/aqbudgets.pl b/admin/aqbudgets.pl
index 8920d5d..9c21bb3 100755
--- a/admin/aqbudgets.pl
+++ b/admin/aqbudgets.pl
@@ -292,8 +292,8 @@ if ($op eq 'add_form') {
 # if amount == 0 dont display...
         delete  $budget->{'budget_unalloc_sublevel'} if  $budget->{'budget_unalloc_sublevel'} == 0 ;
 
-        $budget->{'remaining_pos'} = 1 if $budget->{'budget_remaining'} > 0;
-        $budget->{'remaining_neg'} = 1 if $budget->{'budget_remaining'} < 0;
+        $budget->{'style_remaining'} = 'style="color: green"'  if $budget->{'budget_remaining'} > 0;
+        $budget->{'style_remaining'} = 'style="color: red"'    if $budget->{'budget_remaining'} < 0;
 		for (grep {/total_levels_spent|budget_spent|budget_amount|budget_remaining|budget_unalloc/} keys %$budget){
         $$budget{$_}               = $num->format_price( $$budget{$_} ) if defined($$budget{$_})
 		}
diff --git a/admin/aqplan.pl b/admin/aqplan.pl
index 55367ef..6918123 100755
--- a/admin/aqplan.pl
+++ b/admin/aqplan.pl
@@ -386,7 +386,7 @@ foreach my $budget (@budgets) {
         my ( $actual, $estimated, $display ) = GetBudgetsPlanCell( \%cell, $period, $budget );
         $cell{actual_amount}    = sprintf( "%.2f", $actual );
         $cell{estimated_amount} = sprintf( "%.2f", $estimated );
-        $cell{display}          = $authvals_row[$i]{display};
+        $cell{display}          = $authvals_row[$i]{display}?"":'style="display:none"';
         $cell{colnum}           = $i;
 
         $actual_spent    += $cell{actual_amount};
@@ -414,10 +414,11 @@ foreach my $budget (@budgets) {
 
 
 
-    $budget_line{est_negative} = '1' if $budget_est_remain < 0;
-    $budget_line{est_positive} = '1' if $budget_est_remain > 0;
-    $budget_line{act_negative} = '1' if $budget_act_remain < 0;
-    $budget_line{act_positive} = '1' if $budget_act_remain > 0;
+    #TODO I had rather handle this with jquery
+    $budget_line{style_est} = 'style="color: red;"'   if $budget_est_remain < 0;
+    $budget_line{style_est} = 'style="color: green;"' if $budget_est_remain > 0;
+    $budget_line{style_act} = 'style="color: red;"'   if $budget_act_remain < 0;
+    $budget_line{style_act} = 'style="color: green;"' if $budget_act_remain > 0;
 
     # skip if active set , and spent == 0
     next if ( $show_active == '1' && ( $actual_spent == 0 ) );
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tmpl
index 54e321a..19d9455 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tmpl
@@ -196,9 +196,7 @@
     <td class="data"><!-- TMPL_VAR NAME="budget_amount" --> </td>
     <td class="data"><!-- TMPL_VAR NAME="budget_spent" --> </td>
     <td class="data"><!-- TMPL_VAR NAME="total_levels_spent" --></td>
-    <td class="data"
-    <!-- TMPL_IF NAME="remaining_pos" --> style="color: green;" <!-- /TMPL_IF -->
-    <!-- TMPL_IF NAME="remaining_neg" --> style="color: red;" <!-- /TMPL_IF -->   >
+    <td class="data" <!--TMPL_VAR Name="style_remaining"--> >
     <!-- TMPL_VAR NAME="budget_remaining" --> </td>
 
     <td class="tooltipcontent"><!-- TMPL_IF NAME="budget_owner_id" --><strong>Owner: </strong><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=<!-- TMPL_VAR NAME="budget_owner_id" -->"><!-- TMPL_VAR NAME="budget_owner_name" --></a><!-- /TMPL_IF -->
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqplan.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqplan.tmpl
index c2c6b55..e71d83c 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqplan.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqplan.tmpl
@@ -195,9 +195,7 @@ YAHOO.util.Event.onAvailable("popmenu", function () {
         <div style="display:none;" id='budget_tot_<!-- TMPL_VAR NAME="budget_id" -->'><!-- TMPL_VAR NAME="budget_amount"--></div></td>
 
         <!-- TMPL_LOOP NAME="lines"	-->
-            <td 
-            <!-- TMPL_UNLESS Name="display" --> style="display:none;"<!-- /TMPL_UNLESS -->
-                    class="<!-- TMPL_VAR NAME="colnum"-->"  >  
+            <td <!-- TMPL_VAR Name="display" --> class="<!-- TMPL_VAR NAME="colnum"-->"  >  
             <table class="invis" width="100%">
                 <tr>
                     <!-- TMPL_IF Name="show_actual" -->
@@ -220,19 +218,12 @@ YAHOO.util.Event.onAvailable("popmenu", function () {
         <td>
         <table class="invis" width="100%">
             <tr>
-            <td width="50%"    align="right"  
-       <!-- TMPL_IF Name="show_actual" -->
-            <!-- TMPL_IF NAME="act_negative" --> style="color: red;" <!--/TMPL_IF -->
-                <!-- TMPL_IF NAME="act_positive" --> style="color: green;" <!--/TMPL_IF --> >
+            <td width="50%" align="right"  <!-- TMPL_VAR NAME="style_act" --> >
                 <!-- TMPL_VAR NAME="budget_act_remain"-->
-        <!-- TMPL_ELSE --> >
-        <!-- /TMPL_IF -->
             </td>
 
-            <td width="50%"    align="right"  
-        <!-- TMPL_IF NAME="est_negative" --> style="color: red;" <!--/TMPL_IF --> 
-        <!-- TMPL_IF NAME="est_positive" --> style="color: green;" <!--/TMPL_IF --> 
-        id='budget_est_<!-- TMPL_VAR NAME="budget_id"-->'>  <!-- TMPL_VAR NAME="budget_est_remain"-->&nbsp;    
+            <td width="50%" align="right" <!-- TMPL_VAR NAME="style_est" --> id='budget_est_<!-- TMPL_VAR NAME="budget_id"-->'>  
+                <!-- TMPL_VAR NAME="budget_est_remain"-->&nbsp;    
             </td>
             </tr>
         </table>
-- 
1.6.3.3






More information about the Koha-patches mailing list