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