From 3e0fcf5ec2ecda622736e8d5142e31c592167af2 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Wed, 10 May 2017 11:57:59 +0200
Subject: [PATCH] Fix label "total for this page" on last page.

---
 dev/skeletons/skeleton_list.php          | 2 +-
 htdocs/comm/propal/list.php              | 2 +-
 htdocs/commande/list.php                 | 2 +-
 htdocs/compta/bank/bankentries.php       | 2 +-
 htdocs/compta/bank/index.php             | 2 +-
 htdocs/compta/facture/list.php           | 2 +-
 htdocs/compta/sociales/index.php         | 2 +-
 htdocs/expensereport/list.php            | 2 +-
 htdocs/fichinter/list.php                | 2 +-
 htdocs/fourn/facture/list.php            | 2 +-
 htdocs/product/stock/productlot_list.php | 2 +-
 htdocs/projet/list.php                   | 2 +-
 htdocs/projet/tasks/list.php             | 2 +-
 htdocs/projet/tasks/time.php             | 2 +-
 14 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/dev/skeletons/skeleton_list.php b/dev/skeletons/skeleton_list.php
index 77485c6d638..4453f2d8302 100644
--- a/dev/skeletons/skeleton_list.php
+++ b/dev/skeletons/skeleton_list.php
@@ -523,7 +523,7 @@ if (isset($totalarray['totalhtfield']))
         $i++;
         if ($i == 1)
         {
-            if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
+            if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>';
             else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
         }
         elseif ($totalarray['totalhtfield'] == $i) print '<td align="right">'.price($totalarray['totalht']).'</td>';
diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php
index d85448397de..efb72afb7b7 100644
--- a/htdocs/comm/propal/list.php
+++ b/htdocs/comm/propal/list.php
@@ -991,7 +991,7 @@ if ($resql)
 		   $i++;
 		   if ($i == 1)
 	       {
-        		if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
+        		if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>';
         		else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
 	       }
 		   elseif ($totalarray['totalhtfield'] == $i) print '<td align="right">'.price($totalarray['totalht']).'</td>';
diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php
index 80601ec9727..e62ae11d5cd 100644
--- a/htdocs/commande/list.php
+++ b/htdocs/commande/list.php
@@ -1412,7 +1412,7 @@ if ($resql)
 	        $i++;
 	        if ($i == 1)
 	        {
-	            if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
+	            if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>';
 	            else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
 	        }
 	        elseif ($totalarray['totalhtfield'] == $i) print '<td align="right">'.price($totalarray['totalht']).'</td>';
diff --git a/htdocs/compta/bank/bankentries.php b/htdocs/compta/bank/bankentries.php
index 72e82dd0dd7..4845012a3e0 100644
--- a/htdocs/compta/bank/bankentries.php
+++ b/htdocs/compta/bank/bankentries.php
@@ -1307,7 +1307,7 @@ if ($resql)
 	        $i++;
 	        if ($i == 1)
 	        {
-	            if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
+	            if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>';
 	            else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
 	        }
 	        elseif ($totalarray['totaldebfield'] == $i) print '<td align="right">'.price(-1 * $totalarray['totaldeb']).'</td>';
diff --git a/htdocs/compta/bank/index.php b/htdocs/compta/bank/index.php
index 012dfe42175..5f6e30016d4 100644
--- a/htdocs/compta/bank/index.php
+++ b/htdocs/compta/bank/index.php
@@ -607,7 +607,7 @@ if (isset($totalarray['totalbalancefield']) && $lastcurrencycode != 'various')	/
         $i++;
         if ($i == 1)
         {
-            if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
+            if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>';
             else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
         }
         elseif ($totalarray['totalbalancefield'] == $i) print '<td align="right">'.price($totalarray['totalbalance'], 0, $langs, 0, 0, -1, $lastcurrencycode).'</td>';
diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php
index 693a6f39f97..c5fd9b80482 100644
--- a/htdocs/compta/facture/list.php
+++ b/htdocs/compta/facture/list.php
@@ -1117,7 +1117,7 @@ if ($resql)
     		   $i++;
     		   if ($i == 1)
     	       {
-            		if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
+            		if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>';
             		else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
     	       }
     		   elseif ($totalarray['totalhtfield'] == $i)  print '<td align="right">'.price($totalarray['totalht']).'</td>';
diff --git a/htdocs/compta/sociales/index.php b/htdocs/compta/sociales/index.php
index 66d6a65dd56..e3f4a0b9b4d 100644
--- a/htdocs/compta/sociales/index.php
+++ b/htdocs/compta/sociales/index.php
@@ -274,7 +274,7 @@ if ($resql)
 		if (isset($totalarray['totalttcfield']))
 		{
 		    print '<tr class="liste_total">';
-            if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
+            if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>';
             else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
             print '<td></td>';
             print '<td></td>';
diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php
index 58541330c83..ca7a52ad293 100644
--- a/htdocs/expensereport/list.php
+++ b/htdocs/expensereport/list.php
@@ -694,7 +694,7 @@ if ($resql)
 	        $i++;
 	        if ($i == 1)
 	        {
-	            if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
+	            if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>';
 	            else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
 	        }
 	        elseif ($totalarray['totalhtfield'] == $i) print '<td align="right">'.price($totalarray['totalht']).'</td>';
diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php
index 9ef7d22ad10..bafafb40dd1 100644
--- a/htdocs/fichinter/list.php
+++ b/htdocs/fichinter/list.php
@@ -518,7 +518,7 @@ if ($result)
 	        $i++;
 	        if ($i == 1)
 	        {
-	            if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
+	            if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>';
 	            else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
 	        }
 	        elseif ($totalarray['totaldurationfield'] == $i) print '<td align="right">'.convertSecondToTime($totalarray['totalduration'], 'allhourmin').'</td>';
diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php
index 396d5ffd8a5..77064191d24 100644
--- a/htdocs/fourn/facture/list.php
+++ b/htdocs/fourn/facture/list.php
@@ -970,7 +970,7 @@ if ($resql)
     		   $i++;
     		   if ($i == 1)
     	       {
-            		if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
+            		if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>';
             		else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
     	       }
     		   elseif ($totalarray['totalhtfield'] == $i)  print '<td align="right">'.price($totalarray['totalht']).'</td>';
diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php
index 2910103e380..3d89aee0013 100644
--- a/htdocs/product/stock/productlot_list.php
+++ b/htdocs/product/stock/productlot_list.php
@@ -570,7 +570,7 @@ if ($resql)
             $i++;
             if ($i == 1)
             {
-                if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
+                if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>';
                 else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
             }
             elseif ($totalarray['totalhtfield'] == $i) print '<td align="right">'.price($totalarray['totalht']).'</td>';
diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php
index 51f260cac6f..408031a9ed2 100644
--- a/htdocs/projet/list.php
+++ b/htdocs/projet/list.php
@@ -854,7 +854,7 @@ if (isset($totalarray['totaloppfield']) || isset($totalarray['totalbudgetfield']
         $i++;
         if ($i == 1)
         {
-            if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
+            if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>';
             else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
         }
         elseif ($totalarray['totaloppfield'] == $i) print '<td align="right">'.price($totalarray['totalopp']).'</td>';
diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php
index 30a89109115..482c7b6f446 100644
--- a/htdocs/projet/tasks/list.php
+++ b/htdocs/projet/tasks/list.php
@@ -811,7 +811,7 @@ if (isset($totalarray['totaldurationeffectivefield']) || isset($totalarray['tota
         $i++;
         if ($i == 1)
         {
-            if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
+            if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>';
             else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
         }
         elseif ($totalarray['totalplannedworkloadfield'] == $i) print '<td align="center">'.convertSecondToTime($totalarray['totalplannedworkload'],$plannedworkloadoutputformat).'</td>';
diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php
index 6cb52588a89..4c5d58dab7d 100644
--- a/htdocs/projet/tasks/time.php
+++ b/htdocs/projet/tasks/time.php
@@ -971,7 +971,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
 		        $i++;
 		        if ($i == 1)
 		        {
-		            if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
+		            if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>';
 		            else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
 		        }
 		        elseif ($totalarray['totaldurationfield'] == $i) print '<td align="right">'.convertSecondToTime($totalarray['totalduration'],'allhourmin').'</td>';
-- 
GitLab