Fix pagination on limit failed when limit was forced on url

This commit is contained in:
Laurent Destailleur
2015-12-24 12:52:11 +01:00
parent 8c1f271356
commit a4d5e022cf
2 changed files with 16 additions and 13 deletions

View File

@@ -2959,16 +2959,18 @@ function load_fiche_titre($titre, $mesg='', $picto='title_generic.png', $pictois
* @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 Limit ofnumber of lines on each page
* @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='')
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)
{
global $conf,$langs;
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 > $conf->liste_limit) || ($num == -1))
if (($num > $limit) || ($num == -1))
{
$nextpage = 1;
}
@@ -2997,13 +2999,13 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so
if ($sortorder) $options .= "&amp;sortorder=".$sortorder;
// Show navigation bar
$pagelist = '';
if ($page > 0 || $num > $conf->liste_limit)
if ($page > 0 || $num > $limit)
{
if ($totalnboflines) // If we know total nb of lines
{
$maxnbofpage=(empty($conf->dol_optimize_smallscreen) ? 6 : 3); // nb before and after selected page + ... + first or last
$nbpages=ceil($totalnboflines/$conf->liste_limit);
$nbpages=ceil($totalnboflines/$limit);
$cpt=($page-$maxnbofpage);
if ($cpt < 0) { $cpt=0; }

View File

@@ -39,6 +39,7 @@ $langs->load('holidays');
// Protection if external user
if ($user->societe_id > 0) accessforbidden();
$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
@@ -47,7 +48,7 @@ $page = $page == -1 ? 0 : $page;
if (! $sortfield) $sortfield="cp.rowid";
if (! $sortorder) $sortorder="DESC";
$offset = $conf->liste_limit * $page ;
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
@@ -114,7 +115,7 @@ $filter='';
llxHeader(array(),$langs->trans('CPTitreMenu'));
$order = $db->order($sortfield,$sortorder).$db->plimit($conf->liste_limit + 1, $offset);
$order = $db->order($sortfield,$sortorder).$db->plimit($limit + 1, $offset);
// WHERE
if(!empty($search_ref))
@@ -189,9 +190,6 @@ if (!empty($sall))
if (empty($user->rights->holiday->read_all)) $filter.=' AND cp.fk_user IN ('.join(',',$childids).')';
/*************************************
* Fin des filtres de recherche
*************************************/
// Récupération de l'ID de l'utilisateur
$user_id = $user->id;
@@ -204,7 +202,7 @@ if ($id > 0)
$user_id = $fuser->id;
}
// Récupération des congés payés de l'utilisateur ou de tous les users
if (empty($user->rights->holiday->write_all) || $id > 0)
if (empty($user->rights->holiday->read_all) || $id > 0)
{
$holiday_payes = $holiday->fetchByUser($user_id,$order,$filter); // Load array $holiday->holiday
}
@@ -224,7 +222,8 @@ if ($holiday_payes == '-1')
// Show table of vacations
$var=true; $num = count($holiday->holiday);
$var=true;
$num = count($holiday->holiday);
$form = new Form($db);
$formother = new FormOther($db);
@@ -246,7 +245,9 @@ if ($id > 0)
}
else
{
print_barre_liste($langs->trans("ListeCP"), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, "", $num, 0, 'title_hrm.png');
//print $num;
//print count($holiday->holiday);
print_barre_liste($langs->trans("ListeCP"), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, "", $num, count($holiday->holiday), 'title_hrm.png', 0, '', '', $limit);
dol_fiche_head('');
}