eldy.lib.php 145 KB

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