From 52290b002a84e1234234e11e35b453d111686863 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 13 Mar 2020 12:53:22 +0100 Subject: [PATCH] NEW Another way to navigate between pages for some lists --- htdocs/core/lib/functions.lib.php | 63 +++++++++++++------ .../modulebuilder/template/myobject_list.php | 6 +- htdocs/societe/list.php | 10 ++- htdocs/theme/eldy/global.inc.php | 7 ++- htdocs/theme/md/style.css.php | 7 ++- 5 files changed, 62 insertions(+), 31 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index d7c2e505b84..8434755bef1 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4281,14 +4281,15 @@ function load_fiche_titre($titre, $morehtmlright = '', $picto = 'generic', $pict * @param int|string $totalnboflines Total number of records/lines for all pages (if known). Use a negative value of number to not show number. Use '' if unknown. * @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 $morehtmlright More html to show + * @param string $morehtmlright 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 int $hideselectlimit Force to hide select limit * @param int $hidenavigation Force to hide all navigation tools + * @param int $pagenavastextinput 1=Do not suggest list of pages to navigate but suggest the page number into an input field. * @return void */ -function print_barre_liste($titre, $page, $file, $options = '', $sortfield = '', $sortorder = '', $morehtmlcenter = '', $num = -1, $totalnboflines = '', $picto = 'generic', $pictoisfullpath = 0, $morehtmlright = '', $morecss = '', $limit = -1, $hideselectlimit = 0, $hidenavigation = 0) +function print_barre_liste($titre, $page, $file, $options = '', $sortfield = '', $sortorder = '', $morehtmlcenter = '', $num = -1, $totalnboflines = '', $picto = 'generic', $pictoisfullpath = 0, $morehtmlright = '', $morecss = '', $limit = -1, $hideselectlimit = 0, $hidenavigation = 0, $pagenavastextinput = 0) { global $conf, $langs; @@ -4347,30 +4348,47 @@ function print_barre_liste($titre, $page, $file, $options = '', $sortfield = '', if ($cpt >= 1) { - $pagelist .= ''; - if ($cpt > 2) $pagelist .= ''; - elseif ($cpt == 2) $pagelist .= ''; + if (empty($pagenavastextinput)) { + $pagelist .= ''; + if ($cpt > 2) $pagelist .= ''; + elseif ($cpt == 2) $pagelist .= ''; + } } do { - if ($cpt == $page) - { - $pagelist .= ''; - } - else - { - $pagelist .= ''; + if ($pagenavastextinput) { + if ($cpt == $page) + { + $pagelist .= ''; + if (($cpt + 1) < $nbpages) $pagelist .= '/'; + } + } else { + if ($cpt == $page) + { + $pagelist .= ''; + } + else + { + $pagelist .= ''; + } } $cpt++; } - while ($cpt < $nbpages && $cpt <= $page + $maxnbofpage); + while ($cpt < $nbpages && $cpt <= ($page + $maxnbofpage)); - if ($cpt < $nbpages) - { - if ($cpt < $nbpages - 2) $pagelist .= ''; - elseif ($cpt == $nbpages - 2) $pagelist .= ''; - $pagelist .= ''; + if (empty($pagenavastextinput)) { + if ($cpt < $nbpages) + { + if ($cpt < $nbpages - 2) $pagelist .= ''; + elseif ($cpt == $nbpages - 2) $pagelist .= ''; + $pagelist .= ''; + } + } else { + //var_dump($page.' '.$cpt.' '.$nbpages); + if (($page + 1) < $nbpages) { + $pagelist .= ''; + } } } else @@ -4383,6 +4401,11 @@ function print_barre_liste($titre, $page, $file, $options = '', $sortfield = '', print_fleche_navigation($page, $file, $options, $nextpage, $pagelist, $morehtmlright, $savlimit, $totalnboflines, $hideselectlimit); // output the div and ul for previous/last completed with page numbers into $pagelist } + // js to autoselect page field on focus + if ($pagenavastextinput) { + print ajax_autoselect('.pageplusone'); + } + print ''; print ''."\n"; @@ -8019,7 +8042,7 @@ function getAdvancedPreviewUrl($modulepart, $relativepath, $alldata = 0, $param /** * Make content of an input box selected when we click into input field. * - * @param string $htmlname Id of html object + * @param string $htmlname Id of html object ('#idvalue' or '.classvalue') * @param string $addlink Add a 'link to' after * @return string */ @@ -8028,7 +8051,7 @@ function ajax_autoselect($htmlname, $addlink = '') global $langs; $out = ''; if ($addlink) $out .= ' '.$langs->trans("Link").''; diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index f7f2252ba3c..e451a627d69 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -85,8 +85,8 @@ $id = GETPOST('id', 'int'); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); -if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -372,7 +372,7 @@ print ''; $newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/mymodule/myobject_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); -print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, $newcardbutton, '', $limit); +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, $newcardbutton, '', $limit, 0, 0, 1); // Add code for pre mass action (confirmation or email presend form) $topicmail = "SendMyObjectRef"; diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index a7860012740..06d60843a79 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -97,8 +97,6 @@ $search_type = GETPOST('search_type', 'alpha'); $search_level = GETPOST("search_level", "array"); $search_stcomm = GETPOST('search_stcomm', 'int'); $search_import_key = GETPOST("search_import_key", "alpha"); -$search_btn = GETPOST('button_search', 'alpha'); -$search_remove_btn = GETPOST('button_removefilter', 'alpha'); $search_parent_name = GETPOST('search_parent_name', 'alpha'); $type = GETPOST('type', 'alpha'); @@ -110,10 +108,10 @@ $diroutputmassaction = $conf->societe->dir_output.'/temp/massgeneration/'.$user- $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (!$sortorder) $sortorder = "ASC"; if (!$sortfield) $sortfield = "s.nom"; -if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; } +if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -619,10 +617,10 @@ print ''; print ''; print ''; print ''; -print ''; +//print ''; print ''; -print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'building', 0, $newcardbutton, '', $limit); +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'building', 0, $newcardbutton, '', $limit, 0, 0, 1); $langs->load("other"); $textprofid = array(); diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 4fb723e7291..88293b6f899 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -311,10 +311,15 @@ td.rightborder { td.actionbuttons a { padding-left: 6px; } -select.flat, form.flat select { +select.flat, form.flat select, .pageplusone { font-weight: normal; font-size: unset; } +input.pageplusone { + padding-bottom: 4px; + padding-top: 4px; +} + .optionblue { color: var(--colortextlink); } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 8f61c785f14..8ad0df866c7 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -448,11 +448,16 @@ td.rightborder { td.actionbuttons a { padding-left: 6px; } -select.flat, form.flat select { +select.flat, form.flat select, .pageplusone { font-weight: normal; font-size: unset; height: 2em; } +input.pageplusone { + padding-bottom: 4px; + padding-top: 4px; +} + .optionblue { color: rgb(); }