PageRenderTime 58ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 1ms

/htdocs/core/menus/standard/eldy.lib.php

https://github.com/asterix14/dolibarr
PHP | 1421 lines | 1071 code | 176 blank | 174 comment | 394 complexity | 2bf6f6b1fc39bd8e006f9bae05ddc333 MD5 | raw file
Possible License(s): LGPL-2.0
  1. <?php
  2. /* Copyright (C) 2010-2011 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. * or see http://www.gnu.org/
  18. */
  19. /**
  20. * \file htdocs/core/menus/standard/eldy.lib.php
  21. * \brief Library for file eldy menus
  22. */
  23. /**
  24. * Core function to output top menu eldy
  25. *
  26. * @param $db
  27. * @param $atarget
  28. * @param $type_user 0=Internal,1=External,2=All
  29. */
  30. function print_eldy_menu($db,$atarget,$type_user)
  31. {
  32. global $user,$conf,$langs,$dolibarr_main_db_name;
  33. // On sauve en session le menu principal choisi
  34. if (isset($_GET["mainmenu"])) $_SESSION["mainmenu"]=$_GET["mainmenu"];
  35. if (isset($_GET["idmenu"])) $_SESSION["idmenu"]=$_GET["idmenu"];
  36. $_SESSION["leftmenuopened"]="";
  37. $id='mainmenu';
  38. print_start_menu_array();
  39. // Home
  40. $classname="";
  41. if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "home")
  42. {
  43. $classname='class="tmenusel"'; $_SESSION['idmenu']='';
  44. }
  45. else
  46. {
  47. $classname = 'class="tmenu"';
  48. }
  49. $idsel='home';
  50. print_start_menu_entry($idsel);
  51. print '<a class="tmenuimage" href="'.DOL_URL_ROOT.'/index.php?mainmenu=home&amp;leftmenu="'.($atarget?" target=$atarget":"").'>';
  52. print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
  53. print '</a>';
  54. print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.DOL_URL_ROOT.'/index.php?mainmenu=home&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
  55. print_text_menu_entry($langs->trans("Home"));
  56. print '</a>';
  57. print_end_menu_entry();
  58. // Third parties
  59. if ($conf->societe->enabled || $conf->fournisseur->enabled)
  60. {
  61. $langs->load("companies");
  62. $langs->load("suppliers");
  63. $classname="";
  64. if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "companies")
  65. {
  66. $classname='class="tmenusel"'; $_SESSION['idmenu']='';
  67. }
  68. else
  69. {
  70. $classname = 'class="tmenu"';
  71. }
  72. $idsel='companies';
  73. if (($conf->societe->enabled && $user->rights->societe->lire)
  74. || ($conf->fournisseur->enabled && $user->rights->fournisseur->lire))
  75. {
  76. print_start_menu_entry($idsel);
  77. print '<a class="tmenuimage" href="'.DOL_URL_ROOT.'/societe/index.php?mainmenu=companies&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
  78. print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
  79. print '</a>';
  80. print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.DOL_URL_ROOT.'/societe/index.php?mainmenu=companies&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
  81. print_text_menu_entry($langs->trans("ThirdParties"));
  82. print '</a>';
  83. print_end_menu_entry();
  84. }
  85. else if (empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED))
  86. {
  87. if (! $type_user)
  88. {
  89. print_start_menu_entry($idsel);
  90. print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.'" id="mainmenuspan_'.$idsel.'"></span></div>';
  91. print '<a class="tmenudisabled" id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">';
  92. print_text_menu_entry($langs->trans("ThirdParties"));
  93. print '</a>';
  94. print_end_menu_entry();
  95. }
  96. }
  97. }
  98. // Products-Services
  99. if ($conf->product->enabled || $conf->service->enabled)
  100. {
  101. $langs->load("products");
  102. $classname="";
  103. if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "products")
  104. {
  105. $classname='class="tmenusel"'; $_SESSION['idmenu']='';
  106. }
  107. else
  108. {
  109. $classname = 'class="tmenu"';
  110. }
  111. $chaine="";
  112. if ($conf->product->enabled) { $chaine.=$langs->trans("Products"); }
  113. if ($conf->product->enabled && $conf->service->enabled) { $chaine.="/"; }
  114. if ($conf->service->enabled) { $chaine.=$langs->trans("Services"); }
  115. $idsel='products';
  116. if ($user->rights->produit->lire || $user->rights->service->lire)
  117. {
  118. print_start_menu_entry($idsel);
  119. print '<a class="tmenuimage" href="'.DOL_URL_ROOT.'/product/index.php?mainmenu=products&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
  120. print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
  121. print '</a>';
  122. print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.DOL_URL_ROOT.'/product/index.php?mainmenu=products&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
  123. print_text_menu_entry($chaine);
  124. print '</a>';
  125. print_end_menu_entry();
  126. }
  127. else if (empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED))
  128. {
  129. if (! $type_user)
  130. {
  131. print_start_menu_entry($idsel);
  132. print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.'" id="mainmenuspan_'.$idsel.'"></span></div>';
  133. print '<a class="tmenudisabled" id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">';
  134. print_text_menu_entry($chaine);
  135. print '</a>';
  136. print_end_menu_entry();
  137. }
  138. }
  139. }
  140. // Commercial
  141. $menuqualified=0;
  142. if (! empty($conf->propal->enabled)) $menuqualified++;
  143. if (! empty($conf->commande->enabled)) $menuqualified++;
  144. if (! empty($conf->fournisseur->enabled)) $menuqualified++;
  145. if (! empty($conf->contrat->enabled)) $menuqualified++;
  146. if (! empty($conf->ficheinter->enabled)) $menuqualified++;
  147. if ($menuqualified)
  148. {
  149. $langs->load("commercial");
  150. $classname="";
  151. if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "commercial")
  152. {
  153. $classname='class="tmenusel"'; $_SESSION['idmenu']='';
  154. }
  155. else
  156. {
  157. $classname = 'class="tmenu"';
  158. }
  159. $idsel='commercial';
  160. if($user->rights->societe->lire || $user->rights->societe->contact->lire)
  161. {
  162. print_start_menu_entry($idsel);
  163. print '<a class="tmenuimage" href="'.DOL_URL_ROOT.'/comm/index.php?mainmenu=commercial&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
  164. print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.' tmenuimage" id="'.$id.'"></span></div>';
  165. print '</a>';
  166. print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.DOL_URL_ROOT.'/comm/index.php?mainmenu=commercial&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
  167. print_text_menu_entry($langs->trans("Commercial"));
  168. print '</a>';
  169. print_end_menu_entry();
  170. }
  171. else if (empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED))
  172. {
  173. if (! $type_user)
  174. {
  175. print_start_menu_entry($idsel);
  176. print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.'" id="mainmenuspan_'.$idsel.'"></span></div>';
  177. print '<a class="tmenudisabled" id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">';
  178. print print_text_menu_entry($langs->trans("Commercial"));
  179. print '</a>';
  180. print_end_menu_entry();
  181. }
  182. }
  183. }
  184. // Financial
  185. if ($conf->comptabilite->enabled || $conf->accounting->enabled
  186. || $conf->facture->enabled || $conf->deplacement->enabled || $conf->don->enabled || $conf->tax->enabled)
  187. {
  188. $langs->load("compta");
  189. $classname="";
  190. if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "accountancy")
  191. {
  192. $classname='class="tmenusel"'; $_SESSION['idmenu']='';
  193. }
  194. else
  195. {
  196. $classname = 'class="tmenu"';
  197. }
  198. $idsel='accountancy';
  199. if ($user->rights->compta->resultat->lire || $user->rights->accounting->plancompte->lire
  200. || $user->rights->facture->lire || $user->rights->deplacement->lire || $user->rights->don->lire || $user->rights->tax->charges->lire)
  201. {
  202. print_start_menu_entry($idsel);
  203. print '<a class="tmenuimage" href="'.DOL_URL_ROOT.'/compta/index.php?mainmenu=accountancy&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
  204. print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
  205. print '</a>';
  206. print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.DOL_URL_ROOT.'/compta/index.php?mainmenu=accountancy&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
  207. print_text_menu_entry($langs->trans("MenuFinancial"));
  208. print '</a>';
  209. print_end_menu_entry();
  210. }
  211. else if (empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED))
  212. {
  213. if (! $type_user)
  214. {
  215. print_start_menu_entry($idsel);
  216. print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.'" id="mainmenuspan_'.$idsel.'"></span></div>';
  217. print '<a class="tmenudisabled" id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">';
  218. print_text_menu_entry($langs->trans("MenuFinancial"));
  219. print '</a>';
  220. print_end_menu_entry();
  221. }
  222. }
  223. }
  224. // Bank
  225. if ($conf->banque->enabled || $conf->prelevement->enabled)
  226. {
  227. $langs->load("compta");
  228. $langs->load("banks");
  229. $classname="";
  230. if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "bank")
  231. {
  232. $classname='class="tmenusel"'; $_SESSION['idmenu']='';
  233. }
  234. else
  235. {
  236. $classname = 'class="tmenu"';
  237. }
  238. $idsel='bank';
  239. if ($user->rights->banque->lire)
  240. {
  241. print_start_menu_entry($idsel);
  242. print '<a class="tmenuimage" href="'.DOL_URL_ROOT.'/compta/bank/index.php?mainmenu=bank&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
  243. print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
  244. print '</a>';
  245. print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.DOL_URL_ROOT.'/compta/bank/index.php?mainmenu=bank&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
  246. print_text_menu_entry($langs->trans("MenuBankCash"));
  247. print '</a>';
  248. print_end_menu_entry();
  249. }
  250. else if (empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED))
  251. {
  252. if (! $type_user)
  253. {
  254. print_start_menu_entry($idsel);
  255. print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.'" id="mainmenuspan_'.$idsel.'"></span></div>';
  256. print '<a class="tmenudisabled" id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">';
  257. print_text_menu_entry($langs->trans("MenuBankCash"));
  258. print '</a>';
  259. print_end_menu_entry();
  260. }
  261. }
  262. }
  263. // Projects
  264. if ($conf->projet->enabled)
  265. {
  266. $langs->load("projects");
  267. $classname="";
  268. if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "project")
  269. {
  270. $classname='class="tmenusel"'; $_SESSION['idmenu']='';
  271. }
  272. else
  273. {
  274. $classname = 'class="tmenu"';
  275. }
  276. $idsel='project';
  277. if ($user->rights->projet->lire)
  278. {
  279. print_start_menu_entry($idsel);
  280. print '<a class="tmenuimage" href="'.DOL_URL_ROOT.'/projet/index.php?mainmenu=project&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
  281. print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
  282. print '</a>';
  283. print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.DOL_URL_ROOT.'/projet/index.php?mainmenu=project&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
  284. print_text_menu_entry($langs->trans("Projects"));
  285. print '</a>';
  286. print_end_menu_entry();
  287. }
  288. else if (empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED))
  289. {
  290. if (! $type_user)
  291. {
  292. print_start_menu_entry($idsel);
  293. print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.'" id="mainmenuspan_'.$idsel.'"></span></div>';
  294. print '<a class="tmenudisabled" id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">';
  295. print_text_menu_entry($langs->trans("Projects"));
  296. print '</a>';
  297. print_end_menu_entry();
  298. }
  299. }
  300. }
  301. // Tools
  302. if ($conf->mailing->enabled || $conf->export->enabled || $conf->import->enabled)
  303. {
  304. $langs->load("other");
  305. $classname="";
  306. if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "tools")
  307. {
  308. $classname='class="tmenusel"'; $_SESSION['idmenu']='';
  309. }
  310. else
  311. {
  312. $classname = 'class="tmenu"';
  313. }
  314. $idsel='tools';
  315. if ($user->rights->mailing->lire || $user->rights->export->lire || $user->rights->import->run)
  316. {
  317. print_start_menu_entry($idsel);
  318. print '<a class="tmenuimage" href="'.DOL_URL_ROOT.'/core/tools.php?mainmenu=tools&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
  319. print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
  320. print '</a>';
  321. print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.DOL_URL_ROOT.'/core/tools.php?mainmenu=tools&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
  322. print_text_menu_entry($langs->trans("Tools"));
  323. print '</a>';
  324. print_end_menu_entry();
  325. }
  326. else if (empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED))
  327. {
  328. if (! $type_user)
  329. {
  330. print_start_menu_entry($idsel);
  331. print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.'" id="mainmenuspan_'.$idsel.'"></span></div>';
  332. print '<a class="tmenudisabled" id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">';
  333. print_text_menu_entry($langs->trans("Tools"));
  334. print '</a>';
  335. print_end_menu_entry();
  336. }
  337. }
  338. }
  339. // OSCommerce 1
  340. if (! empty($conf->boutique->enabled))
  341. {
  342. $langs->load("shop");
  343. $classname="";
  344. if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "shop")
  345. {
  346. $classname='class="tmenusel"'; $_SESSION['idmenu']='';
  347. }
  348. else
  349. {
  350. $classname = 'class="tmenu"';
  351. }
  352. $idsel='shop';
  353. print_start_menu_entry($idsel);
  354. print '<a class="tmenuimage" href="'.DOL_URL_ROOT.'/boutique/index.php?mainmenu=shop&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
  355. print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
  356. print '</a>';
  357. print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.DOL_URL_ROOT.'/boutique/index.php?mainmenu=shop&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
  358. print_text_menu_entry($langs->trans("OSCommerce"));
  359. print '</a>';
  360. print_end_menu_entry();
  361. }
  362. // Members
  363. if ($conf->adherent->enabled)
  364. {
  365. // $langs->load("members"); Added in main file
  366. $classname="";
  367. if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "members")
  368. {
  369. $classname='class="tmenusel"'; $_SESSION['idmenu']='';
  370. }
  371. else
  372. {
  373. $classname = 'class="tmenu"';
  374. }
  375. $idsel='members';
  376. if ($user->rights->adherent->lire)
  377. {
  378. print_start_menu_entry($idsel);
  379. print '<a class="tmenuimage" href="'.DOL_URL_ROOT.'/adherents/index.php?mainmenu=members&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
  380. print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
  381. print '</a>';
  382. print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.DOL_URL_ROOT.'/adherents/index.php?mainmenu=members&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
  383. print_text_menu_entry($langs->trans("MenuMembers"));
  384. print '</a>';
  385. print_end_menu_entry();
  386. }
  387. else if (empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED))
  388. {
  389. if (! $type_user)
  390. {
  391. print_start_menu_entry($idsel);
  392. print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.'" id="mainmenuspan_'.$idsel.'"></span></div>';
  393. print '<a class="tmenudisabled" id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">';
  394. print_text_menu_entry($langs->trans("MenuMembers"));
  395. print '</a>';
  396. print_end_menu_entry();
  397. }
  398. }
  399. }
  400. // Show personalized menus
  401. require_once(DOL_DOCUMENT_ROOT."/core/class/menubase.class.php");
  402. $menuArbo = new Menubase($db,'eldy','top');
  403. $newTabMenu = $menuArbo->menuTopCharger($_SESSION['mainmenu'],'',$type_user,'eldy');
  404. $num = count($newTabMenu);
  405. for($i = 0; $i < $num; $i++)
  406. {
  407. if ($newTabMenu[$i]['enabled'] == true)
  408. {
  409. //var_dump($newTabMenu[$i]);
  410. $idsel=(empty($newTabMenu[$i]['mainmenu'])?'none':$newTabMenu[$i]['mainmenu']);
  411. if ($newTabMenu[$i]['right'] == true) // Is allowed
  412. {
  413. if (preg_match("/^(http:\/\/|https:\/\/)/i",$newTabMenu[$i]['url']))
  414. {
  415. $url = $newTabMenu[$i]['url'];
  416. }
  417. else
  418. {
  419. $url=dol_buildpath($newTabMenu[$i]['url'],1);
  420. if (! preg_match('/mainmenu/i',$url) || ! preg_match('/leftmenu/i',$url))
  421. {
  422. if (! preg_match('/\?/',$url)) $url.='?';
  423. else $url.='&';
  424. $url.='mainmenu='.$newTabMenu[$i]['mainmenu'].'&leftmenu=';
  425. }
  426. //$url.="idmenu=".$newTabMenu[$i]['rowid']; // Already done by menuLoad
  427. }
  428. $url=preg_replace('/__LOGIN__/',$user->login,$url);
  429. // Define the class (top menu selected or not)
  430. if (! empty($_SESSION['idmenu']) && $newTabMenu[$i]['rowid'] == $_SESSION['idmenu']) $classname='class="tmenusel"';
  431. else if (! empty($_SESSION['mainmenu']) && $newTabMenu[$i]['mainmenu'] == $_SESSION['mainmenu']) $classname='class="tmenusel"';
  432. else $classname='class="tmenu"';
  433. print_start_menu_entry($idsel);
  434. print '<a class="tmenuimage" href="'.$url.'"'.($newTabMenu[$i]['atarget']?" target='".$newTabMenu[$i]['atarget']."'":($atarget?' target="'.$atarget.'"':'')).'>';
  435. print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
  436. print '</a>';
  437. print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.$url.'"'.($newTabMenu[$i]['atarget']?" target='".$newTabMenu[$i]['atarget']."'":($atarget?' target="'.$atarget.'"':'')).'>';
  438. print_text_menu_entry($newTabMenu[$i]['titre']);
  439. print '</a>';
  440. print_end_menu_entry();
  441. }
  442. else if (empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED))
  443. {
  444. if (! $type_user)
  445. {
  446. print_start_menu_entry($idsel);
  447. print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
  448. print '<a class="tmenudisabled" id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">';
  449. print_text_menu_entry($newTabMenu[$i]['titre']);
  450. print '</a>';
  451. print_end_menu_entry();
  452. }
  453. }
  454. }
  455. }
  456. print_end_menu_array();
  457. }
  458. function print_start_menu_array()
  459. {
  460. global $conf;
  461. if (preg_match('/bluelagoon|eldy|freelug|rodolphe|yellow|dev/',$conf->css)) print '<table class="tmenu" summary="topmenu"><tr class="tmenu">';
  462. else print '<ul class="tmenu">';
  463. }
  464. function print_start_menu_entry($idsel)
  465. {
  466. global $conf;
  467. if (preg_match('/bluelagoon|eldy|freelug|rodolphe|yellow|dev/',$conf->css)) print '<td class="tmenu" id="mainmenutd_'.$idsel.'">';
  468. else print '<li class="tmenu" id="mainmenutd_'.$idsel.'">';
  469. }
  470. function print_text_menu_entry($text)
  471. {
  472. global $conf;
  473. print '<span class="mainmenuaspan">';
  474. print $text;
  475. print '</span>';
  476. }
  477. function print_end_menu_entry()
  478. {
  479. global $conf;
  480. if (preg_match('/bluelagoon|eldy|freelug|rodolphe|yellow|dev/',$conf->css)) print '</td>';
  481. else print '</li>';
  482. print "\n";
  483. }
  484. function print_end_menu_array()
  485. {
  486. global $conf;
  487. if (preg_match('/bluelagoon|eldy|freelug|rodolphe|yellow|dev/',$conf->css)) print '</tr></table>';
  488. else print '</ul>';
  489. print "\n";
  490. }
  491. /**
  492. * Core function to output left menu eldy
  493. *
  494. * @param db Database handler
  495. * @param menu_array_before Table of menu entries to show before entries of menu handler
  496. * @param menu_array_after Table of menu entries to show after entries of menu handler
  497. */
  498. function print_left_eldy_menu($db,$menu_array_before,$menu_array_after)
  499. {
  500. global $user,$conf,$langs,$dolibarr_main_db_name,$mysoc;
  501. // Read mainmenu and leftmenu that define which menu to show
  502. if (isset($_GET["mainmenu"]))
  503. {
  504. // On sauve en session le menu principal choisi
  505. $mainmenu=$_GET["mainmenu"];
  506. $_SESSION["mainmenu"]=$mainmenu;
  507. $_SESSION["leftmenuopened"]="";
  508. }
  509. else
  510. {
  511. // On va le chercher en session si non defini par le lien
  512. $mainmenu=isset($_SESSION["mainmenu"])?$_SESSION["mainmenu"]:'';
  513. }
  514. if (isset($_GET["leftmenu"]))
  515. {
  516. // On sauve en session le menu principal choisi
  517. $leftmenu=$_GET["leftmenu"];
  518. $_SESSION["leftmenu"]=$leftmenu;
  519. if ($_SESSION["leftmenuopened"]==$leftmenu)
  520. {
  521. //$leftmenu="";
  522. $_SESSION["leftmenuopened"]="";
  523. }
  524. else
  525. {
  526. $_SESSION["leftmenuopened"]=$leftmenu;
  527. }
  528. } else {
  529. // On va le chercher en session si non defini par le lien
  530. $leftmenu=isset($_SESSION["leftmenu"])?$_SESSION["leftmenu"]:'';
  531. }
  532. $newmenu = new Menu();
  533. // Show logo company
  534. if (! empty($conf->global->MAIN_SHOW_LOGO))
  535. {
  536. $mysoc->logo_mini=$conf->global->MAIN_INFO_SOCIETE_LOGO_MINI;
  537. if (! empty($mysoc->logo_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini))
  538. {
  539. $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=companylogo&amp;file='.urlencode('thumbs/'.$mysoc->logo_mini);
  540. print "\n".'<!-- Show logo on menu -->'."\n";
  541. print '<div class="blockvmenuimpair">'."\n";
  542. print '<div class="menu_titre" id="menu_titre_logo"></div>';
  543. print '<div class="menu_top" id="menu_top_logo"></div>';
  544. print '<div class="menu_contenu" id="menu_contenu_logo">';
  545. print '<center><img title="'.$title.'" src="'.$urllogo.'"></center>'."\n";
  546. print '</div>';
  547. print '<div class="menu_end" id="menu_end_logo"></div>';
  548. print '</div>'."\n";
  549. }
  550. }
  551. /**
  552. * On definit newmenu en fonction de mainmenu et leftmenu
  553. * ------------------------------------------------------
  554. */
  555. if ($mainmenu)
  556. {
  557. /*
  558. * Menu HOME
  559. */
  560. if ($mainmenu == 'home')
  561. {
  562. $langs->load("users");
  563. if ($user->admin)
  564. {
  565. $langs->load("admin");
  566. $langs->load("help");
  567. $newmenu->add("/admin/index.php?leftmenu=setup", $langs->trans("Setup"));
  568. if ($leftmenu=="setup") $newmenu->add("/admin/company.php", $langs->trans("MenuCompanySetup"),1);
  569. if ($leftmenu=="setup") $newmenu->add("/admin/modules.php", $langs->trans("Modules"),1);
  570. if ($leftmenu=="setup") $newmenu->add("/admin/menus.php", $langs->trans("Menus"),1);
  571. if ($leftmenu=="setup") $newmenu->add("/admin/ihm.php", $langs->trans("GUISetup"),1);
  572. if ($leftmenu=="setup") $newmenu->add("/admin/boxes.php", $langs->trans("Boxes"),1);
  573. if ($leftmenu=="setup") $newmenu->add("/admin/delais.php",$langs->trans("Alerts"),1);
  574. if ($leftmenu=="setup") $newmenu->add("/admin/proxy.php", $langs->trans("Security"),1);
  575. if ($leftmenu=="setup") $newmenu->add("/admin/limits.php", $langs->trans("MenuLimits"),1);
  576. if ($leftmenu=="setup") $newmenu->add("/admin/pdf.php", $langs->trans("PDF"),1);
  577. if ($leftmenu=="setup") $newmenu->add("/admin/mails.php", $langs->trans("Emails"),1);
  578. if ($leftmenu=="setup") $newmenu->add("/admin/sms.php", $langs->trans("Sms"),1);
  579. if ($leftmenu=="setup") $newmenu->add("/admin/dict.php", $langs->trans("DictionnarySetup"),1);
  580. if ($leftmenu=="setup") $newmenu->add("/admin/const.php", $langs->trans("OtherSetup"),1);
  581. $newmenu->add("/admin/system/index.php?leftmenu=system", $langs->trans("SystemInfo"));
  582. if ($leftmenu=="system") $newmenu->add("/admin/system/dolibarr.php", $langs->trans("Dolibarr"),1);
  583. if ($leftmenu=="system") $newmenu->add("/admin/system/constall.php", $langs->trans("AllParameters"),2);
  584. if ($leftmenu=="system") $newmenu->add("/admin/system/modules.php", $langs->trans("Modules"),2);
  585. if ($leftmenu=="system") $newmenu->add("/admin/triggers.php", $langs->trans("Triggers"),2);
  586. if ($leftmenu=="system") $newmenu->add("/admin/system/about.php", $langs->trans("About"),2);
  587. if ($leftmenu=="system") $newmenu->add("/admin/system/os.php", $langs->trans("OS"),1);
  588. if ($leftmenu=="system") $newmenu->add("/admin/system/web.php", $langs->trans("WebServer"),1);
  589. if ($leftmenu=="system") $newmenu->add("/admin/system/phpinfo.php", $langs->trans("Php"),1);
  590. //if ($leftmenu=="system" && function_exists('xdebug_is_enabled')) $newmenu->add("/admin/system/xdebug.php", $langs->trans("XDebug"),1);
  591. if ($leftmenu=="system") $newmenu->add("/admin/system/database.php", $langs->trans("Database"),1);
  592. if ($leftmenu=="system") $newmenu->add("/admin/system/database-tables.php", $langs->trans("Tables"),2);
  593. if ($leftmenu=="system") $newmenu->add("/admin/system/database-tables-contraintes.php", $langs->trans("Constraints"),2);
  594. $newmenu->add("/admin/tools/index.php?leftmenu=admintools", $langs->trans("SystemTools"));
  595. if ($leftmenu=="admintools") $newmenu->add("/admin/tools/dolibarr_export.php", $langs->trans("Backup"),1);
  596. if ($leftmenu=="admintools") $newmenu->add("/admin/tools/dolibarr_import.php", $langs->trans("Restore"),1);
  597. if ($leftmenu=="admintools") $newmenu->add("/admin/tools/update.php", $langs->trans("MenuUpgrade"),1);
  598. if ($leftmenu=="admintools" && function_exists('eaccelerator_info')) $newmenu->add("/admin/tools/eaccelerator.php", $langs->trans("EAccelerator"),1);
  599. if ($leftmenu=="admintools") $newmenu->add("/admin/tools/listevents.php", $langs->trans("Audit"),1);
  600. if ($leftmenu=="admintools") $newmenu->add("/admin/tools/listsessions.php", $langs->trans("Sessions"),1);
  601. if ($leftmenu=="admintools") $newmenu->add("/admin/tools/purge.php", $langs->trans("Purge"),1);
  602. if ($leftmenu=="admintools") $newmenu->add("/support/index.php", $langs->trans("HelpCenter"),1,1,'targethelp');
  603. }
  604. $newmenu->add("/user/home.php?leftmenu=users", $langs->trans("MenuUsersAndGroups"));
  605. if ($leftmenu=="users") $newmenu->add("/user/index.php", $langs->trans("Users"), 1, $user->rights->user->user->lire || $user->admin);
  606. if ($leftmenu=="users") $newmenu->add("/user/fiche.php?action=create", $langs->trans("NewUser"),2, $user->rights->user->user->creer || $user->admin);
  607. if ($leftmenu=="users") $newmenu->add("/user/group/index.php", $langs->trans("Groups"), 1, ($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->read:$user->rights->user->user->lire) || $user->admin);
  608. if ($leftmenu=="users") $newmenu->add("/user/group/fiche.php?action=create", $langs->trans("NewGroup"), 2, ($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->write:$user->rights->user->user->creer) || $user->admin);
  609. }
  610. /*
  611. * Menu TIERS
  612. */
  613. if ($mainmenu == 'companies')
  614. {
  615. // Societes
  616. if ($conf->societe->enabled)
  617. {
  618. $langs->load("companies");
  619. $newmenu->add("/societe/index.php", $langs->trans("ThirdParty"), 0, $user->rights->societe->lire);
  620. if ($user->rights->societe->creer)
  621. {
  622. $newmenu->add("/societe/soc.php?action=create", $langs->trans("MenuNewThirdParty"),1);
  623. if (! $conf->use_javascript_ajax) $newmenu->add("/societe/soc.php?action=create&amp;private=1",$langs->trans("MenuNewPrivateIndividual"),1);
  624. }
  625. // TODO Avoid doing dir scan
  626. if(is_dir("societe/groupe"))
  627. {
  628. $newmenu->add("/societe/groupe/index.php", $langs->trans("MenuSocGroup"),1);
  629. }
  630. }
  631. // Prospects
  632. if ($conf->societe->enabled && empty($conf->global->SOCIETE_DISABLE_PROSPECTS))
  633. {
  634. $langs->load("commercial");
  635. $newmenu->add("/comm/prospect/list.php?leftmenu=prospects", $langs->trans("ListProspectsShort"), 1, $user->rights->societe->lire);
  636. if ($leftmenu=="prospects") $newmenu->add("/comm/prospect/list.php?sortfield=s.datec&amp;sortorder=desc&amp;begin=&amp;stcomm=-1", $langs->trans("LastProspectDoNotContact"), 2, $user->rights->societe->lire);
  637. if ($leftmenu=="prospects") $newmenu->add("/comm/prospect/list.php?sortfield=s.datec&amp;sortorder=desc&amp;begin=&amp;stcomm=0", $langs->trans("LastProspectNeverContacted"), 2, $user->rights->societe->lire);
  638. if ($leftmenu=="prospects") $newmenu->add("/comm/prospect/list.php?sortfield=s.datec&amp;sortorder=desc&amp;begin=&amp;stcomm=1", $langs->trans("LastProspectToContact"), 2, $user->rights->societe->lire);
  639. if ($leftmenu=="prospects") $newmenu->add("/comm/prospect/list.php?sortfield=s.datec&amp;sortorder=desc&amp;begin=&amp;stcomm=2", $langs->trans("LastProspectContactInProcess"), 2, $user->rights->societe->lire);
  640. if ($leftmenu=="prospects") $newmenu->add("/comm/prospect/list.php?sortfield=s.datec&amp;sortorder=desc&amp;begin=&amp;stcomm=3", $langs->trans("LastProspectContactDone"), 2, $user->rights->societe->lire);
  641. $newmenu->add("/societe/soc.php?leftmenu=prospects&amp;action=create&amp;type=p", $langs->trans("MenuNewProspect"), 2, $user->rights->societe->creer);
  642. //$newmenu->add("/contact/list.php?leftmenu=customers&amp;type=p", $langs->trans("Contacts"), 2, $user->rights->societe->contact->lire);
  643. }
  644. // Clients
  645. if ($conf->societe->enabled)
  646. {
  647. $langs->load("commercial");
  648. $newmenu->add("/comm/list.php?leftmenu=customers", $langs->trans("ListCustomersShort"), 1, $user->rights->societe->lire);
  649. $newmenu->add("/societe/soc.php?leftmenu=customers&amp;action=create&amp;type=c", $langs->trans("MenuNewCustomer"), 2, $user->rights->societe->creer);
  650. //$newmenu->add("/contact/list.php?leftmenu=customers&amp;type=c", $langs->trans("Contacts"), 2, $user->rights->societe->contact->lire);
  651. }
  652. // Fournisseurs
  653. if ($conf->societe->enabled && $conf->fournisseur->enabled)
  654. {
  655. $langs->load("suppliers");
  656. $newmenu->add("/fourn/liste.php?leftmenu=suppliers", $langs->trans("ListSuppliersShort"), 1, $user->rights->societe->lire && $user->rights->fournisseur->lire);
  657. if ($user->societe_id == 0)
  658. {
  659. $newmenu->add("/societe/soc.php?leftmenu=suppliers&amp;action=create&amp;type=f",$langs->trans("MenuNewSupplier"), 2, $user->rights->societe->creer && $user->rights->fournisseur->lire);
  660. }
  661. //$newmenu->add("/fourn/liste.php?leftmenu=suppliers", $langs->trans("List"), 2, $user->rights->societe->lire && $user->rights->fournisseur->lire);
  662. //$newmenu->add("/contact/list.php?leftmenu=suppliers&amp;type=f",$langs->trans("Contacts"), 2, $user->rights->societe->lire && $user->rights->fournisseur->lire && $user->rights->societe->contact->lire);
  663. }
  664. // Contacts
  665. $newmenu->add("/contact/list.php?leftmenu=contacts", $langs->trans("ContactsAddresses"), 0, $user->rights->societe->contact->lire);
  666. $newmenu->add("/contact/fiche.php?leftmenu=contacts&amp;action=create", $langs->trans("NewContact"), 1, $user->rights->societe->contact->creer);
  667. $newmenu->add("/contact/list.php?leftmenu=contacts", $langs->trans("List"), 1, $user->rights->societe->contact->lire);
  668. if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) $newmenu->add("/contact/list.php?leftmenu=contacts&type=p", $langs->trans("Prospects"), 2, $user->rights->societe->contact->lire);
  669. $newmenu->add("/contact/list.php?leftmenu=contacts&type=c", $langs->trans("Customers"), 2, $user->rights->societe->contact->lire);
  670. if ($conf->fournisseur->enabled) $newmenu->add("/contact/list.php?leftmenu=contacts&type=f", $langs->trans("Suppliers"), 2, $user->rights->societe->contact->lire);
  671. $newmenu->add("/contact/list.php?leftmenu=contacts&type=o", $langs->trans("Others"), 2, $user->rights->societe->contact->lire);
  672. //$newmenu->add("/contact/list.php?userid=$user->id", $langs->trans("MyContacts"), 1, $user->rights->societe->contact->lire);
  673. // Categories
  674. if ($conf->categorie->enabled)
  675. {
  676. $langs->load("categories");
  677. // Categories prospects/customers
  678. $newmenu->add("/categories/index.php?leftmenu=cat&amp;type=2", $langs->trans("CustomersProspectsCategoriesShort"), 0, $user->rights->categorie->lire);
  679. if ($user->societe_id == 0)
  680. {
  681. $newmenu->add("/categories/fiche.php?action=create&amp;type=2", $langs->trans("NewCategory"), 1, $user->rights->categorie->creer);
  682. }
  683. // Categories suppliers
  684. if ($conf->fournisseur->enabled)
  685. {
  686. $newmenu->add("/categories/index.php?leftmenu=cat&amp;type=1", $langs->trans("SuppliersCategoriesShort"), 0, $user->rights->categorie->lire);
  687. if ($user->societe_id == 0)
  688. {
  689. $newmenu->add("/categories/fiche.php?action=create&amp;type=1", $langs->trans("NewCategory"), 1, $user->rights->categorie->creer);
  690. }
  691. }
  692. //if ($leftmenu=="cat") $newmenu->add("/categories/liste.php", $langs->trans("List"), 1, $user->rights->categorie->lire);
  693. }
  694. }
  695. /*
  696. * Menu COMMERCIAL
  697. */
  698. if ($mainmenu == 'commercial')
  699. {
  700. $langs->load("companies");
  701. // Propal
  702. if (! empty($conf->propal->enabled))
  703. {
  704. $langs->load("propal");
  705. $newmenu->add("/comm/propal/index.php?leftmenu=propals", $langs->trans("Prop"), 0, $user->rights->propale->lire);
  706. $newmenu->add("/societe/societe.php?leftmenu=propals", $langs->trans("NewPropal"), 1, $user->rights->propale->creer);
  707. $newmenu->add("/comm/propal.php?leftmenu=propals", $langs->trans("List"), 1, $user->rights->propale->lire);
  708. if ($leftmenu=="propals") $newmenu->add("/comm/propal.php?leftmenu=propals&viewstatut=0", $langs->trans("PropalsDraft"), 2, $user->rights->propale->lire);
  709. if ($leftmenu=="propals") $newmenu->add("/comm/propal.php?leftmenu=propals&viewstatut=1", $langs->trans("PropalsOpened"), 2, $user->rights->propale->lire);
  710. if ($leftmenu=="propals") $newmenu->add("/comm/propal.php?leftmenu=propals&viewstatut=2", $langs->trans("PropalStatusSigned"), 2, $user->rights->propale->lire);
  711. if ($leftmenu=="propals") $newmenu->add("/comm/propal.php?leftmenu=propals&viewstatut=3", $langs->trans("PropalStatusNotSigned"), 2, $user->rights->propale->lire);
  712. if ($leftmenu=="propals") $newmenu->add("/comm/propal.php?leftmenu=propals&viewstatut=4", $langs->trans("PropalStatusBilled"), 2, $user->rights->propale->lire);
  713. //if ($leftmenu=="propals") $newmenu->add("/comm/propal.php?leftmenu=propals&viewstatut=2,3,4", $langs->trans("PropalStatusClosedShort"), 2, $user->rights->propale->lire);
  714. $newmenu->add("/comm/propal/stats/index.php?leftmenu=propals", $langs->trans("Statistics"), 1, $user->rights->propale->lire);
  715. }
  716. // Customers orders
  717. if (! empty($conf->commande->enabled))
  718. {
  719. $langs->load("orders");
  720. $newmenu->add("/commande/index.php?leftmenu=orders", $langs->trans("CustomersOrders"), 0, $user->rights->commande->lire);
  721. $newmenu->add("/societe/societe.php?leftmenu=orders", $langs->trans("NewOrder"), 1, $user->rights->commande->creer);
  722. $newmenu->add("/commande/liste.php?leftmenu=orders", $langs->trans("List"), 1, $user->rights->commande->lire);
  723. if ($leftmenu=="orders") $newmenu->add("/commande/liste.php?leftmenu=orders&viewstatut=0", $langs->trans("StatusOrderDraftShort"), 2, $user->rights->commande->lire);
  724. if ($leftmenu=="orders") $newmenu->add("/commande/liste.php?leftmenu=orders&viewstatut=1", $langs->trans("StatusOrderValidated"), 2, $user->rights->commande->lire);
  725. if ($leftmenu=="orders") $newmenu->add("/commande/liste.php?leftmenu=orders&viewstatut=2", $langs->trans("StatusOrderOnProcessShort"), 2, $user->rights->commande->lire);
  726. if ($leftmenu=="orders") $newmenu->add("/commande/liste.php?leftmenu=orders&viewstatut=3", $langs->trans("StatusOrderToBill"), 2, $user->rights->commande->lire);
  727. if ($leftmenu=="orders") $newmenu->add("/commande/liste.php?leftmenu=orders&viewstatut=4", $langs->trans("StatusOrderProcessed"), 2, $user->rights->commande->lire);
  728. if ($leftmenu=="orders") $newmenu->add("/commande/liste.php?leftmenu=orders&viewstatut=-1", $langs->trans("StatusOrderCanceledShort"), 2, $user->rights->commande->lire);
  729. $newmenu->add("/commande/stats/index.php?leftmenu=orders", $langs->trans("Statistics"), 1, $user->rights->commande->lire);
  730. }
  731. // Suppliers orders
  732. if (! empty($conf->fournisseur->enabled))
  733. {
  734. $langs->load("orders");
  735. $newmenu->add("/fourn/commande/index.php?leftmenu=orders_suppliers",$langs->trans("SuppliersOrders"), 0, $user->rights->fournisseur->commande->lire);
  736. $newmenu->add("/societe/societe.php?leftmenu=orders_suppliers", $langs->trans("NewOrder"), 1, $user->rights->fournisseur->commande->creer);
  737. $newmenu->add("/fourn/commande/liste.php?leftmenu=orders_suppliers", $langs->trans("List"), 1, $user->rights->fournisseur->commande->lire);
  738. $newmenu->add("/commande/stats/index.php?leftmenu=orders_suppliers&amp;mode=supplier", $langs->trans("Statistics"), 1, $user->rights->fournisseur->commande->lire);
  739. }
  740. // Contrat
  741. if (! empty($conf->contrat->enabled))
  742. {
  743. $langs->load("contracts");
  744. $newmenu->add("/contrat/index.php?leftmenu=contracts", $langs->trans("Contracts"), 0, $user->rights->contrat->lire);
  745. $newmenu->add("/societe/societe.php?leftmenu=contracts", $langs->trans("NewContract"), 1, $user->rights->contrat->creer);
  746. $newmenu->add("/contrat/liste.php?leftmenu=contracts", $langs->trans("List"), 1, $user->rights->contrat->lire);
  747. $newmenu->add("/contrat/services.php?leftmenu=contracts", $langs->trans("MenuServices"), 1, $user->rights->contrat->lire);
  748. if ($leftmenu=="contracts") $newmenu->add("/contrat/services.php?leftmenu=contracts&amp;mode=0", $langs->trans("MenuInactiveServices"), 2, $user->rights->contrat->lire);
  749. if ($leftmenu=="contracts") $newmenu->add("/contrat/services.php?leftmenu=contracts&amp;mode=4", $langs->trans("MenuRunningServices"), 2, $user->rights->contrat->lire);
  750. if ($leftmenu=="contracts") $newmenu->add("/contrat/services.php?leftmenu=contracts&amp;mode=4&amp;filter=expired", $langs->trans("MenuExpiredServices"), 2, $user->rights->contrat->lire);
  751. if ($leftmenu=="contracts") $newmenu->add("/contrat/services.php?leftmenu=contracts&amp;mode=5", $langs->trans("MenuClosedServices"), 2, $user->rights->contrat->lire);
  752. }
  753. // Interventions
  754. if (! empty($conf->ficheinter->enabled))
  755. {
  756. $langs->load("interventions");
  757. $newmenu->add("/fichinter/list.php?leftmenu=ficheinter", $langs->trans("Interventions"), 0, $user->rights->ficheinter->lire);
  758. $newmenu->add("/fichinter/fiche.php?action=create&leftmenu=ficheinter", $langs->trans("NewIntervention"), 1, $user->rights->ficheinter->creer);
  759. $newmenu->add("/fichinter/list.php?leftmenu=ficheinter", $langs->trans("List"), 1, $user->rights->ficheinter->lire);
  760. }
  761. }
  762. /*
  763. * Menu COMPTA-FINANCIAL
  764. */
  765. if ($mainmenu == 'accountancy')
  766. {
  767. $langs->load("companies");
  768. // Customers invoices
  769. if ($conf->facture->enabled)
  770. {
  771. $langs->load("bills");
  772. $newmenu->add("/compta/facture.php?leftmenu=customers_bills",$langs->trans("BillsCustomers"),0,$user->rights->facture->lire);
  773. if ($user->societe_id == 0)
  774. {
  775. $newmenu->add("/compta/clients.php?action=facturer&amp;leftmenu=customers_bills",$langs->trans("NewBill"),1,$user->rights->facture->creer);
  776. }
  777. $newmenu->add("/compta/facture/fiche-rec.php?leftmenu=customers_bills",$langs->trans("Repeatables"),1,$user->rights->facture->lire);
  778. $newmenu->add("/compta/facture/impayees.php?leftmenu=customers_bills",$langs->trans("Unpaid"),1,$user->rights->facture->lire);
  779. $newmenu->add("/compta/paiement/liste.php?leftmenu=customers_bills_payments",$langs->trans("Payments"),1,$user->rights->facture->lire);
  780. if ($conf->global->BILL_ADD_PAYMENT_VALIDATION)
  781. {
  782. $newmenu->add("/compta/paiement/avalider.php?leftmenu=customers_bills_payments",$langs->trans("MenuToValid"),2,$user->rights->facture->lire);
  783. }
  784. $newmenu->add("/compta/paiement/rapport.php?leftmenu=customers_bills_payments",$langs->trans("Reportings"),2,$user->rights->facture->lire);
  785. $newmenu->add("/compta/facture/stats/index.php?leftmenu=customers_bills", $langs->trans("Statistics"),1,$user->rights->facture->lire);
  786. }
  787. // Suppliers
  788. if ($conf->societe->enabled && $conf->fournisseur->enabled)
  789. {
  790. if ($conf->facture->enabled)
  791. {
  792. $langs->load("bills");
  793. $newmenu->add("/fourn/facture/index.php?leftmenu=suppliers_bills", $langs->trans("BillsSuppliers"),0,$user->rights->fournisseur->facture->lire);
  794. if ($user->societe_id == 0)
  795. {
  796. $newmenu->add("/fourn/facture/fiche.php?action=create",$langs->trans("NewBill"),1,$user->rights->fournisseur->facture->creer);
  797. }
  798. $newmenu->add("/fourn/facture/impayees.php", $langs->trans("Unpaid"),1,$user->rights->fournisseur->facture->lire);
  799. $newmenu->add("/fourn/facture/paiement.php", $langs->trans("Payments"),1,$user->rights->fournisseur->facture->lire);
  800. $newmenu->add("/compta/facture/stats/index.php?leftmenu=suppliers_bills&mode=supplier", $langs->trans("Statistics"),1,$user->rights->fournisseur->facture->lire);
  801. }
  802. }
  803. // Orders
  804. if ($conf->commande->enabled)
  805. {
  806. $langs->load("orders");
  807. if ($conf->facture->enabled) $newmenu->add("/commande/liste.php?leftmenu=orders&amp;viewstatut=3", $langs->trans("MenuOrdersToBill"), 0, $user->rights->commande->lire);
  808. // if ($leftmenu=="orders") $newmenu->add("/commande/", $langs->trans("StatusOrderToBill"), 1, $user->rights->commande->lire);
  809. }
  810. // Donations
  811. if ($conf->don->enabled)
  812. {
  813. $langs->load("donations");
  814. $newmenu->add("/compta/dons/index.php?leftmenu=donations&amp;mainmenu=accountancy",$langs->trans("Donations"), 0, $user->rights->don->lire);
  815. if ($leftmenu=="donations") $newmenu->add("/compta/dons/fiche.php?action=create",$langs->trans("NewDonation"), 1, $user->rights->don->creer);
  816. if ($leftmenu=="donations") $newmenu->add("/compta/dons/liste.php",$langs->trans("List"), 1, $user->rights->don->lire);
  817. //if ($leftmenu=="donations") $newmenu->add("/compta/dons/stats.php",$langs->trans("Statistics"), 1, $user->rights->don->lire);
  818. }
  819. // Trips and expenses
  820. if ($conf->deplacement->enabled)
  821. {
  822. $langs->load("trips");
  823. $newmenu->add("/compta/deplacement/index.php?leftmenu=tripsandexpenses&amp;mainmenu=accountancy", $langs->trans("TripsAndExpenses"), 0, $user->rights->deplacement->lire);
  824. if ($leftmenu=="tripsandexpenses") $newmenu->add("/compta/deplacement/fiche.php?action=create&amp;leftmenu=tripsandexpenses&amp;mainmenu=accountancy", $langs->trans("New"), 1, $user->rights->deplacement->creer);
  825. if ($leftmenu=="tripsandexpenses") $newmenu->add("/compta/deplacement/list.php?leftmenu=tripsandexpenses&amp;mainmenu=accountancy", $langs->trans("List"), 1, $user->rights->deplacement->lire);
  826. if ($leftmenu=="tripsandexpenses") $newmenu->add("/compta/deplacement/stats/index.php?leftmenu=tripsandexpenses&amp;mainmenu=accountancy", $langs->trans("Statistics"), 1, $user->rights->deplacement->lire);
  827. }
  828. // Taxes and social contributions
  829. if ($conf->tax->enabled)
  830. {
  831. $newmenu->add("/compta/charges/index.php?leftmenu=tax&amp;mainmenu=accountancy",$langs->trans("MenuTaxAndDividends"), 0, $user->rights->tax->charges->lire);
  832. if (preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/sociales/index.php?leftmenu=tax_social",$langs->trans("MenuSocialContributions"),1,$user->rights->tax->charges->lire);
  833. if (preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/sociales/charges.php?leftmenu=tax_social&action=create",$langs->trans("MenuNewSocialContribution"), 2, $user->rights->tax->charges->creer);
  834. if (preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/charges/index.php?leftmenu=tax_social&amp;mainmenu=accountancy&amp;mode=sconly",$langs->trans("Payments"), 2, $user->rights->tax->charges->lire);
  835. // VAT
  836. if (empty($conf->global->TAX_DISABLE_VAT_MENUS))
  837. {
  838. if (preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/tva/index.php?leftmenu=tax_vat&amp;mainmenu=accountancy",$langs->trans("VAT"),1,$user->rights->tax->charges->lire);
  839. if (preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/tva/fiche.php?leftmenu=tax_vat&action=create",$langs->trans("NewPayment"),2,$user->rights->tax->charges->creer);
  840. if (preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/tva/reglement.php?leftmenu=tax_vat",$langs->trans("Payments"),2,$user->rights->tax->charges->lire);
  841. if (preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/tva/clients.php?leftmenu=tax_vat", $langs->trans("ReportByCustomers"), 2, $user->rights->tax->charges->lire);
  842. if (preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/tva/quadri_detail.php?leftmenu=tax_vat", $langs->trans("ReportByQuarter"), 2, $user->rights->tax->charges->lire);
  843. global $mysoc;
  844. //Local Taxes
  845. if($mysoc->pays_code=='ES' && $mysoc->localtax2_assuj=="1")
  846. {
  847. if (preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/localtax/index.php?leftmenu=tax_vat&amp;mainmenu=accountancy",$langs->transcountry("LT2",$mysoc->pays_code),1,$user->rights->tax->charges->lire);
  848. if (preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/localtax/fiche.php?leftmenu=tax_vat&action=create",$langs->trans("NewPayment"),2,$user->rights->tax->charges->creer);
  849. if (preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/localtax/reglement.php?leftmenu=tax_vat",$langs->trans("Payments"),2,$user->rights->tax->charges->lire);
  850. if (preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/localtax/clients.php?leftmenu=tax_vat", $langs->trans("ReportByCustomers"), 2, $user->rights->tax->charges->lire);
  851. //if (preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/localtax/quadri_detail.php?leftmenu=tax_vat", $langs->trans("ReportByQuarter"), 2, $user->rights->tax->charges->lire);
  852. }
  853. }
  854. }
  855. // Compta simple
  856. if ($conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION)
  857. {
  858. $newmenu->add("/compta/ventilation/index.php?leftmenu=ventil",$langs->trans("Dispatch"),0,$user->rights->compta->ventilation->lire);
  859. if ($leftmenu=="ventil") $newmenu->add("/compta/ventilation/liste.php",$langs->trans("ToDispatch"),1,$user->rights->compta->ventilation->lire);
  860. if ($leftmenu=="ventil") $newmenu->add("/compta/ventilation/lignes.php",$langs->trans("Dispatched"),1,$user->rights->compta->ventilation->lire);
  861. if ($leftmenu=="ventil") $newmenu->add("/compta/param/",$langs->trans("Setup"),1,$user->rights->compta->ventilation->parametrer);
  862. if ($leftmenu=="ventil") $newmenu->add("/compta/param/comptes/fiche.php?action=create",$langs->trans("New"),2,$user->rights->compta->ventilation->parametrer);
  863. if ($leftmenu=="ventil") $newmenu->add("/compta/param/comptes/liste.php",$langs->trans("List"),2,$user->rights->compta->ventilation->parametrer);
  864. if ($leftmenu=="ventil") $newmenu->add("/compta/export/",$langs->trans("Export"),1,$user->rights->compta->ventilation->lire);
  865. if ($leftmenu=="ventil") $newmenu->add("/compta/export/index.php?action=export",$langs->trans("New"),2,$user->rights->compta->ventilation->lire);
  866. if ($leftmenu=="ventil") $newmenu->add("/compta/export/liste.php",$langs->trans("List"),2,$user->rights->compta->ventilation->lire);
  867. }
  868. // Compta expert
  869. if ($conf->accounting->enabled)
  870. {
  871. }
  872. // Rapports
  873. if ($conf->comptabilite->enabled || $conf->accounting->enabled)
  874. {
  875. $langs->load("compta");
  876. // Bilan, resultats
  877. $newmenu->add("/compta/resultat/index.php?leftmenu=ca&amp;mainmenu=accountancy",$langs->trans("Reportings"),0,$user->rights->compta->resultat->lire||$user->rights->accounting->comptarapport->lire);
  878. if ($leftmenu=="ca") $newmenu->add("/compta/resultat/index.php?leftmenu=ca",$langs->trans("ReportInOut"),1,$user->rights->compta->resultat->lire||$user->rights->accounting->comptarapport->lire);
  879. if ($leftmenu=="ca") $newmenu->add("/compta/resultat/clientfourn.php?leftmenu=ca",$langs->trans("ByCompanies"),2,$user->rights->compta->resultat->lire||$user->rights->accounting->comptarapport->lire);
  880. /* On verra ca avec module compabilite expert
  881. if ($leftmenu=="ca") $newmenu->add("/compta/resultat/compteres.php?leftmenu=ca","Compte de resultat",2,$user->rights->compta->resultat->lire);
  882. if ($leftmenu=="ca") $newmenu->add("/compta/resultat/bilan.php?leftmenu=ca","Bilan",2,$user->rights->compta->resultat->lire);
  883. */
  884. if ($leftmenu=="ca") $newmenu->add("/compta/stats/index.php?leftmenu=ca",$langs->trans("ReportTurnover"),1,$user->rights->compta->resultat->lire||$user->rights->accounting->comptarapport->lire);
  885. /*
  886. if ($leftmenu=="ca") $newmenu->add("/compta/stats/cumul.php?leftmenu=ca","Cumule",2,$user->rights->compta->resultat->lire);
  887. if ($conf->propal->enabled) {
  888. if ($leftmenu=="ca") $newmenu->add("/compta/stats/prev.php?leftmenu=ca","Previsionnel",2,$user->rights->compta->resultat->lire);
  889. if ($leftmenu=="ca") $newmenu->add("/compta/stats/comp.php?leftmenu=ca","Transforme",2,$user->rights->compta->resultat->lire);
  890. }
  891. */
  892. if ($leftmenu=="ca") $newmenu->add("/compta/stats/casoc.php?leftmenu=ca",$langs->trans("ByCompanies"),2,$user->rights->compta->resultat->lire||$user->rights->accounting->comptarapport->lire);
  893. if ($leftmenu=="ca") $newmenu->add("/compta/stats/cabyuser.php?leftmenu=ca",$langs->trans("ByUsers"),2,$user->rights->compta->resultat->lire||$user->rights->accounting->comptarapport->lire);
  894. // Journaux
  895. //if ($leftmenu=="ca") $newmenu->add("/compta/journaux/index.php?leftmenu=ca",$langs->trans("Journaux"),1,$user->rights->compta->resultat->lire||$user->rights->accounting->comptarapport->lire);
  896. //journaux
  897. if ($leftmenu=="ca") $newmenu->add("/compta/journal/sellsjournal.php?leftmenu=ca",$langs->trans("SellsJournal"),1,$user->rights->compta->resultat->lire||$user->rights->accounting->comptarapport->lire);
  898. if ($leftmenu=="ca") $newmenu->add("/compta/journal/purchasesjournal.php?leftmenu=ca",$langs->trans("PurchasesJournal"),1,$user->rights->compta->resultat->lire||$user->rights->accounting->comptarapport->lire);
  899. }
  900. }
  901. /*
  902. * Menu BANK
  903. */
  904. if ($mainmenu == 'bank')
  905. {
  906. $langs->load("withdrawals");
  907. $langs->load("banks");
  908. $langs->load("bills");
  909. // Bank-Caisse
  910. if ($conf->banque->enabled)
  911. {
  912. $newmenu->add("/compta/bank/index.php?leftmenu=bank&amp;mainmenu=bank",$langs->trans("MenuBankCash"),0,$user->rights->banque->lire);
  913. $newmenu->add("/compta/bank/fiche.php?action=create",$langs->trans("MenuNewFinancialAccount"),1,$user->rights->banque->configurer);
  914. $newmenu->add("/compta/bank/categ.php",$langs->trans("Rubriques"),1,$user->rights->banque->configurer);
  915. $newmenu->add("/compta/bank/search.php",$langs->trans("ListTransactions"),1,$user->rights->banque->lire);
  916. $newmenu->add("/compta/bank/budget.php",$langs->trans("ListTransactionsByCategory"),1,$user->rights->banque->lire);
  917. $newmenu->add("/compta/bank/virement.php",$langs->trans("BankTransfers"),1,$user->rights->banque->transfer);
  918. }
  919. // Prelevements
  920. if ($conf->prelevement->enabled)
  921. {
  922. $newmenu->add("/compta/prelevement/index.php?leftmenu=withdraw&amp;mainmenu=bank",$langs->trans("StandingOrders"),0,$user->rights->prelevement->bons->lire);
  923. //if ($leftmenu=="withdraw") $newmenu->add("/compta/prelevement/demandes.php?status=0&amp;mainmenu=bank",$langs->trans("StandingOrderToProcess"),1,$user->rights->prelevement->bons->lire);
  924. if ($leftmenu=="withdraw") $newmenu->add("/compta/prelevement/create.php?mainmenu=bank",$langs->trans("NewStandingOrder"),1,$user->rights->prelevement->bons->creer);
  925. if ($leftmenu=="withdraw") $newmenu->add("/compta/prelevement/bons.php?mainmenu=bank",$langs->trans("WithdrawalsReceipts"),1,$user->rights->prelevement->bons->lire);
  926. if ($leftmenu=="withdraw") $newmenu->add("/compta/prelevement/liste.php?mainmenu=bank",$langs->trans("WithdrawalsLines"),1,$user->rights->prelevement->bons->lire);
  927. if ($leftmenu=="withdraw") $newmenu->add("/compta/prelevement/rejets.php?mainmenu=bank",$langs->trans("Rejects"),1,$user->rights->prelevement->bons->lire);
  928. if ($leftmenu=="withdraw") $newmenu->add("/compta/prelevement/stats.php?mainmenu=bank",$langs->trans("Statistics"),1,$user->rights->prelevement->bons->lire);
  929. //if ($leftmenu=="withdraw") $newmenu->add("/compta/prelevement/config.php",$langs->trans("Setup"),1,$user->rights->prelevement->bons->configurer);
  930. }
  931. // Gestion cheques
  932. if ($conf->facture->enabled && $conf->banque->enabled)
  933. {
  934. $newmenu->add("/compta/paiement/cheque/index.php?leftmenu=checks&amp;mainmenu=bank",$langs->trans("MenuChequeDeposits"),0,$user->rights->banque->cheque);
  935. $newmenu->add("/compta/paiement/cheque/fiche.php?leftmenu=checks&amp;action=new&amp;mainmenu=bank",$langs->trans("NewChequeDeposit"),1,$user->rights->banque->cheque);
  936. $newmenu->add("/compta/paiement/cheque/liste.php?leftmenu=checks&amp;mainmenu=bank",$langs->trans("List"),1,$user->rights->banque->cheque);
  937. }
  938. }
  939. /*
  940. * Menu PRODUCTS-SERVICES
  941. */
  942. if ($mainmenu == 'products')
  943. {
  944. // Products
  945. if ($conf->product->enabled)
  946. {
  947. $newmenu->add("/product/index.php?leftmenu=product&amp;type=0", $langs->trans("Products"), 0, $user->rights->produit->lire);
  948. if ($user->societe_id == 0)
  949. {
  950. $newmenu->add("/product/fiche.php?leftmenu=product&amp;action=create&amp;type=0", $langs->trans("NewProduct"), 1, $user->rights->produit->creer);
  951. $newmenu->add("/product/liste.php?leftmenu=product&amp;type=0", $langs->trans("List"), 1, $user->rights->produit->lire);
  952. }
  953. if ($conf->propal->enabled)
  954. {
  955. $newmenu->add("/product/popuprop.php?leftmenu=stats&amp;type=0", $langs->trans("Statistics"), 1, $user->rights->produit->lire && $user->rights->propale->lire);
  956. }
  957. if ($conf->stock->enabled)
  958. {
  959. $newmenu->add("/product/reassort.php?type=0", $langs->trans("Stocks"), 1, $user->rights->produit->lire && $user->rights->stock->lire);
  960. }
  961. }
  962. // Services
  963. if ($conf->service->enabled)
  964. {
  965. $newmenu->add("/product/index.php?leftmenu=service&amp;type=1", $langs->trans("Services"), 0, $user->rights->service->lire);
  966. if ($user->societe_id == 0)
  967. {
  968. $newmenu->add("/product/fiche.php?leftmenu=service&amp;action=create&amp;type=1", $langs->trans("NewService"), 1, $user->rights->service->creer);
  969. }
  970. $newmenu->add("/product/liste.php?leftmenu=service&amp;type=1", $langs->trans("List"), 1, $user->rights->service->lire);
  971. if ($conf->propal->enabled)
  972. {
  973. $newmenu->add("/product/popuprop.php?leftmenu=stats&amp;type=1", $langs->trans("Statistics"), 1, $user->rights->service->lire && $user->rights->propale->lire);
  974. }
  975. }
  976. // Categories
  977. if ($conf->categorie->enabled)
  978. {
  979. $langs->load("categories");
  980. $newmenu->add("/categories/index.php?leftmenu=cat&amp;type=0", $langs->trans("Categories"), 0, $user->rights->categorie->lire);
  981. if ($user->societe_id == 0)
  982. {
  983. $newmenu->add("/categories/fiche.php?action=create&amp;type=0", $langs->trans("NewCategory"), 1, $user->rights->categorie->creer);
  984. }
  985. //if ($leftmenu=="cat") $newmenu->add("/categories/liste.php", $langs->trans("List"), 1, $user->rights->categorie->lire);
  986. }
  987. // Stocks
  988. if ($conf->stock->enabled)
  989. {
  990. $langs->load("stocks");
  991. $newmenu->add("/product/stock/index.php?leftmenu=stock", $langs->trans("Stocks"), 0, $user->rights->stock->lire);
  992. if ($leftmenu=="stock") $newmenu->add("/product/stock/fiche.php?action=create", $langs->trans("MenuNewWarehouse"), 1, $user->rights->stock->creer);
  993. if ($leftmenu=="stock") $newmenu->add("/product/stock/liste.php", $langs->trans("List"), 1, $user->rights->stock->lire);
  994. if ($leftmenu=="stock") $newmenu->add("/product/stock/valo.php", $langs->trans("EnhancedValue"), 1, $user->rights->stock->lire);
  995. if ($leftmenu=="stock") $newmenu->add("/product/stock/mouvement.php", $langs->trans("Movements"), 1, $user->rights->stock->mouvement->lire);
  996. }
  997. // Expeditions
  998. if ($conf->expedition->enabled)
  999. {
  1000. $langs->load("sendings");
  1001. $newmenu->add("/expedition/index.php?leftmenu=sendings", $langs->trans("Shipments"), 0, $user->rights->expedition->lire);
  1002. if ($leftmenu=="sendings") $newmenu->add("/expedition/fiche.php?action=create2&leftmenu=sendings", $langs->trans("NewSending"), 1, $user->rights->expedition->creer);
  1003. if ($leftmenu=="sendings") $newmenu->add("/expedition/liste.php?leftmenu=sendings", $langs->trans("List"), 1, $user->rights->expedition->lire);
  1004. if ($leftmenu=="sendings") $newmenu->add("/expedition/stats/index.php?leftmenu=sendings", $langs->trans("Statistics"), 1, $user->rights->expedition->lire);
  1005. }
  1006. }
  1007. /*
  1008. * Menu SUPPLIERS
  1009. */
  1010. if ($mainmenu == 'suppliers')
  1011. {
  1012. $langs->load("suppliers");
  1013. if ($conf->societe->enabled && $conf->fournisseur->enabled)
  1014. {
  1015. $newmenu->add("/fourn/index.php?leftmenu=suppliers", $langs->trans("Suppliers"), 0, $user->rights->societe->lire && $user->rights->fournisseur->lire);
  1016. // Security check
  1017. if ($user->societe_id == 0)
  1018. {
  1019. $newmenu->add("/societe/soc.php?leftmenu=suppliers&amp;action=create&amp;type=f",$langs->trans("NewSupplier"), 1, $user->rights->societe->creer && $user->rights->fournisseur->lire);
  1020. }
  1021. $newmenu->add("/fourn/liste.php",$langs->trans("List"), 1, $user->rights->societe->lire && $user->rights->fournisseur->lire);
  1022. $newmenu->add("/contact/list.php?leftmenu=suppliers&amp;type=f",$langs->trans("Contacts"), 1, $user->rights->societe->contact->lire && $user->rights->fournisseur->lire);
  1023. $newmenu->add("/fourn/stats.php",$langs->trans("Statistics"), 1, $user->rights->societe->lire && $user->rights->fournisseur->lire);
  1024. }
  1025. if ($conf->facture->enabled)
  1026. {
  1027. $langs->load("bills");
  1028. $newmenu->add("/fourn/facture/index.php", $langs->trans("Bills"), 0, $user->rights->fournisseur->facture->lire);
  1029. if ($user->societe_id == 0)
  1030. {
  1031. $newmenu->add("/fourn/facture/fiche.php?action=create",$langs->trans("NewBill"), 1, $user->rights->fournisseur->facture->creer);
  1032. }
  1033. $newmenu->add("/fourn/facture/paiement.php", $langs->trans("Payments"), 1, $user->rights->fournisseur->facture->lire);
  1034. }
  1035. if ($conf->fournisseur->enabled)
  1036. {
  1037. $langs->load("orders");
  1038. $newmenu->add("/fourn/commande/index.php?leftmenu=suppliers",$langs->trans("Orders"), 0, $user->rights->fournisseur->commande->lire);
  1039. $newmenu->add("/societe/societe.php?leftmenu=supplier", $langs->trans("NewOrder"), 1, $user->rights->fournisseur->commande->creer);
  1040. $newmenu->add("/fourn/commande/liste.php?leftmenu=suppliers", $langs->trans("List"), 1, $user->rights->fournisseur->commande->lire);
  1041. }
  1042. if ($conf->categorie->enabled)
  1043. {
  1044. $langs->load("categories");
  1045. $newmenu->add("/categories/index.php?leftmenu=cat&amp;type=1", $langs->trans("Categories"), 0, $user->rights->categorie->lire);
  1046. if ($user->societe_id == 0)
  1047. {
  1048. $newmenu->add("/categories/fiche.php?action=create&amp;type=1", $langs->trans("NewCategory"), 1, $user->rights->categorie->creer);
  1049. }
  1050. //if ($leftmenu=="cat") $newmenu->add("/categories/liste.php", $langs->trans("List"), 1, $user->rights->categorie->lire);
  1051. }
  1052. }
  1053. /*
  1054. * Menu PROJECTS
  1055. */
  1056. if ($mainmenu == 'project')
  1057. {
  1058. if ($conf->projet->enabled)
  1059. {
  1060. $langs->load("projects");
  1061. // Project affected to user
  1062. $newmenu->add("/projet/index.php?leftmenu=projects&mode=mine", $langs->trans("MyProjects"), 0, $user->rights->projet->lire);
  1063. $newmenu->add("/projet/fiche.php?leftmenu=projects&action=create&mode=mine", $langs->trans("NewProject"), 1, $user->rights->projet->creer);
  1064. $newmenu->add("/projet/liste.php?leftmenu=projects&mode=mine", $langs->trans("List"), 1, $user->rights->projet->lire);
  1065. // All project i have permission on
  1066. $newmenu->add("/projet/index.php?leftmenu=projects", $langs->trans("Projects"), 0, $user->rights->projet->lire && $user->rights->projet->lire);
  1067. $newmenu->add("/projet/fiche.php?leftmenu=projects&action=create", $langs->trans("NewProject"), 1, $user->rights->projet->creer && $user->rights->projet->creer);
  1068. $newmenu->add("/projet/liste.php?leftmenu=projects", $langs->trans("List"), 1, $user->rights->projet->lire && $user->rights->projet->lire);
  1069. // Project affected to user
  1070. $newmenu->add("/projet/activity/index.php?mode=mine", $langs->trans("MyActivities"), 0, $user->rights->projet->lire);
  1071. $newmenu->add("/projet/tasks.php?action=create&mode=mine", $langs->trans("NewTask"), 1, $user->rights->projet->creer);
  1072. $newmenu->add("/projet/tasks/index.php?mode=mine", $langs->trans("List"), 1, $user->rights->projet->lire);
  1073. $newmenu->add("/projet/activity/list.php?mode=mine", $langs->trans("NewTimeSpent"), 1, $user->rights->projet->creer);
  1074. // All project i have permission on
  1075. $newmenu->add("/projet/activity/index.php", $langs->trans("Activities"), 0, $user->rights->projet->lire && $user->rights->projet->lire);
  1076. $newmenu->add("/projet/tasks.php?action=create", $langs->trans("NewTask"), 1, $user->rights->projet->creer && $user->rights->projet->creer);
  1077. $newmenu->add("/projet/tasks/index.php", $langs->trans("List"), 1, $user->rights->projet->lire && $user->rights->projet->lire);
  1078. $newmenu->add("/projet/activity/list.php", $langs->trans("NewTimeSpent"), 1, $user->rights->projet->creer && $user->rights->projet->creer);
  1079. }
  1080. }
  1081. /*
  1082. * Menu TOOLS
  1083. */
  1084. if ($mainmenu == 'tools')
  1085. {
  1086. if (! empty($conf->mailing->enabled))
  1087. {
  1088. $langs->load("mails");
  1089. $newmenu->add("/comm/mailing/index.php?leftmenu=mailing", $langs->trans("EMailings"), 0, $user->rights->mailing->lire);
  1090. $newmenu->add("/comm/mailing/fiche.php?leftmenu=mailing&amp;action=create", $langs->trans("NewMailing"), 1, $user->rights->mailing->creer);
  1091. $newmenu->add("/comm/mailing/liste.php?leftmenu=mailing", $langs->trans("List"), 1, $user->rights->mailing->lire);
  1092. }
  1093. if (! empty($conf->export->enabled))
  1094. {
  1095. $langs->load("exports");
  1096. $newmenu->add("/exports/index.php?leftmenu=export",$langs->trans("FormatedExport"),0, $user->rights->export->lire);
  1097. $newmenu->add("/exports/export.php?leftmenu=export",$langs->trans("NewExport"),1, $user->rights->export->creer);
  1098. //$newmenu->add("/exports/export.php?leftmenu=export",$langs->trans("List"),1, $user->rights->export->lire);
  1099. }
  1100. if (! empty($conf->import->enabled))
  1101. {
  1102. $langs->load("exports");
  1103. $newmenu->add("/imports/index.php?leftmenu=import",$langs->trans("FormatedImport"),0, $user->rights->import->run);
  1104. $newmenu->add("/imports/import.php?leftmenu=import",$langs->trans("NewImport"),1, $user->rights->import->run);
  1105. }
  1106. if (! empty($conf->domain->enabled))
  1107. {
  1108. $langs->load("domains");
  1109. $newmenu->add("/domain/index.php?leftmenu=export",$langs->trans("DomainNames"),0, $user->rights->domain->read);
  1110. $newmenu->add("/domain/fiche.php?action=create&leftmenu=export",$langs->trans("NewDomain"),1, $user->rights->domain->create);
  1111. $newmenu->add("/domain/index.php?leftmenu=export",$langs->trans("List"),1, $user->rights->domain->read);
  1112. }
  1113. if (! empty($conf->submiteverywhere->enabled))
  1114. {
  1115. $langs->load("submiteverywhere@submiteverywhere");
  1116. $newmenu->add("/submiteverywhere/index.php?leftmenu=submiteverywhere", $langs->trans("News"), 0, $user->rights->submiteverywhere->read);
  1117. $newmenu->add("/submiteverywhere/fiche.php?leftmenu=submiteverywhere&amp;action=create", $langs->trans("NewNews"), 1, $user->rights->submiteverywhere->create);
  1118. $newmenu->add("/submiteverywhere/liste.php?leftmenu=submiteverywhere", $langs->trans("List"), 1, $user->rights->submiteverywhere->read);
  1119. }
  1120. }
  1121. /*
  1122. * Menu MEMBERS
  1123. */
  1124. if ($mainmenu == 'members')
  1125. {
  1126. if ($conf->adherent->enabled)
  1127. {
  1128. $langs->load("members");
  1129. $langs->load("compta");
  1130. $newmenu->add("/adherents/index.php?leftmenu=members&amp;mainmenu=members",$langs->trans("Members"),0,$user->rights->adherent->lire);
  1131. $newmenu->add("/adherents/fiche.php?leftmenu=members&amp;action=create",$langs->trans("NewMember"),1,$user->rights->adherent->creer);
  1132. $newmenu->add("/adherents/liste.php?leftmenu=members",$langs->trans("List"),1,$user->rights->adherent->lire);
  1133. $newmenu->add("/adherents/liste.php?leftmenu=members&amp;statut=-1",$langs->trans("MenuMembersToValidate"),2,$user->rights->adherent->lire);
  1134. $newmenu->add("/adherents/liste.php?leftmenu=members&amp;statut=1",$langs->trans("MenuMembersValidated"),2,$user->rights->adherent->lire);
  1135. $newmenu->add("/adherents/liste.php?leftmenu=members&amp;statut=1&amp;filter=uptodate",$langs->trans("MenuMembersUpToDate"),2,$user->rights->adherent->lire);
  1136. $newmenu->add("/adherents/liste.php?leftmenu=members&amp;statut=1&amp;filter=outofdate",$langs->trans("MenuMembersNotUpToDate"),2,$user->rights->adherent->lire);
  1137. $newmenu->add("/adherents/liste.php?leftmenu=members&amp;statut=0",$langs->trans("MenuMembersResiliated"),2,$user->rights->adherent->lire);
  1138. $newmenu->add("/adherents/stats/index.php?leftmenu=members",$langs->trans("MenuMembersStats"),1,$user->rights->adherent->lire);
  1139. $newmenu->add("/adherents/index.php?leftmenu=members&amp;mainmenu=members",$langs->trans("Subscriptions"),0,$user->rights->adherent->cotisation->lire);
  1140. $newmenu->add("/adherents/liste.php?leftmenu=members&amp;statut=-1,1&amp;mainmenu=members",$langs->trans("NewSubscription"),1,$user->rights->adherent->cotisation->creer);
  1141. $newmenu->add("/adherents/cotisations.php?leftmenu=members",$langs->trans("List"),1,$user->rights->adherent->cotisation->lire);
  1142. if ($conf->categorie->enabled)
  1143. {
  1144. $langs->load("categories");
  1145. $newmenu->add("/categories/index.php?leftmenu=cat&amp;type=3", $langs->trans("Categories"), 0, $user->rights->categorie->lire);
  1146. if ($user->societe_id == 0)
  1147. {
  1148. $newmenu->add("/categories/fiche.php?action=create&amp;type=3", $langs->trans("NewCategory"), 1, $user->rights->categorie->creer);
  1149. }
  1150. //if ($leftmenu=="cat") $newmenu->add("/categories/liste.php", $langs->trans("List"), 1, $user->rights->categorie->lire);
  1151. }
  1152. $newmenu->add("/adherents/index.php?leftmenu=export&amp;mainmenu=members",$langs->trans("Exports"),0,$user->rights->adherent->export);
  1153. if ($conf->export->enabled && $leftmenu=="export") $newmenu->add("/exports/index.php?leftmenu=export",$langs->trans("Datas"),1,$user->rights->adherent->export);
  1154. if ($leftmenu=="export") $newmenu->add("/adherents/htpasswd.php?leftmenu=export",$langs->trans("Filehtpasswd"),1,$user->rights->adherent->export);
  1155. if ($leftmenu=="export") $newmenu->add("/adherents/cartes/carte.php?leftmenu=export",$langs->trans("MembersCards"),1,$user->rights->adherent->export);
  1156. // Type
  1157. $newmenu->add("/adherents/type.php?leftmenu=setup&amp;mainmenu=members",$langs->trans("MembersTypes"),0,$user->rights->adherent->configurer);
  1158. $newmenu->add("/adherents/type.php?leftmenu=setup&amp;mainmenu=members&amp;action=create",$langs->trans("New"),1,$user->rights->adherent->configurer);
  1159. $newmenu->add("/adherents/type.php?leftmenu=setup&amp;mainmenu=members",$langs->trans("List"),1,$user->rights->adherent->configurer);
  1160. }
  1161. }
  1162. // Affichage des menus personnalises
  1163. require_once(DOL_DOCUMENT_ROOT."/core/class/menubase.class.php");
  1164. $menuArbo = new Menubase($db,'eldy','left');
  1165. $newmenu = $menuArbo->menuLeftCharger($newmenu,$mainmenu,$leftmenu,($user->societe_id?1:0),'eldy');
  1166. }
  1167. //var_dump($menu_array_before);exit;
  1168. //var_dump($menu_array_after);exit;
  1169. $menu_array=$newmenu->liste;
  1170. if (is_array($menu_array_before)) $menu_array=array_merge($menu_array_before, $menu_array);
  1171. if (is_array($menu_array_after)) $menu_array=array_merge($menu_array, $menu_array_after);
  1172. //var_dump($menu_array);exit;
  1173. // Show menu
  1174. $alt=0;
  1175. if (is_array($menu_array))
  1176. {
  1177. $num=count($menu_array);
  1178. for ($i = 0; $i < $num; $i++)
  1179. {
  1180. $alt++;
  1181. if (empty($menu_array[$i]['level']))
  1182. {
  1183. if (($alt%2==0))
  1184. {
  1185. print '<div class="blockvmenuimpair">'."\n";
  1186. }
  1187. else
  1188. {
  1189. print '<div class="blockvmenupair">'."\n";
  1190. }
  1191. }
  1192. // Place tabulation
  1193. $tabstring='';
  1194. $tabul=($menu_array[$i]['level'] - 1);
  1195. if ($tabul > 0)
  1196. {
  1197. for ($j=0; $j < $tabul; $j++)
  1198. {
  1199. $tabstring.='&nbsp; &nbsp;';
  1200. }
  1201. }
  1202. // For external modules
  1203. $url = dol_buildpath($menu_array[$i]['url'], 1);
  1204. // Menu niveau 0
  1205. if ($menu_array[$i]['level'] == 0)
  1206. {
  1207. if ($menu_array[$i]['enabled'])
  1208. {
  1209. print '<div class="menu_titre">'.$tabstring.'<a class="vmenu" href="'.$url.'"'.($menu_array[$i]['target']?' target="'.$menu_array[$i]['target'].'"':'').'>'.$menu_array[$i]['titre'].'</a></div>'."\n";
  1210. }
  1211. else if (empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED))
  1212. {
  1213. print '<div class="menu_titre">'.$tabstring.'<font class="vmenudisabled">'.$menu_array[$i]['titre'].'</font></div>'."\n";
  1214. }
  1215. print '<div class="menu_top"></div>'."\n";
  1216. }
  1217. // Menu niveau > 0
  1218. if ($menu_array[$i]['level'] > 0)
  1219. {
  1220. if ($menu_array[$i]['enabled'])
  1221. {
  1222. print '<div class="menu_contenu">'.$tabstring;
  1223. if ($menu_array[$i]['url']) print '<a class="vsmenu" href="'.$url.'"'.($menu_array[$i]['target']?' target="'.$menu_array[$i]['target'].'"':'').'>';
  1224. print $menu_array[$i]['titre'];
  1225. if ($menu_array[$i]['url']) print '</a>';
  1226. // If title is not pure text and contains a table, no carriage return added
  1227. if (! strstr($menu_array[$i]['titre'],'<table')) print '<br>';
  1228. print '</div>'."\n";
  1229. }
  1230. else if (empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED))
  1231. {
  1232. print '<div class="menu_contenu">'.$tabstring.'<font class="vsmenudisabled">'.$menu_array[$i]['titre'].'</font><br></div>'."\n";
  1233. }
  1234. }
  1235. // If next is a new block or end
  1236. if (empty($menu_array[$i+1]['level']))
  1237. {
  1238. print '<div class="menu_end"></div>'."\n";
  1239. print "</div>\n";
  1240. }
  1241. }
  1242. }
  1243. return count($menu_array);
  1244. }
  1245. ?>