diff --git a/htdocs/lib/functions.inc.php b/htdocs/lib/functions.inc.php index d254916d695..8cb6c86ebb2 100644 --- a/htdocs/lib/functions.inc.php +++ b/htdocs/lib/functions.inc.php @@ -1699,16 +1699,17 @@ function dol_avscan_file($file) /** \brief Fonction print_barre_liste - \param titre titre de la page - \param page numéro de la page - \param file lien - \param options parametres complementaires lien ('' par defaut) - \param sortfield champ de tri ('' par defaut) - \param sortorder ordre de tri ('' par defaut) - \param center chaine du centre ('' par defaut) - \param num nombre d'élément total + \param titre Titre de la page + \param page numéro de la page + \param file lien + \param options parametres complementaires lien ('' par defaut) + \param sortfield champ de tri ('' par defaut) + \param sortorder ordre de tri ('' par defaut) + \param center chaine du centre ('' par defaut) + \param num number of records found by select with limit+1 + \param totalnboflines Total number of records/lines for all pages (if known) */ -function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $center='', $num=-1) +function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $center='', $num=-1, $totalnboflines=0) { global $conf,$langs; @@ -1723,10 +1724,42 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so print ''; - if ($page > 0 || $num > $conf->liste_limit) + $pagelist = ''; + + if ($page > 0 || $num > $conf->liste_limit) { - print ''; + if ($totalnboflines) + { + print ''; + + $nbpages=ceil($totalnboflines/$conf->liste_limit); + $cpt=($page-10); + if ($cpt<0) { $cpt=0; } + $pagelist.=$langs->trans('Page'); + if ($cpt>=1) { $pagelist.=' 1 ... ';} + do + { + if($cpt==$page) + { + $pagelist.= " ".($page+1); + } + else + { + $pagelist.= ' '.($cpt+1).''; + } + $cpt++; + } while ($cpt < $nbpages && $cpt<=$page+10); + if ($cpt<$nbpages) { $pagelist.= ' ... '.$nbpages.''; } + } + else + { + print ''; + } } else { @@ -1740,34 +1773,35 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so print '
'.$titre.($titre?' - ':'').$langs->trans('page').' '.($page+1); - print '
'; + print '
'.$titre.'
'; + print '
'; + print '
'.$titre.'
'; + $pagelist.= $langs->trans('Page').' '.($page+1); + print '
'; - if ($sortfield) $options .= "&sortfield=$sortfield"; - if ($sortorder) $options .= "&sortorder=$sortorder"; + if ($sortfield) $options .= "&sortfield=".$sortfield; + if ($sortorder) $options .= "&sortorder=".$sortorder; // Affichage des fleches de navigation - print_fleche_navigation($page,$file,$options,$nextpage); + print_fleche_navigation($page,$file,$options,$nextpage,$pagelist); print '
'; } /** \brief Fonction servant a afficher les fleches de navigation dans les pages de listes - \param page Numéro de la page - \param file Lien - \param options Autres parametres d'url a propager dans les liens ("" par defaut) - \param nextpage Faut-il une page suivante + \param page Numéro de la page + \param file Lien + \param options Autres parametres d'url a propager dans les liens ("" par defaut) + \param nextpage Faut-il une page suivante + \param betweenarraows HTML Content to show between arrows */ -function print_fleche_navigation($page,$file,$options='',$nextpage) +function print_fleche_navigation($page,$file,$options='',$nextpage,$betweenarrows='') { - global $conf, $langs; - if ($page > 0) - { - print ''.img_previous($langs->trans("Previous")).''; - } - - if ($nextpage > 0) - { - print ''.img_next($langs->trans("Next")).''; - } + global $conf, $langs; + if ($page > 0) + { + print ''.img_previous($langs->trans("Previous")).''; + } + if ($betweenarrows) print ($page > 0?' ':'').$betweenarrows.($nextpage>0?' ':''); + if ($nextpage > 0) + { + print ''.img_next($langs->trans("Next")).''; + } }