eldy.lib.php 146 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449
  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('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || 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->results)) {
  800. $menu_array[] = $hookmanager->results; // add
  801. } elseif ($reshook == 1) {
  802. $menu_array = $hookmanager->results; // 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. // Load translation files required by the page
  980. $langs->loadLangs(array("admin", "help"));
  981. $warnpicto = '';
  982. if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) {
  983. $langs->load("errors");
  984. $warnpicto = img_warning($langs->trans("WarningMandatorySetupNotComplete"));
  985. }
  986. $newmenu->add("/admin/company.php?mainmenu=home", $langs->trans("MenuCompanySetup").$warnpicto, 1);
  987. $warnpicto = '';
  988. if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING) ? 1 : $conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) { // If only user module enabled
  989. $langs->load("errors");
  990. $warnpicto = img_warning($langs->trans("WarningMandatorySetupNotComplete"));
  991. }
  992. $newmenu->add("/admin/modules.php?mainmenu=home", $langs->trans("Modules").$warnpicto, 1);
  993. $newmenu->add("/admin/ihm.php?mainmenu=home", $langs->trans("GUISetup"), 1);
  994. $newmenu->add("/admin/menus.php?mainmenu=home", $langs->trans("Menus"), 1);
  995. $newmenu->add("/admin/translation.php?mainmenu=home", $langs->trans("Translation"), 1);
  996. $newmenu->add("/admin/defaultvalues.php?mainmenu=home", $langs->trans("DefaultValues"), 1);
  997. $newmenu->add("/admin/boxes.php?mainmenu=home", $langs->trans("Boxes"), 1);
  998. $newmenu->add("/admin/delais.php?mainmenu=home", $langs->trans("MenuWarnings"), 1);
  999. $newmenu->add("/admin/security_other.php?mainmenu=home", $langs->trans("Security"), 1);
  1000. $newmenu->add("/admin/limits.php?mainmenu=home", $langs->trans("MenuLimits"), 1);
  1001. $newmenu->add("/admin/pdf.php?mainmenu=home", $langs->trans("PDF"), 1);
  1002. $warnpicto = '';
  1003. if (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail' && empty($conf->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) {
  1004. $langs->load("errors");
  1005. $warnpicto = img_warning($langs->trans("WarningPHPMailD"));
  1006. }
  1007. if (!empty($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmail')) && empty($conf->global->MAIN_MAIL_SMTP_SERVER)) {
  1008. $langs->load("errors");
  1009. $warnpicto = img_warning($langs->trans("ErrorSetupOfEmailsNotComplete"));
  1010. }
  1011. $newmenu->add("/admin/mails.php?mainmenu=home", $langs->trans("Emails").$warnpicto, 1);
  1012. $newmenu->add("/admin/sms.php?mainmenu=home", $langs->trans("SMS"), 1);
  1013. $newmenu->add("/admin/dict.php?mainmenu=home", $langs->trans("Dictionary"), 1);
  1014. $newmenu->add("/admin/const.php?mainmenu=home", $langs->trans("OtherSetup"), 1);
  1015. }
  1016. // System tools
  1017. $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>');
  1018. if ($usemenuhider || empty($leftmenu) || preg_match('/^admintools/', $leftmenu)) {
  1019. // Load translation files required by the page
  1020. $langs->loadLangs(array('admin', 'help'));
  1021. $newmenu->add('/admin/system/dolibarr.php?mainmenu=home&amp;leftmenu=admintools_info', $langs->trans('InfoDolibarr'), 1);
  1022. if ($usemenuhider || empty($leftmenu) || $leftmenu == 'admintools_info') {
  1023. $newmenu->add('/admin/system/modules.php?mainmenu=home&amp;leftmenu=admintools_info', $langs->trans('Modules'), 2);
  1024. $newmenu->add('/admin/triggers.php?mainmenu=home&amp;leftmenu=admintools_info', $langs->trans('Triggers'), 2);
  1025. $newmenu->add('/admin/system/filecheck.php?mainmenu=home&amp;leftmenu=admintools_info', $langs->trans('FileCheck'), 2);
  1026. }
  1027. $newmenu->add('/admin/system/browser.php?mainmenu=home&amp;leftmenu=admintools', $langs->trans('InfoBrowser'), 1);
  1028. $newmenu->add('/admin/system/os.php?mainmenu=home&amp;leftmenu=admintools', $langs->trans('InfoOS'), 1);
  1029. $newmenu->add('/admin/system/web.php?mainmenu=home&amp;leftmenu=admintools', $langs->trans('InfoWebServer'), 1);
  1030. $newmenu->add('/admin/system/phpinfo.php?mainmenu=home&amp;leftmenu=admintools', $langs->trans('InfoPHP'), 1);
  1031. $newmenu->add('/admin/system/database.php?mainmenu=home&amp;leftmenu=admintools', $langs->trans('InfoDatabase'), 1);
  1032. $newmenu->add("/admin/system/perf.php?mainmenu=home&amp;leftmenu=admintools", $langs->trans("InfoPerf"), 1);
  1033. $newmenu->add("/admin/system/security.php?mainmenu=home&amp;leftmenu=admintools", $langs->trans("InfoSecurity"), 1);
  1034. $newmenu->add("/admin/tools/dolibarr_export.php?mainmenu=home&amp;leftmenu=admintools", $langs->trans("Backup"), 1);
  1035. $newmenu->add("/admin/tools/dolibarr_import.php?mainmenu=home&amp;leftmenu=admintools", $langs->trans("Restore"), 1);
  1036. $newmenu->add("/admin/tools/update.php?mainmenu=home&amp;leftmenu=admintools", $langs->trans("MenuUpgrade"), 1);
  1037. $newmenu->add("/admin/tools/purge.php?mainmenu=home&amp;leftmenu=admintools", $langs->trans("Purge"), 1);
  1038. $newmenu->add("/admin/tools/listevents.php?mainmenu=home&amp;leftmenu=admintools", $langs->trans("Audit"), 1);
  1039. $newmenu->add("/admin/tools/listsessions.php?mainmenu=home&amp;leftmenu=admintools", $langs->trans("Sessions"), 1);
  1040. $newmenu->add('/admin/system/about.php?mainmenu=home&amp;leftmenu=admintools', $langs->trans('ExternalResources'), 1);
  1041. if (isModEnabled('product') || isModEnabled('service')) {
  1042. $langs->load("products");
  1043. $newmenu->add("/product/admin/product_tools.php?mainmenu=home&amp;leftmenu=admintools", $langs->trans("ProductVatMassChange"), 1, $user->admin);
  1044. }
  1045. }
  1046. $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"'));
  1047. if ($user->hasRight('user', 'user', 'read')) {
  1048. if ($usemenuhider || empty($leftmenu) || $leftmenu == "users") {
  1049. $newmenu->add("", $langs->trans("Users"), 1, $user->hasRight('user', 'user', 'lire') || $user->admin);
  1050. $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 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE), '', 'home');
  1051. $newmenu->add("/user/list.php?leftmenu=users", $langs->trans("ListOfUsers"), 2, $user->hasRight('user', 'user', 'lire') || $user->admin);
  1052. $newmenu->add("/user/hierarchy.php?leftmenu=users", $langs->trans("HierarchicView"), 2, $user->hasRight('user', 'user', 'lire') || $user->admin);
  1053. if (isModEnabled('categorie')) {
  1054. $langs->load("categories");
  1055. $newmenu->add("/categories/index.php?leftmenu=users&type=7", $langs->trans("UsersCategoriesShort"), 2, $user->hasRight('categorie', 'lire'), '', $mainmenu, 'cat');
  1056. }
  1057. $newmenu->add("", $langs->trans("Groups"), 1, ($user->hasRight('user', 'user', 'lire') || $user->admin) && !(isModEnabled('multicompany') && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE));
  1058. $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 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE));
  1059. $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 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE));
  1060. }
  1061. }
  1062. }
  1063. }
  1064. /**
  1065. * Get left Menu THIRDPARTIES
  1066. *
  1067. * @param string $mainmenu Main menu
  1068. * @param Menu $newmenu Object Menu to return back list of menu entries
  1069. * @param string $usemenuhider Use menu hider
  1070. * @param string $leftmenu Left menu
  1071. * @param int $type_user Type of targeted user for menu
  1072. * @return void
  1073. */
  1074. function get_left_menu_thridparties($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0)
  1075. {
  1076. global $user, $conf, $langs;
  1077. if ($mainmenu == 'companies') {
  1078. // Societes
  1079. if (isModEnabled('societe')) {
  1080. $langs->load("companies");
  1081. $newmenu->add("/societe/index.php?leftmenu=thirdparties", $langs->trans("ThirdParty"), 0, $user->hasRight('societe', 'lire'), '', $mainmenu, 'thirdparties', 0, '', '', '', img_picto('', 'company', 'class="paddingright pictofixedwidth"'));
  1082. if ($user->hasRight('societe', 'creer')) {
  1083. $newmenu->add("/societe/card.php?action=create", $langs->trans("MenuNewThirdParty"), 1);
  1084. if (!$conf->use_javascript_ajax) {
  1085. $newmenu->add("/societe/card.php?action=create&amp;private=1", $langs->trans("MenuNewPrivateIndividual"), 1);
  1086. }
  1087. }
  1088. }
  1089. $newmenu->add("/societe/list.php?leftmenu=thirdparties", $langs->trans("List"), 1);
  1090. // Prospects
  1091. if (isModEnabled('societe') && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
  1092. $langs->load("commercial");
  1093. $newmenu->add("/societe/list.php?type=p&amp;leftmenu=prospects", $langs->trans("ListProspectsShort"), 2, $user->hasRight('societe', 'lire'), '', $mainmenu, 'prospects');
  1094. /* no more required, there is a filter that can do more
  1095. 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'));
  1096. 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'));
  1097. 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'));
  1098. 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'));
  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=3", $langs->trans("LastProspectContactDone"), 2, $user->hasRight('societe', 'lire'));
  1100. */
  1101. $newmenu->add("/societe/card.php?leftmenu=prospects&amp;action=create&amp;type=p", $langs->trans("MenuNewProspect"), 3, $user->hasRight('societe', 'creer'));
  1102. }
  1103. // Customers/Prospects
  1104. if (isModEnabled('societe') && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
  1105. $langs->load("commercial");
  1106. $newmenu->add("/societe/list.php?type=c&amp;leftmenu=customers", $langs->trans("ListCustomersShort"), 2, $user->hasRight('societe', 'lire'), '', $mainmenu, 'customers');
  1107. $newmenu->add("/societe/card.php?leftmenu=customers&amp;action=create&amp;type=c", $langs->trans("MenuNewCustomer"), 3, $user->hasRight('societe', 'creer'));
  1108. }
  1109. // Suppliers
  1110. if (isModEnabled('societe') && (((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('supplier_order') || isModEnabled('supplier_invoice')) || isModEnabled('supplier_proposal'))) {
  1111. $langs->load("suppliers");
  1112. $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');
  1113. $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')));
  1114. }
  1115. // Categories
  1116. if (isModEnabled('categorie')) {
  1117. $langs->load("categories");
  1118. if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
  1119. // Categories prospects/customers
  1120. $menutoshow = $langs->trans("CustomersProspectsCategoriesShort");
  1121. if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
  1122. $menutoshow = $langs->trans("CustomersCategoriesShort");
  1123. }
  1124. if (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
  1125. $menutoshow = $langs->trans("ProspectsCategoriesShort");
  1126. }
  1127. $newmenu->add("/categories/index.php?leftmenu=cat&amp;type=2", $menutoshow, 1, $user->hasRight('categorie', 'lire'), '', $mainmenu, 'cat');
  1128. }
  1129. // Categories suppliers
  1130. if ((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('supplier_order') || isModEnabled('supplier_invoice')) {
  1131. $newmenu->add("/categories/index.php?leftmenu=catfournish&amp;type=1", $langs->trans("SuppliersCategoriesShort"), 1, $user->hasRight('categorie', 'lire'));
  1132. }
  1133. }
  1134. // Contacts
  1135. $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"'));
  1136. $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'));
  1137. $newmenu->add("/contact/list.php?leftmenu=contacts", $langs->trans("List"), 1, $user->hasRight('societe', 'contact', 'lire'));
  1138. if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
  1139. $newmenu->add("/contact/list.php?leftmenu=contacts&type=p", $langs->trans("Prospects"), 2, $user->hasRight('societe', 'contact', 'lire'));
  1140. }
  1141. if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
  1142. $newmenu->add("/contact/list.php?leftmenu=contacts&type=c", $langs->trans("Customers"), 2, $user->hasRight('societe', 'contact', 'lire'));
  1143. }
  1144. if ((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('supplier_order') || isModEnabled('supplier_invoice')) {
  1145. $newmenu->add("/contact/list.php?leftmenu=contacts&type=f", $langs->trans("Suppliers"), 2, $user->hasRight('fournisseur', 'lire'));
  1146. }
  1147. $newmenu->add("/contact/list.php?leftmenu=contacts&type=o", $langs->trans("ContactOthers"), 2, $user->hasRight('societe', 'contact', 'lire'));
  1148. //$newmenu->add("/contact/list.php?userid=$user->id", $langs->trans("MyContacts"), 1, $user->hasRight('societe', 'contact', 'lire'));
  1149. // Categories
  1150. if (isModEnabled('categorie')) {
  1151. $langs->load("categories");
  1152. // Categories Contact
  1153. $newmenu->add("/categories/index.php?leftmenu=catcontact&amp;type=4", $langs->trans("ContactCategoriesShort"), 1, $user->hasRight('categorie', 'lire'), '', $mainmenu, 'cat');
  1154. }
  1155. }
  1156. }
  1157. /**
  1158. * Get left Menu COMMERCIAL (propal, commande, supplier_proposal, supplier_order, contrat, ficheinter)
  1159. *
  1160. * @param string $mainmenu Main menu
  1161. * @param Menu $newmenu Object Menu to return back list of menu entries
  1162. * @param string $usemenuhider Use menu hider
  1163. * @param string $leftmenu Left menu
  1164. * @param int $type_user Type of targeted user for menu
  1165. * @return void
  1166. */
  1167. function get_left_menu_commercial($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0)
  1168. {
  1169. global $user, $conf, $langs;
  1170. if ($mainmenu == 'commercial') {
  1171. $langs->load("companies");
  1172. // Customer proposal
  1173. if (isModEnabled('propal')) {
  1174. $langs->load("propal");
  1175. $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"'));
  1176. $newmenu->add("/comm/propal/card.php?action=create&amp;leftmenu=propals", $langs->trans("NewPropal"), 1, $user->hasRight('propal', 'write'));
  1177. $newmenu->add("/comm/propal/list.php?leftmenu=propals", $langs->trans("List"), 1, $user->hasRight('propal', 'read'));
  1178. if ($usemenuhider || empty($leftmenu) || $leftmenu == "propals") {
  1179. $newmenu->add("/comm/propal/list.php?leftmenu=propals&search_status=0", $langs->trans("PropalsDraft"), 2, $user->hasRight('propal', 'read'));
  1180. $newmenu->add("/comm/propal/list.php?leftmenu=propals&search_status=1", $langs->trans("PropalsOpened"), 2, $user->hasRight('propal', 'read'));
  1181. $newmenu->add("/comm/propal/list.php?leftmenu=propals&search_status=2", $langs->trans("PropalStatusSigned"), 2, $user->hasRight('propal', 'read'));
  1182. $newmenu->add("/comm/propal/list.php?leftmenu=propals&search_status=3", $langs->trans("PropalStatusNotSigned"), 2, $user->hasRight('propal', 'read'));
  1183. $newmenu->add("/comm/propal/list.php?leftmenu=propals&search_status=4", $langs->trans("PropalStatusBilled"), 2, $user->hasRight('propal', 'read'));
  1184. //$newmenu->add("/comm/propal/list.php?leftmenu=propals&search_status=2,3,4", $langs->trans("PropalStatusClosedShort"), 2, $user->hasRight('propal', 'read'));
  1185. }
  1186. $newmenu->add("/comm/propal/stats/index.php?leftmenu=propals", $langs->trans("Statistics"), 1, $user->hasRight('propal', 'read'));
  1187. }
  1188. // Customers orders
  1189. if (isModEnabled('commande')) {
  1190. $langs->load("orders");
  1191. $newmenu->add("/commande/index.php?leftmenu=orders", $langs->trans("CustomersOrders"), 0, $user->hasRight('commande', 'lire'), '', $mainmenu, 'orders', 200, '', '', '', img_picto('', 'order', 'class="paddingright pictofixedwidth"'));
  1192. $newmenu->add("/commande/card.php?action=create&amp;leftmenu=orders", $langs->trans("NewOrder"), 1, $user->hasRight('commande', 'creer'));
  1193. $newmenu->add("/commande/list.php?leftmenu=orders", $langs->trans("List"), 1, $user->hasRight('commande', 'lire'));
  1194. if ($usemenuhider || empty($leftmenu) || $leftmenu == "orders") {
  1195. $newmenu->add("/commande/list.php?leftmenu=orders&search_status=0", $langs->trans("StatusOrderDraftShort"), 2, $user->hasRight('commande', 'lire'));
  1196. $newmenu->add("/commande/list.php?leftmenu=orders&search_status=1", $langs->trans("StatusOrderValidated"), 2, $user->hasRight('commande', 'lire'));
  1197. if (isModEnabled('expedition')) {
  1198. $newmenu->add("/commande/list.php?leftmenu=orders&search_status=2", $langs->trans("StatusOrderSentShort"), 2, $user->hasRight('commande', 'lire'));
  1199. }
  1200. $newmenu->add("/commande/list.php?leftmenu=orders&search_status=3", $langs->trans("StatusOrderDelivered"), 2, $user->hasRight('commande', 'lire'));
  1201. //$newmenu->add("/commande/list.php?leftmenu=orders&search_status=4", $langs->trans("StatusOrderProcessed"), 2, $user->hasRight('commande', 'lire'));
  1202. $newmenu->add("/commande/list.php?leftmenu=orders&search_status=-1", $langs->trans("StatusOrderCanceledShort"), 2, $user->hasRight('commande', 'lire'));
  1203. }
  1204. if ($conf->global->MAIN_FEATURES_LEVEL >= 2 && empty($user->socid)) {
  1205. $newmenu->add("/commande/list_det.php?leftmenu=orders", $langs->trans("ListOrderLigne"), 1, $user->hasRight('commande', 'lire'));
  1206. }
  1207. $newmenu->add("/commande/stats/index.php?leftmenu=orders", $langs->trans("Statistics"), 1, $user->hasRight('commande', 'lire'));
  1208. }
  1209. // Supplier proposal
  1210. if (isModEnabled('supplier_proposal')) {
  1211. $langs->load("supplier_proposal");
  1212. $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"'));
  1213. $newmenu->add("/supplier_proposal/card.php?action=create&amp;leftmenu=supplier_proposals", $langs->trans("SupplierProposalNew"), 1, $user->hasRight('supplier_proposal', 'creer'));
  1214. $newmenu->add("/supplier_proposal/list.php?leftmenu=supplier_proposals", $langs->trans("List"), 1, $user->hasRight('supplier_proposal', 'lire'));
  1215. $newmenu->add("/comm/propal/stats/index.php?leftmenu=supplier_proposals&amp;mode=supplier", $langs->trans("Statistics"), 1, $user->hasRight('supplier_proposal', 'lire'));
  1216. }
  1217. // Suppliers orders
  1218. if (isModEnabled('supplier_order')) {
  1219. $langs->load("orders");
  1220. $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"'));
  1221. $newmenu->add("/fourn/commande/card.php?action=create&amp;leftmenu=orders_suppliers", $langs->trans("NewSupplierOrderShort"), 1, $user->hasRight('fournisseur', 'commande', 'creer'));
  1222. $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers", $langs->trans("List"), 1, $user->hasRight('fournisseur', 'commande', 'lire'));
  1223. if ($usemenuhider || empty($leftmenu) || $leftmenu == "orders_suppliers") {
  1224. $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=0", $langs->trans("StatusSupplierOrderDraftShort"), 2, $user->hasRight('fournisseur', 'commande', 'lire'));
  1225. if (empty($conf->global->SUPPLIER_ORDER_HIDE_VALIDATED)) {
  1226. $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=1", $langs->trans("StatusSupplierOrderValidated"), 2, $user->hasRight('fournisseur', 'commande', 'lire'));
  1227. }
  1228. $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=2", $langs->trans("StatusSupplierOrderApprovedShort"), 2, $user->hasRight('fournisseur', 'commande', 'lire'));
  1229. $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=3", $langs->trans("StatusSupplierOrderOnProcessShort"), 2, $user->hasRight('fournisseur', 'commande', 'lire'));
  1230. $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=4", $langs->trans("StatusSupplierOrderReceivedPartiallyShort"), 2, $user->hasRight('fournisseur', 'commande', 'lire'));
  1231. $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=5", $langs->trans("StatusSupplierOrderReceivedAll"), 2, $user->hasRight('fournisseur', 'commande', 'lire'));
  1232. $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=6,7", $langs->trans("StatusSupplierOrderCanceled"), 2, $user->hasRight('fournisseur', 'commande', 'lire'));
  1233. $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=9", $langs->trans("StatusSupplierOrderRefused"), 2, $user->hasRight('fournisseur', 'commande', 'lire'));
  1234. }
  1235. // 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'));
  1236. $newmenu->add("/commande/stats/index.php?leftmenu=orders_suppliers&amp;mode=supplier", $langs->trans("Statistics"), 1, $user->hasRight('fournisseur', 'commande', 'lire'));
  1237. }
  1238. // Contrat
  1239. if (isModEnabled('contrat')) {
  1240. $langs->load("contracts");
  1241. $newmenu->add("/contrat/index.php?leftmenu=contracts", $langs->trans("ContractsSubscriptions"), 0, $user->hasRight('contrat', 'lire'), '', $mainmenu, 'contracts', 2000, '', '', '', img_picto('', 'contract', 'class="paddingright pictofixedwidth"'));
  1242. $newmenu->add("/contrat/card.php?action=create&amp;leftmenu=contracts", $langs->trans("NewContractSubscription"), 1, $user->hasRight('contrat', 'creer'));
  1243. $newmenu->add("/contrat/list.php?leftmenu=contracts", $langs->trans("List"), 1, $user->hasRight('contrat', 'lire'));
  1244. $newmenu->add("/contrat/services_list.php?leftmenu=contracts", $langs->trans("MenuServices"), 1, $user->hasRight('contrat', 'lire'));
  1245. if ($usemenuhider || empty($leftmenu) || $leftmenu == "contracts") {
  1246. $newmenu->add("/contrat/services_list.php?leftmenu=contracts&amp;search_status=0", $langs->trans("MenuInactiveServices"), 2, $user->hasRight('contrat', 'lire'));
  1247. $newmenu->add("/contrat/services_list.php?leftmenu=contracts&amp;search_status=4", $langs->trans("MenuRunningServices"), 2, $user->hasRight('contrat', 'lire'));
  1248. $newmenu->add("/contrat/services_list.php?leftmenu=contracts&amp;search_status=4&amp;filter=expired", $langs->trans("MenuExpiredServices"), 2, $user->hasRight('contrat', 'lire'));
  1249. $newmenu->add("/contrat/services_list.php?leftmenu=contracts&amp;search_status=5", $langs->trans("MenuClosedServices"), 2, $user->hasRight('contrat', 'lire'));
  1250. }
  1251. }
  1252. // Interventions
  1253. if (isModEnabled('ficheinter')) {
  1254. $langs->load("interventions");
  1255. $newmenu->add("/fichinter/index.php?leftmenu=ficheinter", $langs->trans("Interventions"), 0, $user->hasRight('ficheinter', 'lire'), '', $mainmenu, 'ficheinter', 2200, '', '', '', img_picto('', 'intervention', 'class="paddingright pictofixedwidth"'));
  1256. $newmenu->add("/fichinter/card.php?action=create&amp;leftmenu=ficheinter", $langs->trans("NewIntervention"), 1, $user->hasRight('ficheinter', 'creer'), '', '', '', 201);
  1257. $newmenu->add("/fichinter/list.php?leftmenu=ficheinter", $langs->trans("List"), 1, $user->hasRight('ficheinter', 'lire'), '', '', '', 202);
  1258. if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
  1259. $newmenu->add("/fichinter/card-rec.php?leftmenu=ficheinter", $langs->trans("ListOfTemplates"), 1, $user->hasRight('ficheinter', 'lire'), '', '', '', 203);
  1260. }
  1261. $newmenu->add("/fichinter/stats/index.php?leftmenu=ficheinter", $langs->trans("Statistics"), 1, $user->hasRight('ficheinter', 'lire'));
  1262. }
  1263. }
  1264. }
  1265. /**
  1266. * Get left COMPTA-FINANCIAL
  1267. *
  1268. * @param string $mainmenu Main menu
  1269. * @param Menu $newmenu Object Menu to return back list of menu entries
  1270. * @param string $usemenuhider Use menu hider
  1271. * @param string $leftmenu Left menu
  1272. * @param int $type_user Type of targeted user for menu
  1273. * @return void
  1274. */
  1275. function get_left_menu_billing($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0)
  1276. {
  1277. global $user, $conf, $langs;
  1278. if ($mainmenu == 'billing') {
  1279. $langs->load("companies");
  1280. // Customers invoices
  1281. if (isModEnabled('facture')) {
  1282. $langs->load("bills");
  1283. $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"'));
  1284. $newmenu->add("/compta/facture/card.php?action=create", $langs->trans("NewBill"), 1, $user->hasRight('facture', 'creer'));
  1285. $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills", $langs->trans("List"), 1, $user->hasRight('facture', 'lire'), '', $mainmenu, 'customers_bills_list');
  1286. if ($usemenuhider || empty($leftmenu) || preg_match('/customers_bills(|_draft|_notpaid|_paid|_canceled)$/', $leftmenu)) {
  1287. $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills_draft&amp;search_status=0", $langs->trans("BillShortStatusDraft"), 2, $user->hasRight('facture', 'lire'));
  1288. $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills_notpaid&amp;search_status=1", $langs->trans("BillShortStatusNotPaid"), 2, $user->hasRight('facture', 'lire'));
  1289. $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills_paid&amp;search_status=2", $langs->trans("BillShortStatusPaid"), 2, $user->hasRight('facture', 'lire'));
  1290. $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills_canceled&amp;search_status=3", $langs->trans("BillShortStatusCanceled"), 2, $user->hasRight('facture', 'lire'));
  1291. }
  1292. $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.
  1293. $newmenu->add("/compta/paiement/list.php?leftmenu=customers_bills_payment", $langs->trans("Payments"), 1, $user->hasRight('facture', 'lire'), '', $mainmenu, 'customers_bills_payment');
  1294. if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) {
  1295. $newmenu->add("/compta/paiement/tovalidate.php?leftmenu=customers_bills_tovalid", $langs->trans("MenuToValid"), 2, $user->hasRight('facture', 'lire'), '', $mainmenu, 'customer_bills_tovalid');
  1296. }
  1297. if ($usemenuhider || empty($leftmenu) || preg_match('/customers_bills/', $leftmenu)) {
  1298. $newmenu->add("/compta/paiement/rapport.php?leftmenu=customers_bills_payment_report", $langs->trans("Reportings"), 2, $user->hasRight('facture', 'lire'), '', $mainmenu, 'customers_bills_payment_report');
  1299. }
  1300. $newmenu->add("/compta/facture/stats/index.php?leftmenu=customers_bills_stats", $langs->trans("Statistics"), 1, $user->hasRight('facture', 'lire'), '', $mainmenu, 'customers_bills_stats');
  1301. }
  1302. // Suppliers invoices
  1303. if (isModEnabled('societe') && isModEnabled('supplier_invoice')) {
  1304. $langs->load("bills");
  1305. $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"'));
  1306. $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');
  1307. $newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills", $langs->trans("List"), 1, $user->hasRight('fournisseur', 'facture', 'lire'), '', $mainmenu, 'suppliers_bills_list');
  1308. if ($usemenuhider || empty($leftmenu) || preg_match('/suppliers_bills/', $leftmenu)) {
  1309. $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');
  1310. $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');
  1311. $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');
  1312. }
  1313. $newmenu->add("/fourn/facture/list-rec.php?leftmenu=supplierinvoicestemplate_list", $langs->trans("ListOfTemplates"), 1, $user->hasRight('fournisseur', 'facture', 'lire'), '', $mainmenu, 'supplierinvoicestemplate_list');
  1314. $newmenu->add("/fourn/paiement/list.php?leftmenu=suppliers_bills_payment", $langs->trans("Payments"), 1, $user->hasRight('fournisseur', 'facture', 'lire'), '', $mainmenu, 'suppliers_bills_payment');
  1315. if ($usemenuhider || empty($leftmenu) || preg_match('/suppliers_bills/', $leftmenu)) {
  1316. $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');
  1317. }
  1318. $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');
  1319. }
  1320. // Orders
  1321. if (isModEnabled('commande')) {
  1322. $langs->load("orders");
  1323. if (isModEnabled('facture')) {
  1324. $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"'));
  1325. }
  1326. //if ($usemenuhider || empty($leftmenu) || $leftmenu=="orders") $newmenu->add("/commande/", $langs->trans("StatusOrderToBill"), 1, $user->hasRight('commande', 'lire'));
  1327. }
  1328. // Supplier Orders to bill
  1329. if (isModEnabled('supplier_invoice')) {
  1330. if (!empty($conf->global->SUPPLIER_MENU_ORDER_RECEIVED_INTO_INVOICE)) {
  1331. $langs->load("supplier");
  1332. $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"'));
  1333. //if ($usemenuhider || empty($leftmenu) || $leftmenu=="orders") $newmenu->add("/commande/", $langs->trans("StatusOrderToBill"), 1, $user->hasRight('commande', 'lire'));
  1334. }
  1335. }
  1336. // Donations
  1337. if (isModEnabled('don')) {
  1338. $langs->load("donations");
  1339. $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"'));
  1340. if ($usemenuhider || empty($leftmenu) || $leftmenu == "donations") {
  1341. $newmenu->add("/don/card.php?leftmenu=donations&amp;action=create", $langs->trans("NewDonation"), 1, $user->hasRight('don', 'creer'));
  1342. $newmenu->add("/don/list.php?leftmenu=donations", $langs->trans("List"), 1, $user->hasRight('don', 'lire'));
  1343. }
  1344. // if ($leftmenu=="donations") $newmenu->add("/don/stats/index.php",$langs->trans("Statistics"), 1, $user->hasRight('don', 'lire'));
  1345. }
  1346. // Taxes and social contributions
  1347. if (isModEnabled('tax')) {
  1348. $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"'));
  1349. $newmenu->add("/compta/sociales/list.php?leftmenu=tax_social", $langs->trans("MenuSocialContributions"), 1, $user->hasRight('tax', 'charges', 'lire'));
  1350. if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_social/i', $leftmenu)) {
  1351. $newmenu->add("/compta/sociales/card.php?leftmenu=tax_social&action=create", $langs->trans("MenuNewSocialContribution"), 2, $user->hasRight('tax', 'charges', 'creer'));
  1352. $newmenu->add("/compta/sociales/list.php?leftmenu=tax_social", $langs->trans("List"), 2, $user->hasRight('tax', 'charges', 'lire'));
  1353. $newmenu->add("/compta/sociales/payments.php?leftmenu=tax_social&amp;mainmenu=billing", $langs->trans("Payments"), 2, $user->hasRight('tax', 'charges', 'lire'));
  1354. }
  1355. // VAT
  1356. if (empty($conf->global->TAX_DISABLE_VAT_MENUS)) {
  1357. global $mysoc;
  1358. $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');
  1359. if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_vat/i', $leftmenu)) {
  1360. $newmenu->add("/compta/tva/card.php?leftmenu=tax_vat&action=create", $langs->trans("New"), 2, $user->hasRight('tax', 'charges', 'creer'));
  1361. $newmenu->add("/compta/tva/list.php?leftmenu=tax_vat", $langs->trans("List"), 2, $user->hasRight('tax', 'charges', 'lire'));
  1362. $newmenu->add("/compta/tva/payments.php?mode=tvaonly&amp;leftmenu=tax_vat", $langs->trans("Payments"), 2, $user->hasRight('tax', 'charges', 'lire'));
  1363. $newmenu->add("/compta/tva/index.php?leftmenu=tax_vat", $langs->trans("ReportByMonth"), 2, $user->hasRight('tax', 'charges', 'lire'));
  1364. $newmenu->add("/compta/tva/clients.php?leftmenu=tax_vat", $langs->trans("ReportByThirdparties"), 2, $user->hasRight('tax', 'charges', 'lire'));
  1365. $newmenu->add("/compta/tva/quadri_detail.php?leftmenu=tax_vat", $langs->trans("ReportByQuarter"), 2, $user->hasRight('tax', 'charges', 'lire'));
  1366. }
  1367. //Local Taxes 1
  1368. if ($mysoc->useLocalTax(1) && (isset($mysoc->localtax1_assuj) && $mysoc->localtax1_assuj == "1")) {
  1369. $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'));
  1370. if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_1_vat/i', $leftmenu)) {
  1371. $newmenu->add("/compta/localtax/card.php?leftmenu=tax_1_vat&action=create&amp;localTaxType=1", $langs->trans("New"), 2, $user->hasRight('tax', 'charges', 'creer'));
  1372. $newmenu->add("/compta/localtax/list.php?leftmenu=tax_1_vat&amp;localTaxType=1", $langs->trans("List"), 2, $user->hasRight('tax', 'charges', 'lire'));
  1373. $newmenu->add("/compta/localtax/index.php?leftmenu=tax_1_vat&amp;localTaxType=1", $langs->trans("ReportByMonth"), 2, $user->hasRight('tax', 'charges', 'lire'));
  1374. $newmenu->add("/compta/localtax/clients.php?leftmenu=tax_1_vat&amp;localTaxType=1", $langs->trans("ReportByThirdparties"), 2, $user->hasRight('tax', 'charges', 'lire'));
  1375. $newmenu->add("/compta/localtax/quadri_detail.php?leftmenu=tax_1_vat&amp;localTaxType=1", $langs->trans("ReportByQuarter"), 2, $user->hasRight('tax', 'charges', 'lire'));
  1376. }
  1377. }
  1378. //Local Taxes 2
  1379. if ($mysoc->useLocalTax(2) && (isset($mysoc->localtax2_assuj) && $mysoc->localtax2_assuj == "1")) {
  1380. $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'));
  1381. if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_2_vat/i', $leftmenu)) {
  1382. $newmenu->add("/compta/localtax/card.php?leftmenu=tax_2_vat&action=create&amp;localTaxType=2", $langs->trans("New"), 2, $user->hasRight('tax', 'charges', 'creer'));
  1383. $newmenu->add("/compta/localtax/list.php?leftmenu=tax_2_vat&amp;localTaxType=2", $langs->trans("List"), 2, $user->hasRight('tax', 'charges', 'lire'));
  1384. $newmenu->add("/compta/localtax/index.php?leftmenu=tax_2_vat&amp;localTaxType=2", $langs->trans("ReportByMonth"), 2, $user->hasRight('tax', 'charges', 'lire'));
  1385. $newmenu->add("/compta/localtax/clients.php?leftmenu=tax_2_vat&amp;localTaxType=2", $langs->trans("ReportByThirdparties"), 2, $user->hasRight('tax', 'charges', 'lire'));
  1386. $newmenu->add("/compta/localtax/quadri_detail.php?leftmenu=tax_2_vat&amp;localTaxType=2", $langs->trans("ReportByQuarter"), 2, $user->hasRight('tax', 'charges', 'lire'));
  1387. }
  1388. }
  1389. }
  1390. }
  1391. // Salaries
  1392. if (isModEnabled('salaries')) {
  1393. $langs->load("salaries");
  1394. $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"'));
  1395. if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_salary/i', $leftmenu)) {
  1396. $newmenu->add("/salaries/card.php?leftmenu=tax_salary&action=create", $langs->trans("New"), 1, $user->hasRight('salaries', 'write'));
  1397. $newmenu->add("/salaries/list.php?leftmenu=tax_salary", $langs->trans("List"), 1, $user->hasRight('salaries', 'read'));
  1398. $newmenu->add("/salaries/payments.php?leftmenu=tax_salary", $langs->trans("Payments"), 1, $user->hasRight('salaries', 'read'));
  1399. $newmenu->add("/salaries/stats/index.php?leftmenu=tax_salary", $langs->trans("Statistics"), 1, $user->hasRight('salaries', 'read'));
  1400. }
  1401. }
  1402. // Loan
  1403. if (isModEnabled('loan')) {
  1404. $langs->load("loan");
  1405. $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"'));
  1406. if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_loan/i', $leftmenu)) {
  1407. $newmenu->add("/loan/card.php?leftmenu=tax_loan&action=create", $langs->trans("NewLoan"), 1, $user->hasRight('loan', 'write'));
  1408. //$newmenu->add("/loan/payment/list.php?leftmenu=tax_loan",$langs->trans("Payments"),2,$user->hasRight('loan', 'read'));
  1409. }
  1410. }
  1411. // Various payment
  1412. if (isModEnabled('banque') && empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT)) {
  1413. $langs->load("banks");
  1414. $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"'));
  1415. if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_various/i', $leftmenu)) {
  1416. $newmenu->add("/compta/bank/various_payment/card.php?leftmenu=tax_various&action=create", $langs->trans("New"), 1, $user->hasRight('banque', 'modifier'));
  1417. $newmenu->add("/compta/bank/various_payment/list.php?leftmenu=tax_various", $langs->trans("List"), 1, $user->hasRight('banque', 'lire'));
  1418. }
  1419. }
  1420. }
  1421. }
  1422. /**
  1423. * Get left COMPTA-FINANCIAL (accountancy)
  1424. *
  1425. * @param string $mainmenu Main menu
  1426. * @param Menu $newmenu Object Menu to return back list of menu entries
  1427. * @param string $usemenuhider Use menu hider
  1428. * @param string $leftmenu Left menu
  1429. * @param int $type_user Type of targeted user for menu
  1430. * @return void
  1431. */
  1432. function get_left_menu_accountancy($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0)
  1433. {
  1434. global $user, $conf, $langs;
  1435. global $db;
  1436. if ($mainmenu == 'accountancy') {
  1437. $langs->load("companies");
  1438. // Accounting (Double entries)
  1439. if (isModEnabled('accounting')) {
  1440. //$permtoshowmenu = (isModEnabled('accounting') || $user->hasRight('accounting', 'bind', 'write') || $user->hasRight('compta', 'resultat', 'lire'));
  1441. //$newmenu->add("/accountancy/index.php?leftmenu=accountancy", $langs->trans("MenuAccountancy"), 0, $permtoshowmenu, '', $mainmenu, 'accountancy');
  1442. // Configuration
  1443. $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"'));
  1444. if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/', $leftmenu)) {
  1445. global $mysoc;
  1446. $newmenu->add("/accountancy/admin/index.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("General"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_general', 10);
  1447. // Fiscal year - Not really yet used. In a future will lock some periods.
  1448. if ($conf->global->MAIN_FEATURES_LEVEL > 1) {
  1449. $newmenu->add("/accountancy/admin/fiscalyear.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("FiscalPeriod"), 1, $user->hasRight('accounting', 'fiscalyear', 'write'), '', $mainmenu, 'fiscalyear', 20);
  1450. }
  1451. $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);
  1452. $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);
  1453. $newmenu->add("/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Chartofaccounts"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_chart', 41);
  1454. $newmenu->add("/accountancy/admin/subaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("ChartOfSubaccounts"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_chart', 41);
  1455. $newmenu->add("/accountancy/admin/defaultaccounts.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuDefaultAccounts"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_default', 60);
  1456. if (isModEnabled('banque')) {
  1457. $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);
  1458. }
  1459. if (isModEnabled('facture') || ((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('supplier_invoice'))) {
  1460. $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);
  1461. }
  1462. if (isModEnabled('tax')) {
  1463. $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);
  1464. }
  1465. if (isModEnabled('expensereport')) {
  1466. $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);
  1467. }
  1468. $newmenu->add("/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuProductsAccounts"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_product', 110);
  1469. if ($conf->global->MAIN_FEATURES_LEVEL > 1) {
  1470. $newmenu->add("/accountancy/admin/closure.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuClosureAccounts"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_closure', 120);
  1471. }
  1472. $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);
  1473. $newmenu->add("/accountancy/admin/export.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("ExportOptions"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_export', 130);
  1474. }
  1475. // Transfer in accounting
  1476. $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"'));
  1477. // Binding
  1478. // $newmenu->add("", $langs->trans("Binding"), 0, $user->hasRight('accounting', 'bind', 'write'), '', $mainmenu, 'dispatch');
  1479. if (isModEnabled('facture') && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES)) {
  1480. $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');
  1481. if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_dispatch_customer/', $leftmenu)) {
  1482. $newmenu->add("/accountancy/customer/list.php?mainmenu=accountancy&amp;leftmenu=accountancy_dispatch_customer", $langs->trans("ToBind"), 2, $user->hasRight('accounting', 'bind', 'write'));
  1483. $newmenu->add("/accountancy/customer/lines.php?mainmenu=accountancy&amp;leftmenu=accountancy_dispatch_customer", $langs->trans("Binded"), 2, $user->hasRight('accounting', 'bind', 'write'));
  1484. }
  1485. }
  1486. if (isModEnabled('supplier_invoice') && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES)) {
  1487. $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');
  1488. if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_dispatch_supplier/', $leftmenu)) {
  1489. $newmenu->add("/accountancy/supplier/list.php?mainmenu=accountancy&amp;leftmenu=accountancy_dispatch_supplier", $langs->trans("ToBind"), 2, $user->hasRight('accounting', 'bind', 'write'));
  1490. $newmenu->add("/accountancy/supplier/lines.php?mainmenu=accountancy&amp;leftmenu=accountancy_dispatch_supplier", $langs->trans("Binded"), 2, $user->hasRight('accounting', 'bind', 'write'));
  1491. }
  1492. }
  1493. if (isModEnabled('expensereport') && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS)) {
  1494. $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');
  1495. if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_dispatch_expensereport/', $leftmenu)) {
  1496. $newmenu->add("/accountancy/expensereport/list.php?mainmenu=accountancy&amp;leftmenu=accountancy_dispatch_expensereport", $langs->trans("ToBind"), 2, $user->hasRight('accounting', 'bind', 'write'));
  1497. $newmenu->add("/accountancy/expensereport/lines.php?mainmenu=accountancy&amp;leftmenu=accountancy_dispatch_expensereport", $langs->trans("Binded"), 2, $user->hasRight('accounting', 'bind', 'write'));
  1498. }
  1499. }
  1500. // Journals
  1501. if (isModEnabled('accounting') && $user->hasRight('accounting', 'comptarapport', 'lire') && $mainmenu == 'accountancy') {
  1502. $newmenu->add('', $langs->trans("RegistrationInAccounting"), 1, $user->hasRight('accounting', 'comptarapport', 'lire'), '', '', '');
  1503. // Multi journal
  1504. $sql = "SELECT rowid, code, label, nature";
  1505. $sql .= " FROM ".MAIN_DB_PREFIX."accounting_journal";
  1506. $sql .= " WHERE entity = ".$conf->entity;
  1507. $sql .= " AND active = 1";
  1508. $sql .= " ORDER BY nature ASC, label DESC";
  1509. $resql = $db->query($sql);
  1510. if ($resql) {
  1511. $numr = $db->num_rows($resql);
  1512. $i = 0;
  1513. if ($numr > 0) {
  1514. while ($i < $numr) {
  1515. $objp = $db->fetch_object($resql);
  1516. $nature = '';
  1517. // Must match array $sourceList defined into journals_list.php
  1518. if ($objp->nature == 2 && isModEnabled('facture') && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES)) {
  1519. $nature = "sells";
  1520. }
  1521. if ($objp->nature == 3
  1522. && ((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('supplier_invoice'))
  1523. && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES)) {
  1524. $nature = "purchases";
  1525. }
  1526. if ($objp->nature == 4 && isModEnabled('banque')) {
  1527. $nature = "bank";
  1528. }
  1529. if ($objp->nature == 5 && isModEnabled('expensereport') && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS)) {
  1530. $nature = "expensereports";
  1531. }
  1532. if ($objp->nature == 1 && isModEnabled('asset')) {
  1533. $nature = "various"; // Warning: The page /accountancy/journal/variousjournal.php is bugged. It read tables that does not exists.
  1534. }
  1535. if ($objp->nature == 8) {
  1536. $nature = "inventory";
  1537. }
  1538. if ($objp->nature == 9) {
  1539. $nature = "hasnew";
  1540. }
  1541. // To enable when page exists
  1542. if (empty($conf->global->ACCOUNTANCY_SHOW_DEVELOP_JOURNAL)) {
  1543. if ($nature == 'hasnew' || $nature == 'inventory') {
  1544. $nature = '';
  1545. }
  1546. }
  1547. if ($nature) {
  1548. $langs->load('accountancy');
  1549. $journallabel = '';
  1550. if ($objp->label) {
  1551. $journallabel = '<span class="opacitymedium">('.$langs->transnoentities($objp->label).')</span>'; // Label of bank account in llx_accounting_journal
  1552. }
  1553. $key = $langs->trans("AccountingJournalType".strtoupper($objp->nature));
  1554. $transferlabel = ($objp->nature && $key != "AccountingJournalType".strtoupper($langs->trans($objp->nature)) ? $key.($journallabel != $key ? ' '.$journallabel : ''): $journallabel);
  1555. $newmenu->add('/accountancy/journal/'.$nature.'journal.php?mainmenu=accountancy&leftmenu=accountancy_journal&id_journal='.$objp->rowid, $transferlabel, 2, $user->hasRight('accounting', 'comptarapport', 'lire'));
  1556. }
  1557. $i++;
  1558. }
  1559. } else {
  1560. // Should not happend. Entries are added
  1561. $newmenu->add('', $langs->trans("NoJournalDefined"), 2, $user->hasRight('accounting', 'comptarapport', 'lire'));
  1562. }
  1563. } else {
  1564. dol_print_error($db);
  1565. }
  1566. $db->free($resql);
  1567. }
  1568. // Files
  1569. if (empty($conf->global->ACCOUNTANCY_HIDE_EXPORT_FILES_MENU)) {
  1570. $newmenu->add("/compta/accounting-files.php?mainmenu=accountancy&amp;leftmenu=accountancy_files", $langs->trans("AccountantFiles"), 1, $user->hasRight('accounting', 'mouvements', 'lire'));
  1571. }
  1572. // Accounting
  1573. $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"'));
  1574. // General Ledger
  1575. $newmenu->add("/accountancy/bookkeeping/listbyaccount.php?mainmenu=accountancy&amp;leftmenu=accountancy_accountancy", $langs->trans("Bookkeeping"), 1, $user->hasRight('accounting', 'mouvements', 'lire'));
  1576. // Journals
  1577. $newmenu->add("/accountancy/bookkeeping/list.php?mainmenu=accountancy&amp;leftmenu=accountancy_accountancy", $langs->trans("Journals"), 1, $user->hasRight('accounting', 'mouvements', 'lire'));
  1578. // Account Balance
  1579. $newmenu->add("/accountancy/bookkeeping/balance.php?mainmenu=accountancy&amp;leftmenu=accountancy_accountancy", $langs->trans("AccountBalance"), 1, $user->hasRight('accounting', 'mouvements', 'lire'));
  1580. // Closure
  1581. $newmenu->add("/accountancy/closure/index.php?mainmenu=accountancy&amp;leftmenu=accountancy_closure", $langs->trans("MenuAccountancyClosure"), 1, $user->hasRight('accounting', 'fiscalyear', 'write'), '', $mainmenu, 'closure');
  1582. // Reports
  1583. $newmenu->add("/accountancy/index.php?leftmenu=accountancy_report", $langs->trans("Reportings"), 1, $user->hasRight('accounting', 'comptarapport', 'lire'), '', $mainmenu, 'ca');
  1584. if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/', $leftmenu)) {
  1585. $newmenu->add("/compta/resultat/index.php?leftmenu=accountancy_report", $langs->trans("MenuReportInOut"), 2, $user->hasRight('accounting', 'comptarapport', 'lire'));
  1586. $newmenu->add("/compta/resultat/clientfourn.php?leftmenu=accountancy_report", $langs->trans("ByPredefinedAccountGroups"), 3, $user->hasRight('accounting', 'comptarapport', 'lire'));
  1587. $newmenu->add("/compta/resultat/result.php?leftmenu=accountancy_report", $langs->trans("ByPersonalizedAccountGroups"), 3, $user->hasRight('accounting', 'comptarapport', 'lire'));
  1588. }
  1589. $modecompta = 'CREANCES-DETTES';
  1590. if (isModEnabled('accounting') && $user->hasRight('accounting', 'comptarapport', 'lire') && $mainmenu == 'accountancy') {
  1591. $modecompta = 'BOOKKEEPING'; // Not yet implemented. Should be BOOKKEEPINGCOLLECTED
  1592. }
  1593. if ($modecompta) {
  1594. if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/', $leftmenu)) {
  1595. $newmenu->add("/compta/stats/index.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ReportTurnover"), 2, $user->hasRight('accounting', 'comptarapport', 'lire'));
  1596. $newmenu->add("/compta/stats/casoc.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByCompanies"), 3, $user->hasRight('accounting', 'comptarapport', 'lire'));
  1597. $newmenu->add("/compta/stats/cabyuser.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByUsers"), 3, $user->hasRight('accounting', 'comptarapport', 'lire'));
  1598. $newmenu->add("/compta/stats/cabyprodserv.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByProductsAndServices"), 3, $user->hasRight('accounting', 'comptarapport', 'lire'));
  1599. $newmenu->add("/compta/stats/byratecountry.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByVatRate"), 3, $user->hasRight('accounting', 'comptarapport', 'lire'));
  1600. }
  1601. }
  1602. $modecompta = 'RECETTES-DEPENSES';
  1603. //if (isModEnabled('accounting') && $user->hasRight('accounting', 'comptarapport', 'lire') && $mainmenu == 'accountancy') $modecompta=''; // Not yet implemented. Should be BOOKKEEPINGCOLLECTED
  1604. if ($modecompta) {
  1605. if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/', $leftmenu)) {
  1606. $newmenu->add("/compta/stats/index.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ReportTurnoverCollected"), 2, $user->hasRight('accounting', 'comptarapport', 'lire'));
  1607. $newmenu->add("/compta/stats/casoc.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByCompanies"), 3, $user->hasRight('accounting', 'comptarapport', 'lire'));
  1608. $newmenu->add("/compta/stats/cabyuser.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByUsers"), 3, $user->hasRight('accounting', 'comptarapport', 'lire'));
  1609. //$newmenu->add("/compta/stats/cabyprodserv.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByProductsAndServices"),3,$user->hasRight('accounting', 'comptarapport', 'lire'));
  1610. //$newmenu->add("/compta/stats/byratecountry.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByVatRate"),3,$user->hasRight('accounting', 'comptarapport', 'lire'));
  1611. }
  1612. }
  1613. $modecompta = 'CREANCES-DETTES';
  1614. if (isModEnabled('accounting') && $user->hasRight('accounting', 'comptarapport', 'lire') && $mainmenu == 'accountancy') {
  1615. $modecompta = 'BOOKKEEPING'; // Not yet implemented.
  1616. }
  1617. if ($modecompta && ((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('supplier_invoice'))) {
  1618. if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/', $leftmenu)) {
  1619. $newmenu->add("/compta/stats/supplier_turnover.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ReportPurchaseTurnover"), 2, $user->hasRight('accounting', 'comptarapport', 'lire'));
  1620. $newmenu->add("/compta/stats/supplier_turnover_by_thirdparty.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByCompanies"), 3, $user->hasRight('accounting', 'comptarapport', 'lire'));
  1621. $newmenu->add("/compta/stats/supplier_turnover_by_prodserv.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByProductsAndServices"), 3, $user->hasRight('accounting', 'comptarapport', 'lire'));
  1622. }
  1623. }
  1624. $modecompta = 'RECETTES-DEPENSES';
  1625. if (isModEnabled('accounting') && $user->hasRight('accounting', 'comptarapport', 'lire') && $mainmenu == 'accountancy') {
  1626. $modecompta = 'BOOKKEEPINGCOLLECTED'; // Not yet implemented.
  1627. }
  1628. if ($modecompta && ((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('supplier_invoice'))) {
  1629. if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/', $leftmenu)) {
  1630. $newmenu->add("/compta/stats/supplier_turnover.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ReportPurchaseTurnoverCollected"), 2, $user->hasRight('accounting', 'comptarapport', 'lire'));
  1631. $newmenu->add("/compta/stats/supplier_turnover_by_thirdparty.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByCompanies"), 3, $user->hasRight('accounting', 'comptarapport', 'lire'));
  1632. }
  1633. }
  1634. }
  1635. // Accountancy (simple)
  1636. if (isModEnabled('comptabilite')) {
  1637. // Files
  1638. if (empty($conf->global->ACCOUNTANCY_HIDE_EXPORT_FILES_MENU)) {
  1639. $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"'));
  1640. }
  1641. // Bilan, resultats
  1642. $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"'));
  1643. if ($usemenuhider || empty($leftmenu) || preg_match('/report/', $leftmenu)) {
  1644. $newmenu->add("/compta/resultat/index.php?leftmenu=report", $langs->trans("MenuReportInOut"), 1, $user->hasRight('compta', 'resultat', 'lire'));
  1645. $newmenu->add("/compta/resultat/clientfourn.php?leftmenu=report", $langs->trans("ByCompanies"), 2, $user->hasRight('compta', 'resultat', 'lire'));
  1646. /* On verra ca avec module compabilite expert
  1647. $newmenu->add("/compta/resultat/compteres.php?leftmenu=report","Compte de resultat",2,$user->hasRight('compta', 'resultat', 'lire'));
  1648. $newmenu->add("/compta/resultat/bilan.php?leftmenu=report","Bilan",2,$user->hasRight('compta', 'resultat', 'lire'));
  1649. */
  1650. /*
  1651. $newmenu->add("/compta/stats/cumul.php?leftmenu=report","Cumule",2,$user->hasRight('compta', 'resultat', 'lire'));
  1652. if (isModEnabled('propal')) {
  1653. $newmenu->add("/compta/stats/prev.php?leftmenu=report","Previsionnel",2,$user->hasRight('compta', 'resultat', 'lire'));
  1654. $newmenu->add("/compta/stats/comp.php?leftmenu=report","Transforme",2,$user->hasRight('compta', 'resultat', 'lire'));
  1655. }
  1656. */
  1657. $modecompta = 'CREANCES-DETTES';
  1658. $newmenu->add("/compta/stats/index.php?leftmenu=report&modecompta=".$modecompta, $langs->trans("ReportTurnover"), 1, $user->hasRight('compta', 'resultat', 'lire'));
  1659. $newmenu->add("/compta/stats/casoc.php?leftmenu=report&modecompta=".$modecompta, $langs->trans("ByCompanies"), 2, $user->hasRight('compta', 'resultat', 'lire'));
  1660. $newmenu->add("/compta/stats/cabyuser.php?leftmenu=report&modecompta=".$modecompta, $langs->trans("ByUsers"), 2, $user->hasRight('compta', 'resultat', 'lire'));
  1661. $newmenu->add("/compta/stats/cabyprodserv.php?leftmenu=report&modecompta=".$modecompta, $langs->trans("ByProductsAndServices"), 2, $user->hasRight('compta', 'resultat', 'lire'));
  1662. $newmenu->add("/compta/stats/byratecountry.php?leftmenu=report&modecompta=".$modecompta, $langs->trans("ByVatRate"), 2, $user->hasRight('compta', 'resultat', 'lire'));
  1663. $modecompta = 'RECETTES-DEPENSES';
  1664. $newmenu->add("/compta/stats/index.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ReportTurnoverCollected"), 1, $user->hasRight('compta', 'resultat', 'lire'));
  1665. $newmenu->add("/compta/stats/casoc.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByCompanies"), 2, $user->hasRight('compta', 'resultat', 'lire'));
  1666. $newmenu->add("/compta/stats/cabyuser.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByUsers"), 2, $user->hasRight('compta', 'resultat', 'lire'));
  1667. //Achats
  1668. $modecompta = 'CREANCES-DETTES';
  1669. $newmenu->add("/compta/stats/supplier_turnover.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ReportPurchaseTurnover"), 1, $user->hasRight('compta', 'resultat', 'lire'));
  1670. $newmenu->add("/compta/stats/supplier_turnover_by_thirdparty.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByCompanies"), 2, $user->hasRight('compta', 'resultat', 'lire'));
  1671. $newmenu->add("/compta/stats/supplier_turnover_by_prodserv.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByProductsAndServices"), 2, $user->hasRight('compta', 'resultat', 'lire'));
  1672. /*
  1673. $modecompta = 'RECETTES-DEPENSES';
  1674. $newmenu->add("/compta/stats/index.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ReportPurchaseTurnoverCollected"), 1, $user->hasRight('compta', 'resultat', 'lire'));
  1675. $newmenu->add("/compta/stats/casoc.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByCompanies"), 2, $user->hasRight('compta', 'resultat', 'lire'));
  1676. $newmenu->add("/compta/stats/cabyuser.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByUsers"), 2, $user->hasRight('compta', 'resultat', 'lire'));
  1677. */
  1678. // Journals
  1679. $newmenu->add("/compta/journal/sellsjournal.php?leftmenu=report", $langs->trans("SellsJournal"), 1, $user->hasRight('compta', 'resultat', 'lire'), '', '', '', 50);
  1680. $newmenu->add("/compta/journal/purchasesjournal.php?leftmenu=report", $langs->trans("PurchasesJournal"), 1, $user->hasRight('compta', 'resultat', 'lire'), '', '', '', 51);
  1681. }
  1682. //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'));
  1683. }
  1684. // Intracomm report
  1685. if (isModEnabled('intracommreport')) {
  1686. $newmenu->add("/intracommreport/list.php?leftmenu=intracommreport", $langs->trans("MenuIntracommReport"), 0, $user->hasRight('intracommreport', 'read'), '', $mainmenu, 'intracommreport', 60, '', '', '', img_picto('', 'intracommreport', 'class="paddingright pictofixedwidth"'));
  1687. if ($usemenuhider || empty($leftmenu) || preg_match('/intracommreport/', $leftmenu)) {
  1688. // DEB / DES
  1689. $newmenu->add("/intracommreport/card.php?action=create&leftmenu=intracommreport", $langs->trans("MenuIntracommReportNew"), 1, $user->hasRight('intracommreport', 'write'), '', $mainmenu, 'intracommreport', 1);
  1690. $newmenu->add("/intracommreport/list.php?leftmenu=intracommreport", $langs->trans("MenuIntracommReportList"), 1, $user->hasRight('intracommreport', 'read'), '', $mainmenu, 'intracommreport', 1);
  1691. }
  1692. }
  1693. // Assets
  1694. if (isModEnabled('asset')) {
  1695. $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"'));
  1696. $newmenu->add("/asset/card.php?leftmenu=asset&amp;action=create", $langs->trans("MenuNewAsset"), 1, $user->hasRight('asset', 'write'));
  1697. $newmenu->add("/asset/list.php?leftmenu=asset&amp;mainmenu=accountancy", $langs->trans("MenuListAssets"), 1, $user->hasRight('asset', 'read'));
  1698. $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');
  1699. if ($usemenuhider || empty($leftmenu) || preg_match('/asset_model/', $leftmenu)) {
  1700. $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')));
  1701. $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')));
  1702. }
  1703. }
  1704. }
  1705. }
  1706. /**
  1707. * Get left Menu BANK
  1708. *
  1709. * @param string $mainmenu Main menu
  1710. * @param Menu $newmenu Object Menu to return back list of menu entries
  1711. * @param string $usemenuhider Use menu hider
  1712. * @param string $leftmenu Left menu
  1713. * @param int $type_user Type of targeted user for menu
  1714. * @return void
  1715. */
  1716. function get_left_menu_bank($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0)
  1717. {
  1718. global $user, $conf, $langs;
  1719. if ($mainmenu == 'bank') {
  1720. // Load translation files required by the page
  1721. $langs->loadLangs(array("withdrawals", "banks", "bills", "categories"));
  1722. // Bank-Cash account
  1723. if (isModEnabled('banque')) {
  1724. $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"'));
  1725. $newmenu->add("/compta/bank/card.php?action=create", $langs->trans("MenuNewFinancialAccount"), 1, $user->hasRight('banque', 'configurer'));
  1726. $newmenu->add("/compta/bank/list.php?leftmenu=bank&amp;mainmenu=bank", $langs->trans("List"), 1, $user->hasRight('banque', 'lire'), '', $mainmenu, 'bank');
  1727. $newmenu->add("/compta/bank/bankentries_list.php", $langs->trans("ListTransactions"), 1, $user->hasRight('banque', 'lire'));
  1728. $newmenu->add("/compta/bank/budget.php", $langs->trans("ListTransactionsByCategory"), 1, $user->hasRight('banque', 'lire'));
  1729. $newmenu->add("/compta/bank/transfer.php", $langs->trans("MenuBankInternalTransfer"), 1, $user->hasRight('banque', 'transfer'));
  1730. }
  1731. if (isModEnabled('categorie')) {
  1732. $langs->load("categories");
  1733. $newmenu->add("/categories/index.php?type=5", $langs->trans("Rubriques"), 1, $user->hasRight('categorie', 'creer'), '', $mainmenu, 'tags');
  1734. $newmenu->add("/compta/bank/categ.php", $langs->trans("RubriquesTransactions"), 1, $user->hasRight('banque', 'configurer'), '', $mainmenu, 'tags');
  1735. }
  1736. // Direct debit order
  1737. if (isModEnabled('prelevement')) {
  1738. $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"'));
  1739. if ($usemenuhider || empty($leftmenu) || $leftmenu == "withdraw") {
  1740. $newmenu->add("/compta/prelevement/create.php?mainmenu=bank", $langs->trans("NewStandingOrder"), 1, $user->hasRight('prelevement', 'bons', 'creer'));
  1741. $newmenu->add("/compta/prelevement/orders_list.php?mainmenu=bank", $langs->trans("WithdrawalsReceipts"), 1, $user->hasRight('prelevement', 'bons', 'lire'));
  1742. $newmenu->add("/compta/prelevement/list.php?mainmenu=bank", $langs->trans("WithdrawalsLines"), 1, $user->hasRight('prelevement', 'bons', 'lire'));
  1743. $newmenu->add("/compta/prelevement/rejets.php?mainmenu=bank", $langs->trans("Rejects"), 1, $user->hasRight('prelevement', 'bons', 'lire'));
  1744. $newmenu->add("/compta/prelevement/stats.php?mainmenu=bank", $langs->trans("Statistics"), 1, $user->hasRight('prelevement', 'bons', 'lire'));
  1745. }
  1746. }
  1747. // Bank transfer order
  1748. if (isModEnabled('paymentbybanktransfer')) {
  1749. $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"'));
  1750. if ($usemenuhider || empty($leftmenu) || $leftmenu == "banktransfer") {
  1751. $newmenu->add("/compta/prelevement/create.php?type=bank-transfer&mainmenu=bank", $langs->trans("NewPaymentByBankTransfer"), 1, $user->hasRight('paymentbybanktransfer', 'create'));
  1752. $newmenu->add("/compta/prelevement/orders_list.php?type=bank-transfer&mainmenu=bank", $langs->trans("PaymentByBankTransferReceipts"), 1, $user->hasRight('paymentbybanktransfer', 'read'));
  1753. $newmenu->add("/compta/prelevement/list.php?type=bank-transfer&mainmenu=bank", $langs->trans("PaymentByBankTransferLines"), 1, $user->hasRight('paymentbybanktransfer', 'read'));
  1754. $newmenu->add("/compta/prelevement/rejets.php?type=bank-transfer&mainmenu=bank", $langs->trans("Rejects"), 1, $user->hasRight('paymentbybanktransfer', 'read'));
  1755. $newmenu->add("/compta/prelevement/stats.php?type=bank-transfer&mainmenu=bank", $langs->trans("Statistics"), 1, $user->hasRight('paymentbybanktransfer', 'read'));
  1756. }
  1757. }
  1758. // Management of checks
  1759. if (empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT) && isModEnabled('banque') && (isModEnabled('facture') || !empty($conf->global->MAIN_MENU_CHEQUE_DEPOSIT_ON))) {
  1760. $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"'));
  1761. if (preg_match('/checks/', $leftmenu)) {
  1762. $newmenu->add("/compta/paiement/cheque/card.php?leftmenu=checks_bis&amp;action=new&amp;mainmenu=bank", $langs->trans("NewChequeDeposit"), 1, $user->hasRight('banque', 'cheque'));
  1763. $newmenu->add("/compta/paiement/cheque/list.php?leftmenu=checks_bis&amp;mainmenu=bank", $langs->trans("List"), 1, $user->hasRight('banque', 'cheque'));
  1764. }
  1765. }
  1766. // Cash Control
  1767. if (isModEnabled('takepos') || isModEnabled('cashdesk')) {
  1768. $permtomakecashfence = ($user->hasRight('cashdesk', 'run')|| $user->hasRight('takepos', 'run'));
  1769. $newmenu->add("/compta/cashcontrol/cashcontrol_list.php?action=list", $langs->trans("POS"), 0, $permtomakecashfence, '', $mainmenu, 'cashcontrol', 0, '', '', '', img_picto('', 'pos', 'class="pictofixedwidth"'));
  1770. $newmenu->add("/compta/cashcontrol/cashcontrol_card.php?action=create", $langs->trans("NewCashFence"), 1, $permtomakecashfence);
  1771. $newmenu->add("/compta/cashcontrol/cashcontrol_list.php?action=list", $langs->trans("List"), 1, $permtomakecashfence);
  1772. }
  1773. }
  1774. }
  1775. /**
  1776. * Get left Menu PRODUCTS-SERVICES
  1777. *
  1778. * @param string $mainmenu Main menu
  1779. * @param Menu $newmenu Object Menu to return back list of menu entries
  1780. * @param string $usemenuhider Use menu hider
  1781. * @param string $leftmenu Left menu
  1782. * @param int $type_user Type of targeted user for menu
  1783. * @return void
  1784. */
  1785. function get_left_menu_products($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0)
  1786. {
  1787. global $user, $conf, $langs;
  1788. if ($mainmenu == 'products') {
  1789. // Products
  1790. if (isModEnabled('product')) {
  1791. $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"'));
  1792. $newmenu->add("/product/card.php?leftmenu=product&amp;action=create&amp;type=0", $langs->trans("NewProduct"), 1, $user->hasRight('product', 'creer'));
  1793. $newmenu->add("/product/list.php?leftmenu=product&amp;type=0", $langs->trans("List"), 1, $user->hasRight('product', 'read'));
  1794. if (isModEnabled('stock')) {
  1795. $newmenu->add("/product/reassort.php?type=0", $langs->trans("MenuStocks"), 1, $user->hasRight('product', 'read') && $user->hasRight('stock', 'lire'));
  1796. }
  1797. if (isModEnabled('productbatch')) {
  1798. $langs->load("stocks");
  1799. $newmenu->add("/product/reassortlot.php?type=0&search_subjecttolotserial=1", $langs->trans("StocksByLotSerial"), 1, $user->hasRight('product', 'read') && $user->hasRight('stock', 'lire'));
  1800. $newmenu->add("/product/stock/productlot_list.php", $langs->trans("LotSerial"), 1, $user->hasRight('product', 'read') && $user->hasRight('stock', 'lire'));
  1801. }
  1802. if (isModEnabled('variants')) {
  1803. $newmenu->add("/variants/list.php", $langs->trans("VariantAttributes"), 1, $user->hasRight('product', 'read'));
  1804. }
  1805. if (isModEnabled('propal') || (isModEnabled('commande') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('facture') || isModEnabled('fournisseur') || isModEnabled('supplier_proposal') || isModEnabled('supplier_order') || isModEnabled('supplier_invoice')) {
  1806. $newmenu->add("/product/stats/card.php?id=all&leftmenu=stats&type=0", $langs->trans("Statistics"), 1, $user->hasRight('product', 'read'));
  1807. }
  1808. // Categories
  1809. if (isModEnabled('categorie')) {
  1810. $langs->load("categories");
  1811. $newmenu->add("/categories/index.php?leftmenu=cat&amp;type=0", $langs->trans("Categories"), 1, $user->hasRight('categorie', 'lire'), '', $mainmenu, 'cat');
  1812. //if ($usemenuhider || empty($leftmenu) || $leftmenu=="cat") $newmenu->add("/categories/list.php", $langs->trans("List"), 1, $user->hasRight('categorie', 'lire'));
  1813. }
  1814. }
  1815. // Services
  1816. if (isModEnabled('service')) {
  1817. $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"'));
  1818. $newmenu->add("/product/card.php?leftmenu=service&amp;action=create&amp;type=1", $langs->trans("NewService"), 1, $user->hasRight('service', 'creer'));
  1819. $newmenu->add("/product/list.php?leftmenu=service&amp;type=1", $langs->trans("List"), 1, $user->hasRight('service', 'read'));
  1820. if (isModEnabled('propal') || isModEnabled('commande') || isModEnabled('facture') || (isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('supplier_proposal') || isModEnabled('supplier_order') || isModEnabled('supplier_invoice')) {
  1821. $newmenu->add("/product/stats/card.php?id=all&leftmenu=stats&type=1", $langs->trans("Statistics"), 1, $user->hasRight('service', 'read'));
  1822. }
  1823. // Categories
  1824. if (isModEnabled('categorie')) {
  1825. $langs->load("categories");
  1826. $newmenu->add("/categories/index.php?leftmenu=cat&amp;type=0", $langs->trans("Categories"), 1, $user->hasRight('categorie', 'lire'), '', $mainmenu, 'cat');
  1827. //if ($usemenuhider || empty($leftmenu) || $leftmenu=="cat") $newmenu->add("/categories/list.php", $langs->trans("List"), 1, $user->hasRight('categorie', 'lire'));
  1828. }
  1829. }
  1830. // Warehouse
  1831. if (isModEnabled('stock')) {
  1832. $langs->load("stocks");
  1833. $newmenu->add("/product/stock/index.php?leftmenu=stock", $langs->trans("Warehouses"), 0, $user->hasRight('stock', 'lire'), '', $mainmenu, 'stock', 0, '', '', '', img_picto('', 'stock', 'class="pictofixedwidth"'));
  1834. $newmenu->add("/product/stock/card.php?action=create", $langs->trans("MenuNewWarehouse"), 1, $user->hasRight('stock', 'creer'));
  1835. $newmenu->add("/product/stock/list.php", $langs->trans("List"), 1, $user->hasRight('stock', 'lire'));
  1836. $newmenu->add("/product/stock/movement_list.php", $langs->trans("Movements"), 1, $user->hasRight('stock', 'mouvement', 'lire'));
  1837. $newmenu->add("/product/stock/massstockmove.php?init=1", $langs->trans("MassStockTransferShort"), 1, $user->hasRight('stock', 'mouvement', 'creer'));
  1838. if (isModEnabled('supplier_order')) {
  1839. $newmenu->add("/product/stock/replenish.php", $langs->trans("Replenishment"), 1, $user->hasRight('stock', 'mouvement', 'creer') && $user->hasRight('fournisseur', 'lire'));
  1840. }
  1841. $newmenu->add("/product/stock/stockatdate.php", $langs->trans("StockAtDate"), 1, $user->hasRight('product', 'read') && $user->hasRight('stock', 'lire'));
  1842. // Categories for warehouses
  1843. if (isModEnabled('categorie')) {
  1844. $newmenu->add("/categories/index.php?leftmenu=stock&amp;type=9", $langs->trans("Categories"), 1, $user->hasRight('categorie', 'lire'), '', $mainmenu, 'cat');
  1845. }
  1846. }
  1847. if (isModEnabled('stocktransfer')) {
  1848. $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"'));
  1849. $newmenu->add('/product/stock/stocktransfer/stocktransfer_card.php?action=create', $langs->trans('StockTransferNew'), 1, $user->hasRight('stocktransfer', 'stocktransfer', 'write'));
  1850. $newmenu->add('/product/stock/stocktransfer/stocktransfer_list.php', $langs->trans('List'), 1, $user->hasRight('stocktransfer', 'stocktransfer', 'read'));
  1851. }
  1852. // Inventory
  1853. if (isModEnabled('stock')) {
  1854. $langs->load("stocks");
  1855. if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
  1856. $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"'));
  1857. if ($usemenuhider || empty($leftmenu) || $leftmenu == "stock_inventories") {
  1858. $newmenu->add("/product/inventory/card.php?action=create&leftmenu=stock_inventories", $langs->trans("NewInventory"), 1, $user->hasRight('stock', 'creer'));
  1859. $newmenu->add("/product/inventory/list.php?leftmenu=stock_inventories", $langs->trans("List"), 1, $user->hasRight('stock', 'lire'));
  1860. }
  1861. } else {
  1862. $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"'));
  1863. if ($usemenuhider || empty($leftmenu) || $leftmenu == "stock_inventories") {
  1864. $newmenu->add("/product/inventory/card.php?action=create&leftmenu=stock_inventories", $langs->trans("NewInventory"), 1, $user->hasRight('stock', 'inventory_advance', 'write'));
  1865. $newmenu->add("/product/inventory/list.php?leftmenu=stock_inventories", $langs->trans("List"), 1, $user->hasRight('stock', 'inventory_advance', 'read'));
  1866. }
  1867. }
  1868. }
  1869. // Shipments
  1870. if (isModEnabled('expedition')) {
  1871. $langs->load("sendings");
  1872. $newmenu->add("/expedition/index.php?leftmenu=sendings", $langs->trans("Shipments"), 0, $user->hasRight('expedition', 'lire'), '', $mainmenu, 'sendings', 0, '', '', '', img_picto('', 'shipment', 'class="pictofixedwidth"'));
  1873. $newmenu->add("/expedition/card.php?action=create2&amp;leftmenu=sendings", $langs->trans("NewSending"), 1, $user->hasRight('expedition', 'creer'));
  1874. $newmenu->add("/expedition/list.php?leftmenu=sendings", $langs->trans("List"), 1, $user->hasRight('expedition', 'lire'));
  1875. if ($usemenuhider || empty($leftmenu) || $leftmenu == "sendings") {
  1876. $newmenu->add("/expedition/list.php?leftmenu=sendings&search_status=0", $langs->trans("StatusSendingDraftShort"), 2, $user->hasRight('expedition', 'lire'));
  1877. $newmenu->add("/expedition/list.php?leftmenu=sendings&search_status=1", $langs->trans("StatusSendingValidatedShort"), 2, $user->hasRight('expedition', 'lire'));
  1878. $newmenu->add("/expedition/list.php?leftmenu=sendings&search_status=2", $langs->trans("StatusSendingProcessedShort"), 2, $user->hasRight('expedition', 'lire'));
  1879. }
  1880. $newmenu->add("/expedition/stats/index.php?leftmenu=sendings", $langs->trans("Statistics"), 1, $user->hasRight('expedition', 'lire'));
  1881. }
  1882. // Receptions
  1883. if (isModEnabled('reception')) {
  1884. $langs->load("receptions");
  1885. $newmenu->add("/reception/index.php?leftmenu=receptions", $langs->trans("Receptions"), 0, $user->hasRight('reception', 'lire'), '', $mainmenu, 'receptions', 0, '', '', '', img_picto('', 'dollyrevert', 'class="pictofixedwidth"'));
  1886. $newmenu->add("/reception/card.php?action=create2&amp;leftmenu=receptions", $langs->trans("NewReception"), 1, $user->hasRight('reception', 'creer'));
  1887. $newmenu->add("/reception/list.php?leftmenu=receptions", $langs->trans("List"), 1, $user->hasRight('reception', 'lire'));
  1888. if ($usemenuhider || empty($leftmenu) || $leftmenu == "receptions") {
  1889. $newmenu->add("/reception/list.php?leftmenu=receptions&search_status=0", $langs->trans("StatusReceptionDraftShort"), 2, $user->hasRight('reception', 'lire'));
  1890. }
  1891. if ($usemenuhider || empty($leftmenu) || $leftmenu == "receptions") {
  1892. $newmenu->add("/reception/list.php?leftmenu=receptions&search_status=1", $langs->trans("StatusReceptionValidatedShort"), 2, $user->hasRight('reception', 'lire'));
  1893. }
  1894. if ($usemenuhider || empty($leftmenu) || $leftmenu == "receptions") {
  1895. $newmenu->add("/reception/list.php?leftmenu=receptions&search_status=2", $langs->trans("StatusReceptionProcessedShort"), 2, $user->hasRight('reception', 'lire'));
  1896. }
  1897. $newmenu->add("/reception/stats/index.php?leftmenu=receptions", $langs->trans("Statistics"), 1, $user->hasRight('reception', 'lire'));
  1898. }
  1899. }
  1900. }
  1901. /**
  1902. * Get left Menu PRODUCTS-SERVICES MRP - GPAO
  1903. *
  1904. * @param string $mainmenu Main menu
  1905. * @param Menu $newmenu Object Menu to return back list of menu entries
  1906. * @param string $usemenuhider Use menu hider
  1907. * @param string $leftmenu Left menu
  1908. * @param int $type_user Type of targeted user for menu
  1909. * @return void
  1910. */
  1911. function get_left_menu_mrp($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0)
  1912. {
  1913. global $user, $conf, $langs;
  1914. if ($mainmenu == 'mrp') {
  1915. // BOM
  1916. if (isModEnabled('bom') || isModEnabled('mrp')) {
  1917. $langs->load("mrp");
  1918. $newmenu->add("", $langs->trans("MenuBOM"), 0, $user->hasRight('bom', 'read'), '', $mainmenu, 'bom', 0, '', '', '', img_picto('', 'bom', 'class="paddingright pictofixedwidth"'));
  1919. $newmenu->add("/bom/bom_card.php?leftmenu=bom&amp;action=create", $langs->trans("NewBOM"), 1, $user->hasRight('bom', 'write'), '', $mainmenu, 'bom');
  1920. $newmenu->add("/bom/bom_list.php?leftmenu=bom", $langs->trans("List"), 1, $user->hasRight('bom', 'read'), '', $mainmenu, 'bom');
  1921. }
  1922. if (isModEnabled('mrp')) {
  1923. $langs->load("mrp");
  1924. $newmenu->add("", $langs->trans("MenuMRP"), 0, $user->hasRight('mrp', 'read'), '', $mainmenu, 'mo', 0, '', '', '', img_picto('', 'mrp', 'class="paddingright pictofixedwidth"'));
  1925. $newmenu->add("/mrp/mo_card.php?leftmenu=mo&amp;action=create", $langs->trans("NewMO"), 1, $user->hasRight('mrp', 'write'), '', $mainmenu, 'mo');
  1926. $newmenu->add("/mrp/mo_list.php?leftmenu=mo", $langs->trans("List"), 1, $user->hasRight('mrp', 'read'), '', $mainmenu, 'mo');
  1927. }
  1928. }
  1929. }
  1930. /**
  1931. * Get left Menu PROJECTS
  1932. *
  1933. * @param string $mainmenu Main menu
  1934. * @param Menu $newmenu Object Menu to return back list of menu entries
  1935. * @param string $usemenuhider Use menu hider
  1936. * @param string $leftmenu Left menu
  1937. * @param int $type_user Type of targeted user for menu
  1938. * @return void
  1939. */
  1940. function get_left_menu_projects($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0)
  1941. {
  1942. global $user, $conf, $langs;
  1943. if ($mainmenu == 'project') {
  1944. if (isModEnabled('projet')) {
  1945. $langs->load("projects");
  1946. $search_project_user = GETPOST('search_project_user', 'int');
  1947. $tmpentry = array(
  1948. 'enabled'=>isModEnabled('projet'),
  1949. 'perms'=>$user->hasRight('projet', 'lire'),
  1950. 'module'=>'projet'
  1951. );
  1952. $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL);
  1953. $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal);
  1954. $titleboth = $langs->trans("LeadsOrProjects");
  1955. $titlenew = $langs->trans("NewLeadOrProject"); // Leads and opportunities by default
  1956. if (empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
  1957. $titleboth = $langs->trans("Projects");
  1958. $titlenew = $langs->trans("NewProject");
  1959. }
  1960. if (isset($conf->global->PROJECT_USE_OPPORTUNITIES) && $conf->global->PROJECT_USE_OPPORTUNITIES == 2) { // 2 = leads only
  1961. $titleboth = $langs->trans("Leads");
  1962. $titlenew = $langs->trans("NewLead");
  1963. }
  1964. // Project assigned to user
  1965. $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"'));
  1966. $newmenu->add("/projet/card.php?leftmenu=projects&action=create".($search_project_user ? '&search_project_user='.$search_project_user : ''), $titlenew, 1, $user->hasRight('projet', 'creer'));
  1967. if (empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
  1968. $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');
  1969. } elseif (isset($conf->global->PROJECT_USE_OPPORTUNITIES) && $conf->global->PROJECT_USE_OPPORTUNITIES == 1) {
  1970. $newmenu->add("/projet/list.php?leftmenu=projets".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("List"), 1, $showmode, '', 'project', 'list');
  1971. $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);
  1972. $newmenu->add('/projet/list.php?mainmenu=project&amp;leftmenu=list&search_opp_status=notopenedopp&search_status=99&contextpage=project', $langs->trans("ListOpenProjects"), 2, $showmode);
  1973. } elseif (isset($conf->global->PROJECT_USE_OPPORTUNITIES) && $conf->global->PROJECT_USE_OPPORTUNITIES == 2) { // 2 = leads only
  1974. $newmenu->add('/projet/list.php?mainmenu=project&amp;leftmenu=list&search_usage_opportunity=1&search_status=99', $langs->trans("List"), 2, $showmode);
  1975. }
  1976. $newmenu->add("/projet/stats/index.php?leftmenu=projects", $langs->trans("Statistics"), 1, $user->hasRight('projet', 'lire'));
  1977. // Categories
  1978. if (isModEnabled('categorie')) {
  1979. $langs->load("categories");
  1980. $newmenu->add("/categories/index.php?leftmenu=cat&amp;type=6", $langs->trans("Categories"), 1, $user->hasRight('categorie', 'lire'), '', $mainmenu, 'cat');
  1981. }
  1982. if (empty($conf->global->PROJECT_HIDE_TASKS)) {
  1983. // Project affected to user
  1984. $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"'));
  1985. $newmenu->add("/projet/tasks.php?leftmenu=tasks&action=create", $langs->trans("NewTask"), 1, $user->hasRight('projet', 'creer'));
  1986. $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'));
  1987. $newmenu->add("/projet/tasks/stats/index.php?leftmenu=projects", $langs->trans("Statistics"), 1, $user->hasRight('projet', 'lire'));
  1988. $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"'));
  1989. $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'));
  1990. }
  1991. }
  1992. }
  1993. }
  1994. /**
  1995. * Get left Menu HRM
  1996. *
  1997. * @param string $mainmenu Main menu
  1998. * @param Menu $newmenu Object Menu to return back list of menu entries
  1999. * @param string $usemenuhider Use menu hider
  2000. * @param string $leftmenu Left menu
  2001. * @param int $type_user Type of targeted user for menu
  2002. * @return void
  2003. */
  2004. function get_left_menu_hrm($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0)
  2005. {
  2006. global $user, $conf, $langs;
  2007. if ($mainmenu == 'hrm') {
  2008. // HRM module
  2009. if (isModEnabled('hrm')) {
  2010. $langs->load("hrm");
  2011. $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"'));
  2012. $newmenu->add("/user/card.php?mainmenu=hrm&leftmenu=hrm&action=create&employee=1", $langs->trans("NewEmployee"), 1, $user->hasRight('user', 'user', 'write'));
  2013. $newmenu->add("/user/list.php?mainmenu=hrm&leftmenu=hrm&contextpage=employeelist", $langs->trans("List"), 1, $user->hasRight('user', 'user', 'read'));
  2014. $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"'));
  2015. // Skills
  2016. $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"'));
  2017. //$newmenu->add("/hrm/skill_card.php?mainmenu=hrm&leftmenu=hrm_sm&action=create", $langs->trans("NewSkill"), 1, $user->hasRight('hrm', 'all', 'write'));
  2018. //$newmenu->add("/hrm/skill_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("List"), 1, $user->hasRight('hrm', 'all', 'read'));
  2019. // Job (Description of work to do and skills required)
  2020. $newmenu->add("/hrm/job_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("JobsPosition"), 1, $user->hasRight('hrm', 'all', 'read'), '', $mainmenu, 'hrm_sm', 0, '', '', '', img_picto('', 'technic', 'class="paddingright pictofixedwidth"'));
  2021. //$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'));
  2022. //$newmenu->add("/hrm/job_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("List"), 1, $user->hasRight('hrm', 'all', 'read'));
  2023. // Position = Link job - user
  2024. $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"'));
  2025. //$newmenu->add("/hrm/position.php?mainmenu=hrm&leftmenu=hrm_sm&action=create", $langs->transnoentities("NewObject", $langs->trans("Position")), 1, $user->hasRight('hrm', 'all', 'write'));
  2026. //$newmenu->add("/hrm/position_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("List"), 1, $user->hasRight('hrm', 'all', 'read'));
  2027. // Evaluation
  2028. $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"'));
  2029. //$newmenu->add("/hrm/evaluation_card.php?mainmenu=hrm&leftmenu=hrm_sm&action=create", $langs->trans("NewEval"), 1, $user->hasRight('hrm', 'evaluation', 'write'));
  2030. //$newmenu->add("/hrm/evaluation_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("List"), 1, $user->hasRight('hrm', 'evaluation', 'read'));
  2031. $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'));
  2032. }
  2033. // Leave/Holiday/Vacation module
  2034. if (isModEnabled('holiday')) {
  2035. // Load translation files required by the page
  2036. $langs->loadLangs(array("holiday", "trips"));
  2037. $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"'));
  2038. $newmenu->add("/holiday/card.php?mainmenu=hrm&leftmenu=holiday&action=create", $langs->trans("New"), 1, $user->hasRight('holiday', 'write'), '', $mainmenu);
  2039. $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');
  2040. $newmenu->add("/holiday/list.php?mainmenu=hrm&leftmenu=holiday", $langs->trans("List"), 1, $user->hasRight('holiday', 'read'), '', $mainmenu);
  2041. if ($usemenuhider || empty($leftmenu) || $leftmenu == "holiday") {
  2042. $newmenu->add("/holiday/list.php?search_status=1&mainmenu=hrm&leftmenu=holiday", $langs->trans("DraftCP"), 2, $user->hasRight('holiday', 'read'), '', $mainmenu, 'holiday_sm');
  2043. $newmenu->add("/holiday/list.php?search_status=2&mainmenu=hrm&leftmenu=holiday", $langs->trans("ToReviewCP"), 2, $user->hasRight('holiday', 'read'), '', $mainmenu, 'holiday_sm');
  2044. $newmenu->add("/holiday/list.php?search_status=3&mainmenu=hrm&leftmenu=holiday", $langs->trans("ApprovedCP"), 2, $user->hasRight('holiday', 'read'), '', $mainmenu, 'holiday_sm');
  2045. $newmenu->add("/holiday/list.php?search_status=4&mainmenu=hrm&leftmenu=holiday", $langs->trans("CancelCP"), 2, $user->hasRight('holiday', 'read'), '', $mainmenu, 'holiday_sm');
  2046. $newmenu->add("/holiday/list.php?search_status=5&mainmenu=hrm&leftmenu=holiday", $langs->trans("RefuseCP"), 2, $user->hasRight('holiday', 'read'), '', $mainmenu, 'holiday_sm');
  2047. }
  2048. $newmenu->add("/holiday/define_holiday.php?mainmenu=hrm", $langs->trans("MenuConfCP"), 1, $user->hasRight('holiday', 'read'), '', $mainmenu, 'holiday_sm');
  2049. $newmenu->add("/holiday/month_report.php?mainmenu=hrm&leftmenu=holiday", $langs->trans("MenuReportMonth"), 1, $user->hasRight('holiday', 'readall'), '', $mainmenu, 'holiday_sm');
  2050. $newmenu->add("/holiday/view_log.php?mainmenu=hrm&leftmenu=holiday", $langs->trans("MenuLogCP"), 1, $user->hasRight('holiday', 'define_holiday'), '', $mainmenu, 'holiday_sm');
  2051. }
  2052. // Trips and expenses (old module)
  2053. if (isModEnabled('deplacement')) {
  2054. $langs->load("trips");
  2055. $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"'));
  2056. $newmenu->add("/compta/deplacement/card.php?action=create&amp;leftmenu=tripsandexpenses&amp;mainmenu=hrm", $langs->trans("New"), 1, $user->hasRight('deplacement', 'creer'));
  2057. $newmenu->add("/compta/deplacement/list.php?leftmenu=tripsandexpenses&amp;mainmenu=hrm", $langs->trans("List"), 1, $user->hasRight('deplacement', 'lire'));
  2058. $newmenu->add("/compta/deplacement/stats/index.php?leftmenu=tripsandexpenses&amp;mainmenu=hrm", $langs->trans("Statistics"), 1, $user->hasRight('deplacement', 'lire'));
  2059. }
  2060. // Expense report
  2061. if (isModEnabled('expensereport')) {
  2062. $langs->loadLangs(array("trips", "bills"));
  2063. $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"'));
  2064. $newmenu->add("/expensereport/card.php?action=create&amp;leftmenu=expensereport&amp;mainmenu=hrm", $langs->trans("New"), 1, $user->hasRight('expensereport', 'creer'));
  2065. $newmenu->add("/expensereport/list.php?leftmenu=expensereport&amp;mainmenu=hrm", $langs->trans("List"), 1, $user->hasRight('expensereport', 'lire'));
  2066. if ($usemenuhider || empty($leftmenu) || $leftmenu == "expensereport") {
  2067. $newmenu->add("/expensereport/list.php?search_status=0&amp;leftmenu=expensereport&amp;mainmenu=hrm", $langs->trans("Draft"), 2, $user->hasRight('expensereport', 'lire'));
  2068. $newmenu->add("/expensereport/list.php?search_status=2&amp;leftmenu=expensereport&amp;mainmenu=hrm", $langs->trans("Validated"), 2, $user->hasRight('expensereport', 'lire'));
  2069. $newmenu->add("/expensereport/list.php?search_status=5&amp;leftmenu=expensereport&amp;mainmenu=hrm", $langs->trans("Approved"), 2, $user->hasRight('expensereport', 'lire'));
  2070. $newmenu->add("/expensereport/list.php?search_status=6&amp;leftmenu=expensereport&amp;mainmenu=hrm", $langs->trans("Paid"), 2, $user->hasRight('expensereport', 'lire'));
  2071. $newmenu->add("/expensereport/list.php?search_status=4&amp;leftmenu=expensereport&amp;mainmenu=hrm", $langs->trans("Canceled"), 2, $user->hasRight('expensereport', 'lire'));
  2072. $newmenu->add("/expensereport/list.php?search_status=99&amp;leftmenu=expensereport&amp;mainmenu=hrm", $langs->trans("Refused"), 2, $user->hasRight('expensereport', 'lire'));
  2073. }
  2074. $newmenu->add("/expensereport/payment/list.php?leftmenu=expensereport_payments&amp;mainmenu=hrm", $langs->trans("Payments"), 1, $user->hasRight('expensereport', 'lire'));
  2075. $newmenu->add("/expensereport/stats/index.php?leftmenu=expensereport&amp;mainmenu=hrm", $langs->trans("Statistics"), 1, $user->hasRight('expensereport', 'lire'));
  2076. }
  2077. if (isModEnabled('projet')) {
  2078. if (empty($conf->global->PROJECT_HIDE_TASKS)) {
  2079. $langs->load("projects");
  2080. $search_project_user = GETPOST('search_project_user', 'int');
  2081. $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"'));
  2082. }
  2083. }
  2084. }
  2085. }
  2086. /**
  2087. * Get left Menu TOOLS
  2088. *
  2089. * @param string $mainmenu Main menu
  2090. * @param Menu $newmenu Object Menu to return back list of menu entries
  2091. * @param string $usemenuhider Use menu hider
  2092. * @param string $leftmenu Left menu
  2093. * @param int $type_user Type of targeted user for menu
  2094. * @return void
  2095. */
  2096. function get_left_menu_tools($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0)
  2097. {
  2098. global $user, $conf, $langs;
  2099. if ($mainmenu == 'tools') {
  2100. if (empty($user->socid)) { // limit to internal users
  2101. $langs->load("mails");
  2102. $newmenu->add("/admin/mails_templates.php?leftmenu=email_templates", $langs->trans("EMailTemplates"), 0, 1, '', $mainmenu, 'email_templates', 0, '', '', '', img_picto('', 'email', 'class="paddingright pictofixedwidth"'));
  2103. }
  2104. if (isModEnabled('mailing')) {
  2105. $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"'));
  2106. $newmenu->add("/comm/mailing/card.php?leftmenu=mailing&amp;action=create", $langs->trans("NewMailing"), 1, $user->hasRight('mailing', 'creer'));
  2107. $newmenu->add("/comm/mailing/list.php?leftmenu=mailing", $langs->trans("List"), 1, $user->hasRight('mailing', 'lire'));
  2108. }
  2109. if (isModEnabled('export')) {
  2110. $langs->load("exports");
  2111. $newmenu->add("/exports/index.php?leftmenu=export", $langs->trans("FormatedExport"), 0, $user->hasRight('export', 'lire'), '', $mainmenu, 'export', 0, '', '', '', img_picto('', 'technic', 'class="paddingright pictofixedwidth"'));
  2112. $newmenu->add("/exports/export.php?leftmenu=export", $langs->trans("NewExport"), 1, $user->hasRight('export', 'creer'));
  2113. //$newmenu->add("/exports/export.php?leftmenu=export",$langs->trans("List"),1, $user->hasRight('export', 'lire'));
  2114. }
  2115. if (isModEnabled('import')) {
  2116. $langs->load("exports");
  2117. $newmenu->add("/imports/index.php?leftmenu=import", $langs->trans("FormatedImport"), 0, $user->hasRight('import', 'run'), '', $mainmenu, 'import', 0, '', '', '', img_picto('', 'technic', 'class="paddingright pictofixedwidth"'));
  2118. $newmenu->add("/imports/import.php?leftmenu=import", $langs->trans("NewImport"), 1, $user->hasRight('import', 'run'));
  2119. }
  2120. }
  2121. }
  2122. /**
  2123. * Get left Menu MEMBERS
  2124. *
  2125. * @param string $mainmenu Main menu
  2126. * @param Menu $newmenu Object Menu to return back list of menu entries
  2127. * @param string $usemenuhider Use menu hider
  2128. * @param string $leftmenu Left menu
  2129. * @param int $type_user Type of targeted user for menu
  2130. * @return void
  2131. */
  2132. function get_left_menu_members($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0)
  2133. {
  2134. global $user, $conf, $langs;
  2135. if ($mainmenu == 'members') {
  2136. if (isModEnabled('adherent')) {
  2137. // Load translation files required by the page
  2138. $langs->loadLangs(array("members", "compta"));
  2139. $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"'));
  2140. $newmenu->add("/adherents/card.php?leftmenu=members&amp;action=create", $langs->trans("NewMember"), 1, $user->hasRight('adherent', 'write'));
  2141. $newmenu->add("/adherents/list.php?leftmenu=members", $langs->trans("List"), 1, $user->hasRight('adherent', 'read'));
  2142. $newmenu->add("/adherents/list.php?leftmenu=members&amp;statut=-1", $langs->trans("MenuMembersToValidate"), 2, $user->hasRight('adherent', 'read'));
  2143. $newmenu->add("/adherents/list.php?leftmenu=members&amp;statut=1", $langs->trans("MenuMembersValidated"), 2, $user->hasRight('adherent', 'read'));
  2144. $newmenu->add("/adherents/list.php?leftmenu=members&amp;statut=1&amp;filter=waitingsubscription", $langs->trans("WaitingSubscription"), 3, $user->hasRight('adherent', 'read'));
  2145. $newmenu->add("/adherents/list.php?leftmenu=members&amp;statut=1&amp;filter=uptodate", $langs->trans("UpToDate"), 3, $user->hasRight('adherent', 'read'));
  2146. $newmenu->add("/adherents/list.php?leftmenu=members&amp;statut=1&amp;filter=outofdate", $langs->trans("OutOfDate"), 3, $user->hasRight('adherent', 'read'));
  2147. $newmenu->add("/adherents/list.php?leftmenu=members&amp;statut=0", $langs->trans("MenuMembersResiliated"), 2, $user->hasRight('adherent', 'read'));
  2148. $newmenu->add("/adherents/list.php?leftmenu=members&amp;statut=-2", $langs->trans("MenuMembersExcluded"), 2, $user->hasRight('adherent', 'read'));
  2149. $newmenu->add("/adherents/stats/index.php?leftmenu=members", $langs->trans("MenuMembersStats"), 1, $user->hasRight('adherent', 'read'));
  2150. $newmenu->add("/adherents/cartes/carte.php?leftmenu=export", $langs->trans("MembersCards"), 1, $user->hasRight('adherent', 'export'));
  2151. if (!empty($conf->global->MEMBER_LINK_TO_HTPASSWDFILE) && ($usemenuhider || empty($leftmenu) || $leftmenu == 'none' || $leftmenu == "members" || $leftmenu == "export")) {
  2152. $newmenu->add("/adherents/htpasswd.php?leftmenu=export", $langs->trans("Filehtpasswd"), 1, $user->hasRight('adherent', 'export'));
  2153. }
  2154. if (isModEnabled('categorie')) {
  2155. $langs->load("categories");
  2156. $newmenu->add("/categories/index.php?leftmenu=cat&amp;type=3", $langs->trans("Categories"), 1, $user->hasRight('categorie', 'read'), '', $mainmenu, 'cat');
  2157. }
  2158. $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"'));
  2159. $newmenu->add("/adherents/list.php?leftmenu=members&amp;statut=-1,1&amp;mainmenu=members", $langs->trans("NewSubscription"), 1, $user->hasRight('adherent', 'cotisation', 'write'));
  2160. $newmenu->add("/adherents/subscription/list.php?leftmenu=members", $langs->trans("List"), 1, $user->hasRight('adherent', 'cotisation', 'read'));
  2161. $newmenu->add("/adherents/stats/index.php?leftmenu=members", $langs->trans("MenuMembersStats"), 1, $user->hasRight('adherent', 'read'));
  2162. //$newmenu->add("/adherents/index.php?leftmenu=export&amp;mainmenu=members",$langs->trans("Tools"),0,$user->hasRight('adherent', 'export'), '', $mainmenu, 'export');
  2163. //if (isModEnabled('export') && ($usemenuhider || empty($leftmenu) || $leftmenu=="export")) $newmenu->add("/exports/index.php?leftmenu=export",$langs->trans("Datas"),1,$user->hasRight('adherent', 'export'));
  2164. // Type
  2165. $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"'));
  2166. $newmenu->add("/adherents/type.php?leftmenu=setup&amp;mainmenu=members&amp;action=create", $langs->trans("New"), 1, $user->hasRight('adherent', 'configurer'));
  2167. $newmenu->add("/adherents/type.php?leftmenu=setup&amp;mainmenu=members", $langs->trans("List"), 1, $user->hasRight('adherent', 'configurer'));
  2168. }
  2169. }
  2170. }