From 3fdfebf7ef437ff7d050dede9d0c92740e51827a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Tue, 27 Jun 2017 04:25:41 +0200 Subject: [PATCH] Fix position of top menu does not follow 'position' field. --- htdocs/comm/action/peruser.php | 4 +- htdocs/core/class/menu.class.php | 18 +- htdocs/core/class/menubase.class.php | 2 +- htdocs/core/get_menudiv.php | 2 +- htdocs/core/menus/standard/auguria.lib.php | 25 ++- htdocs/core/menus/standard/eldy.lib.php | 76 +++---- htdocs/core/menus/standard/empty.php | 247 ++++++++++++++++++--- htdocs/core/modules/modAgenda.class.php | 10 +- htdocs/hrm/index.php | 19 +- htdocs/theme/eldy/style.css.php | 1 + htdocs/theme/md/style.css.php | 1 + 11 files changed, 298 insertions(+), 107 deletions(-) diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 42fb67c8bde..7453b84d477 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -729,8 +729,8 @@ foreach ($usernames as $username) { $var = ! $var; echo "<tr>"; - echo '<td class="cal_current_month cal_peruserviewname'.($var?' cal_impair':'').'">'; - print $username->getNomUrl(-1,'',0,0,24,1,''); + echo '<td class="tdoverflowmax100 cal_current_month cal_peruserviewname'.($var?' cal_impair':'').'">'; + print $username->getNomUrl(-1,'',0,0,20,1,''); print '</td>'; $tmpday = $sav; diff --git a/htdocs/core/class/menu.class.php b/htdocs/core/class/menu.class.php index 58e93ec5544..d4570218ff2 100644 --- a/htdocs/core/class/menu.class.php +++ b/htdocs/core/class/menu.class.php @@ -51,7 +51,7 @@ class Menu /** * Add a menu entry into this->liste (at end) * - * @param string $url Url to follow on click + * @param string $url Url to follow on click (does not include DOL_URL_ROOT) * @param string $titre Label of menu to add * @param integer $level Level of menu to add * @param int $enabled Menu active or not (0=Not active, 1=Active, 2=Active but grey) @@ -59,11 +59,14 @@ class Menu * @param string $mainmenu Main menu ('home', 'companies', 'products', ...) * @param string $leftmenu Left menu ('setup', 'system', 'admintools', ...) * @param int $position Position (not used yet) + * @param string $id Id + * @param string $idsel Id sel + * @param string $classname Class name * @return void */ - function add($url, $titre, $level=0, $enabled=1, $target='',$mainmenu='',$leftmenu='',$position=0) + function add($url, $titre, $level=0, $enabled=1, $target='',$mainmenu='',$leftmenu='',$position=0, $id='', $idsel='', $classname='') { - $this->liste[]=array('url'=>$url,'titre'=>$titre,'level'=>$level,'enabled'=>$enabled,'target'=>$target,'mainmenu'=>$mainmenu,'leftmenu'=>$leftmenu, 'position'=>$position); + $this->liste[]=array('url'=>$url,'titre'=>$titre,'level'=>$level,'enabled'=>$enabled,'target'=>$target,'mainmenu'=>$mainmenu,'leftmenu'=>$leftmenu, 'position'=>$position, 'id'=>$id, 'idsel'=>$idsel, 'classname'=>$classname); } /** @@ -78,12 +81,15 @@ class Menu * @param string $mainmenu Main menu ('home', 'companies', 'products', ...) * @param string $leftmenu Left menu ('setup', 'system', 'admintools', ...) * @param int $position Position (not used yet) + * @param string $id Id + * @param string $idsel Id sel + * @param string $classname Class name * @return void */ - function insert($idafter, $url, $titre, $level=0, $enabled=1, $target='',$mainmenu='',$leftmenu='',$position=0) + function insert($idafter, $url, $titre, $level=0, $enabled=1, $target='',$mainmenu='',$leftmenu='',$position=0, $id='', $idsel='', $classname='') { $array_start = array_slice($this->liste,0,($idafter+1)); - $array_new = array(0=>array('url'=>$url,'titre'=>$titre,'level'=>$level,'enabled'=>$enabled,'target'=>$target,'mainmenu'=>$mainmenu,'leftmenu'=>$leftmenu,'position'=>$position)); + $array_new = array(0=>array('url'=>$url,'titre'=>$titre,'level'=>$level,'enabled'=>$enabled,'target'=>$target,'mainmenu'=>$mainmenu,'leftmenu'=>$leftmenu,'position'=>$position, 'id'=>$id, 'idsel'=>$idsel, 'classname'=>$classname)); $array_end = array_slice($this->liste,($idafter+1)); $this->liste=array_merge($array_start,$array_new,$array_end); } @@ -100,7 +106,7 @@ class Menu /** * Return number of visible entries (gray or not) - * + * * @return int Number of visible (gray or not) menu entries */ function getNbOfVisibleMenuEntries() diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index a6770b57c37..137a5517231 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -602,7 +602,7 @@ class Menubase //$tabMenu[$b]['langs'] = $menu['langs']; $tabMenu[$b]['fk_mainmenu'] = $menu['fk_mainmenu']; $tabMenu[$b]['fk_leftmenu'] = $menu['fk_leftmenu']; - $tabMenu[$b]['position'] = $menu['position']; + $tabMenu[$b]['position'] = (int) $menu['position']; $b++; } diff --git a/htdocs/core/get_menudiv.php b/htdocs/core/get_menudiv.php index d2712de201f..4ffee2caad9 100644 --- a/htdocs/core/get_menudiv.php +++ b/htdocs/core/get_menudiv.php @@ -194,7 +194,7 @@ if (! class_exists('MenuManager')) } $menumanager = new MenuManager($db, empty($user->societe_id)?0:1); $menumanager->loadMenu('all','all'); -//var_dump($menumanager->tabMenu);exit; +//var_dump($menumanager);exit; $menumanager->showmenu('jmobile'); print '</body>'; diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index b51d303765b..7b7adc76901 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -62,10 +62,7 @@ function print_auguria_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$m $classname = 'class="tmenu menuhider"'; $idsel='menu'; - if (empty($noout)) print_start_menu_entry_auguria($idsel,$classname,$showmode); - if (empty($noout)) print_text_menu_entry_auguria('', 1, '#', $id, $idsel, $classname, $atarget); - if (empty($noout)) print_end_menu_entry_auguria($showmode); - $menu->add('#', '', 0, $showmode, $atarget, "xxx", ''); + $menu->add('#', '', 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname); } $num = count($newTabMenu); @@ -95,7 +92,9 @@ function print_auguria_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$m } //$url.="idmenu=".$newTabMenu[$i]['rowid']; // Already done by menuLoad $url = dol_buildpath($url,1).($param?'?'.$param:''); - $shorturl = $shorturl.($param?'?'.$param:''); + //$shorturl = $shorturl.($param?'?'.$param:''); + $shorturl = $url; + if (DOL_URL_ROOT) $shorturl = preg_replace('/^'.preg_quote(DOL_URL_ROOT,'/').'/','',$shorturl); } $url=preg_replace('/__LOGIN__/',$user->login,$url); @@ -118,10 +117,18 @@ function print_auguria_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$m } else if ($showmode == 2) $classname='class="tmenu"'; - if (empty($noout)) print_start_menu_entry_auguria($idsel,$classname,$showmode); - if (empty($noout)) print_text_menu_entry_auguria($newTabMenu[$i]['titre'], $showmode, $url, $id, $idsel, $classname, ($newTabMenu[$i]['target']?$newTabMenu[$i]['target']:$atarget)); - if (empty($noout)) print_end_menu_entry_auguria($showmode); - $menu->add($shorturl, $newTabMenu[$i]['titre'], 0, $showmode, ($newTabMenu[$i]['target']?$newTabMenu[$i]['target']:$atarget), ($newTabMenu[$i]['mainmenu']?$newTabMenu[$i]['mainmenu']:$newTabMenu[$i]['rowid']), ''); + $menu->add($shorturl, $newTabMenu[$i]['titre'], 0, $showmode, ($newTabMenu[$i]['target']?$newTabMenu[$i]['target']:$atarget), ($newTabMenu[$i]['mainmenu']?$newTabMenu[$i]['mainmenu']:$newTabMenu[$i]['rowid']), ($newTabMenu[$i]['leftmenu']?$newTabMenu[$i]['leftmenu']:''), $newTabMenu[$i]['position'], $id, $idsel, $classname); + } + + // Sort on position + $menu->liste = dol_sort_array($menu->liste, 'position'); + + // Output menu entries + foreach($menu->liste as $menkey => $menuval) + { + if (empty($noout)) print_start_menu_entry_auguria($menuval['idsel'],$menuval['classname'],$menuval['enabled']); + if (empty($noout)) print_text_menu_entry_auguria($menuval['titre'], $menuval['enabled'], ($menuval['url']!='#'?DOL_URL_ROOT:'').$menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target']?$menuval['target']:$atarget)); + if (empty($noout)) print_end_menu_entry_auguria($menuval['enabled']); } $showmode=1; diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index cd53f913780..ad0bce68f86 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -60,10 +60,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode $classname = 'class="tmenu menuhider"'; $idsel='menu'; - if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode); - if (empty($noout)) print_text_menu_entry('', 1, '#', $id, $idsel, $classname, $atarget); - if (empty($noout)) print_end_menu_entry($showmode); - $menu->add('#', '', 0, $showmode, $atarget, "xxx", ''); + $menu->add('#', '', 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname); } // Home @@ -73,10 +70,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode else $classname = 'class="tmenu"'; $idsel='home'; - if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode); - if (empty($noout)) print_text_menu_entry($langs->trans("Home"), 1, DOL_URL_ROOT.'/index.php?mainmenu=home&leftmenu=', $id, $idsel, $classname, $atarget); - if (empty($noout)) print_end_menu_entry($showmode); - $menu->add('/index.php?mainmenu=home&leftmenu=home', $langs->trans("Home"), 0, $showmode, $atarget, "home", ''); + $menu->add('/index.php?mainmenu=home&leftmenu=home', $langs->trans("Home"), 0, $showmode, $atarget, "home", '', 10, $id, $idsel, $classname); // Third parties $tmpentry=array('enabled'=>(( ! empty($conf->societe->enabled) && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))) || ! empty($conf->fournisseur->enabled)), 'perms'=>(! empty($user->rights->societe->lire) || ! empty($user->rights->fournisseur->lire)), 'module'=>'societe|fournisseur'); @@ -91,10 +85,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode else $classname = 'class="tmenu"'; $idsel='companies'; - if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode); - if (empty($noout)) print_text_menu_entry($langs->trans("ThirdParties"), $showmode, DOL_URL_ROOT.'/societe/index.php?mainmenu=companies&leftmenu=', $id, $idsel, $classname, $atarget); - if (empty($noout)) print_end_menu_entry($showmode); - $menu->add('/societe/index.php?mainmenu=companies&leftmenu=', $langs->trans("ThirdParties"), 0, $showmode, $atarget, "companies", ''); + $menu->add('/societe/index.php?mainmenu=companies&leftmenu=', $langs->trans("ThirdParties"), 0, $showmode, $atarget, "companies", '', 20, $id, $idsel, $classname); } // Products-Services @@ -120,10 +111,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode $chaine.=$langs->trans("TMenuServices"); } - if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode); - if (empty($noout)) print_text_menu_entry($chaine, $showmode, DOL_URL_ROOT.'/product/index.php?mainmenu=products&leftmenu=', $id, $idsel, $classname, $atarget); - if (empty($noout)) print_end_menu_entry($showmode); - $menu->add('/product/index.php?mainmenu=products&leftmenu=', $chaine, 0, $showmode, $atarget, "products", ''); + $menu->add('/product/index.php?mainmenu=products&leftmenu=', $chaine, 0, $showmode, $atarget, "products", '', 30, $id, $idsel, $classname); } // Commercial @@ -147,10 +135,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode else $classname = 'class="tmenu"'; $idsel='commercial'; - if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode); - if (empty($noout)) print_text_menu_entry($langs->trans("Commercial"), $showmode, DOL_URL_ROOT.'/comm/index.php?mainmenu=commercial&leftmenu=', $id, $idsel, $classname, $atarget); - if (empty($noout)) print_end_menu_entry($showmode); - $menu->add('/comm/index.php?mainmenu=commercial&leftmenu=', $langs->trans("Commercial"), 0, $showmode, $atarget, "commercial", ""); + $menu->add('/comm/index.php?mainmenu=commercial&leftmenu=', $langs->trans("Commercial"), 0, $showmode, $atarget, "commercial", "", 40, $id, $idsel, $classname); } // Financial @@ -177,10 +162,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode else $classname = 'class="tmenu"'; $idsel='accountancy'; - if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode); - if (empty($noout)) print_text_menu_entry($langs->trans("MenuFinancial"), $showmode, DOL_URL_ROOT.'/compta/index.php?mainmenu=accountancy&leftmenu=', $id, $idsel, $classname, $atarget); - if (empty($noout)) print_end_menu_entry($showmode); - $menu->add('/compta/index.php?mainmenu=accountancy&leftmenu=', $langs->trans("MenuFinancial"), 0, $showmode, $atarget, "accountancy", ''); + $menu->add('/compta/index.php?mainmenu=accountancy&leftmenu=', $langs->trans("MenuFinancial"), 0, $showmode, $atarget, "accountancy", '', 50, $id, $idsel, $classname); } // Bank @@ -198,10 +180,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode else $classname = 'class="tmenu"'; $idsel='bank'; - if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode); - if (empty($noout)) print_text_menu_entry($langs->trans("MenuBankCash"), $showmode, DOL_URL_ROOT.'/compta/bank/index.php?mainmenu=bank&leftmenu=', $id, $idsel, $classname, $atarget); - if (empty($noout)) print_end_menu_entry($showmode); - $menu->add('/compta/bank/index.php?mainmenu=bank&leftmenu=', $langs->trans("MenuBankCash"), 0, $showmode, $atarget, "bank", ''); + $menu->add('/compta/bank/index.php?mainmenu=bank&leftmenu=', $langs->trans("MenuBankCash"), 0, $showmode, $atarget, "bank", '', 60, $id, $idsel, $classname); } // Projects @@ -218,10 +197,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode else $classname = 'class="tmenu"'; $idsel='project'; - if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode); - if (empty($noout)) print_text_menu_entry($langs->trans("Projects"), $showmode, DOL_URL_ROOT.'/projet/index.php?mainmenu=project&leftmenu=', $id, $idsel, $classname, $atarget); - if (empty($noout)) print_end_menu_entry($showmode); - $menu->add('/projet/index.php?mainmenu=project&leftmenu=', $langs->trans("Projects"), 0, $showmode, $atarget, "project", ''); + $menu->add('/projet/index.php?mainmenu=project&leftmenu=', $langs->trans("Projects"), 0, $showmode, $atarget, "project", '', 70, $id, $idsel, $classname); } // HRM @@ -238,10 +214,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode else $classname = 'class="tmenu"'; $idsel='hrm'; - if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode); - if (empty($noout)) print_text_menu_entry($langs->trans("HRM"), $showmode, DOL_URL_ROOT.'/hrm/index.php?mainmenu=hrm&leftmenu=', $id, $idsel, $classname, $atarget); - if (empty($noout)) print_end_menu_entry($showmode); - $menu->add('/hrm/index.php?mainmenu=hrm&leftmenu=', $langs->trans("HRM"), 0, $showmode, $atarget, "hrm", ''); + $menu->add('/hrm/index.php?mainmenu=hrm&leftmenu=', $langs->trans("HRM"), 0, $showmode, $atarget, "hrm", '', 80, $id, $idsel, $classname); } @@ -260,10 +233,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode else $classname = 'class="tmenu"'; $idsel='tools'; - if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode); - if (empty($noout)) print_text_menu_entry($langs->trans("TMenuTools"), $showmode, DOL_URL_ROOT.'/core/tools.php?mainmenu=tools&leftmenu=', $id, $idsel, $classname, $atarget); - if (empty($noout)) print_end_menu_entry($showmode); - $menu->add('/core/tools.php?mainmenu=tools&leftmenu=', $langs->trans("Tools"), 0, $showmode, $atarget, "tools", ''); + $menu->add('/core/tools.php?mainmenu=tools&leftmenu=', $langs->trans("Tools"), 0, $showmode, $atarget, "tools", '', 90, $id, $idsel, $classname); } // Members @@ -278,10 +248,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode else $classname = 'class="tmenu"'; $idsel='members'; - if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode); - if (empty($noout)) print_text_menu_entry($langs->trans("MenuMembers"), $showmode, DOL_URL_ROOT.'/adherents/index.php?mainmenu=members&leftmenu=', $id, $idsel, $classname, $atarget); - if (empty($noout)) print_end_menu_entry($showmode); - $menu->add('/adherents/index.php?mainmenu=members&leftmenu=', $langs->trans("MenuMembers"), 0, $showmode, $atarget, "members", ''); + $menu->add('/adherents/index.php?mainmenu=members&leftmenu=', $langs->trans("MenuMembers"), 0, $showmode, $atarget, "members", '', 100, $id, $idsel, $classname); } @@ -297,6 +264,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode $showmode=dol_eldy_showmenu($type_user,$newTabMenu[$i],$listofmodulesforexternal); if ($showmode == 1) { + // url = url from host, shorturl = relative path into dolibarr sources $url = $shorturl = $newTabMenu[$i]['url']; if (! preg_match("/^(http:\/\/|https:\/\/)/i",$newTabMenu[$i]['url'])) { @@ -307,7 +275,9 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode if (! preg_match('/mainmenu/i',$param) || ! preg_match('/leftmenu/i',$param)) $param.=($param?'&':'').'mainmenu='.$newTabMenu[$i]['mainmenu'].'&leftmenu='; //$url.="idmenu=".$newTabMenu[$i]['rowid']; // Already done by menuLoad $url = dol_buildpath($url,1).($param?'?'.$param:''); - $shorturl = $shorturl.($param?'?'.$param:''); + //$shorturl = $shorturl.($param?'?'.$param:''); + $shorturl = $url; + if (DOL_URL_ROOT) $shorturl = preg_replace('/^'.preg_quote(DOL_URL_ROOT,'/').'/','',$shorturl); } $url=preg_replace('/__LOGIN__/',$user->login,$url); $shorturl=preg_replace('/__LOGIN__/',$user->login,$shorturl); @@ -321,10 +291,18 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode } else if ($showmode == 2) $classname='class="tmenu"'; - if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode); - if (empty($noout)) print_text_menu_entry($newTabMenu[$i]['titre'], $showmode, $url, $id, $idsel, $classname, ($newTabMenu[$i]['target']?$newTabMenu[$i]['target']:$atarget)); - if (empty($noout)) print_end_menu_entry($showmode); - $menu->add($shorturl, $newTabMenu[$i]['titre'], 0, $showmode, ($newTabMenu[$i]['target']?$newTabMenu[$i]['target']:$atarget), ($newTabMenu[$i]['mainmenu']?$newTabMenu[$i]['mainmenu']:$newTabMenu[$i]['rowid']), ''); + $menu->add($shorturl, $newTabMenu[$i]['titre'], 0, $showmode, ($newTabMenu[$i]['target']?$newTabMenu[$i]['target']:$atarget), ($newTabMenu[$i]['mainmenu']?$newTabMenu[$i]['mainmenu']:$newTabMenu[$i]['rowid']), ($newTabMenu[$i]['leftmenu']?$newTabMenu[$i]['leftmenu']:''), $newTabMenu[$i]['position'], $id, $idsel, $classname); + } + + // Sort on position + $menu->liste = dol_sort_array($menu->liste, 'position'); + + // Output menu entries + foreach($menu->liste as $menkey => $menuval) + { + if (empty($noout)) print_start_menu_entry($menuval['idsel'],$menuval['classname'],$menuval['enabled']); + if (empty($noout)) print_text_menu_entry($menuval['titre'], $menuval['enabled'], ($menuval['url']!='#'?DOL_URL_ROOT:'').$menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target']?$menuval['target']:$atarget)); + if (empty($noout)) print_end_menu_entry($menuval['enabled']); } $showmode=1; diff --git a/htdocs/core/menus/standard/empty.php b/htdocs/core/menus/standard/empty.php index e4424712625..dafc0486145 100644 --- a/htdocs/core/menus/standard/empty.php +++ b/htdocs/core/menus/standard/empty.php @@ -76,39 +76,47 @@ class MenuManager $res='ErrorBadParameterForMode'; $noout=0; - if ($mode == 'jmobile') $noout=1; + //if ($mode == 'jmobile') $noout=1; if ($mode == 'topnb') { return 1; } - if ($mode == 'top' || $mode == 'jmobile') + if ($mode == 'top') { if (empty($noout)) print_start_menu_array_empty(); - // Home - $showmode=1; - $idsel='home'; - $classname='class="tmenusel"'; + $usemenuhider = (GETPOST('testmenuhider','int') || ! empty($conf->global->MAIN_TESTMENUHIDER)); // Show/Hide vertical menu - if ($mode != 'jmobile' && $mode != 'topnb' && (GETPOST('testmenuhider','int') || ! empty($conf->global->MAIN_TESTMENUHIDER)) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if ($mode != 'jmobile' && $mode != 'topnb' && $usemenuhider && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $showmode=1; $classname = 'class="tmenu menuhider"'; $idsel='menu'; - if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode); - if (empty($noout)) print_text_menu_entry('', 1, '#', $id, $idsel, $classname, $atarget); - if (empty($noout)) print_end_menu_entry($showmode); - $menu->add('#', '', 0, $showmode, $atarget, "xxx", ''); + $this->menu->add('#', '', 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname); } - if (empty($noout)) print_start_menu_entry_empty($idsel, $classname, $showmode); - if (empty($noout)) print_text_menu_entry_empty($langs->trans("Home"), 1, dol_buildpath('/index.php',1).'?mainmenu=home&leftmenu=', $id, $idsel, $classname, $this->atarget); - if (empty($noout)) print_end_menu_entry_empty($showmode); - $this->menu->add(dol_buildpath('/index.php',1), $langs->trans("Home"), 0, $showmode, $this->atarget, 'home', ''); + // Home + $showmode=1; + $classname='class="tmenusel"'; + $idsel='home'; + + $this->menu->add('/index.php', $langs->trans("Home"), 0, $showmode, $this->atarget, 'home', '', 10, $id, $idsel, $classname); + + + // Sort on position + $this->menu->liste = dol_sort_array($this->menu->liste, 'position'); + + // Output menu entries + foreach($this->menu->liste as $menkey => $menuval) + { + if (empty($noout)) print_start_menu_entry_empty($menuval['idsel'],$menuval['classname'],$menuval['enabled']); + if (empty($noout)) print_text_menu_entry_empty($menuval['titre'], $menuval['enabled'], ($menuval['url']!='#'?DOL_URL_ROOT:'').$menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target']?$menuval['target']:$atarget)); + if (empty($noout)) print_end_menu_entry_empty($menuval['enabled']); + } $showmode=1; if (empty($noout)) print_start_menu_entry_empty('','class="tmenuend"',$showmode); @@ -123,7 +131,195 @@ class MenuManager } } - if ($mode == 'left' || $mode == 'jmobile') + if ($mode == 'jmobile') // Used to get menu in xml ul/li + { + // Home + $showmode=1; + $classname='class="tmenusel"'; + $idsel='home'; + + $this->menu->add('/index.php', $langs->trans("Home"), 0, $showmode, $this->atarget, 'home', '', 10, $id, $idsel, $classname); + + + // $this->menu->liste is top menu + //var_dump($this->menu->liste);exit; + $lastlevel = array(); + print '<!-- Generate menu list from menu handler '.$this->name.' -->'."\n"; + foreach($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' + { + print '<ul class="ulmenu" data-inset="true">'; + print '<li class="lilevel0">'; + + if ($val['enabled'] == 1) + { + $relurl=dol_buildpath($val['url'],1); + $relurl=preg_replace('/__LOGIN__/',$user->login,$relurl); + $relurl=preg_replace('/__USERID__/',$user->id,$relurl); + $canonurl=preg_replace('/\?.*$/','',$val['url']); + + print '<a class="alilevel0" href="#">'; + + // Add font-awesome + if ($val['level'] == 0 && $val['mainmenu'] == 'home') print '<span class="fa fa-home fa-fw paddingright" aria-hidden="true"></span>'; + + print $val['titre']; + print '</a>'."\n"; + + // Search submenu fot this mainmenu entry + $tmpmainmenu=$val['mainmenu']; + $tmpleftmenu='all'; + $submenu=new Menu(); + + $langs->load("admin"); // Load translation file admin.lang + $submenu->add("/admin/index.php?leftmenu=setup", $langs->trans("Setup"),0); + $submenu->add("/admin/company.php", $langs->trans("MenuCompanySetup"),1); + $submenu->add("/admin/modules.php", $langs->trans("Modules"),1); + $submenu->add("/admin/menus.php", $langs->trans("Menus"),1); + $submenu->add("/admin/ihm.php", $langs->trans("GUISetup"),1); + $submenu->add("/admin/translation.php?mainmenu=home", $langs->trans("Translation"),1); + $submenu->add("/admin/defaultvalues.php?mainmenu=home", $langs->trans("DefaultValues"),1); + + $submenu->add("/admin/boxes.php", $langs->trans("Boxes"),1); + $submenu->add("/admin/delais.php",$langs->trans("Alerts"),1); + $submenu->add("/admin/proxy.php?mainmenu=home", $langs->trans("Security"),1); + $submenu->add("/admin/limits.php?mainmenu=home", $langs->trans("MenuLimits"),1); + $submenu->add("/admin/pdf.php?mainmenu=home", $langs->trans("PDF"),1); + $submenu->add("/admin/mails.php?mainmenu=home", $langs->trans("Emails"),1); + $submenu->add("/admin/sms.php?mainmenu=home", $langs->trans("SMS"),1); + $submenu->add("/admin/dict.php?mainmenu=home", $langs->trans("DictionarySetup"),1); + $submenu->add("/admin/const.php?mainmenu=home", $langs->trans("OtherSetup"),1); + + //if ($tmpmainmenu.'-'.$tmpleftmenu == 'home-all') { var_dump($submenu); exit; } + //if ($tmpmainmenu=='accountancy') { var_dump($submenu->liste); exit; } + $nexturl=dol_buildpath($submenu->liste[0]['url'],1); + + $canonrelurl=preg_replace('/\?.*$/','',$relurl); + $canonnexturl=preg_replace('/\?.*$/','',$nexturl); + //var_dump($canonrelurl); + //var_dump($canonnexturl); + print '<ul>'."\n"; + if (($canonrelurl != $canonnexturl && ! in_array($val['mainmenu'],array('tools'))) + || (strpos($canonrelurl,'/product/index.php') !== false || strpos($canonrelurl,'/compta/bank/index.php') !== false)) + { + // We add sub entry + print str_pad('',1).'<li class="lilevel1 ui-btn-icon-right ui-btn">'; // ui-btn to highlight on clic + print '<a href="'.$relurl.'">'; + if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") // No translation + { + if (in_array($val['mainmenu'], array('cashdesk', 'websites'))) print $langs->trans("Access"); + else print $langs->trans("Dashboard"); + } + else print $langs->trans(ucfirst($val['mainmenu'])."Dashboard"); + print '</a>'; + print '</li>'."\n"; + } + + if ($val['level']==0) + { + if ($val['enabled']) + { + $lastlevel[0]='enabled'; + } + else if ($showmenu) // Not enabled but visible (so greyed) + { + $lastlevel[0]='greyed'; + } + else + { + $lastlevel[0]='hidden'; + } + } + + $lastlevel2 = array(); + foreach($submenu->liste as $key2 => $val2) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' + { + $showmenu=true; + if (! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($val2['enabled'])) $showmenu=false; + + // If at least one parent is not enabled, we do not show any menu of all children + if ($val2['level'] > 0) + { + $levelcursor = $val2['level']-1; + while ($levelcursor >= 0) + { + if ($lastlevel2[$levelcursor] != 'enabled') $showmenu=false; + $levelcursor--; + } + } + + if ($showmenu) // Visible (option to hide when not allowed is off or allowed) + { + $relurl2=dol_buildpath($val2['url'],1); + $relurl2=preg_replace('/__LOGIN__/',$user->login,$relurl2); + $relurl2=preg_replace('/__USERID__/',$user->id,$relurl2); + $canonurl2=preg_replace('/\?.*$/','',$val2['url']); + //var_dump($val2['url'].' - '.$canonurl2.' - '.$val2['level']); + if (in_array($canonurl2,array('/admin/index.php','/admin/tools/index.php','/core/tools.php'))) $relurl2=''; + + $disabled=''; + if (! $val2['enabled']) + { + $disabled=" vsmenudisabled"; + } + + print str_pad('',$val2['level']+1); + print '<li class="lilevel'.($val2['level']+1); + if ($val2['level']==0) print ' ui-btn-icon-right ui-btn'; // ui-btn to highlight on clic + print $disabled.'">'; // ui-btn to highlight on clic + if ($relurl2) + { + if ($val2['enabled']) // Allowed + { + print '<a href="'.$relurl2.'"'; + //print ' data-ajax="false"'; + print '>'; + $lastlevel2[$val2['level']]='enabled'; + } + else // Not allowed but visible (greyed) + { + print '<a href="#" class="vsmenudisabled">'; + $lastlevel2[$val2['level']]='greyed'; + } + } + else + { + if ($val2['enabled']) // Allowed + { + $lastlevel2[$val2['level']]='enabled'; + } + else + { + $lastlevel2[$val2['level']]='greyed'; + } + } + //var_dump($val2['level']); + //var_dump($lastlevel2); + print $val2['titre']; + if ($relurl2) + { + if ($val2['enabled']) // Allowed + print '</a>'; + else + print '</a>'; + } + print '</li>'."\n"; + } + + + } + //var_dump($submenu); + print '</ul>'; + } + if ($val['enabled'] == 2) + { + print '<font class="vsmenudisabled">'.$val['titre'].'</font>'; + } + print '</li>'; + print '</ul>'."\n"; + } + } + + if ($mode == 'left') { // Put here left menu entries // ***** START ***** @@ -134,8 +330,10 @@ class MenuManager $this->menu->add("/admin/modules.php", $langs->trans("Modules"),1); $this->menu->add("/admin/menus.php", $langs->trans("Menus"),1); $this->menu->add("/admin/ihm.php", $langs->trans("GUISetup"),1); - $this->menu->add("/admin/fiscalyear.php", $langs->trans("Fiscalyear"),1); - $this->menu->add("/admin/boxes.php", $langs->trans("Boxes"),1); + $this->menu->add("/admin/translation.php?mainmenu=home", $langs->trans("Translation"),1); + $this->menu->add("/admin/defaultvalues.php?mainmenu=home", $langs->trans("DefaultValues"),1); + + $this->menu->add("/admin/boxes.php", $langs->trans("Boxes"),1); $this->menu->add("/admin/delais.php",$langs->trans("Alerts"),1); $this->menu->add("/admin/proxy.php?mainmenu=home", $langs->trans("Security"),1); $this->menu->add("/admin/limits.php?mainmenu=home", $langs->trans("MenuLimits"),1); @@ -143,7 +341,6 @@ class MenuManager $this->menu->add("/admin/mails.php?mainmenu=home", $langs->trans("Emails"),1); $this->menu->add("/admin/sms.php?mainmenu=home", $langs->trans("SMS"),1); $this->menu->add("/admin/dict.php?mainmenu=home", $langs->trans("DictionarySetup"),1); - if (! empty($conf->accounting->enabled)) $this->menu->add("/accountancy/admin/account.php", $langs->trans("Chartofaccounts"),1); $this->menu->add("/admin/const.php?mainmenu=home", $langs->trans("OtherSetup"),1); // ***** END ***** @@ -170,15 +367,15 @@ class MenuManager $lastopened = 1; // For menu manager "empty", we force to not have blockvmenulast defined if (($alt%2==0)) { - print '<div class="blockvmenuimpair blockvmenuunique'.($lastopened?' blockvmenulast':'').($alt == 1 ? ' blockvmenufirst':'').'">'."\n"; + print '<div class="blockvmenub lockvmenuimpair blockvmenuunique'.($lastopened?' blockvmenulast':'').($alt == 1 ? ' blockvmenufirst':'').'">'."\n"; } else { - print '<div class="blockvmenupair blockvmenuunique'.($lastopened?' blockvmenulast':'').($alt == 1 ? ' blockvmenufirst':'').'">'."\n"; + print '<div class="blockvmenu blockvmenupair blockvmenuunique'.($lastopened?' blockvmenulast':'').($alt == 1 ? ' blockvmenufirst':'').'">'."\n"; } } - // Place tabulation + // Add tabulation $tabstring=''; $tabul=($this->menu->liste[$i]['level'] - 1); if ($tabul > 0) @@ -243,10 +440,10 @@ class MenuManager unset($this->menu->liste); } } - +/* if ($mode == 'jmobile') { - foreach($this->topmenu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' + foreach($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' { print '<ul class="ulmenu" data-inset="true">'; print '<li class="lilevel0">'; @@ -296,7 +493,7 @@ class MenuManager break; // Only first menu entry (so home) } } - +*/ unset($this->menu); return $res; diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php index 7513b489195..de7b42ef1a6 100644 --- a/htdocs/core/modules/modAgenda.class.php +++ b/htdocs/core/modules/modAgenda.class.php @@ -86,17 +86,17 @@ class modAgenda extends DolibarrModules { while ($obj = $this->db->fetch_object($sqlreadactions)) { - //if (preg_match('/_CREATE$/',$obj->code) && (! in_array($obj->code, array('COMPANY_CREATE','PRODUCT_CREATE','TASK_CREATE')))) continue; // We don't track such events (*_CREATE) by default, we prefer validation (except thirdparty/product/task creation because there is no validation). + //if (preg_match('/_CREATE$/',$obj->code) && (! in_array($obj->code, array('COMPANY_CREATE','PRODUCT_CREATE','TASK_CREATE')))) continue; // We don't track such events (*_CREATE) by default, we prefer validation (except thirdparty/product/task creation because there is no validation). if (preg_match('/^TASK_/',$obj->code)) continue; // We don't track such events by default. //if (preg_match('/^_MODIFY/',$obj->code)) continue; // We don't track such events by default. $this->const[] = array('MAIN_AGENDA_ACTIONAUTO_'.$obj->code, "chaine", "1"); } } - else + else { dol_print_error($this->db->lasterror()); } - + // New pages on tabs // ----------------- $this->tabs = array(); @@ -197,7 +197,7 @@ class modAgenda extends DolibarrModules 'mainmenu'=>'agenda', 'url'=>'/comm/action/index.php', 'langs'=>'agenda', - 'position'=>100, + 'position'=>15, 'perms'=>'$user->rights->agenda->myactions->read', 'enabled'=>'$conf->agenda->enabled', 'target'=>'', @@ -407,5 +407,5 @@ class modAgenda extends DolibarrModules $this->export_sql_end[$r] .=' ORDER BY ac.datep'; } - + } diff --git a/htdocs/hrm/index.php b/htdocs/hrm/index.php index 24038fd3403..5b3548cc8fb 100644 --- a/htdocs/hrm/index.php +++ b/htdocs/hrm/index.php @@ -109,7 +109,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele print '</tr>'; $i++; } - print '</table>'; + print '</table>'; print '</form>'; print '<br>'; } @@ -171,12 +171,13 @@ if (! empty($conf->holiday->enabled) && $user->rights->holiday->read) $holidaystatic=new Holiday($db); $userstatic=new User($db); - + $listhalfday=array('morning'=>$langs->trans("Morning"),"afternoon"=>$langs->trans("Afternoon")); $typeleaves=$holidaystatic->getTypes(1,-1); - + $i = 0; + print '<div class="div-table-responsive">'; print '<table class="noborder" width="100%">'; print '<tr class="liste_titre">'; print '<th colspan="3">'.$langs->trans("BoxTitleLastLeaveRequests",min($max,$num)).'</th>'; @@ -202,16 +203,16 @@ if (! empty($conf->holiday->enabled) && $user->rights->holiday->read) print '<td>'.$holidaystatic->getNomUrl(1).'</td>'; print '<td>'.$userstatic->getNomUrl(-1, 'leave').'</td>'; print '<td>'.$typeleaves[$obj->fk_type]['label'].'</td>'; - + $starthalfday=($obj->halfday == -1 || $obj->halfday == 2)?'afternoon':'morning'; $endhalfday=($obj->halfday == 1 || $obj->halfday == 2)?'morning':'afternoon'; - + print '<td>'.dol_print_date($obj->date_start,'day').' '.$langs->trans($listhalfday[$starthalfday]); print '<td>'.dol_print_date($obj->date_end,'day').' '.$langs->trans($listhalfday[$endhalfday]); print '<td align="right">'.dol_print_date($db->jdate($obj->dm),'day').'</td>'; print '<td>'.$holidaystatic->LibStatut($obj->status,3).'</td>'; print '</tr>'; - + $i++; } @@ -220,7 +221,7 @@ if (! empty($conf->holiday->enabled) && $user->rights->holiday->read) { print '<tr class="oddeven"><td colspan="7" class="opacitymedium">'.$langs->trans("None").'</td></tr>'; } - print '</table><br>'; + print '</table></div><br>'; } else dol_print_error($db); } @@ -279,7 +280,7 @@ if (! empty($conf->deplacement->enabled) && $user->rights->deplacement->lire) print '<td align="right">'.dol_print_date($db->jdate($obj->dm),'day').'</td>'; print '<td>'.$deplacementstatic->LibStatut($obj->fk_statut,3).'</td>'; print '</tr>'; - + $i++; } @@ -346,7 +347,7 @@ if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire print '<td align="right">'.dol_print_date($db->jdate($obj->dm),'day').'</td>'; print '<td>'.$expensereportstatic->LibStatut($obj->status,3).'</td>'; print '</tr>'; - + $i++; } diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 67359ea650f..d7ba1f979b4 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -1735,6 +1735,7 @@ img.userphotosmall { /* size for user photo in lists */ height: 12px; background-size: contain; vertical-align: middle; + background-color: #FFF; } .span-icon-user { background-image: url(<?php echo dol_buildpath($path.'/theme/'.$theme.'/img/object_user.png',1); ?>); diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 8543b2ecc0f..a2c9b20c63b 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1747,6 +1747,7 @@ img.login, img.printer, img.entity { height: 16px; background-size: contain; vertical-align: text-bottom; + background-color: #FFF; } img.userphoto { /* size for user photo in lists */ border-radius: 9px; -- GitLab