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