From 9b41e11a1ef09094a211d3f007bcd8364b504776 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 Feb 2016 19:28:10 +0100 Subject: [PATCH] NEW Can select dynamicaly number of lines to show on page --- htdocs/compta/facture/list.php | 1 + htdocs/core/lib/functions.lib.php | 59 +++++++++++++++++++++--------- htdocs/public/test/test_arrays.php | 4 +- htdocs/societe/list.php | 32 ++++++++-------- 4 files changed, 62 insertions(+), 34 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 5068306646b..38d1ce96f59 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -695,6 +695,7 @@ if ($resql) } $param='&socid='.$socid; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($month) $param.='&month='.$month; if ($year) $param.='&year=' .$year; if ($search_ref) $param.='&search_ref=' .$search_ref; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 26f549fab1f..efa80e70554 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2961,25 +2961,26 @@ function load_fiche_titre($titre, $mesg='', $picto='title_generic.png', $pictois * @param string $options parametres complementaires lien ('' par defaut) * @param string $sortfield champ de tri ('' par defaut) * @param string $sortorder ordre de tri ('' par defaut) - * @param string $center chaine du centre ('' par defaut) + * @param string $center chaine du centre ('' par defaut). We often find here string $massaction comming from $form->selectMassAction() * @param int $num number of records found by select with limit+1 * @param int $totalnboflines Total number of records/lines for all pages (if known) * @param string $picto Icon to use before title (should be a 32x32 transparent png file) * @param int $pictoisfullpath 1=Icon name is a full absolute url of image * @param string $morehtml More html to show * @param string $morecss More css to the table - * @param int $limit Max number of lines + * @param int $limit Max number of lines (-1 = use default, 0 = no limit, > 0 = limit) * @return void */ -function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $center='', $num=-1, $totalnboflines=0, $picto='title_generic.png', $pictoisfullpath=0, $morehtml='', $morecss='', $limit=0) +function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $center='', $num=-1, $totalnboflines=0, $picto='title_generic.png', $pictoisfullpath=0, $morehtml='', $morecss='', $limit=-1) { global $conf,$langs; - + + $savlimit = $limit; + if ($picto == 'setup') $picto='title_setup.png'; if (($conf->browser->name == 'ie') && $picto=='title_generic.png') $picto='title.gif'; - if ($limit < 1) $limit = $conf->liste_limit; - - if (($num > $limit) || ($num == -1)) + if ($limit < 0) $limit = $conf->liste_limit; + if ($savlimit >= 0 && (($num > $limit) || ($num == -1) || ($limit == 0))) { $nextpage = 1; } @@ -3012,13 +3013,14 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so if ($sortorder) $options .= "&sortorder=".$sortorder; // Show navigation bar $pagelist = ''; - if ($page > 0 || $num > $limit) + if ($savlimit != 0 && ($page > 0 || $num > $limit)) { if ($totalnboflines) // If we know total nb of lines { - $maxnbofpage=(empty($conf->dol_optimize_smallscreen) ? 6 : 3); // page nb before and after selected page + ... + first or last + $maxnbofpage=(empty($conf->dol_optimize_smallscreen) ? 4 : 2); // page nb before and after selected page + ... + first or last - $nbpages=ceil($totalnboflines/$limit); + if ($limit > 0) $nbpages=ceil($totalnboflines/$limit); + else $nbpages=1; $cpt=($page-$maxnbofpage); if ($cpt < 0) { $cpt=0; } @@ -3055,7 +3057,7 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so $pagelist.= 'dol_use_jmobile)?' class="pagination"':'').'>dol_use_jmobile)?'class="active"':'data-role="button"').'>'.($page+1).""; } } - print_fleche_navigation($page, $file, $options, $nextpage, $pagelist, $morehtml, $limit, $totalnboflines); // output the div and ul for previous/last completed with page numbers into $pagelist + print_fleche_navigation($page, $file, $options, $nextpage, $pagelist, $morehtml, $savlimit, $totalnboflines); // output the div and ul for previous/last completed with page numbers into $pagelist print ''; print ''."\n"; @@ -3071,22 +3073,30 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so * @param integer $nextpage Do we show a next page button * @param string $betweenarrows HTML content to show between arrows. MUST contains '
  • ' tags or '
  • '. * @param string $afterarrows HTML content to show after arrows. Must NOT contains '
  • ' tags. - * @param string $limit Max nb of record to show ('' = unknown = default, '0' = no limit, 'x' = limit) + * @param int $limit Max nb of record to show (-1 = no combo with limit, 0 = no limit, > 0 = limit) * @param int $totalnboflines Total number of records/lines for all pages (if known) * @return void */ -function print_fleche_navigation($page, $file, $options='', $nextpage=0, $betweenarrows='', $afterarrows='', $limit='', $totalnboflines=0) +function print_fleche_navigation($page, $file, $options='', $nextpage=0, $betweenarrows='', $afterarrows='', $limit=-1, $totalnboflines=0) { global $conf, $langs; print '