forked from Wavyzz/dolibarr
Fix pagination on limit failed when limit was forced on url
This commit is contained in:
@@ -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 int $pictoisfullpath 1=Icon name is a full absolute url of image
|
||||||
* @param string $morehtml More html to show
|
* @param string $morehtml More html to show
|
||||||
* @param string $morecss More css to the table
|
* @param string $morecss More css to the table
|
||||||
|
* @param int $limit Limit ofnumber of lines on each page
|
||||||
* @return void
|
* @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;
|
global $conf,$langs;
|
||||||
|
|
||||||
if ($picto == 'setup') $picto='title_setup.png';
|
if ($picto == 'setup') $picto='title_setup.png';
|
||||||
if (($conf->browser->name == 'ie') && $picto=='title_generic.png') $picto='title.gif';
|
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;
|
$nextpage = 1;
|
||||||
}
|
}
|
||||||
@@ -2997,13 +2999,13 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so
|
|||||||
if ($sortorder) $options .= "&sortorder=".$sortorder;
|
if ($sortorder) $options .= "&sortorder=".$sortorder;
|
||||||
// Show navigation bar
|
// Show navigation bar
|
||||||
$pagelist = '';
|
$pagelist = '';
|
||||||
if ($page > 0 || $num > $conf->liste_limit)
|
if ($page > 0 || $num > $limit)
|
||||||
{
|
{
|
||||||
if ($totalnboflines) // If we know total nb of lines
|
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
|
$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);
|
$cpt=($page-$maxnbofpage);
|
||||||
if ($cpt < 0) { $cpt=0; }
|
if ($cpt < 0) { $cpt=0; }
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ $langs->load('holidays');
|
|||||||
// Protection if external user
|
// Protection if external user
|
||||||
if ($user->societe_id > 0) accessforbidden();
|
if ($user->societe_id > 0) accessforbidden();
|
||||||
|
|
||||||
|
$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
|
||||||
$sortfield = GETPOST("sortfield",'alpha');
|
$sortfield = GETPOST("sortfield",'alpha');
|
||||||
$sortorder = GETPOST("sortorder",'alpha');
|
$sortorder = GETPOST("sortorder",'alpha');
|
||||||
$page = GETPOST("page",'int');
|
$page = GETPOST("page",'int');
|
||||||
@@ -47,7 +48,7 @@ $page = $page == -1 ? 0 : $page;
|
|||||||
|
|
||||||
if (! $sortfield) $sortfield="cp.rowid";
|
if (! $sortfield) $sortfield="cp.rowid";
|
||||||
if (! $sortorder) $sortorder="DESC";
|
if (! $sortorder) $sortorder="DESC";
|
||||||
$offset = $conf->liste_limit * $page ;
|
$offset = $limit * $page;
|
||||||
$pageprev = $page - 1;
|
$pageprev = $page - 1;
|
||||||
$pagenext = $page + 1;
|
$pagenext = $page + 1;
|
||||||
|
|
||||||
@@ -114,7 +115,7 @@ $filter='';
|
|||||||
|
|
||||||
llxHeader(array(),$langs->trans('CPTitreMenu'));
|
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
|
// WHERE
|
||||||
if(!empty($search_ref))
|
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).')';
|
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
|
// Récupération de l'ID de l'utilisateur
|
||||||
$user_id = $user->id;
|
$user_id = $user->id;
|
||||||
@@ -204,7 +202,7 @@ if ($id > 0)
|
|||||||
$user_id = $fuser->id;
|
$user_id = $fuser->id;
|
||||||
}
|
}
|
||||||
// Récupération des congés payés de l'utilisateur ou de tous les users
|
// 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
|
$holiday_payes = $holiday->fetchByUser($user_id,$order,$filter); // Load array $holiday->holiday
|
||||||
}
|
}
|
||||||
@@ -224,7 +222,8 @@ if ($holiday_payes == '-1')
|
|||||||
|
|
||||||
// Show table of vacations
|
// Show table of vacations
|
||||||
|
|
||||||
$var=true; $num = count($holiday->holiday);
|
$var=true;
|
||||||
|
$num = count($holiday->holiday);
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
$formother = new FormOther($db);
|
$formother = new FormOther($db);
|
||||||
|
|
||||||
@@ -246,7 +245,9 @@ if ($id > 0)
|
|||||||
}
|
}
|
||||||
else
|
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('');
|
dol_fiche_head('');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user