From 8b90f82f4f2a54b03b380aacc08f4ca8028b7eb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 1 Feb 2018 14:41:37 +0100 Subject: [PATCH 1/4] display search result from page 0 even we are page 350 --- htdocs/modulebuilder/template/myobject_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index fa06a7e7d05..71894b8659b 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -317,7 +317,7 @@ if ($user->rights->mymodule->delete) $arrayofmassactions['predelete']=$langs->tr if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); -print '
'; +print ''; if ($optioncss != '') print ''; print ''; print ''; From bb42589d6bd726ee864387fd14e3c5bc884faeb5 Mon Sep 17 00:00:00 2001 From: fappels Date: Sun, 4 Feb 2018 12:59:02 +0100 Subject: [PATCH 2/4] Fix paging when filtering If total resultset is smaller then paging size (filtering), goto and load page 0. If total resultset is smaller the limit, no need to do paging. --- .../modulebuilder/template/myobject_list.php | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 71894b8659b..f7bf371c289 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -253,17 +253,30 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); } - -$sql.= $db->plimit($limit+1, $offset); - -$resql=$db->query($sql); -if (! $resql) +if (($page * $limit) > $nbtotalofrecords) { - dol_print_error($db); - exit; + $page = 0; + $offset = 0; } +// if total resultset is smaller the limit, no need to do paging. +if ($limit > $nbtotalofrecords) +{ + $resql = $result; + $num = $nbtotalofrecords; +} +else +{ + $sql.= $db->plimit($limit+1, $offset); -$num = $db->num_rows($resql); + $resql=$db->query($sql); + if (! $resql) + { + dol_print_error($db); + exit; + } + + $num = $db->num_rows($resql); +} // Direct jump if only one record found if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) @@ -317,7 +330,7 @@ if ($user->rights->mymodule->delete) $arrayofmassactions['predelete']=$langs->tr if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); -print ''; +print ''; if ($optioncss != '') print ''; print ''; print ''; From 83e1545720405ebc93c1c66e2f9c529073712fd7 Mon Sep 17 00:00:00 2001 From: fappels Date: Sun, 4 Feb 2018 12:59:30 +0100 Subject: [PATCH 3/4] Fix comment --- htdocs/modulebuilder/template/myobject_list.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index f7bf371c289..7c3575401e4 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -253,6 +253,7 @@ 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; From f5ace81116681974d4bb29ebceafe8cefb94f972 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Feb 2018 13:07:05 +0100 Subject: [PATCH 4/4] Update myobject_list.php --- htdocs/modulebuilder/template/myobject_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 7c3575401e4..ef384edb818 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -260,7 +260,7 @@ if (($page * $limit) > $nbtotalofrecords) $offset = 0; } // if total resultset is smaller the limit, no need to do paging. -if ($limit > $nbtotalofrecords) +if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) { $resql = $result; $num = $nbtotalofrecords;