dolibarr 22.0.5
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-2024 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-2025 Frédéric France <frederic.france@free.fr>
9 * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
10 * Copyright (C) 2022-2023 Solution Libre SAS <contact@solution-libre.fr>
11 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
12 * Copyright (C) 2024-2025 Alexandre Spangaro <alexandre@inovea-conseil.com>
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program. If not, see <https://www.gnu.org/licenses/>.
26 * or see https://www.gnu.org/
27 */
28
33require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php';
34
35
48function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 0, $mode = '')
49{
50 global $user, $conf, $langs, $mysoc;
51 global $dolibarr_main_db_name;
52
53 $mainmenu = (empty($_SESSION["mainmenu"]) ? '' : $_SESSION["mainmenu"]);
54 $leftmenu = (empty($_SESSION["leftmenu"]) ? '' : $_SESSION["leftmenu"]);
55
56 $id = 'mainmenu';
57 $listofmodulesforexternal = explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL'));
58
59 $substitarray = getCommonSubstitutionArray($langs, 0, null, null);
60
61 global $usemenuhider;
62 $usemenuhider = 1;
63
64 // Show/Hide vertical menu. The hamburger icon for .menuhider action.
65 if ($mode != 'jmobile' && $mode != 'topnb' && $usemenuhider && !getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
66 $showmode = 1;
67 $classname = 'class="tmenu menuhider nohover"';
68 $idsel = 'menu';
69
70 $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>');
71 }
72
73 $menu_arr = array();
74
75 // Home
76 $homepage = getDolUserString('MAIN_HOME_PAGE', getDolGlobalString('MAIN_HOME_PAGE'));
77 if (!empty($homepage) && !$user->admin) {
78 $homepage = dol_buildpath($homepage, 1);
79 } else {
80 $homepage = '/index.php?mainmenu=home&leftmenu=home';
81 }
82 $menu_arr[] = array(
83 'name' => 'Home',
84 'link' => $homepage,
85 'title' => "Home",
86 'level' => 0,
87 'enabled' => $showmode = 1,
88 'target' => $atarget,
89 'mainmenu' => "home",
90 'leftmenu' => '',
91 'position' => 10,
92 'id' => $id,
93 'idsel' => 'home',
94 'classname' => $classname = (empty($_SESSION["mainmenu"]) || $_SESSION["mainmenu"] == "home") ? 'class="tmenusel"' : 'class="tmenu"',
95 'prefix' => '<span class="fas fa-home fa-fw"></span>',
96 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "home") ? 0 : 1),
97 'loadLangs' => array(),
98 'submenus' => array(),
99 );
100
101 // Members
102 $tmpentry = array(
103 'enabled' => (int) isModEnabled('member'),
104 'perms' => (string) (int) $user->hasRight('adherent', 'lire'),
105 'module' => 'adherent'
106 );
107 $menu_arr[] = array(
108 'name' => 'Members',
109 'link' => '/adherents/index.php?mainmenu=members&amp;leftmenu=',
110 'title' => "MenuMembers",
111 'level' => 0,
112 'enabled' => (int) ($showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal)),
113 'target' => $atarget,
114 'mainmenu' => "members",
115 'leftmenu' => '',
116 'position' => 18,
117 'id' => $id,
118 'idsel' => 'members',
119 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "members") ? 'class="tmenusel"' : 'class="tmenu"',
120 'prefix' => img_picto('', 'member', 'class="fa-fw pictofixedwidth"'),
121 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "members") ? 0 : 1),
122 'loadLangs' => array("members"),
123 'submenus' => array(),
124 );
125
126 // Third parties
127 $tmpentry = array(
128 'enabled' => (int) (
129 (
130 isModEnabled('societe') &&
131 (!getDolGlobalString('SOCIETE_DISABLE_PROSPECTS') || !getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS'))
132 )
133 || (isModEnabled('supplier_proposal') || isModEnabled('supplier_order') || isModEnabled('supplier_invoice'))
134 ),
135 'perms' => (string) (int) ($user->hasRight('societe', 'lire') || $user->hasRight('societe', 'contact', 'lire') || $user->hasRight('fournisseur', 'lire') || $user->hasRight('supplier_order', 'lire') || $user->hasRight('supplier_invoice', 'lire') || $user->hasRight('supplier_proposal', 'lire')),
136 'module' => 'societe|fournisseur'
137 );
138
139 $menu_arr[] = array(
140 'name' => 'Companies',
141 'link' => '/societe/index.php?mainmenu=companies&amp;leftmenu=',
142 'title' => "ThirdParties",
143 'level' => 0,
144 'enabled' => (int) ($showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal)),
145 'target' => $atarget,
146 'mainmenu' => "companies",
147 'leftmenu' => '',
148 'position' => 20,
149 'id' => $id,
150 'idsel' => 'companies',
151 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "companies") ? 'class="tmenusel"' : 'class="tmenu"',
152 'prefix' => img_picto('', 'company', 'class="fa-fw pictofixedwidth"'),
153 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "companies") ? 0 : 1),
154 'loadLangs' => array("companies", "suppliers"),
155 'submenus' => array(),
156 );
157
158 // Products-Services
159 $tmpentry = array(
160 'enabled' => (int) (isModEnabled('product') || isModEnabled('service') || isModEnabled('shipping')),
161 'perms' => (string) (int) ($user->hasRight('product', 'read') || $user->hasRight('service', 'read') || $user->hasRight('expedition', 'lire')),
162 'module' => 'product|service'
163 );
164 $menu_arr[] = array(
165 'name' => 'Products',
166 'link' => '/product/index.php?mainmenu=products&amp;leftmenu=',
167 'title' => (isModEnabled('product') && isModEnabled('service'))
168 ? (array("TMenuProducts", " | ", "TMenuServices"))
169 : (isModEnabled('product') ? "TMenuProducts" : "TMenuServices"),
170 'level' => 0,
171 'enabled' => (int) ($showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal)),
172 'target' => $atarget,
173 'mainmenu' => "products",
174 'leftmenu' => '',
175 'position' => 30,
176 'id' => $id,
177 'idsel' => 'products',
178 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "products") ? 'class="tmenusel"' : 'class="tmenu"',
179 'prefix' => img_picto('', 'product', 'class="fa-fw pictofixedwidth"'),
180 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "products") ? 0 : 1),
181 'loadLangs' => array("products", "stocks"),
182 'submenus' => array(),
183 );
184
185 // MRP - GPAO
186 $tmpentry = array(
187 'enabled' => (int) (isModEnabled('bom') || isModEnabled('mrp')),
188 'perms' => (string) (int) ($user->hasRight('bom', 'read') || $user->hasRight('mrp', 'read')),
189 'module' => 'bom|mrp'
190 );
191 $menu_arr[] = array(
192 'name' => 'TMenuMRP',
193 'link' => '/mrp/index.php?mainmenu=mrp&amp;leftmenu=',
194 'title' => "TMenuMRP",
195 'level' => 0,
196 'enabled' => (int) ($showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal)),
197 'target' => $atarget,
198 'mainmenu' => "mrp",
199 'leftmenu' => '',
200 'position' => 31,
201 'id' => $id,
202 'idsel' => 'mrp',
203 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "mrp") ? 'class="tmenusel"' : 'class="tmenu"',
204 'prefix' => img_picto('', 'mrp', 'class="fa-fw pictofixedwidth"'),
205 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "mrp") ? 0 : 1),
206 'loadLangs' => array("mrp"),
207 'submenus' => array(),
208 );
209
210 // Projects
211 $tmpentry = array(
212 'enabled' => (int) (isModEnabled('project') ? 1 : 0),
213 'perms' => (string) (int) ($user->hasRight('projet', 'lire') ? 1 : 0),
214 'module' => 'projet'
215 );
216
217 if ($mode == 'jmobile') {
218 $titleboth = $langs->trans("LeadsOrProjects");
219 } else {
220 $titleboth = $langs->trans("Projects");
221 }
222 if (!getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) {
223 $titleboth = $langs->trans("Projects");
224 }
225 if (getDolGlobalInt('PROJECT_USE_OPPORTUNITIES') == 2) { // 2 = leads only
226 $titleboth = $langs->trans("Leads");
227 }
228
229 $menu_arr[] = array(
230 'name' => 'Project',
231 'link' => '/projet/index.php?mainmenu=project&amp;leftmenu=',
232 'title' => $titleboth,
233 'level' => 0,
234 'enabled' => (int) ($showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal)),
235 'target' => $atarget,
236 'mainmenu' => "project",
237 'leftmenu' => '',
238 'position' => 35,
239 'id' => $id,
240 'idsel' => 'project',
241 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "project") ? 'class="tmenusel"' : 'class="tmenu"',
242 'prefix' => img_picto('', 'project', 'class="fa-fw pictofixedwidth"'),
243 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "project") ? 0 : 1),
244 'loadLangs' => array("projects"),
245 'submenus' => array(),
246 );
247
248 // Commercial (propal, commande, supplier_proposal, supplier_order, contrat, ficheinter)
249 $tmpentry = array(
250 'enabled' => (int) (
251 isModEnabled('propal')
252 || isModEnabled('order')
253 || isModEnabled('fournisseur')
254 || isModEnabled('supplier_proposal')
255 || isModEnabled('supplier_order')
256 || isModEnabled('contract')
257 || isModEnabled('intervention')
258 ) ? 1 : 0,
259 'perms' => (string) (int) (
260 $user->hasRight('propal', 'read')
261 || $user->hasRight('commande', 'lire')
262 || $user->hasRight('supplier_proposal', 'lire')
263 || $user->hasRight('fournisseur', 'commande', 'lire')
264 || $user->hasRight('supplier_order', 'lire')
265 || $user->hasRight('contrat', 'lire')
266 || $user->hasRight('ficheinter', 'lire')
267 ),
268 'module' => 'propal|commande|supplier_proposal|supplier_order|contrat|ficheinter'
269 );
270
271 $onlysupplierorder = $user->hasRight('fournisseur', 'commande', 'lire') &&
272 !$user->hasRight('propal', 'lire') &&
273 !$user->hasRight('commande', 'lire') &&
274 !$user->hasRight('supplier_order', 'lire') &&
275 !$user->hasRight('supplier_proposal', 'lire') &&
276 !$user->hasRight('contrat', 'lire') &&
277 !$user->hasRight('ficheinter', 'lire');
278
279 $menu_arr[] = array(
280 'name' => 'Commercial',
281 'link' => ($onlysupplierorder ? '/fourn/commande/index.php?mainmenu=commercial&amp;leftmenu=' : '/comm/index.php?mainmenu=commercial&amp;leftmenu='),
282 'title' => "Commercial",
283 'level' => 0,
284 'enabled' => (int) ($showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal)),
285 'target' => $atarget,
286 'mainmenu' => "commercial",
287 'leftmenu' => '',
288 'position' => 40,
289 'id' => $id,
290 'idsel' => 'commercial',
291 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "commercial") ? 'class="tmenusel"' : 'class="tmenu"',
292 'prefix' => img_picto('', 'contract', 'class="fa-fw pictofixedwidth"'),
293 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "commercial") ? 0 : 1),
294 'loadLangs' => array("commercial"),
295 'submenus' => array(),
296 );
297
298 // Billing - Financial
299 $tmpentry = array(
300 'enabled' => (int) (
301 isModEnabled('invoice') ||
302 isModEnabled('don') ||
303 isModEnabled('tax') ||
304 isModEnabled('salaries') ||
305 isModEnabled('supplier_invoice') ||
306 isModEnabled('loan') ||
307 isModEnabled('margin')
308 ) ? 1 : 0,
309 'perms' => (string) (int) ($user->hasRight('facture', 'lire') || $user->hasRight('don', 'contact', 'lire')
310 || $user->hasRight('tax', 'charges', 'lire') || $user->hasRight('salaries', 'read')
311 || $user->hasRight('fournisseur', 'facture', 'lire') || $user->hasRight('loan', 'read') || $user->hasRight('margins', 'liretous')),
312 'module' => 'facture|supplier_invoice|don|tax|salaries|loan'
313 );
314 $menu_arr[] = array(
315 'name' => 'Compta',
316 'link' => '/compta/index.php?mainmenu=billing&amp;leftmenu=',
317 'title' => "MenuFinancial",
318 'level' => 0,
319 'enabled' => (int) ($showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal)),
320 'target' => $atarget,
321 'mainmenu' => "billing",
322 'leftmenu' => '',
323 'position' => 50,
324 'id' => $id,
325 'idsel' => 'billing',
326 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "billing") ? 'class="tmenusel"' : 'class="tmenu"',
327 'prefix' => img_picto('', 'bill', 'class="fa-fw pictofixedwidth"'),
328 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "billing") ? 0 : 1),
329 'loadLangs' => array("compta"),
330 'submenus' => array(),
331 );
332
333 // Bank
334 $tmpentry = array(
335 'enabled' => (int) (isModEnabled('bank') || isModEnabled('prelevement')),
336 'perms' => (string) (int) ($user->hasRight('banque', 'lire') || $user->hasRight('prelevement', 'lire') || $user->hasRight('paymentbybanktransfer', 'read')),
337 'module' => 'banque|prelevement|paymentbybanktransfer'
338 );
339 $menu_arr[] = array(
340 'name' => 'Bank',
341 'link' => '/compta/bank/list.php?mainmenu=bank&amp;leftmenu=&amp;search_status=opened',
342 'title' => "MenuBankCash",
343 'level' => 0,
344 'enabled' => (int) ($showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal)),
345 'target' => $atarget,
346 'mainmenu' => "bank",
347 'leftmenu' => '',
348 'position' => 52,
349 'id' => $id,
350 'idsel' => 'bank',
351 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "bank") ? 'class="tmenusel"' : 'class="tmenu"',
352 'prefix' => img_picto('', 'bank_account', 'class="fa-fw pictofixedwidth"'),
353 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "bank") ? 0 : 1),
354 'loadLangs' => array("compta", "banks"),
355 'submenus' => array(),
356 );
357
358 // Accounting
359 $tmpentry = array(
360 'enabled' => (int) (isModEnabled('comptabilite') || isModEnabled('accounting') || isModEnabled('asset') || isModEnabled('intracommreport')),
361 'perms' => (string) (int) ($user->hasRight('compta', 'resultat', 'lire') || $user->hasRight('accounting', 'comptarapport', 'lire') || $user->hasRight('accounting', 'mouvements', 'lire') || $user->hasRight('asset', 'read') || $user->hasRight('intracommreport', 'read')),
362 'module' => 'comptabilite|accounting|asset|intracommreport'
363 );
364 $menu_arr[] = array(
365 'name' => 'Accounting',
366 'link' => '/accountancy/index.php?mainmenu=accountancy&amp;leftmenu=',
367 'title' => "MenuAccountancy",
368 'level' => 0,
369 'enabled' => (int) ($showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal)),
370 'target' => $atarget,
371 'mainmenu' => "accountancy",
372 'leftmenu' => '',
373 'position' => 54,
374 'id' => $id,
375 'idsel' => 'accountancy',
376 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "accountancy") ? 'class="tmenusel"' : 'class="tmenu"',
377 'prefix' => img_picto('', 'accountancy', 'class="fa-fw pictofixedwidth"'),
378 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "accountancy") ? 0 : 1),
379 'loadLangs' => array("compta", "accountancy", "assets", "intracommreport"),
380 'submenus' => array(),
381 );
382
383 // HRM
384 $tmpentry = array(
385 'enabled' => (int) (isModEnabled('hrm') || (isModEnabled('holiday')) || isModEnabled('deplacement') || isModEnabled('expensereport') || isModEnabled('recruitment')),
386 'perms' => (string) (int) ($user->hasRight('user', 'user', 'lire') || $user->hasRight('holiday', 'read') || $user->hasRight('deplacement', 'lire') || $user->hasRight('expensereport', 'lire') || $user->hasRight('recruitment', 'recruitmentjobposition', 'read')),
387 'module' => 'hrm|holiday|deplacement|expensereport|recruitment'
388 );
389
390 $menu_arr[] = array(
391 'name' => 'HRM',
392 'link' => '/hrm/index.php?mainmenu=hrm&amp;leftmenu=',
393 'title' => "HRM",
394 'level' => 0,
395 'enabled' => (int) ($showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal)),
396 'target' => $atarget,
397 'mainmenu' => "hrm",
398 'leftmenu' => '',
399 'position' => 80,
400 'id' => $id,
401 'idsel' => 'hrm',
402 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "hrm") ? 'class="tmenusel"' : 'class="tmenu"',
403 'prefix' => img_picto('', 'hrm', 'class="fa-fw pictofixedwidth"'),
404 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "hrm") ? 0 : 1),
405 'loadLangs' => array("hrm", "holiday"),
406 'submenus' => array(),
407 );
408
409 // Tickets and Knowledge base
410 $tmpentry = array(
411 'enabled' => (int) (isModEnabled('ticket') || isModEnabled('knowledgemanagement')),
412 'perms' => (string) (int) ($user->hasRight('ticket', 'read') || $user->hasRight('knowledgemanagement', 'knowledgerecord', 'read')),
413 'module' => 'ticket|knowledgemanagement'
414 );
415 $link = '';
416 if (isModEnabled('ticket')) {
417 $link = '/ticket/index.php?mainmenu=ticket&amp;leftmenu=';
418 } else {
419 $link = '/knowledgemanagement/knowledgerecord_list.php?mainmenu=ticket&amp;leftmenu=';
420 }
421 $menu_arr[] = array(
422 'name' => 'Ticket',
423 'link' => $link,
424 'title' => isModEnabled('ticket') ? "Tickets" : "MenuKnowledgeRecordShort",
425 'level' => 0,
426 'enabled' => (int) ($showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal)),
427 'target' => $atarget,
428 'mainmenu' => "ticket",
429 'leftmenu' => '',
430 'position' => 88,
431 'id' => $id,
432 'idsel' => 'ticket',
433 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "ticket") ? 'class="tmenusel"' : 'class="tmenu"',
434 'prefix' => img_picto('', 'ticket', 'class="fa-fw pictofixedwidth"'),
435 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "ticket") ? 0 : 1),
436 'loadLangs' => array("ticket", "knowledgemanagement"),
437 'submenus' => array(),
438 );
439
440 // Tools
441 $tmpentry = array(
442 'enabled' => 1,
443 'perms' => '1',
444 'module' => ''
445 );
446 $menu_arr[] = array(
447 'name' => 'Tools',
448 'link' => '/core/tools.php?mainmenu=tools&amp;leftmenu=',
449 'title' => "Tools",
450 'level' => 0,
451 'enabled' => (int) ($showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal)),
452 'target' => $atarget,
453 'mainmenu' => "tools",
454 'leftmenu' => '',
455 'position' => 90,
456 'id' => $id,
457 'idsel' => 'tools',
458 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "tools") ? 'class="tmenusel"' : 'class="tmenu"',
459 'prefix' => img_picto('', 'tools', 'class="fa-fw pictofixedwidth"'),
460 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "tools") ? 0 : 1),
461 'loadLangs' => array("other"),
462 'submenus' => array(),
463 );
464
465 // Add menus previously had code declared
466 foreach ($menu_arr as $key => $smenu) {
467 $smenu = (object) $smenu;
468
469 if ($smenu->enabled) {
470 if ($smenu->session) {
471 $_SESSION['idmenu'] = '';
472 }
473
474 // Load Langue
475 if (!empty($smenu->loadLangs)) {
476 $langs->loadLangs($smenu->loadLangs);
477 }
478
479 // Trans title
480 $mtitle = '';
481 if (is_array($smenu->title)) {
482 foreach ($smenu->title as $item) {
483 $mtitle .= $langs->trans($item);
484 }
485 } else {
486 $mtitle = $langs->trans($smenu->title);
487 }
488 // Add item
489 $menu->add($smenu->link, $mtitle, $smenu->level, $smenu->enabled, $smenu->target, $smenu->mainmenu, $smenu->leftmenu, $smenu->position, $smenu->id, $smenu->idsel, $smenu->classname, (string) $smenu->prefix);
490 }
491 }
492
493 // Load menu with top entries of non hardcoded core menu enties and external modules
494 $menuArbo = new Menubase($db, 'eldy');
495 $newTabMenu = $menuArbo->menuTopCharger('', '', $type_user, 'eldy', $tabMenu); // Set tabMenu with only top entries of non hardcoded core menu enties and external modules
496
497 // Add menu with top entries of non hardcoded core menu entries and of external modules
498 $num = count($newTabMenu);
499 for ($i = 0; $i < $num; $i++) {
500 //var_dump($type_user.' '.$newTabMenu[$i]['url'].' '.$showmode.' '.$newTabMenu[$i]['perms']);
501 $idsel = (empty($newTabMenu[$i]['mainmenu']) ? 'none' : $newTabMenu[$i]['mainmenu']);
502
503 $newTabMenu[$i]['url'] = make_substitutions($newTabMenu[$i]['url'], $substitarray);
504
505 // Phan issue #4881 requires that we reforce the type
506 '@phan-var-force array<array{rowid:string,fk_menu:string,langs:string,enabled:int<0,2>,type:string,fk_mainmenu:string,fk_leftmenu:string,url:string,titre:string,perms:string,target:string,mainmenu:string,leftmenu:string,position:int,positionfull:int|string,showtopmenuinframe:int,prefix:string}> $newTabMenu';
507
508 // url = url from host, shorturl = relative path into dolibarr sources
509 $url = $shorturl = $newTabMenu[$i]['url'];
510 if (!preg_match("/^(http:\/\/|https:\/\/)/i", $newTabMenu[$i]['url'])) { // Do not change url content for external links
511 $tmp = explode('?', $newTabMenu[$i]['url'], 2);
512 $url = $shorturl = $tmp[0];
513 $param = (isset($tmp[1]) ? $tmp[1] : '');
514
515 // Complete the url only when neither mainmenu nor leftmenu is already set, like print_left_eldy_menu() does.
516 // With a OR, a url already carrying only mainmenu got a second one, and a url already carrying only leftmenu
517 // got an empty leftmenu appended that overrode the real value.
518 if ((!preg_match('/mainmenu/i', $param)) && (!preg_match('/leftmenu/i', $param))) {
519 // @phan-suppress-next-line PhanTypeSuspiciousStringExpression
520 $param .= ($param ? '&' : '').'mainmenu='.$newTabMenu[$i]['mainmenu'].'&leftmenu=';
521 }
522 //$url.="idmenu=".$newTabMenu[$i]['rowid']; // Already done by menuLoad
523 $url = dol_buildpath($url, 1).($param ? '?'.$param : '');
524 //$shorturl = $shorturl.($param?'?'.$param:'');
525 $shorturl = $url;
526 if (DOL_URL_ROOT) {
527 $shorturl = preg_replace('/^'.preg_quote(DOL_URL_ROOT, '/').'/', '', $shorturl);
528 }
529 }
530
531 // Modify URL for the case we are using the option showtopmenuinframe
532 if ($newTabMenu[$i]['showtopmenuinframe']) {
533 if (preg_match("/^(http:\/\/|https:\/\/)/i", $newTabMenu[$i]['url'])) {
534 $url = $shorturl = '/core/frames.php?idmenu='.$newTabMenu[$i]['rowid'];
535 }
536 }
537
538 $showmode = isVisibleToUserType($type_user, $newTabMenu[$i], $listofmodulesforexternal);
539 if ($showmode == 1) {
540 // Define the class (top menu selected or not)
541 if (!empty($_SESSION['idmenu']) && $newTabMenu[$i]['rowid'] == $_SESSION['idmenu']) {
542 $classname = 'class="tmenusel"';
543 } elseif (!empty($_SESSION["mainmenu"]) && $newTabMenu[$i]['mainmenu'] == $_SESSION["mainmenu"]) {
544 $classname = 'class="tmenusel"';
545 } else {
546 $classname = 'class="tmenu"';
547 }
548 } elseif ($showmode == 2) {
549 $classname = 'class="tmenu"';
550 }
551
552 $menu->add(
553 $shorturl,
554 $newTabMenu[$i]['titre'],
555 0,
556 $showmode,
557 ($newTabMenu[$i]['target'] ? $newTabMenu[$i]['target'] : $atarget),
558 ($newTabMenu[$i]['mainmenu'] ? $newTabMenu[$i]['mainmenu'] : $newTabMenu[$i]['rowid']),
559 ($newTabMenu[$i]['leftmenu'] ? $newTabMenu[$i]['leftmenu'] : ''),
560 $newTabMenu[$i]['position'],
561 $id,
562 $idsel,
563 $classname,
564 $newTabMenu[$i]['prefix']
565 );
566 }
567
568 // Sort the top menu on position
569 $menu->liste = dol_sort_array($menu->liste, 'position');
570
571 // If noout is on (for jmobile div menu for example)
572 if ($noout) {
573 return 0;
574 }
575
576 // Output menu entries
577
579
580 // Show logo company
581 if (!getDolGlobalString('MAIN_MENU_INVERT') && getDolGlobalString('MAIN_SHOW_LOGO') && !getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
582 //$mysoc->logo_mini=(empty($conf->global->MAIN_INFO_SOCIETE_LOGO_MINI)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO_MINI);
583 $mysoc->logo_squarred_mini = (!getDolGlobalString('MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI') ? '' : $conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI);
584
585 $logoContainerAdditionalClass = 'backgroundforcompanylogo';
586 if (getDolGlobalString('MAIN_INFO_SOCIETE_LOGO_NO_BACKGROUND')) {
587 $logoContainerAdditionalClass = '';
588 }
589
590 if (!empty($mysoc->logo_squarred_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_squarred_mini)) {
591 $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_squarred_mini);
592 /*} elseif (!empty($mysoc->logo_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini))
593 {
594 $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_mini);
595 }*/
596 } else {
597 $urllogo = DOL_URL_ROOT.'/theme/dolibarr_512x512_white.png';
598 $logoContainerAdditionalClass = '';
599 }
600 $title = $langs->trans("GoIntoSetupToChangeLogo");
601
602 print "\n".'<!-- Show logo on menu -->'."\n";
603 print_start_menu_entry('companylogo', 'class="tmenu tmenucompanylogo nohover"', 1);
604
605 print '<div class="center '.$logoContainerAdditionalClass.' menulogocontainer"><img class="mycompany" title="'.dol_escape_htmltag($title).'" alt="" src="'.$urllogo.'" style="max-width: 100px"></div>'."\n";
606
608 }
609
610 //var_dump($menu->liste);
611 foreach ($menu->liste as $menuval) {
612 print_start_menu_entry($menuval['idsel'], $menuval['classname'], $menuval['enabled']);
613 // @phan-ignore-next-line
614 // @phpstan-ignore-next-line
615 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);
616 print_end_menu_entry($menuval['enabled']);
617 }
618
619 if (!getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
620 $showmode = 1;
621 print_start_menu_entry('', 'class="tmenuend"', $showmode);
622 print_end_menu_entry($showmode);
624 }
625
626 return 0;
627}
628
629
636{
637 print '<div class="tmenudiv">';
638 print '<ul role="navigation" class="tmenu"'.(getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER') ? ' title="Top menu"' : '').'>';
639}
640
649function print_start_menu_entry($idsel, $classname, $showmode)
650{
651 if ($showmode) {
652 print '<li '.$classname.' id="mainmenutd_'.$idsel.'">';
653 //print '<div class="tmenuleft tmenusep"></div>';
654 print '<div class="tmenucenter">';
655 }
656}
657
671function print_text_menu_entry($text, $showmode, $url, $id, $idsel, $classname, $atarget, $menuval = array())
672{
673 global $langs;
674
675 $classnameimg = str_replace('class="', 'class="tmenuimage ', $classname);
676 $classnametxt = str_replace('class="', 'class="tmenulabel ', $classname);
677
678 //$conf->global->THEME_TOPMENU_DISABLE_IMAGE=1;
679 if ($showmode == 1) {
680 print '<a '.$classnameimg.' tabindex="-1" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').' title="'.dol_escape_htmltag($text).'">';
681 print '<div class="'.$id.' '.$idsel.' topmenuimage">';
682 $reg = array();
683 if (!empty($menuval['prefix']) && strpos($menuval['prefix'], '<span') === 0) {
684 print $menuval['prefix'];
685 } elseif (!empty($menuval['prefix']) && preg_match('/^(fa[rsb]? )?fa-/', $menuval['prefix'], $reg)) {
686 print '<span class="'.$id.' '.(empty($reg[1]) ? 'fa ' : '').$menuval['prefix'].'" id="mainmenuspan_'.$idsel.'"></span>';
687 } else {
688 print '<span class="'.$id.' tmenuimageforpng" id="mainmenuspan_'.$idsel.'"></span>';
689 }
690 print '</div>';
691 print '</a>';
692 if (!getDolGlobalString('THEME_TOPMENU_DISABLE_TEXT')) {
693 print '<a '.$classnametxt.' id="mainmenua_'.$idsel.'" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').' title="'.dol_escape_htmltag($text).'">';
694 print '<span class="mainmenuaspan">';
695 print $text;
696 print '</span>';
697 print '</a>';
698 }
699 } elseif ($showmode == 2) {
700 print '<div '.$classnameimg.' title="'.dol_escape_htmltag($text.' - '.$langs->trans("NotAllowed")).'">';
701 print '<div class="'.$id.' '.$idsel.' topmenuimage tmenudisabled">';
702 if (!empty($menuval['prefix']) && strpos($menuval['prefix'], '<span') === 0) {
703 print $menuval['prefix'];
704 } else {
705 print '<span class="'.$id.' tmenuimageforpng tmenudisabled" id="mainmenuspan_'.$idsel.'"></span>';
706 }
707 print '</div>';
708 print '</div>';
709 if (!getDolGlobalString('THEME_TOPMENU_DISABLE_TEXT')) {
710 print '<span '.$classnametxt.' id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($text.' - '.$langs->trans("NotAllowed")).'">';
711 print '<span class="mainmenuaspan tmenudisabled">';
712 print $text;
713 print '</span>';
714 print '</span>';
715 }
716 }
717}
718
725function print_end_menu_entry($showmode)
726{
727 if ($showmode) {
728 print '</div></li>';
729 }
730 print "\n";
731}
732
739{
740 print '</ul>';
741 print '</div>';
742 print "\n";
743}
744
761function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabMenu, &$menu, $noout = 0, $forcemainmenu = '', $forceleftmenu = '', $moredata = null, $type_user = 0)
762{
763 global $user, $conf, $langs, $hookmanager;
764
765 //var_dump($tabMenu);
766
767 $newmenu = $menu;
768
769 $mainmenu = ($forcemainmenu ? $forcemainmenu : $_SESSION["mainmenu"] ?? '');
770 $leftmenu = ($forceleftmenu ? '' : (empty($_SESSION["leftmenu"]) ? 'none' : $_SESSION["leftmenu"] ?? ''));
771
772 if (empty($mainmenu)) {
773 $mainmenu = 'home';
774 }
775
776 global $usemenuhider;
777 $usemenuhider = 0;
778
779 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
780 print "\n";
781 print "<!-- Begin SearchForm -->\n";
782 print '<div id="blockvmenusearch" class="blockvmenusearch">'."\n";
783 print $moredata['searchform'];
784 print '</div>'."\n";
785 print "<!-- End SearchForm -->\n";
786 }
787
788 if (is_array($moredata) && !empty($moredata['bookmarks'])) {
789 print "\n";
790 print "<!-- Begin Bookmarks -->\n";
791 print '<div id="blockvmenubookmarks" class="blockvmenubookmarks">'."\n";
792 print $moredata['bookmarks'];
793 print '</div>'."\n";
794 print "<!-- End Bookmarks -->\n";
795 }
796
797 $substitarray = getCommonSubstitutionArray($langs, 0, null, null);
798
799 $listofmodulesforexternal = explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL'));
800
805 if ($mainmenu) { // If this is empty, loading hard coded menu and loading personalised menu will fail
806 /*
807 * Menu HOME
808 */
809 if ($mainmenu == 'home') {
810 get_left_menu_home($mainmenu, $newmenu, $usemenuhider, $leftmenu, $type_user);
811 }
812
813 /*
814 * Menu THIRDPARTIES
815 */
816 if ($mainmenu == 'companies') {
817 get_left_menu_thridparties($mainmenu, $newmenu, $usemenuhider, $leftmenu, $type_user);
818 }
819
820 /*
821 * Menu COMMERCIAL (propal, commande, supplier_proposal, supplier_order, contrat, ficheinter)
822 */
823 if ($mainmenu == 'commercial') {
824 get_left_menu_commercial($mainmenu, $newmenu, $usemenuhider, $leftmenu, $type_user);
825 }
826
827 /*
828 * Menu COMPTA-FINANCIAL
829 */
830 if ($mainmenu == 'billing') {
831 get_left_menu_billing($mainmenu, $newmenu, $usemenuhider, $leftmenu, $type_user);
832 }
833
834 /*
835 * Menu COMPTA-FINANCIAL
836 */
837 if ($mainmenu == 'accountancy') {
838 get_left_menu_accountancy($mainmenu, $newmenu, $usemenuhider, $leftmenu, $type_user);
839 }
840
841 /*
842 * Menu BANK
843 */
844 if ($mainmenu == 'bank') {
845 get_left_menu_bank($mainmenu, $newmenu, $usemenuhider, $leftmenu, $type_user);
846 }
847
848 /*
849 * Menu PRODUCTS-SERVICES
850 */
851 if ($mainmenu == 'products') {
852 get_left_menu_products($mainmenu, $newmenu, $usemenuhider, $leftmenu, $type_user);
853 }
854
855 /*
856 * Menu PRODUCTS-SERVICES MRP - GPAO
857 */
858 if ($mainmenu == 'mrp') {
859 get_left_menu_mrp($mainmenu, $newmenu, $usemenuhider, $leftmenu, $type_user);
860 }
861
862 /*
863 * Menu PROJECTS
864 */
865 if ($mainmenu == 'project') {
866 get_left_menu_projects($mainmenu, $newmenu, $usemenuhider, $leftmenu, $type_user);
867 }
868
869 /*
870 * Menu HRM
871 */
872 if ($mainmenu == 'hrm') {
873 get_left_menu_hrm($mainmenu, $newmenu, $usemenuhider, $leftmenu, $type_user);
874 }
875 /*
876 * Menu TOOLS
877 */
878 if ($mainmenu == 'tools') {
879 get_left_menu_tools($mainmenu, $newmenu, $usemenuhider, $leftmenu, $type_user);
880 }
881
882 /*
883 * Menu MEMBERS
884 */
885 if ($mainmenu == 'members') {
886 get_left_menu_members($mainmenu, $newmenu, $usemenuhider, $leftmenu, $type_user);
887 }
888
889 // Add personalized menus and modules menus
890 //var_dump($newmenu->liste); //
891 $menuArbo = new Menubase($db, 'eldy');
892 $newmenu = $menuArbo->menuLeftCharger($newmenu, $mainmenu, $leftmenu, (empty($user->socid) ? 0 : 1), 'eldy', $tabMenu);
893 //var_dump($newmenu->liste); //
894
895 if (isModEnabled('ftp') && $mainmenu == 'ftp') { // Entry for FTP
896 $MAXFTP = 20;
897 $i = 1;
898 while ($i <= $MAXFTP) {
899 $paramkey = 'FTP_NAME_'.$i;
900 //print $paramkey;
901 if (getDolGlobalString($paramkey)) {
902 $link = "/ftp/index.php?idmenu=".$_SESSION["idmenu"]."&numero_ftp=".$i;
903 $newmenu->add($link, dol_trunc($conf->global->$paramkey, 24));
904 }
905 $i++;
906 }
907 }
908 }
909
910 //var_dump($tabMenu);
911 //var_dump($newmenu->liste);
912
913 // Build final $menu_array = $menu_array_before +$newmenu->liste + $menu_array_after
914 //var_dump($menu_array_before);exit;
915 //var_dump($menu_array_after);exit;
916 $menu_array = $newmenu->liste;
917 if (is_array($menu_array_before)) {
918 $menu_array = array_merge($menu_array_before, $menu_array);
919 }
920 if (is_array($menu_array_after)) {
921 $menu_array = array_merge($menu_array, $menu_array_after);
922 }
923 //var_dump($menu_array);exit;
924 if (!is_array($menu_array)) {
925 return 0;
926 }
927
928 // Allow the $menu_array of the menu to be manipulated by modules
929 $parameters = array(
930 'mainmenu' => $mainmenu,
931 );
932 $hook_items = $menu_array;
933 $reshook = $hookmanager->executeHooks('menuLeftMenuItems', $parameters, $hook_items); // Note that $action and $object may have been modified by some hooks @phan-suppress-current-line PhanTypeMismatchArgument
934
935 if (is_numeric($reshook)) {
936 if ($reshook == 0 && !empty($hookmanager->resArray)) {
937 $menu_array[] = $hookmanager->resArray; // add
938 } elseif ($reshook == 1) {
939 $menu_array = $hookmanager->resArray; // replace
940 }
941 }
942
943 // Set a field positionfull to allow to sort tree entry without breaking the hierarchy.
944 $counter = 0;
945 $currentpositionlevel = 0;
946 $currentpositionpath = '';
947 foreach ($menu_array as $key => $val) {
948 $counter++;
949 //print 'key='.$key.' level='.$menu_array[$key]['level'].' currentpositionlevel='.$currentpositionlevel.' <br>'."\n";
950 if ($menu_array[$key]['level'] <= $currentpositionlevel) { // We found a break we are now on a lower level
951 $tmparray = explode('_', $currentpositionpath);
952 $currentpositionpath = '';
953 for ($i = 0; $i < $menu_array[$key]['level']; $i++) {
954 $currentpositionpath .= $tmparray[$i].'_';
955 }
956 $currentpositionpath .= $menu_array[$key]['position'].'.'.$counter;
957 $menu_array[$key]['positionfull'] = $currentpositionpath;
958 //print '$currentpositionpath='.$currentpositionpath.'<br>'."\n";
959 } else {
960 $currentpositionpath .= '_'.$menu_array[$key]['position'].'.'.$counter;
961 $menu_array[$key]['positionfull'] = $currentpositionpath;
962 //print '$currentpositionpath='.$currentpositionpath.'<br>'."\n";
963 }
964 $currentpositionlevel = $menu_array[$key]['level'];
965 }
966
967 //var_dump($menu_array);exit;
968 $menu_array = dol_sort_array($menu_array, 'positionfull', 'asc', 1, 0, 1);
969
970 // Force the typing at this point to get useful analysis below:
971 '@phan-var-force array<array{rowid:string,fk_menu:string,langs:string,enabled:int<0,2>,type:string,fk_mainmenu:string,fk_leftmenu:string,url:string,titre:string,perms:string,target:string,mainmenu:string,leftmenu:string,position:int,positionfull:int|string,showtopmenuinframe:int,level?:int,prefix:string}> $menu_array';
972
973
974 // Show menu
975 $invert = !getDolGlobalString('MAIN_MENU_INVERT') ? "" : "invert";
976 if (empty($noout)) {
977 $altok = 0;
978 $blockvmenuopened = false;
979 $lastlevel0 = '';
980 $num = count($menu_array);
981 foreach (array_keys($menu_array) as $i) { // Loop on each menu entry (got better static analysis)
982 $showmenu = true;
983 if (getDolGlobalString('MAIN_MENU_HIDE_UNAUTHORIZED') && empty($menu_array[$i]['enabled'])) {
984 $showmenu = false;
985 }
986
987 // Begin of new left menu block
988 if (empty($menu_array[$i]['level']) && $showmenu) {
989 $altok++;
990 $blockvmenuopened = true;
991 $lastopened = true;
992 for ($j = ($i + 1); $j < $num; $j++) {
993 if (empty($menu_array[$j]['level'])) {
994 $lastopened = false;
995 }
996 }
997 if ($altok % 2 == 0) {
998 print '<div class="blockvmenu blockvmenuimpair'.$invert.($lastopened ? ' blockvmenulast' : '').($altok == 1 ? ' blockvmenufirst' : '').'">'."\n";
999 } else {
1000 print '<div class="blockvmenu blockvmenupair'.$invert.($lastopened ? ' blockvmenulast' : '').($altok == 1 ? ' blockvmenufirst' : '').'">'."\n";
1001 }
1002 }
1003
1004 // Add tabulation
1005 $tabstring = '';
1006 $tabul = ($menu_array[$i]['level'] - 1);
1007 if ($tabul > 0) {
1008 for ($j = 0; $j < $tabul; $j++) {
1009 $tabstring .= '&nbsp;&nbsp;&nbsp;';
1010 }
1011 }
1012
1013 // $menu_array[$i]['url'] can be a relative url, a full external url. We try substitution
1014
1015 $menu_array[$i]['url'] = make_substitutions($menu_array[$i]['url'], $substitarray);
1016
1017 $url = $shorturl = $shorturlwithoutparam = $menu_array[$i]['url'];
1018 if (!preg_match("/^(http:\/\/|https:\/\/)/i", $menu_array[$i]['url'])) {
1019 $tmp = explode('?', $menu_array[$i]['url'], 2);
1020 $url = $shorturl = $tmp[0];
1021 $param = (isset($tmp[1]) ? $tmp[1] : ''); // params in url of the menu link
1022
1023 // Complete param to force leftmenu to '' to close open menu when we click on a link with no leftmenu defined.
1024 if ((!preg_match('/mainmenu/i', $param)) && (!preg_match('/leftmenu/i', $param)) && !empty($menu_array[$i]['mainmenu'])) {
1025 $param .= ($param ? '&' : '').'mainmenu='.$menu_array[$i]['mainmenu'].'&leftmenu=';
1026 }
1027 if ((!preg_match('/mainmenu/i', $param)) && (!preg_match('/leftmenu/i', $param)) && empty($menu_array[$i]['mainmenu'])) {
1028 $param .= ($param ? '&' : '').'leftmenu=';
1029 }
1030 //$url.="idmenu=".$menu_array[$i]['rowid']; // Already done by menuLoad
1031 $url = dol_buildpath($url, 1).($param ? '?'.$param : '');
1032 $shorturlwithoutparam = $shorturl;
1033 $shorturl .= ($param ? '?'.$param : '');
1034 }
1035
1036
1037 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'].' positionfull='.$menu_array[$i]['positionfull'].' -->'."\n";
1038
1039 // Menu level 0
1040 if ($menu_array[$i]['level'] == 0) {
1041 if ($menu_array[$i]['enabled']) { // Enabled so visible
1042 print '<div class="menu_titre">'.$tabstring;
1043 if ($shorturlwithoutparam) {
1044 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'].'"' : '').'>';
1045 } else {
1046 print '<span class="vmenu">';
1047 }
1048 if (!empty($menu_array[$i]['prefix'])) {
1049 $reg = array();
1050 if (preg_match('/^(fa[rsb]? )?fa-/', $menu_array[$i]['prefix'], $reg)) {
1051 print '<span class="'.(empty($reg[1]) ? 'fa ' : '').$menu_array[$i]['prefix'].' paddingright pictofixedwidth"></span>';
1052 } else {
1053 print $menu_array[$i]['prefix'];
1054 }
1055 }
1056 print $menu_array[$i]['titre'];
1057 if ($shorturlwithoutparam) {
1058 print '</a>';
1059 } else {
1060 print '</span>';
1061 }
1062 print '</div>'."\n";
1063 $lastlevel0 = 'enabled';
1064 } elseif ($showmenu) { // Not enabled but visible (so greyed)
1065 print '<div class="menu_titre">'.$tabstring;
1066 print '<span class="vmenudisabled" title="'.dolPrintHTMLForAttribute($menu_array[$i]['titre']).'">';
1067 if (!empty($menu_array[$i]['prefix'])) {
1068 print $menu_array[$i]['prefix'];
1069 }
1070 print $menu_array[$i]['titre'];
1071 print '</span>';
1072 print '</div>'."\n";
1073 $lastlevel0 = 'greyed';
1074 } else {
1075 $lastlevel0 = 'hidden';
1076 }
1077 if ($showmenu) {
1078 print '<div class="menu_top"></div>'."\n";
1079 }
1080 }
1081
1082 // Menu level > 0
1083 if ($menu_array[$i]['level'] > 0) {
1084 $cssmenu = '';
1085 if ($menu_array[$i]['url']) {
1086 $cssmenu = ' menu_contenu'.dol_string_nospecial(preg_replace('/\.php.*$/', '', $menu_array[$i]['url']));
1087 }
1088
1089 if ($menu_array[$i]['enabled'] && $lastlevel0 == 'enabled') {
1090 // Enabled so visible, except if parent was not enabled.
1091 print '<div class="menu_contenu'.$cssmenu.'">';
1092 print $tabstring;
1093 if ($shorturlwithoutparam) {
1094 print '<a class="vsmenu" title="'.dolPrintHTMLForAttribute($menu_array[$i]['titre']).'" href="'.$url.'"'.($menu_array[$i]['target'] ? ' target="'.$menu_array[$i]['target'].'"' : '').'>';
1095 } else {
1096 print '<span class="vsmenu" title="'.dolPrintHTMLForAttribute($menu_array[$i]['titre']).'">';
1097 }
1098 print $menu_array[$i]['titre'];
1099 if ($shorturlwithoutparam) {
1100 print '</a>';
1101 } else {
1102 print '</span>';
1103 }
1104 // If title is not pure text and contains a table, no carriage return added
1105 if (!strstr($menu_array[$i]['titre'], '<table')) {
1106 print '<br>';
1107 }
1108 print '</div>'."\n";
1109 } elseif ($showmenu && $lastlevel0 == 'enabled') {
1110 // Not enabled but visible (so greyed), except if parent was not enabled.
1111 print '<div class="menu_contenu'.$cssmenu.'">';
1112 print $tabstring;
1113 print '<span class="vsmenudisabled vsmenudisabledmargin" title="'.dolPrintHTMLForAttribute($menu_array[$i]['titre']).'">'.$menu_array[$i]['titre'].'</span><br>';
1114 print '</div>'."\n";
1115 }
1116 }
1117
1118 // If next is a new block or if there is nothing after
1119 if (empty($menu_array[$i + 1]['level'])) { // End menu block
1120 if ($showmenu) {
1121 print '<div class="menu_end"></div>'."\n";
1122 }
1123 if ($blockvmenuopened) {
1124 print '</div>'."\n";
1125 $blockvmenuopened = false;
1126 }
1127 }
1128 }
1129
1130 if ($altok) {
1131 print '<div class="blockvmenuend"></div>'; // End menu block
1132 }
1133 }
1134
1135 return count($menu_array);
1136}
1137
1138
1149function get_left_menu_home($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0)
1150{
1151 global $user, $conf, $langs;
1152
1153 if ($mainmenu == 'home') {
1154 $langs->load("users");
1155
1156 // Home - dashboard
1157 $landingpage = getDolUserString('MAIN_LANDING_PAGE', getDolGlobalString('MAIN_LANDING_PAGE'));
1158 if (!empty($landingpage)) {
1159 $landingpage = dol_buildpath($landingpage, 1);
1160 } else {
1161 $landingpage = '/index.php?mainmenu=home&leftmenu=home';
1162 }
1163 $newmenu->add($landingpage, $langs->trans("MyDashboard"), 0, 1, '', $mainmenu, 'home', 0, '', '', '', '<i class="fas fa-chart-bar fa-fw paddingright pictofixedwidth"></i>');
1164
1165 // Setup
1166 $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>');
1167
1168 if ($usemenuhider || empty($leftmenu) || $leftmenu == "setup") {
1169 // Define $nbmodulesnotautoenabled - TODO This code is at different places
1170 $nbmodulesnotautoenabled = count($conf->modules);
1171 $listofmodulesautoenabled = array('user', 'agenda', 'fckeditor', 'export', 'import');
1172 foreach ($listofmodulesautoenabled as $moduleautoenable) {
1173 if (in_array($moduleautoenable, $conf->modules)) {
1174 $nbmodulesnotautoenabled--;
1175 }
1176 }
1177
1178 // Load translation files required by the page
1179 $langs->loadLangs(array("admin", "help"));
1180 $warnpicto = '';
1181 if (!getDolGlobalString('MAIN_INFO_SOCIETE_NOM') || !getDolGlobalString('MAIN_INFO_SOCIETE_COUNTRY') || getDolGlobalString('MAIN_INFO_SOCIETE_SETUP_TODO_WARNING')) {
1182 $langs->load("errors");
1183 $warnpicto = img_warning($langs->trans("WarningMandatorySetupNotComplete"));
1184 }
1185 $newmenu->add("/admin/company.php?mainmenu=home", $langs->trans("MenuCompanySetup").$warnpicto, 1);
1186 $warnpicto = '';
1187 if ($nbmodulesnotautoenabled < getDolGlobalInt('MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING', 1)) { // If only minimal initial modules enabled)
1188 $langs->load("errors");
1189 $warnpicto = img_warning($langs->trans("WarningMandatorySetupNotComplete"));
1190 }
1191 $newmenu->add("/admin/modules.php?mainmenu=home", $langs->trans("Modules").$warnpicto, 1);
1192 $newmenu->add("/admin/ihm.php?mainmenu=home", $langs->trans("GUISetup"), 1);
1193 $newmenu->add("/admin/menus.php?mainmenu=home", $langs->trans("Menus"), 1);
1194
1195 $newmenu->add("/admin/translation.php?mainmenu=home", $langs->trans("Translation"), 1);
1196 $newmenu->add("/admin/defaultvalues.php?mainmenu=home", $langs->trans("DefaultValues"), 1);
1197 $newmenu->add("/admin/boxes.php?mainmenu=home", $langs->trans("Boxes"), 1);
1198 $newmenu->add("/admin/delais.php?mainmenu=home", $langs->trans("MenuWarnings"), 1);
1199 $newmenu->add("/admin/security_other.php?mainmenu=home", $langs->trans("Security"), 1);
1200 $newmenu->add("/admin/limits.php?mainmenu=home", $langs->trans("MenuLimits"), 1);
1201 $newmenu->add("/admin/pdf.php?mainmenu=home", $langs->trans("PDF"), 1);
1202
1203 $warnpicto = '';
1204 /* No warning into menu entry, the message in Email setup page is enough
1205 A warning will be important if a DMARC record exists and SPF is not aligned.
1206 if (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail' && !getDolGlobalString('MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP')) {
1207 $langs->load("errors");
1208 $warnpicto = img_warning($langs->trans("WarningPHPMailD"));
1209 }
1210 */
1211 if (getDolGlobalString('MAIN_MAIL_SENDMODE') && in_array(getDolGlobalString('MAIN_MAIL_SENDMODE'), array('smtps', 'swiftmail')) && !getDolGlobalString('MAIN_MAIL_SMTP_SERVER')) {
1212 $langs->load("errors");
1213 $warnpicto = img_warning($langs->trans("ErrorSetupOfEmailsNotComplete"));
1214 }
1215
1216 $newmenu->add("/admin/mails.php?mainmenu=home", $langs->trans("Emails").$warnpicto, 1);
1217 $newmenu->add("/admin/sms.php?mainmenu=home", $langs->trans("SMS"), 1);
1218 $newmenu->add("/admin/dict.php?mainmenu=home", $langs->trans("Dictionary"), 1);
1219 $newmenu->add("/admin/const.php?mainmenu=home", $langs->trans("OtherSetup"), 1);
1220 }
1221
1222 // System tools
1223 $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>');
1224 if ($usemenuhider || empty($leftmenu) || preg_match('/^admintools/', $leftmenu)) {
1225 // Load translation files required by the page
1226 $langs->loadLangs(array('admin', 'help'));
1227
1228 $newmenu->add('/admin/system/dolibarr.php?mainmenu=home&amp;leftmenu=admintools_info', $langs->trans('InfoDolibarr'), 1);
1229 if ($usemenuhider || empty($leftmenu) || $leftmenu == 'admintools_info') {
1230 $newmenu->add('/admin/system/modules.php?mainmenu=home&amp;leftmenu=admintools_info', $langs->trans('Modules'), 2);
1231 $newmenu->add('/admin/triggers.php?mainmenu=home&amp;leftmenu=admintools_info', $langs->trans('Triggers'), 2);
1232 $newmenu->add('/admin/system/filecheck.php?mainmenu=home&amp;leftmenu=admintools_info', $langs->trans('FileCheck'), 2);
1233 $newmenu->add('/admin/system/about.php?mainmenu=home&amp;leftmenu=admintools_info', $langs->trans('ExternalResources'), 2);
1234 }
1235 $newmenu->add('/admin/system/browser.php?mainmenu=home&amp;leftmenu=admintools', $langs->trans('InfoBrowser'), 1);
1236 $newmenu->add('/admin/system/os.php?mainmenu=home&amp;leftmenu=admintools', $langs->trans('InfoOS'), 1);
1237 $newmenu->add('/admin/system/web.php?mainmenu=home&amp;leftmenu=admintools', $langs->trans('InfoWebServer'), 1);
1238 $newmenu->add('/admin/system/phpinfo.php?mainmenu=home&amp;leftmenu=admintools', $langs->trans('InfoPHP'), 1);
1239 $newmenu->add('/admin/system/database.php?mainmenu=home&amp;leftmenu=admintools', $langs->trans('InfoDatabase'), 1);
1240 $newmenu->add("/admin/system/perf.php?mainmenu=home&amp;leftmenu=admintools", $langs->trans("InfoPerf"), 1);
1241 $newmenu->add("/admin/system/security.php?mainmenu=home&amp;leftmenu=admintools", $langs->trans("InfoSecurity"), 1);
1242 $newmenu->add("/admin/tools/listevents.php?mainmenu=home&amp;leftmenu=admintools", $langs->trans("Audit"), 1);
1243 $newmenu->add("/admin/tools/listsessions.php?mainmenu=home&amp;leftmenu=admintools", $langs->trans("Sessions"), 1);
1244 $newmenu->add("/admin/tools/dolibarr_export.php?mainmenu=home&amp;leftmenu=admintools", $langs->trans("Backup"), 1);
1245 $newmenu->add("/admin/tools/dolibarr_import.php?mainmenu=home&amp;leftmenu=admintools", $langs->trans("Restore"), 1);
1246 $newmenu->add("/admin/tools/update.php?mainmenu=home&amp;leftmenu=admintools", $langs->trans("MenuUpgrade"), 1);
1247 $newmenu->add("/admin/tools/purge.php?mainmenu=home&amp;leftmenu=admintools", $langs->trans("Purge"), 1);
1248
1249 /* Already into menu Tools
1250 if (isModEnabled('blockedlog')) {
1251 $langs->load("blockedlog");
1252 $newmenu->add("/blockedlog/admin/blockedlog_list.php?mainmenu=home&amp;leftmenu=admintools", $langs->trans("BrowseBlockedLog"), 1, $user->admin);
1253 }
1254 */
1255
1256 if (isModEnabled('product') || isModEnabled('service')) {
1257 $langs->load("products");
1258 $newmenu->add("/product/admin/product_tools.php?mainmenu=home&amp;leftmenu=admintools", $langs->trans("ProductVatMassChange"), 1, $user->admin);
1259 }
1260 }
1261
1262 $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"'));
1263 if ($user->hasRight('user', 'user', 'read')) {
1264 if ($usemenuhider || empty($leftmenu) || $leftmenu == "users") {
1265 $newmenu->add("", $langs->trans("Users"), 1, (int) ($user->hasRight('user', 'user', 'read') || $user->admin));
1266 $newmenu->add("/user/card.php?leftmenu=users&action=create", $langs->trans("NewUser"), 2, (int) (($user->hasRight("user", "user", "write") || $user->admin) && !(isModEnabled('multicompany') && !empty($user->entity) && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE'))), '', 'home');
1267 $newmenu->add("/user/list.php?leftmenu=users", $langs->trans("ListOfUsers"), 2, (int) ($user->hasRight('user', 'user', 'read') || $user->admin));
1268 $newmenu->add("/user/hierarchy.php?leftmenu=users", $langs->trans("HierarchicView"), 2, (int) ($user->hasRight('user', 'user', 'read') || $user->admin));
1269 if (isModEnabled('category') && getDolGlobalString('CATEGORY_EDIT_IN_MENU_NOT_IN_POPUP')) {
1270 $langs->load("categories");
1271 $newmenu->add("/categories/categorie_list.php?leftmenu=users&type=7", $langs->trans("UsersCategoriesShort"), 2, $user->hasRight('categorie', 'read'), '', $mainmenu, 'cat');
1272 }
1273 $newmenu->add("", $langs->trans("Groups"), 1, (int) (($user->hasRight('user', 'user', 'read') || $user->admin) && !(isModEnabled('multicompany') && !empty($user->entity) && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE'))));
1274 $newmenu->add("/user/group/card.php?leftmenu=users&action=create", $langs->trans("NewGroup"), 2, (int) (((getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? $user->hasRight("user", "group_advance", "write") : $user->hasRight("user", "user", "write")) || $user->admin) && !(isModEnabled('multicompany') && !empty($user->entity) && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE'))));
1275 $newmenu->add("/user/group/list.php?leftmenu=users", $langs->trans("ListOfGroups"), 2, (int) ((getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? $user->hasRight('user', 'group_advance', 'read') : $user->hasRight('user', 'user', 'read')) || $user->admin));
1276 }
1277 }
1278 }
1279}
1280
1291function get_left_menu_thridparties($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0)
1292{
1293 global $user, $conf, $langs;
1294
1295 if ($mainmenu == 'companies') {
1296 // Societes
1297 if (isModEnabled('societe')) {
1298 $langs->load("companies");
1299 $newmenu->add("/societe/index.php?leftmenu=thirdparties", $langs->trans("ThirdParty"), 0, $user->hasRight('societe', 'lire'), '', $mainmenu, 'thirdparties', 0, '', '', '', img_picto('', 'company', 'class="paddingright pictofixedwidth"'));
1300
1301 if ($user->hasRight('societe', 'creer')) {
1302 $newmenu->add("/societe/card.php?action=create", $langs->trans("MenuNewThirdParty"), 1);
1303 if (!$conf->use_javascript_ajax) {
1304 $newmenu->add("/societe/card.php?action=create&amp;private=1", $langs->trans("MenuNewPrivateIndividual"), 1);
1305 }
1306 }
1307 }
1308
1309 $newmenu->add("/societe/list.php?leftmenu=thirdparties", $langs->trans("List"), 1, $user->hasRight('societe', 'lire'), '', $mainmenu, 'thirdparties_list', 2);
1310
1311 // Prospects
1312 if (isModEnabled('societe') && !getDolGlobalString('SOCIETE_DISABLE_PROSPECTS')) {
1313 $langs->load("commercial");
1314 $newmenu->add("/societe/list.php?type=p&amp;leftmenu=prospects", $langs->trans("Prospects"), 2, $user->hasRight('societe', 'lire'), '', $mainmenu, 'prospects', 5);
1315
1316 $newmenu->add("/societe/card.php?leftmenu=prospects&action=create&type=p", $langs->trans("MenuNewProspect"), 3, $user->hasRight('societe', 'creer'));
1317 }
1318
1319 // Customers/Prospects
1320 if (isModEnabled('societe') && !getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS')) {
1321 $langs->load("commercial");
1322 $newmenu->add("/societe/list.php?type=c&amp;leftmenu=customers", $langs->trans("Customers"), 2, $user->hasRight('societe', 'lire'), '', $mainmenu, 'customers', 10);
1323
1324 $newmenu->add("/societe/card.php?leftmenu=customers&action=create&type=c", $langs->trans("MenuNewCustomer"), 3, $user->hasRight('societe', 'creer'));
1325 }
1326
1327 // Suppliers
1328 if (isModEnabled('societe') && (isModEnabled('supplier_order') || isModEnabled('supplier_invoice') || isModEnabled('supplier_proposal'))) {
1329 $langs->load("suppliers");
1330 $newmenu->add("/societe/list.php?type=f&amp;leftmenu=suppliers", $langs->trans("Suppliers"), 2, (int) ($user->hasRight('fournisseur', 'lire') || $user->hasRight('supplier_order', 'lire') || $user->hasRight('supplier_invoice', 'lire') || $user->hasRight('supplier_proposal', 'lire')), '', $mainmenu, 'suppliers', 15);
1331
1332 $newmenu->add("/societe/card.php?leftmenu=suppliers&action=create&type=f", $langs->trans("MenuNewSupplier"), 3, (int) ($user->hasRight('societe', 'creer') && ($user->hasRight('fournisseur', 'lire') || $user->hasRight('supplier_order', 'lire') || $user->hasRight('supplier_invoice', 'lire') || $user->hasRight('supplier_proposal', 'lire'))));
1333 }
1334
1335 // Categories
1336 if (isModEnabled('category')) {
1337 $langs->load("categories");
1338 if (!getDolGlobalString('SOCIETE_DISABLE_PROSPECTS') || !getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS')) {
1339 // Categories prospects/customers
1340 $menutoshow = $langs->trans("CustomersProspectsCategoriesShort");
1341 if (getDolGlobalString('SOCIETE_DISABLE_PROSPECTS')) {
1342 $menutoshow = $langs->trans("CustomersCategoriesShort");
1343 }
1344 if (getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS')) {
1345 $menutoshow = $langs->trans("ProspectsCategoriesShort");
1346 }
1347 if (getDolGlobalString('CATEGORY_EDIT_IN_MENU_NOT_IN_POPUP')) {
1348 $langs->load("categories");
1349 $newmenu->add("/categories/categorie_list.php?leftmenu=cat&type=2", $menutoshow, 1, $user->hasRight('categorie', 'lire'), '', $mainmenu, 'cat', 3);
1350 }
1351 }
1352 // Categories suppliers
1353 if (isModEnabled('supplier_proposal') || isModEnabled('supplier_order') || isModEnabled('supplier_invoice')) {
1354 if (getDolGlobalString('CATEGORY_EDIT_IN_MENU_NOT_IN_POPUP')) {
1355 $langs->load("categories");
1356 $newmenu->add("/categories/categorie_list.php?leftmenu=catfournish&type=1", $langs->trans("SuppliersCategoriesShort"), 1, $user->hasRight('categorie', 'lire'), '', $mainmenu, 'catsupplier', 4);
1357 }
1358 }
1359 }
1360
1361 // Contacts
1362 $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"'));
1363
1364 $newmenu->add("/contact/card.php?leftmenu=contacts&action=create", (getDolGlobalString('SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans("NewContact") : $langs->trans("NewContactAddress")), 1, $user->hasRight('societe', 'contact', 'creer'));
1365 $newmenu->add("/contact/list.php?leftmenu=contacts", $langs->trans("List"), 1, $user->hasRight('societe', 'contact', 'lire'));
1366 if (!getDolGlobalString('SOCIETE_DISABLE_PROSPECTS')) {
1367 $newmenu->add("/contact/list.php?leftmenu=contacts&type=p", $langs->trans("Prospects"), 2, $user->hasRight('societe', 'contact', 'lire'));
1368 }
1369 if (!getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS')) {
1370 $newmenu->add("/contact/list.php?leftmenu=contacts&type=c", $langs->trans("Customers"), 2, $user->hasRight('societe', 'contact', 'lire'));
1371 }
1372 if (isModEnabled('supplier_proposal') || isModEnabled('supplier_order') || isModEnabled('supplier_invoice')) {
1373 $newmenu->add("/contact/list.php?leftmenu=contacts&type=f", $langs->trans("Suppliers"), 2, $user->hasRight('fournisseur', 'lire'));
1374 }
1375 $newmenu->add("/contact/list.php?leftmenu=contacts&type=o", $langs->trans("ContactOthers"), 2, $user->hasRight('societe', 'contact', 'lire'));
1376 //$newmenu->add("/contact/list.php?userid=$user->id", $langs->trans("MyContacts"), 1, $user->hasRight('societe', 'contact', 'lire'));
1377
1378 // Categories
1379 if (isModEnabled('category') && getDolGlobalString('CATEGORY_EDIT_IN_MENU_NOT_IN_POPUP')) {
1380 $langs->load("categories");
1381 // Categories Contact
1382 $newmenu->add("/categories/categorie_list.php?leftmenu=catcontact&type=4", $langs->trans("ContactCategoriesShort"), 1, $user->hasRight('categorie', 'lire'), '', $mainmenu, 'cat');
1383 }
1384 }
1385}
1386
1397function get_left_menu_commercial($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0)
1398{
1399 global $user, $langs;
1400
1401 if ($mainmenu == 'commercial') {
1402 $langs->load("companies");
1403
1404 // Customer proposal
1405 if (isModEnabled('propal')) {
1406 $langs->load("propal");
1407 $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"'));
1408 $newmenu->add("/comm/propal/card.php?action=create&amp;leftmenu=propals", $langs->trans("NewPropal"), 1, $user->hasRight('propal', 'write'));
1409 $newmenu->add("/comm/propal/list.php?leftmenu=propals", $langs->trans("List"), 1, $user->hasRight('propal', 'read'));
1410 if ($usemenuhider || empty($leftmenu) || $leftmenu == "propals") {
1411 $newmenu->add("/comm/propal/list.php?leftmenu=propals&search_status=0", $langs->trans("PropalsDraft"), 2, $user->hasRight('propal', 'read'));
1412 $newmenu->add("/comm/propal/list.php?leftmenu=propals&search_status=1", $langs->trans("PropalsOpened"), 2, $user->hasRight('propal', 'read'));
1413 $newmenu->add("/comm/propal/list.php?leftmenu=propals&search_status=2", $langs->trans("PropalStatusSigned"), 2, $user->hasRight('propal', 'read'));
1414 $newmenu->add("/comm/propal/list.php?leftmenu=propals&search_status=3", $langs->trans("PropalStatusNotSigned"), 2, $user->hasRight('propal', 'read'));
1415 $newmenu->add("/comm/propal/list.php?leftmenu=propals&search_status=4", $langs->trans("PropalStatusBilled"), 2, $user->hasRight('propal', 'read'));
1416 //$newmenu->add("/comm/propal/list.php?leftmenu=propals&search_status=2,3,4", $langs->trans("PropalStatusClosedShort"), 2, $user->hasRight('propal', 'read'));
1417 }
1418 $newmenu->add("/comm/propal/stats/index.php?leftmenu=propals", $langs->trans("Statistics"), 1, $user->hasRight('propal', 'read'));
1419 }
1420
1421 // Customers orders
1422 if (isModEnabled('order')) {
1423 $langs->load("orders");
1424 $newmenu->add("/commande/index.php?leftmenu=orders", $langs->trans("CustomersOrders"), 0, $user->hasRight('commande', 'lire'), '', $mainmenu, 'orders', 200, '', '', '', img_picto('', 'order', 'class="paddingright pictofixedwidth"'));
1425 $newmenu->add("/commande/card.php?action=create&amp;leftmenu=orders", $langs->trans("NewOrder"), 1, $user->hasRight('commande', 'creer'));
1426 $newmenu->add("/commande/list.php?leftmenu=orders", $langs->trans("List"), 1, $user->hasRight('commande', 'lire'));
1427 if ($usemenuhider || empty($leftmenu) || $leftmenu == "orders") {
1428 $newmenu->add("/commande/list.php?leftmenu=orders&search_status=0", $langs->trans("StatusOrderDraftShort"), 2, $user->hasRight('commande', 'lire'));
1429 $newmenu->add("/commande/list.php?leftmenu=orders&search_status=1", $langs->trans("StatusOrderValidated"), 2, $user->hasRight('commande', 'lire'));
1430 if (isModEnabled('shipping')) {
1431 $newmenu->add("/commande/list.php?leftmenu=orders&search_status=2", $langs->trans("StatusOrderSentShort"), 2, $user->hasRight('commande', 'lire'));
1432 }
1433 $newmenu->add("/commande/list.php?leftmenu=orders&search_status=3", $langs->trans("StatusOrderDelivered"), 2, $user->hasRight('commande', 'lire'));
1434 //$newmenu->add("/commande/list.php?leftmenu=orders&search_status=4", $langs->trans("StatusOrderProcessed"), 2, $user->hasRight('commande', 'lire'));
1435 $newmenu->add("/commande/list.php?leftmenu=orders&search_status=-1", $langs->trans("StatusOrderCanceledShort"), 2, $user->hasRight('commande', 'lire'));
1436 }
1437 if (empty($user->socid)) {
1438 $newmenu->add("/commande/list_det.php?leftmenu=orders", $langs->trans("ListOrderLigne"), 1, $user->hasRight('commande', 'lire'));
1439 }
1440 if (getDolGlobalInt('MAIN_NEED_EXPORT_PERMISSION_TO_READ_STATISTICS')) {
1441 $newmenu->add("/commande/stats/index.php?leftmenu=orders", $langs->trans("Statistics"), 1, $user->hasRight('commande', 'commande', 'export'));
1442 } else {
1443 $newmenu->add("/commande/stats/index.php?leftmenu=orders", $langs->trans("Statistics"), 1, $user->hasRight('commande', 'lire'));
1444 }
1445
1446 // Categories
1447 if (isModEnabled('category') && getDolGlobalString('CATEGORY_EDIT_IN_MENU_NOT_IN_POPUP')) {
1448 $langs->load("categories");
1449 $newmenu->add("/categories/categorie_list.php?leftmenu=cat&type=16", $langs->trans("Categories"), 1, $user->hasRight('categorie', 'lire'), '', $mainmenu, 'cat');
1450 }
1451 }
1452
1453 // Supplier proposal
1454 if (isModEnabled('supplier_proposal')) {
1455 $langs->load("supplier_proposal");
1456 $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"'));
1457 $newmenu->add("/supplier_proposal/card.php?action=create&amp;leftmenu=supplier_proposals", $langs->trans("SupplierProposalNew"), 1, $user->hasRight('supplier_proposal', 'creer'));
1458 $newmenu->add("/supplier_proposal/list.php?leftmenu=supplier_proposals", $langs->trans("List"), 1, $user->hasRight('supplier_proposal', 'lire'));
1459 $newmenu->add("/comm/propal/stats/index.php?leftmenu=supplier_proposals&amp;mode=supplier", $langs->trans("Statistics"), 1, $user->hasRight('supplier_proposal', 'lire'));
1460 }
1461
1462 // Suppliers orders
1463 if (isModEnabled('supplier_order')) {
1464 $langs->load("orders");
1465 $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"'));
1466 $newmenu->add("/fourn/commande/card.php?action=create&amp;leftmenu=orders_suppliers", $langs->trans("NewSupplierOrderShort"), 1, $user->hasRight('fournisseur', 'commande', 'creer'));
1467 $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers", $langs->trans("List"), 1, $user->hasRight('fournisseur', 'commande', 'lire'));
1468
1469 if ($usemenuhider || empty($leftmenu) || $leftmenu == "orders_suppliers") {
1470 $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=0", $langs->trans("StatusSupplierOrderDraftShort"), 2, $user->hasRight('fournisseur', 'commande', 'lire'));
1471 if (!getDolGlobalString('SUPPLIER_ORDER_HIDE_VALIDATED')) {
1472 $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=1", $langs->trans("StatusSupplierOrderValidated"), 2, $user->hasRight('fournisseur', 'commande', 'lire'));
1473 }
1474 $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=2", $langs->trans("StatusSupplierOrderApprovedShort"), 2, $user->hasRight('fournisseur', 'commande', 'lire'));
1475 $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=3", $langs->trans("StatusSupplierOrderOnProcessShort"), 2, $user->hasRight('fournisseur', 'commande', 'lire'));
1476 $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=4", $langs->trans("StatusSupplierOrderReceivedPartiallyShort"), 2, $user->hasRight('fournisseur', 'commande', 'lire'));
1477 $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=5", $langs->trans("StatusSupplierOrderReceivedAll"), 2, $user->hasRight('fournisseur', 'commande', 'lire'));
1478 $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=6,7", $langs->trans("StatusSupplierOrderCanceled"), 2, $user->hasRight('fournisseur', 'commande', 'lire'));
1479 $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=9", $langs->trans("StatusSupplierOrderRefused"), 2, $user->hasRight('fournisseur', 'commande', 'lire'));
1480 }
1481 // 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'));
1482
1483 if (getDolGlobalInt('MAIN_NEED_EXPORT_PERMISSION_TO_READ_STATISTICS')) {
1484 $newmenu->add("/commande/stats/index.php?leftmenu=orders_suppliers&amp;mode=supplier", $langs->trans("Statistics"), 1, $user->hasRight('fournisseur', 'commande', 'export'));
1485 } else {
1486 $newmenu->add("/commande/stats/index.php?leftmenu=orders_suppliers&amp;mode=supplier", $langs->trans("Statistics"), 1, $user->hasRight('fournisseur', 'commande', 'lire'));
1487 }
1488
1489 // Categories
1490 if (isModEnabled('category') && getDolGlobalString('CATEGORY_EDIT_IN_MENU_NOT_IN_POPUP')) {
1491 $langs->load("categories");
1492 $newmenu->add("/categories/categorie_list.php?leftmenu=cat&type=20", $langs->trans("Categories"), 1, $user->hasRight('categorie', 'lire'), '', $mainmenu, 'cat');
1493 }
1494 }
1495
1496 // Contrat
1497 if (isModEnabled('contract')) {
1498 $langs->load("contracts");
1499 $newmenu->add("/contrat/index.php?leftmenu=contracts", $langs->trans("ContractsSubscriptions"), 0, $user->hasRight('contrat', 'lire'), '', $mainmenu, 'contracts', 2000, '', '', '', img_picto('', 'contract', 'class="paddingright pictofixedwidth"'));
1500 $newmenu->add("/contrat/card.php?action=create&amp;leftmenu=contracts", $langs->trans("NewContractSubscription"), 1, $user->hasRight('contrat', 'creer'));
1501 $newmenu->add("/contrat/list.php?leftmenu=contracts", $langs->trans("List"), 1, $user->hasRight('contrat', 'lire'));
1502 $newmenu->add("/contrat/services_list.php?leftmenu=contracts", $langs->trans("MenuServices"), 1, $user->hasRight('contrat', 'lire'));
1503 if ($usemenuhider || empty($leftmenu) || $leftmenu == "contracts") {
1504 $newmenu->add("/contrat/services_list.php?leftmenu=contracts&amp;search_status=0", $langs->trans("MenuInactiveServices"), 2, $user->hasRight('contrat', 'lire'));
1505 $newmenu->add("/contrat/services_list.php?leftmenu=contracts&amp;search_status=4", $langs->trans("MenuRunningServices"), 2, $user->hasRight('contrat', 'lire'));
1506 $newmenu->add("/contrat/services_list.php?leftmenu=contracts&amp;search_status=4%26filter=expired", $langs->trans("MenuExpiredServices"), 2, $user->hasRight('contrat', 'lire'));
1507 $newmenu->add("/contrat/services_list.php?leftmenu=contracts&amp;search_status=5", $langs->trans("MenuClosedServices"), 2, $user->hasRight('contrat', 'lire'));
1508 }
1509 }
1510
1511 // Interventions
1512 if (isModEnabled('intervention')) {
1513 $langs->load("interventions");
1514 $newmenu->add("/fichinter/index.php?leftmenu=ficheinter", $langs->trans("Interventions"), 0, $user->hasRight('ficheinter', 'lire'), '', $mainmenu, 'ficheinter', 2200, '', '', '', img_picto('', 'intervention', 'class="paddingright pictofixedwidth"'));
1515 $newmenu->add("/fichinter/card.php?action=create&amp;leftmenu=ficheinter", $langs->trans("NewIntervention"), 1, $user->hasRight('ficheinter', 'creer'), '', '', '', 201);
1516 $newmenu->add("/fichinter/list.php?leftmenu=ficheinter", $langs->trans("List"), 1, $user->hasRight('ficheinter', 'lire'), '', '', '', 202);
1517 if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
1518 $newmenu->add("/fichinter/card-rec.php?leftmenu=ficheinter", $langs->trans("ListOfTemplates"), 1, $user->hasRight('ficheinter', 'lire'), '', '', '', 203);
1519 }
1520 $newmenu->add("/fichinter/stats/index.php?leftmenu=ficheinter", $langs->trans("Statistics"), 1, $user->hasRight('ficheinter', 'lire'), '', '', '', 204);
1521 }
1522 }
1523}
1524
1535function get_left_menu_billing($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0)
1536{
1537 global $user, $langs;
1538
1539 if ($mainmenu == 'billing') {
1540 $langs->load("companies");
1541
1542 // Customers invoices
1543 if (isModEnabled('invoice')) {
1544 $langs->load("bills");
1545 $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"'));
1546 $newmenu->add("/compta/facture/card.php?action=create", $langs->trans("NewBill"), 1, $user->hasRight('facture', 'creer'));
1547 $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills", $langs->trans("List"), 1, $user->hasRight('facture', 'lire'), '', $mainmenu, 'customers_bills_list');
1548
1549 if ($usemenuhider || empty($leftmenu) || preg_match('/customers_bills(|_draft|_notpaid|_paid|_canceled)$/', $leftmenu)) {
1550 $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills_draft&amp;search_status=0", $langs->trans("BillShortStatusDraft"), 2, $user->hasRight('facture', 'lire'));
1551 $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills_notpaid&amp;search_status=1", $langs->trans("BillShortStatusNotPaid"), 2, $user->hasRight('facture', 'lire'));
1552 $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills_paid&amp;search_status=2", $langs->trans("BillShortStatusPaid"), 2, $user->hasRight('facture', 'lire'));
1553 $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills_canceled&amp;search_status=3", $langs->trans("BillShortStatusCanceled"), 2, $user->hasRight('facture', 'lire'));
1554 }
1555 $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.
1556
1557 $newmenu->add("/compta/paiement/list.php?leftmenu=customers_bills_payment", $langs->trans("Payments"), 1, $user->hasRight('facture', 'lire'), '', $mainmenu, 'customers_bills_payment');
1558
1559 if (getDolGlobalString('BILL_ADD_PAYMENT_VALIDATION') && preg_match('/customers_bills_payment/', $leftmenu)) {
1560 $newmenu->add("/compta/paiement/tovalidate.php?leftmenu=customers_bills_payment_tovalid", $langs->trans("MenuToValid"), 2, $user->hasRight('facture', 'lire'), '', $mainmenu, 'customers_bills_payment_tovalid');
1561 }
1562 if ($usemenuhider || empty($leftmenu) || preg_match('/customers_bills_payment/', $leftmenu)) {
1563 $newmenu->add("/compta/paiement/rapport.php?leftmenu=customers_bills_payment_report", $langs->trans("Reportings"), 2, $user->hasRight('facture', 'lire'), '', $mainmenu, 'customers_bills_payment_report');
1564 }
1565
1566 $newmenu->add("/compta/facture/stats/index.php?leftmenu=customers_bills_stats", $langs->trans("Statistics"), 1, $user->hasRight('facture', 'lire'), '', $mainmenu, 'customers_bills_stats');
1567
1568 // Categories
1569 if (isModEnabled('category') && getDolGlobalString('CATEGORY_EDIT_IN_MENU_NOT_IN_POPUP')) {
1570 $langs->load("categories");
1571 $newmenu->add("/categories/categorie_list.php?leftmenu=cat&type=17", $langs->trans("Categories"), 1, $user->rights->categorie->lire, '', $mainmenu, 'cat');
1572 }
1573 }
1574
1575 // Suppliers invoices
1576 if (isModEnabled('societe') && isModEnabled('supplier_invoice') && !getDolGlobalString('SUPPLIER_INVOICE_MENU_DISABLED')) {
1577 $langs->load("bills");
1578 $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"'));
1579 $newmenu->add("/fourn/facture/card.php?leftmenu=suppliers_bills&action=create", $langs->trans("NewBill"), 1, (int) ($user->hasRight('fournisseur', 'facture', 'creer') || $user->hasRight('supplier_invoice', 'creer')), '', $mainmenu, 'suppliers_bills_create');
1580 $newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills", $langs->trans("List"), 1, $user->hasRight('fournisseur', 'facture', 'lire'), '', $mainmenu, 'suppliers_bills_list');
1581
1582 if ($usemenuhider || empty($leftmenu) || preg_match('/suppliers_bills(|_draft|_notpaid|_paid|_canceled)$/', $leftmenu)) {
1583 $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');
1584 $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');
1585 $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');
1586 }
1587
1588 $newmenu->add("/fourn/facture/list-rec.php?leftmenu=supplierinvoicestemplate_list", $langs->trans("ListOfTemplates"), 1, $user->hasRight('fournisseur', 'facture', 'lire'), '', $mainmenu, 'supplierinvoicestemplate_list');
1589
1590 $newmenu->add("/fourn/paiement/list.php?leftmenu=suppliers_bills_payment", $langs->trans("Payments"), 1, $user->hasRight('fournisseur', 'facture', 'lire'), '', $mainmenu, 'suppliers_bills_payment');
1591
1592 if ($usemenuhider || empty($leftmenu) || preg_match('/suppliers_bills_payment/', $leftmenu)) {
1593 $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');
1594 }
1595
1596 $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');
1597
1598 // Categories
1599 if (isModEnabled('category') && getDolGlobalString('CATEGORY_EDIT_IN_MENU_NOT_IN_POPUP')) {
1600 $langs->load("categories");
1601 $newmenu->add("/categories/categorie_list.php?leftmenu=cat&type=21", $langs->trans("Categories"), 1, $user->rights->categorie->lire, '', $mainmenu, 'cat');
1602 }
1603 }
1604
1605 // Orders
1606 if (isModEnabled('order')) {
1607 $langs->load("orders");
1608 if (isModEnabled('invoice')) {
1609 $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"'));
1610 }
1611 //if ($usemenuhider || empty($leftmenu) || $leftmenu=="orders") $newmenu->add("/commande/", $langs->trans("StatusOrderToBill"), 1, $user->hasRight('commande', 'lire'));
1612 }
1613
1614 // Supplier Orders to bill
1615 if (isModEnabled('supplier_invoice')) {
1616 if (getDolGlobalString('SUPPLIER_MENU_ORDER_RECEIVED_INTO_INVOICE')) {
1617 $langs->load("supplier");
1618 $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"'));
1619 //if ($usemenuhider || empty($leftmenu) || $leftmenu=="orders") $newmenu->add("/commande/", $langs->trans("StatusOrderToBill"), 1, $user->hasRight('commande', 'lire'));
1620 }
1621 }
1622
1623
1624 // Donations
1625 if (isModEnabled('don')) {
1626 $langs->load("donations");
1627 $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"'));
1628 if ($usemenuhider || empty($leftmenu) || $leftmenu == "donations") {
1629 $newmenu->add("/don/card.php?leftmenu=donations&action=create", $langs->trans("NewDonation"), 1, $user->hasRight('don', 'creer'));
1630 $newmenu->add("/don/list.php?leftmenu=donations", $langs->trans("List"), 1, $user->hasRight('don', 'lire'));
1631 $newmenu->add("/don/paiement/list.php?leftmenu=donations", $langs->trans("Payments"), 1, $user->hasRight('don', 'lire'));
1632 $newmenu->add("/don/stats/index.php", $langs->trans("Statistics"), 1, $user->hasRight('don', 'lire'));
1633 }
1634 // if ($leftmenu=="donations") $newmenu->add("/don/stats/index.php",$langs->trans("Statistics"), 1, $user->hasRight('don', 'lire'));
1635 }
1636
1637 // Taxes and social contributions
1638 if (isModEnabled('tax')) {
1639 $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"'));
1640
1641 $newmenu->add("/compta/sociales/list.php?leftmenu=tax_social", $langs->trans("MenuSocialContributions"), 1, $user->hasRight('tax', 'charges', 'lire'));
1642 if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_social/i', $leftmenu)) {
1643 $newmenu->add("/compta/sociales/card.php?leftmenu=tax_social&action=create", $langs->trans("MenuNewSocialContribution"), 2, $user->hasRight('tax', 'charges', 'creer'));
1644 $newmenu->add("/compta/sociales/list.php?leftmenu=tax_social", $langs->trans("List"), 2, $user->hasRight('tax', 'charges', 'lire'));
1645 $newmenu->add("/compta/sociales/payments.php?leftmenu=tax_social&amp;mainmenu=billing", $langs->trans("Payments"), 2, $user->hasRight('tax', 'charges', 'lire'));
1646 }
1647 // VAT
1648 if (!getDolGlobalString('TAX_DISABLE_VAT_MENUS')) {
1649 global $mysoc;
1650
1651 $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');
1652 if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_vat/i', $leftmenu)) {
1653 $newmenu->add("/compta/tva/card.php?leftmenu=tax_vat&action=create", $langs->trans("New"), 2, $user->hasRight('tax', 'charges', 'creer'));
1654 $newmenu->add("/compta/tva/list.php?leftmenu=tax_vat", $langs->trans("List"), 2, $user->hasRight('tax', 'charges', 'lire'));
1655 $newmenu->add("/compta/tva/payments.php?mode=tvaonly&amp;leftmenu=tax_vat", $langs->trans("Payments"), 2, $user->hasRight('tax', 'charges', 'lire'));
1656 $newmenu->add("/compta/tva/index.php?leftmenu=tax_vat", $langs->trans("ReportByMonth"), 2, $user->hasRight('tax', 'charges', 'lire'));
1657 $newmenu->add("/compta/tva/clients.php?leftmenu=tax_vat", $langs->trans("ReportByThirdparties"), 2, $user->hasRight('tax', 'charges', 'lire'));
1658 $newmenu->add("/compta/tva/quadri_detail.php?leftmenu=tax_vat", $langs->trans("ReportByQuarter"), 2, $user->hasRight('tax', 'charges', 'lire'));
1659 }
1660
1661 //Local Taxes 1
1662 if ($mysoc->useLocalTax(1) && (isset($mysoc->localtax1_assuj) && $mysoc->localtax1_assuj == "1")) {
1663 $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'));
1664 if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_1_vat/i', $leftmenu)) {
1665 $newmenu->add("/compta/localtax/card.php?leftmenu=tax_1_vat&action=create&amp;localTaxType=1", $langs->trans("New"), 2, $user->hasRight('tax', 'charges', 'creer'));
1666 $newmenu->add("/compta/localtax/list.php?leftmenu=tax_1_vat&amp;localTaxType=1", $langs->trans("List"), 2, $user->hasRight('tax', 'charges', 'lire'));
1667 $newmenu->add("/compta/localtax/index.php?leftmenu=tax_1_vat&amp;localTaxType=1", $langs->trans("ReportByMonth"), 2, $user->hasRight('tax', 'charges', 'lire'));
1668 $newmenu->add("/compta/localtax/clients.php?leftmenu=tax_1_vat&amp;localTaxType=1", $langs->trans("ReportByThirdparties"), 2, $user->hasRight('tax', 'charges', 'lire'));
1669 $newmenu->add("/compta/localtax/quadri_detail.php?leftmenu=tax_1_vat&amp;localTaxType=1", $langs->trans("ReportByQuarter"), 2, $user->hasRight('tax', 'charges', 'lire'));
1670 }
1671 }
1672 //Local Taxes 2
1673 if ($mysoc->useLocalTax(2) && (isset($mysoc->localtax2_assuj) && $mysoc->localtax2_assuj == "1")) {
1674 $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'));
1675 if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_2_vat/i', $leftmenu)) {
1676 $newmenu->add("/compta/localtax/card.php?leftmenu=tax_2_vat&action=create&amp;localTaxType=2", $langs->trans("New"), 2, $user->hasRight('tax', 'charges', 'creer'));
1677 $newmenu->add("/compta/localtax/list.php?leftmenu=tax_2_vat&amp;localTaxType=2", $langs->trans("List"), 2, $user->hasRight('tax', 'charges', 'lire'));
1678 $newmenu->add("/compta/localtax/index.php?leftmenu=tax_2_vat&amp;localTaxType=2", $langs->trans("ReportByMonth"), 2, $user->hasRight('tax', 'charges', 'lire'));
1679 $newmenu->add("/compta/localtax/clients.php?leftmenu=tax_2_vat&amp;localTaxType=2", $langs->trans("ReportByThirdparties"), 2, $user->hasRight('tax', 'charges', 'lire'));
1680 $newmenu->add("/compta/localtax/quadri_detail.php?leftmenu=tax_2_vat&amp;localTaxType=2", $langs->trans("ReportByQuarter"), 2, $user->hasRight('tax', 'charges', 'lire'));
1681 }
1682 }
1683 }
1684 }
1685
1686 // Salaries
1687 if (isModEnabled('salaries')) {
1688 $langs->load("salaries");
1689 $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"'));
1690 if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_salary/i', $leftmenu)) {
1691 $newmenu->add("/salaries/card.php?leftmenu=tax_salary&action=create", $langs->trans("New"), 1, $user->hasRight('salaries', 'write'));
1692 $newmenu->add("/salaries/list.php?leftmenu=tax_salary", $langs->trans("List"), 1, $user->hasRight('salaries', 'read'));
1693 $newmenu->add("/salaries/payments.php?leftmenu=tax_salary", $langs->trans("Payments"), 1, $user->hasRight('salaries', 'read'));
1694 $newmenu->add("/salaries/stats/index.php?leftmenu=tax_salary", $langs->trans("Statistics"), 1, $user->hasRight('salaries', 'read'));
1695 }
1696 }
1697
1698 // Loan
1699 if (isModEnabled('loan')) {
1700 $langs->load("loan");
1701 $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"'));
1702 if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_loan/i', $leftmenu)) {
1703 $newmenu->add("/loan/card.php?leftmenu=tax_loan&action=create", $langs->trans("NewLoan"), 1, $user->hasRight('loan', 'write'));
1704 //$newmenu->add("/loan/payment/list.php?leftmenu=tax_loan",$langs->trans("Payments"),2,$user->hasRight('loan', 'read'));
1705 }
1706 }
1707
1708 // Various payment
1709 if (isModEnabled('bank') && !getDolGlobalString('BANK_USE_OLD_VARIOUS_PAYMENT')) {
1710 $langs->load("banks");
1711 $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"'));
1712 if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_various/i', $leftmenu)) {
1713 $newmenu->add("/compta/bank/various_payment/card.php?leftmenu=tax_various&action=create", $langs->trans("New"), 1, $user->hasRight('banque', 'modifier'));
1714 $newmenu->add("/compta/bank/various_payment/list.php?leftmenu=tax_various", $langs->trans("List"), 1, $user->hasRight('banque', 'lire'));
1715 }
1716 }
1717 }
1718}
1719
1730function get_left_menu_accountancy($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0)
1731{
1732 global $user, $conf, $langs;
1733 global $db;
1734
1735 if ($mainmenu == 'accountancy') {
1736 $langs->load("companies");
1737
1738 // Accounting (Double entries)
1739 if (isModEnabled('accounting')) {
1740 //$permtoshowmenu = (isModEnabled('accounting') || $user->hasRight('accounting', 'bind', 'write') || $user->hasRight('compta', 'resultat', 'lire'));
1741 //$newmenu->add("/accountancy/index.php?leftmenu=accountancy", $langs->trans("MenuAccountancy"), 0, $permtoshowmenu, '', $mainmenu, 'accountancy');
1742
1743 // Configuration
1744 $newmenu->add("/accountancy/admin/index.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Setup"), 0, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin', 1, '', '', '', img_picto('', 'technic', 'class="paddingright pictofixedwidth"'));
1745 if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/', $leftmenu)) {
1746 global $mysoc;
1747 $newmenu->add("/accountancy/admin/index.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("General"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_general', 10);
1748
1749 $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);
1750 $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);
1751 $newmenu->add("/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Chartofaccounts"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_chart', 41);
1752 $newmenu->add("/accountancy/admin/subaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("ChartOfSubaccounts"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_chart', 41);
1753
1754 // Fiscal year
1755 $newmenu->add("/accountancy/admin/fiscalyear.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("FiscalPeriod"), 1, $user->hasRight('accounting', 'fiscalyear', 'write'), '', $mainmenu, 'fiscalyear', 45);
1756
1757 $newmenu->add("/accountancy/admin/defaultaccounts.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuDefaultAccounts"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_default', 60);
1758 if (isModEnabled('bank')) {
1759 $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);
1760 }
1761 if (isModEnabled('invoice') || isModEnabled('supplier_invoice')) {
1762 $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);
1763 }
1764 if (isModEnabled('tax')) {
1765 $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);
1766 }
1767 if (isModEnabled('expensereport')) {
1768 $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);
1769 }
1770 $newmenu->add("/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuProductsAccounts"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_product', 110);
1771 $newmenu->add("/accountancy/admin/closure.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuClosureAccounts"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_closure', 120);
1772 if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
1773 $newmenu->add("/accountancy/admin/report_list.php?id=32&search_country_id=" . $mysoc->country_id . "&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingReport"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_report', 125);
1774 }
1775 $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', 130);
1776 }
1777
1778 // Transfer in accounting
1779 $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"'));
1780
1781 // Binding
1782 // $newmenu->add("", $langs->trans("Binding"), 0, $user->hasRight('accounting', 'bind', 'write'), '', $mainmenu, 'dispatch');
1783 if (isModEnabled('invoice') && !getDolGlobalString('ACCOUNTING_DISABLE_BINDING_ON_SALES')) {
1784 $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');
1785 if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_dispatch_customer/', $leftmenu)) {
1786 $newmenu->add("/accountancy/customer/list.php?mainmenu=accountancy&amp;leftmenu=accountancy_dispatch_customer", $langs->trans("ToBind"), 2, $user->hasRight('accounting', 'bind', 'write'));
1787 $newmenu->add("/accountancy/customer/lines.php?mainmenu=accountancy&amp;leftmenu=accountancy_dispatch_customer", $langs->trans("Binded"), 2, $user->hasRight('accounting', 'bind', 'write'));
1788 }
1789 }
1790 if (isModEnabled('supplier_invoice') && !getDolGlobalString('ACCOUNTING_DISABLE_BINDING_ON_PURCHASES')) {
1791 $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');
1792 if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_dispatch_supplier/', $leftmenu)) {
1793 $newmenu->add("/accountancy/supplier/list.php?mainmenu=accountancy&amp;leftmenu=accountancy_dispatch_supplier", $langs->trans("ToBind"), 2, $user->hasRight('accounting', 'bind', 'write'));
1794 $newmenu->add("/accountancy/supplier/lines.php?mainmenu=accountancy&amp;leftmenu=accountancy_dispatch_supplier", $langs->trans("Binded"), 2, $user->hasRight('accounting', 'bind', 'write'));
1795 }
1796 }
1797 if (isModEnabled('expensereport') && !getDolGlobalString('ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS')) {
1798 $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');
1799 if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_dispatch_expensereport/', $leftmenu)) {
1800 $newmenu->add("/accountancy/expensereport/list.php?mainmenu=accountancy&amp;leftmenu=accountancy_dispatch_expensereport", $langs->trans("ToBind"), 2, $user->hasRight('accounting', 'bind', 'write'));
1801 $newmenu->add("/accountancy/expensereport/lines.php?mainmenu=accountancy&amp;leftmenu=accountancy_dispatch_expensereport", $langs->trans("Binded"), 2, $user->hasRight('accounting', 'bind', 'write'));
1802 }
1803 }
1804
1805 // Journals
1806 if (isModEnabled('accounting') && $user->hasRight('accounting', 'comptarapport', 'lire') && $mainmenu == 'accountancy') {
1807 $newmenu->add('', $langs->trans("RegistrationInAccounting"), 1, $user->hasRight('accounting', 'comptarapport', 'lire'), '', $mainmenu, 'accountancy_journal');
1808
1809 // Multi journal
1810 $sql = "SELECT rowid, code, label, nature";
1811 $sql .= " FROM ".MAIN_DB_PREFIX."accounting_journal";
1812 $sql .= " WHERE entity = ".((int) $conf->entity);
1813 if (getDolGlobalString('ACCOUNTING_MODE') == 'RECETTES-DEPENSES') {
1814 $sql .= " AND nature = 4"; // only bank journal when using treasury accounting mode
1815 }
1816 $sql .= " AND active = 1";
1817 $sql .= " ORDER BY nature ASC, label DESC";
1818
1819 $resql = $db->query($sql);
1820 if ($resql) {
1821 $numr = $db->num_rows($resql);
1822 $i = 0;
1823
1824 if ($numr > 0) {
1825 while ($i < $numr) {
1826 $objp = $db->fetch_object($resql);
1827
1828 $nature = '';
1829
1830 // Must match array $sourceList defined into journals_list.php
1831 if ($objp->nature == 2 && isModEnabled('invoice') && !getDolGlobalString('ACCOUNTING_DISABLE_BINDING_ON_SALES')) {
1832 $nature = "sells";
1833 }
1834 if ($objp->nature == 3
1835 && isModEnabled('supplier_invoice')
1836 && !getDolGlobalString('ACCOUNTING_DISABLE_BINDING_ON_PURCHASES')) {
1837 $nature = "purchases";
1838 }
1839 if ($objp->nature == 4 && isModEnabled('bank')) {
1840 $nature = "bank";
1841 }
1842 if ($objp->nature == 5 && isModEnabled('expensereport') && !getDolGlobalString('ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS')) {
1843 $nature = "expensereports";
1844 }
1845 if ($objp->nature == 1 && isModEnabled('asset')) {
1846 $nature = "various"; // Warning: The page /accountancy/journal/variousjournal.php is bugged. It read tables that does not exists.
1847 }
1848 if ($objp->nature == 8) {
1849 $nature = "inventory";
1850 }
1851 if ($objp->nature == 9) {
1852 $nature = "hasnew";
1853 }
1854
1855 // To enable when page exists
1856 if (!getDolGlobalString('ACCOUNTANCY_SHOW_DEVELOP_JOURNAL')) {
1857 if ($nature == 'hasnew' || $nature == 'inventory') {
1858 $nature = '';
1859 }
1860 }
1861
1862 if ($nature) {
1863 $langs->load('accountancy');
1864 $journallabel = '';
1865 $journallabelwithoutspan = '';
1866 if ($objp->label) {
1867 $journallabelwithoutspan = $langs->trans($objp->label);
1868 $journallabel = '<span class="opacitymedium">('.$langs->trans($objp->label).')</span>'; // Label of bank account in llx_accounting_journal
1869 }
1870
1871 $key = $langs->trans("AccountingJournalType".$objp->nature); // $objp->nature is 1, 2, 3 ...
1872 $transferlabel = (($objp->nature && $key != "AccountingJournalType".$objp->nature) ? $key.($journallabelwithoutspan != $key ? ' '.$journallabel : '') : $journallabel);
1873
1874 if (getDolGlobalString('ACCOUNTING_MODE') == 'RECETTES-DEPENSES') {
1875 $journalNaturePrefixUrl = 'treasury';
1876 } else {
1877 $journalNaturePrefixUrl = $nature;
1878 }
1879 $newmenu->add('/accountancy/journal/'.$journalNaturePrefixUrl.'journal.php?mainmenu=accountancy&leftmenu=accountancy_journal&id_journal='.$objp->rowid, $transferlabel, 2, $user->hasRight('accounting', 'comptarapport', 'lire'));
1880 }
1881 $i++;
1882 }
1883 } else {
1884 // Should not happen. Entries are added
1885 $newmenu->add('', $langs->trans("NoJournalDefined"), 2, $user->hasRight('accounting', 'comptarapport', 'lire'));
1886 }
1887 } else {
1888 dol_print_error($db);
1889 }
1890 $db->free($resql);
1891 }
1892
1893 // Files
1894 if (!getDolGlobalString('ACCOUNTANCY_HIDE_EXPORT_FILES_MENU')) {
1895 $newmenu->add("/compta/accounting-files.php?mainmenu=accountancy&amp;leftmenu=accountancy_files", $langs->trans("AccountantFiles"), 1, $user->hasRight('accounting', 'mouvements', 'lire'));
1896 }
1897
1898
1899 // Accounting
1900 $newmenu->add("/accountancy/index.php?leftmenu=accountancy_accountancy", $langs->trans("MenuAccountancy"), 0, (int) ($user->hasRight('accounting', 'mouvements', 'lire') || $user->hasRight('accounting', 'comptarapport', 'lire')), '', $mainmenu, 'accountancy', 1, '', '', '', img_picto('', 'accountancy', 'class="paddingright pictofixedwidth"'));
1901
1902 // General Ledger
1903 $newmenu->add("/accountancy/bookkeeping/listbyaccount.php?mainmenu=accountancy&amp;leftmenu=accountancy_accountancy", $langs->trans("Bookkeeping"), 1, $user->hasRight('accounting', 'mouvements', 'lire'));
1904
1905 // Journals
1906 $newmenu->add("/accountancy/bookkeeping/list.php?mainmenu=accountancy&amp;leftmenu=accountancy_accountancy", $langs->trans("Journals"), 1, $user->hasRight('accounting', 'mouvements', 'lire'));
1907
1908 // Account Balance
1909 $newmenu->add("/accountancy/bookkeeping/balance.php?mainmenu=accountancy&amp;leftmenu=accountancy_accountancy", $langs->trans("AccountBalance"), 1, $user->hasRight('accounting', 'mouvements', 'lire'));
1910
1911 // Export accountancy
1912 $newmenu->add("/accountancy/bookkeeping/export.php?mainmenu=accountancy&amp;leftmenu=accountancy_accountancy", $langs->trans("MenuExportAccountancy"), 1, $user->hasRight('accounting', 'mouvements', 'lire'));
1913
1914 // Closure
1915 $newmenu->add("/accountancy/closure/index.php?mainmenu=accountancy&amp;leftmenu=accountancy_closure", $langs->trans("MenuAccountancyClosure"), 1, $user->hasRight('accounting', 'fiscalyear', 'write'), '', $mainmenu, 'closure');
1916
1917 // Reports
1918 $newmenu->add("/accountancy/index.php?leftmenu=accountancy_report", $langs->trans("Reportings"), 1, $user->hasRight('accounting', 'comptarapport', 'lire'), '', $mainmenu, 'ca');
1919
1920 if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/', $leftmenu)) {
1921 $newmenu->add("/compta/resultat/index.php?leftmenu=accountancy_report", $langs->trans("MenuReportInOut"), 2, $user->hasRight('accounting', 'comptarapport', 'lire'));
1922 $newmenu->add("/compta/resultat/clientfourn.php?leftmenu=accountancy_report", $langs->trans("ByPredefinedAccountGroups"), 3, $user->hasRight('accounting', 'comptarapport', 'lire'));
1923
1924 if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
1925 global $mysoc;
1926
1927 // Multi personalized reports
1928 $sql = "SELECT rowid, code, label";
1929 $sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_report";
1930 $sql .= " WHERE entity = ".((int) $conf->entity);
1931 $sql .= " AND fk_country = ".((int) $mysoc->country_id);
1932 $sql .= " AND active = 1";
1933 $sql .= " ORDER BY label DESC";
1934
1935 $resql = $db->query($sql);
1936 if ($resql) {
1937 $numr = $db->num_rows($resql);
1938 $i = 0;
1939
1940 if ($numr > 0) {
1941 while ($i < $numr) {
1942 $objp = $db->fetch_object($resql);
1943 $newmenu->add('/compta/resultat/result.php?mainmenu=accountancy&leftmenu=accountancy_report&id_report='.$objp->rowid, $langs->trans("Personalized") . " - " . $objp->label, 3, $user->hasRight('accounting', 'comptarapport', 'lire'));
1944 $i++;
1945 }
1946 } else {
1947 // Should not happen. We keep a link in case it happen to go to the page to explain how to create custom groups.
1948 $newmenu->add("/compta/resultat/result.php?mainmenu=accountancy&leftmenu=accountancy_report", $langs->trans("ByPersonalizedAccountGroups"), 3, $user->hasRight('accounting', 'comptarapport', 'lire'));
1949 //$newmenu->add('', $langs->trans("NoReportDefined"), 3, 0);
1950 }
1951 } else {
1952 dol_print_error($db);
1953 }
1954 $db->free($resql);
1955 } else {
1956 $newmenu->add("/compta/resultat/result.php?leftmenu=accountancy_report", $langs->trans("ByPersonalizedAccountGroups"), 3, $user->hasRight('accounting', 'comptarapport', 'lire'));
1957 }
1958 }
1959
1960 $modecompta = 'CREANCES-DETTES';
1961 if (isModEnabled('accounting') && $user->hasRight('accounting', 'comptarapport', 'lire') && $mainmenu == 'accountancy') {
1962 $modecompta = 'BOOKKEEPING'; // Not yet implemented. Should be BOOKKEEPINGCOLLECTED
1963 }
1964 if ($modecompta) {
1965 if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/', $leftmenu)) {
1966 $newmenu->add("/compta/stats/index.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ReportTurnover"), 2, $user->hasRight('accounting', 'comptarapport', 'lire'));
1967 $newmenu->add("/compta/stats/casoc.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByCompanies"), 3, $user->hasRight('accounting', 'comptarapport', 'lire'));
1968 $newmenu->add("/compta/stats/cabyuser.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByUsers"), 3, $user->hasRight('accounting', 'comptarapport', 'lire'));
1969 $newmenu->add("/compta/stats/cabyprodserv.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByProductsAndServices"), 3, $user->hasRight('accounting', 'comptarapport', 'lire'));
1970 $newmenu->add("/compta/stats/byratecountry.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByVatRate"), 3, $user->hasRight('accounting', 'comptarapport', 'lire'));
1971 }
1972 }
1973
1974 $modecompta = 'RECETTES-DEPENSES';
1975 //if (isModEnabled('accounting') && $user->hasRight('accounting', 'comptarapport', 'lire') && $mainmenu == 'accountancy') $modecompta=''; // Not yet implemented. Should be BOOKKEEPINGCOLLECTED
1976 if ($modecompta) {
1977 if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/', $leftmenu)) {
1978 $newmenu->add("/compta/stats/index.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ReportTurnoverCollected"), 2, $user->hasRight('accounting', 'comptarapport', 'lire'));
1979 $newmenu->add("/compta/stats/casoc.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByCompanies"), 3, $user->hasRight('accounting', 'comptarapport', 'lire'));
1980 $newmenu->add("/compta/stats/cabyuser.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByUsers"), 3, $user->hasRight('accounting', 'comptarapport', 'lire'));
1981 //$newmenu->add("/compta/stats/cabyprodserv.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByProductsAndServices"),3,$user->hasRight('accounting', 'comptarapport', 'lire'));
1982 //$newmenu->add("/compta/stats/byratecountry.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByVatRate"),3,$user->hasRight('accounting', 'comptarapport', 'lire'));
1983 }
1984 }
1985
1986 $modecompta = 'CREANCES-DETTES';
1987 if (isModEnabled('accounting') && $user->hasRight('accounting', 'comptarapport', 'lire') && $mainmenu == 'accountancy') {
1988 $modecompta = 'BOOKKEEPING'; // Not yet implemented.
1989 }
1990 if ($modecompta && isModEnabled('supplier_invoice')) {
1991 if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/', $leftmenu)) {
1992 $newmenu->add("/compta/stats/supplier_turnover.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ReportPurchaseTurnover"), 2, $user->hasRight('accounting', 'comptarapport', 'lire'));
1993 $newmenu->add("/compta/stats/supplier_turnover_by_thirdparty.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByCompanies"), 3, $user->hasRight('accounting', 'comptarapport', 'lire'));
1994 $newmenu->add("/compta/stats/supplier_turnover_by_prodserv.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByProductsAndServices"), 3, $user->hasRight('accounting', 'comptarapport', 'lire'));
1995 }
1996 }
1997
1998 $modecompta = 'RECETTES-DEPENSES';
1999 if (isModEnabled('accounting') && $user->hasRight('accounting', 'comptarapport', 'lire') && $mainmenu == 'accountancy') {
2000 $modecompta = 'BOOKKEEPINGCOLLECTED'; // Not yet implemented.
2001 }
2002 if ($modecompta && ((isModEnabled('fournisseur') && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) || isModEnabled('supplier_invoice'))) {
2003 if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/', $leftmenu)) {
2004 $newmenu->add("/compta/stats/supplier_turnover.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ReportPurchaseTurnoverCollected"), 2, $user->hasRight('accounting', 'comptarapport', 'lire'));
2005 $newmenu->add("/compta/stats/supplier_turnover_by_thirdparty.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByCompanies"), 3, $user->hasRight('accounting', 'comptarapport', 'lire'));
2006 }
2007 }
2008 }
2009
2010 // Accountancy (simple)
2011 if (isModEnabled('comptabilite')) {
2012 // Files
2013 if (!getDolGlobalString('ACCOUNTANCY_HIDE_EXPORT_FILES_MENU')) {
2014 $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"'));
2015 }
2016
2017 // Bilan, resultats
2018 $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"'));
2019
2020 if ($usemenuhider || empty($leftmenu) || preg_match('/report/', $leftmenu)) {
2021 $newmenu->add("/compta/resultat/index.php?leftmenu=report", $langs->trans("MenuReportInOut"), 1, $user->hasRight('compta', 'resultat', 'lire'));
2022 $newmenu->add("/compta/resultat/clientfourn.php?leftmenu=report", $langs->trans("ByPredefinedAccountGroups"), 2, $user->hasRight('compta', 'resultat', 'lire'));
2023 /* On verra ca avec module compabilite expert
2024 $newmenu->add("/compta/resultat/compteres.php?leftmenu=report","Compte de resultat",2,$user->hasRight('compta', 'resultat', 'lire'));
2025 $newmenu->add("/compta/resultat/bilan.php?leftmenu=report","Bilan",2,$user->hasRight('compta', 'resultat', 'lire'));
2026 */
2027
2028 /*
2029 $newmenu->add("/compta/stats/cumul.php?leftmenu=report","Cumule",2,$user->hasRight('compta', 'resultat', 'lire'));
2030 if (isModEnabled('propal')) {
2031 $newmenu->add("/compta/stats/prev.php?leftmenu=report","Previsionnel",2,$user->hasRight('compta', 'resultat', 'lire'));
2032 $newmenu->add("/compta/stats/comp.php?leftmenu=report","Transferred",2,$user->hasRight('compta', 'resultat', 'lire'));
2033 }
2034 */
2035
2036 $modecompta = 'CREANCES-DETTES';
2037 $newmenu->add("/compta/stats/index.php?leftmenu=report&modecompta=".$modecompta, $langs->trans("ReportTurnover"), 1, $user->hasRight('compta', 'resultat', 'lire'));
2038 $newmenu->add("/compta/stats/casoc.php?leftmenu=report&modecompta=".$modecompta, $langs->trans("ByCompanies"), 2, $user->hasRight('compta', 'resultat', 'lire'));
2039 $newmenu->add("/compta/stats/cabyuser.php?leftmenu=report&modecompta=".$modecompta, $langs->trans("ByUsers"), 2, $user->hasRight('compta', 'resultat', 'lire'));
2040 $newmenu->add("/compta/stats/cabyprodserv.php?leftmenu=report&modecompta=".$modecompta, $langs->trans("ByProductsAndServices"), 2, $user->hasRight('compta', 'resultat', 'lire'));
2041 $newmenu->add("/compta/stats/byratecountry.php?leftmenu=report&modecompta=".$modecompta, $langs->trans("ByVatRate"), 2, $user->hasRight('compta', 'resultat', 'lire'));
2042
2043 $modecompta = 'RECETTES-DEPENSES';
2044 $newmenu->add("/compta/stats/index.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ReportTurnoverCollected"), 1, $user->hasRight('compta', 'resultat', 'lire'));
2045 $newmenu->add("/compta/stats/casoc.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByCompanies"), 2, $user->hasRight('compta', 'resultat', 'lire'));
2046 $newmenu->add("/compta/stats/cabyuser.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByUsers"), 2, $user->hasRight('compta', 'resultat', 'lire'));
2047
2048 //Achats
2049 $modecompta = 'CREANCES-DETTES';
2050 $newmenu->add("/compta/stats/supplier_turnover.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ReportPurchaseTurnover"), 1, $user->hasRight('compta', 'resultat', 'lire'));
2051 $newmenu->add("/compta/stats/supplier_turnover_by_thirdparty.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByCompanies"), 2, $user->hasRight('compta', 'resultat', 'lire'));
2052 $newmenu->add("/compta/stats/supplier_turnover_by_prodserv.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByProductsAndServices"), 2, $user->hasRight('compta', 'resultat', 'lire'));
2053
2054 /*
2055 $modecompta = 'RECETTES-DEPENSES';
2056 $newmenu->add("/compta/stats/index.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ReportPurchaseTurnoverCollected"), 1, $user->hasRight('compta', 'resultat', 'lire'));
2057 $newmenu->add("/compta/stats/casoc.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByCompanies"), 2, $user->hasRight('compta', 'resultat', 'lire'));
2058 $newmenu->add("/compta/stats/cabyuser.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByUsers"), 2, $user->hasRight('compta', 'resultat', 'lire'));
2059 */
2060
2061 // Journals
2062 $newmenu->add("/compta/journal/sellsjournal.php?leftmenu=report", $langs->trans("SellsJournal"), 1, $user->hasRight('compta', 'resultat', 'lire'), '', '', '', 50);
2063 $newmenu->add("/compta/journal/purchasesjournal.php?leftmenu=report", $langs->trans("PurchasesJournal"), 1, $user->hasRight('compta', 'resultat', 'lire'), '', '', '', 51);
2064 }
2065 //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'));
2066 }
2067
2068 // Intracomm report
2069 if (isModEnabled('intracommreport')) {
2070 $newmenu->add("/intracommreport/list.php?leftmenu=intracommreport", $langs->trans("MenuIntracommReport"), 0, $user->hasRight('intracommreport', 'read'), '', $mainmenu, 'intracommreport', 60, '', '', '', img_picto('', 'intracommreport', 'class="paddingright pictofixedwidth"'));
2071 if ($usemenuhider || empty($leftmenu) || preg_match('/intracommreport/', $leftmenu)) {
2072 // DEB / DES
2073 $newmenu->add("/intracommreport/card.php?action=create&leftmenu=intracommreport", $langs->trans("MenuIntracommReportNew"), 1, $user->hasRight('intracommreport', 'write'), '', $mainmenu, 'intracommreport', 1);
2074 $newmenu->add("/intracommreport/list.php?leftmenu=intracommreport", $langs->trans("MenuIntracommReportList"), 1, $user->hasRight('intracommreport', 'read'), '', $mainmenu, 'intracommreport', 1);
2075 }
2076 }
2077
2078 // Assets
2079 if (isModEnabled('asset')) {
2080 $newmenu->add("/asset/list.php?leftmenu=asset&mainmenu=accountancy", $langs->trans("MenuAssets"), 0, $user->hasRight('asset', 'read'), '', $mainmenu, 'asset', 100, '', '', '', img_picto('', 'payment', 'class="paddingright pictofixedwidth"'));
2081 $newmenu->add("/asset/card.php?leftmenu=asset&action=create", $langs->trans("MenuNewAsset"), 1, $user->hasRight('asset', 'write'));
2082 $newmenu->add("/asset/list.php?leftmenu=asset&mainmenu=accountancy", $langs->trans("MenuListAssets"), 1, $user->hasRight('asset', 'read'));
2083 $newmenu->add("/asset/model/list.php?leftmenu=asset_model", $langs->trans("MenuAssetModels"), 1, (int) ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('asset', 'read')) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('asset', 'model_advance', 'read'))), '', $mainmenu, 'asset_model');
2084 if ($usemenuhider || empty($leftmenu) || preg_match('/asset_model/', $leftmenu)) {
2085 $newmenu->add("/asset/model/card.php?leftmenu=asset_model&action=create", $langs->trans("MenuNewAssetModel"), 2, (int) ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('asset', 'write')) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('asset', 'model_advance', 'write'))));
2086 $newmenu->add("/asset/model/list.php?leftmenu=asset_model", $langs->trans("MenuListAssetModels"), 2, (int) ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('asset', 'read')) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('asset', 'model_advance', 'read'))));
2087 }
2088 }
2089 }
2090}
2091
2102function get_left_menu_bank($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0)
2103{
2104 global $user, $langs;
2105
2106 if ($mainmenu == 'bank') {
2107 // Load translation files required by the page
2108 $langs->loadLangs(array("withdrawals", "banks", "bills", "categories"));
2109
2110 // Bank-Cash account
2111 if (isModEnabled('bank')) {
2112 $newmenu->add("/compta/bank/list.php?leftmenu=bank&mainmenu=bank&search_status=opened", $langs->trans("MenuBankCash"), 0, $user->hasRight('banque', 'lire'), '', $mainmenu, 'bank', 0, '', '', '', img_picto('', 'bank_account', 'class="paddingright pictofixedwidth"'));
2113
2114 $newmenu->add("/compta/bank/card.php?action=create&token=" . newToken(), $langs->trans("MenuNewFinancialAccount"), 1, $user->hasRight('banque', 'configurer'));
2115 $newmenu->add("/compta/bank/list.php?leftmenu=bank&mainmenu=bank&search_status=opened", $langs->trans("List"), 1, $user->hasRight('banque', 'lire'), '', $mainmenu, 'bank');
2116 $newmenu->add("/compta/bank/bankentries_list.php", $langs->trans("ListTransactions"), 1, $user->hasRight('banque', 'lire'));
2117 $newmenu->add("/compta/bank/budget.php", $langs->trans("ListTransactionsByCategory"), 1, $user->hasRight('banque', 'lire'));
2118
2119 $newmenu->add("/compta/bank/transfer.php", $langs->trans("MenuBankInternalTransfer"), 1, $user->hasRight('banque', 'transfer'));
2120 }
2121
2122 if (isModEnabled('category') && getDolGlobalString('CATEGORY_EDIT_IN_MENU_NOT_IN_POPUP')) {
2123 $langs->load("categories");
2124 $newmenu->add("/categories/categorie_list.php?type=5", $langs->trans("Rubriques"), 1, $user->hasRight('categorie', 'creer'), '', $mainmenu, 'tags');
2125 $newmenu->add("/categories/categorie_list.php?type=8", $langs->trans("RubriquesTransactions"), 1, $user->hasRight('banque', 'configurer'), '', $mainmenu, 'tags');
2126 }
2127
2128 // Direct debit order
2129 if (isModEnabled('prelevement')) {
2130 $newmenu->add("/compta/prelevement/index.php?leftmenu=withdraw&mainmenu=bank", $langs->trans("PaymentByDirectDebit"), 0, $user->hasRight('prelevement', 'bons', 'lire'), '', $mainmenu, 'withdraw', 0, '', '', '', img_picto('', 'payment', 'class="paddingright pictofixedwidth"'));
2131
2132 if ($usemenuhider || empty($leftmenu) || $leftmenu == "withdraw") {
2133 $newmenu->add("/compta/prelevement/create.php?mainmenu=bank&token=" . newToken(), $langs->trans("NewStandingOrder"), 1, $user->hasRight('prelevement', 'bons', 'creer'));
2134
2135 $newmenu->add("/compta/prelevement/orders_list.php?mainmenu=bank", $langs->trans("List"), 1, $user->hasRight('prelevement', 'bons', 'lire'));
2136 $newmenu->add("/compta/prelevement/list.php?mainmenu=bank", $langs->trans("WithdrawalsLines"), 1, $user->hasRight('prelevement', 'bons', 'lire'));
2137 $newmenu->add("/compta/prelevement/rejets.php?mainmenu=bank", $langs->trans("Rejects"), 1, $user->hasRight('prelevement', 'bons', 'lire'));
2138 $newmenu->add("/compta/prelevement/stats.php?mainmenu=bank", $langs->trans("Statistics"), 1, $user->hasRight('prelevement', 'bons', 'lire'));
2139 }
2140 }
2141
2142 // Bank transfer order
2143 if (isModEnabled('paymentbybanktransfer')) {
2144 $newmenu->add("/compta/paymentbybanktransfer/index.php?leftmenu=banktransfer&mainmenu=bank", $langs->trans("PaymentByBankTransfer"), 0, $user->hasRight('paymentbybanktransfer', 'read'), '', $mainmenu, 'banktransfer', 0, '', '', '', img_picto('', 'payment', 'class="paddingright pictofixedwidth"'));
2145
2146 if ($usemenuhider || empty($leftmenu) || $leftmenu == "banktransfer") {
2147 $newmenu->add("/compta/prelevement/create.php?type=bank-transfer&mainmenu=bank&token=" . newToken(), $langs->trans("NewPaymentByBankTransfer"), 1, $user->hasRight('paymentbybanktransfer', 'create'));
2148
2149 $newmenu->add("/compta/prelevement/orders_list.php?type=bank-transfer&mainmenu=bank", $langs->trans("List"), 1, $user->hasRight('paymentbybanktransfer', 'read'));
2150 $newmenu->add("/compta/prelevement/list.php?type=bank-transfer&mainmenu=bank", $langs->trans("PaymentByBankTransferLines"), 1, $user->hasRight('paymentbybanktransfer', 'read'));
2151 $newmenu->add("/compta/prelevement/rejets.php?type=bank-transfer&mainmenu=bank", $langs->trans("Rejects"), 1, $user->hasRight('paymentbybanktransfer', 'read'));
2152 $newmenu->add("/compta/prelevement/stats.php?type=bank-transfer&mainmenu=bank", $langs->trans("Statistics"), 1, $user->hasRight('paymentbybanktransfer', 'read'));
2153 }
2154 }
2155
2156 // Management of checks
2157 if (!getDolGlobalString('BANK_DISABLE_CHECK_DEPOSIT') && isModEnabled('bank') && (isModEnabled('invoice') || getDolGlobalString('MAIN_MENU_CHEQUE_DEPOSIT_ON'))) {
2158 $newmenu->add("/compta/paiement/cheque/index.php?leftmenu=checks&mainmenu=bank", $langs->trans("MenuChequeDeposits"), 0, $user->hasRight('banque', 'cheque'), '', $mainmenu, 'checks', 0, '', '', '', img_picto('', 'payment', 'class="paddingright pictofixedwidth"'));
2159 if (preg_match('/checks/', $leftmenu)) {
2160 $newmenu->add("/compta/paiement/cheque/card.php?leftmenu=checks_bis&action=new&mainmenu=bank", $langs->trans("NewChequeDeposit"), 1, $user->hasRight('banque', 'cheque'));
2161 $newmenu->add("/compta/paiement/cheque/list.php?leftmenu=checks_bis&mainmenu=bank", $langs->trans("List"), 1, $user->hasRight('banque', 'cheque'));
2162 }
2163 }
2164
2165 // Cash Control
2166 if (isModEnabled('takepos') || isModEnabled('cashdesk')) {
2167 $permtomakecashfence = ($user->hasRight('cashdesk', 'run') || $user->hasRight('takepos', 'run'));
2168 $newmenu->add("/compta/cashcontrol/cashcontrol_list.php", $langs->trans("CashControl"), 0, (int) $permtomakecashfence, '', $mainmenu, 'cashcontrol', 0, '', '', '', img_picto('', 'pos', 'class="paddingright pictofixedwidth"'));
2169 $newmenu->add("/compta/cashcontrol/cashcontrol_card.php?action=create&token=" . newToken(), $langs->trans("NewCashFence"), 1, (int) $permtomakecashfence);
2170 $newmenu->add("/compta/cashcontrol/cashcontrol_list.php", $langs->trans("List"), 1, (int) $permtomakecashfence);
2171 }
2172 }
2173}
2174
2185function get_left_menu_products($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0)
2186{
2187 global $user, $langs;
2188
2189 if ($mainmenu == 'products') {
2190 // Products
2191 if (isModEnabled('product')) {
2192 $newmenu->add("/product/index.php?leftmenu=product", $langs->trans("Products"), 0, $user->hasRight('product', 'read'), '', $mainmenu, 'product', 0, '', '', '', img_picto('', 'product', 'class="paddingright pictofixedwidth"'));
2193 $newmenu->add("/product/card.php?leftmenu=product&action=create&type=0", $langs->trans("NewProduct"), 1, $user->hasRight('product', 'creer'));
2194 $newmenu->add("/product/list.php?leftmenu=product&type=0", $langs->trans("List"), 1, $user->hasRight('product', 'read'));
2195 if (isModEnabled('stock')) {
2196 $newmenu->add("/product/reassort.php?type=0", $langs->trans("MenuStocks"), 1, (int) ($user->hasRight('product', 'read') && $user->hasRight('stock', 'lire')));
2197 }
2198 if (isModEnabled('productbatch')) {
2199 $langs->load("stocks");
2200 $newmenu->add("/product/reassortlot.php?type=0&search_subjecttolotserial=1", $langs->trans("StocksByLotSerial"), 1, (int) ($user->hasRight('product', 'read') && $user->hasRight('stock', 'lire')));
2201 $newmenu->add("/product/stock/productlot_list.php", $langs->trans("LotSerial"), 1, (int) ($user->hasRight('product', 'read') && $user->hasRight('stock', 'lire')));
2202 }
2203 if (isModEnabled('variants')) {
2204 $newmenu->add("/variants/list.php", $langs->trans("VariantAttributes"), 1, $user->hasRight('product', 'read'));
2205 }
2206 if (isModEnabled('propal') || isModEnabled('order') || isModEnabled('invoice') || isModEnabled('supplier_proposal') || isModEnabled('supplier_order') || isModEnabled('supplier_invoice')) {
2207 $newmenu->add("/product/stats/card.php?id=all&leftmenu=stats&type=0", $langs->trans("Statistics"), 1, $user->hasRight('product', 'read'));
2208 }
2209
2210 // Categories
2211 if (isModEnabled('category') && getDolGlobalString('CATEGORY_EDIT_IN_MENU_NOT_IN_POPUP')) {
2212 $langs->load("categories");
2213 $newmenu->add("/categories/categorie_list.php?leftmenu=cat&type=0", $langs->trans("Categories"), 1, $user->hasRight('categorie', 'lire'), '', $mainmenu, 'cat');
2214 }
2215 }
2216
2217 // Services
2218 if (isModEnabled('service')) {
2219 $newmenu->add("/product/index.php?leftmenu=service", $langs->trans("Services"), 0, $user->hasRight('service', 'read'), '', $mainmenu, 'service', 0, '', '', '', img_picto('', 'service', 'class="paddingright pictofixedwidth"'));
2220 $newmenu->add("/product/card.php?leftmenu=service&action=create&type=1", $langs->trans("NewService"), 1, $user->hasRight('service', 'creer'));
2221 $newmenu->add("/product/list.php?leftmenu=service&type=1", $langs->trans("List"), 1, $user->hasRight('service', 'read'));
2222
2223 if (isModEnabled('stock') && getDolGlobalString('STOCK_SUPPORTS_SERVICES')) {
2224 $newmenu->add("/product/reassort.php?type=1", $langs->trans("MenuStocks"), 1, (int) ($user->hasRight('service', 'read') && $user->hasRight('stock', 'lire')));
2225 }
2226 if (isModEnabled('variants')) {
2227 $newmenu->add("/variants/list.php", $langs->trans("VariantAttributes"), 1, $user->hasRight('service', 'read'));
2228 }
2229 if (isModEnabled('propal') || isModEnabled('order') || isModEnabled('invoice') || isModEnabled('supplier_proposal') || isModEnabled('supplier_order') || isModEnabled('supplier_invoice')) {
2230 $newmenu->add("/product/stats/card.php?id=all&leftmenu=stats&type=1", $langs->trans("Statistics"), 1, $user->hasRight('service', 'read'));
2231 }
2232 // Categories
2233 if (isModEnabled('category') && getDolGlobalString('CATEGORY_EDIT_IN_MENU_NOT_IN_POPUP')) {
2234 $langs->load("categories");
2235 $newmenu->add("/categories/categorie_list.php?leftmenu=cat&type=0", $langs->trans("Categories"), 1, $user->hasRight('categorie', 'lire'), '', $mainmenu, 'cat');
2236 }
2237 }
2238
2239 // Warehouse
2240 if (isModEnabled('stock')) {
2241 $langs->load("stocks");
2242 $newmenu->add("/product/index.php?leftmenu=stock", $langs->trans("Warehouses"), 0, $user->hasRight('stock', 'lire'), '', $mainmenu, 'stock', 0, '', '', '', img_picto('', 'stock', 'class="paddingright pictofixedwidth"'));
2243 $newmenu->add("/product/stock/card.php?action=create", $langs->trans("MenuNewWarehouse"), 1, $user->hasRight('stock', 'creer'));
2244 $newmenu->add("/product/stock/list.php", $langs->trans("List"), 1, $user->hasRight('stock', 'lire'));
2245 $newmenu->add("/product/stock/movement_list.php", $langs->trans("Movements"), 1, $user->hasRight('stock', 'mouvement', 'lire'));
2246
2247 $newmenu->add("/product/stock/massstockmove.php?init=1", $langs->trans("MassStockTransferShort"), 1, $user->hasRight('stock', 'mouvement', 'creer'));
2248 if (isModEnabled('supplier_order')) {
2249 $newmenu->add("/product/stock/replenish.php", $langs->trans("Replenishment"), 1, (int) ($user->hasRight('stock', 'mouvement', 'creer') && $user->hasRight('fournisseur', 'lire')));
2250 }
2251 $newmenu->add("/product/stock/stockatdate.php", $langs->trans("StockAtDate"), 1, (int) ($user->hasRight('product', 'read') && $user->hasRight('stock', 'lire')));
2252
2253 // Categories for warehouses
2254 if (isModEnabled('category') && getDolGlobalString('CATEGORY_EDIT_IN_MENU_NOT_IN_POPUP')) {
2255 $newmenu->add("/categories/categorie_list.php?leftmenu=stock&type=9", $langs->trans("Categories"), 1, $user->hasRight('categorie', 'lire'), '', $mainmenu, 'cat');
2256 }
2257 }
2258
2259 if (isModEnabled('stocktransfer')) {
2260 $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"'));
2261 $newmenu->add('/product/stock/stocktransfer/stocktransfer_card.php?action=create', $langs->trans('StockTransferNew'), 1, $user->hasRight('stocktransfer', 'stocktransfer', 'write'));
2262 $newmenu->add('/product/stock/stocktransfer/stocktransfer_list.php', $langs->trans('List'), 1, $user->hasRight('stocktransfer', 'stocktransfer', 'read'));
2263 }
2264
2265 // Inventory
2266 if (isModEnabled('stock')) {
2267 $langs->load("stocks");
2268 if (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) {
2269 $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"'));
2270 if ($usemenuhider || empty($leftmenu) || $leftmenu == "stock_inventories") {
2271 $newmenu->add("/product/inventory/card.php?action=create&leftmenu=stock_inventories", $langs->trans("NewInventory"), 1, $user->hasRight('stock', 'creer'));
2272 $newmenu->add("/product/inventory/list.php?leftmenu=stock_inventories", $langs->trans("List"), 1, $user->hasRight('stock', 'lire'));
2273 }
2274 } else {
2275 $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"'));
2276 if ($usemenuhider || empty($leftmenu) || $leftmenu == "stock_inventories") {
2277 $newmenu->add("/product/inventory/card.php?action=create&leftmenu=stock_inventories", $langs->trans("NewInventory"), 1, $user->hasRight('stock', 'inventory_advance', 'write'));
2278 $newmenu->add("/product/inventory/list.php?leftmenu=stock_inventories", $langs->trans("List"), 1, $user->hasRight('stock', 'inventory_advance', 'read'));
2279 }
2280 }
2281 }
2282
2283 // Shipments
2284 if (isModEnabled('shipping')) {
2285 $langs->load("sendings");
2286 $newmenu->add("/expedition/index.php?leftmenu=sendings", $langs->trans("Shipments"), 0, $user->hasRight('expedition', 'lire'), '', $mainmenu, 'sendings', 0, '', '', '', img_picto('', 'shipment', 'class="paddingright pictofixedwidth"'));
2287 $newmenu->add("/expedition/card.php?action=create2&leftmenu=sendings", $langs->trans("NewSending"), 1, $user->hasRight('expedition', 'creer'));
2288 $newmenu->add("/expedition/list.php?leftmenu=sendings", $langs->trans("List"), 1, $user->hasRight('expedition', 'lire'));
2289 if ($usemenuhider || empty($leftmenu) || $leftmenu == "sendings") {
2290 $newmenu->add("/expedition/list.php?leftmenu=sendings&search_status=0", $langs->trans("StatusSendingDraftShort"), 2, $user->hasRight('expedition', 'lire'));
2291 $newmenu->add("/expedition/list.php?leftmenu=sendings&search_status=1", $langs->trans("StatusSendingValidatedShort"), 2, $user->hasRight('expedition', 'lire'));
2292 $newmenu->add("/expedition/list.php?leftmenu=sendings&search_status=2", $langs->trans("StatusSendingProcessedShort"), 2, $user->hasRight('expedition', 'lire'));
2293 }
2294 $newmenu->add("/expedition/stats/index.php?leftmenu=sendings", $langs->trans("Statistics"), 1, $user->hasRight('expedition', 'lire'));
2295 }
2296
2297 // Receptions
2298 if (isModEnabled('reception')) {
2299 $langs->load("receptions");
2300 $newmenu->add("/reception/index.php?leftmenu=receptions", $langs->trans("Receptions"), 0, $user->hasRight('reception', 'lire'), '', $mainmenu, 'receptions', 0, '', '', '', img_picto('', 'dollyrevert', 'class="pictofixedwidth", style="text-align: right;"'));
2301 $newmenu->add("/reception/card.php?action=create2&leftmenu=receptions", $langs->trans("NewReception"), 1, $user->hasRight('reception', 'creer'));
2302 $newmenu->add("/reception/list.php?leftmenu=receptions", $langs->trans("List"), 1, $user->hasRight('reception', 'lire'));
2303 if ($usemenuhider || empty($leftmenu) || $leftmenu == "receptions") {
2304 $newmenu->add("/reception/list.php?leftmenu=receptions&search_status=0", $langs->trans("StatusReceptionDraftShort"), 2, $user->hasRight('reception', 'lire'));
2305 }
2306 if ($usemenuhider || empty($leftmenu) || $leftmenu == "receptions") {
2307 $newmenu->add("/reception/list.php?leftmenu=receptions&search_status=1", $langs->trans("StatusReceptionValidatedShort"), 2, $user->hasRight('reception', 'lire'));
2308 }
2309 if ($usemenuhider || empty($leftmenu) || $leftmenu == "receptions") {
2310 $newmenu->add("/reception/list.php?leftmenu=receptions&search_status=2", $langs->trans("StatusReceptionProcessedShort"), 2, $user->hasRight('reception', 'lire'));
2311 }
2312 $newmenu->add("/reception/stats/index.php?leftmenu=receptions", $langs->trans("Statistics"), 1, $user->hasRight('reception', 'lire'));
2313 }
2314 }
2315}
2316
2327function get_left_menu_mrp($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0)
2328{
2329 global $user, $conf, $langs;
2330
2331 if ($mainmenu == 'mrp') {
2332 // BOM
2333 if (isModEnabled('bom') || isModEnabled('mrp')) {
2334 $langs->load("mrp");
2335
2336 $newmenu->add("", $langs->trans("MenuBOM"), 0, $user->hasRight('bom', 'read'), '', $mainmenu, 'bom', 0, '', '', '', img_picto('', 'bom', 'class="paddingright pictofixedwidth"'));
2337 $newmenu->add("/bom/bom_card.php?leftmenu=bom&action=create", $langs->trans("NewBOM"), 1, $user->hasRight('bom', 'write'), '', $mainmenu, 'bom');
2338 $newmenu->add("/bom/bom_list.php?leftmenu=bom", $langs->trans("List"), 1, $user->hasRight('bom', 'read'), '', $mainmenu, 'bom');
2339 }
2340
2341 if (isModEnabled('mrp')) {
2342 $langs->load("mrp");
2343
2344 $newmenu->add("", $langs->trans("MenuMRP"), 0, $user->hasRight('mrp', 'read'), '', $mainmenu, 'mrp', 0, '', '', '', img_picto('', 'mrp', 'class="paddingright pictofixedwidth"'));
2345 $newmenu->add("/mrp/mo_card.php?leftmenu=mo&action=create", $langs->trans("NewMO"), 1, $user->hasRight('mrp', 'write'), '', $mainmenu, '');
2346 $newmenu->add("/mrp/mo_list.php?leftmenu=mo", $langs->trans("List"), 1, $user->hasRight('mrp', 'read'), '', $mainmenu, '');
2347 }
2348 }
2349}
2350
2361function get_left_menu_projects($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0)
2362{
2363 global $user, $langs;
2364
2365 if ($mainmenu == 'project') {
2366 if (isModEnabled('project')) {
2367 $langs->load("projects");
2368
2369 $search_project_user = GETPOSTINT('search_project_user');
2370
2371 $tmpentry = array(
2372 'enabled' => (int) isModEnabled('project'),
2373 'perms' => (string) (int) $user->hasRight('projet', 'lire'),
2374 'module' => 'projet'
2375 );
2376 $listofmodulesforexternal = explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL'));
2377 $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal);
2378
2379 $titleboth = $langs->trans("LeadsOrProjects");
2380 $titlenew = $langs->trans("NewLeadOrProject"); // Leads and opportunities by default
2381 if (!getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) {
2382 $titleboth = $langs->trans("Projects");
2383 $titlenew = $langs->trans("NewProject");
2384 }
2385 if (getDolGlobalInt('PROJECT_USE_OPPORTUNITIES') == 2) { // 2 = leads only
2386 $titleboth = $langs->trans("Leads");
2387 $titlenew = $langs->trans("NewLead");
2388 }
2389
2390 // Project assigned to user
2391 $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"'));
2392 $newmenu->add("/projet/card.php?leftmenu=projects&action=create".($search_project_user ? '&search_project_user='.$search_project_user : ''), $titlenew, 1, $user->hasRight('projet', 'creer'));
2393
2394 if (!getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) {
2395 $newmenu->add("/projet/list.php?leftmenu=projects".($search_project_user ? '&search_project_user='.$search_project_user : '').'&search_status=99', $langs->trans("List"), 1, $showmode, '', 'project', 'list');
2396 } elseif (getDolGlobalInt('PROJECT_USE_OPPORTUNITIES') == 1) {
2397 $newmenu->add("/projet/list.php?leftmenu=projects".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("List"), 1, $showmode, '', 'project', 'list');
2398 $newmenu->add('/projet/list.php?mainmenu=project&leftmenu=list&search_usage_opportunity=1&search_status=99&search_opp_status=openedopp&contextpage=lead', $langs->trans("ListOpenLeads"), 2, $showmode);
2399 $newmenu->add('/projet/list.php?mainmenu=project&leftmenu=list&search_opp_status=notopenedopp&search_status=99&contextpage=project', $langs->trans("ListOpenProjects"), 2, $showmode);
2400 } elseif (getDolGlobalInt('PROJECT_USE_OPPORTUNITIES') == 2) { // 2 = leads only
2401 $newmenu->add('/projet/list.php?mainmenu=project&leftmenu=list&search_usage_opportunity=1&search_status=99', $langs->trans("List"), 2, $showmode);
2402 }
2403
2404 $newmenu->add("/projet/stats/index.php?leftmenu=projects", $langs->trans("Statistics"), 1, $user->hasRight('projet', 'lire'));
2405
2406 // Categories
2407 if (isModEnabled('category') && getDolGlobalString('CATEGORY_EDIT_IN_MENU_NOT_IN_POPUP')) {
2408 $langs->load("categories");
2409 $newmenu->add("/categories/categorie_list.php?leftmenu=cat&type=6", $langs->trans("Categories"), 1, $user->hasRight('categorie', 'lire'), '', $mainmenu, 'cat');
2410 }
2411
2412 if (!getDolGlobalString('PROJECT_HIDE_TASKS')) {
2413 // Project assigned to user
2414 $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"'));
2415 $newmenu->add("/projet/tasks.php?leftmenu=tasks&action=create", $langs->trans("NewTask"), 1, $user->hasRight('projet', 'creer'));
2416 $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'));
2417 $newmenu->add("/projet/tasks/stats/index.php?leftmenu=projects", $langs->trans("Statistics"), 1, $user->hasRight('projet', 'lire'));
2418
2419 $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"'));
2420 $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'));
2421 }
2422 }
2423 }
2424}
2425
2436function get_left_menu_hrm($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0)
2437{
2438 global $user, $langs;
2439
2440 if ($mainmenu == 'hrm') {
2441 // HRM module
2442 if (isModEnabled('hrm')) {
2443 $langs->load("hrm");
2444
2445 $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"'));
2446 $newmenu->add("/user/card.php?mainmenu=hrm&leftmenu=hrm&action=create&employee=1", $langs->trans("NewEmployee"), 1, $user->hasRight('user', 'user', 'write'));
2447 $newmenu->add("/user/list.php?mainmenu=hrm&leftmenu=hrm&contextpage=employeelist", $langs->trans("List"), 1, $user->hasRight('user', 'user', 'read'));
2448
2449 $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"'));
2450
2451 // Skills
2452 $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"'));
2453 //$newmenu->add("/hrm/skill_card.php?mainmenu=hrm&leftmenu=hrm_sm&action=create", $langs->trans("NewSkill"), 1, $user->hasRight('hrm', 'all', 'write'));
2454 //$newmenu->add("/hrm/skill_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("List"), 1, $user->hasRight('hrm', 'all', 'read'));
2455
2456 // Job (Description of work to do and skills required)
2457 $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"'));
2458 //$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'));
2459 //$newmenu->add("/hrm/job_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("List"), 1, $user->hasRight('hrm', 'all', 'read'));
2460
2461 // Position = Link job - user
2462 $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"'));
2463 //$newmenu->add("/hrm/position.php?mainmenu=hrm&leftmenu=hrm_sm&action=create", $langs->transnoentities("NewObject", $langs->trans("Position")), 1, $user->hasRight('hrm', 'all', 'write'));
2464 //$newmenu->add("/hrm/position_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("List"), 1, $user->hasRight('hrm', 'all', 'read'));
2465
2466 // Evaluation
2467 $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"'));
2468 //$newmenu->add("/hrm/evaluation_card.php?mainmenu=hrm&leftmenu=hrm_sm&action=create", $langs->trans("NewEval"), 1, $user->hasRight('hrm', 'evaluation', 'write'));
2469 //$newmenu->add("/hrm/evaluation_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("List"), 1, $user->hasRight('hrm', 'evaluation', 'read'));
2470 $newmenu->add("/hrm/compare.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("SkillComparison"), 1, (int) ($user->hasRight('hrm', 'evaluation', 'read') || $user->hasRight('hrm', 'compare_advance', 'read')));
2471 }
2472
2473 // Leave/Holiday/Vacation module
2474 if (isModEnabled('holiday')) {
2475 // Load translation files required by the page
2476 $langs->loadLangs(array("holiday", "trips"));
2477
2478 $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"'));
2479 $newmenu->add("/holiday/card.php?mainmenu=hrm&leftmenu=holiday&action=create", $langs->trans("New"), 1, $user->hasRight('holiday', 'write'), '', $mainmenu);
2480 $newmenu->add("/holiday/card_group.php?mainmenu=hrm&leftmenu=holiday&action=create", $langs->trans("NewHolidayForGroup"), 1, (int) ($user->hasRight('holiday', 'writeall') && $user->hasRight('holiday', 'readall')), '', $mainmenu, 'holiday_sm');
2481 $newmenu->add("/holiday/list.php?mainmenu=hrm&leftmenu=holiday", $langs->trans("List"), 1, $user->hasRight('holiday', 'read'), '', $mainmenu);
2482 if ($usemenuhider || empty($leftmenu) || $leftmenu == "holiday") {
2483 $newmenu->add("/holiday/list.php?search_status=1&mainmenu=hrm&leftmenu=holiday", $langs->trans("DraftCP"), 2, $user->hasRight('holiday', 'read'), '', $mainmenu, 'holiday_sm');
2484 $newmenu->add("/holiday/list.php?search_status=2&mainmenu=hrm&leftmenu=holiday", $langs->trans("ToReviewCP"), 2, $user->hasRight('holiday', 'read'), '', $mainmenu, 'holiday_sm');
2485 $newmenu->add("/holiday/list.php?search_status=3&mainmenu=hrm&leftmenu=holiday", $langs->trans("ApprovedCP"), 2, $user->hasRight('holiday', 'read'), '', $mainmenu, 'holiday_sm');
2486 $newmenu->add("/holiday/list.php?search_status=4&mainmenu=hrm&leftmenu=holiday", $langs->trans("CancelCP"), 2, $user->hasRight('holiday', 'read'), '', $mainmenu, 'holiday_sm');
2487 $newmenu->add("/holiday/list.php?search_status=5&mainmenu=hrm&leftmenu=holiday", $langs->trans("RefuseCP"), 2, $user->hasRight('holiday', 'read'), '', $mainmenu, 'holiday_sm');
2488 }
2489 $newmenu->add("/holiday/define_holiday.php?mainmenu=hrm", $langs->trans("MenuConfCP"), 1, $user->hasRight('holiday', 'read'), '', $mainmenu, 'holiday_sm');
2490 $newmenu->add("/holiday/month_report.php?mainmenu=hrm&leftmenu=holiday", $langs->trans("MenuReportMonth"), 1, $user->hasRight('holiday', 'readall'), '', $mainmenu, 'holiday_sm');
2491 $newmenu->add("/holiday/view_log.php?mainmenu=hrm&leftmenu=holiday", $langs->trans("MenuLogCP"), 1, $user->hasRight('holiday', 'define_holiday'), '', $mainmenu, 'holiday_sm');
2492 }
2493
2494 // Trips and expenses (old module)
2495 if (isModEnabled('deplacement')) {
2496 $langs->load("trips");
2497 $newmenu->add("/compta/deplacement/index.php?leftmenu=tripsandexpenses&mainmenu=hrm", $langs->trans("TripsAndExpenses"), 0, $user->hasRight('deplacement', 'lire'), '', $mainmenu, 'tripsandexpenses', 0, '', '', '', img_picto('', 'trip', 'class="paddingright pictofixedwidth"'));
2498 $newmenu->add("/compta/deplacement/card.php?action=create&leftmenu=tripsandexpenses&mainmenu=hrm", $langs->trans("New"), 1, $user->hasRight('deplacement', 'creer'));
2499 $newmenu->add("/compta/deplacement/list.php?leftmenu=tripsandexpenses&mainmenu=hrm", $langs->trans("List"), 1, $user->hasRight('deplacement', 'lire'));
2500 $newmenu->add("/compta/deplacement/stats/index.php?leftmenu=tripsandexpenses&mainmenu=hrm", $langs->trans("Statistics"), 1, $user->hasRight('deplacement', 'lire'));
2501 }
2502
2503 // Expense report
2504 if (isModEnabled('expensereport')) {
2505 $langs->loadLangs(array("trips", "bills"));
2506 $newmenu->add("/expensereport/index.php?leftmenu=expensereport&mainmenu=hrm", $langs->trans("TripsAndExpenses"), 0, $user->hasRight('expensereport', 'lire'), '', $mainmenu, 'expensereport', 0, '', '', '', img_picto('', 'expensereport', 'class="paddingright pictofixedwidth"'));
2507 $newmenu->add("/expensereport/card.php?action=create&leftmenu=expensereport&mainmenu=hrm", $langs->trans("New"), 1, $user->hasRight('expensereport', 'creer'));
2508 $newmenu->add("/expensereport/list.php?leftmenu=expensereport&mainmenu=hrm", $langs->trans("List"), 1, $user->hasRight('expensereport', 'lire'));
2509 if ($usemenuhider || empty($leftmenu) || $leftmenu == "expensereport") {
2510 $newmenu->add("/expensereport/list.php?search_status=0&leftmenu=expensereport&mainmenu=hrm", $langs->trans("Draft"), 2, $user->hasRight('expensereport', 'lire'));
2511 $newmenu->add("/expensereport/list.php?search_status=2&leftmenu=expensereport&mainmenu=hrm", $langs->trans("Validated"), 2, $user->hasRight('expensereport', 'lire'));
2512 $newmenu->add("/expensereport/list.php?search_status=5&leftmenu=expensereport&mainmenu=hrm", $langs->trans("Approved"), 2, $user->hasRight('expensereport', 'lire'));
2513 $newmenu->add("/expensereport/list.php?search_status=6&leftmenu=expensereport&mainmenu=hrm", $langs->trans("Paid"), 2, $user->hasRight('expensereport', 'lire'));
2514 $newmenu->add("/expensereport/list.php?search_status=4&leftmenu=expensereport&mainmenu=hrm", $langs->trans("Canceled"), 2, $user->hasRight('expensereport', 'lire'));
2515 $newmenu->add("/expensereport/list.php?search_status=99&leftmenu=expensereport&mainmenu=hrm", $langs->trans("Refused"), 2, $user->hasRight('expensereport', 'lire'));
2516 }
2517 $newmenu->add("/expensereport/payment/list.php?leftmenu=expensereport_payments&mainmenu=hrm", $langs->trans("Payments"), 1, (int) (int) ($user->hasRight('expensereport', 'lire') && isModEnabled('bank')));
2518 $newmenu->add("/expensereport/stats/index.php?leftmenu=expensereport&mainmenu=hrm", $langs->trans("Statistics"), 1, $user->hasRight('expensereport', 'lire'));
2519 }
2520
2521 if (isModEnabled('project')) {
2522 if (!getDolGlobalString('PROJECT_HIDE_TASKS')) {
2523 $langs->load("projects");
2524
2525 $search_project_user = GETPOSTINT('search_project_user');
2526
2527 $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"'));
2528 }
2529 }
2530 }
2531}
2532
2533
2544function get_left_menu_tools($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0)
2545{
2546 global $user, $langs;
2547
2548 if ($mainmenu == 'tools') {
2549 if (isModEnabled('category')) {
2550 $titleindex = $langs->trans("Categories");
2551 $newmenu->add("/categories/index.php?leftmenu=category", $titleindex, 0, $user->hasRight('category', 'read'), '', $mainmenu, 'category', 5, '', '', '', img_picto('', 'category', 'class="paddingright pictofixedwidth"'));
2552 }
2553
2554 if (empty($user->socid)) { // limit to internal users
2555 $langs->load("mails");
2556 $newmenu->add("/admin/mails_templates.php?leftmenu=email_templates", $langs->trans("EMailTemplates"), 0, 1, '', $mainmenu, 'email_templates', 10, '', '', '', img_picto('', 'email', 'class="paddingright pictofixedwidth"'));
2557 }
2558
2559 if (isModEnabled('mailing')) {
2560 $titleindex = $langs->trans("EMailings");
2561 $titlenew = $langs->trans("NewMailing");
2562 $titlelist = $langs->trans("List");
2563 if (getDolGlobalInt('EMAILINGS_SUPPORT_ALSO_SMS')) {
2564 $titleindex .= ' | '.$langs->trans("SMSings");
2565 $titlenew .= ' | '.$langs->trans("NewSMSing");
2566 }
2567 $newmenu->add("/comm/mailing/index.php?leftmenu=mailing", $titleindex, 0, $user->hasRight('mailing', 'lire'), '', $mainmenu, 'mailing', 15, '', '', '', img_picto('', 'email', 'class="paddingright pictofixedwidth"'));
2568 $newmenu->add("/comm/mailing/card.php?leftmenu=mailing&action=create", $titlenew, 1, $user->hasRight('mailing', 'creer'));
2569 $newmenu->add("/comm/mailing/list.php?leftmenu=mailing", $titlelist, 1, $user->hasRight('mailing', 'lire'));
2570 }
2571
2572 $title = "ImportExportArea";
2573 if (isModEnabled('import') && !isModEnabled('export')) {
2574 $title = "FormatedImport";
2575 }
2576 if (!isModEnabled('import') && isModEnabled('export')) {
2577 $title = "FormatedExport";
2578 }
2579 if (isModEnabled('import') || isModEnabled('export')) {
2580 $langs->load("exports");
2581 $newmenu->add("/imports/index.php?leftmenu=import", $langs->trans($title), 0, (int) ($user->hasRight('import', 'run') || $user->hasRight('export', 'lire')), '', $mainmenu, 'import', 20, '', '', '', img_picto('', 'technic', 'class="paddingright pictofixedwidth"'));
2582 $newmenu->add("/imports/import.php?leftmenu=import", $langs->trans("NewImport"), 1, $user->hasRight('import', 'run'));
2583 $newmenu->add("/exports/export.php?leftmenu=export", $langs->trans("NewExport"), 1, $user->hasRight('export', 'lire'));
2584 }
2585 /*
2586 if (isModEnabled('export')) {
2587 $langs->load("exports");
2588 $newmenu->add("/exports/index.php?leftmenu=export", $langs->trans("FormatedExport"), 0, $user->hasRight('export', 'lire'), '', $mainmenu, 'export', 0, '', '', '', img_picto('', 'technic', 'class="paddingright pictofixedwidth"'));
2589 $newmenu->add("/exports/export.php?leftmenu=export", $langs->trans("NewExport"), 1, $user->hasRight('export', 'lire'));
2590 } */
2591
2592 $newmenu->add("/core/customreports.php?leftmenu=customreports", $langs->trans("BICustomReports"), 0, 1, '', $mainmenu, 'customreports', 100, '', '', '', img_picto('', 'graph', 'class="paddingright pictofixedwidth"'));
2593 }
2594}
2595
2606function get_left_menu_members($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0)
2607{
2608 global $user, $langs;
2609
2610 if ($mainmenu == 'members') {
2611 if (isModEnabled('member')) {
2612 // Load translation files required by the page
2613 $langs->loadLangs(array("members", "compta"));
2614
2615 $newmenu->add("/adherents/index.php?leftmenu=members&mainmenu=members", $langs->trans("Members"), 0, $user->hasRight('adherent', 'read'), '', $mainmenu, 'members', 0, '', '', '', img_picto('', 'member', 'class="paddingright pictofixedwidth"'));
2616 $newmenu->add("/adherents/card.php?leftmenu=members&action=create", $langs->trans("NewMember"), 1, $user->hasRight('adherent', 'write'));
2617 $newmenu->add("/adherents/list.php?leftmenu=members", $langs->trans("List"), 1, $user->hasRight('adherent', 'read'));
2618 $newmenu->add("/adherents/list.php?leftmenu=members&statut=-1", $langs->trans("MenuMembersToValidate"), 2, $user->hasRight('adherent', 'read'));
2619 $newmenu->add("/adherents/list.php?leftmenu=members&statut=1", $langs->trans("MenuMembersValidated"), 2, $user->hasRight('adherent', 'read'));
2620 $newmenu->add("/adherents/list.php?leftmenu=members&statut=1&filter=waitingsubscription", $langs->trans("WaitingSubscription"), 3, $user->hasRight('adherent', 'read'));
2621 $newmenu->add("/adherents/list.php?leftmenu=members&statut=1&filter=uptodate", $langs->trans("UpToDate"), 3, $user->hasRight('adherent', 'read'));
2622 $newmenu->add("/adherents/list.php?leftmenu=members&statut=1&filter=outofdate", $langs->trans("OutOfDate"), 3, $user->hasRight('adherent', 'read'));
2623 $newmenu->add("/adherents/list.php?leftmenu=members&statut=0", $langs->trans("MenuMembersResiliated"), 2, $user->hasRight('adherent', 'read'));
2624 $newmenu->add("/adherents/list.php?leftmenu=members&statut=-2", $langs->trans("MenuMembersExcluded"), 2, $user->hasRight('adherent', 'read'));
2625 $newmenu->add("/adherents/stats/index.php?leftmenu=members", $langs->trans("MenuMembersStats"), 1, $user->hasRight('adherent', 'read'));
2626
2627 $newmenu->add("/adherents/cartes/carte.php?leftmenu=export", $langs->trans("MembersCards"), 1, $user->hasRight('adherent', 'export'));
2628
2629 if (isModEnabled('category') && getDolGlobalString('CATEGORY_EDIT_IN_MENU_NOT_IN_POPUP')) {
2630 $langs->load("categories");
2631 $newmenu->add("/categories/categorie_list.php?leftmenu=cat&type=3", $langs->trans("Categories"), 1, $user->hasRight('categorie', 'read'), '', $mainmenu, 'cat');
2632 }
2633
2634 $newmenu->add("/adherents/index.php?leftmenu=members&mainmenu=members", $langs->trans("Subscriptions"), 0, $user->hasRight('adherent', 'cotisation', 'read'), '', $mainmenu, 'members', 0, '', '', '', img_picto('', 'payment', 'class="paddingright pictofixedwidth"'));
2635 $newmenu->add("/adherents/list.php?leftmenu=members&statut=-1,1&mainmenu=members", $langs->trans("NewMembership"), 1, $user->hasRight('adherent', 'cotisation', 'write'));
2636 $newmenu->add("/adherents/subscription/list.php?leftmenu=members", $langs->trans("List"), 1, $user->hasRight('adherent', 'cotisation', 'read'));
2637 $newmenu->add("/adherents/stats/index.php?leftmenu=members", $langs->trans("MenuMembersStats"), 1, $user->hasRight('adherent', 'read'));
2638
2639 //$newmenu->add("/adherents/index.php?leftmenu=export&mainmenu=members",$langs->trans("Tools"),0,$user->hasRight('adherent', 'export'), '', $mainmenu, 'export');
2640 //if (isModEnabled('export') && ($usemenuhider || empty($leftmenu) || $leftmenu=="export")) $newmenu->add("/exports/index.php?leftmenu=export",$langs->trans("Datas"),1,$user->hasRight('adherent', 'export'));
2641
2642 // Type
2643 $newmenu->add("/adherents/type.php?leftmenu=setup&mainmenu=members", $langs->trans("MembersTypes"), 0, $user->hasRight('adherent', 'configurer'), '', $mainmenu, 'setup', 0, '', '', '', img_picto('', 'members', 'class="paddingright pictofixedwidth"'));
2644 $newmenu->add("/adherents/type.php?leftmenu=setup&mainmenu=members&action=create", $langs->trans("New"), 1, $user->hasRight('adherent', 'configurer'));
2645 $newmenu->add("/adherents/type.php?leftmenu=setup&mainmenu=members", $langs->trans("List"), 1, $user->hasRight('adherent', 'configurer'));
2646 }
2647 }
2648}
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:48
Class to manage menu entries.
print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout=0, $mode='')
Core function to output the top menu eldy.
Definition eldy.lib.php:48
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:649
print_end_menu_entry($showmode)
Output end menu entry.
Definition eldy.lib.php:725
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:671
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:738
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:635
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:761
get_left_menu_billing($mainmenu, &$newmenu, $usemenuhider=1, $leftmenu='none', $type_user=0)
Get left COMPTA-FINANCIAL.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
getDolUserString($key, $default='', $tmpuser=null)
Return Dolibarr user constant string value.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
getDolGlobalString($key, $default='')
Return a 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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79