/** * Core function to output top menu eldy * * @param $db * @param $atarget * @param $type_user 0=Internal,1=External,2=All */ function print_eldy_menu($db, $atarget, $type_user) { global $user, $conf, $langs, $dolibarr_main_db_name; // On sauve en session le menu principal choisi if (isset($_GET["mainmenu"])) { $_SESSION["mainmenu"] = $_GET["mainmenu"]; } if (isset($_GET["idmenu"])) { $_SESSION["idmenu"] = $_GET["idmenu"]; } $_SESSION["leftmenuopened"] = ""; $id = 'mainmenu'; print_start_menu_array(); // Home $classname = ""; if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "home") { $classname = 'class="tmenusel"'; $_SESSION['idmenu'] = ''; } else { $classname = 'class="tmenu"'; } $idsel = 'home'; print_start_menu_entry($idsel); print '<a class="tmenuimage" href="' . DOL_URL_ROOT . '/index.php?mainmenu=home&leftmenu="' . ($atarget ? " target={$atarget}" : "") . '>'; print '<div class="' . $id . ' ' . $idsel . '"><span class="' . $id . ' tmenuimage" id="mainmenuspan_' . $idsel . '"></span></div>'; print '</a>'; print '<a ' . $classname . ' id="mainmenua_' . $idsel . '" href="' . DOL_URL_ROOT . '/index.php?mainmenu=home&leftmenu="' . ($atarget ? ' target="' . $atarget . '"' : '') . '>'; print_text_menu_entry($langs->trans("Home")); print '</a>'; print_end_menu_entry(); // Third parties if ($conf->societe->enabled || $conf->fournisseur->enabled) { $langs->load("companies"); $langs->load("suppliers"); $classname = ""; if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "companies") { $classname = 'class="tmenusel"'; $_SESSION['idmenu'] = ''; } else { $classname = 'class="tmenu"'; } $idsel = 'companies'; if ($conf->societe->enabled && $user->rights->societe->lire || $conf->fournisseur->enabled && $user->rights->fournisseur->lire) { print_start_menu_entry($idsel); print '<a class="tmenuimage" href="' . DOL_URL_ROOT . '/societe/index.php?mainmenu=companies&leftmenu="' . ($atarget ? ' target="' . $atarget . '"' : '') . '>'; print '<div class="' . $id . ' ' . $idsel . '"><span class="' . $id . ' tmenuimage" id="mainmenuspan_' . $idsel . '"></span></div>'; print '</a>'; print '<a ' . $classname . ' id="mainmenua_' . $idsel . '" href="' . DOL_URL_ROOT . '/societe/index.php?mainmenu=companies&leftmenu="' . ($atarget ? ' target="' . $atarget . '"' : '') . '>'; print_text_menu_entry($langs->trans("ThirdParties")); print '</a>'; print_end_menu_entry(); } else { if (empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED)) { if (!$type_user) { print_start_menu_entry($idsel); print '<div class="' . $id . ' ' . $idsel . '"><span class="' . $id . '" id="mainmenuspan_' . $idsel . '"></span></div>'; print '<a class="tmenudisabled" id="mainmenua_' . $idsel . '" href="#" title="' . dol_escape_htmltag($langs->trans("NotAllowed")) . '">'; print_text_menu_entry($langs->trans("ThirdParties")); print '</a>'; print_end_menu_entry(); } } } } // Products-Services if ($conf->product->enabled || $conf->service->enabled) { $langs->load("products"); $classname = ""; if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "products") { $classname = 'class="tmenusel"'; $_SESSION['idmenu'] = ''; } else { $classname = 'class="tmenu"'; } $chaine = ""; if ($conf->product->enabled) { $chaine .= $langs->trans("Products"); } if ($conf->product->enabled && $conf->service->enabled) { $chaine .= "/"; } if ($conf->service->enabled) { $chaine .= $langs->trans("Services"); } $idsel = 'products'; if ($user->rights->produit->lire || $user->rights->service->lire) { print_start_menu_entry($idsel); print '<a class="tmenuimage" href="' . DOL_URL_ROOT . '/product/index.php?mainmenu=products&leftmenu="' . ($atarget ? ' target="' . $atarget . '"' : '') . '>'; print '<div class="' . $id . ' ' . $idsel . '"><span class="' . $id . ' tmenuimage" id="mainmenuspan_' . $idsel . '"></span></div>'; print '</a>'; print '<a ' . $classname . ' id="mainmenua_' . $idsel . '" href="' . DOL_URL_ROOT . '/product/index.php?mainmenu=products&leftmenu="' . ($atarget ? ' target="' . $atarget . '"' : '') . '>'; print_text_menu_entry($chaine); print '</a>'; print_end_menu_entry(); } else { if (empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED)) { if (!$type_user) { print_start_menu_entry($idsel); print '<div class="' . $id . ' ' . $idsel . '"><span class="' . $id . '" id="mainmenuspan_' . $idsel . '"></span></div>'; print '<a class="tmenudisabled" id="mainmenua_' . $idsel . '" href="#" title="' . dol_escape_htmltag($langs->trans("NotAllowed")) . '">'; print_text_menu_entry($chaine); print '</a>'; print_end_menu_entry(); } } } } // Commercial $menuqualified = 0; if (!empty($conf->propal->enabled)) { $menuqualified++; } if (!empty($conf->commande->enabled)) { $menuqualified++; } if (!empty($conf->fournisseur->enabled)) { $menuqualified++; } if (!empty($conf->contrat->enabled)) { $menuqualified++; } if (!empty($conf->ficheinter->enabled)) { $menuqualified++; } if ($menuqualified) { $langs->load("commercial"); $classname = ""; if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "commercial") { $classname = 'class="tmenusel"'; $_SESSION['idmenu'] = ''; } else { $classname = 'class="tmenu"'; } $idsel = 'commercial'; if ($user->rights->societe->lire || $user->rights->societe->contact->lire) { print_start_menu_entry($idsel); print '<a class="tmenuimage" href="' . DOL_URL_ROOT . '/comm/index.php?mainmenu=commercial&leftmenu="' . ($atarget ? ' target="' . $atarget . '"' : '') . '>'; print '<div class="' . $id . ' ' . $idsel . '"><span class="' . $id . ' tmenuimage" id="' . $id . '"></span></div>'; print '</a>'; print '<a ' . $classname . ' id="mainmenua_' . $idsel . '" href="' . DOL_URL_ROOT . '/comm/index.php?mainmenu=commercial&leftmenu="' . ($atarget ? ' target="' . $atarget . '"' : '') . '>'; print_text_menu_entry($langs->trans("Commercial")); print '</a>'; print_end_menu_entry(); } else { if (empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED)) { if (!$type_user) { print_start_menu_entry($idsel); print '<div class="' . $id . ' ' . $idsel . '"><span class="' . $id . '" id="mainmenuspan_' . $idsel . '"></span></div>'; print '<a class="tmenudisabled" id="mainmenua_' . $idsel . '" href="#" title="' . dol_escape_htmltag($langs->trans("NotAllowed")) . '">'; print print_text_menu_entry($langs->trans("Commercial")); print '</a>'; print_end_menu_entry(); } } } } // Financial if ($conf->comptabilite->enabled || $conf->accounting->enabled || $conf->facture->enabled || $conf->deplacement->enabled || $conf->don->enabled || $conf->tax->enabled) { $langs->load("compta"); $classname = ""; if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "accountancy") { $classname = 'class="tmenusel"'; $_SESSION['idmenu'] = ''; } else { $classname = 'class="tmenu"'; } $idsel = 'accountancy'; if ($user->rights->compta->resultat->lire || $user->rights->accounting->plancompte->lire || $user->rights->facture->lire || $user->rights->deplacement->lire || $user->rights->don->lire || $user->rights->tax->charges->lire) { print_start_menu_entry($idsel); print '<a class="tmenuimage" href="' . DOL_URL_ROOT . '/compta/index.php?mainmenu=accountancy&leftmenu="' . ($atarget ? ' target="' . $atarget . '"' : '') . '>'; print '<div class="' . $id . ' ' . $idsel . '"><span class="' . $id . ' tmenuimage" id="mainmenuspan_' . $idsel . '"></span></div>'; print '</a>'; print '<a ' . $classname . ' id="mainmenua_' . $idsel . '" href="' . DOL_URL_ROOT . '/compta/index.php?mainmenu=accountancy&leftmenu="' . ($atarget ? ' target="' . $atarget . '"' : '') . '>'; print_text_menu_entry($langs->trans("MenuFinancial")); print '</a>'; print_end_menu_entry(); } else { if (empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED)) { if (!$type_user) { print_start_menu_entry($idsel); print '<div class="' . $id . ' ' . $idsel . '"><span class="' . $id . '" id="mainmenuspan_' . $idsel . '"></span></div>'; print '<a class="tmenudisabled" id="mainmenua_' . $idsel . '" href="#" title="' . dol_escape_htmltag($langs->trans("NotAllowed")) . '">'; print_text_menu_entry($langs->trans("MenuFinancial")); print '</a>'; print_end_menu_entry(); } } } } // Bank if ($conf->banque->enabled || $conf->prelevement->enabled) { $langs->load("compta"); $langs->load("banks"); $classname = ""; if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "bank") { $classname = 'class="tmenusel"'; $_SESSION['idmenu'] = ''; } else { $classname = 'class="tmenu"'; } $idsel = 'bank'; if ($user->rights->banque->lire) { print_start_menu_entry($idsel); print '<a class="tmenuimage" href="' . DOL_URL_ROOT . '/compta/bank/index.php?mainmenu=bank&leftmenu="' . ($atarget ? ' target="' . $atarget . '"' : '') . '>'; print '<div class="' . $id . ' ' . $idsel . '"><span class="' . $id . ' tmenuimage" id="mainmenuspan_' . $idsel . '"></span></div>'; print '</a>'; print '<a ' . $classname . ' id="mainmenua_' . $idsel . '" href="' . DOL_URL_ROOT . '/compta/bank/index.php?mainmenu=bank&leftmenu="' . ($atarget ? ' target="' . $atarget . '"' : '') . '>'; print_text_menu_entry($langs->trans("MenuBankCash")); print '</a>'; print_end_menu_entry(); } else { if (empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED)) { if (!$type_user) { print_start_menu_entry($idsel); print '<div class="' . $id . ' ' . $idsel . '"><span class="' . $id . '" id="mainmenuspan_' . $idsel . '"></span></div>'; print '<a class="tmenudisabled" id="mainmenua_' . $idsel . '" href="#" title="' . dol_escape_htmltag($langs->trans("NotAllowed")) . '">'; print_text_menu_entry($langs->trans("MenuBankCash")); print '</a>'; print_end_menu_entry(); } } } } // Projects if ($conf->projet->enabled) { $langs->load("projects"); $classname = ""; if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "project") { $classname = 'class="tmenusel"'; $_SESSION['idmenu'] = ''; } else { $classname = 'class="tmenu"'; } $idsel = 'project'; if ($user->rights->projet->lire) { print_start_menu_entry($idsel); print '<a class="tmenuimage" href="' . DOL_URL_ROOT . '/projet/index.php?mainmenu=project&leftmenu="' . ($atarget ? ' target="' . $atarget . '"' : '') . '>'; print '<div class="' . $id . ' ' . $idsel . '"><span class="' . $id . ' tmenuimage" id="mainmenuspan_' . $idsel . '"></span></div>'; print '</a>'; print '<a ' . $classname . ' id="mainmenua_' . $idsel . '" href="' . DOL_URL_ROOT . '/projet/index.php?mainmenu=project&leftmenu="' . ($atarget ? ' target="' . $atarget . '"' : '') . '>'; print_text_menu_entry($langs->trans("Projects")); print '</a>'; print_end_menu_entry(); } else { if (empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED)) { if (!$type_user) { print_start_menu_entry($idsel); print '<div class="' . $id . ' ' . $idsel . '"><span class="' . $id . '" id="mainmenuspan_' . $idsel . '"></span></div>'; print '<a class="tmenudisabled" id="mainmenua_' . $idsel . '" href="#" title="' . dol_escape_htmltag($langs->trans("NotAllowed")) . '">'; print_text_menu_entry($langs->trans("Projects")); print '</a>'; print_end_menu_entry(); } } } } // Tools if ($conf->mailing->enabled || $conf->export->enabled || $conf->import->enabled) { $langs->load("other"); $classname = ""; if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "tools") { $classname = 'class="tmenusel"'; $_SESSION['idmenu'] = ''; } else { $classname = 'class="tmenu"'; } $idsel = 'tools'; if ($user->rights->mailing->lire || $user->rights->export->lire || $user->rights->import->run) { print_start_menu_entry($idsel); print '<a class="tmenuimage" href="' . DOL_URL_ROOT . '/core/tools.php?mainmenu=tools&leftmenu="' . ($atarget ? ' target="' . $atarget . '"' : '') . '>'; print '<div class="' . $id . ' ' . $idsel . '"><span class="' . $id . ' tmenuimage" id="mainmenuspan_' . $idsel . '"></span></div>'; print '</a>'; print '<a ' . $classname . ' id="mainmenua_' . $idsel . '" href="' . DOL_URL_ROOT . '/core/tools.php?mainmenu=tools&leftmenu="' . ($atarget ? ' target="' . $atarget . '"' : '') . '>'; print_text_menu_entry($langs->trans("Tools")); print '</a>'; print_end_menu_entry(); } else { if (empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED)) { if (!$type_user) { print_start_menu_entry($idsel); print '<div class="' . $id . ' ' . $idsel . '"><span class="' . $id . '" id="mainmenuspan_' . $idsel . '"></span></div>'; print '<a class="tmenudisabled" id="mainmenua_' . $idsel . '" href="#" title="' . dol_escape_htmltag($langs->trans("NotAllowed")) . '">'; print_text_menu_entry($langs->trans("Tools")); print '</a>'; print_end_menu_entry(); } } } } // OSCommerce 1 if (!empty($conf->boutique->enabled)) { $langs->load("shop"); $classname = ""; if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "shop") { $classname = 'class="tmenusel"'; $_SESSION['idmenu'] = ''; } else { $classname = 'class="tmenu"'; } $idsel = 'shop'; print_start_menu_entry($idsel); print '<a class="tmenuimage" href="' . DOL_URL_ROOT . '/boutique/index.php?mainmenu=shop&leftmenu="' . ($atarget ? ' target="' . $atarget . '"' : '') . '>'; print '<div class="' . $id . ' ' . $idsel . '"><span class="' . $id . ' tmenuimage" id="mainmenuspan_' . $idsel . '"></span></div>'; print '</a>'; print '<a ' . $classname . ' id="mainmenua_' . $idsel . '" href="' . DOL_URL_ROOT . '/boutique/index.php?mainmenu=shop&leftmenu="' . ($atarget ? ' target="' . $atarget . '"' : '') . '>'; print_text_menu_entry($langs->trans("OSCommerce")); print '</a>'; print_end_menu_entry(); } // Members if ($conf->adherent->enabled) { // $langs->load("members"); Added in main file $classname = ""; if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "members") { $classname = 'class="tmenusel"'; $_SESSION['idmenu'] = ''; } else { $classname = 'class="tmenu"'; } $idsel = 'members'; if ($user->rights->adherent->lire) { print_start_menu_entry($idsel); print '<a class="tmenuimage" href="' . DOL_URL_ROOT . '/adherents/index.php?mainmenu=members&leftmenu="' . ($atarget ? ' target="' . $atarget . '"' : '') . '>'; print '<div class="' . $id . ' ' . $idsel . '"><span class="' . $id . ' tmenuimage" id="mainmenuspan_' . $idsel . '"></span></div>'; print '</a>'; print '<a ' . $classname . ' id="mainmenua_' . $idsel . '" href="' . DOL_URL_ROOT . '/adherents/index.php?mainmenu=members&leftmenu="' . ($atarget ? ' target="' . $atarget . '"' : '') . '>'; print_text_menu_entry($langs->trans("MenuMembers")); print '</a>'; print_end_menu_entry(); } else { if (empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED)) { if (!$type_user) { print_start_menu_entry($idsel); print '<div class="' . $id . ' ' . $idsel . '"><span class="' . $id . '" id="mainmenuspan_' . $idsel . '"></span></div>'; print '<a class="tmenudisabled" id="mainmenua_' . $idsel . '" href="#" title="' . dol_escape_htmltag($langs->trans("NotAllowed")) . '">'; print_text_menu_entry($langs->trans("MenuMembers")); print '</a>'; print_end_menu_entry(); } } } } // Show personalized menus require_once DOL_DOCUMENT_ROOT . "/core/class/menubase.class.php"; $tabMenu = array(); $menuArbo = new Menubase($db, 'eldy', 'top'); $newTabMenu = $menuArbo->menuTopCharger($_SESSION['mainmenu'], '', $type_user, 'eldy', $tabMenu); for ($i = 0; $i < count($newTabMenu); $i++) { if ($newTabMenu[$i]['enabled'] == true) { //var_dump($newTabMenu[$i]); $idsel = empty($newTabMenu[$i]['mainmenu']) ? 'none' : $newTabMenu[$i]['mainmenu']; if ($newTabMenu[$i]['right'] == true) { if (preg_match("/^(http:\\/\\/|https:\\/\\/)/i", $newTabMenu[$i]['url'])) { $url = $newTabMenu[$i]['url']; } else { $url = dol_buildpath($newTabMenu[$i]['url'], 1); if (!preg_match('/mainmenu/i', $url) || !preg_match('/leftmenu/i', $url)) { if (!preg_match('/\\?/', $url)) { $url .= '?'; } else { $url .= '&'; } $url .= 'mainmenu=' . $newTabMenu[$i]['mainmenu'] . '&leftmenu='; } //$url.="idmenu=".$newTabMenu[$i]['rowid']; // Already done by menuLoad } $url = preg_replace('/__LOGIN__/', $user->login, $url); // Define the class (top menu selected or not) if (!empty($_SESSION['idmenu']) && $newTabMenu[$i]['rowid'] == $_SESSION['idmenu']) { $classname = 'class="tmenusel"'; } else { if (!empty($_SESSION['mainmenu']) && $newTabMenu[$i]['mainmenu'] == $_SESSION['mainmenu']) { $classname = 'class="tmenusel"'; } else { $classname = 'class="tmenu"'; } } print_start_menu_entry($idsel); print '<a class="tmenuimage" href="' . $url . '"' . ($newTabMenu[$i]['atarget'] ? " target='" . $newTabMenu[$i]['atarget'] . "'" : ($atarget ? ' target="' . $atarget . '"' : '')) . '>'; print '<div class="' . $id . ' ' . $idsel . '"><span class="' . $id . ' tmenuimage" id="mainmenuspan_' . $idsel . '"></span></div>'; print '</a>'; print '<a ' . $classname . ' id="mainmenua_' . $idsel . '" href="' . $url . '"' . ($newTabMenu[$i]['atarget'] ? " target='" . $newTabMenu[$i]['atarget'] . "'" : ($atarget ? ' target="' . $atarget . '"' : '')) . '>'; print_text_menu_entry($newTabMenu[$i]['titre']); print '</a>'; print_end_menu_entry(); } else { if (empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED)) { if (!$type_user) { print_start_menu_entry($idsel); print '<div class="' . $id . ' ' . $idsel . '"><span class="' . $id . ' tmenuimage" id="mainmenuspan_' . $idsel . '"></span></div>'; print '<a class="tmenudisabled" id="mainmenua_' . $idsel . '" href="#" title="' . dol_escape_htmltag($langs->trans("NotAllowed")) . '">'; print_text_menu_entry($newTabMenu[$i]['titre']); print '</a>'; print_end_menu_entry(); } } } } } print_end_menu_array(); }
/** * Core function to output top menu eldy * * @param DoliDB $db Database handler * @param string $atarget Target (Example: '' or '_top') * @param int $type_user 0=Menu for backoffice, 1=Menu for front office * @param array $tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty) * @param array $menu Object Menu to return back list of menu entries * @param int $noout Disable output (Initialise &$menu only). * @return int 0 */ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 0) { global $user, $conf, $langs, $dolibarr_main_db_name; $mainmenu = empty($_SESSION["mainmenu"]) ? '' : $_SESSION["mainmenu"]; $leftmenu = empty($_SESSION["leftmenu"]) ? '' : $_SESSION["leftmenu"]; $id = 'mainmenu'; $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); if (empty($noout)) { print_start_menu_array(); } // Home $showmode = 1; $classname = ""; if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "home") { $classname = 'class="tmenusel"'; $_SESSION['idmenu'] = ''; } 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=', $langs->trans("Home"), 0, $showmode, $atarget, "home", ''); // 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'); $showmode = dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) { $langs->load("companies"); $langs->load("suppliers"); $classname = ""; if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "companies") { $classname = 'class="tmenusel"'; $_SESSION['idmenu'] = ''; } 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", ''); } // Products-Services $tmpentry = array('enabled' => !empty($conf->product->enabled) || !empty($conf->service->enabled), 'perms' => !empty($user->rights->produit->lire) || !empty($user->rights->service->lire), 'module' => 'product|service'); $showmode = dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) { $langs->load("products"); $classname = ""; if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "products") { $classname = 'class="tmenusel"'; $_SESSION['idmenu'] = ''; } else { $classname = 'class="tmenu"'; } $idsel = 'products'; $chaine = ""; if (!empty($conf->product->enabled)) { $chaine .= $langs->trans("Products"); } if (!empty($conf->product->enabled) && !empty($conf->service->enabled)) { $chaine .= "/"; } if (!empty($conf->service->enabled)) { $chaine .= $langs->trans("Services"); } 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", ''); } // Commercial $menuqualified = 0; if (!empty($conf->propal->enabled)) { $menuqualified++; } if (!empty($conf->commande->enabled)) { $menuqualified++; } if (!empty($conf->fournisseur->enabled)) { $menuqualified++; } if (!empty($conf->contrat->enabled)) { $menuqualified++; } if (!empty($conf->ficheinter->enabled)) { $menuqualified++; } $tmpentry = array('enabled' => $menuqualified, 'perms' => !empty($user->rights->societe->lire) || !empty($user->rights->societe->contact->lire), 'module' => 'propal|commande|fournisseur|contrat|ficheinter'); $showmode = dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) { $langs->load("commercial"); $classname = ""; if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "commercial") { $classname = 'class="tmenusel"'; $_SESSION['idmenu'] = ''; } 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", ""); } // Financial $tmpentry = array('enabled' => !empty($conf->comptabilite->enabled) || !empty($conf->accounting->enabled) || !empty($conf->facture->enabled) || !empty($conf->don->enabled) || !empty($conf->tax->enabled) || !empty($conf->salaries->enabled) || !empty($conf->fournisseur->enabled) || !empty($conf->loan->enabled), 'perms' => !empty($user->rights->compta->resultat->lire) || !empty($user->rights->accounting->plancompte->lire) || !empty($user->rights->facture->lire) || !empty($user->rights->don->lire) || !empty($user->rights->tax->charges->lire) || !empty($user->rights->salaries->read) || !empty($user->rights->fournisseur->facture->lire) || !empty($user->rights->loan->read), 'module' => 'comptabilite|accounting|facture|don|tax|salaries|loan'); $showmode = dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) { $langs->load("compta"); $classname = ""; if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "accountancy") { $classname = 'class="tmenusel"'; $_SESSION['idmenu'] = ''; } 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", ''); } // Bank $tmpentry = array('enabled' => !empty($conf->banque->enabled) || !empty($conf->prelevement->enabled), 'perms' => !empty($user->rights->banque->lire) || !empty($user->rights->prelevement->lire), 'module' => 'banque|prelevement'); $showmode = dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) { $langs->load("compta"); $langs->load("banks"); $classname = ""; if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "bank") { $classname = 'class="tmenusel"'; $_SESSION['idmenu'] = ''; } 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", ''); } // Projects $tmpentry = array('enabled' => !empty($conf->projet->enabled), 'perms' => !empty($user->rights->projet->lire), 'module' => 'projet'); $showmode = dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) { $langs->load("projects"); $classname = ""; if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "project") { $classname = 'class="tmenusel"'; $_SESSION['idmenu'] = ''; } 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", ''); } // HRM $tmpentry = array('enabled' => !empty($conf->holiday->enabled) || !empty($conf->deplacement->enabled) || !empty($conf->expensereport->enabled), 'perms' => !empty($user->rights->holiday->write) || !empty($user->rights->deplacement->lire) || !empty($user->rights->expensereport->lire), 'module' => 'holiday|deplacement|expensereport'); $showmode = dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) { $langs->load("holiday"); $classname = ""; if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "hrm") { $classname = 'class="tmenusel"'; $_SESSION['idmenu'] = ''; } 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 . '/compta/hrm.php?mainmenu=hrm&leftmenu=', $id, $idsel, $classname, $atarget); } if (empty($noout)) { print_end_menu_entry($showmode); } $menu->add('/compta/hrm.php?mainmenu=hrm&leftmenu=', $langs->trans("HRM"), 0, $showmode, $atarget, "hrm", ''); } // Tools $tmpentry = array('enabled' => !empty($conf->barcode->enabled) || !empty($conf->mailing->enabled) || !empty($conf->export->enabled) || !empty($conf->import->enabled) || !empty($conf->opensurvey->enabled) || !empty($conf->resource->enabled), 'perms' => !empty($conf->barcode->enabled) || !empty($user->rights->mailing->lire) || !empty($user->rights->export->lire) || !empty($user->rights->import->run) || !empty($user->rights->opensurvey->read) || !empty($user->rights->resource->read), 'module' => 'mailing|export|import|opensurvey|resource'); $showmode = dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) { $langs->load("other"); $classname = ""; if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "tools") { $classname = 'class="tmenusel"'; $_SESSION['idmenu'] = ''; } 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("Tools"), $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", ''); } // Members $tmpentry = array('enabled' => !empty($conf->adherent->enabled), 'perms' => !empty($user->rights->adherent->lire), 'module' => 'adherent'); $showmode = dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) { $classname = ""; if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "members") { $classname = 'class="tmenusel"'; $_SESSION['idmenu'] = ''; } 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", ''); } // Show personalized menus $menuArbo = new Menubase($db, 'eldy'); $newTabMenu = $menuArbo->menuTopCharger('', '', $type_user, 'eldy', $tabMenu); // Return tabMenu with only top entries $num = count($newTabMenu); for ($i = 0; $i < $num; $i++) { $idsel = empty($newTabMenu[$i]['mainmenu']) ? 'none' : $newTabMenu[$i]['mainmenu']; $showmode = dol_eldy_showmenu($type_user, $newTabMenu[$i], $listofmodulesforexternal); if ($showmode == 1) { $url = $shorturl = $newTabMenu[$i]['url']; if (!preg_match("/^(http:\\/\\/|https:\\/\\/)/i", $newTabMenu[$i]['url'])) { $tmp = explode('?', $newTabMenu[$i]['url'], 2); $url = $shorturl = $tmp[0]; $param = isset($tmp[1]) ? $tmp[1] : ''; 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 : ''); } $url = preg_replace('/__LOGIN__/', $user->login, $url); $shorturl = preg_replace('/__LOGIN__/', $user->login, $shorturl); $url = preg_replace('/__USERID__/', $user->id, $url); $shorturl = preg_replace('/__USERID__/', $user->id, $shorturl); // Define the class (top menu selected or not) if (!empty($_SESSION['idmenu']) && $newTabMenu[$i]['rowid'] == $_SESSION['idmenu']) { $classname = 'class="tmenusel"'; } else { if (!empty($_SESSION["mainmenu"]) && $newTabMenu[$i]['mainmenu'] == $_SESSION["mainmenu"]) { $classname = 'class="tmenusel"'; } else { $classname = 'class="tmenu"'; } } } 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'], ''); } $showmode = 1; if (empty($noout)) { print_start_menu_entry('', 'class="tmenuend"', $showmode); } if (empty($noout)) { print_end_menu_entry($showmode); } if (empty($noout)) { print_end_menu_array(); } return 0; }