From e67be201ed800ae34b8b83669ca1bf2d5823384c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Feb 2016 16:49:13 +0100 Subject: [PATCH] NEW Can select number of lines on page list for projects and tasks --- htdocs/core/lib/functions.lib.php | 7 ++++--- htdocs/projet/list.php | 33 +++++++++++++++---------------- htdocs/projet/tasks/list.php | 9 +++++---- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index d4d74ec3fe6..ba8ed5624d1 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2970,7 +2970,7 @@ 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|string $limit Max number of lines (-1 = use default, 0 = no limit, > 0 = limit). + * @param int $limit Max number of lines (-1 = use default, 0 = no limit, > 0 = limit). * @param int $hideselectlimit Force to hide select limit * @return void */ @@ -2983,7 +2983,7 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so if ($picto == 'setup') $picto='title_setup.png'; if (($conf->browser->name == 'ie') && $picto=='title_generic.png') $picto='title.gif'; if ($limit < 0) $limit = $conf->liste_limit; - if ($savlimit >= 0 && (($num > $limit) || ($num == -1) || ($limit == 0))) + if ($savlimit != 0 && (($num > $limit) || ($num == -1) || ($limit == 0))) { $nextpage = 1; } @@ -2991,7 +2991,8 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so { $nextpage = 0; } - + //print 'totalnboflines='.$totalnboflines.'-savlimit='.$savlimit.'-limit='.$limit.'-num='.$num.'-nextpage='.$nextpage; + print "\n"; print "\n"; print ''; diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 75dca94540b..627bb67ff53 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -50,12 +50,12 @@ if ($socid > 0) if (!$user->rights->projet->lire) accessforbidden(); +$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $sortfield = GETPOST("sortfield","alpha"); $sortorder = GETPOST("sortorder"); $page = GETPOST("page"); $page = is_numeric($page) ? $page : 0; $page = $page == -1 ? 0 : $page; - if (! $sortfield) $sortfield="p.ref"; if (! $sortorder) $sortorder="ASC"; $offset = $conf->liste_limit * $page ; @@ -71,6 +71,7 @@ $search_all=GETPOST("search_all"); $search_status=GETPOST("search_status",'int'); $search_opp_status=GETPOST("search_opp_status",'alpha'); $search_opp_percent=GETPOST("search_opp_percent",'alpha'); +$search_opp_amount=GETPOST("search_opp_amount",'alpha'); $search_public=GETPOST("search_public",'int'); $search_user=GETPOST('search_user','int'); $search_sale=GETPOST('search_sale','int'); @@ -88,16 +89,6 @@ $year = GETPOST('year','int'); if ($search_status == '') $search_status=-1; // -1 or 1 -$sortfield = GETPOST("sortfield",'alpha'); -$sortorder = GETPOST("sortorder",'alpha'); -$page = GETPOST("page",'int'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; -if ($page == -1) { $page = 0; } -$offset = $limit * $page; -$pageprev = $page - 1; -$pagenext = $page + 1; -if (! $sortfield) $sortfield='p.ref'; -if (! $sortorder) $sortorder='DESC'; // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $contextpage='projectlist'; @@ -160,6 +151,8 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP $search_year=""; $search_status=-1; $search_opp_status=-1; + $search_opp_amount=''; + $search_opp_percent=''; $search_public=""; $search_sale=""; $search_user=''; @@ -237,6 +230,8 @@ if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$soc if ($search_ref) $sql .= natural_search('p.ref', $search_ref); if ($search_label) $sql .= natural_search('p.title', $search_label); if ($search_societe) $sql .= natural_search('s.nom', $search_societe); +if ($search_opp_amount) $sql .= natural_search('p.opp_amount', $search_opp_amount, 1); +if ($search_opp_percent) $sql .= natural_search('p.opp_percent', $search_opp_percent, 1); if ($smonth > 0) { if ($syear > 0 && empty($sday)) @@ -301,6 +296,7 @@ if ($resql) $num = $db->num_rows($resql); $param=''; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($sday) $param.='&sday='.$day; if ($smonth) $param.='&smonth='.$smonth; if ($syear) $param.='&syear=' .$syear; @@ -329,7 +325,6 @@ if ($resql) $text=$langs->trans("Projects"); if ($search_user == $user->id) $text=$langs->trans('MyProjects'); - print_barre_liste($text, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, "", $num,'','title_project'); print ''; if ($optioncss != '') print ''; @@ -340,7 +335,9 @@ if ($resql) print ''; print ''; - // Show description of content + print_barre_liste($text, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, "", $num, $nbtotalofrecords, 'title_project', 0, '', '', $limit); + + // Show description of content if ($search_user == $user->id) print $langs->trans("MyProjectsDesc").'

'; else { @@ -471,8 +468,9 @@ if ($resql) } if (! empty($arrayfields['p.opp_amount']['checked'])) { - print ''; + print ''; } if (! empty($arrayfields['p.fk_opp_status']['checked'])) { @@ -482,8 +480,9 @@ if ($resql) } if (! empty($arrayfields['p.opp_percent']['checked'])) { - print ''; + print ''; } // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 98bbff88483..d258dbb1e38 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -74,10 +74,10 @@ $socid=0; if ($user->societe_id > 0) $socid = $user->societe_id; if (!$user->rights->projet->lire) accessforbidden(); +$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; if ($page == -1) { $page = 0; } $offset = $limit * $page; $pageprev = $page - 1; @@ -300,7 +300,8 @@ if ($resql) $num = $db->num_rows($resql); $param=''; - if ($sday) $param.='&sday='.$day; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + if ($sday) $param.='&sday='.$day; if ($smonth) $param.='&smonth='.$smonth; if ($syear) $param.='&syear=' .$syear; if ($day) $param.='&day='.$day; @@ -327,8 +328,6 @@ if ($resql) if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); } - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, '', 'title_project'); - print ''; if ($optioncss != '') print ''; print ''; @@ -338,6 +337,8 @@ if ($resql) print ''; print ''; + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, $nbtotalofrecords, 'title_project', 0, '', '', $limit); + // Show description of content if ($search_task_user == $user->id) print $langs->trans("MyTasksDesc").'

'; else
'; - print ''; + print ''; + print ''; - print ''; + print ''; + print '