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