Browse Source

FIX When on a high page and searching for a small result, list was not
visible.

Laurent Destailleur 7 years ago
parent
commit
461ae46cc4
65 changed files with 351 additions and 54 deletions
  1. 5 0
      htdocs/accountancy/admin/account.php
  2. 5 0
      htdocs/accountancy/admin/fiscalyear.php
  3. 6 0
      htdocs/accountancy/admin/productaccount.php
  4. 6 1
      htdocs/accountancy/customer/lines.php
  5. 5 0
      htdocs/accountancy/customer/list.php
  6. 5 0
      htdocs/accountancy/expensereport/lines.php
  7. 5 0
      htdocs/accountancy/expensereport/list.php
  8. 5 0
      htdocs/accountancy/supplier/lines.php
  9. 5 0
      htdocs/accountancy/supplier/list.php
  10. 5 0
      htdocs/adherents/list.php
  11. 5 0
      htdocs/adherents/subscription/list.php
  12. 9 2
      htdocs/adherents/type.php
  13. 5 0
      htdocs/admin/mails_senderprofile_list.php
  14. 5 0
      htdocs/admin/tools/listevents.php
  15. 5 0
      htdocs/assets/list.php
  16. 9 2
      htdocs/assets/type.php
  17. 6 8
      htdocs/categories/class/categorie.class.php
  18. 5 0
      htdocs/comm/action/list.php
  19. 5 0
      htdocs/comm/action/rapport/index.php
  20. 6 0
      htdocs/comm/mailing/cibles.php
  21. 6 0
      htdocs/comm/propal/list.php
  22. 6 0
      htdocs/commande/customer.php
  23. 6 0
      htdocs/commande/list.php
  24. 7 1
      htdocs/compta/facture/invoicetemplate_list.php
  25. 5 0
      htdocs/compta/facture/list.php
  26. 5 0
      htdocs/compta/paiement/cheque/list.php
  27. 5 0
      htdocs/compta/paiement/list.php
  28. 5 0
      htdocs/compta/paiement/tovalidate.php
  29. 5 0
      htdocs/compta/prelevement/bons.php
  30. 5 0
      htdocs/compta/prelevement/card.php
  31. 5 0
      htdocs/compta/prelevement/factures.php
  32. 5 0
      htdocs/compta/prelevement/fiche-rejet.php
  33. 5 0
      htdocs/compta/prelevement/list.php
  34. 5 0
      htdocs/contact/list.php
  35. 5 0
      htdocs/contrat/list.php
  36. 5 0
      htdocs/contrat/services_list.php
  37. 5 0
      htdocs/cron/list.php
  38. 7 0
      htdocs/don/list.php
  39. 7 1
      htdocs/expedition/list.php
  40. 6 0
      htdocs/expensereport/list.php
  41. 5 0
      htdocs/fichinter/list.php
  42. 5 0
      htdocs/fourn/commande/list.php
  43. 5 0
      htdocs/fourn/facture/list.php
  44. 5 0
      htdocs/fourn/facture/paiement.php
  45. 9 1
      htdocs/fourn/product/list.php
  46. 5 0
      htdocs/loan/index.php
  47. 5 4
      htdocs/margin/checkMargins.php
  48. 6 7
      htdocs/modulebuilder/template/myobject_list.php
  49. 5 7
      htdocs/opensurvey/list.php
  50. 5 6
      htdocs/product/inventory/list.php
  51. 7 0
      htdocs/product/list.php
  52. 5 0
      htdocs/product/reassort.php
  53. 5 0
      htdocs/product/reassortlot.php
  54. 5 0
      htdocs/product/stock/mouvement.php
  55. 5 0
      htdocs/product/stock/productlot_list.php
  56. 5 0
      htdocs/projet/list.php
  57. 5 0
      htdocs/projet/tasks/list.php
  58. 1 1
      htdocs/societe/agenda.php
  59. 5 0
      htdocs/societe/list.php
  60. 5 0
      htdocs/societe/notify/card.php
  61. 5 0
      htdocs/societe/website.php
  62. 5 0
      htdocs/supplier_proposal/list.php
  63. 6 7
      htdocs/ticketsup/class/api_ticketsups.class.php
  64. 5 6
      htdocs/ticketsup/list.php
  65. 5 0
      htdocs/user/notify/card.php

+ 5 - 0
htdocs/accountancy/admin/account.php

@@ -188,6 +188,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
 	$resql = $db->query($sql);
 	$nbtotalofrecords = $db->num_rows($resql);
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 
 $sql .= $db->plimit($limit + 1, $offset);

+ 5 - 0
htdocs/accountancy/admin/fiscalyear.php

@@ -94,6 +94,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
 	$result = $db->query($sql);
 	$nbtotalofrecords = $db->num_rows($result);
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 
 $sql.= $db->plimit($limit+1, $offset);

+ 6 - 0
htdocs/accountancy/admin/productaccount.php

@@ -256,7 +256,13 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
     $result = $db->query($sql);
     $nbtotalofrecords = $db->num_rows($result);
+    if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+    {
+    	$page = 0;
+    	$offset = 0;
+    }
 }
+
 $sql .= $db->plimit($limit + 1, $offset);
 
 dol_syslog("/accountancy/admin/productaccount.php:: sql=" . $sql, LOG_DEBUG);

+ 6 - 1
htdocs/accountancy/customer/lines.php

@@ -242,6 +242,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
     $result = $db->query($sql);
     $nbtotalofrecords = $db->num_rows($result);
+    if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+    {
+    	$page = 0;
+    	$offset = 0;
+    }
 }
 
 $sql .= $db->plimit($limit + 1, $offset);
@@ -334,7 +339,7 @@ if ($result) {
 		$facture_static->ref = $objp->ref;
 		$facture_static->id = $objp->facid;
 		$facture_static->type = $objp->ftype;
-		
+
 		$product_static->ref = $objp->product_ref;
 		$product_static->id = $objp->product_id;
 		$product_static->type = $objp->type;

+ 5 - 0
htdocs/accountancy/customer/list.php

@@ -289,6 +289,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
     $result = $db->query($sql);
     $nbtotalofrecords = $db->num_rows($result);
+    if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+    {
+    	$page = 0;
+    	$offset = 0;
+    }
 }
 
 $sql .= $db->plimit($limit + 1, $offset);

+ 5 - 0
htdocs/accountancy/expensereport/lines.php

@@ -208,6 +208,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
     $result = $db->query($sql);
     $nbtotalofrecords = $db->num_rows($result);
+    if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+    {
+    	$page = 0;
+    	$offset = 0;
+    }
 }
 
 $sql .= $db->plimit($limit + 1, $offset);

+ 5 - 0
htdocs/accountancy/expensereport/list.php

@@ -237,6 +237,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
     $result = $db->query($sql);
     $nbtotalofrecords = $db->num_rows($result);
+    if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+    {
+    	$page = 0;
+    	$offset = 0;
+    }
 }
 
 $sql .= $db->plimit($limit + 1, $offset);

+ 5 - 0
htdocs/accountancy/supplier/lines.php

@@ -241,6 +241,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
     $result = $db->query($sql);
     $nbtotalofrecords = $db->num_rows($result);
+    if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+    {
+    	$page = 0;
+    	$offset = 0;
+    }
 }
 
 $sql .= $db->plimit($limit + 1, $offset);

+ 5 - 0
htdocs/accountancy/supplier/list.php

@@ -288,6 +288,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
     $result = $db->query($sql);
     $nbtotalofrecords = $db->num_rows($result);
+    if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+    {
+    	$page = 0;
+    	$offset = 0;
+    }
 }
 
 $sql .= $db->plimit($limit + 1, $offset);

+ 5 - 0
htdocs/adherents/list.php

@@ -262,6 +262,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 	$resql = $db->query($sql);
 	if ($resql) $nbtotalofrecords = $db->num_rows($resql);
 	else dol_print_error($db);
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 // Add limit
 $sql.= $db->plimit($limit+1, $offset);

+ 5 - 0
htdocs/adherents/subscription/list.php

@@ -145,6 +145,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
     $result = $db->query($sql);
     $nbtotalofrecords = $db->num_rows($result);
+    if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+    {
+    	$page = 0;
+    	$offset = 0;
+    }
 }
 
 $sql.= $db->plimit($limit+1, $offset);

+ 9 - 2
htdocs/adherents/type.php

@@ -487,6 +487,9 @@ if ($rowid > 0)
 		{
 		    $sql.=" AND datefin < '".$db->idate($now)."'";
 		}
+
+		$sql.= " ".$db->order($sortfield,$sortorder);
+
 		// Count total nb of records
 		$nbtotalofrecords = '';
 		if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
@@ -494,9 +497,13 @@ if ($rowid > 0)
 			$resql = $db->query($sql);
 		    if ($resql) $nbtotalofrecords = $db->num_rows($result);
 		    else dol_print_error($db);
+		    if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+		    {
+		    	$page = 0;
+		    	$offset = 0;
+		    }
 		}
-		// Add order and limit
-		$sql.= " ".$db->order($sortfield,$sortorder);
+
 		$sql.= " ".$db->plimit($conf->liste_limit+1, $offset);
 
 		$resql = $db->query($sql);

+ 5 - 0
htdocs/admin/mails_senderprofile_list.php

@@ -230,6 +230,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
 	$result = $db->query($sql);
 	$nbtotalofrecords = $db->num_rows($result);
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 
 $sql.= $db->plimit($limit+1, $offset);

+ 5 - 0
htdocs/admin/tools/listevents.php

@@ -184,6 +184,11 @@ $nbtotalofrecords = '';
 {
     $result = $db->query($sql);
     $nbtotalofrecords = $db->num_rows($result);
+    if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+    {
+    	$page = 0;
+    	$offset = 0;
+    }
 }*/
 
 $sql.= $db->plimit($conf->liste_limit+1, $offset);

+ 5 - 0
htdocs/assets/list.php

@@ -225,6 +225,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
 	$result = $db->query($sql);
 	$nbtotalofrecords = $db->num_rows($result);
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 
 $sql.= $db->plimit($limit+1, $offset);

+ 9 - 2
htdocs/assets/type.php

@@ -464,6 +464,9 @@ if ($rowid > 0)
 		{
 			$sql.=" AND datefin < '".$db->idate($now)."'";
 		}
+
+		$sql.= " ".$db->order($sortfield,$sortorder);
+
 		// Count total nb of records
 		$nbtotalofrecords = '';
 		if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
@@ -471,9 +474,13 @@ if ($rowid > 0)
 			$resql = $db->query($sql);
 			if ($resql) $nbtotalofrecords = $db->num_rows($result);
 			else dol_print_error($db);
+			if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+			{
+				$page = 0;
+				$offset = 0;
+			}
 		}
-		// Add order and limit
-		$sql.= " ".$db->order($sortfield,$sortorder);
+
 		$sql.= " ".$db->plimit($conf->liste_limit+1, $offset);
 
 		$resql = $db->query($sql);

+ 6 - 8
htdocs/categories/class/categorie.class.php

@@ -895,24 +895,22 @@ class Categorie extends CommonObject
 		$sql.= ' AND s.rowid = sub.fk_categorie';
 		$sql.= ' AND sub.'.$subcol_name.' = '.$id;
 
+		$sql.= $this->db->order($sortfield, $sortorder);
+
 		$nbtotalofrecords = '';
 		if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 		{
 			$result = $this->db->query($sql);
 			$nbtotalofrecords = $this->db->num_rows($result);
-		}
-
-		$sql.= $this->db->order($sortfield, $sortorder);
-		if ($limit)	{
-			if ($page < 0)
+			if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
 			{
 				$page = 0;
+				$offset = 0;
 			}
-			$offset = $limit * $page;
-
-			$sql.= $this->db->plimit($limit + 1, $offset);
 		}
 
+		$sql.= $this->db->plimit($limit + 1, $offset);
+
 		$result = $this->db->query($sql);
 		if ($result)
 		{

+ 5 - 0
htdocs/comm/action/list.php

@@ -318,6 +318,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
     $result = $db->query($sql);
     $nbtotalofrecords = $db->num_rows($result);
+    if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+    {
+    	$page = 0;
+    	$offset = 0;
+    }
 }
 
 $sql.= $db->plimit($limit + 1, $offset);

+ 5 - 0
htdocs/comm/action/rapport/index.php

@@ -93,6 +93,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
     $result = $db->query($sql);
     $nbtotalofrecords = $db->num_rows($result);
+    if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+    {
+    	$page = 0;
+    	$offset = 0;
+    }
 }
 
 $sql.= $db->plimit($limit+1,$offset);

+ 6 - 0
htdocs/comm/mailing/cibles.php

@@ -425,7 +425,13 @@ if ($object->fetch($id) >= 0)
 	{
 	    $result = $db->query($sql);
 	    $nbtotalofrecords = $db->num_rows($result);
+	    if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	    {
+	    	$page = 0;
+	    	$offset = 0;
+	    }
 	}
+
 	//$nbtotalofrecords=$object->nbemail;     // nbemail is a denormalized field storing nb of targets
 	$sql .= $db->plimit($limit+1, $offset);
 

+ 6 - 0
htdocs/comm/propal/list.php

@@ -335,6 +335,12 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
 	$result = $db->query($sql);
 	$nbtotalofrecords = $db->num_rows($result);
+
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 
 $sql.= $db->plimit($limit+1, $offset);

+ 6 - 0
htdocs/commande/customer.php

@@ -102,6 +102,12 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
 	$result = $db->query($sql);
 	$nbtotalofrecords = $db->num_rows($result);
+
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 
 $sql.= $db->plimit($limit + 1, $offset);

+ 6 - 0
htdocs/commande/list.php

@@ -342,6 +342,12 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
 	$result = $db->query($sql);
 	$nbtotalofrecords = $db->num_rows($result);
+
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 
 $sql.= $db->plimit($limit + 1,$offset);

+ 7 - 1
htdocs/compta/facture/invoicetemplate_list.php

@@ -273,14 +273,20 @@ else if ($search_year_date_when > 0)
 	$sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($search_year_date_when,1,false))."' AND '".$db->idate(dol_get_last_day($search_year_date_when,12,false))."'";
 }
 
+$sql.= $db->order($sortfield, $sortorder);
+
 $nbtotalofrecords = '';
 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
 	$result = $db->query($sql);
 	$nbtotalofrecords = $db->num_rows($result);
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 
-$sql.= $db->order($sortfield, $sortorder);
 $sql.= $db->plimit($limit+1,$offset);
 
 $resql = $db->query($sql);

+ 5 - 0
htdocs/compta/facture/list.php

@@ -515,6 +515,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
 	$result = $db->query($sql);
 	$nbtotalofrecords = $db->num_rows($result);
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 
 $sql.= $db->plimit($limit+1,$offset);

+ 5 - 0
htdocs/compta/paiement/cheque/list.php

@@ -117,6 +117,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
 	$result = $db->query($sql);
 	$nbtotalofrecords = $db->num_rows($result);
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 
 $sql.= $db->plimit($limit+1, $offset);

+ 5 - 0
htdocs/compta/paiement/list.php

@@ -192,6 +192,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
 	$result = $db->query($sql);
 	$nbtotalofrecords = $db->num_rows($result);
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 
 $sql.= $db->plimit($limit+1, $offset);

+ 5 - 0
htdocs/compta/paiement/tovalidate.php

@@ -85,6 +85,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
     $result = $db->query($sql);
     $nbtotalofrecords = $db->num_rows($result);
+    if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+    {
+    	$page = 0;
+    	$offset = 0;
+    }
 }
 
 $sql.= $db->plimit($limit + 1,$offset);

+ 5 - 0
htdocs/compta/prelevement/bons.php

@@ -87,6 +87,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
     $result = $db->query($sql);
     $nbtotalofrecords = $db->num_rows($result);
+    if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+    {
+    	$page = 0;
+    	$offset = 0;
+    }
 }
 
 $sql.= $db->plimit($limit + 1,$offset);

+ 5 - 0
htdocs/compta/prelevement/card.php

@@ -322,6 +322,11 @@ if ($id > 0 || $ref)
 	{
 		$result = $db->query($sql);
 		$nbtotalofrecords = $db->num_rows($result);
+		if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+		{
+			$page = 0;
+			$offset = 0;
+		}
 	}
 
 	$sql.= $db->plimit($limit+1, $offset);

+ 5 - 0
htdocs/compta/prelevement/factures.php

@@ -170,6 +170,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
     $result = $db->query($sql);
     $nbtotalofrecords = $db->num_rows($result);
+    if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+    {
+    	$page = 0;
+    	$offset = 0;
+    }
 }
 
 $sql.= $db->plimit($limit + 1,$offset);

+ 5 - 0
htdocs/compta/prelevement/fiche-rejet.php

@@ -169,6 +169,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
 	$result = $db->query($sql);
 	$nbtotalofrecords = $db->num_rows($result);
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 
 $sql.= $db->plimit($limit+1, $offset);

+ 5 - 0
htdocs/compta/prelevement/list.php

@@ -111,6 +111,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
     $result = $db->query($sql);
     $nbtotalofrecords = $db->num_rows($result);
+    if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+    {
+    	$page = 0;
+    	$offset = 0;
+    }
 }
 
 $sql.= $db->plimit($limit + 1,$offset);

+ 5 - 0
htdocs/contact/list.php

@@ -349,6 +349,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
 	$result = $db->query($sql);
 	$nbtotalofrecords = $db->num_rows($result);
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 
 $sql.= $db->plimit($limit+1, $offset);

+ 5 - 0
htdocs/contrat/list.php

@@ -301,6 +301,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
 	$result = $db->query($sql);
 	$nbtotalofrecords = $db->num_rows($result);
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 
 $sql.= $db->plimit($limit + 1, $offset);

+ 5 - 0
htdocs/contrat/services_list.php

@@ -257,6 +257,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
 	$result = $db->query($sql);
 	$nbtotalofrecords = $db->num_rows($result);
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 
 $sql .= $db->plimit($limit + 1, $offset);

+ 5 - 0
htdocs/cron/list.php

@@ -276,6 +276,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
     $result = $db->query($sql);
     $nbtotalofrecords = $db->num_rows($result);
+    if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+    {
+    	$page = 0;
+    	$offset = 0;
+    }
 }
 
 $sql.= $db->plimit($limit+1, $offset);

+ 7 - 0
htdocs/don/list.php

@@ -113,12 +113,19 @@ if (trim($search_name) != '')
 if ($search_amount) $sql.= natural_search('d.amount', $search_amount, 1);
 
 $sql.= $db->order($sortfield,$sortorder);
+
 $nbtotalofrecords = '';
 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
 	$result = $db->query($sql);
 	$nbtotalofrecords = $db->num_rows($result);
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
+
 $sql.= $db->plimit($limit+1, $offset);
 
 $resql = $db->query($sql);

+ 7 - 1
htdocs/expedition/list.php

@@ -233,14 +233,20 @@ $parameters=array();
 $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters);    // Note that $action and $object may have been modified by hook
 $sql.=$hookmanager->resPrint;
 
+$sql.= $db->order($sortfield,$sortorder);
+
 $nbtotalofrecords = '';
 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
 	$result = $db->query($sql);
 	$nbtotalofrecords = $db->num_rows($result);
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 
-$sql.= $db->order($sortfield,$sortorder);
 $sql.= $db->plimit($limit + 1,$offset);
 
 //print $sql;

+ 6 - 0
htdocs/expensereport/list.php

@@ -329,7 +329,13 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
     $result = $db->query($sql);
     $nbtotalofrecords = $db->num_rows($result);
+    if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+    {
+    	$page = 0;
+    	$offset = 0;
+    }
 }
+
 $sql.= $db->plimit($limit+1, $offset);
 
 //print $sql;

+ 5 - 0
htdocs/fichinter/list.php

@@ -230,6 +230,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
 	$result = $db->query($sql);
 	$nbtotalofrecords = $db->num_rows($result);
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 
 $sql.= $db->plimit($limit+1, $offset);

+ 5 - 0
htdocs/fourn/commande/list.php

@@ -584,6 +584,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
 	$result = $db->query($sql);
 	$nbtotalofrecords = $db->num_rows($result);
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 
 $sql.= $db->plimit($limit+1, $offset);

+ 5 - 0
htdocs/fourn/facture/list.php

@@ -412,6 +412,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
 	$result = $db->query($sql);
 	$nbtotalofrecords = $db->num_rows($result);
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 
 $sql.= $db->plimit($limit+1, $offset);

+ 5 - 0
htdocs/fourn/facture/paiement.php

@@ -784,6 +784,11 @@ if (empty($action))
     {
         $result = $db->query($sql);
         $nbtotalofrecords = $db->num_rows($result);
+        if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+        {
+        	$page = 0;
+        	$offset = 0;
+        }
     }
 
     $sql.= $db->plimit($limit+1, $offset);

+ 9 - 1
htdocs/fourn/product/list.php

@@ -157,14 +157,22 @@ if ($fourn_id > 0)
 {
 	$sql .= " AND ppf.fk_soc = ".$fourn_id;
 }
+
+$sql .= $db->order($sortfield,$sortorder);
+
 // Count total nb of records without orderby and limit
 $nbtotalofrecords = '';
 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
     $result = $db->query($sql);
     $nbtotalofrecords = $db->num_rows($result);
+    if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+    {
+    	$page = 0;
+    	$offset = 0;
+    }
 }
-$sql .= $db->order($sortfield,$sortorder);
+
 $sql .= $db->plimit($limit + 1, $offset);
 
 dol_syslog("fourn/product/list.php:", LOG_DEBUG);

+ 5 - 0
htdocs/loan/index.php

@@ -91,6 +91,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
     $result = $db->query($sql);
     $nbtotalofrecords = $db->num_rows($result);
+    if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+    {
+    	$page = 0;
+    	$offset = 0;
+    }
 }
 
 $sql.= $db->plimit($limit+1, $offset);

+ 5 - 4
htdocs/margin/checkMargins.php

@@ -205,10 +205,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
 
 	dol_syslog(__FILE__, LOG_DEBUG);
 	$result = $db->query($sql);
-	if ($result) {
-		$nbtotalofrecords = $db->num_rows($result);
-	} else {
-		setEventMessages($db->lasterror, null, 'errors');
+	$nbtotalofrecords = $db->num_rows($result);
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
 	}
 }
 

+ 6 - 7
htdocs/modulebuilder/template/myobject_list.php

@@ -262,14 +262,13 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
 	$resql = $db->query($sql);
 	$nbtotalofrecords = $db->num_rows($resql);
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
-// if total resultset is smaller then paging size (filtering), goto and load page 0
-if (($page * $limit) > $nbtotalofrecords)
-{
-	$page = 0;
-	$offset = 0;
-}
-// if total resultset is smaller the limit, no need to do paging.
+// if total resultset is smaller than limit, no need to do paging adn restart select with limits.
 if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords)
 {
 	$num = $nbtotalofrecords;

+ 5 - 7
htdocs/opensurvey/list.php

@@ -115,13 +115,6 @@ $sql = "SELECT p.id_sondage, p.fk_user_creat, p.format, p.date_fin, p.status, p.
 $sql.= " u.login, u.firstname, u.lastname";
 $sql.= " FROM ".MAIN_DB_PREFIX."opensurvey_sondage as p";
 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user u ON u.rowid = p.fk_user_creat";
-// Count total nb of records
-$nbtotalofrecords = '';
-if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
-{
-	$result = $db->query($sql);
-	$nbtotalofrecords = $db->num_rows($result);
-}
 $sql.= " WHERE p.entity IN (".getEntity('survey').")";
 if ($search_status != '-1' && $search_status != '') $sql.=natural_search("p.status", $search_status, 2);
 if ($search_expired == 'expired') $sql.=" AND p.date_fin < '".$db->idate($now)."'";
@@ -136,6 +129,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
 	$result = $db->query($sql);
 	$nbtotalofrecords = $db->num_rows($result);
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 
 $sql.= $db->plimit($limit+1, $offset);

+ 5 - 6
htdocs/product/inventory/list.php

@@ -233,12 +233,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
 	$result = $db->query($sql);
 	$nbtotalofrecords = $db->num_rows($result);
-}
-// if total resultset is smaller then paging size (filtering), goto and load page 0
-if (($page * $limit) > $nbtotalofrecords)
-{
-	$page = 0;
-	$offset = 0;
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 // if total resultset is smaller the limit, no need to do paging.
 if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords)

+ 7 - 0
htdocs/product/list.php

@@ -338,12 +338,19 @@ else
 	$sql.=$hookmanager->resPrint;
 	//if (GETPOST("toolowstock")) $sql.= " HAVING SUM(s.reel) < p.seuil_stock_alerte";    // Not used yet
 	$sql.= $db->order($sortfield,$sortorder);
+
 	$nbtotalofrecords = '';
 	if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 	{
 		$result = $db->query($sql);
 		$nbtotalofrecords = $db->num_rows($result);
+		if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+		{
+			$page = 0;
+			$offset = 0;
+		}
 	}
+
 	$sql.= $db->plimit($limit + 1, $offset);
 
 	$resql = $db->query($sql);

+ 5 - 0
htdocs/product/reassort.php

@@ -155,6 +155,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
     $result = $db->query($sql);
     $nbtotalofrecords = $db->num_rows($result);
+    if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+    {
+    	$page = 0;
+    	$offset = 0;
+    }
 }
 
 $sql.= $db->plimit($limit + 1, $offset);

+ 5 - 0
htdocs/product/reassortlot.php

@@ -167,6 +167,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
     $result = $db->query($sql);
     $nbtotalofrecords = $db->num_rows($result);
+    if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+    {
+    	$page = 0;
+    	$offset = 0;
+    }
 }
 
 $sql.= $db->plimit($limit + 1, $offset);

+ 5 - 0
htdocs/product/stock/mouvement.php

@@ -473,6 +473,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
     $result = $db->query($sql);
     $nbtotalofrecords = $db->num_rows($result);
+    if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+    {
+    	$page = 0;
+    	$offset = 0;
+    }
 }
 
 $sql.= $db->plimit($limit+1, $offset);

+ 5 - 0
htdocs/product/stock/productlot_list.php

@@ -253,6 +253,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
 	$result = $db->query($sql);
 	$nbtotalofrecords = $db->num_rows($result);
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 
 $sql.= $db->plimit($limit+1, $offset);

+ 5 - 0
htdocs/projet/list.php

@@ -373,6 +373,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
 	$result = $db->query($sql);
 	$nbtotalofrecords = $db->num_rows($result);
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 
 $sql.= $db->plimit($limit + 1,$offset);

+ 5 - 0
htdocs/projet/tasks/list.php

@@ -327,6 +327,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
 	$result = $db->query($sql);
 	$nbtotalofrecords = $db->num_rows($result);
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 
 $sql.= $db->plimit($limit + 1,$offset);

+ 1 - 1
htdocs/societe/agenda.php

@@ -164,7 +164,7 @@ if ($socid > 0)
     {
     	if (! empty($user->rights->agenda->myactions->create) || ! empty($user->rights->agenda->allactions->create))
     	{
-        	$newcardbutton.='<a class="addnewrecord" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'">'.$langs->trans("AddAction");
+        	$newcardbutton.='<a class="butActionNew" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'">'.$langs->trans("AddAction");
         	$newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
         	$newcardbutton.= '</a>';
     	}

+ 5 - 0
htdocs/societe/list.php

@@ -485,6 +485,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
 	$result = $db->query($sql);
 	$nbtotalofrecords = $db->num_rows($result);
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 
 $sql.= $db->plimit($limit+1, $offset);

+ 5 - 0
htdocs/societe/notify/card.php

@@ -432,6 +432,11 @@ if ($result > 0)
     {
         $result = $db->query($sql);
         $nbtotalofrecords = $db->num_rows($result);
+        if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+        {
+        	$page = 0;
+        	$offset = 0;
+        }
     }
 
     $sql.= $db->plimit($limit+1, $offset);

+ 5 - 0
htdocs/societe/website.php

@@ -292,6 +292,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
 	$result = $db->query($sql);
 	$nbtotalofrecords = $db->num_rows($result);
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 
 $sql.= $db->plimit($limit+1, $offset);

+ 5 - 0
htdocs/supplier_proposal/list.php

@@ -332,6 +332,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
 	$resql = $db->query($sql);
 	$nbtotalofrecords = $db->num_rows($resql);
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 
 $sql.= $db->plimit($limit + 1,$offset);

+ 6 - 7
htdocs/ticketsup/class/api_ticketsups.class.php

@@ -258,16 +258,15 @@ class Ticketsups extends DolibarrApi
         if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
             $result = $db->query($sql);
             $nbtotalofrecords = $db->num_rows($result);
+            if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+            {
+            	$page = 0;
+            	$offset = 0;
+            }
         }
 
-        if ($limit) {
-            if ($page < 0) {
-                $page = 0;
-            }
-            $offset = $limit * $page;
+        $sql.= $db->plimit($limit + 1, $offset);
 
-            $sql.= $db->plimit($limit + 1, $offset);
-        }
         $result = $db->query($sql);
         if ($result) {
             $num = $db->num_rows($result);

+ 5 - 6
htdocs/ticketsup/list.php

@@ -255,12 +255,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
 	$result = $db->query($sql);
 	$nbtotalofrecords = $db->num_rows($result);
-}
-// if total resultset is smaller then paging size (filtering), goto and load page 0
-if (($page * $limit) > $nbtotalofrecords)
-{
-	$page = 0;
-	$offset = 0;
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 // if total resultset is smaller the limit, no need to do paging.
 if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords)

+ 5 - 0
htdocs/user/notify/card.php

@@ -411,6 +411,11 @@ if ($result > 0)
     {
         $result = $db->query($sql);
         $nbtotalofrecords = $db->num_rows($result);
+        if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+        {
+        	$page = 0;
+        	$offset = 0;
+        }
     }
 
     $sql.= $db->plimit($limit+1, $offset);