eldy.lib.php 146 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455
  1. <?php
  2. /* Copyright (C) 2010-2022 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2010 Regis Houssin <regis.houssin@inodbox.com>
  4. * Copyright (C) 2012-2015 Juanjo Menent <jmenent@2byte.es>
  5. * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
  6. * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
  7. * Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
  8. * Copyright (C) 2018-2022 Frédéric France <frederic.france@netlogic.fr>
  9. * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 3 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  23. * or see https://www.gnu.org/
  24. */
  25. /**
  26. * \file htdocs/core/menus/standard/eldy.lib.php
  27. * \brief Library for file eldy menus
  28. */
  29. require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php';
  30. /**
  31. * Core function to output top menu eldy
  32. *
  33. * @param DoliDB $db Database handler
  34. * @param string $atarget Target (Example: '' or '_top')
  35. * @param int $type_user 0=Menu for backoffice, 1=Menu for front office
  36. * @param array $tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty). For eldy menu, it contains menu entries loaded from database.
  37. * @param Menu $menu Object Menu to return back list of menu entries
  38. * @param int $noout 1=Disable output (Initialise &$menu only).
  39. * @param string $mode 'top', 'topnb', 'left', 'jmobile'
  40. * @return int 0
  41. */
  42. function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 0, $mode = '')
  43. {
  44. global $user, $conf, $langs, $mysoc;
  45. global $dolibarr_main_db_name;
  46. $mainmenu = (empty($_SESSION["mainmenu"]) ? '' : $_SESSION["mainmenu"]);
  47. $leftmenu = (empty($_SESSION["leftmenu"]) ? '' : $_SESSION["leftmenu"]);
  48. $id = 'mainmenu';
  49. $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL);
  50. $substitarray = getCommonSubstitutionArray($langs, 0, null, null);
  51. if (empty($noout)) {
  52. print_start_menu_array();
  53. }
  54. global $usemenuhider;
  55. $usemenuhider = 1;
  56. // Show/Hide vertical menu. The hamburger icon for .menuhider action.
  57. if ($mode != 'jmobile' && $mode != 'topnb' && $usemenuhider && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
  58. $showmode = 1;
  59. $classname = 'class="tmenu menuhider nohover"';
  60. $idsel = 'menu';
  61. $menu->add('#', (getDolGlobalInt('THEME_TOPMENU_DISABLE_IMAGE') == 1 ? '<span class="fa fa-bars"></span>' : ''), 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname);
  62. }
  63. $menu_arr = array();
  64. // Home
  65. $menu_arr[] = array(
  66. 'name' => 'Home',
  67. 'link' => '/index.php?mainmenu=home&amp;leftmenu=home',
  68. 'title' => "Home",
  69. 'level' => 0,
  70. 'enabled' => $showmode = 1,
  71. 'target' => $atarget,
  72. 'mainmenu' => "home",
  73. 'leftmenu' => '',
  74. 'position' => 10,
  75. 'id' => $id,
  76. 'idsel' => 'home',
  77. 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "home") ? 'class="tmenusel"' : 'class="tmenu"',
  78. 'prefix' => '<span class="fa fa-home fa-fw paddingright"></span>',
  79. 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "home") ? 0 : 1),
  80. 'loadLangs' => array(),
  81. 'submenus' => array(),
  82. );
  83. // Members
  84. $tmpentry = array(
  85. 'enabled' => isModEnabled('adherent'),
  86. 'perms' => $user->hasRight('adherent', 'lire'),
  87. 'module' => 'adherent'
  88. );
  89. $menu_arr[] = array(
  90. 'name' => 'Members',
  91. 'link' => '/adherents/index.php?mainmenu=members&amp;leftmenu=',
  92. 'title' => "MenuMembers",
  93. 'level' => 0,
  94. 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal),
  95. 'target' => $atarget,
  96. 'mainmenu' => "members",
  97. 'leftmenu' => '',
  98. 'position' => 18,
  99. 'id' => $id,
  100. 'idsel' => 'members',
  101. 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "members") ? 'class="tmenusel"' : 'class="tmenu"',
  102. 'prefix' => img_picto('', 'member', 'class="fa-fw paddingright pictofixedwidth"'),
  103. 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "members") ? 0 : 1),
  104. 'loadLangs' => array("members"),
  105. 'submenus' => array(),
  106. );
  107. // Third parties
  108. $tmpentry = array(
  109. 'enabled'=> ((isModEnabled('societe') &&
  110. (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))
  111. )
  112. || (isModEnabled('supplier_proposal') || isModEnabled('supplier_order') || isModEnabled('supplier_invoice'))
  113. ),
  114. 'perms'=> ($user->hasRight('societe', 'lire') || $user->hasRight('fournisseur', 'lire') || $user->hasRight('supplier_order', 'lire') || $user->hasRight('supplier_invoice', 'lire') || $user->hasRight('supplier_proposal', 'lire')),
  115. 'module'=>'societe|fournisseur'
  116. );
  117. $menu_arr[] = array(
  118. 'name' => 'Companies',
  119. 'link' => '/societe/index.php?mainmenu=companies&amp;leftmenu=',
  120. 'title' => "ThirdParties",
  121. 'level' => 0,
  122. 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal),
  123. 'target' => $atarget,
  124. 'mainmenu' => "companies",
  125. 'leftmenu' => '',
  126. 'position' => 20,
  127. 'id' => $id,
  128. 'idsel' => 'companies',
  129. 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "companies") ? 'class="tmenusel"' : 'class="tmenu"',
  130. 'prefix' => img_picto('', 'company', 'class="fa-fw paddingright pictofixedwidth"'),
  131. 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "companies") ? 0 : 1),
  132. 'loadLangs' => array("companies", "suppliers"),
  133. 'submenus' => array(),
  134. );
  135. // Products-Services
  136. $tmpentry = array(
  137. 'enabled'=> (isModEnabled('product') || isModEnabled('service') || isModEnabled('expedition')),
  138. 'perms'=> ($user->hasRight('product', 'read') || $user->hasRight('service', 'read') || $user->hasRight('expedition', 'lire')),
  139. 'module'=>'product|service'
  140. );
  141. $menu_arr[] = array(
  142. 'name' => 'Products',
  143. 'link' => '/product/index.php?mainmenu=products&amp;leftmenu=',
  144. 'title' => (isModEnabled('product') && isModEnabled('service'))
  145. ? (array("TMenuProducts", " | ", "TMenuServices"))
  146. : (isModEnabled('product') ? "TMenuProducts" : "TMenuServices"),
  147. 'level' => 0,
  148. 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal),
  149. 'target' => $atarget,
  150. 'mainmenu' => "products",
  151. 'leftmenu' => '',
  152. 'position' => 30,
  153. 'id' => $id,
  154. 'idsel' => 'products',
  155. 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "products") ? 'class="tmenusel"' : 'class="tmenu"',
  156. 'prefix' => img_picto('', 'product', 'class="fa-fw paddingright pictofixedwidth"'),
  157. 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "products") ? 0 : 1),
  158. 'loadLangs' => array("products", "stocks"),
  159. 'submenus' => array(),
  160. );
  161. // MRP - GPAO
  162. $tmpentry = array(
  163. 'enabled'=>(isModEnabled('bom') || isModEnabled('mrp')),
  164. 'perms'=>($user->hasRight('bom', 'read') || $user->hasRight('mrp', 'read')),
  165. 'module'=>'bom|mrp'
  166. );
  167. $menu_arr[] = array(
  168. 'name' => 'TMenuMRP',
  169. 'link' => '/mrp/index.php?mainmenu=mrp&amp;leftmenu=',
  170. 'title' => "TMenuMRP",
  171. 'level' => 0,
  172. 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal),
  173. 'target' => $atarget,
  174. 'mainmenu' => "mrp",
  175. 'leftmenu' => '',
  176. 'position' => 31,
  177. 'id' => $id,
  178. 'idsel' => 'mrp',
  179. 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "mrp") ? 'class="tmenusel"' : 'class="tmenu"',
  180. 'prefix' => img_picto('', 'mrp', 'class="fa-fw paddingright pictofixedwidth"'),
  181. 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "mrp") ? 0 : 1),
  182. 'loadLangs' => array("mrp"),
  183. 'submenus' => array(),
  184. );
  185. // Projects
  186. $tmpentry = array(
  187. 'enabled'=> (isModEnabled('projet') ? 1 : 0),
  188. 'perms'=> ($user->hasRight('projet', 'lire') ? 1 : 0),
  189. 'module'=>'projet'
  190. );
  191. if ($mode == 'jmobile') {
  192. $titleboth = $langs->trans("LeadsOrProjects");
  193. } else {
  194. $titleboth = $langs->trans("Projects");
  195. }
  196. if (empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
  197. $titleboth = $langs->trans("Projects");
  198. }
  199. if (isset($conf->global->PROJECT_USE_OPPORTUNITIES) && $conf->global->PROJECT_USE_OPPORTUNITIES == 2) { // 2 = leads only
  200. $titleboth = $langs->trans("Leads");
  201. }
  202. $menu_arr[] = array(
  203. 'name' => 'Project',
  204. 'link' => '/projet/index.php?mainmenu=project&amp;leftmenu=',
  205. 'title' => $titleboth,
  206. 'level' => 0,
  207. 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal),
  208. 'target' => $atarget,
  209. 'mainmenu' => "project",
  210. 'leftmenu' => '',
  211. 'position' => 35,
  212. 'id' => $id,
  213. 'idsel' => 'project',
  214. 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "project") ? 'class="tmenusel"' : 'class="tmenu"',
  215. 'prefix' => img_picto('', 'project', 'class="fa-fw paddingright pictofixedwidth"'),
  216. 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "project") ? 0 : 1),
  217. 'loadLangs' => array("projects"),
  218. 'submenus' => array(),
  219. );
  220. // Commercial (propal, commande, supplier_proposal, supplier_order, contrat, ficheinter)
  221. $tmpentry = array(
  222. 'enabled'=>(isModEnabled('propal')
  223. || isModEnabled('commande')
  224. || isModEnabled('fournisseur')
  225. || isModEnabled('supplier_proposal')
  226. || isModEnabled('supplier_order')
  227. || isModEnabled('contrat')
  228. || isModEnabled('ficheinter')
  229. ) ? 1 : 0,
  230. 'perms'=>($user->hasRight('propal', 'read')
  231. || $user->hasRight('commande', 'lire')
  232. || $user->hasRight('supplier_proposal', 'lire')
  233. || $user->hasRight('fournisseur', 'lire')
  234. || $user->hasRight('fournisseur', 'commande', 'lire')
  235. || $user->hasRight('supplier_order', 'lire')
  236. || $user->hasRight('contrat', 'lire')
  237. || $user->hasRight('ficheinter', 'lire')
  238. ),
  239. 'module'=>'propal|commande|supplier_proposal|supplier_order|contrat|ficheinter'
  240. );
  241. $onlysupplierorder = $user->hasRight('fournisseur', 'commande', 'lire') &&
  242. !$user->hasRight('propal', 'lire') &&
  243. !$user->hasRight('commande', 'lire') &&
  244. !$user->hasRight('supplier_order', 'lire') &&
  245. !$user->hasRight('supplier_proposal', 'lire') &&
  246. !$user->hasRight('contrat', 'lire') &&
  247. !$user->hasRight('ficheinter', 'lire');
  248. $menu_arr[] = array(
  249. 'name' => 'Commercial',
  250. 'link' => ($onlysupplierorder ? '/fourn/commande/index.php?mainmenu=commercial&amp;leftmenu=' : '/comm/index.php?mainmenu=commercial&amp;leftmenu='),
  251. 'title' => "Commercial",
  252. 'level' => 0,
  253. 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal),
  254. 'target' => $atarget,
  255. 'mainmenu' => "commercial",
  256. 'leftmenu' => '',
  257. 'position' => 40,
  258. 'id' => $id,
  259. 'idsel' => 'commercial',
  260. 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "commercial") ? 'class="tmenusel"' : 'class="tmenu"',
  261. 'prefix' => img_picto('', 'contract', 'class="fa-fw paddingright pictofixedwidth"'),
  262. 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "commercial") ? 0 : 1),
  263. 'loadLangs' => array("commercial"),
  264. 'submenus' => array(),
  265. );
  266. // Billing - Financial
  267. $tmpentry = array(
  268. 'enabled'=>(isModEnabled('facture') ||
  269. isModEnabled('don') ||
  270. isModEnabled('tax') ||
  271. isModEnabled('salaries') ||
  272. isModEnabled('supplier_invoice') ||
  273. isModEnabled('loan') ||
  274. isModEnabled('margins')
  275. ) ? 1 : 0,
  276. 'perms'=>($user->hasRight('facture', 'lire') || $user->hasRight('don', 'contact', 'lire')
  277. || $user->hasRight('tax', 'charges', 'lire') || $user->hasRight('salaries', 'read')
  278. || $user->hasRight('fournisseur', 'facture', 'lire') || $user->hasRight('loan', 'read') || $user->hasRight('margins', 'liretous')),
  279. 'module'=>'facture|supplier_invoice|don|tax|salaries|loan'
  280. );
  281. $menu_arr[] = array(
  282. 'name' => 'Compta',
  283. 'link' => '/compta/index.php?mainmenu=billing&amp;leftmenu=',
  284. 'title' => "MenuFinancial",
  285. 'level' => 0,
  286. 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal),
  287. 'target' => $atarget,
  288. 'mainmenu' => "billing",
  289. 'leftmenu' => '',
  290. 'position' => 50,
  291. 'id' => $id,
  292. 'idsel' => 'billing',
  293. 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "billing") ? 'class="tmenusel"' : 'class="tmenu"',
  294. 'prefix' => img_picto('', 'bill', 'class="fa-fw paddingright pictofixedwidth"'),
  295. 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "billing") ? 0 : 1),
  296. 'loadLangs' => array("compta"),
  297. 'submenus' => array(),
  298. );
  299. // Bank
  300. $tmpentry = array(
  301. 'enabled'=>(isModEnabled('banque') || isModEnabled('prelevement')),
  302. 'perms'=>($user->hasRight('banque', 'lire') || $user->hasRight('prelevement', 'lire') || $user->hasRight('paymentbybanktransfer', 'read')),
  303. 'module'=>'banque|prelevement|paymentbybanktransfer'
  304. );
  305. $menu_arr[] = array(
  306. 'name' => 'Bank',
  307. 'link' => '/compta/bank/list.php?mainmenu=bank&amp;leftmenu=',
  308. 'title' => "MenuBankCash",
  309. 'level' => 0,
  310. 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal),
  311. 'target' => $atarget,
  312. 'mainmenu' => "bank",
  313. 'leftmenu' => '',
  314. 'position' => 52,
  315. 'id' => $id,
  316. 'idsel' => 'bank',
  317. 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "bank") ? 'class="tmenusel"' : 'class="tmenu"',
  318. 'prefix' => img_picto('', 'bank_account', 'class="fa-fw paddingright pictofixedwidth"'),
  319. 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "bank") ? 0 : 1),
  320. 'loadLangs' => array("compta", "banks"),
  321. 'submenus' => array(),
  322. );
  323. // Accounting
  324. $tmpentry = array(
  325. 'enabled'=>(isModEnabled('comptabilite') || isModEnabled('accounting') || isModEnabled('asset') || isModEnabled('intracommreport')),
  326. 'perms'=>($user->hasRight('compta', 'resultat', 'lire') || $user->hasRight('accounting', 'comptarapport', 'lire') || $user->hasRight('accounting', 'mouvements', 'lire') || $user->hasRight('asset', 'read') || $user->hasRight('intracommreport', 'read')),
  327. 'module'=>'comptabilite|accounting|asset|intracommreport'
  328. );
  329. $menu_arr[] = array(
  330. 'name' => 'Accounting',
  331. 'link' => '/accountancy/index.php?mainmenu=accountancy&amp;leftmenu=',
  332. 'title' => "MenuAccountancy",
  333. 'level' => 0,
  334. 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal),
  335. 'target' => $atarget,
  336. 'mainmenu' => "accountancy",
  337. 'leftmenu' => '',
  338. 'position' => 54,
  339. 'id' => $id,
  340. 'idsel' => 'accountancy',
  341. 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "accountancy") ? 'class="tmenusel"' : 'class="tmenu"',
  342. 'prefix' => img_picto('', 'accountancy', 'class="fa-fw paddingright pictofixedwidth"'),
  343. 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "accountancy") ? 0 : 1),
  344. 'loadLangs' => array("compta", "accountancy", "assets", "intracommreport"),
  345. 'submenus' => array(),
  346. );
  347. // HRM
  348. $tmpentry = array(
  349. 'enabled'=>(isModEnabled('hrm') || (isModEnabled('holiday')) || isModEnabled('deplacement') || isModEnabled('expensereport') || isModEnabled('recruitment')),
  350. 'perms'=>($user->hasRight('user', 'user', 'lire') || $user->hasRight('holiday', 'read') || $user->hasRight('deplacement', 'lire') || $user->hasRight('expensereport', 'lire') || $user->hasRight('recruitment', 'recruitmentjobposition', 'read')),
  351. 'module'=>'hrm|holiday|deplacement|expensereport|recruitment'
  352. );
  353. $menu_arr[] = array(
  354. 'name' => 'HRM',
  355. 'link' => '/hrm/index.php?mainmenu=hrm&amp;leftmenu=',
  356. 'title' => "HRM",
  357. 'level' => 0,
  358. 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal),
  359. 'target' => $atarget,
  360. 'mainmenu' => "hrm",
  361. 'leftmenu' => '',
  362. 'position' => 80,
  363. 'id' => $id,
  364. 'idsel' => 'hrm',
  365. 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "hrm") ? 'class="tmenusel"' : 'class="tmenu"',
  366. 'prefix' => img_picto('', 'hrm', 'class="fa-fw paddingright pictofixedwidth"'),
  367. 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "hrm") ? 0 : 1),
  368. 'loadLangs' => array("hrm", "holiday"),
  369. 'submenus' => array(),
  370. );
  371. // Tickets and knowledge base
  372. $tmpentry = array(
  373. 'enabled'=>(isModEnabled('ticket') || isModEnabled('knowledgemanagement')),
  374. 'perms'=>($user->hasRight('ticket', 'read') || $user->hasRight('knowledgemanagement', 'knowledgerecord', 'read')),
  375. 'module'=>'ticket|knowledgemanagement'
  376. );
  377. $link = '';
  378. if (isModEnabled('ticket')) {
  379. $link = '/ticket/index.php?mainmenu=ticket&amp;leftmenu=';
  380. } else {
  381. $link = '/knowledgemanagement/knowledgerecord_list.php?mainmenu=ticket&amp;leftmenu=';
  382. }
  383. $menu_arr[] = array(
  384. 'name' => 'Ticket',
  385. 'link' => $link,
  386. 'title' => "Tickets",
  387. 'level' => 0,
  388. 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal),
  389. 'target' => $atarget,
  390. 'mainmenu' => "ticket",
  391. 'leftmenu' => '',
  392. 'position' => 88,
  393. 'id' => $id,
  394. 'idsel' => 'ticket',
  395. 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "ticket") ? 'class="tmenusel"' : 'class="tmenu"',
  396. 'prefix' => img_picto('', 'ticket', 'class="fa-fw paddingright pictofixedwidth"'),
  397. 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "ticket") ? 0 : 1),
  398. 'loadLangs' => array("ticket", "knowledgemanagement"),
  399. 'submenus' => array(),
  400. );
  401. // Tools
  402. $tmpentry = array(
  403. 'enabled'=>1,
  404. 'perms'=>1,
  405. 'module'=>''
  406. );
  407. $menu_arr[] = array(
  408. 'name' => 'Tools',
  409. 'link' => '/core/tools.php?mainmenu=tools&amp;leftmenu=',
  410. 'title' => "Tools",
  411. 'level' => 0,
  412. 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal),
  413. 'target' => $atarget,
  414. 'mainmenu' => "tools",
  415. 'leftmenu' => '',
  416. 'position' => 90,
  417. 'id' => $id,
  418. 'idsel' => 'tools',
  419. 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "tools") ? 'class="tmenusel"' : 'class="tmenu"',
  420. 'prefix' => img_picto('', 'tools', 'class="fa-fw paddingright pictofixedwidth"'),
  421. 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "tools") ? 0 : 1),
  422. 'loadLangs' => array("other"),
  423. 'submenus' => array(),
  424. );
  425. // Add menus
  426. foreach ($menu_arr as $key => $smenu) {
  427. $smenu = (object) $smenu;
  428. if ($smenu->enabled) {
  429. if ($smenu->session) {
  430. $_SESSION['idmenu'] = '';
  431. }
  432. // Load Langue
  433. if (!empty($smenu->loadLangs)) {
  434. $langs->loadLangs($smenu->loadLangs);
  435. }
  436. // Trans title
  437. $mtitle = '';
  438. if (is_array($smenu->title)) {
  439. foreach ($smenu->title as $item) {
  440. $mtitle .= $langs->trans($item);
  441. }
  442. } else {
  443. $mtitle = $langs->trans($smenu->title);
  444. }
  445. // Add item
  446. $menu->add($smenu->link, $mtitle, $smenu->level, $smenu->enabled, $smenu->target, $smenu->mainmenu, $smenu->leftmenu, $smenu->position, $smenu->id, $smenu->idsel, $smenu->classname, $smenu->prefix);
  447. }
  448. }
  449. // Show personalized menus
  450. $menuArbo = new Menubase($db, 'eldy');
  451. $newTabMenu = $menuArbo->menuTopCharger('', '', $type_user, 'eldy', $tabMenu); // Return tabMenu with only top entries
  452. $num = count($newTabMenu);
  453. for ($i = 0; $i < $num; $i++) {
  454. //var_dump($type_user.' '.$newTabMenu[$i]['url'].' '.$showmode.' '.$newTabMenu[$i]['perms']);
  455. $idsel = (empty($newTabMenu[$i]['mainmenu']) ? 'none' : $newTabMenu[$i]['mainmenu']);
  456. $newTabMenu[$i]['url'] = make_substitutions($newTabMenu[$i]['url'], $substitarray);
  457. // url = url from host, shorturl = relative path into dolibarr sources
  458. $url = $shorturl = $newTabMenu[$i]['url'];
  459. if (!preg_match("/^(http:\/\/|https:\/\/)/i", $newTabMenu[$i]['url'])) { // Do not change url content for external links
  460. $tmp = explode('?', $newTabMenu[$i]['url'], 2);
  461. $url = $shorturl = $tmp[0];
  462. $param = (isset($tmp[1]) ? $tmp[1] : '');
  463. if ((!preg_match('/mainmenu/i', $param)) || !preg_match('/leftmenu/i', $param)) {
  464. $param .= ($param ? '&' : '').'mainmenu='.$newTabMenu[$i]['mainmenu'].'&leftmenu=';
  465. }
  466. //$url.="idmenu=".$newTabMenu[$i]['rowid']; // Already done by menuLoad
  467. $url = dol_buildpath($url, 1).($param ? '?'.$param : '');
  468. //$shorturl = $shorturl.($param?'?'.$param:'');
  469. $shorturl = $url;
  470. if (DOL_URL_ROOT) {
  471. $shorturl = preg_replace('/^'.preg_quote(DOL_URL_ROOT, '/').'/', '', $shorturl);
  472. }
  473. }
  474. $showmode = isVisibleToUserType($type_user, $newTabMenu[$i], $listofmodulesforexternal);
  475. if ($showmode == 1) {
  476. // Define the class (top menu selected or not)
  477. if (!empty($_SESSION['idmenu']) && $newTabMenu[$i]['rowid'] == $_SESSION['idmenu']) {
  478. $classname = 'class="tmenusel"';
  479. } elseif (!empty($_SESSION["mainmenu"]) && $newTabMenu[$i]['mainmenu'] == $_SESSION["mainmenu"]) {
  480. $classname = 'class="tmenusel"';
  481. } else {
  482. $classname = 'class="tmenu"';
  483. }
  484. } elseif ($showmode == 2) {
  485. $classname = 'class="tmenu"';
  486. }
  487. $menu->add(
  488. $shorturl,
  489. $newTabMenu[$i]['titre'],
  490. 0,
  491. $showmode,
  492. ($newTabMenu[$i]['target'] ? $newTabMenu[$i]['target'] : $atarget),
  493. ($newTabMenu[$i]['mainmenu'] ? $newTabMenu[$i]['mainmenu'] : $newTabMenu[$i]['rowid']),
  494. ($newTabMenu[$i]['leftmenu'] ? $newTabMenu[$i]['leftmenu'] : ''),
  495. $newTabMenu[$i]['position'],
  496. $id,
  497. $idsel,
  498. $classname,
  499. $newTabMenu[$i]['prefix']
  500. );
  501. }
  502. // Sort on position
  503. $menu->liste = dol_sort_array($menu->liste, 'position');
  504. // Output menu entries
  505. // Show logo company
  506. if (empty($conf->global->MAIN_MENU_INVERT) && empty($noout) && !empty($conf->global->MAIN_SHOW_LOGO) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
  507. //$mysoc->logo_mini=(empty($conf->global->MAIN_INFO_SOCIETE_LOGO_MINI)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO_MINI);
  508. $mysoc->logo_squarred_mini = (empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI) ? '' : $conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI);
  509. $logoContainerAdditionalClass = 'backgroundforcompanylogo';
  510. if (!empty($conf->global->MAIN_INFO_SOCIETE_LOGO_NO_BACKGROUND)) {
  511. $logoContainerAdditionalClass = '';
  512. }
  513. if (!empty($mysoc->logo_squarred_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_squarred_mini)) {
  514. $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_squarred_mini);
  515. /*} elseif (!empty($mysoc->logo_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini))
  516. {
  517. $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_mini);
  518. }*/
  519. } else {
  520. $urllogo = DOL_URL_ROOT.'/theme/dolibarr_512x512_white.png';
  521. $logoContainerAdditionalClass = '';
  522. }
  523. $title = $langs->trans("GoIntoSetupToChangeLogo");
  524. print "\n".'<!-- Show logo on menu -->'."\n";
  525. print_start_menu_entry('companylogo', 'class="tmenu tmenucompanylogo nohover"', 1);
  526. print '<div class="center '.$logoContainerAdditionalClass.' menulogocontainer"><img class="mycompany" title="'.dol_escape_htmltag($title).'" alt="" src="'.$urllogo.'" style="max-width: 100px"></div>'."\n";
  527. print_end_menu_entry(4);
  528. }
  529. if (empty($noout)) {
  530. foreach ($menu->liste as $menuval) {
  531. print_start_menu_entry($menuval['idsel'], $menuval['classname'], $menuval['enabled']);
  532. print_text_menu_entry($menuval['titre'], $menuval['enabled'], (($menuval['url'] != '#' && !preg_match('/^(http:\/\/|https:\/\/)/i', $menuval['url'])) ? DOL_URL_ROOT:'').$menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target'] ? $menuval['target'] : $atarget));
  533. print_end_menu_entry($menuval['enabled']);
  534. }
  535. }
  536. $showmode = 1;
  537. if (empty($noout)) {
  538. print_start_menu_entry('', 'class="tmenuend"', $showmode);
  539. print_end_menu_entry($showmode);
  540. print_end_menu_array();
  541. }
  542. return 0;
  543. }
  544. /**
  545. * Output start menu array
  546. *
  547. * @return void
  548. */
  549. function print_start_menu_array()
  550. {
  551. global $conf;
  552. print '<div class="tmenudiv">';
  553. print '<ul role="navigation" class="tmenu"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '' : ' title="Top menu"').'>';
  554. }
  555. /**
  556. * Output start menu entry
  557. *
  558. * @param string $idsel Text
  559. * @param string $classname String to add a css class
  560. * @param int $showmode 0 = hide, 1 = allowed or 2 = not allowed
  561. * @return void
  562. */
  563. function print_start_menu_entry($idsel, $classname, $showmode)
  564. {
  565. if ($showmode) {
  566. print '<li '.$classname.' id="mainmenutd_'.$idsel.'">';
  567. //print '<div class="tmenuleft tmenusep"></div>';
  568. print '<div class="tmenucenter">';
  569. }
  570. }
  571. /**
  572. * Output menu entry
  573. *
  574. * @param string $text Text
  575. * @param int $showmode 0 = hide, 1 = allowed or 2 = not allowed
  576. * @param string $url Url
  577. * @param string $id Id
  578. * @param string $idsel Id sel
  579. * @param string $classname Class name
  580. * @param string $atarget Target
  581. * @return void
  582. */
  583. function print_text_menu_entry($text, $showmode, $url, $id, $idsel, $classname, $atarget)
  584. {
  585. global $conf, $langs;
  586. $classnameimg = str_replace('class="', 'class="tmenuimage ', $classname);
  587. $classnametxt = str_replace('class="', 'class="tmenulabel ', $classname);
  588. //$conf->global->THEME_TOPMENU_DISABLE_TEXT=1;
  589. if ($showmode == 1) {
  590. print '<a '.$classnameimg.' tabindex="-1" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').' title="'.dol_escape_htmltag($text).'">';
  591. print '<div class="'.$id.' '.$idsel.' topmenuimage"><span class="'.$id.' tmenuimageforpng" id="mainmenuspan_'.$idsel.'"></span></div>';
  592. print '</a>';
  593. if (empty($conf->global->THEME_TOPMENU_DISABLE_TEXT)) {
  594. print '<a '.$classnametxt.' id="mainmenua_'.$idsel.'" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').' title="'.dol_escape_htmltag($text).'">';
  595. print '<span class="mainmenuaspan">';
  596. print $text;
  597. print '</span>';
  598. print '</a>';
  599. }
  600. } elseif ($showmode == 2) {
  601. print '<div '.$classnameimg.' title="'.dol_escape_htmltag($text.' - '.$langs->trans("NotAllowed")).'">';
  602. print '<div class="'.$id.' '.$idsel.' topmenuimage tmenudisabled"><span class="'.$id.' tmenuimageforpng tmenudisabled" id="mainmenuspan_'.$idsel.'"></span></div>';
  603. print '</div>';
  604. if (empty($conf->global->THEME_TOPMENU_DISABLE_TEXT)) {
  605. print '<span '.$classnametxt.' id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($text.' - '.$langs->trans("NotAllowed")).'">';
  606. print '<span class="mainmenuaspan tmenudisabled">';
  607. print $text;
  608. print '</span>';
  609. print '</span>';
  610. }
  611. }
  612. }
  613. /**
  614. * Output end menu entry
  615. *
  616. * @param int $showmode 0 = hide, 1 = allowed or 2 = not allowed
  617. * @return void
  618. */
  619. function print_end_menu_entry($showmode)
  620. {
  621. if ($showmode) {
  622. print '</div></li>';
  623. }
  624. print "\n";
  625. }
  626. /**
  627. * Output menu array
  628. *
  629. * @return void
  630. */
  631. function print_end_menu_array()
  632. {
  633. print '</ul>';
  634. print '</div>';
  635. print "\n";
  636. }
  637. /**
  638. * Core function to output left menu eldy
  639. * Fill &$menu (example with $forcemainmenu='home' $forceleftmenu='all', return left menu tree of Home)
  640. *
  641. * @param DoliDB $db Database handler
  642. * @param array $menu_array_before Table of menu entries to show before entries of menu handler (menu->liste filled with menu->add)
  643. * @param array $menu_array_after Table of menu entries to show after entries of menu handler (menu->liste filled with menu->add)
  644. * @param array $tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty)
  645. * @param Menu $menu Object Menu to return back list of menu entries
  646. * @param int $noout Disable output (Initialise &$menu only).
  647. * @param string $forcemainmenu 'x'=Force mainmenu to mainmenu='x'
  648. * @param string $forceleftmenu 'all'=Force leftmenu to '' (= all). If value come being '', we change it to value in session and 'none' if not defined in session.
  649. * @param array $moredata An array with more data to output
  650. * @param int $type_user 0=Menu for backoffice, 1=Menu for front office
  651. * @return int Nb of menu entries
  652. */
  653. function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabMenu, &$menu, $noout = 0, $forcemainmenu = '', $forceleftmenu = '', $moredata = null, $type_user = 0)
  654. {
  655. global $user, $conf, $langs, $hookmanager;
  656. //var_dump($tabMenu);
  657. $newmenu = $menu;
  658. $mainmenu = ($forcemainmenu ? $forcemainmenu : $_SESSION["mainmenu"]);
  659. $leftmenu = ($forceleftmenu ? '' : (empty($_SESSION["leftmenu"]) ? 'none' : $_SESSION["leftmenu"]));
  660. global $usemenuhider;
  661. $usemenuhider = 0;
  662. if (is_array($moredata) && !empty($moredata['searchform'])) { // searchform can contains select2 code or link to show old search form or link to switch on search page
  663. print "\n";
  664. print "<!-- Begin SearchForm -->\n";
  665. print '<div id="blockvmenusearch" class="blockvmenusearch">'."\n";
  666. print $moredata['searchform'];
  667. print '</div>'."\n";
  668. print "<!-- End SearchForm -->\n";
  669. }
  670. if (is_array($moredata) && !empty($moredata['bookmarks'])) {
  671. print "\n";
  672. print "<!-- Begin Bookmarks -->\n";
  673. print '<div id="blockvmenubookmarks" class="blockvmenubookmarks">'."\n";
  674. print $moredata['bookmarks'];
  675. print '</div>'."\n";
  676. print "<!-- End Bookmarks -->\n";
  677. }
  678. $substitarray = getCommonSubstitutionArray($langs, 0, null, null);
  679. $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL);
  680. /**
  681. * We update newmenu with entries found into database
  682. * --------------------------------------------------
  683. */
  684. if ($mainmenu) { // If this is empty, loading hard coded menu and loading personalised menu will fail
  685. /*
  686. * Menu HOME
  687. */
  688. if ($mainmenu == 'home') {
  689. get_left_menu_home($mainmenu, $newmenu, $usemenuhider, $leftmenu, $type_user);
  690. }
  691. /*
  692. * Menu THIRDPARTIES
  693. */
  694. if ($mainmenu == 'companies') {
  695. get_left_menu_thridparties($mainmenu, $newmenu, $usemenuhider, $leftmenu, $type_user);
  696. }
  697. /*
  698. * Menu COMMERCIAL (propal, commande, supplier_proposal, supplier_order, contrat, ficheinter)
  699. */
  700. if ($mainmenu == 'commercial') {
  701. get_left_menu_commercial($mainmenu, $newmenu, $usemenuhider, $leftmenu, $type_user);
  702. }
  703. /*
  704. * Menu COMPTA-FINANCIAL
  705. */
  706. if ($mainmenu == 'billing') {
  707. get_left_menu_billing($mainmenu, $newmenu, $usemenuhider, $leftmenu, $type_user);
  708. }
  709. /*
  710. * Menu COMPTA-FINANCIAL
  711. */
  712. if ($mainmenu == 'accountancy') {
  713. get_left_menu_accountancy($mainmenu, $newmenu, $usemenuhider, $leftmenu, $type_user);
  714. }
  715. /*
  716. * Menu BANK
  717. */
  718. if ($mainmenu == 'bank') {
  719. get_left_menu_bank($mainmenu, $newmenu, $usemenuhider, $leftmenu, $type_user);
  720. }
  721. /*
  722. * Menu PRODUCTS-SERVICES
  723. */
  724. if ($mainmenu == 'products') {
  725. get_left_menu_products($mainmenu, $newmenu, $usemenuhider, $leftmenu, $type_user);
  726. }
  727. /*
  728. * Menu PRODUCTS-SERVICES MRP - GPAO
  729. */
  730. if ($mainmenu == 'mrp') {
  731. get_left_menu_mrp($mainmenu, $newmenu, $usemenuhider, $leftmenu, $type_user);
  732. }
  733. /*
  734. * Menu PROJECTS
  735. */
  736. if ($mainmenu == 'project') {
  737. get_left_menu_projects($mainmenu, $newmenu, $usemenuhider, $leftmenu, $type_user);
  738. }
  739. /*
  740. * Menu HRM
  741. */
  742. if ($mainmenu == 'hrm') {
  743. get_left_menu_hrm($mainmenu, $newmenu, $usemenuhider, $leftmenu, $type_user);
  744. }
  745. /*
  746. * Menu TOOLS
  747. */
  748. if ($mainmenu == 'tools') {
  749. get_left_menu_tools($mainmenu, $newmenu, $usemenuhider, $leftmenu, $type_user);
  750. }
  751. /*
  752. * Menu MEMBERS
  753. */
  754. if ($mainmenu == 'members') {
  755. get_left_menu_members($mainmenu, $newmenu, $usemenuhider, $leftmenu, $type_user);
  756. }
  757. // Add personalized menus and modules menus
  758. //var_dump($newmenu->liste); //
  759. $menuArbo = new Menubase($db, 'eldy');
  760. $newmenu = $menuArbo->menuLeftCharger($newmenu, $mainmenu, $leftmenu, (empty($user->socid) ? 0 : 1), 'eldy', $tabMenu);
  761. //var_dump($newmenu->liste); //
  762. if (isModEnabled('ftp') && $mainmenu == 'ftp') { // Entry for FTP
  763. $MAXFTP = 20;
  764. $i = 1;
  765. while ($i <= $MAXFTP) {
  766. $paramkey = 'FTP_NAME_'.$i;
  767. //print $paramkey;
  768. if (!empty($conf->global->$paramkey)) {
  769. $link = "/ftp/index.php?idmenu=".$_SESSION["idmenu"]."&numero_ftp=".$i;
  770. $newmenu->add($link, dol_trunc($conf->global->$paramkey, 24));
  771. }
  772. $i++;
  773. }
  774. }
  775. }
  776. //var_dump($tabMenu);
  777. //var_dump($newmenu->liste);
  778. // Build final $menu_array = $menu_array_before +$newmenu->liste + $menu_array_after
  779. //var_dump($menu_array_before);exit;
  780. //var_dump($menu_array_after);exit;
  781. $menu_array = $newmenu->liste;
  782. if (is_array($menu_array_before)) {
  783. $menu_array = array_merge($menu_array_before, $menu_array);
  784. }
  785. if (is_array($menu_array_after)) {
  786. $menu_array = array_merge($menu_array, $menu_array_after);
  787. }
  788. //var_dump($menu_array);exit;
  789. if (!is_array($menu_array)) {
  790. return 0;
  791. }
  792. // Allow the $menu_array of the menu to be manipulated by modules
  793. $parameters = array(
  794. 'mainmenu' => $mainmenu,
  795. );
  796. $hook_items = $menu_array;
  797. $reshook = $hookmanager->executeHooks('menuLeftMenuItems', $parameters, $hook_items); // Note that $action and $object may have been modified by some hooks
  798. if (is_numeric($reshook)) {
  799. if ($reshook == 0 && !empty($hookmanager->resArray)) {
  800. $menu_array[] = $hookmanager->resArray; // add
  801. } elseif ($reshook == 1) {
  802. $menu_array = $hookmanager->resArray; // replace
  803. }
  804. // @todo Sort menu items by 'position' value
  805. // $position = array();
  806. // foreach ($menu_array as $key => $row) {
  807. // $position[$key] = $row['position'];
  808. // }
  809. // $array1_sort_order = SORT_ASC;
  810. // array_multisort($position, $array1_sort_order, $menu_array);
  811. }
  812. // TODO Use the position property in menu_array to reorder the $menu_array
  813. //var_dump($menu_array);
  814. /*$new_menu_array = array();
  815. $level=0; $cusor=0; $position=0;
  816. $nbentry = count($menu_array);
  817. while (findNextEntryForLevel($menu_array, $cursor, $position, $level))
  818. {
  819. $cursor++;
  820. }*/
  821. // Show menu
  822. $invert = empty($conf->global->MAIN_MENU_INVERT) ? "" : "invert";
  823. if (empty($noout)) {
  824. $altok = 0;
  825. $blockvmenuopened = false;
  826. $lastlevel0 = '';
  827. $num = count($menu_array);
  828. for ($i = 0; $i < $num; $i++) { // Loop on each menu entry
  829. $showmenu = true;
  830. if (!empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($menu_array[$i]['enabled'])) {
  831. $showmenu = false;
  832. }
  833. // Begin of new left menu block
  834. if (empty($menu_array[$i]['level']) && $showmenu) {
  835. $altok++;
  836. $blockvmenuopened = true;
  837. $lastopened = true;
  838. for ($j = ($i + 1); $j < $num; $j++) {
  839. if (empty($menu_array[$j]['level'])) {
  840. $lastopened = false;
  841. }
  842. }
  843. if ($altok % 2 == 0) {
  844. print '<div class="blockvmenu blockvmenuimpair'.$invert.($lastopened ? ' blockvmenulast' : '').($altok == 1 ? ' blockvmenufirst' : '').'">'."\n";
  845. } else {
  846. print '<div class="blockvmenu blockvmenupair'.$invert.($lastopened ? ' blockvmenulast' : '').($altok == 1 ? ' blockvmenufirst' : '').'">'."\n";
  847. }
  848. }
  849. // Add tabulation
  850. $tabstring = '';
  851. $tabul = ($menu_array[$i]['level'] - 1);
  852. if ($tabul > 0) {
  853. for ($j = 0; $j < $tabul; $j++) {
  854. $tabstring .= '&nbsp;&nbsp;&nbsp;';
  855. }
  856. }
  857. // $menu_array[$i]['url'] can be a relative url, a full external url. We try substitution
  858. $menu_array[$i]['url'] = make_substitutions($menu_array[$i]['url'], $substitarray);
  859. $url = $shorturl = $shorturlwithoutparam = $menu_array[$i]['url'];
  860. if (!preg_match("/^(http:\/\/|https:\/\/)/i", $menu_array[$i]['url'])) {
  861. $tmp = explode('?', $menu_array[$i]['url'], 2);
  862. $url = $shorturl = $tmp[0];
  863. $param = (isset($tmp[1]) ? $tmp[1] : ''); // params in url of the menu link
  864. // Complete param to force leftmenu to '' to close open menu when we click on a link with no leftmenu defined.
  865. if ((!preg_match('/mainmenu/i', $param)) && (!preg_match('/leftmenu/i', $param)) && !empty($menu_array[$i]['mainmenu'])) {
  866. $param .= ($param ? '&' : '').'mainmenu='.$menu_array[$i]['mainmenu'].'&leftmenu=';
  867. }
  868. if ((!preg_match('/mainmenu/i', $param)) && (!preg_match('/leftmenu/i', $param)) && empty($menu_array[$i]['mainmenu'])) {
  869. $param .= ($param ? '&' : '').'leftmenu=';
  870. }
  871. //$url.="idmenu=".$menu_array[$i]['rowid']; // Already done by menuLoad
  872. $url = dol_buildpath($url, 1).($param ? '?'.$param : '');
  873. $shorturlwithoutparam = $shorturl;
  874. $shorturl = $shorturl.($param ? '?'.$param : '');
  875. }
  876. print '<!-- Process menu entry with mainmenu='.$menu_array[$i]['mainmenu'].', leftmenu='.$menu_array[$i]['leftmenu'].', level='.$menu_array[$i]['level'].' enabled='.$menu_array[$i]['enabled'].', position='.$menu_array[$i]['position'].' -->'."\n";
  877. // Menu level 0
  878. if ($menu_array[$i]['level'] == 0) {
  879. if ($menu_array[$i]['enabled']) { // Enabled so visible
  880. print '<div class="menu_titre">'.$tabstring;
  881. if ($shorturlwithoutparam) {
  882. print '<a class="vmenu" title="'.dol_escape_htmltag(dol_string_nohtmltag($menu_array[$i]['titre'])).'" href="'.$url.'"'.($menu_array[$i]['target'] ? ' target="'.$menu_array[$i]['target'].'"' : '').'>';
  883. } else {
  884. print '<span class="vmenu">';
  885. }
  886. print ($menu_array[$i]['prefix'] ? $menu_array[$i]['prefix'] : '').$menu_array[$i]['titre'];
  887. if ($shorturlwithoutparam) {
  888. print '</a>';
  889. } else {
  890. print '</span>';
  891. }
  892. print '</div>'."\n";
  893. $lastlevel0 = 'enabled';
  894. } elseif ($showmenu) { // Not enabled but visible (so greyed)
  895. print '<div class="menu_titre">'.$tabstring;
  896. print '<span class="vmenudisabled">';
  897. print ($menu_array[$i]['prefix'] ? $menu_array[$i]['prefix'] : '').$menu_array[$i]['titre'];
  898. print '</span>';
  899. print '</div>'."\n";
  900. $lastlevel0 = 'greyed';
  901. } else {
  902. $lastlevel0 = 'hidden';
  903. }
  904. if ($showmenu) {
  905. print '<div class="menu_top"></div>'."\n";
  906. }
  907. }
  908. // Menu level > 0
  909. if ($menu_array[$i]['level'] > 0) {
  910. $cssmenu = '';
  911. if ($menu_array[$i]['url']) {
  912. $cssmenu = ' menu_contenu'.dol_string_nospecial(preg_replace('/\.php.*$/', '', $menu_array[$i]['url']));
  913. }
  914. if ($menu_array[$i]['enabled'] && $lastlevel0 == 'enabled') {
  915. // Enabled so visible, except if parent was not enabled.
  916. print '<div class="menu_contenu'.$cssmenu.'">';
  917. print $tabstring;
  918. if ($shorturlwithoutparam) {
  919. print '<a class="vsmenu" title="'.dol_escape_htmltag(dol_string_nohtmltag($menu_array[$i]['titre'])).'" href="'.$url.'"'.($menu_array[$i]['target'] ? ' target="'.$menu_array[$i]['target'].'"' : '').'>';
  920. } else {
  921. print '<span class="vsmenu" title="'.dol_escape_htmltag($menu_array[$i]['titre']).'">';
  922. }
  923. print $menu_array[$i]['titre'];
  924. if ($shorturlwithoutparam) {
  925. print '</a>';
  926. } else {
  927. print '</span>';
  928. }
  929. // If title is not pure text and contains a table, no carriage return added
  930. if (!strstr($menu_array[$i]['titre'], '<table')) {
  931. print '<br>';
  932. }
  933. print '</div>'."\n";
  934. } elseif ($showmenu && $lastlevel0 == 'enabled') {
  935. // Not enabled but visible (so greyed), except if parent was not enabled.
  936. print '<div class="menu_contenu'.$cssmenu.'">';
  937. print $tabstring;
  938. print '<span class="vsmenudisabled vsmenudisabledmargin">'.$menu_array[$i]['titre'].'</span><br>';
  939. print '</div>'."\n";
  940. }
  941. }
  942. // If next is a new block or if there is nothing after
  943. if (empty($menu_array[$i + 1]['level'])) { // End menu block
  944. if ($showmenu) {
  945. print '<div class="menu_end"></div>'."\n";
  946. }
  947. if ($blockvmenuopened) {
  948. print '</div>'."\n";
  949. $blockvmenuopened = false;
  950. }
  951. }
  952. }
  953. if ($altok) {
  954. print '<div class="blockvmenuend"></div>'; // End menu block
  955. }
  956. }
  957. return count($menu_array);
  958. }
  959. /**
  960. * Get left Menu HOME
  961. *
  962. * @param string $mainmenu Main menu
  963. * @param Menu $newmenu Object Menu to return back list of menu entries
  964. * @param string $usemenuhider Use menu hider
  965. * @param string $leftmenu Left menu
  966. * @param int $type_user Type of user
  967. * @return void
  968. */
  969. function get_left_menu_home($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0)
  970. {
  971. global $user, $conf, $langs;
  972. if ($mainmenu == 'home') {
  973. $langs->load("users");
  974. // Home - dashboard
  975. $newmenu->add("/index.php?mainmenu=home&amp;leftmenu=home", $langs->trans("MyDashboard"), 0, 1, '', $mainmenu, 'home', 0, '', '', '', '<i class="fa fa-bar-chart fa-fw paddingright pictofixedwidth"></i>');
  976. // Setup
  977. $newmenu->add("/admin/index.php?mainmenu=home&amp;leftmenu=setup", $langs->trans("Setup"), 0, $user->admin, '', $mainmenu, 'setup', 0, '', '', '', '<i class="fa fa-tools fa-fw paddingright pictofixedwidth"></i>');
  978. if ($usemenuhider || empty($leftmenu) || $leftmenu == "setup") {
  979. $nbmodulesnotautoenabled = count($conf->modules);
  980. if (in_array('fckeditor', $conf->modules)) $nbmodulesnotautoenabled--;
  981. if (in_array('export', $conf->modules)) $nbmodulesnotautoenabled--;
  982. if (in_array('import', $conf->modules)) $nbmodulesnotautoenabled--;
  983. // Load translation files required by the page
  984. $langs->loadLangs(array("admin", "help"));
  985. $warnpicto = '';
  986. if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY) || !empty($conf->global->MAIN_INFO_SOCIETE_SETUP_TODO_WARNING)) {
  987. $langs->load("errors");
  988. $warnpicto = img_warning($langs->trans("WarningMandatorySetupNotComplete"));
  989. }
  990. $newmenu->add("/admin/company.php?mainmenu=home", $langs->trans("MenuCompanySetup").$warnpicto, 1);
  991. $warnpicto = '';
  992. if ($nbmodulesnotautoenabled <= getDolGlobalInt('MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING', 1)) { // If only user module enabled
  993. $langs->load("errors");
  994. $warnpicto = img_warning($langs->trans("WarningMandatorySetupNotComplete"));
  995. }
  996. $newmenu->add("/admin/modules.php?mainmenu=home", $langs->trans("Modules").$warnpicto, 1);
  997. $newmenu->add("/admin/ihm.php?mainmenu=home", $langs->trans("GUISetup"), 1);
  998. $newmenu->add("/admin/menus.php?mainmenu=home", $langs->trans("Menus"), 1);
  999. $newmenu->add("/admin/translation.php?mainmenu=home", $langs->trans("Translation"), 1);
  1000. $newmenu->add("/admin/defaultvalues.php?mainmenu=home", $langs->trans("DefaultValues"), 1);
  1001. $newmenu->add("/admin/boxes.php?mainmenu=home", $langs->trans("Boxes"), 1);
  1002. $newmenu->add("/admin/delais.php?mainmenu=home", $langs->trans("MenuWarnings"), 1);
  1003. $newmenu->add("/admin/security_other.php?mainmenu=home", $langs->trans("Security"), 1);
  1004. $newmenu->add("/admin/limits.php?mainmenu=home", $langs->trans("MenuLimits"), 1);
  1005. $newmenu->add("/admin/pdf.php?mainmenu=home", $langs->trans("PDF"), 1);
  1006. $warnpicto = '';
  1007. if (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail' && empty($conf->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) {
  1008. $langs->load("errors");
  1009. $warnpicto = img_warning($langs->trans("WarningPHPMailD"));
  1010. }
  1011. if (!empty($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmail')) && empty($conf->global->MAIN_MAIL_SMTP_SERVER)) {
  1012. $langs->load("errors");
  1013. $warnpicto = img_warning($langs->trans("ErrorSetupOfEmailsNotComplete"));
  1014. }
  1015. $newmenu->add("/admin/mails.php?mainmenu=home", $langs->trans("Emails").$warnpicto, 1);
  1016. $newmenu->add("/admin/sms.php?mainmenu=home", $langs->trans("SMS"), 1);
  1017. $newmenu->add("/admin/dict.php?mainmenu=home", $langs->trans("Dictionary"), 1);
  1018. $newmenu->add("/admin/const.php?mainmenu=home", $langs->trans("OtherSetup"), 1);
  1019. }
  1020. // System tools
  1021. $newmenu->add("/admin/tools/index.php?mainmenu=home&amp;leftmenu=admintools", $langs->trans("AdminTools"), 0, $user->admin, '', $mainmenu, 'admintools', 0, '', '', '', '<i class="fa fa-server fa-fw paddingright pictofixedwidth"></i>');
  1022. if ($usemenuhider || empty($leftmenu) || preg_match('/^admintools/', $leftmenu)) {
  1023. // Load translation files required by the page
  1024. $langs->loadLangs(array('admin', 'help'));
  1025. $newmenu->add('/admin/system/dolibarr.php?mainmenu=home&amp;leftmenu=admintools_info', $langs->trans('InfoDolibarr'), 1);
  1026. if ($usemenuhider || empty($leftmenu) || $leftmenu == 'admintools_info') {
  1027. $newmenu->add('/admin/system/modules.php?mainmenu=home&amp;leftmenu=admintools_info', $langs->trans('Modules'), 2);
  1028. $newmenu->add('/admin/triggers.php?mainmenu=home&amp;leftmenu=admintools_info', $langs->trans('Triggers'), 2);
  1029. $newmenu->add('/admin/system/filecheck.php?mainmenu=home&amp;leftmenu=admintools_info', $langs->trans('FileCheck'), 2);
  1030. }
  1031. $newmenu->add('/admin/system/browser.php?mainmenu=home&amp;leftmenu=admintools', $langs->trans('InfoBrowser'), 1);
  1032. $newmenu->add('/admin/system/os.php?mainmenu=home&amp;leftmenu=admintools', $langs->trans('InfoOS'), 1);
  1033. $newmenu->add('/admin/system/web.php?mainmenu=home&amp;leftmenu=admintools', $langs->trans('InfoWebServer'), 1);
  1034. $newmenu->add('/admin/system/phpinfo.php?mainmenu=home&amp;leftmenu=admintools', $langs->trans('InfoPHP'), 1);
  1035. $newmenu->add('/admin/system/database.php?mainmenu=home&amp;leftmenu=admintools', $langs->trans('InfoDatabase'), 1);
  1036. $newmenu->add("/admin/system/perf.php?mainmenu=home&amp;leftmenu=admintools", $langs->trans("InfoPerf"), 1);
  1037. $newmenu->add("/admin/system/security.php?mainmenu=home&amp;leftmenu=admintools", $langs->trans("InfoSecurity"), 1);
  1038. $newmenu->add("/admin/tools/dolibarr_export.php?mainmenu=home&amp;leftmenu=admintools", $langs->trans("Backup"), 1);
  1039. $newmenu->add("/admin/tools/dolibarr_import.php?mainmenu=home&amp;leftmenu=admintools", $langs->trans("Restore"), 1);
  1040. $newmenu->add("/admin/tools/update.php?mainmenu=home&amp;leftmenu=admintools", $langs->trans("MenuUpgrade"), 1);
  1041. $newmenu->add("/admin/tools/purge.php?mainmenu=home&amp;leftmenu=admintools", $langs->trans("Purge"), 1);
  1042. $newmenu->add("/admin/tools/listevents.php?mainmenu=home&amp;leftmenu=admintools", $langs->trans("Audit"), 1);
  1043. $newmenu->add("/admin/tools/listsessions.php?mainmenu=home&amp;leftmenu=admintools", $langs->trans("Sessions"), 1);
  1044. $newmenu->add('/admin/system/about.php?mainmenu=home&amp;leftmenu=admintools', $langs->trans('ExternalResources'), 1);
  1045. if (isModEnabled('product') || isModEnabled('service')) {
  1046. $langs->load("products");
  1047. $newmenu->add("/product/admin/product_tools.php?mainmenu=home&amp;leftmenu=admintools", $langs->trans("ProductVatMassChange"), 1, $user->admin);
  1048. }
  1049. }
  1050. $newmenu->add("/user/home.php?leftmenu=users", $langs->trans("MenuUsersAndGroups"), 0, $user->hasRight('user', 'user', 'read'), '', $mainmenu, 'users', 0, '', '', '', img_picto('', 'user', 'class="paddingright pictofixedwidth"'));
  1051. if ($user->hasRight('user', 'user', 'read')) {
  1052. if ($usemenuhider || empty($leftmenu) || $leftmenu == "users") {
  1053. $newmenu->add("", $langs->trans("Users"), 1, $user->hasRight('user', 'user', 'lire') || $user->admin);
  1054. $newmenu->add("/user/card.php?leftmenu=users&action=create", $langs->trans("NewUser"), 2, ($user->hasRight("user", "user", "write") || $user->admin) && !(isModEnabled('multicompany') && $conf->entity > 1 && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)), '', 'home');
  1055. $newmenu->add("/user/list.php?leftmenu=users", $langs->trans("ListOfUsers"), 2, $user->hasRight('user', 'user', 'lire') || $user->admin);
  1056. $newmenu->add("/user/hierarchy.php?leftmenu=users", $langs->trans("HierarchicView"), 2, $user->hasRight('user', 'user', 'lire') || $user->admin);
  1057. if (isModEnabled('categorie')) {
  1058. $langs->load("categories");
  1059. $newmenu->add("/categories/index.php?leftmenu=users&type=7", $langs->trans("UsersCategoriesShort"), 2, $user->hasRight('categorie', 'lire'), '', $mainmenu, 'cat');
  1060. }
  1061. $newmenu->add("", $langs->trans("Groups"), 1, ($user->hasRight('user', 'user', 'lire') || $user->admin) && !(isModEnabled('multicompany') && $conf->entity > 1 && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)));
  1062. $newmenu->add("/user/group/card.php?leftmenu=users&action=create", $langs->trans("NewGroup"), 2, ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) ? $user->hasRight("user", "group_advance", "create") : $user->hasRight("user", "user", "create")) || $user->admin) && !(isModEnabled('multicompany') && $conf->entity > 1 && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)));
  1063. $newmenu->add("/user/group/list.php?leftmenu=users", $langs->trans("ListOfGroups"), 2, ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) ? $user->hasRight('user', 'group_advance', 'read') : $user->hasRight('user', 'user', 'lire')) || $user->admin) && !(isModEnabled('multicompany') && $conf->entity > 1 && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)));
  1064. }
  1065. }
  1066. }
  1067. }
  1068. /**
  1069. * Get left Menu THIRDPARTIES
  1070. *
  1071. * @param string $mainmenu Main menu
  1072. * @param Menu $newmenu Object Menu to return back list of menu entries
  1073. * @param string $usemenuhider Use menu hider
  1074. * @param string $leftmenu Left menu
  1075. * @param int $type_user Type of targeted user for menu
  1076. * @return void
  1077. */
  1078. function get_left_menu_thridparties($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0)
  1079. {
  1080. global $user, $conf, $langs;
  1081. if ($mainmenu == 'companies') {
  1082. // Societes
  1083. if (isModEnabled('societe')) {
  1084. $langs->load("companies");
  1085. $newmenu->add("/societe/index.php?leftmenu=thirdparties", $langs->trans("ThirdParty"), 0, $user->hasRight('societe', 'lire'), '', $mainmenu, 'thirdparties', 0, '', '', '', img_picto('', 'company', 'class="paddingright pictofixedwidth"'));
  1086. if ($user->hasRight('societe', 'creer')) {
  1087. $newmenu->add("/societe/card.php?action=create", $langs->trans("MenuNewThirdParty"), 1);
  1088. if (!$conf->use_javascript_ajax) {
  1089. $newmenu->add("/societe/card.php?action=create&amp;private=1", $langs->trans("MenuNewPrivateIndividual"), 1);
  1090. }
  1091. }
  1092. }
  1093. $newmenu->add("/societe/list.php?leftmenu=thirdparties", $langs->trans("List"), 1);
  1094. // Prospects
  1095. if (isModEnabled('societe') && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
  1096. $langs->load("commercial");
  1097. $newmenu->add("/societe/list.php?type=p&amp;leftmenu=prospects", $langs->trans("ListProspectsShort"), 2, $user->hasRight('societe', 'lire'), '', $mainmenu, 'prospects');
  1098. /* no more required, there is a filter that can do more
  1099. if ($usemenuhider || empty($leftmenu) || $leftmenu=="prospects") $newmenu->add("/societe/list.php?type=p&amp;sortfield=s.datec&amp;sortorder=desc&amp;begin=&amp;search_stcomm=-1", $langs->trans("LastProspectDoNotContact"), 2, $user->hasRight('societe', 'lire'));
  1100. if ($usemenuhider || empty($leftmenu) || $leftmenu=="prospects") $newmenu->add("/societe/list.php?type=p&amp;sortfield=s.datec&amp;sortorder=desc&amp;begin=&amp;search_stcomm=0", $langs->trans("LastProspectNeverContacted"), 2, $user->hasRight('societe', 'lire'));
  1101. if ($usemenuhider || empty($leftmenu) || $leftmenu=="prospects") $newmenu->add("/societe/list.php?type=p&amp;sortfield=s.datec&amp;sortorder=desc&amp;begin=&amp;search_stcomm=1", $langs->trans("LastProspectToContact"), 2, $user->hasRight('societe', 'lire'));
  1102. if ($usemenuhider || empty($leftmenu) || $leftmenu=="prospects") $newmenu->add("/societe/list.php?type=p&amp;sortfield=s.datec&amp;sortorder=desc&amp;begin=&amp;search_stcomm=2", $langs->trans("LastProspectContactInProcess"), 2, $user->hasRight('societe', 'lire'));
  1103. if ($usemenuhider || empty($leftmenu) || $leftmenu=="prospects") $newmenu->add("/societe/list.php?type=p&amp;sortfield=s.datec&amp;sortorder=desc&amp;begin=&amp;search_stcomm=3", $langs->trans("LastProspectContactDone"), 2, $user->hasRight('societe', 'lire'));
  1104. */
  1105. $newmenu->add("/societe/card.php?leftmenu=prospects&amp;action=create&amp;type=p", $langs->trans("MenuNewProspect"), 3, $user->hasRight('societe', 'creer'));
  1106. }
  1107. // Customers/Prospects
  1108. if (isModEnabled('societe') && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
  1109. $langs->load("commercial");
  1110. $newmenu->add("/societe/list.php?type=c&amp;leftmenu=customers", $langs->trans("ListCustomersShort"), 2, $user->hasRight('societe', 'lire'), '', $mainmenu, 'customers');
  1111. $newmenu->add("/societe/card.php?leftmenu=customers&amp;action=create&amp;type=c", $langs->trans("MenuNewCustomer"), 3, $user->hasRight('societe', 'creer'));
  1112. }
  1113. // Suppliers
  1114. if (isModEnabled('societe') && (isModEnabled('supplier_order') || isModEnabled('supplier_invoice') || isModEnabled('supplier_proposal'))) {
  1115. $langs->load("suppliers");
  1116. $newmenu->add("/societe/list.php?type=f&amp;leftmenu=suppliers", $langs->trans("ListSuppliersShort"), 2, ($user->hasRight('fournisseur', 'lire') || $user->hasRight('supplier_order', 'lire') || $user->hasRight('supplier_invoice', 'lire') || $user->hasRight('supplier_proposal', 'lire')), '', $mainmenu, 'suppliers');
  1117. $newmenu->add("/societe/card.php?leftmenu=suppliers&amp;action=create&amp;type=f", $langs->trans("MenuNewSupplier"), 3, $user->hasRight('societe', 'creer') && ($user->hasRight('fournisseur', 'lire') || $user->hasRight('supplier_order', 'lire') || $user->hasRight('supplier_invoice', 'lire') || $user->hasRight('supplier_proposal', 'lire')));
  1118. }
  1119. // Categories
  1120. if (isModEnabled('categorie')) {
  1121. $langs->load("categories");
  1122. if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
  1123. // Categories prospects/customers
  1124. $menutoshow = $langs->trans("CustomersProspectsCategoriesShort");
  1125. if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
  1126. $menutoshow = $langs->trans("CustomersCategoriesShort");
  1127. }
  1128. if (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
  1129. $menutoshow = $langs->trans("ProspectsCategoriesShort");
  1130. }
  1131. $newmenu->add("/categories/index.php?leftmenu=cat&amp;type=2", $menutoshow, 1, $user->hasRight('categorie', 'lire'), '', $mainmenu, 'cat');
  1132. }
  1133. // Categories suppliers
  1134. if (isModEnabled('supplier_proposal') || isModEnabled('supplier_order') || isModEnabled('supplier_invoice')) {
  1135. $newmenu->add("/categories/index.php?leftmenu=catfournish&amp;type=1", $langs->trans("SuppliersCategoriesShort"), 1, $user->hasRight('categorie', 'lire'));
  1136. }
  1137. }
  1138. // Contacts
  1139. $newmenu->add("/societe/index.php?leftmenu=thirdparties", (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")), 0, $user->hasRight('societe', 'contact', 'lire'), '', $mainmenu, 'contacts', 0, '', '', '', img_picto('', 'contact', 'class="paddingright pictofixedwidth"'));
  1140. $newmenu->add("/contact/card.php?leftmenu=contacts&amp;action=create", (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("NewContact") : $langs->trans("NewContactAddress")), 1, $user->hasRight('societe', 'contact', 'creer'));
  1141. $newmenu->add("/contact/list.php?leftmenu=contacts", $langs->trans("List"), 1, $user->hasRight('societe', 'contact', 'lire'));
  1142. if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
  1143. $newmenu->add("/contact/list.php?leftmenu=contacts&type=p", $langs->trans("Prospects"), 2, $user->hasRight('societe', 'contact', 'lire'));
  1144. }
  1145. if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
  1146. $newmenu->add("/contact/list.php?leftmenu=contacts&type=c", $langs->trans("Customers"), 2, $user->hasRight('societe', 'contact', 'lire'));
  1147. }
  1148. if (isModEnabled('supplier_proposal') || isModEnabled('supplier_order') || isModEnabled('supplier_invoice')) {
  1149. $newmenu->add("/contact/list.php?leftmenu=contacts&type=f", $langs->trans("Suppliers"), 2, $user->hasRight('fournisseur', 'lire'));
  1150. }
  1151. $newmenu->add("/contact/list.php?leftmenu=contacts&type=o", $langs->trans("ContactOthers"), 2, $user->hasRight('societe', 'contact', 'lire'));
  1152. //$newmenu->add("/contact/list.php?userid=$user->id", $langs->trans("MyContacts"), 1, $user->hasRight('societe', 'contact', 'lire'));
  1153. // Categories
  1154. if (isModEnabled('categorie')) {
  1155. $langs->load("categories");
  1156. // Categories Contact
  1157. $newmenu->add("/categories/index.php?leftmenu=catcontact&amp;type=4", $langs->trans("ContactCategoriesShort"), 1, $user->hasRight('categorie', 'lire'), '', $mainmenu, 'cat');
  1158. }
  1159. }
  1160. }
  1161. /**
  1162. * Get left Menu COMMERCIAL (propal, commande, supplier_proposal, supplier_order, contrat, ficheinter)
  1163. *
  1164. * @param string $mainmenu Main menu
  1165. * @param Menu $newmenu Object Menu to return back list of menu entries
  1166. * @param string $usemenuhider Use menu hider
  1167. * @param string $leftmenu Left menu
  1168. * @param int $type_user Type of targeted user for menu
  1169. * @return void
  1170. */
  1171. function get_left_menu_commercial($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0)
  1172. {
  1173. global $user, $conf, $langs;
  1174. if ($mainmenu == 'commercial') {
  1175. $langs->load("companies");
  1176. // Customer proposal
  1177. if (isModEnabled('propal')) {
  1178. $langs->load("propal");
  1179. $newmenu->add("/comm/propal/index.php?leftmenu=propals", $langs->trans("Proposals"), 0, $user->hasRight('propal', 'read'), '', $mainmenu, 'propals', 100, '', '', '', img_picto('', 'propal', 'class="paddingright pictofixedwidth"'));
  1180. $newmenu->add("/comm/propal/card.php?action=create&amp;leftmenu=propals", $langs->trans("NewPropal"), 1, $user->hasRight('propal', 'write'));
  1181. $newmenu->add("/comm/propal/list.php?leftmenu=propals", $langs->trans("List"), 1, $user->hasRight('propal', 'read'));
  1182. if ($usemenuhider || empty($leftmenu) || $leftmenu == "propals") {
  1183. $newmenu->add("/comm/propal/list.php?leftmenu=propals&search_status=0", $langs->trans("PropalsDraft"), 2, $user->hasRight('propal', 'read'));
  1184. $newmenu->add("/comm/propal/list.php?leftmenu=propals&search_status=1", $langs->trans("PropalsOpened"), 2, $user->hasRight('propal', 'read'));
  1185. $newmenu->add("/comm/propal/list.php?leftmenu=propals&search_status=2", $langs->trans("PropalStatusSigned"), 2, $user->hasRight('propal', 'read'));
  1186. $newmenu->add("/comm/propal/list.php?leftmenu=propals&search_status=3", $langs->trans("PropalStatusNotSigned"), 2, $user->hasRight('propal', 'read'));
  1187. $newmenu->add("/comm/propal/list.php?leftmenu=propals&search_status=4", $langs->trans("PropalStatusBilled"), 2, $user->hasRight('propal', 'read'));
  1188. //$newmenu->add("/comm/propal/list.php?leftmenu=propals&search_status=2,3,4", $langs->trans("PropalStatusClosedShort"), 2, $user->hasRight('propal', 'read'));
  1189. }
  1190. $newmenu->add("/comm/propal/stats/index.php?leftmenu=propals", $langs->trans("Statistics"), 1, $user->hasRight('propal', 'read'));
  1191. }
  1192. // Customers orders
  1193. if (isModEnabled('commande')) {
  1194. $langs->load("orders");
  1195. $newmenu->add("/commande/index.php?leftmenu=orders", $langs->trans("CustomersOrders"), 0, $user->hasRight('commande', 'lire'), '', $mainmenu, 'orders', 200, '', '', '', img_picto('', 'order', 'class="paddingright pictofixedwidth"'));
  1196. $newmenu->add("/commande/card.php?action=create&amp;leftmenu=orders", $langs->trans("NewOrder"), 1, $user->hasRight('commande', 'creer'));
  1197. $newmenu->add("/commande/list.php?leftmenu=orders", $langs->trans("List"), 1, $user->hasRight('commande', 'lire'));
  1198. if ($usemenuhider || empty($leftmenu) || $leftmenu == "orders") {
  1199. $newmenu->add("/commande/list.php?leftmenu=orders&search_status=0", $langs->trans("StatusOrderDraftShort"), 2, $user->hasRight('commande', 'lire'));
  1200. $newmenu->add("/commande/list.php?leftmenu=orders&search_status=1", $langs->trans("StatusOrderValidated"), 2, $user->hasRight('commande', 'lire'));
  1201. if (isModEnabled('expedition')) {
  1202. $newmenu->add("/commande/list.php?leftmenu=orders&search_status=2", $langs->trans("StatusOrderSentShort"), 2, $user->hasRight('commande', 'lire'));
  1203. }
  1204. $newmenu->add("/commande/list.php?leftmenu=orders&search_status=3", $langs->trans("StatusOrderDelivered"), 2, $user->hasRight('commande', 'lire'));
  1205. //$newmenu->add("/commande/list.php?leftmenu=orders&search_status=4", $langs->trans("StatusOrderProcessed"), 2, $user->hasRight('commande', 'lire'));
  1206. $newmenu->add("/commande/list.php?leftmenu=orders&search_status=-1", $langs->trans("StatusOrderCanceledShort"), 2, $user->hasRight('commande', 'lire'));
  1207. }
  1208. if ($conf->global->MAIN_FEATURES_LEVEL >= 2 && empty($user->socid)) {
  1209. $newmenu->add("/commande/list_det.php?leftmenu=orders", $langs->trans("ListOrderLigne"), 1, $user->hasRight('commande', 'lire'));
  1210. }
  1211. $newmenu->add("/commande/stats/index.php?leftmenu=orders", $langs->trans("Statistics"), 1, $user->hasRight('commande', 'lire'));
  1212. }
  1213. // Supplier proposal
  1214. if (isModEnabled('supplier_proposal')) {
  1215. $langs->load("supplier_proposal");
  1216. $newmenu->add("/supplier_proposal/index.php?leftmenu=propals_supplier", $langs->trans("SupplierProposalsShort"), 0, $user->hasRight('supplier_proposal', 'lire'), '', $mainmenu, 'propals_supplier', 300, '', '', '', img_picto('', 'supplier_proposal', 'class="paddingright pictofixedwidth"'));
  1217. $newmenu->add("/supplier_proposal/card.php?action=create&amp;leftmenu=supplier_proposals", $langs->trans("SupplierProposalNew"), 1, $user->hasRight('supplier_proposal', 'creer'));
  1218. $newmenu->add("/supplier_proposal/list.php?leftmenu=supplier_proposals", $langs->trans("List"), 1, $user->hasRight('supplier_proposal', 'lire'));
  1219. $newmenu->add("/comm/propal/stats/index.php?leftmenu=supplier_proposals&amp;mode=supplier", $langs->trans("Statistics"), 1, $user->hasRight('supplier_proposal', 'lire'));
  1220. }
  1221. // Suppliers orders
  1222. if (isModEnabled('supplier_order')) {
  1223. $langs->load("orders");
  1224. $newmenu->add("/fourn/commande/index.php?leftmenu=orders_suppliers", $langs->trans("SuppliersOrders"), 0, $user->hasRight('fournisseur', 'commande', 'lire'), '', $mainmenu, 'orders_suppliers', 400, '', '', '', img_picto('', 'supplier_order', 'class="paddingright pictofixedwidth"'));
  1225. $newmenu->add("/fourn/commande/card.php?action=create&amp;leftmenu=orders_suppliers", $langs->trans("NewSupplierOrderShort"), 1, $user->hasRight('fournisseur', 'commande', 'creer'));
  1226. $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers", $langs->trans("List"), 1, $user->hasRight('fournisseur', 'commande', 'lire'));
  1227. if ($usemenuhider || empty($leftmenu) || $leftmenu == "orders_suppliers") {
  1228. $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=0", $langs->trans("StatusSupplierOrderDraftShort"), 2, $user->hasRight('fournisseur', 'commande', 'lire'));
  1229. if (empty($conf->global->SUPPLIER_ORDER_HIDE_VALIDATED)) {
  1230. $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=1", $langs->trans("StatusSupplierOrderValidated"), 2, $user->hasRight('fournisseur', 'commande', 'lire'));
  1231. }
  1232. $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=2", $langs->trans("StatusSupplierOrderApprovedShort"), 2, $user->hasRight('fournisseur', 'commande', 'lire'));
  1233. $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=3", $langs->trans("StatusSupplierOrderOnProcessShort"), 2, $user->hasRight('fournisseur', 'commande', 'lire'));
  1234. $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=4", $langs->trans("StatusSupplierOrderReceivedPartiallyShort"), 2, $user->hasRight('fournisseur', 'commande', 'lire'));
  1235. $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=5", $langs->trans("StatusSupplierOrderReceivedAll"), 2, $user->hasRight('fournisseur', 'commande', 'lire'));
  1236. $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=6,7", $langs->trans("StatusSupplierOrderCanceled"), 2, $user->hasRight('fournisseur', 'commande', 'lire'));
  1237. $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=9", $langs->trans("StatusSupplierOrderRefused"), 2, $user->hasRight('fournisseur', 'commande', 'lire'));
  1238. }
  1239. // Billed is another field. We should add instead a dedicated filter on list. if ($usemenuhider || empty($leftmenu) || $leftmenu=="orders_suppliers") $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&billed=1", $langs->trans("Billed"), 2, $user->hasRight('fournisseur', 'commande', 'lire'));
  1240. $newmenu->add("/commande/stats/index.php?leftmenu=orders_suppliers&amp;mode=supplier", $langs->trans("Statistics"), 1, $user->hasRight('fournisseur', 'commande', 'lire'));
  1241. }
  1242. // Contrat
  1243. if (isModEnabled('contrat')) {
  1244. $langs->load("contracts");
  1245. $newmenu->add("/contrat/index.php?leftmenu=contracts", $langs->trans("ContractsSubscriptions"), 0, $user->hasRight('contrat', 'lire'), '', $mainmenu, 'contracts', 2000, '', '', '', img_picto('', 'contract', 'class="paddingright pictofixedwidth"'));
  1246. $newmenu->add("/contrat/card.php?action=create&amp;leftmenu=contracts", $langs->trans("NewContractSubscription"), 1, $user->hasRight('contrat', 'creer'));
  1247. $newmenu->add("/contrat/list.php?leftmenu=contracts", $langs->trans("List"), 1, $user->hasRight('contrat', 'lire'));
  1248. $newmenu->add("/contrat/services_list.php?leftmenu=contracts", $langs->trans("MenuServices"), 1, $user->hasRight('contrat', 'lire'));
  1249. if ($usemenuhider || empty($leftmenu) || $leftmenu == "contracts") {
  1250. $newmenu->add("/contrat/services_list.php?leftmenu=contracts&amp;search_status=0", $langs->trans("MenuInactiveServices"), 2, $user->hasRight('contrat', 'lire'));
  1251. $newmenu->add("/contrat/services_list.php?leftmenu=contracts&amp;search_status=4", $langs->trans("MenuRunningServices"), 2, $user->hasRight('contrat', 'lire'));
  1252. $newmenu->add("/contrat/services_list.php?leftmenu=contracts&amp;search_status=4&amp;filter=expired", $langs->trans("MenuExpiredServices"), 2, $user->hasRight('contrat', 'lire'));
  1253. $newmenu->add("/contrat/services_list.php?leftmenu=contracts&amp;search_status=5", $langs->trans("MenuClosedServices"), 2, $user->hasRight('contrat', 'lire'));
  1254. }
  1255. }
  1256. // Interventions
  1257. if (isModEnabled('ficheinter')) {
  1258. $langs->load("interventions");
  1259. $newmenu->add("/fichinter/index.php?leftmenu=ficheinter", $langs->trans("Interventions"), 0, $user->hasRight('ficheinter', 'lire'), '', $mainmenu, 'ficheinter', 2200, '', '', '', img_picto('', 'intervention', 'class="paddingright pictofixedwidth"'));
  1260. $newmenu->add("/fichinter/card.php?action=create&amp;leftmenu=ficheinter", $langs->trans("NewIntervention"), 1, $user->hasRight('ficheinter', 'creer'), '', '', '', 201);
  1261. $newmenu->add("/fichinter/list.php?leftmenu=ficheinter", $langs->trans("List"), 1, $user->hasRight('ficheinter', 'lire'), '', '', '', 202);
  1262. if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
  1263. $newmenu->add("/fichinter/card-rec.php?leftmenu=ficheinter", $langs->trans("ListOfTemplates"), 1, $user->hasRight('ficheinter', 'lire'), '', '', '', 203);
  1264. }
  1265. $newmenu->add("/fichinter/stats/index.php?leftmenu=ficheinter", $langs->trans("Statistics"), 1, $user->hasRight('ficheinter', 'lire'));
  1266. }
  1267. }
  1268. }
  1269. /**
  1270. * Get left COMPTA-FINANCIAL
  1271. *
  1272. * @param string $mainmenu Main menu
  1273. * @param Menu $newmenu Object Menu to return back list of menu entries
  1274. * @param string $usemenuhider Use menu hider
  1275. * @param string $leftmenu Left menu
  1276. * @param int $type_user Type of targeted user for menu
  1277. * @return void
  1278. */
  1279. function get_left_menu_billing($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0)
  1280. {
  1281. global $user, $conf, $langs;
  1282. if ($mainmenu == 'billing') {
  1283. $langs->load("companies");
  1284. // Customers invoices
  1285. if (isModEnabled('facture')) {
  1286. $langs->load("bills");
  1287. $newmenu->add("/compta/facture/index.php?leftmenu=customers_bills", $langs->trans("BillsCustomers"), 0, $user->hasRight('facture', 'lire'), '', $mainmenu, 'customers_bills', 0, '', '', '', img_picto('', 'bill', 'class="paddingright pictofixedwidth"'));
  1288. $newmenu->add("/compta/facture/card.php?action=create", $langs->trans("NewBill"), 1, $user->hasRight('facture', 'creer'));
  1289. $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills", $langs->trans("List"), 1, $user->hasRight('facture', 'lire'), '', $mainmenu, 'customers_bills_list');
  1290. if ($usemenuhider || empty($leftmenu) || preg_match('/customers_bills(|_draft|_notpaid|_paid|_canceled)$/', $leftmenu)) {
  1291. $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills_draft&amp;search_status=0", $langs->trans("BillShortStatusDraft"), 2, $user->hasRight('facture', 'lire'));
  1292. $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills_notpaid&amp;search_status=1", $langs->trans("BillShortStatusNotPaid"), 2, $user->hasRight('facture', 'lire'));
  1293. $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills_paid&amp;search_status=2", $langs->trans("BillShortStatusPaid"), 2, $user->hasRight('facture', 'lire'));
  1294. $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills_canceled&amp;search_status=3", $langs->trans("BillShortStatusCanceled"), 2, $user->hasRight('facture', 'lire'));
  1295. }
  1296. $newmenu->add("/compta/facture/invoicetemplate_list.php?leftmenu=customers_bills_templates", $langs->trans("ListOfTemplates"), 1, $user->hasRight('facture', 'creer'), '', $mainmenu, 'customers_bills_templates'); // No need to see recurring invoices, if user has no permission to create invoice.
  1297. $newmenu->add("/compta/paiement/list.php?leftmenu=customers_bills_payment", $langs->trans("Payments"), 1, $user->hasRight('facture', 'lire'), '', $mainmenu, 'customers_bills_payment');
  1298. if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) {
  1299. $newmenu->add("/compta/paiement/tovalidate.php?leftmenu=customers_bills_tovalid", $langs->trans("MenuToValid"), 2, $user->hasRight('facture', 'lire'), '', $mainmenu, 'customer_bills_tovalid');
  1300. }
  1301. if ($usemenuhider || empty($leftmenu) || preg_match('/customers_bills/', $leftmenu)) {
  1302. $newmenu->add("/compta/paiement/rapport.php?leftmenu=customers_bills_payment_report", $langs->trans("Reportings"), 2, $user->hasRight('facture', 'lire'), '', $mainmenu, 'customers_bills_payment_report');
  1303. }
  1304. $newmenu->add("/compta/facture/stats/index.php?leftmenu=customers_bills_stats", $langs->trans("Statistics"), 1, $user->hasRight('facture', 'lire'), '', $mainmenu, 'customers_bills_stats');
  1305. }
  1306. // Suppliers invoices
  1307. if (isModEnabled('societe') && isModEnabled('supplier_invoice')) {
  1308. $langs->load("bills");
  1309. $newmenu->add("/fourn/facture/index.php?leftmenu=suppliers_bills", $langs->trans("BillsSuppliers"), 0, $user->hasRight('fournisseur', 'facture', 'lire'), '', $mainmenu, 'suppliers_bills', 0, '', '', '', img_picto('', 'supplier_invoice', 'class="paddingright pictofixedwidth"'));
  1310. $newmenu->add("/fourn/facture/card.php?leftmenu=suppliers_bills&amp;action=create", $langs->trans("NewBill"), 1, ($user->hasRight('fournisseur', 'facture', 'creer') || $user->hasRight('supplier_invoice', 'creer')), '', $mainmenu, 'suppliers_bills_create');
  1311. $newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills", $langs->trans("List"), 1, $user->hasRight('fournisseur', 'facture', 'lire'), '', $mainmenu, 'suppliers_bills_list');
  1312. if ($usemenuhider || empty($leftmenu) || preg_match('/suppliers_bills/', $leftmenu)) {
  1313. $newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills_draft&amp;search_status=0", $langs->trans("BillShortStatusDraft"), 2, $user->hasRight('fournisseur', 'facture', 'lire'), '', $mainmenu, 'suppliers_bills_draft');
  1314. $newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills_notpaid&amp;search_status=1", $langs->trans("BillShortStatusNotPaid"), 2, $user->hasRight('fournisseur', 'facture', 'lire'), '', $mainmenu, 'suppliers_bills_notpaid');
  1315. $newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills_paid&amp;search_status=2", $langs->trans("BillShortStatusPaid"), 2, $user->hasRight('fournisseur', 'facture', 'lire'), '', $mainmenu, 'suppliers_bills_paid');
  1316. }
  1317. $newmenu->add("/fourn/facture/list-rec.php?leftmenu=supplierinvoicestemplate_list", $langs->trans("ListOfTemplates"), 1, $user->hasRight('fournisseur', 'facture', 'lire'), '', $mainmenu, 'supplierinvoicestemplate_list');
  1318. $newmenu->add("/fourn/paiement/list.php?leftmenu=suppliers_bills_payment", $langs->trans("Payments"), 1, $user->hasRight('fournisseur', 'facture', 'lire'), '', $mainmenu, 'suppliers_bills_payment');
  1319. if ($usemenuhider || empty($leftmenu) || preg_match('/suppliers_bills/', $leftmenu)) {
  1320. $newmenu->add("/fourn/facture/rapport.php?leftmenu=suppliers_bills_payment_report", $langs->trans("Reportings"), 2, $user->hasRight('fournisseur', 'facture', 'lire'), '', $mainmenu, 'suppliers_bills_payment_report');
  1321. }
  1322. $newmenu->add("/compta/facture/stats/index.php?mode=supplier&amp;leftmenu=suppliers_bills_stats", $langs->trans("Statistics"), 1, $user->hasRight('fournisseur', 'facture', 'lire'), '', $mainmenu, 'suppliers_bills_stats');
  1323. }
  1324. // Orders
  1325. if (isModEnabled('commande')) {
  1326. $langs->load("orders");
  1327. if (isModEnabled('facture')) {
  1328. $newmenu->add("/commande/list.php?leftmenu=orders&amp;search_status=-3&amp;billed=0&amp;contextpage=billableorders", $langs->trans("MenuOrdersToBill2"), 0, $user->hasRight('commande', 'lire'), '', $mainmenu, 'orders', 0, '', '', '', img_picto('', 'order', 'class="paddingright pictofixedwidth"'));
  1329. }
  1330. //if ($usemenuhider || empty($leftmenu) || $leftmenu=="orders") $newmenu->add("/commande/", $langs->trans("StatusOrderToBill"), 1, $user->hasRight('commande', 'lire'));
  1331. }
  1332. // Supplier Orders to bill
  1333. if (isModEnabled('supplier_invoice')) {
  1334. if (!empty($conf->global->SUPPLIER_MENU_ORDER_RECEIVED_INTO_INVOICE)) {
  1335. $langs->load("supplier");
  1336. $newmenu->add("/fourn/commande/list.php?leftmenu=orders&amp;search_status=5&amp;billed=0", $langs->trans("MenuOrdersSupplierToBill"), 0, $user->hasRight('commande', 'lire'), '', $mainmenu, 'orders', 0, '', '', '', img_picto('', 'supplier_order', 'class="paddingright pictofixedwidth"'));
  1337. //if ($usemenuhider || empty($leftmenu) || $leftmenu=="orders") $newmenu->add("/commande/", $langs->trans("StatusOrderToBill"), 1, $user->hasRight('commande', 'lire'));
  1338. }
  1339. }
  1340. // Donations
  1341. if (isModEnabled('don')) {
  1342. $langs->load("donations");
  1343. $newmenu->add("/don/index.php?leftmenu=donations&amp;mainmenu=billing", $langs->trans("Donations"), 0, $user->hasRight('don', 'lire'), '', $mainmenu, 'donations', 0, '', '', '', img_picto('', 'donation', 'class="paddingright pictofixedwidth"'));
  1344. if ($usemenuhider || empty($leftmenu) || $leftmenu == "donations") {
  1345. $newmenu->add("/don/card.php?leftmenu=donations&amp;action=create", $langs->trans("NewDonation"), 1, $user->hasRight('don', 'creer'));
  1346. $newmenu->add("/don/list.php?leftmenu=donations", $langs->trans("List"), 1, $user->hasRight('don', 'lire'));
  1347. }
  1348. // if ($leftmenu=="donations") $newmenu->add("/don/stats/index.php",$langs->trans("Statistics"), 1, $user->hasRight('don', 'lire'));
  1349. }
  1350. // Taxes and social contributions
  1351. if (isModEnabled('tax')) {
  1352. $newmenu->add("/compta/charges/index.php?leftmenu=tax&amp;mainmenu=billing", $langs->trans("MenuTaxesAndSpecialExpenses"), 0, $user->hasRight('tax', 'charges', 'lire'), '', $mainmenu, 'tax', 0, '', '', '', img_picto('', 'payment', 'class="paddingright pictofixedwidth"'));
  1353. $newmenu->add("/compta/sociales/list.php?leftmenu=tax_social", $langs->trans("MenuSocialContributions"), 1, $user->hasRight('tax', 'charges', 'lire'));
  1354. if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_social/i', $leftmenu)) {
  1355. $newmenu->add("/compta/sociales/card.php?leftmenu=tax_social&action=create", $langs->trans("MenuNewSocialContribution"), 2, $user->hasRight('tax', 'charges', 'creer'));
  1356. $newmenu->add("/compta/sociales/list.php?leftmenu=tax_social", $langs->trans("List"), 2, $user->hasRight('tax', 'charges', 'lire'));
  1357. $newmenu->add("/compta/sociales/payments.php?leftmenu=tax_social&amp;mainmenu=billing", $langs->trans("Payments"), 2, $user->hasRight('tax', 'charges', 'lire'));
  1358. }
  1359. // VAT
  1360. if (empty($conf->global->TAX_DISABLE_VAT_MENUS)) {
  1361. global $mysoc;
  1362. $newmenu->add("/compta/tva/list.php?leftmenu=tax_vat&amp;mainmenu=billing", $langs->transcountry("VAT", $mysoc->country_code), 1, $user->hasRight('tax', 'charges', 'lire'), '', $mainmenu, 'tax_vat');
  1363. if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_vat/i', $leftmenu)) {
  1364. $newmenu->add("/compta/tva/card.php?leftmenu=tax_vat&action=create", $langs->trans("New"), 2, $user->hasRight('tax', 'charges', 'creer'));
  1365. $newmenu->add("/compta/tva/list.php?leftmenu=tax_vat", $langs->trans("List"), 2, $user->hasRight('tax', 'charges', 'lire'));
  1366. $newmenu->add("/compta/tva/payments.php?mode=tvaonly&amp;leftmenu=tax_vat", $langs->trans("Payments"), 2, $user->hasRight('tax', 'charges', 'lire'));
  1367. $newmenu->add("/compta/tva/index.php?leftmenu=tax_vat", $langs->trans("ReportByMonth"), 2, $user->hasRight('tax', 'charges', 'lire'));
  1368. $newmenu->add("/compta/tva/clients.php?leftmenu=tax_vat", $langs->trans("ReportByThirdparties"), 2, $user->hasRight('tax', 'charges', 'lire'));
  1369. $newmenu->add("/compta/tva/quadri_detail.php?leftmenu=tax_vat", $langs->trans("ReportByQuarter"), 2, $user->hasRight('tax', 'charges', 'lire'));
  1370. }
  1371. //Local Taxes 1
  1372. if ($mysoc->useLocalTax(1) && (isset($mysoc->localtax1_assuj) && $mysoc->localtax1_assuj == "1")) {
  1373. $newmenu->add("/compta/localtax/list.php?leftmenu=tax_1_vat&amp;mainmenu=billing&amp;localTaxType=1", $langs->transcountry("LT1", $mysoc->country_code), 1, $user->hasRight('tax', 'charges', 'lire'));
  1374. if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_1_vat/i', $leftmenu)) {
  1375. $newmenu->add("/compta/localtax/card.php?leftmenu=tax_1_vat&action=create&amp;localTaxType=1", $langs->trans("New"), 2, $user->hasRight('tax', 'charges', 'creer'));
  1376. $newmenu->add("/compta/localtax/list.php?leftmenu=tax_1_vat&amp;localTaxType=1", $langs->trans("List"), 2, $user->hasRight('tax', 'charges', 'lire'));
  1377. $newmenu->add("/compta/localtax/index.php?leftmenu=tax_1_vat&amp;localTaxType=1", $langs->trans("ReportByMonth"), 2, $user->hasRight('tax', 'charges', 'lire'));
  1378. $newmenu->add("/compta/localtax/clients.php?leftmenu=tax_1_vat&amp;localTaxType=1", $langs->trans("ReportByThirdparties"), 2, $user->hasRight('tax', 'charges', 'lire'));
  1379. $newmenu->add("/compta/localtax/quadri_detail.php?leftmenu=tax_1_vat&amp;localTaxType=1", $langs->trans("ReportByQuarter"), 2, $user->hasRight('tax', 'charges', 'lire'));
  1380. }
  1381. }
  1382. //Local Taxes 2
  1383. if ($mysoc->useLocalTax(2) && (isset($mysoc->localtax2_assuj) && $mysoc->localtax2_assuj == "1")) {
  1384. $newmenu->add("/compta/localtax/list.php?leftmenu=tax_2_vat&amp;mainmenu=billing&amp;localTaxType=2", $langs->transcountry("LT2", $mysoc->country_code), 1, $user->hasRight('tax', 'charges', 'lire'));
  1385. if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_2_vat/i', $leftmenu)) {
  1386. $newmenu->add("/compta/localtax/card.php?leftmenu=tax_2_vat&action=create&amp;localTaxType=2", $langs->trans("New"), 2, $user->hasRight('tax', 'charges', 'creer'));
  1387. $newmenu->add("/compta/localtax/list.php?leftmenu=tax_2_vat&amp;localTaxType=2", $langs->trans("List"), 2, $user->hasRight('tax', 'charges', 'lire'));
  1388. $newmenu->add("/compta/localtax/index.php?leftmenu=tax_2_vat&amp;localTaxType=2", $langs->trans("ReportByMonth"), 2, $user->hasRight('tax', 'charges', 'lire'));
  1389. $newmenu->add("/compta/localtax/clients.php?leftmenu=tax_2_vat&amp;localTaxType=2", $langs->trans("ReportByThirdparties"), 2, $user->hasRight('tax', 'charges', 'lire'));
  1390. $newmenu->add("/compta/localtax/quadri_detail.php?leftmenu=tax_2_vat&amp;localTaxType=2", $langs->trans("ReportByQuarter"), 2, $user->hasRight('tax', 'charges', 'lire'));
  1391. }
  1392. }
  1393. }
  1394. }
  1395. // Salaries
  1396. if (isModEnabled('salaries')) {
  1397. $langs->load("salaries");
  1398. $newmenu->add("/salaries/list.php?leftmenu=tax_salary&amp;mainmenu=billing", $langs->trans("Salaries"), 0, $user->hasRight('salaries', 'read'), '', $mainmenu, 'tax_salary', 0, '', '', '', img_picto('', 'salary', 'class="paddingright pictofixedwidth"'));
  1399. if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_salary/i', $leftmenu)) {
  1400. $newmenu->add("/salaries/card.php?leftmenu=tax_salary&action=create", $langs->trans("New"), 1, $user->hasRight('salaries', 'write'));
  1401. $newmenu->add("/salaries/list.php?leftmenu=tax_salary", $langs->trans("List"), 1, $user->hasRight('salaries', 'read'));
  1402. $newmenu->add("/salaries/payments.php?leftmenu=tax_salary", $langs->trans("Payments"), 1, $user->hasRight('salaries', 'read'));
  1403. $newmenu->add("/salaries/stats/index.php?leftmenu=tax_salary", $langs->trans("Statistics"), 1, $user->hasRight('salaries', 'read'));
  1404. }
  1405. }
  1406. // Loan
  1407. if (isModEnabled('loan')) {
  1408. $langs->load("loan");
  1409. $newmenu->add("/loan/list.php?leftmenu=tax_loan&amp;mainmenu=billing", $langs->trans("Loans"), 0, $user->hasRight('loan', 'read'), '', $mainmenu, 'tax_loan', 0, '', '', '', img_picto('', 'loan', 'class="paddingright pictofixedwidth"'));
  1410. if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_loan/i', $leftmenu)) {
  1411. $newmenu->add("/loan/card.php?leftmenu=tax_loan&action=create", $langs->trans("NewLoan"), 1, $user->hasRight('loan', 'write'));
  1412. //$newmenu->add("/loan/payment/list.php?leftmenu=tax_loan",$langs->trans("Payments"),2,$user->hasRight('loan', 'read'));
  1413. }
  1414. }
  1415. // Various payment
  1416. if (isModEnabled('banque') && empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT)) {
  1417. $langs->load("banks");
  1418. $newmenu->add("/compta/bank/various_payment/list.php?leftmenu=tax_various&amp;mainmenu=billing", $langs->trans("MenuVariousPayment"), 0, $user->hasRight('banque', 'lire'), '', $mainmenu, 'tax_various', 0, '', '', '', img_picto('', 'payment', 'class="paddingright pictofixedwidth"'));
  1419. if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_various/i', $leftmenu)) {
  1420. $newmenu->add("/compta/bank/various_payment/card.php?leftmenu=tax_various&action=create", $langs->trans("New"), 1, $user->hasRight('banque', 'modifier'));
  1421. $newmenu->add("/compta/bank/various_payment/list.php?leftmenu=tax_various", $langs->trans("List"), 1, $user->hasRight('banque', 'lire'));
  1422. }
  1423. }
  1424. }
  1425. }
  1426. /**
  1427. * Get left COMPTA-FINANCIAL (accountancy)
  1428. *
  1429. * @param string $mainmenu Main menu
  1430. * @param Menu $newmenu Object Menu to return back list of menu entries
  1431. * @param string $usemenuhider Use menu hider
  1432. * @param string $leftmenu Left menu
  1433. * @param int $type_user Type of targeted user for menu
  1434. * @return void
  1435. */
  1436. function get_left_menu_accountancy($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0)
  1437. {
  1438. global $user, $conf, $langs;
  1439. global $db;
  1440. if ($mainmenu == 'accountancy') {
  1441. $langs->load("companies");
  1442. // Accounting (Double entries)
  1443. if (isModEnabled('accounting')) {
  1444. //$permtoshowmenu = (isModEnabled('accounting') || $user->hasRight('accounting', 'bind', 'write') || $user->hasRight('compta', 'resultat', 'lire'));
  1445. //$newmenu->add("/accountancy/index.php?leftmenu=accountancy", $langs->trans("MenuAccountancy"), 0, $permtoshowmenu, '', $mainmenu, 'accountancy');
  1446. // Configuration
  1447. $newmenu->add("/accountancy/index.php?leftmenu=accountancy_admin", $langs->trans("Setup"), 0, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin', 1, '', '', '', img_picto('', 'technic', 'class="paddingright pictofixedwidth"'));
  1448. if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/', $leftmenu)) {
  1449. global $mysoc;
  1450. $newmenu->add("/accountancy/admin/index.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("General"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_general', 10);
  1451. // Fiscal year - Not really yet used. In a future will lock some periods.
  1452. if ($conf->global->MAIN_FEATURES_LEVEL > 1) {
  1453. $newmenu->add("/accountancy/admin/fiscalyear.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("FiscalPeriod"), 1, $user->hasRight('accounting', 'fiscalyear', 'write'), '', $mainmenu, 'fiscalyear', 20);
  1454. }
  1455. $newmenu->add("/accountancy/admin/journals_list.php?id=35&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingJournals"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_journal', 30);
  1456. $newmenu->add("/accountancy/admin/accountmodel.php?id=31&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Pcg_version"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_chartmodel', 40);
  1457. $newmenu->add("/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Chartofaccounts"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_chart', 41);
  1458. $newmenu->add("/accountancy/admin/subaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("ChartOfSubaccounts"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_chart', 41);
  1459. $newmenu->add("/accountancy/admin/defaultaccounts.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuDefaultAccounts"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_default', 60);
  1460. if (isModEnabled('banque')) {
  1461. $newmenu->add("/compta/bank/list.php?mainmenu=accountancy&leftmenu=accountancy_admin&search_status=-1", $langs->trans("MenuBankAccounts"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_bank', 70);
  1462. }
  1463. if (isModEnabled('facture') || isModEnabled('supplier_invoice')) {
  1464. $newmenu->add("/admin/dict.php?id=10&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuVatAccounts"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_default', 80);
  1465. }
  1466. if (isModEnabled('tax')) {
  1467. $newmenu->add("/admin/dict.php?id=7&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuTaxAccounts"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_default', 90);
  1468. }
  1469. if (isModEnabled('expensereport')) {
  1470. $newmenu->add("/admin/dict.php?id=17&from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuExpenseReportAccounts"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_default', 100);
  1471. }
  1472. $newmenu->add("/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuProductsAccounts"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_product', 110);
  1473. if ($conf->global->MAIN_FEATURES_LEVEL > 1) {
  1474. $newmenu->add("/accountancy/admin/closure.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuClosureAccounts"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_closure', 120);
  1475. }
  1476. $newmenu->add("/accountancy/admin/categories_list.php?id=32&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingCategory"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_chart', 125);
  1477. $newmenu->add("/accountancy/admin/export.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("ExportOptions"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_export', 130);
  1478. }
  1479. // Transfer in accounting
  1480. $newmenu->add("/accountancy/index.php?leftmenu=accountancy_transfer", $langs->trans("TransferInAccounting"), 0, $user->hasRight('accounting', 'bind', 'write'), '', $mainmenu, 'transfer', 1, '', '', '', img_picto('', 'long-arrow-alt-right', 'class="paddingright pictofixedwidth"'));
  1481. // Binding
  1482. // $newmenu->add("", $langs->trans("Binding"), 0, $user->hasRight('accounting', 'bind', 'write'), '', $mainmenu, 'dispatch');
  1483. if (isModEnabled('facture') && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES)) {
  1484. $newmenu->add("/accountancy/customer/index.php?leftmenu=accountancy_dispatch_customer&amp;mainmenu=accountancy", $langs->trans("CustomersVentilation"), 1, $user->hasRight('accounting', 'bind', 'write'), '', $mainmenu, 'dispatch_customer');
  1485. if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_dispatch_customer/', $leftmenu)) {
  1486. $newmenu->add("/accountancy/customer/list.php?mainmenu=accountancy&amp;leftmenu=accountancy_dispatch_customer", $langs->trans("ToBind"), 2, $user->hasRight('accounting', 'bind', 'write'));
  1487. $newmenu->add("/accountancy/customer/lines.php?mainmenu=accountancy&amp;leftmenu=accountancy_dispatch_customer", $langs->trans("Binded"), 2, $user->hasRight('accounting', 'bind', 'write'));
  1488. }
  1489. }
  1490. if (isModEnabled('supplier_invoice') && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES)) {
  1491. $newmenu->add("/accountancy/supplier/index.php?leftmenu=accountancy_dispatch_supplier&amp;mainmenu=accountancy", $langs->trans("SuppliersVentilation"), 1, $user->hasRight('accounting', 'bind', 'write'), '', $mainmenu, 'dispatch_supplier');
  1492. if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_dispatch_supplier/', $leftmenu)) {
  1493. $newmenu->add("/accountancy/supplier/list.php?mainmenu=accountancy&amp;leftmenu=accountancy_dispatch_supplier", $langs->trans("ToBind"), 2, $user->hasRight('accounting', 'bind', 'write'));
  1494. $newmenu->add("/accountancy/supplier/lines.php?mainmenu=accountancy&amp;leftmenu=accountancy_dispatch_supplier", $langs->trans("Binded"), 2, $user->hasRight('accounting', 'bind', 'write'));
  1495. }
  1496. }
  1497. if (isModEnabled('expensereport') && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS)) {
  1498. $newmenu->add("/accountancy/expensereport/index.php?leftmenu=accountancy_dispatch_expensereport&amp;mainmenu=accountancy", $langs->trans("ExpenseReportsVentilation"), 1, $user->hasRight('accounting', 'bind', 'write'), '', $mainmenu, 'dispatch_expensereport');
  1499. if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_dispatch_expensereport/', $leftmenu)) {
  1500. $newmenu->add("/accountancy/expensereport/list.php?mainmenu=accountancy&amp;leftmenu=accountancy_dispatch_expensereport", $langs->trans("ToBind"), 2, $user->hasRight('accounting', 'bind', 'write'));
  1501. $newmenu->add("/accountancy/expensereport/lines.php?mainmenu=accountancy&amp;leftmenu=accountancy_dispatch_expensereport", $langs->trans("Binded"), 2, $user->hasRight('accounting', 'bind', 'write'));
  1502. }
  1503. }
  1504. // Journals
  1505. if (isModEnabled('accounting') && $user->hasRight('accounting', 'comptarapport', 'lire') && $mainmenu == 'accountancy') {
  1506. $newmenu->add('', $langs->trans("RegistrationInAccounting"), 1, $user->hasRight('accounting', 'comptarapport', 'lire'), '', $mainmenu, 'accountancy_journal');
  1507. // Multi journal
  1508. $sql = "SELECT rowid, code, label, nature";
  1509. $sql .= " FROM ".MAIN_DB_PREFIX."accounting_journal";
  1510. $sql .= " WHERE entity = ".((int) $conf->entity);
  1511. $sql .= " AND active = 1";
  1512. $sql .= " ORDER BY nature ASC, label DESC";
  1513. $resql = $db->query($sql);
  1514. if ($resql) {
  1515. $numr = $db->num_rows($resql);
  1516. $i = 0;
  1517. if ($numr > 0) {
  1518. while ($i < $numr) {
  1519. $objp = $db->fetch_object($resql);
  1520. $nature = '';
  1521. // Must match array $sourceList defined into journals_list.php
  1522. if ($objp->nature == 2 && isModEnabled('facture') && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES)) {
  1523. $nature = "sells";
  1524. }
  1525. if ($objp->nature == 3
  1526. && isModEnabled('supplier_invoice')
  1527. && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES)) {
  1528. $nature = "purchases";
  1529. }
  1530. if ($objp->nature == 4 && isModEnabled('banque')) {
  1531. $nature = "bank";
  1532. }
  1533. if ($objp->nature == 5 && isModEnabled('expensereport') && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS)) {
  1534. $nature = "expensereports";
  1535. }
  1536. if ($objp->nature == 1 && isModEnabled('asset')) {
  1537. $nature = "various"; // Warning: The page /accountancy/journal/variousjournal.php is bugged. It read tables that does not exists.
  1538. }
  1539. if ($objp->nature == 8) {
  1540. $nature = "inventory";
  1541. }
  1542. if ($objp->nature == 9) {
  1543. $nature = "hasnew";
  1544. }
  1545. // To enable when page exists
  1546. if (empty($conf->global->ACCOUNTANCY_SHOW_DEVELOP_JOURNAL)) {
  1547. if ($nature == 'hasnew' || $nature == 'inventory') {
  1548. $nature = '';
  1549. }
  1550. }
  1551. if ($nature) {
  1552. $langs->load('accountancy');
  1553. $journallabel = '';
  1554. if ($objp->label) {
  1555. $journallabelwithoutspan = $langs->trans($objp->label);
  1556. $journallabel = '<span class="opacitymedium">('.$langs->trans($objp->label).')</span>'; // Label of bank account in llx_accounting_journal
  1557. }
  1558. $key = $langs->trans("AccountingJournalType".$objp->nature); // $objp->nature is 1, 2, 3 ...
  1559. $transferlabel = (($objp->nature && $key != "AccountingJournalType".$objp->nature) ? $key.($journallabelwithoutspan != $key ? ' '.$journallabel : ''): $journallabel);
  1560. $newmenu->add('/accountancy/journal/'.$nature.'journal.php?mainmenu=accountancy&leftmenu=accountancy_journal&id_journal='.$objp->rowid, $transferlabel, 2, $user->hasRight('accounting', 'comptarapport', 'lire'));
  1561. }
  1562. $i++;
  1563. }
  1564. } else {
  1565. // Should not happend. Entries are added
  1566. $newmenu->add('', $langs->trans("NoJournalDefined"), 2, $user->hasRight('accounting', 'comptarapport', 'lire'));
  1567. }
  1568. } else {
  1569. dol_print_error($db);
  1570. }
  1571. $db->free($resql);
  1572. }
  1573. // Files
  1574. if (empty($conf->global->ACCOUNTANCY_HIDE_EXPORT_FILES_MENU)) {
  1575. $newmenu->add("/compta/accounting-files.php?mainmenu=accountancy&amp;leftmenu=accountancy_files", $langs->trans("AccountantFiles"), 1, $user->hasRight('accounting', 'mouvements', 'lire'));
  1576. }
  1577. // Accounting
  1578. $newmenu->add("/accountancy/index.php?leftmenu=accountancy_accountancy", $langs->trans("MenuAccountancy"), 0, $user->hasRight('accounting', 'mouvements', 'lire') || $user->hasRight('accounting', 'comptarapport', 'lire'), '', $mainmenu, 'accountancy', 1, '', '', '', img_picto('', 'accountancy', 'class="paddingright pictofixedwidth"'));
  1579. // General Ledger
  1580. $newmenu->add("/accountancy/bookkeeping/listbyaccount.php?mainmenu=accountancy&amp;leftmenu=accountancy_accountancy", $langs->trans("Bookkeeping"), 1, $user->hasRight('accounting', 'mouvements', 'lire'));
  1581. // Journals
  1582. $newmenu->add("/accountancy/bookkeeping/list.php?mainmenu=accountancy&amp;leftmenu=accountancy_accountancy", $langs->trans("Journals"), 1, $user->hasRight('accounting', 'mouvements', 'lire'));
  1583. // Account Balance
  1584. $newmenu->add("/accountancy/bookkeeping/balance.php?mainmenu=accountancy&amp;leftmenu=accountancy_accountancy", $langs->trans("AccountBalance"), 1, $user->hasRight('accounting', 'mouvements', 'lire'));
  1585. // Export accountancy
  1586. $newmenu->add("/accountancy/bookkeeping/export.php?mainmenu=accountancy&amp;leftmenu=accountancy_accountancy", $langs->trans("MenuExportAccountancy"), 1, $user->hasRight('accounting', 'mouvements', 'lire'));
  1587. // Closure
  1588. $newmenu->add("/accountancy/closure/index.php?mainmenu=accountancy&amp;leftmenu=accountancy_closure", $langs->trans("MenuAccountancyClosure"), 1, $user->hasRight('accounting', 'fiscalyear', 'write'), '', $mainmenu, 'closure');
  1589. // Reports
  1590. $newmenu->add("/accountancy/index.php?leftmenu=accountancy_report", $langs->trans("Reportings"), 1, $user->hasRight('accounting', 'comptarapport', 'lire'), '', $mainmenu, 'ca');
  1591. if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/', $leftmenu)) {
  1592. $newmenu->add("/compta/resultat/index.php?leftmenu=accountancy_report", $langs->trans("MenuReportInOut"), 2, $user->hasRight('accounting', 'comptarapport', 'lire'));
  1593. $newmenu->add("/compta/resultat/clientfourn.php?leftmenu=accountancy_report", $langs->trans("ByPredefinedAccountGroups"), 3, $user->hasRight('accounting', 'comptarapport', 'lire'));
  1594. $newmenu->add("/compta/resultat/result.php?leftmenu=accountancy_report", $langs->trans("ByPersonalizedAccountGroups"), 3, $user->hasRight('accounting', 'comptarapport', 'lire'));
  1595. }
  1596. $modecompta = 'CREANCES-DETTES';
  1597. if (isModEnabled('accounting') && $user->hasRight('accounting', 'comptarapport', 'lire') && $mainmenu == 'accountancy') {
  1598. $modecompta = 'BOOKKEEPING'; // Not yet implemented. Should be BOOKKEEPINGCOLLECTED
  1599. }
  1600. if ($modecompta) {
  1601. if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/', $leftmenu)) {
  1602. $newmenu->add("/compta/stats/index.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ReportTurnover"), 2, $user->hasRight('accounting', 'comptarapport', 'lire'));
  1603. $newmenu->add("/compta/stats/casoc.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByCompanies"), 3, $user->hasRight('accounting', 'comptarapport', 'lire'));
  1604. $newmenu->add("/compta/stats/cabyuser.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByUsers"), 3, $user->hasRight('accounting', 'comptarapport', 'lire'));
  1605. $newmenu->add("/compta/stats/cabyprodserv.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByProductsAndServices"), 3, $user->hasRight('accounting', 'comptarapport', 'lire'));
  1606. $newmenu->add("/compta/stats/byratecountry.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByVatRate"), 3, $user->hasRight('accounting', 'comptarapport', 'lire'));
  1607. }
  1608. }
  1609. $modecompta = 'RECETTES-DEPENSES';
  1610. //if (isModEnabled('accounting') && $user->hasRight('accounting', 'comptarapport', 'lire') && $mainmenu == 'accountancy') $modecompta=''; // Not yet implemented. Should be BOOKKEEPINGCOLLECTED
  1611. if ($modecompta) {
  1612. if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/', $leftmenu)) {
  1613. $newmenu->add("/compta/stats/index.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ReportTurnoverCollected"), 2, $user->hasRight('accounting', 'comptarapport', 'lire'));
  1614. $newmenu->add("/compta/stats/casoc.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByCompanies"), 3, $user->hasRight('accounting', 'comptarapport', 'lire'));
  1615. $newmenu->add("/compta/stats/cabyuser.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByUsers"), 3, $user->hasRight('accounting', 'comptarapport', 'lire'));
  1616. //$newmenu->add("/compta/stats/cabyprodserv.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByProductsAndServices"),3,$user->hasRight('accounting', 'comptarapport', 'lire'));
  1617. //$newmenu->add("/compta/stats/byratecountry.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByVatRate"),3,$user->hasRight('accounting', 'comptarapport', 'lire'));
  1618. }
  1619. }
  1620. $modecompta = 'CREANCES-DETTES';
  1621. if (isModEnabled('accounting') && $user->hasRight('accounting', 'comptarapport', 'lire') && $mainmenu == 'accountancy') {
  1622. $modecompta = 'BOOKKEEPING'; // Not yet implemented.
  1623. }
  1624. if ($modecompta && isModEnabled('supplier_invoice')) {
  1625. if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/', $leftmenu)) {
  1626. $newmenu->add("/compta/stats/supplier_turnover.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ReportPurchaseTurnover"), 2, $user->hasRight('accounting', 'comptarapport', 'lire'));
  1627. $newmenu->add("/compta/stats/supplier_turnover_by_thirdparty.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByCompanies"), 3, $user->hasRight('accounting', 'comptarapport', 'lire'));
  1628. $newmenu->add("/compta/stats/supplier_turnover_by_prodserv.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByProductsAndServices"), 3, $user->hasRight('accounting', 'comptarapport', 'lire'));
  1629. }
  1630. }
  1631. $modecompta = 'RECETTES-DEPENSES';
  1632. if (isModEnabled('accounting') && $user->hasRight('accounting', 'comptarapport', 'lire') && $mainmenu == 'accountancy') {
  1633. $modecompta = 'BOOKKEEPINGCOLLECTED'; // Not yet implemented.
  1634. }
  1635. if ($modecompta && ((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('supplier_invoice'))) {
  1636. if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/', $leftmenu)) {
  1637. $newmenu->add("/compta/stats/supplier_turnover.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ReportPurchaseTurnoverCollected"), 2, $user->hasRight('accounting', 'comptarapport', 'lire'));
  1638. $newmenu->add("/compta/stats/supplier_turnover_by_thirdparty.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByCompanies"), 3, $user->hasRight('accounting', 'comptarapport', 'lire'));
  1639. }
  1640. }
  1641. }
  1642. // Accountancy (simple)
  1643. if (isModEnabled('comptabilite')) {
  1644. // Files
  1645. if (empty($conf->global->ACCOUNTANCY_HIDE_EXPORT_FILES_MENU)) {
  1646. $newmenu->add("/compta/accounting-files.php?mainmenu=accountancy&leftmenu=accountancy_files", $langs->trans("AccountantFiles"), 0, $user->hasRight('compta', 'resultat', 'lire'), '', $mainmenu, 'files', 0, '', '', '', img_picto('', 'accountancy', 'class="paddingright pictofixedwidth"'));
  1647. }
  1648. // Bilan, resultats
  1649. $newmenu->add("/compta/resultat/index.php?leftmenu=report&mainmenu=accountancy", $langs->trans("Reportings"), 0, $user->hasRight('compta', 'resultat', 'lire'), '', $mainmenu, 'ca', 0, '', '', '', img_picto('', 'accountancy', 'class="paddingright pictofixedwidth"'));
  1650. if ($usemenuhider || empty($leftmenu) || preg_match('/report/', $leftmenu)) {
  1651. $newmenu->add("/compta/resultat/index.php?leftmenu=report", $langs->trans("MenuReportInOut"), 1, $user->hasRight('compta', 'resultat', 'lire'));
  1652. $newmenu->add("/compta/resultat/clientfourn.php?leftmenu=report", $langs->trans("ByCompanies"), 2, $user->hasRight('compta', 'resultat', 'lire'));
  1653. /* On verra ca avec module compabilite expert
  1654. $newmenu->add("/compta/resultat/compteres.php?leftmenu=report","Compte de resultat",2,$user->hasRight('compta', 'resultat', 'lire'));
  1655. $newmenu->add("/compta/resultat/bilan.php?leftmenu=report","Bilan",2,$user->hasRight('compta', 'resultat', 'lire'));
  1656. */
  1657. /*
  1658. $newmenu->add("/compta/stats/cumul.php?leftmenu=report","Cumule",2,$user->hasRight('compta', 'resultat', 'lire'));
  1659. if (isModEnabled('propal')) {
  1660. $newmenu->add("/compta/stats/prev.php?leftmenu=report","Previsionnel",2,$user->hasRight('compta', 'resultat', 'lire'));
  1661. $newmenu->add("/compta/stats/comp.php?leftmenu=report","Transforme",2,$user->hasRight('compta', 'resultat', 'lire'));
  1662. }
  1663. */
  1664. $modecompta = 'CREANCES-DETTES';
  1665. $newmenu->add("/compta/stats/index.php?leftmenu=report&modecompta=".$modecompta, $langs->trans("ReportTurnover"), 1, $user->hasRight('compta', 'resultat', 'lire'));
  1666. $newmenu->add("/compta/stats/casoc.php?leftmenu=report&modecompta=".$modecompta, $langs->trans("ByCompanies"), 2, $user->hasRight('compta', 'resultat', 'lire'));
  1667. $newmenu->add("/compta/stats/cabyuser.php?leftmenu=report&modecompta=".$modecompta, $langs->trans("ByUsers"), 2, $user->hasRight('compta', 'resultat', 'lire'));
  1668. $newmenu->add("/compta/stats/cabyprodserv.php?leftmenu=report&modecompta=".$modecompta, $langs->trans("ByProductsAndServices"), 2, $user->hasRight('compta', 'resultat', 'lire'));
  1669. $newmenu->add("/compta/stats/byratecountry.php?leftmenu=report&modecompta=".$modecompta, $langs->trans("ByVatRate"), 2, $user->hasRight('compta', 'resultat', 'lire'));
  1670. $modecompta = 'RECETTES-DEPENSES';
  1671. $newmenu->add("/compta/stats/index.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ReportTurnoverCollected"), 1, $user->hasRight('compta', 'resultat', 'lire'));
  1672. $newmenu->add("/compta/stats/casoc.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByCompanies"), 2, $user->hasRight('compta', 'resultat', 'lire'));
  1673. $newmenu->add("/compta/stats/cabyuser.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByUsers"), 2, $user->hasRight('compta', 'resultat', 'lire'));
  1674. //Achats
  1675. $modecompta = 'CREANCES-DETTES';
  1676. $newmenu->add("/compta/stats/supplier_turnover.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ReportPurchaseTurnover"), 1, $user->hasRight('compta', 'resultat', 'lire'));
  1677. $newmenu->add("/compta/stats/supplier_turnover_by_thirdparty.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByCompanies"), 2, $user->hasRight('compta', 'resultat', 'lire'));
  1678. $newmenu->add("/compta/stats/supplier_turnover_by_prodserv.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByProductsAndServices"), 2, $user->hasRight('compta', 'resultat', 'lire'));
  1679. /*
  1680. $modecompta = 'RECETTES-DEPENSES';
  1681. $newmenu->add("/compta/stats/index.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ReportPurchaseTurnoverCollected"), 1, $user->hasRight('compta', 'resultat', 'lire'));
  1682. $newmenu->add("/compta/stats/casoc.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByCompanies"), 2, $user->hasRight('compta', 'resultat', 'lire'));
  1683. $newmenu->add("/compta/stats/cabyuser.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByUsers"), 2, $user->hasRight('compta', 'resultat', 'lire'));
  1684. */
  1685. // Journals
  1686. $newmenu->add("/compta/journal/sellsjournal.php?leftmenu=report", $langs->trans("SellsJournal"), 1, $user->hasRight('compta', 'resultat', 'lire'), '', '', '', 50);
  1687. $newmenu->add("/compta/journal/purchasesjournal.php?leftmenu=report", $langs->trans("PurchasesJournal"), 1, $user->hasRight('compta', 'resultat', 'lire'), '', '', '', 51);
  1688. }
  1689. //if ($leftmenu=="ca") $newmenu->add("/compta/journaux/index.php?leftmenu=ca",$langs->trans("Journals"),1,$user->hasRight('compta', 'resultat', 'lire')||$user->hasRight('accounting', 'comptarapport', 'lire'));
  1690. }
  1691. // Intracomm report
  1692. if (isModEnabled('intracommreport')) {
  1693. $newmenu->add("/intracommreport/list.php?leftmenu=intracommreport", $langs->trans("MenuIntracommReport"), 0, $user->hasRight('intracommreport', 'read'), '', $mainmenu, 'intracommreport', 60, '', '', '', img_picto('', 'intracommreport', 'class="paddingright pictofixedwidth"'));
  1694. if ($usemenuhider || empty($leftmenu) || preg_match('/intracommreport/', $leftmenu)) {
  1695. // DEB / DES
  1696. $newmenu->add("/intracommreport/card.php?action=create&leftmenu=intracommreport", $langs->trans("MenuIntracommReportNew"), 1, $user->hasRight('intracommreport', 'write'), '', $mainmenu, 'intracommreport', 1);
  1697. $newmenu->add("/intracommreport/list.php?leftmenu=intracommreport", $langs->trans("MenuIntracommReportList"), 1, $user->hasRight('intracommreport', 'read'), '', $mainmenu, 'intracommreport', 1);
  1698. }
  1699. }
  1700. // Assets
  1701. if (isModEnabled('asset')) {
  1702. $newmenu->add("/asset/list.php?leftmenu=asset&amp;mainmenu=accountancy", $langs->trans("MenuAssets"), 0, $user->hasRight('asset', 'read'), '', $mainmenu, 'asset', 100, '', '', '', img_picto('', 'payment', 'class="paddingright pictofixedwidth"'));
  1703. $newmenu->add("/asset/card.php?leftmenu=asset&amp;action=create", $langs->trans("MenuNewAsset"), 1, $user->hasRight('asset', 'write'));
  1704. $newmenu->add("/asset/list.php?leftmenu=asset&amp;mainmenu=accountancy", $langs->trans("MenuListAssets"), 1, $user->hasRight('asset', 'read'));
  1705. $newmenu->add("/asset/model/list.php?leftmenu=asset_model", $langs->trans("MenuAssetModels"), 1, (empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'read')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'model_advance', 'read')), '', $mainmenu, 'asset_model');
  1706. if ($usemenuhider || empty($leftmenu) || preg_match('/asset_model/', $leftmenu)) {
  1707. $newmenu->add("/asset/model/card.php?leftmenu=asset_model&amp;action=create", $langs->trans("MenuNewAssetModel"), 2, (empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'write')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'model_advance', 'write')));
  1708. $newmenu->add("/asset/model/list.php?leftmenu=asset_model", $langs->trans("MenuListAssetModels"), 2, (empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'read')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'model_advance', 'read')));
  1709. }
  1710. }
  1711. }
  1712. }
  1713. /**
  1714. * Get left Menu BANK
  1715. *
  1716. * @param string $mainmenu Main menu
  1717. * @param Menu $newmenu Object Menu to return back list of menu entries
  1718. * @param string $usemenuhider Use menu hider
  1719. * @param string $leftmenu Left menu
  1720. * @param int $type_user Type of targeted user for menu
  1721. * @return void
  1722. */
  1723. function get_left_menu_bank($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0)
  1724. {
  1725. global $user, $conf, $langs;
  1726. if ($mainmenu == 'bank') {
  1727. // Load translation files required by the page
  1728. $langs->loadLangs(array("withdrawals", "banks", "bills", "categories"));
  1729. // Bank-Cash account
  1730. if (isModEnabled('banque')) {
  1731. $newmenu->add("/compta/bank/list.php?leftmenu=bank&amp;mainmenu=bank", $langs->trans("MenuBankCash"), 0, $user->hasRight('banque', 'lire'), '', $mainmenu, 'bank', 0, '', '', '', img_picto('', 'bank_account', 'class="paddingright pictofixedwidth"'));
  1732. $newmenu->add("/compta/bank/card.php?action=create", $langs->trans("MenuNewFinancialAccount"), 1, $user->hasRight('banque', 'configurer'));
  1733. $newmenu->add("/compta/bank/list.php?leftmenu=bank&amp;mainmenu=bank", $langs->trans("List"), 1, $user->hasRight('banque', 'lire'), '', $mainmenu, 'bank');
  1734. $newmenu->add("/compta/bank/bankentries_list.php", $langs->trans("ListTransactions"), 1, $user->hasRight('banque', 'lire'));
  1735. $newmenu->add("/compta/bank/budget.php", $langs->trans("ListTransactionsByCategory"), 1, $user->hasRight('banque', 'lire'));
  1736. $newmenu->add("/compta/bank/transfer.php", $langs->trans("MenuBankInternalTransfer"), 1, $user->hasRight('banque', 'transfer'));
  1737. }
  1738. if (isModEnabled('categorie')) {
  1739. $langs->load("categories");
  1740. $newmenu->add("/categories/index.php?type=5", $langs->trans("Rubriques"), 1, $user->hasRight('categorie', 'creer'), '', $mainmenu, 'tags');
  1741. $newmenu->add("/compta/bank/categ.php", $langs->trans("RubriquesTransactions"), 1, $user->hasRight('banque', 'configurer'), '', $mainmenu, 'tags');
  1742. }
  1743. // Direct debit order
  1744. if (isModEnabled('prelevement')) {
  1745. $newmenu->add("/compta/prelevement/index.php?leftmenu=withdraw&amp;mainmenu=bank", $langs->trans("PaymentByDirectDebit"), 0, $user->hasRight('prelevement', 'bons', 'lire'), '', $mainmenu, 'withdraw', 0, '', '', '', img_picto('', 'payment', 'class="paddingright pictofixedwidth"'));
  1746. if ($usemenuhider || empty($leftmenu) || $leftmenu == "withdraw") {
  1747. $newmenu->add("/compta/prelevement/create.php?mainmenu=bank", $langs->trans("NewStandingOrder"), 1, $user->hasRight('prelevement', 'bons', 'creer'));
  1748. $newmenu->add("/compta/prelevement/orders_list.php?mainmenu=bank", $langs->trans("WithdrawalsReceipts"), 1, $user->hasRight('prelevement', 'bons', 'lire'));
  1749. $newmenu->add("/compta/prelevement/list.php?mainmenu=bank", $langs->trans("WithdrawalsLines"), 1, $user->hasRight('prelevement', 'bons', 'lire'));
  1750. $newmenu->add("/compta/prelevement/rejets.php?mainmenu=bank", $langs->trans("Rejects"), 1, $user->hasRight('prelevement', 'bons', 'lire'));
  1751. $newmenu->add("/compta/prelevement/stats.php?mainmenu=bank", $langs->trans("Statistics"), 1, $user->hasRight('prelevement', 'bons', 'lire'));
  1752. }
  1753. }
  1754. // Bank transfer order
  1755. if (isModEnabled('paymentbybanktransfer')) {
  1756. $newmenu->add("/compta/paymentbybanktransfer/index.php?leftmenu=banktransfer&amp;mainmenu=bank", $langs->trans("PaymentByBankTransfer"), 0, $user->hasRight('paymentbybanktransfer', 'read'), '', $mainmenu, 'banktransfer', 0, '', '', '', img_picto('', 'payment', 'class="paddingright pictofixedwidth"'));
  1757. if ($usemenuhider || empty($leftmenu) || $leftmenu == "banktransfer") {
  1758. $newmenu->add("/compta/prelevement/create.php?type=bank-transfer&mainmenu=bank", $langs->trans("NewPaymentByBankTransfer"), 1, $user->hasRight('paymentbybanktransfer', 'create'));
  1759. $newmenu->add("/compta/prelevement/orders_list.php?type=bank-transfer&mainmenu=bank", $langs->trans("PaymentByBankTransferReceipts"), 1, $user->hasRight('paymentbybanktransfer', 'read'));
  1760. $newmenu->add("/compta/prelevement/list.php?type=bank-transfer&mainmenu=bank", $langs->trans("PaymentByBankTransferLines"), 1, $user->hasRight('paymentbybanktransfer', 'read'));
  1761. $newmenu->add("/compta/prelevement/rejets.php?type=bank-transfer&mainmenu=bank", $langs->trans("Rejects"), 1, $user->hasRight('paymentbybanktransfer', 'read'));
  1762. $newmenu->add("/compta/prelevement/stats.php?type=bank-transfer&mainmenu=bank", $langs->trans("Statistics"), 1, $user->hasRight('paymentbybanktransfer', 'read'));
  1763. }
  1764. }
  1765. // Management of checks
  1766. if (empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT) && isModEnabled('banque') && (isModEnabled('facture') || !empty($conf->global->MAIN_MENU_CHEQUE_DEPOSIT_ON))) {
  1767. $newmenu->add("/compta/paiement/cheque/index.php?leftmenu=checks&amp;mainmenu=bank", $langs->trans("MenuChequeDeposits"), 0, $user->hasRight('banque', 'cheque'), '', $mainmenu, 'checks', 0, '', '', '', img_picto('', 'payment', 'class="paddingright pictofixedwidth"'));
  1768. if (preg_match('/checks/', $leftmenu)) {
  1769. $newmenu->add("/compta/paiement/cheque/card.php?leftmenu=checks_bis&amp;action=new&amp;mainmenu=bank", $langs->trans("NewChequeDeposit"), 1, $user->hasRight('banque', 'cheque'));
  1770. $newmenu->add("/compta/paiement/cheque/list.php?leftmenu=checks_bis&amp;mainmenu=bank", $langs->trans("List"), 1, $user->hasRight('banque', 'cheque'));
  1771. }
  1772. }
  1773. // Cash Control
  1774. if (isModEnabled('takepos') || isModEnabled('cashdesk')) {
  1775. $permtomakecashfence = ($user->hasRight('cashdesk', 'run')|| $user->hasRight('takepos', 'run'));
  1776. $newmenu->add("/compta/cashcontrol/cashcontrol_list.php?action=list", $langs->trans("POS"), 0, $permtomakecashfence, '', $mainmenu, 'cashcontrol', 0, '', '', '', img_picto('', 'pos', 'class="pictofixedwidth"'));
  1777. $newmenu->add("/compta/cashcontrol/cashcontrol_card.php?action=create", $langs->trans("NewCashFence"), 1, $permtomakecashfence);
  1778. $newmenu->add("/compta/cashcontrol/cashcontrol_list.php?action=list", $langs->trans("List"), 1, $permtomakecashfence);
  1779. }
  1780. }
  1781. }
  1782. /**
  1783. * Get left Menu PRODUCTS-SERVICES
  1784. *
  1785. * @param string $mainmenu Main menu
  1786. * @param Menu $newmenu Object Menu to return back list of menu entries
  1787. * @param string $usemenuhider Use menu hider
  1788. * @param string $leftmenu Left menu
  1789. * @param int $type_user Type of targeted user for menu
  1790. * @return void
  1791. */
  1792. function get_left_menu_products($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0)
  1793. {
  1794. global $user, $conf, $langs;
  1795. if ($mainmenu == 'products') {
  1796. // Products
  1797. if (isModEnabled('product')) {
  1798. $newmenu->add("/product/index.php?leftmenu=product&amp;type=0", $langs->trans("Products"), 0, $user->hasRight('product', 'read'), '', $mainmenu, 'product', 0, '', '', '', img_picto('', 'product', 'class="pictofixedwidth"'));
  1799. $newmenu->add("/product/card.php?leftmenu=product&amp;action=create&amp;type=0", $langs->trans("NewProduct"), 1, $user->hasRight('product', 'creer'));
  1800. $newmenu->add("/product/list.php?leftmenu=product&amp;type=0", $langs->trans("List"), 1, $user->hasRight('product', 'read'));
  1801. if (isModEnabled('stock')) {
  1802. $newmenu->add("/product/reassort.php?type=0", $langs->trans("MenuStocks"), 1, $user->hasRight('product', 'read') && $user->hasRight('stock', 'lire'));
  1803. }
  1804. if (isModEnabled('productbatch')) {
  1805. $langs->load("stocks");
  1806. $newmenu->add("/product/reassortlot.php?type=0&search_subjecttolotserial=1", $langs->trans("StocksByLotSerial"), 1, $user->hasRight('product', 'read') && $user->hasRight('stock', 'lire'));
  1807. $newmenu->add("/product/stock/productlot_list.php", $langs->trans("LotSerial"), 1, $user->hasRight('product', 'read') && $user->hasRight('stock', 'lire'));
  1808. }
  1809. if (isModEnabled('variants')) {
  1810. $newmenu->add("/variants/list.php", $langs->trans("VariantAttributes"), 1, $user->hasRight('product', 'read'));
  1811. }
  1812. if (isModEnabled('propal') || isModEnabled('commande') || isModEnabled('facture') || isModEnabled('supplier_proposal') || isModEnabled('supplier_order') || isModEnabled('supplier_invoice')) {
  1813. $newmenu->add("/product/stats/card.php?id=all&leftmenu=stats&type=0", $langs->trans("Statistics"), 1, $user->hasRight('product', 'read'));
  1814. }
  1815. // Categories
  1816. if (isModEnabled('categorie')) {
  1817. $langs->load("categories");
  1818. $newmenu->add("/categories/index.php?leftmenu=cat&amp;type=0", $langs->trans("Categories"), 1, $user->hasRight('categorie', 'lire'), '', $mainmenu, 'cat');
  1819. //if ($usemenuhider || empty($leftmenu) || $leftmenu=="cat") $newmenu->add("/categories/list.php", $langs->trans("List"), 1, $user->hasRight('categorie', 'lire'));
  1820. }
  1821. }
  1822. // Services
  1823. if (isModEnabled('service')) {
  1824. $newmenu->add("/product/index.php?leftmenu=service&amp;type=1", $langs->trans("Services"), 0, $user->hasRight('service', 'read'), '', $mainmenu, 'service', 0, '', '', '', img_picto('', 'service', 'class="pictofixedwidth"'));
  1825. $newmenu->add("/product/card.php?leftmenu=service&amp;action=create&amp;type=1", $langs->trans("NewService"), 1, $user->hasRight('service', 'creer'));
  1826. $newmenu->add("/product/list.php?leftmenu=service&amp;type=1", $langs->trans("List"), 1, $user->hasRight('service', 'read'));
  1827. if (isModEnabled('propal') || isModEnabled('commande') || isModEnabled('facture') || isModEnabled('supplier_proposal') || isModEnabled('supplier_order') || isModEnabled('supplier_invoice')) {
  1828. $newmenu->add("/product/stats/card.php?id=all&leftmenu=stats&type=1", $langs->trans("Statistics"), 1, $user->hasRight('service', 'read'));
  1829. }
  1830. // Categories
  1831. if (isModEnabled('categorie')) {
  1832. $langs->load("categories");
  1833. $newmenu->add("/categories/index.php?leftmenu=cat&amp;type=0", $langs->trans("Categories"), 1, $user->hasRight('categorie', 'lire'), '', $mainmenu, 'cat');
  1834. //if ($usemenuhider || empty($leftmenu) || $leftmenu=="cat") $newmenu->add("/categories/list.php", $langs->trans("List"), 1, $user->hasRight('categorie', 'lire'));
  1835. }
  1836. }
  1837. // Warehouse
  1838. if (isModEnabled('stock')) {
  1839. $langs->load("stocks");
  1840. $newmenu->add("/product/stock/index.php?leftmenu=stock", $langs->trans("Warehouses"), 0, $user->hasRight('stock', 'lire'), '', $mainmenu, 'stock', 0, '', '', '', img_picto('', 'stock', 'class="pictofixedwidth"'));
  1841. $newmenu->add("/product/stock/card.php?action=create", $langs->trans("MenuNewWarehouse"), 1, $user->hasRight('stock', 'creer'));
  1842. $newmenu->add("/product/stock/list.php", $langs->trans("List"), 1, $user->hasRight('stock', 'lire'));
  1843. $newmenu->add("/product/stock/movement_list.php", $langs->trans("Movements"), 1, $user->hasRight('stock', 'mouvement', 'lire'));
  1844. $newmenu->add("/product/stock/massstockmove.php?init=1", $langs->trans("MassStockTransferShort"), 1, $user->hasRight('stock', 'mouvement', 'creer'));
  1845. if (isModEnabled('supplier_order')) {
  1846. $newmenu->add("/product/stock/replenish.php", $langs->trans("Replenishment"), 1, $user->hasRight('stock', 'mouvement', 'creer') && $user->hasRight('fournisseur', 'lire'));
  1847. }
  1848. $newmenu->add("/product/stock/stockatdate.php", $langs->trans("StockAtDate"), 1, $user->hasRight('product', 'read') && $user->hasRight('stock', 'lire'));
  1849. // Categories for warehouses
  1850. if (isModEnabled('categorie')) {
  1851. $newmenu->add("/categories/index.php?leftmenu=stock&amp;type=9", $langs->trans("Categories"), 1, $user->hasRight('categorie', 'lire'), '', $mainmenu, 'cat');
  1852. }
  1853. }
  1854. if (isModEnabled('stocktransfer')) {
  1855. $newmenu->add('/product/stock/stocktransfer/stocktransfer_list.php', $langs->trans("ModuleStockTransferName"), 0, $user->hasRight('stocktransfer', 'stocktransfer', 'read'), '', $mainmenu, 'stocktransfer', 0, '', '', '', img_picto('', 'stock', 'class="pictofixedwidth"'));
  1856. $newmenu->add('/product/stock/stocktransfer/stocktransfer_card.php?action=create', $langs->trans('StockTransferNew'), 1, $user->hasRight('stocktransfer', 'stocktransfer', 'write'));
  1857. $newmenu->add('/product/stock/stocktransfer/stocktransfer_list.php', $langs->trans('List'), 1, $user->hasRight('stocktransfer', 'stocktransfer', 'read'));
  1858. }
  1859. // Inventory
  1860. if (isModEnabled('stock')) {
  1861. $langs->load("stocks");
  1862. if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
  1863. $newmenu->add("/product/inventory/list.php?leftmenu=stock_inventories", $langs->trans("Inventories"), 0, $user->hasRight('stock', 'lire'), '', $mainmenu, 'stock', 0, '', '', '', img_picto('', 'inventory', 'class="pictofixedwidth"'));
  1864. if ($usemenuhider || empty($leftmenu) || $leftmenu == "stock_inventories") {
  1865. $newmenu->add("/product/inventory/card.php?action=create&leftmenu=stock_inventories", $langs->trans("NewInventory"), 1, $user->hasRight('stock', 'creer'));
  1866. $newmenu->add("/product/inventory/list.php?leftmenu=stock_inventories", $langs->trans("List"), 1, $user->hasRight('stock', 'lire'));
  1867. }
  1868. } else {
  1869. $newmenu->add("/product/inventory/list.php?leftmenu=stock_inventories", $langs->trans("Inventories"), 0, $user->hasRight('stock', 'inventory_advance', 'read'), '', $mainmenu, 'stock', 0, '', '', '', img_picto('', 'inventory', 'class="pictofixedwidth"'));
  1870. if ($usemenuhider || empty($leftmenu) || $leftmenu == "stock_inventories") {
  1871. $newmenu->add("/product/inventory/card.php?action=create&leftmenu=stock_inventories", $langs->trans("NewInventory"), 1, $user->hasRight('stock', 'inventory_advance', 'write'));
  1872. $newmenu->add("/product/inventory/list.php?leftmenu=stock_inventories", $langs->trans("List"), 1, $user->hasRight('stock', 'inventory_advance', 'read'));
  1873. }
  1874. }
  1875. }
  1876. // Shipments
  1877. if (isModEnabled('expedition')) {
  1878. $langs->load("sendings");
  1879. $newmenu->add("/expedition/index.php?leftmenu=sendings", $langs->trans("Shipments"), 0, $user->hasRight('expedition', 'lire'), '', $mainmenu, 'sendings', 0, '', '', '', img_picto('', 'shipment', 'class="pictofixedwidth"'));
  1880. $newmenu->add("/expedition/card.php?action=create2&amp;leftmenu=sendings", $langs->trans("NewSending"), 1, $user->hasRight('expedition', 'creer'));
  1881. $newmenu->add("/expedition/list.php?leftmenu=sendings", $langs->trans("List"), 1, $user->hasRight('expedition', 'lire'));
  1882. if ($usemenuhider || empty($leftmenu) || $leftmenu == "sendings") {
  1883. $newmenu->add("/expedition/list.php?leftmenu=sendings&search_status=0", $langs->trans("StatusSendingDraftShort"), 2, $user->hasRight('expedition', 'lire'));
  1884. $newmenu->add("/expedition/list.php?leftmenu=sendings&search_status=1", $langs->trans("StatusSendingValidatedShort"), 2, $user->hasRight('expedition', 'lire'));
  1885. $newmenu->add("/expedition/list.php?leftmenu=sendings&search_status=2", $langs->trans("StatusSendingProcessedShort"), 2, $user->hasRight('expedition', 'lire'));
  1886. }
  1887. $newmenu->add("/expedition/stats/index.php?leftmenu=sendings", $langs->trans("Statistics"), 1, $user->hasRight('expedition', 'lire'));
  1888. }
  1889. // Receptions
  1890. if (isModEnabled('reception')) {
  1891. $langs->load("receptions");
  1892. $newmenu->add("/reception/index.php?leftmenu=receptions", $langs->trans("Receptions"), 0, $user->hasRight('reception', 'lire'), '', $mainmenu, 'receptions', 0, '', '', '', img_picto('', 'dollyrevert', 'class="pictofixedwidth"'));
  1893. $newmenu->add("/reception/card.php?action=create2&amp;leftmenu=receptions", $langs->trans("NewReception"), 1, $user->hasRight('reception', 'creer'));
  1894. $newmenu->add("/reception/list.php?leftmenu=receptions", $langs->trans("List"), 1, $user->hasRight('reception', 'lire'));
  1895. if ($usemenuhider || empty($leftmenu) || $leftmenu == "receptions") {
  1896. $newmenu->add("/reception/list.php?leftmenu=receptions&search_status=0", $langs->trans("StatusReceptionDraftShort"), 2, $user->hasRight('reception', 'lire'));
  1897. }
  1898. if ($usemenuhider || empty($leftmenu) || $leftmenu == "receptions") {
  1899. $newmenu->add("/reception/list.php?leftmenu=receptions&search_status=1", $langs->trans("StatusReceptionValidatedShort"), 2, $user->hasRight('reception', 'lire'));
  1900. }
  1901. if ($usemenuhider || empty($leftmenu) || $leftmenu == "receptions") {
  1902. $newmenu->add("/reception/list.php?leftmenu=receptions&search_status=2", $langs->trans("StatusReceptionProcessedShort"), 2, $user->hasRight('reception', 'lire'));
  1903. }
  1904. $newmenu->add("/reception/stats/index.php?leftmenu=receptions", $langs->trans("Statistics"), 1, $user->hasRight('reception', 'lire'));
  1905. }
  1906. }
  1907. }
  1908. /**
  1909. * Get left Menu PRODUCTS-SERVICES MRP - GPAO
  1910. *
  1911. * @param string $mainmenu Main menu
  1912. * @param Menu $newmenu Object Menu to return back list of menu entries
  1913. * @param string $usemenuhider Use menu hider
  1914. * @param string $leftmenu Left menu
  1915. * @param int $type_user Type of targeted user for menu
  1916. * @return void
  1917. */
  1918. function get_left_menu_mrp($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0)
  1919. {
  1920. global $user, $conf, $langs;
  1921. if ($mainmenu == 'mrp') {
  1922. // BOM
  1923. if (isModEnabled('bom') || isModEnabled('mrp')) {
  1924. $langs->load("mrp");
  1925. $newmenu->add("", $langs->trans("MenuBOM"), 0, $user->hasRight('bom', 'read'), '', $mainmenu, 'bom', 0, '', '', '', img_picto('', 'bom', 'class="paddingright pictofixedwidth"'));
  1926. $newmenu->add("/bom/bom_card.php?leftmenu=bom&amp;action=create", $langs->trans("NewBOM"), 1, $user->hasRight('bom', 'write'), '', $mainmenu, 'bom');
  1927. $newmenu->add("/bom/bom_list.php?leftmenu=bom", $langs->trans("List"), 1, $user->hasRight('bom', 'read'), '', $mainmenu, 'bom');
  1928. }
  1929. if (isModEnabled('mrp')) {
  1930. $langs->load("mrp");
  1931. $newmenu->add("", $langs->trans("MenuMRP"), 0, $user->hasRight('mrp', 'read'), '', $mainmenu, 'mrp', 0, '', '', '', img_picto('', 'mrp', 'class="paddingright pictofixedwidth"'));
  1932. $newmenu->add("/mrp/mo_card.php?leftmenu=mo&amp;action=create", $langs->trans("NewMO"), 1, $user->hasRight('mrp', 'write'), '', $mainmenu, '');
  1933. $newmenu->add("/mrp/mo_list.php?leftmenu=mo", $langs->trans("List"), 1, $user->hasRight('mrp', 'read'), '', $mainmenu, '');
  1934. }
  1935. }
  1936. }
  1937. /**
  1938. * Get left Menu PROJECTS
  1939. *
  1940. * @param string $mainmenu Main menu
  1941. * @param Menu $newmenu Object Menu to return back list of menu entries
  1942. * @param string $usemenuhider Use menu hider
  1943. * @param string $leftmenu Left menu
  1944. * @param int $type_user Type of targeted user for menu
  1945. * @return void
  1946. */
  1947. function get_left_menu_projects($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0)
  1948. {
  1949. global $user, $conf, $langs;
  1950. if ($mainmenu == 'project') {
  1951. if (isModEnabled('projet')) {
  1952. $langs->load("projects");
  1953. $search_project_user = GETPOST('search_project_user', 'int');
  1954. $tmpentry = array(
  1955. 'enabled'=>isModEnabled('projet'),
  1956. 'perms'=>$user->hasRight('projet', 'lire'),
  1957. 'module'=>'projet'
  1958. );
  1959. $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL);
  1960. $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal);
  1961. $titleboth = $langs->trans("LeadsOrProjects");
  1962. $titlenew = $langs->trans("NewLeadOrProject"); // Leads and opportunities by default
  1963. if (empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
  1964. $titleboth = $langs->trans("Projects");
  1965. $titlenew = $langs->trans("NewProject");
  1966. }
  1967. if (isset($conf->global->PROJECT_USE_OPPORTUNITIES) && $conf->global->PROJECT_USE_OPPORTUNITIES == 2) { // 2 = leads only
  1968. $titleboth = $langs->trans("Leads");
  1969. $titlenew = $langs->trans("NewLead");
  1970. }
  1971. // Project assigned to user
  1972. $newmenu->add("/projet/index.php?leftmenu=projects".($search_project_user ? '&search_project_user='.$search_project_user : ''), $titleboth, 0, $user->hasRight('projet', 'lire'), '', $mainmenu, 'projects', 0, '', '', '', img_picto('', 'project', 'class="paddingright pictofixedwidth"'));
  1973. $newmenu->add("/projet/card.php?leftmenu=projects&action=create".($search_project_user ? '&search_project_user='.$search_project_user : ''), $titlenew, 1, $user->hasRight('projet', 'creer'));
  1974. if (empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
  1975. $newmenu->add("/projet/list.php?leftmenu=projets".($search_project_user ? '&search_project_user='.$search_project_user : '').'&search_status=99', $langs->trans("List"), 1, $showmode, '', 'project', 'list');
  1976. } elseif (isset($conf->global->PROJECT_USE_OPPORTUNITIES) && $conf->global->PROJECT_USE_OPPORTUNITIES == 1) {
  1977. $newmenu->add("/projet/list.php?leftmenu=projets".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("List"), 1, $showmode, '', 'project', 'list');
  1978. $newmenu->add('/projet/list.php?mainmenu=project&amp;leftmenu=list&search_usage_opportunity=1&search_status=99&search_opp_status=openedopp&contextpage=lead', $langs->trans("ListOpenLeads"), 2, $showmode);
  1979. $newmenu->add('/projet/list.php?mainmenu=project&amp;leftmenu=list&search_opp_status=notopenedopp&search_status=99&contextpage=project', $langs->trans("ListOpenProjects"), 2, $showmode);
  1980. } elseif (isset($conf->global->PROJECT_USE_OPPORTUNITIES) && $conf->global->PROJECT_USE_OPPORTUNITIES == 2) { // 2 = leads only
  1981. $newmenu->add('/projet/list.php?mainmenu=project&amp;leftmenu=list&search_usage_opportunity=1&search_status=99', $langs->trans("List"), 2, $showmode);
  1982. }
  1983. $newmenu->add("/projet/stats/index.php?leftmenu=projects", $langs->trans("Statistics"), 1, $user->hasRight('projet', 'lire'));
  1984. // Categories
  1985. if (isModEnabled('categorie')) {
  1986. $langs->load("categories");
  1987. $newmenu->add("/categories/index.php?leftmenu=cat&amp;type=6", $langs->trans("Categories"), 1, $user->hasRight('categorie', 'lire'), '', $mainmenu, 'cat');
  1988. }
  1989. if (empty($conf->global->PROJECT_HIDE_TASKS)) {
  1990. // Project affected to user
  1991. $newmenu->add("/projet/activity/index.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("Activities"), 0, $user->hasRight('projet', 'lire'), '', 'project', 'tasks', 0, '', '', '', img_picto('', 'projecttask', 'class="paddingright pictofixedwidth"'));
  1992. $newmenu->add("/projet/tasks.php?leftmenu=tasks&action=create", $langs->trans("NewTask"), 1, $user->hasRight('projet', 'creer'));
  1993. $newmenu->add("/projet/tasks/list.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("List"), 1, $user->hasRight('projet', 'lire'));
  1994. $newmenu->add("/projet/tasks/stats/index.php?leftmenu=projects", $langs->trans("Statistics"), 1, $user->hasRight('projet', 'lire'));
  1995. $newmenu->add("/projet/activity/perweek.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("NewTimeSpent"), 0, $user->hasRight('projet', 'lire'), '', 'project', 'timespent', 0, '', '', '', img_picto('', 'timespent', 'class="paddingright pictofixedwidth"'));
  1996. $newmenu->add("/projet/tasks/time.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("List"), 1, $user->hasRight('projet', 'lire'));
  1997. }
  1998. }
  1999. }
  2000. }
  2001. /**
  2002. * Get left Menu HRM
  2003. *
  2004. * @param string $mainmenu Main menu
  2005. * @param Menu $newmenu Object Menu to return back list of menu entries
  2006. * @param string $usemenuhider Use menu hider
  2007. * @param string $leftmenu Left menu
  2008. * @param int $type_user Type of targeted user for menu
  2009. * @return void
  2010. */
  2011. function get_left_menu_hrm($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0)
  2012. {
  2013. global $user, $conf, $langs;
  2014. if ($mainmenu == 'hrm') {
  2015. // HRM module
  2016. if (isModEnabled('hrm')) {
  2017. $langs->load("hrm");
  2018. $newmenu->add("/user/list.php?mainmenu=hrm&leftmenu=hrm&contextpage=employeelist", $langs->trans("Employees"), 0, $user->hasRight('user', 'user', 'read'), '', $mainmenu, 'hrm', 0, '', '', '', img_picto('', 'user', 'class="paddingright pictofixedwidth"'));
  2019. $newmenu->add("/user/card.php?mainmenu=hrm&leftmenu=hrm&action=create&employee=1", $langs->trans("NewEmployee"), 1, $user->hasRight('user', 'user', 'write'));
  2020. $newmenu->add("/user/list.php?mainmenu=hrm&leftmenu=hrm&contextpage=employeelist", $langs->trans("List"), 1, $user->hasRight('user', 'user', 'read'));
  2021. $newmenu->add("/hrm/skill_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("SkillsManagement"), 0, $user->hasRight('hrm', 'all', 'read'), '', $mainmenu, 'hrm_sm', 0, '', '', '', img_picto('', 'shapes', 'class="paddingright pictofixedwidth"'));
  2022. // Skills
  2023. $newmenu->add("/hrm/skill_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("Skills"), 1, $user->hasRight('hrm', 'all', 'read'), '', $mainmenu, 'hrm_sm', 0, '', '', '', img_picto('', 'shapes', 'class="paddingright pictofixedwidth"'));
  2024. //$newmenu->add("/hrm/skill_card.php?mainmenu=hrm&leftmenu=hrm_sm&action=create", $langs->trans("NewSkill"), 1, $user->hasRight('hrm', 'all', 'write'));
  2025. //$newmenu->add("/hrm/skill_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("List"), 1, $user->hasRight('hrm', 'all', 'read'));
  2026. // Job (Description of work to do and skills required)
  2027. $newmenu->add("/hrm/job_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("JobsProfiles"), 1, $user->hasRight('hrm', 'all', 'read'), '', $mainmenu, 'hrm_sm', 0, '', '', '', img_picto('', 'technic', 'class="paddingright pictofixedwidth"'));
  2028. //$newmenu->add("/hrm/job_card.php?mainmenu=hrm&leftmenu=hrm_sm&action=create", $langs->transnoentities("NewObject", $langs->trans("Job")), 1, $user->hasRight('hrm', 'all', 'write'));
  2029. //$newmenu->add("/hrm/job_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("List"), 1, $user->hasRight('hrm', 'all', 'read'));
  2030. // Position = Link job - user
  2031. $newmenu->add("/hrm/position_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("EmployeePositions"), 1, $user->hasRight('hrm', 'all', 'read'), '', $mainmenu, 'hrm_sm', 0, '', '', '', img_picto('', 'user-cog', 'class="paddingright pictofixedwidth"'));
  2032. //$newmenu->add("/hrm/position.php?mainmenu=hrm&leftmenu=hrm_sm&action=create", $langs->transnoentities("NewObject", $langs->trans("Position")), 1, $user->hasRight('hrm', 'all', 'write'));
  2033. //$newmenu->add("/hrm/position_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("List"), 1, $user->hasRight('hrm', 'all', 'read'));
  2034. // Evaluation
  2035. $newmenu->add("/hrm/evaluation_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("Evals"), 1, $user->hasRight('hrm', 'evaluation', 'read'), '', $mainmenu, 'hrm_sm', 0, '', '', '', img_picto('', 'user', 'class="paddingright pictofixedwidth"'));
  2036. //$newmenu->add("/hrm/evaluation_card.php?mainmenu=hrm&leftmenu=hrm_sm&action=create", $langs->trans("NewEval"), 1, $user->hasRight('hrm', 'evaluation', 'write'));
  2037. //$newmenu->add("/hrm/evaluation_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("List"), 1, $user->hasRight('hrm', 'evaluation', 'read'));
  2038. $newmenu->add("/hrm/compare.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("SkillComparison"), 1, $user->hasRight('hrm', 'evaluation', 'read') || $user->hasRight('hrm', 'compare_advance', 'read'));
  2039. }
  2040. // Leave/Holiday/Vacation module
  2041. if (isModEnabled('holiday')) {
  2042. // Load translation files required by the page
  2043. $langs->loadLangs(array("holiday", "trips"));
  2044. $newmenu->add("/holiday/list.php?mainmenu=hrm&leftmenu=holiday", $langs->trans("CPTitreMenu"), 0, $user->hasRight('holiday', 'read'), '', $mainmenu, 'holiday', 0, '', '', '', img_picto('', 'holiday', 'class="paddingright pictofixedwidth"'));
  2045. $newmenu->add("/holiday/card.php?mainmenu=hrm&leftmenu=holiday&action=create", $langs->trans("New"), 1, $user->hasRight('holiday', 'write'), '', $mainmenu);
  2046. $newmenu->add("/holiday/card_group.php?mainmenu=hrm&leftmenu=holiday&action=create", $langs->trans("NewHolidayForGroup"), 1, ($user->hasRight('holiday', 'writeall') && $user->hasRight('holiday', 'readall')), '', $mainmenu, 'holiday_sm');
  2047. $newmenu->add("/holiday/list.php?mainmenu=hrm&leftmenu=holiday", $langs->trans("List"), 1, $user->hasRight('holiday', 'read'), '', $mainmenu);
  2048. if ($usemenuhider || empty($leftmenu) || $leftmenu == "holiday") {
  2049. $newmenu->add("/holiday/list.php?search_status=1&mainmenu=hrm&leftmenu=holiday", $langs->trans("DraftCP"), 2, $user->hasRight('holiday', 'read'), '', $mainmenu, 'holiday_sm');
  2050. $newmenu->add("/holiday/list.php?search_status=2&mainmenu=hrm&leftmenu=holiday", $langs->trans("ToReviewCP"), 2, $user->hasRight('holiday', 'read'), '', $mainmenu, 'holiday_sm');
  2051. $newmenu->add("/holiday/list.php?search_status=3&mainmenu=hrm&leftmenu=holiday", $langs->trans("ApprovedCP"), 2, $user->hasRight('holiday', 'read'), '', $mainmenu, 'holiday_sm');
  2052. $newmenu->add("/holiday/list.php?search_status=4&mainmenu=hrm&leftmenu=holiday", $langs->trans("CancelCP"), 2, $user->hasRight('holiday', 'read'), '', $mainmenu, 'holiday_sm');
  2053. $newmenu->add("/holiday/list.php?search_status=5&mainmenu=hrm&leftmenu=holiday", $langs->trans("RefuseCP"), 2, $user->hasRight('holiday', 'read'), '', $mainmenu, 'holiday_sm');
  2054. }
  2055. $newmenu->add("/holiday/define_holiday.php?mainmenu=hrm", $langs->trans("MenuConfCP"), 1, $user->hasRight('holiday', 'read'), '', $mainmenu, 'holiday_sm');
  2056. $newmenu->add("/holiday/month_report.php?mainmenu=hrm&leftmenu=holiday", $langs->trans("MenuReportMonth"), 1, $user->hasRight('holiday', 'readall'), '', $mainmenu, 'holiday_sm');
  2057. $newmenu->add("/holiday/view_log.php?mainmenu=hrm&leftmenu=holiday", $langs->trans("MenuLogCP"), 1, $user->hasRight('holiday', 'define_holiday'), '', $mainmenu, 'holiday_sm');
  2058. }
  2059. // Trips and expenses (old module)
  2060. if (isModEnabled('deplacement')) {
  2061. $langs->load("trips");
  2062. $newmenu->add("/compta/deplacement/index.php?leftmenu=tripsandexpenses&amp;mainmenu=hrm", $langs->trans("TripsAndExpenses"), 0, $user->hasRight('deplacement', 'lire'), '', $mainmenu, 'tripsandexpenses', 0, '', '', '', img_picto('', 'trip', 'class="paddingright pictofixedwidth"'));
  2063. $newmenu->add("/compta/deplacement/card.php?action=create&amp;leftmenu=tripsandexpenses&amp;mainmenu=hrm", $langs->trans("New"), 1, $user->hasRight('deplacement', 'creer'));
  2064. $newmenu->add("/compta/deplacement/list.php?leftmenu=tripsandexpenses&amp;mainmenu=hrm", $langs->trans("List"), 1, $user->hasRight('deplacement', 'lire'));
  2065. $newmenu->add("/compta/deplacement/stats/index.php?leftmenu=tripsandexpenses&amp;mainmenu=hrm", $langs->trans("Statistics"), 1, $user->hasRight('deplacement', 'lire'));
  2066. }
  2067. // Expense report
  2068. if (isModEnabled('expensereport')) {
  2069. $langs->loadLangs(array("trips", "bills"));
  2070. $newmenu->add("/expensereport/index.php?leftmenu=expensereport&amp;mainmenu=hrm", $langs->trans("TripsAndExpenses"), 0, $user->hasRight('expensereport', 'lire'), '', $mainmenu, 'expensereport', 0, '', '', '', img_picto('', 'trip', 'class="paddingright pictofixedwidth"'));
  2071. $newmenu->add("/expensereport/card.php?action=create&amp;leftmenu=expensereport&amp;mainmenu=hrm", $langs->trans("New"), 1, $user->hasRight('expensereport', 'creer'));
  2072. $newmenu->add("/expensereport/list.php?leftmenu=expensereport&amp;mainmenu=hrm", $langs->trans("List"), 1, $user->hasRight('expensereport', 'lire'));
  2073. if ($usemenuhider || empty($leftmenu) || $leftmenu == "expensereport") {
  2074. $newmenu->add("/expensereport/list.php?search_status=0&amp;leftmenu=expensereport&amp;mainmenu=hrm", $langs->trans("Draft"), 2, $user->hasRight('expensereport', 'lire'));
  2075. $newmenu->add("/expensereport/list.php?search_status=2&amp;leftmenu=expensereport&amp;mainmenu=hrm", $langs->trans("Validated"), 2, $user->hasRight('expensereport', 'lire'));
  2076. $newmenu->add("/expensereport/list.php?search_status=5&amp;leftmenu=expensereport&amp;mainmenu=hrm", $langs->trans("Approved"), 2, $user->hasRight('expensereport', 'lire'));
  2077. $newmenu->add("/expensereport/list.php?search_status=6&amp;leftmenu=expensereport&amp;mainmenu=hrm", $langs->trans("Paid"), 2, $user->hasRight('expensereport', 'lire'));
  2078. $newmenu->add("/expensereport/list.php?search_status=4&amp;leftmenu=expensereport&amp;mainmenu=hrm", $langs->trans("Canceled"), 2, $user->hasRight('expensereport', 'lire'));
  2079. $newmenu->add("/expensereport/list.php?search_status=99&amp;leftmenu=expensereport&amp;mainmenu=hrm", $langs->trans("Refused"), 2, $user->hasRight('expensereport', 'lire'));
  2080. }
  2081. $newmenu->add("/expensereport/payment/list.php?leftmenu=expensereport_payments&amp;mainmenu=hrm", $langs->trans("Payments"), 1, $user->hasRight('expensereport', 'lire'));
  2082. $newmenu->add("/expensereport/stats/index.php?leftmenu=expensereport&amp;mainmenu=hrm", $langs->trans("Statistics"), 1, $user->hasRight('expensereport', 'lire'));
  2083. }
  2084. if (isModEnabled('projet')) {
  2085. if (empty($conf->global->PROJECT_HIDE_TASKS)) {
  2086. $langs->load("projects");
  2087. $search_project_user = GETPOST('search_project_user', 'int');
  2088. $newmenu->add("/projet/activity/perweek.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("NewTimeSpent"), 0, $user->hasRight('projet', 'lire'), '', $mainmenu, 'timespent', 0, '', '', '', img_picto('', 'timespent', 'class="paddingright pictofixedwidth"'));
  2089. }
  2090. }
  2091. }
  2092. }
  2093. /**
  2094. * Get left Menu TOOLS
  2095. *
  2096. * @param string $mainmenu Main menu
  2097. * @param Menu $newmenu Object Menu to return back list of menu entries
  2098. * @param string $usemenuhider Use menu hider
  2099. * @param string $leftmenu Left menu
  2100. * @param int $type_user Type of targeted user for menu
  2101. * @return void
  2102. */
  2103. function get_left_menu_tools($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0)
  2104. {
  2105. global $user, $conf, $langs;
  2106. if ($mainmenu == 'tools') {
  2107. if (empty($user->socid)) { // limit to internal users
  2108. $langs->load("mails");
  2109. $newmenu->add("/admin/mails_templates.php?leftmenu=email_templates", $langs->trans("EMailTemplates"), 0, 1, '', $mainmenu, 'email_templates', 0, '', '', '', img_picto('', 'email', 'class="paddingright pictofixedwidth"'));
  2110. }
  2111. if (isModEnabled('mailing')) {
  2112. $newmenu->add("/comm/mailing/index.php?leftmenu=mailing", $langs->trans("EMailings"), 0, $user->hasRight('mailing', 'lire'), '', $mainmenu, 'mailing', 0, '', '', '', img_picto('', 'email', 'class="paddingright pictofixedwidth"'));
  2113. $newmenu->add("/comm/mailing/card.php?leftmenu=mailing&amp;action=create", $langs->trans("NewMailing"), 1, $user->hasRight('mailing', 'creer'));
  2114. $newmenu->add("/comm/mailing/list.php?leftmenu=mailing", $langs->trans("List"), 1, $user->hasRight('mailing', 'lire'));
  2115. }
  2116. if (isModEnabled('export')) {
  2117. $langs->load("exports");
  2118. $newmenu->add("/exports/index.php?leftmenu=export", $langs->trans("FormatedExport"), 0, $user->hasRight('export', 'lire'), '', $mainmenu, 'export', 0, '', '', '', img_picto('', 'technic', 'class="paddingright pictofixedwidth"'));
  2119. $newmenu->add("/exports/export.php?leftmenu=export", $langs->trans("NewExport"), 1, $user->hasRight('export', 'creer'));
  2120. //$newmenu->add("/exports/export.php?leftmenu=export",$langs->trans("List"),1, $user->hasRight('export', 'lire'));
  2121. }
  2122. if (isModEnabled('import')) {
  2123. $langs->load("exports");
  2124. $newmenu->add("/imports/index.php?leftmenu=import", $langs->trans("FormatedImport"), 0, $user->hasRight('import', 'run'), '', $mainmenu, 'import', 0, '', '', '', img_picto('', 'technic', 'class="paddingright pictofixedwidth"'));
  2125. $newmenu->add("/imports/import.php?leftmenu=import", $langs->trans("NewImport"), 1, $user->hasRight('import', 'run'));
  2126. }
  2127. }
  2128. }
  2129. /**
  2130. * Get left Menu MEMBERS
  2131. *
  2132. * @param string $mainmenu Main menu
  2133. * @param Menu $newmenu Object Menu to return back list of menu entries
  2134. * @param string $usemenuhider Use menu hider
  2135. * @param string $leftmenu Left menu
  2136. * @param int $type_user Type of targeted user for menu
  2137. * @return void
  2138. */
  2139. function get_left_menu_members($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0)
  2140. {
  2141. global $user, $conf, $langs;
  2142. if ($mainmenu == 'members') {
  2143. if (isModEnabled('adherent')) {
  2144. // Load translation files required by the page
  2145. $langs->loadLangs(array("members", "compta"));
  2146. $newmenu->add("/adherents/index.php?leftmenu=members&amp;mainmenu=members", $langs->trans("Members"), 0, $user->hasRight('adherent', 'read'), '', $mainmenu, 'members', 0, '', '', '', img_picto('', 'member', 'class="paddingright pictofixedwidth"'));
  2147. $newmenu->add("/adherents/card.php?leftmenu=members&amp;action=create", $langs->trans("NewMember"), 1, $user->hasRight('adherent', 'write'));
  2148. $newmenu->add("/adherents/list.php?leftmenu=members", $langs->trans("List"), 1, $user->hasRight('adherent', 'read'));
  2149. $newmenu->add("/adherents/list.php?leftmenu=members&amp;statut=-1", $langs->trans("MenuMembersToValidate"), 2, $user->hasRight('adherent', 'read'));
  2150. $newmenu->add("/adherents/list.php?leftmenu=members&amp;statut=1", $langs->trans("MenuMembersValidated"), 2, $user->hasRight('adherent', 'read'));
  2151. $newmenu->add("/adherents/list.php?leftmenu=members&amp;statut=1&amp;filter=waitingsubscription", $langs->trans("WaitingSubscription"), 3, $user->hasRight('adherent', 'read'));
  2152. $newmenu->add("/adherents/list.php?leftmenu=members&amp;statut=1&amp;filter=uptodate", $langs->trans("UpToDate"), 3, $user->hasRight('adherent', 'read'));
  2153. $newmenu->add("/adherents/list.php?leftmenu=members&amp;statut=1&amp;filter=outofdate", $langs->trans("OutOfDate"), 3, $user->hasRight('adherent', 'read'));
  2154. $newmenu->add("/adherents/list.php?leftmenu=members&amp;statut=0", $langs->trans("MenuMembersResiliated"), 2, $user->hasRight('adherent', 'read'));
  2155. $newmenu->add("/adherents/list.php?leftmenu=members&amp;statut=-2", $langs->trans("MenuMembersExcluded"), 2, $user->hasRight('adherent', 'read'));
  2156. $newmenu->add("/adherents/stats/index.php?leftmenu=members", $langs->trans("MenuMembersStats"), 1, $user->hasRight('adherent', 'read'));
  2157. $newmenu->add("/adherents/cartes/carte.php?leftmenu=export", $langs->trans("MembersCards"), 1, $user->hasRight('adherent', 'export'));
  2158. if (!empty($conf->global->MEMBER_LINK_TO_HTPASSWDFILE) && ($usemenuhider || empty($leftmenu) || $leftmenu == 'none' || $leftmenu == "members" || $leftmenu == "export")) {
  2159. $newmenu->add("/adherents/htpasswd.php?leftmenu=export", $langs->trans("Filehtpasswd"), 1, $user->hasRight('adherent', 'export'));
  2160. }
  2161. if (isModEnabled('categorie')) {
  2162. $langs->load("categories");
  2163. $newmenu->add("/categories/index.php?leftmenu=cat&amp;type=3", $langs->trans("Categories"), 1, $user->hasRight('categorie', 'read'), '', $mainmenu, 'cat');
  2164. }
  2165. $newmenu->add("/adherents/index.php?leftmenu=members&amp;mainmenu=members", $langs->trans("Subscriptions"), 0, $user->hasRight('adherent', 'cotisation', 'read'), '', $mainmenu, 'members', 0, '', '', '', img_picto('', 'payment', 'class="paddingright pictofixedwidth"'));
  2166. $newmenu->add("/adherents/list.php?leftmenu=members&amp;statut=-1,1&amp;mainmenu=members", $langs->trans("NewSubscription"), 1, $user->hasRight('adherent', 'cotisation', 'write'));
  2167. $newmenu->add("/adherents/subscription/list.php?leftmenu=members", $langs->trans("List"), 1, $user->hasRight('adherent', 'cotisation', 'read'));
  2168. $newmenu->add("/adherents/stats/index.php?leftmenu=members", $langs->trans("MenuMembersStats"), 1, $user->hasRight('adherent', 'read'));
  2169. //$newmenu->add("/adherents/index.php?leftmenu=export&amp;mainmenu=members",$langs->trans("Tools"),0,$user->hasRight('adherent', 'export'), '', $mainmenu, 'export');
  2170. //if (isModEnabled('export') && ($usemenuhider || empty($leftmenu) || $leftmenu=="export")) $newmenu->add("/exports/index.php?leftmenu=export",$langs->trans("Datas"),1,$user->hasRight('adherent', 'export'));
  2171. // Type
  2172. $newmenu->add("/adherents/type.php?leftmenu=setup&amp;mainmenu=members", $langs->trans("MembersTypes"), 0, $user->hasRight('adherent', 'configurer'), '', $mainmenu, 'setup', 0, '', '', '', img_picto('', 'members', 'class="paddingright pictofixedwidth"'));
  2173. $newmenu->add("/adherents/type.php?leftmenu=setup&amp;mainmenu=members&amp;action=create", $langs->trans("New"), 1, $user->hasRight('adherent', 'configurer'));
  2174. $newmenu->add("/adherents/type.php?leftmenu=setup&amp;mainmenu=members", $langs->trans("List"), 1, $user->hasRight('adherent', 'configurer'));
  2175. }
  2176. }
  2177. }