From 6662c1b5e1a5782dbf98403a910bd2e68525ea4d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 Feb 2016 23:37:34 +0100 Subject: [PATCH] NEW Can select dynamicaly number of lines to show on page on product, shipment, contact, orders, thirdparties Fix can make a shipment for product not predefined in multiwarehouse mode --- htdocs/commande/list.php | 21 ++++++- htdocs/contact/list.php | 23 ++++---- htdocs/core/lib/functions.lib.php | 40 +++++++------ htdocs/expedition/card.php | 98 +++++++++++++++++++------------ htdocs/expedition/list.php | 46 ++++++++++++--- htdocs/product/list.php | 24 ++++---- htdocs/societe/list.php | 2 +- 7 files changed, 164 insertions(+), 90 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 5a112e60861..ce6df0524c4 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -64,10 +64,10 @@ $id = (GETPOST('orderid')?GETPOST('orderid'):GETPOST('id','int')); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'commande', $id,''); +$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; @@ -90,6 +90,19 @@ $fieldstosearchall = array( ); if (empty($user->socid)) $fieldstosearchall["c.note_private"]="NotePrivate"; +$arrayfields=array( +); +// Extra fields +/* + if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) + { + foreach($extrafields->attribute_label as $key => $val) + { + $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + } + } + */ + /* * Actions @@ -257,6 +270,7 @@ if ($resql) $title.=' - '.$langs->trans('StatusOrderValidated').', '.(empty($conf->expedition->enabled)?'':$langs->trans("StatusOrderSent").', ').$langs->trans('StatusOrderToBill'); $param=''; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($socid > 0) $param.='&socid='.$socid; if ($viewstatut != '') $param.='&viewstatut='.$viewstatut; if ($ordermonth) $param.='&ordermonth='.$ordermonth; @@ -272,7 +286,6 @@ if ($resql) if ($optioncss != '') $param.='&optioncss='.$optioncss; $num = $db->num_rows($resql); - print_barre_liste($title, $page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_commercial.png'); // Lignes des champs de filtre print '
'; @@ -283,7 +296,9 @@ if ($resql) print ''; print ''; - if ($sall) + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_commercial.png', 0, '', '', $limit); + + if ($sall) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index b319072dc68..f06de2ec8ec 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -67,6 +67,7 @@ $optioncss = GETPOST('optioncss','alpha'); $type=GETPOST("type"); $view=GETPOST("view"); +$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -76,7 +77,6 @@ $begin=GETPOST('begin'); if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="p.lastname"; if ($page < 0) { $page = 0; } -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $offset = $limit * $page; $langs->load("companies"); @@ -345,12 +345,12 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if($view == "recent") { $sql.= $db->order("p.datec","DESC"); - $sql.= $db->plimit($conf->liste_limit+1, $offset); + $sql.= $db->plimit($limit+1, $offset); } else { $sql.= $db->order($sortfield,$sortorder); - $sql.= $db->plimit($conf->liste_limit+1, $offset); + $sql.= $db->plimit($limit+1, $offset); } //print $sql; @@ -361,11 +361,14 @@ if ($result) $num = $db->num_rows($result); $i = 0; - $param ='&begin='.urlencode($begin).'&view='.urlencode($view).'&userid='.urlencode($userid).'&contactname='.urlencode($sall); - $param.='&type='.urlencode($type).'&view='.urlencode($view).'&search_lastname='.urlencode($search_lastname).'&search_firstname='.urlencode($search_firstname).'&search_societe='.urlencode($search_societe).'&search_email='.urlencode($search_email); + $param=''; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + $param.='&begin='.urlencode($begin).'&view='.urlencode($view).'&userid='.urlencode($userid).'&contactname='.urlencode($sall); + $param.='&type='.urlencode($type).'&view='.urlencode($view); if (!empty($search_categ)) $param.='&search_categ='.urlencode($search_categ); if ($search_lastname != '') $param.='&search_lastname='.urlencode($search_lastname); if ($search_firstname != '') $param.='&search_firstname='.urlencode($search_firstname); + if ($search_societe != '') $param.='&search_societe='.urlencode($search_societe); if ($search_zip != '') $param.='&search_zip='.urlencode($search_zip); if ($search_town != '') $param.='&search_town='.urlencode($search_town); if ($search_job != '') $param.='&search_job='.urlencode($search_job); @@ -385,8 +388,6 @@ if ($result) if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); } - print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords,'title_companies.png'); - print ''; if ($optioncss != '') print ''; print ''; @@ -395,6 +396,8 @@ if ($result) print ''; print ''; + print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies.png', 0, '', '', $limit); + if ($sall) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); @@ -739,10 +742,10 @@ if ($result) print ""; + if ($num > $limit || $page) print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies.png', 0, '', '', $limit, 1); + print '
'; - - if ($num > $limit) print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, ''); - + $db->free($result); } else diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index efa80e70554..d5f7345d7a7 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2955,28 +2955,29 @@ function load_fiche_titre($titre, $mesg='', $picto='title_generic.png', $pictois /** * Print a title with navigation controls for pagination * - * @param string $titre Title to show (required) - * @param string $page Numero of page to show in navigation links (required) - * @param string $file Url of page (required) - * @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). 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 (-1 = use default, 0 = no limit, > 0 = limit) + * @param string $titre Title to show (required) + * @param string $page Numero of page to show in navigation links (required) + * @param string $file Url of page (required) + * @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). 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|string $limit Max number of lines (-1 = use default, 0 = no limit, > 0 = limit). + * @param int $hideselectlimit Force to hide select 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=-1) +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, $hideselectlimit=0) { 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 < 0) $limit = $conf->liste_limit; @@ -3057,7 +3058,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, $savlimit, $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, $hideselectlimit); // output the div and ul for previous/last completed with page numbers into $pagelist print ''; print ''."\n"; @@ -3075,14 +3076,15 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so * @param string $afterarrows HTML content to show after arrows. Must NOT contains '
  • ' tags. * @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) + * @param int $hideselectlimit Force to hide select limit * @return void */ -function print_fleche_navigation($page, $file, $options='', $nextpage=0, $betweenarrows='', $afterarrows='', $limit=-1, $totalnboflines=0) +function print_fleche_navigation($page, $file, $options='', $nextpage=0, $betweenarrows='', $afterarrows='', $limit=-1, $totalnboflines=0, $hideselectlimit=0) { global $conf, $langs; print '