From 9973315a07300c4830e37fe108f5f1ed861327fd Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Wed, 16 Dec 2015 19:38:40 +0100
Subject: [PATCH] Fix we muste have ($limit = $conf->liste_limite; $offset =
 $limit * $page) and not ($offset = $conf->liste_limite * $page). In a future
 $limit that could be overwrite from search post form.

---
 htdocs/accountancy/bookkeeping/list.php       | 3 ++-
 htdocs/accountancy/bookkeeping/listbyyear.php | 3 ++-
 htdocs/comm/mailing/list.php                  | 3 ++-
 htdocs/commande/list.php                      | 4 ++--
 htdocs/compta/deplacement/list.php            | 4 ++--
 htdocs/compta/facture/list.php                | 4 ++--
 htdocs/compta/paiement/cheque/list.php        | 4 ++--
 htdocs/compta/paiement/list.php               | 4 ++--
 htdocs/compta/ventilation/list.php            | 4 ++--
 htdocs/don/list.php                           | 4 ++--
 htdocs/expedition/list.php                    | 5 ++---
 htdocs/expensereport/list.php                 | 4 ++--
 htdocs/fichinter/list.php                     | 4 ++--
 htdocs/opensurvey/list.php                    | 5 ++---
 htdocs/product/stock/mouvement.php            | 3 ++-
 htdocs/public/members/public_list.php         | 3 ++-
 htdocs/societe/price.php                      | 5 +++--
 htdocs/supplier_proposal/list.php             | 4 ++--
 18 files changed, 37 insertions(+), 33 deletions(-)

diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php
index b6f412d5480..951a07d3171 100644
--- a/htdocs/accountancy/bookkeeping/list.php
+++ b/htdocs/accountancy/bookkeeping/list.php
@@ -44,13 +44,14 @@ $search_doc_ref = GETPOST("search_doc_ref");
 $search_account = GETPOST("search_account");
 $search_thirdparty = GETPOST("search_thirdparty");
 $search_journal = GETPOST("search_journal");
+$limit = $conf->liste_limit;
 
 if ($sortorder == "")
 	$sortorder = "ASC";
 if ($sortfield == "")
 	$sortfield = "bk.rowid";
 
-$offset = $conf->liste_limit * $page;
+$offset = $limit * $page;
 
 $formventilation = new FormVentilation($db);
 $formother = new FormOther($db);
diff --git a/htdocs/accountancy/bookkeeping/listbyyear.php b/htdocs/accountancy/bookkeeping/listbyyear.php
index ce6d10f9730..fe185fd1118 100644
--- a/htdocs/accountancy/bookkeeping/listbyyear.php
+++ b/htdocs/accountancy/bookkeeping/listbyyear.php
@@ -36,6 +36,7 @@ $langs->load("accountancy");
 $page = GETPOST("page");
 $sortorder = GETPOST("sortorder");
 $sortfield = GETPOST("sortfield");
+$limit = $conf->liste_limit;
 
 // Filter
 $year = GETPOST("year", 'int');
@@ -52,7 +53,7 @@ if ($sortorder == "")
 if ($sortfield == "")
 	$sortfield = "bk.rowid";
 
-$offset = $conf->liste_limit * $page;
+$offset = $limit * $page;
 
 llxHeader('', $langs->trans("Bookkeeping"));
 
diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php
index cc7bafa9f5d..20796db24f4 100644
--- a/htdocs/comm/mailing/list.php
+++ b/htdocs/comm/mailing/list.php
@@ -32,9 +32,10 @@ $result=restrictedArea($user,'mailing');
 
 $sortfield = GETPOST("sortfield",'alpha');
 $sortorder = GETPOST("sortorder",'alpha');
+$limit = $conf->liste_limit;
 $page = GETPOST("page",'int');
 if ($page == -1) { $page = 0; }
-$offset = $conf->liste_limit * $page;
+$offset = $limit * $page;
 $pageprev = $page - 1;
 $pagenext = $page + 1;
 if (! $sortorder) $sortorder="DESC";
diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php
index b35aa1628f3..b7caa472425 100644
--- a/htdocs/commande/list.php
+++ b/htdocs/commande/list.php
@@ -67,13 +67,13 @@ $result = restrictedArea($user, 'commande', $id,'');
 $sortfield = GETPOST("sortfield",'alpha');
 $sortorder = GETPOST("sortorder",'alpha');
 $page = GETPOST("page",'int');
+$limit = $conf->liste_limit;
 if ($page == -1) { $page = 0; }
-$offset = $conf->liste_limit * $page;
+$offset = $limit * $page;
 $pageprev = $page - 1;
 $pagenext = $page + 1;
 if (! $sortfield) $sortfield='c.rowid';
 if (! $sortorder) $sortorder='DESC';
-$limit = $conf->liste_limit;
 
 $viewstatut=GETPOST('viewstatut');
 
diff --git a/htdocs/compta/deplacement/list.php b/htdocs/compta/deplacement/list.php
index c3c5f7dd80b..7c849f67f50 100644
--- a/htdocs/compta/deplacement/list.php
+++ b/htdocs/compta/deplacement/list.php
@@ -46,13 +46,13 @@ $search_company=GETPOST('search_company','alpha');
 $sortfield = GETPOST("sortfield",'alpha');
 $sortorder = GETPOST("sortorder",'alpha');
 $page = GETPOST("page",'int');
+$limit = $conf->liste_limit;
 if ($page == -1) { $page = 0; }
-$offset = $conf->liste_limit * $page;
+$offset = $limit * $page;
 $pageprev = $page - 1;
 $pagenext = $page + 1;
 if (! $sortorder) $sortorder="DESC";
 if (! $sortfield) $sortfield="d.dated";
-$limit = $conf->liste_limit;
 
 $year=GETPOST("year");
 $month=GETPOST("month");
diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php
index 707ad32eec7..0d0d1835732 100644
--- a/htdocs/compta/facture/list.php
+++ b/htdocs/compta/facture/list.php
@@ -77,14 +77,14 @@ if ($option == 'late') $filter = 'paye:0';
 
 $sortfield = GETPOST("sortfield",'alpha');
 $sortorder = GETPOST("sortorder",'alpha');
+$limit = $conf->liste_limit;
 $page = GETPOST("page",'int');
 if ($page == -1) {
     $page = 0;
 }
-$offset = $conf->liste_limit * $page;
+$offset = $limit * $page;
 if (! $sortorder) $sortorder='DESC';
 if (! $sortfield) $sortfield='f.datef';
-$limit = $conf->liste_limit;
 
 $pageprev = $page - 1;
 $pagenext = $page + 1;
diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php
index c322863efc1..f4451178e71 100644
--- a/htdocs/compta/paiement/cheque/list.php
+++ b/htdocs/compta/paiement/cheque/list.php
@@ -43,12 +43,12 @@ $search_account = GETPOST('search_account','int');
 $search_amount = GETPOST('search_amount','alpha');
 $sortfield = GETPOST("sortfield",'alpha');
 $sortorder = GETPOST("sortorder",'alpha');
+$limit = $conf->liste_limit;
 $page = GETPOST("page",'int');
 if ($page == -1) { $page = 0; }
-$offset = $conf->liste_limit * $page;
+$offset = $limit * $page;
 $pageprev = $page - 1;
 $pagenext = $page + 1;
-$limit = $conf->liste_limit;
 if (! $sortorder) $sortorder="DESC";
 if (! $sortfield) $sortfield="dp";
 
diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php
index 6e3d31364ce..0a5c2cd1572 100644
--- a/htdocs/compta/paiement/list.php
+++ b/htdocs/compta/paiement/list.php
@@ -57,12 +57,12 @@ $search_amount=GETPOST("search_amount");
 $search_company=GETPOST("search_company");
 $sortfield = GETPOST("sortfield",'alpha');
 $sortorder = GETPOST("sortorder",'alpha');
+$limit = $conf->liste_limit;
 $page = GETPOST("page",'int');
 if ($page == -1) { $page = 0; }
-$offset = $conf->liste_limit * $page;
+$offset = $limit * $page;
 $pageprev = $page - 1;
 $pagenext = $page + 1;
-$limit = $conf->liste_limit;
 if (! $sortorder) $sortorder="DESC";
 if (! $sortfield) $sortfield="p.rowid";
 
diff --git a/htdocs/compta/ventilation/list.php b/htdocs/compta/ventilation/list.php
index 03a1b658cd2..264673049ad 100644
--- a/htdocs/compta/ventilation/list.php
+++ b/htdocs/compta/ventilation/list.php
@@ -47,12 +47,12 @@ llxHeader('','Ventilation');
 
 $sortfield = GETPOST("sortfield",'alpha');
 $sortorder = GETPOST("sortorder",'alpha');
+$limit = $conf->liste_limit;
 $page = GETPOST("page",'int');
 if ($page == -1) { $page = 0; }
-$offset = $conf->liste_limit * $page;
+$offset = $limit * $page;
 $pageprev = $page - 1;
 $pagenext = $page + 1;
-$limit = $conf->liste_limit;
 
 $sql = "SELECT f.facnumber, f.rowid as facid, l.fk_product, l.description, f.total as price, l.rowid, l.fk_code_ventilation,";
 $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type";
diff --git a/htdocs/don/list.php b/htdocs/don/list.php
index 0a91e59593d..9477e91837e 100644
--- a/htdocs/don/list.php
+++ b/htdocs/don/list.php
@@ -34,13 +34,13 @@ $langs->load("donations");
 $sortfield = GETPOST("sortfield",'alpha');
 $sortorder = GETPOST("sortorder",'alpha');
 $page = GETPOST("page",'int');
+$limit = $conf->liste_limit;
 if ($page == -1) { $page = 0; }
-$offset = $conf->liste_limit * $page;
+$offset = $limit * $page;
 $pageprev = $page - 1;
 $pagenext = $page + 1;
 if (! $sortorder) $sortorder="DESC";
 if (! $sortfield) $sortfield="d.datedon";
-$limit = $conf->liste_limit;
 
 $statut=isset($_GET["statut"])?$_GET["statut"]:"-1";
 $search_all=GETPOST('sall','alpha');
diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php
index 5339538901e..bee47fe25bd 100644
--- a/htdocs/expedition/list.php
+++ b/htdocs/expedition/list.php
@@ -43,15 +43,14 @@ $optioncss = GETPOST('optioncss','alpha');
 $sortfield = GETPOST('sortfield','alpha');
 $sortorder = GETPOST('sortorder','alpha');
 $page = GETPOST('page','int');
+$limit = $conf->liste_limit;
 
 if ($page == -1) { $page = 0; }
-$offset = $conf->liste_limit * $page;
+$offset = $limit * $page;
 $pageprev = $page - 1;
 $pagenext = $page + 1;
-$limit = $conf->liste_limit;
 if (! $sortfield) $sortfield="e.ref";
 if (! $sortorder) $sortorder="DESC";
-$limit = $conf->liste_limit;
 
 $viewstatut=GETPOST('viewstatut');
 
diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php
index 502125faf61..0d1dc22971a 100644
--- a/htdocs/expensereport/list.php
+++ b/htdocs/expensereport/list.php
@@ -93,15 +93,15 @@ $sortfield     = GETPOST("sortfield");
 $page          = GETPOST("page");
 if (!$sortorder) $sortorder="DESC";
 if (!$sortfield) $sortfield="d.date_debut";
+$limit = $conf->liste_limit;
 
 if ($page == -1) {
 	$page = 0 ;
 }
 
-$offset = $conf->liste_limit * $page;
+$offset = $limit * $page;
 $pageprev = $page - 1;
 $pagenext = $page + 1;
-$limit = $conf->liste_limit;
 
 $sql = "SELECT d.rowid, d.ref, d.fk_user_author, d.total_ht, d.total_tva, d.total_ttc, d.fk_statut as status,";
 $sql.= " d.date_debut, d.date_fin,";
diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php
index 896d8c6a4fa..35224cb7780 100644
--- a/htdocs/fichinter/list.php
+++ b/htdocs/fichinter/list.php
@@ -44,9 +44,10 @@ $result = restrictedArea($user, 'ficheinter', $fichinterid,'fichinter');
 
 $sortfield = GETPOST('sortfield','alpha');
 $sortorder = GETPOST('sortorder','alpha');
+$limit = $conf->liste_limit;
 $page = GETPOST('page','int');
 if ($page == -1) { $page = 0; }
-$offset = $conf->liste_limit * $page;
+$offset = $limit * $page;
 $pageprev = $page - 1;
 $pagenext = $page + 1;
 if (! $sortorder) $sortorder="DESC";
@@ -55,7 +56,6 @@ if (! $sortfield)
  	if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) $sortfield="fd.date";
  	else $sortfield="f.ref";
 }
-$limit = $conf->liste_limit;
 
 $search_ref=GETPOST('search_ref')?GETPOST('search_ref','alpha'):GETPOST('search_inter','alpha');
 $search_company=GETPOST('search_company','alpha');
diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php
index 4844d9f8e59..fe73419c98b 100644
--- a/htdocs/opensurvey/list.php
+++ b/htdocs/opensurvey/list.php
@@ -38,9 +38,10 @@ $status=GETPOST('status');
 
 $sortfield = GETPOST("sortfield",'alpha');
 $sortorder = GETPOST("sortorder",'alpha');
+$limit = $conf->liste_limit;
 $page = GETPOST("page",'int');
 if ($page == -1) { $page = 0; }
-$offset = $conf->liste_limit * $page;
+$offset = $limit * $page;
 $pageprev = $page - 1;
 $pagenext = $page + 1;
 if (! $sortfield) $sortfield="p.date_fin";
@@ -48,8 +49,6 @@ if (! $sortorder) $sortorder="DESC";
 if ($page < 0) {
 	$page = 0;
 }
-$limit = $conf->liste_limit;
-$offset = $limit * $page;
 
 $langs->load("opensurvey");
 
diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php
index c04766ab59f..fbb80551fad 100644
--- a/htdocs/product/stock/mouvement.php
+++ b/htdocs/product/stock/mouvement.php
@@ -54,11 +54,12 @@ $search_warehouse = trim(GETPOST("search_warehouse"));
 $search_inventorycode = trim(GETPOST("search_inventorycode"));
 $search_user = trim(GETPOST("search_user"));
 $search_batch = trim(GETPOST("search_batch"));
+$limit = $conf->liste_limit;
 $page = GETPOST("page",'int');
 $sortfield = GETPOST("sortfield",'alpha');
 $sortorder = GETPOST("sortorder",'alpha');
 if ($page < 0) $page = 0;
-$offset = $conf->liste_limit * $page;
+$offset = $limit * $page;
 
 if (! $sortfield) $sortfield="m.datem";
 if (! $sortorder) $sortorder="DESC";
diff --git a/htdocs/public/members/public_list.php b/htdocs/public/members/public_list.php
index ea2b70c2447..d96d238c41b 100644
--- a/htdocs/public/members/public_list.php
+++ b/htdocs/public/members/public_list.php
@@ -81,9 +81,10 @@ function llxFooterVierge()
 
 $sortfield = GETPOST("sortfield",'alpha');
 $sortorder = GETPOST("sortorder",'alpha');
+$limit = $conf->liste_limit;
 $page = GETPOST("page",'int');
 if ($page == -1) { $page = 0; }
-$offset = $conf->liste_limit * $page;
+$offset = $limit * $page;
 $pageprev = $page - 1;
 $pagenext = $page + 1;
 
diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php
index 64ac2fbb256..6341f1dd37e 100644
--- a/htdocs/societe/price.php
+++ b/htdocs/societe/price.php
@@ -181,11 +181,12 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
 
 	$sortfield = GETPOST("sortfield", 'alpha');
 	$sortorder = GETPOST("sortorder", 'alpha');
+    $limit = $conf->liste_limit;
 	$page = GETPOST("page", 'int');
 	if ($page == - 1) {
 		$page = 0;
 	}
-	$offset = $conf->liste_limit * $page;
+	$offset = $limit * $page;
 	$pageprev = $page - 1;
 	$pagenext = $page + 1;
 	if (! $sortorder)
@@ -200,7 +201,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
 
 	$search_soc = GETPOST('search_soc');
 	if (! empty($search_soc)) {
-		$filter ['soc.nom'] = $search_soc;
+		$filter['soc.nom'] = $search_soc;
 	}
 
 	if ($action == 'add_customer_price') {
diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php
index 6aad541c1f9..1df4b49b56a 100644
--- a/htdocs/supplier_proposal/list.php
+++ b/htdocs/supplier_proposal/list.php
@@ -139,15 +139,15 @@ $now=dol_now();
 
 $sortfield = GETPOST("sortfield",'alpha');
 $sortorder = GETPOST("sortorder",'alpha');
+$limit = $conf->liste_limit;
 $page = GETPOST("page",'int');
 if ($page == -1) { $page = 0; }
-$offset = $conf->liste_limit * $page;
+$offset = $limit * $page;
 $pageprev = $page - 1;
 $pagenext = $page + 1;
 
 if (! $sortfield) $sortfield='p.date_livraison';
 if (! $sortorder) $sortorder='DESC';
-$limit = $conf->liste_limit;
 
 
 $sql = 'SELECT s.rowid, s.nom as name, s.town, s.client, s.code_client,';
-- 
GitLab