Passed
Push — master ( 4e88da...5feb35 )
by Alxarafe
26:36
created

EldyLib::print_end_menu_array()   A

Complexity

Conditions 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
/* Copyright (C) 2010-2014 Laurent Destailleur  <[email protected]>
3
 * Copyright (C) 2010      Regis Houssin        <[email protected]>
4
 * Copyright (C) 2012-2015 Juanjo Menent        <[email protected]>
5
 * Copyright (C) 2013      Cédric Salvador      <[email protected]>
6
 * Copyright (C) 2015      Marcos García        <[email protected]>
7
 * Copyright (C) 2018      Ferran Marcet        <[email protected]>
8
 * Copyright (C) 2018       Frédéric France         <[email protected]>
9
 * Copyright (C) 2018-2019  Alxarafe                <[email protected]>
10
 *
11
 * This program is free software; you can redistribute it and/or modify
12
 * it under the terms of the GNU General Public License as published by
13
 * the Free Software Foundation; either version 3 of the License, or
14
 * (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23
 * or see http://www.gnu.org/
24
 */
25
namespace Alixar\Helpers;
26
27
/**
28
 *  \file		htdocs/core/menus/standard/eldy.lib.php
29
 *  \brief		Library for file eldy menus
30
 */
31
use Alxarafe\Helpers\Config;
32
use Alixar\Base\Menubase;
33
use Alixar\Base\Conf;
34
use Alixar\Helpers\DolUtils;
35
36
class EldyLib
37
{
38
39
    /**
40
     * Core function to output top menu eldy
41
     *
42
     * @param 	DoliDB	Config::$dbEngine				Database handler
43
     * @param 	string	$atarget		Target (Example: '' or '_top')
44
     * @param 	int		$type_user     	0=Menu for backoffice, 1=Menu for front office
45
     * @param  	array	$tabMenu        If array with menu entries already loaded, we put this array here (in most cases, it's empty)
46
     * @param	Menu	$menu			Object Menu to return back list of menu entries
0 ignored issues
show
Bug introduced by alxarafe
The type Alixar\Helpers\Menu was not found. Did you mean Menu? If so, make sure to prefix the type with \.
Loading history...
47
     * @param	int		$noout			1=Disable output (Initialise &$menu only).
48
     * @param	string	$mode			'top', 'topnb', 'left', 'jmobile'
49
     * @return	int						0
50
     */
51
    static function print_eldy_menu($dba, $atarget, $type_user, &$tabMenu, &$menu, $noout = 0, $mode = '')
52
    {
53
        //global Globals::$user, $conf, $langs, $dolibarr_main_db_name;
54
55
        $mainmenu = (empty($_SESSION["mainmenu"]) ? '' : $_SESSION["mainmenu"]);
56
        $leftmenu = (empty($_SESSION["leftmenu"]) ? '' : $_SESSION["leftmenu"]);
57
58
        $id = 'mainmenu';
59
        $listofmodulesforexternal = explode(',', Conf::$global->MAIN_MODULES_FOR_EXTERNAL ?? '');
60
61
        if (empty($noout)) {
62
            EldyLib::print_start_menu_array();
63
        }
64
65
        $usemenuhider = (DolUtils::GETPOST('testmenuhider', 'int') || !empty(Conf::$global->MAIN_TESTMENUHIDER));
66
67
// Show/Hide vertical menu
68
        if ($mode != 'jmobile' && $mode != 'topnb' && $usemenuhider && empty(Conf::$global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
69
            $showmode = 1;
70
            $classname = 'class="tmenu menuhider"';
71
            $idsel = 'menu';
72
73
            $menu->add('#', '', 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname);
74
        }
75
76
// Home
77
        $showmode = 1;
78
        $classname = "";
79
        if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "home") {
80
            $classname = 'class="tmenusel"';
81
            $_SESSION['idmenu'] = '';
82
        } else {
83
            $classname = 'class="tmenu"';
84
        }
85
        $idsel = 'home';
86
87
        $titlehome = Globals::$langs->trans("Home");
88
        if (!empty(Conf::$global->THEME_TOPMENU_DISABLE_IMAGE)) {
89
            $titlehome = '&nbsp; <span class="fa fa-home"></span> &nbsp;';
90
        }
91
//$menu->add('/index.php?mainmenu=home&leftmenu=home', $titlehome, 0, $showmode, $atarget, "home", '', 10, $id, $idsel, $classname);
92
        $menu->add('?mainmenu=home&leftmenu=home', $titlehome, 0, $showmode, $atarget, "home", '', 10, $id, $idsel, $classname);
93
94
// Members
95
        $tmpentry = array(
96
            'enabled' => (!empty($conf->adherent->enabled)),
0 ignored issues
show
Comprehensibility Best Practice introduced by alxarafe
The variable $conf seems to be never defined.
Loading history...
97
            'perms' => (!empty(Globals::$user->rights->adherent->lire)),
98
            'module' => 'adherent',
99
        );
100
        $showmode = DolUtils::isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal);
101
        if ($showmode) {
102
            $classname = "";
103
            if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "members") {
104
                $classname = 'class="tmenusel"';
105
                $_SESSION['idmenu'] = '';
106
            } else {
107
                $classname = 'class="tmenu"';
108
            }
109
            $idsel = 'members';
110
111
//$menu->add('/adherents/index.php?mainmenu=members&leftmenu=', Globals::$langs->trans("MenuMembers"), 0, $showmode, $atarget, "members", '', 18, $id, $idsel, $classname);
112
            $menu->add('?controller=adherents&method=index&mainmenu=members&leftmenu=', Globals::$langs->trans("MenuMembers"), 0, $showmode, $atarget, "members", '', 18, $id, $idsel, $classname);
113
        }
114
115
// Third parties
116
        $tmpentry = array(
117
            'enabled' => ((!empty($conf->societe->enabled) && (empty(Conf::$global->SOCIETE_DISABLE_PROSPECTS) || empty(Conf::$global->SOCIETE_DISABLE_CUSTOMERS))) || !empty($conf->fournisseur->enabled)),
118
            'perms' => (!empty(Globals::$user->rights->societe->lire) || !empty(Globals::$user->rights->fournisseur->lire)),
119
            'module' => 'societe|fournisseur',
120
        );
121
        $showmode = DolUtils::isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal);
122
        if ($showmode) {
123
// Load translation files required by the page
124
            Globals::$langs->loadLangs(array("companies", "suppliers"));
125
126
            $classname = "";
127
            if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "companies") {
128
                $classname = 'class="tmenusel"';
129
                $_SESSION['idmenu'] = '';
130
            } else {
131
                $classname = 'class="tmenu"';
132
            }
133
            $idsel = 'companies';
134
135
//$menu->add('/societe/index.php?mainmenu=companies&leftmenu=', Globals::$langs->trans("ThirdParties"), 0, $showmode, $atarget, "companies", '', 20, $id, $idsel, $classname);
136
            $menu->add('?controller=societe&method=index&mainmenu=companies&leftmenu=', Globals::$langs->trans("ThirdParties"), 0, $showmode, $atarget, "companies", '', 20, $id, $idsel, $classname);
137
        }
138
139
// Products-Services
140
        $tmpentry = array(
141
            'enabled' => (!empty($conf->product->enabled) || !empty($conf->service->enabled)),
142
            'perms' => (!empty(Globals::$user->rights->produit->lire) || !empty(Globals::$user->rights->service->lire)),
143
            'module' => 'product|service',
144
        );
145
        $showmode = DolUtils::isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal);
146
        if ($showmode) {
147
            Globals::$langs->load("products");
148
149
            $classname = "";
150
            if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "products") {
151
                $classname = 'class="tmenusel"';
152
                $_SESSION['idmenu'] = '';
153
            } else {
154
                $classname = 'class="tmenu"';
155
            }
156
            $idsel = 'products';
157
158
            $chaine = "";
159
            if (!empty($conf->product->enabled)) {
160
                $chaine .= Globals::$langs->trans("TMenuProducts");
161
            }
162
            if (!empty($conf->product->enabled) && !empty($conf->service->enabled)) {
163
                $chaine .= " | ";
164
            }
165
            if (!empty($conf->service->enabled)) {
166
                $chaine .= Globals::$langs->trans("TMenuServices");
167
            }
168
169
//$menu->add('/product/index.php?mainmenu=products&leftmenu=', $chaine, 0, $showmode, $atarget, "products", '', 30, $id, $idsel, $classname);
170
            $menu->add('?controller=product&method=index&mainmenu=products&leftmenu=', $chaine, 0, $showmode, $atarget, "products", '', 30, $id, $idsel, $classname);
171
        }
172
173
// Projects
174
        $tmpentry = array('enabled' => (!empty($conf->projet->enabled)),
175
            'perms' => (!empty(Globals::$user->rights->projet->lire)),
176
            'module' => 'projet');
177
        $showmode = DolUtils::isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal);
178
        if ($showmode) {
179
            Globals::$langs->load("projects");
180
181
            $classname = "";
182
            if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "project") {
183
                $classname = 'class="tmenusel"';
184
                $_SESSION['idmenu'] = '';
185
            } else {
186
                $classname = 'class="tmenu"';
187
            }
188
            $idsel = 'project';
189
190
            $title = Globals::$langs->trans("LeadsOrProjects"); // Leads and opportunities by default
191
            $showmodel = $showmodep = $showmode;
192
            if (empty(Conf::$global->PROJECT_USE_OPPORTUNITIES)) {
193
                $title = Globals::$langs->trans("Projects");
194
                $showmodel = 0;
195
            }
196
            if (Conf::$global->PROJECT_USE_OPPORTUNITIES == 2) {
197
                $title = Globals::$langs->trans("Leads");
198
                $showmodep = 0;
199
            }
200
201
//$menu->add('/projet/index.php?mainmenu=project&leftmenu=', $title, 0, $showmode, $atarget, "project", '', 35, $id, $idsel, $classname);
202
            $menu->add('?controller=projet&method=index&mainmenu=project&leftmenu=', $title, 0, $showmode, $atarget, "project", '', 35, $id, $idsel, $classname);
203
//$menu->add('/projet/index.php?mainmenu=project&leftmenu=&search_opp_status=openedopp', Globals::$langs->trans("ListLeads"), 0, $showmodel & Conf::$global->PROJECT_USE_OPPORTUNITIES, $atarget, "project", '', 70, $id, $idsel, $classname);
204
//$menu->add('/projet/index.php?mainmenu=project&leftmenu=&search_opp_status=notopenedopp', Globals::$langs->trans("ListProjects"), 0, $showmodep, $atarget, "project", '', 70, $id, $idsel, $classname);
205
        }
206
207
// Commercial
208
        $menuqualified = 0;
209
        if (!empty($conf->propal->enabled)) {
210
            $menuqualified++;
211
        }
212
        if (!empty($conf->commande->enabled)) {
213
            $menuqualified++;
214
        }
215
        if (!empty($conf->supplier_order->enabled)) {
216
            $menuqualified++;
217
        }
218
        if (!empty($conf->supplier_proposal->enabled)) {
219
            $menuqualified++;
220
        }
221
        if (!empty($conf->contrat->enabled)) {
222
            $menuqualified++;
223
        }
224
        if (!empty($conf->ficheinter->enabled)) {
225
            $menuqualified++;
226
        }
227
        $tmpentry = array(
228
            'enabled' => $menuqualified,
229
            'perms' => (!empty(Globals::$user->rights->societe->lire) || !empty(Globals::$user->rights->societe->contact->lire)),
230
            'module' => 'propal|commande|supplier_order|contrat|ficheinter',
231
        );
232
        $showmode = DolUtils::isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal);
233
        if ($showmode) {
234
            Globals::$langs->load("commercial");
235
236
            $classname = "";
237
            if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "commercial") {
238
                $classname = 'class="tmenusel"';
239
                $_SESSION['idmenu'] = '';
240
            } else {
241
                $classname = 'class="tmenu"';
242
            }
243
            $idsel = 'commercial';
244
245
//$menu->add('/comm/index.php?mainmenu=commercial&leftmenu=', Globals::$langs->trans("Commercial"), 0, $showmode, $atarget, "commercial", "", 40, $id, $idsel, $classname);
246
            $menu->add('?controller=comm&method=index&mainmenu=commercial&leftmenu=', Globals::$langs->trans("Commercial"), 0, $showmode, $atarget, "commercial", "", 40, $id, $idsel, $classname);
247
        }
248
249
// Billing - Financial
250
        $menuqualified = 0;
251
        if (!empty($conf->facture->enabled)) {
252
            $menuqualified++;
253
        }
254
        if (!empty($conf->don->enabled)) {
255
            $menuqualified++;
256
        }
257
        if (!empty($conf->tax->enabled)) {
258
            $menuqualified++;
259
        }
260
        if (!empty($conf->salaries->enabled)) {
261
            $menuqualified++;
262
        }
263
        if (!empty($conf->supplier_invoice->enabled)) {
264
            $menuqualified++;
265
        }
266
        if (!empty($conf->loan->enabled)) {
267
            $menuqualified++;
268
        }
269
        $tmpentry = array(
270
            'enabled' => $menuqualified,
271
            'perms' => (!empty(Globals::$user->rights->facture->lire) || !empty(Globals::$user->rights->don->lire) || !empty(Globals::$user->rights->tax->charges->lire) || !empty(Globals::$user->rights->salaries->read) || !empty(Globals::$user->rights->fournisseur->facture->lire) || !empty(Globals::$user->rights->loan->read)),
272
            'module' => 'facture|supplier_invoice|don|tax|salaries|loan',
273
        );
274
        $showmode = DolUtils::isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal);
275
        if ($showmode) {
276
            Globals::$langs->load("compta");
277
278
            $classname = "";
279
            if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "billing") {
280
                $classname = 'class="tmenusel"';
281
                $_SESSION['idmenu'] = '';
282
            } else {
283
                $classname = 'class="tmenu"';
284
            }
285
            $idsel = 'billing';
286
287
//$menu->add('/compta/index.php?mainmenu=billing&leftmenu=', Globals::$langs->trans("MenuFinancial"), 0, $showmode, $atarget, "billing", '', 50, $id, $idsel, $classname);
288
            $menu->add('?controller=compta&method=index&mainmenu=billing&leftmenu=', Globals::$langs->trans("MenuFinancial"), 0, $showmode, $atarget, "billing", '', 50, $id, $idsel, $classname);
289
        }
290
291
// Bank
292
        $tmpentry = array(
293
            'enabled' => (!empty($conf->banque->enabled) || !empty($conf->prelevement->enabled)),
294
            'perms' => (!empty(Globals::$user->rights->banque->lire) || !empty(Globals::$user->rights->prelevement->lire)),
295
            'module' => 'banque|prelevement',
296
        );
297
        $showmode = DolUtils::isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal);
298
        if ($showmode) {
299
// Load translation files required by the page
300
            Globals::$langs->loadLangs(array("compta", "banks"));
301
302
            $classname = "";
303
            if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "bank") {
304
                $classname = 'class="tmenusel"';
305
                $_SESSION['idmenu'] = '';
306
            } else
307
                $classname = 'class="tmenu"';
308
            $idsel = 'bank';
309
310
//$menu->add('/compta/bank/list.php?mainmenu=bank&leftmenu=', Globals::$langs->trans("MenuBankCash"), 0, $showmode, $atarget, "bank", '', 52, $id, $idsel, $classname);
311
            $menu->add('?controller=compta/bank&method=list&mainmenu=bank&leftmenu=', Globals::$langs->trans("MenuBankCash"), 0, $showmode, $atarget, "bank", '', 52, $id, $idsel, $classname);
312
        }
313
314
// Accounting
315
        $menuqualified = 0;
316
        if (!empty($conf->comptabilite->enabled)) {
317
            $menuqualified++;
318
        }
319
        if (!empty($conf->accounting->enabled)) {
320
            $menuqualified++;
321
        }
322
        if (!empty($conf->asset->enabled)) {
323
            $menuqualified++;
324
        }
325
        $tmpentry = array(
326
            'enabled' => $menuqualified,
327
            'perms' => (!empty(Globals::$user->rights->compta->resultat->lire) || !empty(Globals::$user->rights->accounting->mouvements->lire) || !empty(Globals::$user->rights->asset->read)),
328
            'module' => 'comptabilite|accounting',
329
        );
330
        $showmode = DolUtils::isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal);
331
        if ($showmode) {
332
            Globals::$langs->load("compta");
333
334
            $classname = "";
335
            if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "accountancy") {
336
                $classname = 'class="tmenusel"';
337
                $_SESSION['idmenu'] = '';
338
            } else {
339
                $classname = 'class="tmenu"';
340
            }
341
            $idsel = 'accountancy';
342
343
//$menu->add('/accountancy/index.php?mainmenu=accountancy&leftmenu=', Globals::$langs->trans("MenuAccountancy"), 0, $showmode, $atarget, "accountancy", '', 54, $id, $idsel, $classname);
344
            $menu->add('?controller=accountancy&method=index&mainmenu=accountancy&leftmenu=', Globals::$langs->trans("MenuAccountancy"), 0, $showmode, $atarget, "accountancy", '', 54, $id, $idsel, $classname);
345
        }
346
347
// HRM
348
        $tmpentry = array(
349
            'enabled' => (!empty($conf->hrm->enabled) || !empty($conf->holiday->enabled) || !empty($conf->deplacement->enabled) || !empty($conf->expensereport->enabled)),
350
            'perms' => (!empty(Globals::$user->rights->hrm->employee->read) || !empty(Globals::$user->rights->holiday->write) || !empty(Globals::$user->rights->deplacement->lire) || !empty(Globals::$user->rights->expensereport->lire)),
351
            'module' => 'hrm|holiday|deplacement|expensereport',
352
        );
353
        $showmode = DolUtils::isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal);
354
        if ($showmode) {
355
            Globals::$langs->load("holiday");
356
357
            $classname = "";
358
            if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "hrm") {
359
                $classname = 'class="tmenusel"';
360
                $_SESSION['idmenu'] = '';
361
            } else {
362
                $classname = 'class="tmenu"';
363
            }
364
            $idsel = 'hrm';
365
366
//$menu->add('/hrm/index.php?mainmenu=hrm&leftmenu=', Globals::$langs->trans("HRM"), 0, $showmode, $atarget, "hrm", '', 80, $id, $idsel, $classname);
367
            $menu->add('?controller=hrm&method=index&mainmenu=hrm&leftmenu=', Globals::$langs->trans("HRM"), 0, $showmode, $atarget, "hrm", '', 80, $id, $idsel, $classname);
368
        }
369
370
// Tools
371
        $tmpentry = array(
372
            'enabled' => 1,
373
            'perms' => 1,
374
            'module' => '',
375
        );
376
        $showmode = DolUtils::isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal);
377
        if ($showmode) {
378
            Globals::$langs->load("other");
379
380
            $classname = "";
381
            if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "tools") {
382
                $classname = 'class="tmenusel"';
383
                $_SESSION['idmenu'] = '';
384
            } else {
385
                $classname = 'class="tmenu"';
386
            }
387
            $idsel = 'tools';
388
389
//$menu->add('/core/tools.php?mainmenu=tools&leftmenu=', Globals::$langs->trans("Tools"), 0, $showmode, $atarget, "tools", '', 90, $id, $idsel, $classname);
390
            $menu->add('?controller=core&method=tools&mainmenu=tools&leftmenu=', Globals::$langs->trans("Tools"), 0, $showmode, $atarget, "tools", '', 90, $id, $idsel, $classname);
391
        }
392
393
// Show personalized menus
394
        $menuArbo = new Menubase(Config::$dbEngine, 'eldy');
395
        $newTabMenu = $menuArbo->menuTopCharger('', '', $type_user, 'eldy', $tabMenu); // Return tabMenu with only top entries
396
397
        $num = count($newTabMenu);
398
        for ($i = 0; $i < $num; $i++) {
399
            $idsel = (empty($newTabMenu[$i]['mainmenu']) ? 'none' : $newTabMenu[$i]['mainmenu']);
400
401
            $showmode = DolUtils::isVisibleToUserType($type_user, $newTabMenu[$i], $listofmodulesforexternal);
402
            if ($showmode == 1) {
403
                $substitarray = array('__LOGIN__' => Globals::$user->login, '__USER_ID__' => Globals::$user->id, '__USER_SUPERVISOR_ID__' => Globals::$user->fk_user);
404
                $substitarray['__USERID__'] = Globals::$user->id; // For backward compatibility
405
                $newTabMenu[$i]['url'] = DolUtils::make_substitutions($newTabMenu[$i]['url'], $substitarray);
406
407
// url = url from host, shorturl = relative path into dolibarr sources
408
                $url = $shorturl = $newTabMenu[$i]['url'];
409
                if (!preg_match("/^(http:\/\/|https:\/\/)/i", $newTabMenu[$i]['url'])) { // Do not change url content for external links
410
                    $tmp = explode('?', $newTabMenu[$i]['url'], 2);
411
                    $url = $shorturl = $tmp[0];
412
                    $param = (isset($tmp[1]) ? $tmp[1] : '');
413
414
                    if (!preg_match('/mainmenu/i', $param) || !preg_match('/leftmenu/i', $param)) {
415
                        $param .= ($param ? '&' : '') . 'mainmenu=' . $newTabMenu[$i]['mainmenu'] . '&leftmenu=';
416
                    }
417
//$url.="idmenu=".$newTabMenu[$i]['rowid'];    // Already done by menuLoad
418
                    $url = DolUtils::dol_buildpath($url, 1) . ($param ? '?' . $param : '');
419
//$shorturl = $shorturl.($param?'?'.$param:'');
420
                    $shorturl = $url;
421
                    if (BASE_URI) {
422
                        $shorturl = preg_replace('/^' . preg_quote(BASE_URI, '/') . '/', '', $shorturl);
423
                    }
424
                }
425
426
// Define the class (top menu selected or not)
427
                if (!empty($_SESSION['idmenu']) && $newTabMenu[$i]['rowid'] == $_SESSION['idmenu']) {
428
                    $classname = 'class="tmenusel"';
429
                } else if (!empty($_SESSION["mainmenu"]) && $newTabMenu[$i]['mainmenu'] == $_SESSION["mainmenu"]) {
430
                    $classname = 'class="tmenusel"';
431
                } else {
432
                    $classname = 'class="tmenu"';
433
                }
434
            } else if ($showmode == 2) {
435
                $classname = 'class="tmenu"';
436
            }
437
438
            $menu->add($shorturl, $newTabMenu[$i]['titre'], 0, $showmode, ($newTabMenu[$i]['target'] ? $newTabMenu[$i]['target'] : $atarget), ($newTabMenu[$i]['mainmenu'] ? $newTabMenu[$i]['mainmenu'] : $newTabMenu[$i]['rowid']), ($newTabMenu[$i]['leftmenu'] ? $newTabMenu[$i]['leftmenu'] : ''), $newTabMenu[$i]['position'], $id, $idsel, $classname);
439
        }
440
441
// Sort on position
442
        $menu->liste = DolUtils::dol_sort_array($menu->liste, 'position');
443
444
// Output menu entries
445
        if (empty($noout)) {
446
            foreach ($menu->liste as $menkey => $menuval) {
447
                self::print_start_menu_entry($menuval['idsel'], $menuval['classname'], $menuval['enabled']);
448
                self::print_text_menu_entry($menuval['titre'], $menuval['enabled'], (($menuval['url'] != '#' && !preg_match('/^(http:\/\/|https:\/\/)/i', $menuval['url'])) ? BASE_URI : '') . $menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target'] ? $menuval['target'] : $atarget));
449
                self::print_end_menu_entry($menuval['enabled']);
450
            }
451
        }
452
453
        $showmode = 1;
454
        if (empty($noout)) {
455
            self::print_start_menu_entry('', 'class="tmenuend"', $showmode);
456
            self::print_end_menu_entry($showmode);
457
            self::print_end_menu_array();
458
        }
459
460
        return 0;
461
    }
462
463
    /**
464
     * Output start menu array
465
     *
466
     * @return	void
467
     */
468
    static function print_start_menu_array()
469
    {
470
        global $conf;
471
472
        print '<div class="tmenudiv">';
473
        print '<ul class="tmenu"' . (empty(Conf::$global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '' : ' title="Top menu"') . '>';
474
    }
475
476
    /**
477
     * Output start menu entry
478
     *
479
     * @param	string	$idsel		Text
480
     * @param	string	$classname	String to add a css class
481
     * @param	int		$showmode	0 = hide, 1 = allowed or 2 = not allowed
482
     * @return	void
483
     */
484
    static function print_start_menu_entry($idsel, $classname, $showmode)
485
    {
486
        if ($showmode) {
487
            print '<li ' . $classname . ' id="mainmenutd_' . $idsel . '">';
488
//print '<div class="tmenuleft tmenusep"></div>';
489
            print '<div class="tmenucenter">';
490
        }
491
    }
492
493
    /**
494
     * Output menu entry
495
     *
496
     * @param	string	$text		Text
497
     * @param	int		$showmode	0 = hide, 1 = allowed or 2 = not allowed
498
     * @param	string	$url		Url
499
     * @param	string	$id			Id
500
     * @param	string	$idsel		Id sel
501
     * @param	string	$classname	Class name
502
     * @param	string	$atarget	Target
503
     * @return	void
504
     */
505
    static function print_text_menu_entry($text, $showmode, $url, $id, $idsel, $classname, $atarget)
506
    {
507
        // global Globals::$langs;
508
509
        if ($showmode == 1) {
510
            print '<a class="tmenuimage" tabindex="-1" href="' . $url . '"' . ($atarget ? ' target="' . $atarget . '"' : '') . '>';
511
            print '<div class="' . $id . ' ' . $idsel . ' topmenuimage"><span class="' . $id . ' tmenuimage" id="mainmenuspan_' . $idsel . '"></span></div>';
512
            print '</a>';
513
            print '<a ' . $classname . ' id="mainmenua_' . $idsel . '" href="' . $url . '"' . ($atarget ? ' target="' . $atarget . '"' : '') . '>';
514
            print '<span class="mainmenuaspan">';
515
            print $text;
516
            print '</span>';
517
            print '</a>';
518
        } elseif ($showmode == 2) {
519
            print '<div class="' . $id . ' ' . $idsel . ' topmenuimage tmenudisabled"><span class="' . $id . '" id="mainmenuspan_' . $idsel . '"></span></div>';
520
            print '<a class="tmenudisabled" id="mainmenua_' . $idsel . '" href="#" title="' . dol_escape_htmltag(Globals::$langs->trans("NotAllowed")) . '">';
521
            print '<span class="mainmenuaspan">';
522
            print $text;
523
            print '</span>';
524
            print '</a>';
525
        }
526
    }
527
528
    /**
529
     * Output end menu entry
530
     *
531
     * @param	int		$showmode	0 = hide, 1 = allowed or 2 = not allowed
532
     * @return	void
533
     */
534
    static function print_end_menu_entry($showmode)
535
    {
536
        if ($showmode) {
537
            print '</div></li>';
538
        }
539
        print "\n";
540
    }
541
542
    /**
543
     * Output menu array
544
     *
545
     * @return	void
546
     */
547
    static function print_end_menu_array()
548
    {
549
        print '</ul>';
550
        print '</div>';
551
        print "\n";
552
    }
553
554
    /**
555
     * Core function to output left menu eldy
556
     * Fill &$menu (example with $forcemainmenu='home' $forceleftmenu='all', return left menu tree of Home)
557
     *
558
     * @param	DoliDB		Config::$dbEngine                 Database handler
559
     * @param 	array		$menu_array_before  Table of menu entries to show before entries of menu handler (menu->liste filled with menu->add)
560
     * @param   array		$menu_array_after   Table of menu entries to show after entries of menu handler (menu->liste filled with menu->add)
561
     * @param	array		$tabMenu       		If array with menu entries already loaded, we put this array here (in most cases, it's empty)
562
     * @param	Menu		$menu				Object Menu to return back list of menu entries
563
     * @param	int			$noout				Disable output (Initialise &$menu only).
564
     * @param	string		$forcemainmenu		'x'=Force mainmenu to mainmenu='x'
565
     * @param	string		$forceleftmenu		'all'=Force leftmenu to '' (= all). If value come being '', we change it to value in session and 'none' if not defined in session.
566
     * @param	array		$moredata			An array with more data to output
567
     * @return	int								nb of menu entries
568
     */
569
    function print_left_eldy_menu($dba, $menu_array_before, $menu_array_after, &$tabMenu, &$menu, $noout = 0, $forcemainmenu = '', $forceleftmenu = '', $moredata = null)
570
    {
571
        // global Globals::$user, $conf, Globals::$langs, $dolibarr_main_db_name, $mysoc;
572
//var_dump($tabMenu);
573
574
        $newmenu = $menu;
575
576
        $mainmenu = ($forcemainmenu ? $forcemainmenu : $_SESSION["mainmenu"]);
577
        $leftmenu = ($forceleftmenu ? '' : (empty($_SESSION["leftmenu"]) ? 'none' : $_SESSION["leftmenu"]));
578
579
        $usemenuhider = (DolUtils::GETPOST('testmenuhider', 'int') || !empty(Conf::$global->MAIN_TESTMENUHIDER));
580
581
// Show logo company
582
        if (empty(Conf::$global->MAIN_MENU_INVERT) && empty($noout) && !empty(Conf::$global->MAIN_SHOW_LOGO) && empty(Conf::$global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
583
            $mysoc->logo_mini = Conf::$global->MAIN_INFO_SOCIETE_LOGO_MINI;
0 ignored issues
show
Comprehensibility Best Practice introduced by alxarafe
The variable $mysoc seems to be never defined.
Loading history...
584
            if (!empty($mysoc->logo_mini) && is_readable($conf->mycompany->dir_output . '/logos/thumbs/' . $mysoc->logo_mini)) {
0 ignored issues
show
Comprehensibility Best Practice introduced by alxarafe
The variable $conf seems to be never defined.
Loading history...
585
                $urllogo = DOL_BASE_URI . '/viewimage.php?cache=1&modulepart=mycompany&file=' . urlencode('logos/thumbs/' . $mysoc->logo_mini);
586
            } else {
587
                $urllogo = DOL_BASE_URI . '/theme/dolibarr_logo.png';
588
            }
589
            $title = Globals::$langs->trans("GoIntoSetupToChangeLogo");
590
            print "\n" . '<!-- Show logo on menu -->' . "\n";
591
            print '<div class="blockvmenuimpair blockvmenulogo">' . "\n";
592
            print '<div class="menu_titre" id="menu_titre_logo"></div>';
593
            print '<div class="menu_top" id="menu_top_logo"></div>';
594
            print '<div class="menu_contenu" id="menu_contenu_logo">';
595
            print '<div class="center"><img class="mycompany" title="' . dol_escape_htmltag($title) . '" alt="" src="' . $urllogo . '" style="max-width: 70%"></div>' . "\n";
596
            print '</div>';
597
            print '<div class="menu_end" id="menu_end_logo"></div>';
598
            print '</div>' . "\n";
599
        }
600
601
        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
602
            print "\n";
603
            print "<!-- Begin SearchForm -->\n";
604
            print '<div id="blockvmenusearch" class="blockvmenusearch">' . "\n";
605
            print $moredata['searchform'];
606
            print '</div>' . "\n";
607
            print "<!-- End SearchForm -->\n";
608
        }
609
610
        if (is_array($moredata) && !empty($moredata['bookmarks'])) {
611
            print "\n";
612
            print "<!-- Begin Bookmarks -->\n";
613
            print '<div id="blockvmenubookmarks" class="blockvmenubookmarks">' . "\n";
614
            print $moredata['bookmarks'];
615
            print '</div>' . "\n";
616
            print "<!-- End Bookmarks -->\n";
617
        }
618
619
        /**
620
         * We update newmenu with entries found into database
621
         * --------------------------------------------------
622
         */
623
        if ($mainmenu) { // If this is empty, loading hard coded menu and loading personalised menu will fail
624
            /*
625
             * Menu HOME
626
             */
627
            if ($mainmenu == 'home') {
628
                Globals::$langs->load("users");
629
630
// Home - dashboard
631
//$newmenu->add("/index.php?mainmenu=home&leftmenu=home", Globals::$langs->trans("MyDashboard"), 0, 1, '', $mainmenu, 'home', 0, '', '', '', '<i class="fa fa-bar-chart fa-fw paddingright"></i>');
632
                $newmenu->add(BASE_URI . "?controller=home&method=home&mainmenu=home&leftmenu=home", Globals::$langs->trans("MyDashboard"), 0, 1, '', $mainmenu, 'home', 0, '', '', '', '<i class="fa fa-bar-chart fa-fw paddingright"></i>');
633
634
// Setup
635
//$newmenu->add("/admin/index.php?mainmenu=home&leftmenu=setup", Globals::$langs->trans("Setup"), 0, Globals::$user->admin, '', $mainmenu, 'setup', 0, '', '', '', '<i class="fa fa-wrench fa-fw paddingright"></i>');
636
                $newmenu->add(BASE_URI . "?controller=admin&method=index&mainmenu=home&leftmenu=setup", Globals::$langs->trans("Setup"), 0, Globals::$user->admin, '', $mainmenu, 'setup', 0, '', '', '', '<i class="fa fa-wrench fa-fw paddingright"></i>');
637
638
                if ($usemenuhider || empty($leftmenu) || $leftmenu == "setup") {
639
// Load translation files required by the page
640
                    Globals::$langs->loadLangs(array("admin", "help"));
641
642
                    $warnpicto = '';
643
                    if (empty(Conf::$global->MAIN_INFO_SOCIETE_NOM) || empty(Conf::$global->MAIN_INFO_SOCIETE_COUNTRY)) {
644
                        Globals::$langs->load("errors");
645
                        $warnpicto = ' ' . img_warning(Globals::$langs->trans("WarningMandatorySetupNotComplete"));
646
                    }
647
//$newmenu->add("/admin/company.php?mainmenu=home", Globals::$langs->trans("MenuCompanySetup") . $warnpicto, 1);
648
                    $newmenu->add(BASE_URI . "?controller=admin&method=company&mainmenu=home", Globals::$langs->trans("MenuCompanySetup") . $warnpicto, 1);
649
                    $warnpicto = '';
650
                    if (count($conf->modules) <= (empty(Conf::$global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING) ? 1 : Conf::$global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) { // If only user module enabled
651
                        Globals::$langs->load("errors");
652
                        $warnpicto = ' ' . img_warning(Globals::$langs->trans("WarningMandatorySetupNotComplete"));
653
                    }
654
                    /*
655
                      $newmenu->add("/admin/modules.php?mainmenu=home", Globals::$langs->trans("Modules") . $warnpicto, 1);
656
                      $newmenu->add("/admin/menus.php?mainmenu=home", Globals::$langs->trans("Menus"), 1);
657
                      $newmenu->add("/admin/ihm.php?mainmenu=home", Globals::$langs->trans("GUISetup"), 1);
658
659
                      $newmenu->add("/admin/translation.php?mainmenu=home", Globals::$langs->trans("Translation"), 1);
660
                      $newmenu->add("/admin/defaultvalues.php?mainmenu=home", Globals::$langs->trans("DefaultValues"), 1);
661
                      $newmenu->add("/admin/boxes.php?mainmenu=home", Globals::$langs->trans("Boxes"), 1);
662
                      $newmenu->add("/admin/delais.php?mainmenu=home", Globals::$langs->trans("MenuWarnings"), 1);
663
                      $newmenu->add("/admin/security_other.php?mainmenu=home", Globals::$langs->trans("Security"), 1);
664
                      $newmenu->add("/admin/limits.php?mainmenu=home", Globals::$langs->trans("MenuLimits"), 1);
665
                      $newmenu->add("/admin/pdf.php?mainmenu=home", Globals::$langs->trans("PDF"), 1);
666
                      $newmenu->add("/admin/mails.php?mainmenu=home", Globals::$langs->trans("Emails"), 1);
667
                      $newmenu->add("/admin/sms.php?mainmenu=home", Globals::$langs->trans("SMS"), 1);
668
                      $newmenu->add("/admin/dict.php?mainmenu=home", Globals::$langs->trans("Dictionary"), 1);
669
                      $newmenu->add("/admin/const.php?mainmenu=home", Globals::$langs->trans("OtherSetup"), 1);
670
                     */
671
                    $newmenu->add(BASE_URI . "?controller=admin&method=modules&mainmenu=home", Globals::$langs->trans("Modules") . $warnpicto, 1);
672
                    $newmenu->add(BASE_URI . "?controller=admin&method=menus&mainmenu=home", Globals::$langs->trans("Menus"), 1);
673
                    $newmenu->add(BASE_URI . "?controller=admin&method=ihm&mainmenu=home", Globals::$langs->trans("GUISetup"), 1);
674
675
                    $newmenu->add(BASE_URI . "?controller=admin&method=translation&mainmenu=home", Globals::$langs->trans("Translation"), 1);
676
                    $newmenu->add(BASE_URI . "?controller=admin&method=defaultvalues&mainmenu=home", Globals::$langs->trans("DefaultValues"), 1);
677
                    $newmenu->add(BASE_URI . "?controller=admin&method=boxes&mainmenu=home", Globals::$langs->trans("Boxes"), 1);
678
                    $newmenu->add(BASE_URI . "?controller=admin&method=delais&mainmenu=home", Globals::$langs->trans("MenuWarnings"), 1);
679
                    $newmenu->add(BASE_URI . "?controller=admin&method=security_other&mainmenu=home", Globals::$langs->trans("Security"), 1);
680
                    $newmenu->add(BASE_URI . "?controller=admin&method=limits&mainmenu=home", Globals::$langs->trans("MenuLimits"), 1);
681
                    $newmenu->add(BASE_URI . "?controller=admin&method=pdf&mainmenu=home", Globals::$langs->trans("PDF"), 1);
682
                    $newmenu->add(BASE_URI . "?controller=admin&method=mails&mainmenu=home", Globals::$langs->trans("Emails"), 1);
683
                    $newmenu->add(BASE_URI . "?controller=admin&method=sms&mainmenu=home", Globals::$langs->trans("SMS"), 1);
684
                    $newmenu->add(BASE_URI . "?controller=admin&method=dict&mainmenu=home", Globals::$langs->trans("Dictionary"), 1);
685
                    $newmenu->add(BASE_URI . "?controller=admin&method=const&mainmenu=home", Globals::$langs->trans("OtherSetup"), 1);
686
                }
687
688
// System tools
689
//$newmenu->add("/admin/tools/index.php?mainmenu=home&leftmenu=admintools", Globals::$langs->trans("AdminTools"), 0, Globals::$user->admin, '', $mainmenu, 'admintools', 0, '', '', '', '<i class="fa fa-server fa-fw paddingright"></i>');
690
                $newmenu->add(BASE_URI . "?controller=admin/tools&method=index&mainmenu=home&leftmenu=admintools", Globals::$langs->trans("AdminTools"), 0, Globals::$user->admin, '', $mainmenu, 'admintools', 0, '', '', '', '<i class="fa fa-server fa-fw paddingright"></i>');
691
692
                if ($usemenuhider || empty($leftmenu) || preg_match('/^admintools/', $leftmenu)) {
693
// Load translation files required by the page
694
                    Globals::$langs->loadLangs(array('admin', 'help'));
695
696
//$newmenu->add('/admin/system/dolibarr.php?mainmenu=home&leftmenu=admintools_info', Globals::$langs->trans('InfoDolibarr'), 1);
697
                    $newmenu->add(BASE_URI . "?controller=admin/system&method=dolibarr&mainmenu=home&leftmenu=admintools_info", Globals::$langs->trans('InfoDolibarr'), 1);
698
                    if ($usemenuhider || empty($leftmenu) || $leftmenu == 'admintools_info') {
699
                        /*
700
                          $newmenu->add('/admin/system/modules.php?mainmenu=home&leftmenu=admintools_info', Globals::$langs->trans('Modules'), 2);
701
                          $newmenu->add('/admin/triggers.php?mainmenu=home&leftmenu=admintools_info', Globals::$langs->trans('Triggers'), 2);
702
                          $newmenu->add('/admin/system/filecheck.php?mainmenu=home&leftmenu=admintools_info', Globals::$langs->trans('FileCheck'), 2);
703
                         */
704
                        $newmenu->add(BASE_URI . '?controller=admin/system&method=modules&mainmenu=home&leftmenu=admintools_info', Globals::$langs->trans('Modules'), 2);
705
                        $newmenu->add(BASE_URI . '?controller=admin&method=triggers&mainmenu=home&leftmenu=admintools_info', Globals::$langs->trans('Triggers'), 2);
706
                        $newmenu->add(BASE_URI . '?controller=admin/system&method=filecheck&mainmenu=home&leftmenu=admintools_info', Globals::$langs->trans('FileCheck'), 2);
707
                    }
708
                    /*
709
                      $newmenu->add('/admin/system/browser.php?mainmenu=home&leftmenu=admintools', Globals::$langs->trans('InfoBrowser'), 1);
710
                      $newmenu->add('/admin/system/os.php?mainmenu=home&leftmenu=admintools', Globals::$langs->trans('InfoOS'), 1);
711
                      $newmenu->add('/admin/system/web.php?mainmenu=home&leftmenu=admintools', Globals::$langs->trans('InfoWebServer'), 1);
712
                      $newmenu->add('/admin/system/phpinfo.php?mainmenu=home&leftmenu=admintools', Globals::$langs->trans('InfoPHP'), 1);
713
                      //if (function_exists('xdebug_is_enabled')) $newmenu->add('/admin/system/xdebug.php', Globals::$langs->trans('XDebug'),1);
714
                      $newmenu->add('/admin/system/database.php?mainmenu=home&leftmenu=admintools', Globals::$langs->trans('InfoDatabase'), 1);
715
                      if (function_exists('eaccelerator_info'))
716
                      $newmenu->add("/admin/tools/eaccelerator.php?mainmenu=home&leftmenu=admintools", Globals::$langs->trans("EAccelerator"), 1);
717
                      //$newmenu->add("/admin/system/perf.php?mainmenu=home&leftmenu=admintools", Globals::$langs->trans("InfoPerf"),1);
718
                      $newmenu->add("/admin/tools/dolibarr_export.php?mainmenu=home&leftmenu=admintools", Globals::$langs->trans("Backup"), 1);
719
                      $newmenu->add("/admin/tools/dolibarr_import.php?mainmenu=home&leftmenu=admintools", Globals::$langs->trans("Restore"), 1);
720
                      $newmenu->add("/admin/tools/update.php?mainmenu=home&leftmenu=admintools", Globals::$langs->trans("MenuUpgrade"), 1);
721
                      $newmenu->add("/admin/tools/purge.php?mainmenu=home&leftmenu=admintools", Globals::$langs->trans("Purge"), 1);
722
                      $newmenu->add("/admin/tools/listevents.php?mainmenu=home&leftmenu=admintools", Globals::$langs->trans("Audit"), 1);
723
                      $newmenu->add("/admin/tools/listsessions.php?mainmenu=home&leftmenu=admintools", Globals::$langs->trans("Sessions"), 1);
724
                      $newmenu->add('/admin/system/about.php?mainmenu=home&leftmenu=admintools', Globals::$langs->trans('ExternalResources'), 1);
725
                     */
726
                    $newmenu->add(BASE_URI . '?controller=admin/system&method=browser&mainmenu=home&leftmenu=admintools', Globals::$langs->trans('InfoBrowser'), 1);
727
                    $newmenu->add(BASE_URI . '?controller=admin/system&method=os&mainmenu=home&leftmenu=admintools', Globals::$langs->trans('InfoOS'), 1);
728
                    $newmenu->add(BASE_URI . '?controller=admin/system&method=web&mainmenu=home&leftmenu=admintools', Globals::$langs->trans('InfoWebServer'), 1);
729
                    $newmenu->add(BASE_URI . '?controller=admin/system&method=phpinfo&mainmenu=home&leftmenu=admintools', Globals::$langs->trans('InfoPHP'), 1);
730
//if (function_exists('xdebug_is_enabled')) $newmenu->add('/admin/system/xdebug.php', Globals::$langs->trans('XDebug'),1);
731
                    $newmenu->add(BASE_URI . '?controller=admin/system&method=database&mainmenu=home&leftmenu=admintools', Globals::$langs->trans('InfoDatabase'), 1);
732
                    if (function_exists('eaccelerator_info')) {
733
                        $newmenu->add(BASE_URI . "?controller=admin/tools&method=eaccelerator&mainmenu=home&leftmenu=admintools", Globals::$langs->trans("EAccelerator"), 1);
734
                    }
735
//$newmenu->add("/admin/system/perf.php?mainmenu=home&leftmenu=admintools", Globals::$langs->trans("InfoPerf"),1);
736
                    $newmenu->add(BASE_URI . "?controller=admin/tools&method=dolibarr_export&mainmenu=home&leftmenu=admintools", Globals::$langs->trans("Backup"), 1);
737
                    $newmenu->add(BASE_URI . "?controller=admin/tools&method=dolibarr_import&mainmenu=home&leftmenu=admintools", Globals::$langs->trans("Restore"), 1);
738
                    $newmenu->add(BASE_URI . "?controller=admin/tools&method=update&mainmenu=home&leftmenu=admintools", Globals::$langs->trans("MenuUpgrade"), 1);
739
                    $newmenu->add(BASE_URI . "?controller=admin/tools&method=purge&mainmenu=home&leftmenu=admintools", Globals::$langs->trans("Purge"), 1);
740
                    $newmenu->add(BASE_URI . "?controller=admin/tools&method=listevents&mainmenu=home&leftmenu=admintools", Globals::$langs->trans("Audit"), 1);
741
                    $newmenu->add(BASE_URI . "?controller=admin/tools&method=listsessions&mainmenu=home&leftmenu=admintools", Globals::$langs->trans("Sessions"), 1);
742
                    $newmenu->add(BASE_URI . '?controller=admin/system&method=about&mainmenu=home&leftmenu=admintools', Globals::$langs->trans('ExternalResources'), 1);
743
744
                    if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
745
                        Globals::$langs->load("products");
746
//$newmenu->add("/product/admin/product_tools.php?mainmenu=home&leftmenu=admintools", Globals::$langs->trans("ProductVatMassChange"), 1, Globals::$user->admin);
747
                        $newmenu->add(BASE_URI . "?controller=product/admin&method=product_tools&mainmenu=home&leftmenu=admintools", Globals::$langs->trans("ProductVatMassChange"), 1, Globals::$user->admin);
748
                    }
749
                }
750
751
//$newmenu->add("/user/home.php?leftmenu=users", Globals::$langs->trans("MenuUsersAndGroups"), 0, Globals::$user->rights->user->user->lire, '', $mainmenu, 'users', 0, '', '', '', '<i class="fa fa-users fa-fw paddingright"></i>');
752
                $newmenu->add(BASE_URI . "?controller=user&method=home&leftmenu=users", Globals::$langs->trans("MenuUsersAndGroups"), 0, Globals::$user->rights->user->user->lire, '', $mainmenu, 'users', 0, '', '', '', '<i class="fa fa-users fa-fw paddingright"></i>');
753
                if (Globals::$user->rights->user->user->lire) {
754
                    if ($usemenuhider || empty($leftmenu) || $leftmenu == "users") {
755
                        $newmenu->add("", Globals::$langs->trans("Users"), 1, Globals::$user->rights->user->user->lire || Globals::$user->admin);
756
                        /*
757
                          $newmenu->add("/user/card.php?leftmenu=users&action=create", Globals::$langs->trans("NewUser"), 2, (Globals::$user->rights->user->user->creer || Globals::$user->admin) && !(!empty($conf->multicompany->enabled) && $conf->entity > 1 && Conf::$global->MULTICOMPANY_TRANSVERSE_MODE), '', 'home');
758
                          $newmenu->add("/user/list.php?leftmenu=users", Globals::$langs->trans("ListOfUsers"), 2, Globals::$user->rights->user->user->lire || Globals::$user->admin);
759
                          $newmenu->add("/user/hierarchy.php?leftmenu=users", Globals::$langs->trans("HierarchicView"), 2, Globals::$user->rights->user->user->lire || Globals::$user->admin);
760
                          if (!empty($conf->categorie->enabled)) {
761
                          Globals::$langs->load("categories");
762
                          $newmenu->add("/categories/index.php?leftmenu=users&type=7", Globals::$langs->trans("UsersCategoriesShort"), 2, Globals::$user->rights->categorie->lire, '', $mainmenu, 'cat');
763
                          }
764
                          $newmenu->add("", Globals::$langs->trans("Groups"), 1, (Globals::$user->rights->user->user->lire || Globals::$user->admin) && !(!empty($conf->multicompany->enabled) && $conf->entity > 1 && Conf::$global->MULTICOMPANY_TRANSVERSE_MODE));
765
                          $newmenu->add("/user/group/card.php?leftmenu=users&action=create", Globals::$langs->trans("NewGroup"), 2, ((Conf::$global->MAIN_USE_ADVANCED_PERMS ? Globals::$user->rights->user->group_advance->write : Globals::$user->rights->user->user->creer) || Globals::$user->admin) && !(!empty($conf->multicompany->enabled) && $conf->entity > 1 && Conf::$global->MULTICOMPANY_TRANSVERSE_MODE));
766
                          $newmenu->add("/user/group/list.php?leftmenu=users", Globals::$langs->trans("ListOfGroups"), 2, ((Conf::$global->MAIN_USE_ADVANCED_PERMS ? Globals::$user->rights->user->group_advance->read : Globals::$user->rights->user->user->lire) || Globals::$user->admin) && !(!empty($conf->multicompany->enabled) && $conf->entity > 1 && Conf::$global->MULTICOMPANY_TRANSVERSE_MODE));
767
                         */
768
                        $newmenu->add(BASE_URI . "?controller=user&method=card&leftmenu=users&action=create", Globals::$langs->trans("NewUser"), 2, (Globals::$user->rights->user->user->creer || Globals::$user->admin) && !(!empty($conf->multicompany->enabled) && $conf->entity > 1 && Conf::$global->MULTICOMPANY_TRANSVERSE_MODE), '', 'home');
769
                        $newmenu->add(BASE_URI . "?controller=user&method=list&leftmenu=users", Globals::$langs->trans("ListOfUsers"), 2, Globals::$user->rights->user->user->lire || Globals::$user->admin);
770
                        $newmenu->add(BASE_URI . "?controller=user&method=hierarchy&leftmenu=users", Globals::$langs->trans("HierarchicView"), 2, Globals::$user->rights->user->user->lire || Globals::$user->admin);
771
                        if (!empty($conf->categorie->enabled)) {
772
                            Globals::$langs->load("categories");
773
                            $newmenu->add(BASE_URI . "?controller=categories&method=index&leftmenu=users&type=7", Globals::$langs->trans("UsersCategoriesShort"), 2, Globals::$user->rights->categorie->lire, '', $mainmenu, 'cat');
774
                        }
775
                        $newmenu->add("", Globals::$langs->trans("Groups"), 1, (Globals::$user->rights->user->user->lire || Globals::$user->admin) && !(!empty($conf->multicompany->enabled) && $conf->entity > 1 && Conf::$global->MULTICOMPANY_TRANSVERSE_MODE));
776
                        $newmenu->add(BASE_URI . "?controller=user/group&method=card&leftmenu=users&action=create", Globals::$langs->trans("NewGroup"), 2, ((Conf::$global->MAIN_USE_ADVANCED_PERMS ? Globals::$user->rights->user->group_advance->write : Globals::$user->rights->user->user->creer) || Globals::$user->admin) && !(!empty($conf->multicompany->enabled) && $conf->entity > 1 && Conf::$global->MULTICOMPANY_TRANSVERSE_MODE));
777
                        $newmenu->add(BASE_URI . "?controller=user/group&method=list&leftmenu=users", Globals::$langs->trans("ListOfGroups"), 2, ((Conf::$global->MAIN_USE_ADVANCED_PERMS ? Globals::$user->rights->user->group_advance->read : Globals::$user->rights->user->user->lire) || Globals::$user->admin) && !(!empty($conf->multicompany->enabled) && $conf->entity > 1 && Conf::$global->MULTICOMPANY_TRANSVERSE_MODE));
778
                    }
779
                }
780
            }
781
782
            /*
783
             * Menu THIRDPARTIES
784
             */
785
            if ($mainmenu == 'companies') {
786
// Societes
787
                if (!empty($conf->societe->enabled)) {
788
                    Globals::$langs->load("companies");
789
//$newmenu->add("/societe/index.php?leftmenu=thirdparties", Globals::$langs->trans("ThirdParty"), 0, Globals::$user->rights->societe->lire, '', $mainmenu, 'thirdparties');
790
                    $newmenu->add(BASE_URI . "?controller=societe&method=index&leftmenu=thirdparties", Globals::$langs->trans("ThirdParty"), 0, Globals::$user->rights->societe->lire, '', $mainmenu, 'thirdparties');
791
792
                    if (Globals::$user->rights->societe->creer) {
793
//$newmenu->add("/societe/card.php?action=create", Globals::$langs->trans("MenuNewThirdParty"), 1);
794
                        $newmenu->add(BASE_URI . "?controller=societe&method=card&action=create", Globals::$langs->trans("MenuNewThirdParty"), 1);
795
                        if (!$conf->use_javascript_ajax) {
796
//$newmenu->add("/societe/card.php?action=create&private=1", Globals::$langs->trans("MenuNewPrivateIndividual"), 1);
797
                            $newmenu->add(BASE_URI . "?controller=societe&method=card&action=create&private=1", Globals::$langs->trans("MenuNewPrivateIndividual"), 1);
798
                        }
799
                    }
800
                }
801
802
//$newmenu->add("/societe/list.php?leftmenu=thirdparties", Globals::$langs->trans("List"), 1);
803
                $newmenu->add(BASE_URI . "?controller=societe&method=list&leftmenu=thirdparties", Globals::$langs->trans("List"), 1);
804
805
// Prospects
806
                if (!empty($conf->societe->enabled) && empty(Conf::$global->SOCIETE_DISABLE_PROSPECTS)) {
807
                    Globals::$langs->load("commercial");
808
//$newmenu->add("/societe/list.php?type=p&leftmenu=prospects", Globals::$langs->trans("ListProspectsShort"), 1, Globals::$user->rights->societe->lire, '', $mainmenu, 'prospects');
809
                    $newmenu->add(BASE_URI . "?controller=societe&method=list&type=p&leftmenu=prospects", Globals::$langs->trans("ListProspectsShort"), 1, Globals::$user->rights->societe->lire, '', $mainmenu, 'prospects');
810
                    /* no more required, there is a filter that can do more
811
                      if ($usemenuhider || empty($leftmenu) || $leftmenu=="prospects") $newmenu->add("/societe/list.php?type=p&sortfield=s.datec&sortorder=desc&begin=&search_stcomm=-1", Globals::$langs->trans("LastProspectDoNotContact"), 2, Globals::$user->rights->societe->lire);
812
                      if ($usemenuhider || empty($leftmenu) || $leftmenu=="prospects") $newmenu->add("/societe/list.php?type=p&sortfield=s.datec&sortorder=desc&begin=&search_stcomm=0", Globals::$langs->trans("LastProspectNeverContacted"), 2, Globals::$user->rights->societe->lire);
813
                      if ($usemenuhider || empty($leftmenu) || $leftmenu=="prospects") $newmenu->add("/societe/list.php?type=p&sortfield=s.datec&sortorder=desc&begin=&search_stcomm=1", Globals::$langs->trans("LastProspectToContact"), 2, Globals::$user->rights->societe->lire);
814
                      if ($usemenuhider || empty($leftmenu) || $leftmenu=="prospects") $newmenu->add("/societe/list.php?type=p&sortfield=s.datec&sortorder=desc&begin=&search_stcomm=2", Globals::$langs->trans("LastProspectContactInProcess"), 2, Globals::$user->rights->societe->lire);
815
                      if ($usemenuhider || empty($leftmenu) || $leftmenu=="prospects") $newmenu->add("/societe/list.php?type=p&sortfield=s.datec&sortorder=desc&begin=&search_stcomm=3", Globals::$langs->trans("LastProspectContactDone"), 2, Globals::$user->rights->societe->lire);
816
                     */
817
//$newmenu->add("/societe/card.php?leftmenu=prospects&action=create&type=p", Globals::$langs->trans("MenuNewProspect"), 2, Globals::$user->rights->societe->creer);
818
                    $newmenu->add(BASE_URI . "?controller=societe&method=card&leftmenu=prospects&action=create&type=p", Globals::$langs->trans("MenuNewProspect"), 2, Globals::$user->rights->societe->creer);
819
//$newmenu->add("/contact/list.php?leftmenu=customers&type=p", Globals::$langs->trans("Contacts"), 2, Globals::$user->rights->societe->contact->lire);
820
                }
821
822
// Customers/Prospects
823
                if (!empty($conf->societe->enabled) && empty(Conf::$global->SOCIETE_DISABLE_CUSTOMERS)) {
824
                    Globals::$langs->load("commercial");
825
//$newmenu->add("/societe/list.php?type=c&leftmenu=customers", Globals::$langs->trans("ListCustomersShort"), 1, Globals::$user->rights->societe->lire, '', $mainmenu, 'customers');
826
                    $newmenu->add(BASE_URI . "?controller=societe&method=list&type=c&leftmenu=customers", Globals::$langs->trans("ListCustomersShort"), 1, Globals::$user->rights->societe->lire, '', $mainmenu, 'customers');
827
828
//$newmenu->add("/societe/card.php?leftmenu=customers&action=create&type=c", Globals::$langs->trans("MenuNewCustomer"), 2, Globals::$user->rights->societe->creer);
829
                    $newmenu->add(BASE_URI . "?controller=societe&method=card&leftmenu=customers&action=create&type=c", Globals::$langs->trans("MenuNewCustomer"), 2, Globals::$user->rights->societe->creer);
830
//$newmenu->add("/contact/list.php?leftmenu=customers&type=c", Globals::$langs->trans("Contacts"), 2, Globals::$user->rights->societe->contact->lire);
831
                }
832
833
// Suppliers
834
                if (!empty($conf->societe->enabled) && (!empty($conf->fournisseur->enabled) || !empty($conf->supplier_proposal->enabled))) {
835
                    Globals::$langs->load("suppliers");
836
//$newmenu->add("/societe/list.php?type=f&leftmenu=suppliers", Globals::$langs->trans("ListSuppliersShort"), 1, (Globals::$user->rights->fournisseur->lire || Globals::$user->rights->supplier_proposal->lire), '', $mainmenu, 'suppliers');
837
//$newmenu->add("/societe/card.php?leftmenu=suppliers&action=create&type=f", Globals::$langs->trans("MenuNewSupplier"), 2, Globals::$user->rights->societe->creer && (Globals::$user->rights->fournisseur->lire || Globals::$user->rights->supplier_proposal->lire));
838
                    $newmenu->add(BASE_URI . "?controller=societe&method=list&type=f&leftmenu=suppliers", Globals::$langs->trans("ListSuppliersShort"), 1, (Globals::$user->rights->fournisseur->lire || Globals::$user->rights->supplier_proposal->lire), '', $mainmenu, 'suppliers');
839
                    $newmenu->add(BASE_URI . "?controller=societe&method=card&leftmenu=suppliers&action=create&type=f", Globals::$langs->trans("MenuNewSupplier"), 2, Globals::$user->rights->societe->creer && (Globals::$user->rights->fournisseur->lire || Globals::$user->rights->supplier_proposal->lire));
840
                }
841
842
// Categories
843
                if (!empty($conf->categorie->enabled)) {
844
                    Globals::$langs->load("categories");
845
                    if (empty(Conf::$global->SOCIETE_DISABLE_PROSPECTS) || empty(Conf::$global->SOCIETE_DISABLE_CUSTOMERS)) {
846
// Categories prospects/customers
847
                        $menutoshow = Globals::$langs->trans("CustomersProspectsCategoriesShort");
848
                        if (!empty(Conf::$global->SOCIETE_DISABLE_PROSPECTS)) {
849
                            $menutoshow = Globals::$langs->trans("CustomersCategoriesShort");
850
                        }
851
                        if (!empty(Conf::$global->SOCIETE_DISABLE_CUSTOMERS)) {
852
                            $menutoshow = Globals::$langs->trans("ProspectsCategoriesShort");
853
                        }
854
//$newmenu->add("/categories/index.php?leftmenu=cat&type=2", $menutoshow, 1, Globals::$user->rights->categorie->lire, '', $mainmenu, 'cat');
855
                        $newmenu->add(BASE_URI . "?controller=categories&method=index&leftmenu=cat&type=2", $menutoshow, 1, Globals::$user->rights->categorie->lire, '', $mainmenu, 'cat');
856
                    }
857
// Categories suppliers
858
                    if (!empty($conf->fournisseur->enabled)) {
859
//$newmenu->add("/categories/index.php?leftmenu=catfournish&type=1", Globals::$langs->trans("SuppliersCategoriesShort"), 1, Globals::$user->rights->categorie->lire);
860
                        $newmenu->add(BASE_URI . "?controller=categories&method=index&leftmenu=catfournish&type=1", Globals::$langs->trans("SuppliersCategoriesShort"), 1, Globals::$user->rights->categorie->lire);
861
                    }
862
                }
863
864
// Contacts
865
//$newmenu->add("/societe/index.php?leftmenu=thirdparties", (!empty(Conf::$global->SOCIETE_ADDRESSES_MANAGEMENT) ? Globals::$langs->trans("Contacts") : Globals::$langs->trans("ContactsAddresses")), 0, Globals::$user->rights->societe->contact->lire, '', $mainmenu, 'contacts');
866
//$newmenu->add("/contact/card.php?leftmenu=contacts&action=create", (!empty(Conf::$global->SOCIETE_ADDRESSES_MANAGEMENT) ? Globals::$langs->trans("NewContact") : Globals::$langs->trans("NewContactAddress")), 1, Globals::$user->rights->societe->contact->creer);
867
//$newmenu->add("/contact/list.php?leftmenu=contacts", Globals::$langs->trans("List"), 1, Globals::$user->rights->societe->contact->lire);
868
                $newmenu->add(BASE_URI . "?controller=societe&method=index&leftmenu=thirdparties", (!empty(Conf::$global->SOCIETE_ADDRESSES_MANAGEMENT) ? Globals::$langs->trans("Contacts") : Globals::$langs->trans("ContactsAddresses")), 0, Globals::$user->rights->societe->contact->lire, '', $mainmenu, 'contacts');
869
                $newmenu->add(BASE_URI . "?controller=contact&method=card&leftmenu=contacts&action=create", (!empty(Conf::$global->SOCIETE_ADDRESSES_MANAGEMENT) ? Globals::$langs->trans("NewContact") : Globals::$langs->trans("NewContactAddress")), 1, Globals::$user->rights->societe->contact->creer);
870
                $newmenu->add(BASE_URI . "?controller=contact&method=list&leftmenu=contacts", Globals::$langs->trans("List"), 1, Globals::$user->rights->societe->contact->lire);
871
                if (empty(Conf::$global->SOCIETE_DISABLE_PROSPECTS)) {
872
//$newmenu->add("/contact/list.php?leftmenu=contacts&type=p", Globals::$langs->trans("Prospects"), 2, Globals::$user->rights->societe->contact->lire);
873
                    $newmenu->add(BASE_URI . "?controller=contact&method=list&leftmenu=contacts&type=p", Globals::$langs->trans("Prospects"), 2, Globals::$user->rights->societe->contact->lire);
874
                }
875
                if (empty(Conf::$global->SOCIETE_DISABLE_CUSTOMERS)) {
876
//$newmenu->add("/contact/list.php?leftmenu=contacts&type=c", Globals::$langs->trans("Customers"), 2, Globals::$user->rights->societe->contact->lire);
877
                    $newmenu->add(BASE_URI . "?controller=contact&method=list&leftmenu=contacts&type=c", Globals::$langs->trans("Customers"), 2, Globals::$user->rights->societe->contact->lire);
878
                }
879
                if (!empty($conf->fournisseur->enabled)) {
880
//$newmenu->add("/contact/list.php?leftmenu=contacts&type=f", Globals::$langs->trans("Suppliers"), 2, Globals::$user->rights->societe->contact->lire);
881
                    $newmenu->add(BASE_URI . "?controller=contact&method=list&leftmenu=contacts&type=f", Globals::$langs->trans("Suppliers"), 2, Globals::$user->rights->societe->contact->lire);
882
                }
883
//$newmenu->add("/contact/list.php?leftmenu=contacts&type=o", Globals::$langs->trans("ContactOthers"), 2, Globals::$user->rights->societe->contact->lire);
884
                $newmenu->add(BASE_URI . "?controller=contact&methos=list&leftmenu=contacts&type=o", Globals::$langs->trans("ContactOthers"), 2, Globals::$user->rights->societe->contact->lire);
885
//$newmenu->add("/contact/list.php?userid=Globals::$user->id", Globals::$langs->trans("MyContacts"), 1, Globals::$user->rights->societe->contact->lire);
886
// Categories
887
                if (!empty($conf->categorie->enabled)) {
888
                    Globals::$langs->load("categories");
889
// Categories Contact
890
//$newmenu->add("/categories/index.php?leftmenu=catcontact&type=4", Globals::$langs->trans("ContactCategoriesShort"), 1, Globals::$user->rights->categorie->lire, '', $mainmenu, 'cat');
891
                    $newmenu->add(BASE_URI . "?controller=categories&method=index&leftmenu=catcontact&type=4", Globals::$langs->trans("ContactCategoriesShort"), 1, Globals::$user->rights->categorie->lire, '', $mainmenu, 'cat');
892
                }
893
            }
894
895
            /*
896
             * Menu COMMERCIAL
897
             */
898
            if ($mainmenu == 'commercial') {
899
                Globals::$langs->load("companies");
900
901
// Customer proposal
902
                if (!empty($conf->propal->enabled)) {
903
                    Globals::$langs->load("propal");
904
//$newmenu->add("/comm/propal/index.php?leftmenu=propals", Globals::$langs->trans("Proposals"), 0, Globals::$user->rights->propale->lire, '', $mainmenu, 'propals', 100);
905
//$newmenu->add("/comm/propal/card.php?action=create&leftmenu=propals", Globals::$langs->trans("NewPropal"), 1, Globals::$user->rights->propale->creer);
906
//$newmenu->add("/comm/propal/list.php?leftmenu=propals", Globals::$langs->trans("List"), 1, Globals::$user->rights->propale->lire);
907
                    $newmenu->add(BASE_URI . "?controller=comm/propal&method=index&leftmenu=propals", Globals::$langs->trans("Proposals"), 0, Globals::$user->rights->propale->lire, '', $mainmenu, 'propals', 100);
908
                    $newmenu->add(BASE_URI . "?controller=comm/propal&method=card&action=create&leftmenu=propals", Globals::$langs->trans("NewPropal"), 1, Globals::$user->rights->propale->creer);
909
                    $newmenu->add(BASE_URI . "?controller=comm/propal&method=list&leftmenu=propals", Globals::$langs->trans("List"), 1, Globals::$user->rights->propale->lire);
910
                    if ($usemenuhider || empty($leftmenu) || $leftmenu == "propals") {
911
                        /*
912
                          $newmenu->add("/comm/propal/list.php?leftmenu=propals&viewstatut=0", Globals::$langs->trans("PropalsDraft"), 2, Globals::$user->rights->propale->lire);
913
                          $newmenu->add("/comm/propal/list.php?leftmenu=propals&viewstatut=1", Globals::$langs->trans("PropalsOpened"), 2, Globals::$user->rights->propale->lire);
914
                          $newmenu->add("/comm/propal/list.php?leftmenu=propals&viewstatut=2", Globals::$langs->trans("PropalStatusSigned"), 2, Globals::$user->rights->propale->lire);
915
                          $newmenu->add("/comm/propal/list.php?leftmenu=propals&viewstatut=3", Globals::$langs->trans("PropalStatusNotSigned"), 2, Globals::$user->rights->propale->lire);
916
                          $newmenu->add("/comm/propal/list.php?leftmenu=propals&viewstatut=4", Globals::$langs->trans("PropalStatusBilled"), 2, Globals::$user->rights->propale->lire);
917
                         */
918
                        $newmenu->add(BASE_URI . "?controller=comm/propal&method=list&leftmenu=propals&viewstatut=0", Globals::$langs->trans("PropalsDraft"), 2, Globals::$user->rights->propale->lire);
919
                        $newmenu->add(BASE_URI . "?controller=comm/propal&method=list&leftmenu=propals&viewstatut=1", Globals::$langs->trans("PropalsOpened"), 2, Globals::$user->rights->propale->lire);
920
                        $newmenu->add(BASE_URI . "?controller=comm/propal&method=list&leftmenu=propals&viewstatut=2", Globals::$langs->trans("PropalStatusSigned"), 2, Globals::$user->rights->propale->lire);
921
                        $newmenu->add(BASE_URI . "?controller=comm/propal&method=list&leftmenu=propals&viewstatut=3", Globals::$langs->trans("PropalStatusNotSigned"), 2, Globals::$user->rights->propale->lire);
922
                        $newmenu->add(BASE_URI . "?controller=comm/propal&method=list&leftmenu=propals&viewstatut=4", Globals::$langs->trans("PropalStatusBilled"), 2, Globals::$user->rights->propale->lire);
923
//$newmenu->add("/comm/propal/list.php?leftmenu=propals&viewstatut=2,3,4", Globals::$langs->trans("PropalStatusClosedShort"), 2, Globals::$user->rights->propale->lire);
924
                    }
925
//$newmenu->add("/comm/propal/stats/index.php?leftmenu=propals", Globals::$langs->trans("Statistics"), 1, Globals::$user->rights->propale->lire);
926
                    $newmenu->add(BASE_URI . "?controller=comm/propal/stats&method=index&leftmenu=propals", Globals::$langs->trans("Statistics"), 1, Globals::$user->rights->propale->lire);
927
                }
928
929
// Customers orders
930
                if (!empty($conf->commande->enabled)) {
931
                    Globals::$langs->load("orders");
932
//$newmenu->add("/commande/index.php?leftmenu=orders", Globals::$langs->trans("CustomersOrders"), 0, Globals::$user->rights->commande->lire, '', $mainmenu, 'orders', 200);
933
//$newmenu->add("/commande/card.php?action=create&leftmenu=orders", Globals::$langs->trans("NewOrder"), 1, Globals::$user->rights->commande->creer);
934
//$newmenu->add("/commande/list.php?leftmenu=orders", Globals::$langs->trans("List"), 1, Globals::$user->rights->commande->lire);
935
                    $newmenu->add(BASE_URI . "?controller=commande&method=index&leftmenu=orders", Globals::$langs->trans("CustomersOrders"), 0, Globals::$user->rights->commande->lire, '', $mainmenu, 'orders', 200);
936
                    $newmenu->add(BASE_URI . "?controller=commande&method=card&action=create&leftmenu=orders", Globals::$langs->trans("NewOrder"), 1, Globals::$user->rights->commande->creer);
937
                    $newmenu->add(BASE_URI . "?controller=commande&method=list&leftmenu=orders", Globals::$langs->trans("List"), 1, Globals::$user->rights->commande->lire);
938
                    if ($usemenuhider || empty($leftmenu) || $leftmenu == "orders") {
939
//$newmenu->add("/commande/list.php?leftmenu=orders&viewstatut=0", Globals::$langs->trans("StatusOrderDraftShort"), 2, Globals::$user->rights->commande->lire);
940
//$newmenu->add("/commande/list.php?leftmenu=orders&viewstatut=1", Globals::$langs->trans("StatusOrderValidated"), 2, Globals::$user->rights->commande->lire);
941
                        $newmenu->add(BASE_URI . "?controller=commande&method=list&leftmenu=orders&viewstatut=0", Globals::$langs->trans("StatusOrderDraftShort"), 2, Globals::$user->rights->commande->lire);
942
                        $newmenu->add(BASE_URI . "?controller=commande&method=list&leftmenu=orders&viewstatut=1", Globals::$langs->trans("StatusOrderValidated"), 2, Globals::$user->rights->commande->lire);
943
                        if (!empty($conf->expedition->enabled)) {
944
//$newmenu->add("/commande/list.php?leftmenu=orders&viewstatut=2", Globals::$langs->trans("StatusOrderSentShort"), 2, Globals::$user->rights->commande->lire);
945
                            $newmenu->add(BASE_URI . "?controller=commande&method=list&leftmenu=orders&viewstatut=2", Globals::$langs->trans("StatusOrderSentShort"), 2, Globals::$user->rights->commande->lire);
946
                        }
947
//$newmenu->add("/commande/list.php?leftmenu=orders&viewstatut=3", Globals::$langs->trans("StatusOrderDelivered"), 2, Globals::$user->rights->commande->lire);
948
                        $newmenu->add(BASE_URI . "?controller=commande&method=list&leftmenu=orders&viewstatut=3", Globals::$langs->trans("StatusOrderDelivered"), 2, Globals::$user->rights->commande->lire);
949
//$newmenu->add("/commande/list.php?leftmenu=orders&viewstatut=4", Globals::$langs->trans("StatusOrderProcessed"), 2, Globals::$user->rights->commande->lire);
950
//$newmenu->add("/commande/list.php?leftmenu=orders&viewstatut=-1", Globals::$langs->trans("StatusOrderCanceledShort"), 2, Globals::$user->rights->commande->lire);
951
                        $newmenu->add(BASE_URI . "?controller=commande&method=list&leftmenu=orders&viewstatut=-1", Globals::$langs->trans("StatusOrderCanceledShort"), 2, Globals::$user->rights->commande->lire);
952
                    }
953
//$newmenu->add("/commande/stats/index.php?leftmenu=orders", Globals::$langs->trans("Statistics"), 1, Globals::$user->rights->commande->lire);
954
                    $newmenu->add(BASE_URI . "?controller=commande/stats&method=index&leftmenu=orders", Globals::$langs->trans("Statistics"), 1, Globals::$user->rights->commande->lire);
955
                }
956
957
// Suppliers orders
958
                if (!empty($conf->supplier_order->enabled)) {
959
                    Globals::$langs->load("orders");
960
//$newmenu->add("/fourn/commande/index.php?leftmenu=orders_suppliers", Globals::$langs->trans("SuppliersOrders"), 0, Globals::$user->rights->fournisseur->commande->lire, '', $mainmenu, 'orders_suppliers', 400);
961
//$newmenu->add("/fourn/commande/card.php?action=create&leftmenu=orders_suppliers", Globals::$langs->trans("NewOrder"), 1, Globals::$user->rights->fournisseur->commande->creer);
962
//$newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers", Globals::$langs->trans("List"), 1, Globals::$user->rights->fournisseur->commande->lire);
963
                    $newmenu->add(BASE_URI . "?controller=fourn/commande&method=index&leftmenu=orders_suppliers", Globals::$langs->trans("SuppliersOrders"), 0, Globals::$user->rights->fournisseur->commande->lire, '', $mainmenu, 'orders_suppliers', 400);
964
                    $newmenu->add(BASE_URI . "?controller=fourn/commande&method=card&action=create&leftmenu=orders_suppliers", Globals::$langs->trans("NewOrder"), 1, Globals::$user->rights->fournisseur->commande->creer);
965
                    $newmenu->add(BASE_URI . "?controller=fourn/commande&method=list&leftmenu=orders_suppliers", Globals::$langs->trans("List"), 1, Globals::$user->rights->fournisseur->commande->lire);
966
967
                    if ($usemenuhider || empty($leftmenu) || $leftmenu == "orders_suppliers") {
968
//$newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=0", Globals::$langs->trans("StatusOrderDraftShort"), 2, Globals::$user->rights->fournisseur->commande->lire);
969
                        $newmenu->add(BASE_URI . "?controller=fourn/commande&method=list&leftmenu=orders_suppliers&statut=0", Globals::$langs->trans("StatusOrderDraftShort"), 2, Globals::$user->rights->fournisseur->commande->lire);
970
                        if (empty(Conf::$global->SUPPLIER_ORDER_HIDE_VALIDATED)) {
971
//$newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=1", Globals::$langs->trans("StatusOrderValidated"), 2, Globals::$user->rights->fournisseur->commande->lire);
972
                            $newmenu->add(BASE_URI . "?controller=fourn/commande&method=list&leftmenu=orders_suppliers&statut=1", Globals::$langs->trans("StatusOrderValidated"), 2, Globals::$user->rights->fournisseur->commande->lire);
973
                        }
974
                        /*
975
                          $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=2", Globals::$langs->trans("StatusOrderApprovedShort"), 2, Globals::$user->rights->fournisseur->commande->lire);
976
                          $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=3", Globals::$langs->trans("StatusOrderOnProcessShort"), 2, Globals::$user->rights->fournisseur->commande->lire);
977
                          $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=4", Globals::$langs->trans("StatusOrderReceivedPartiallyShort"), 2, Globals::$user->rights->fournisseur->commande->lire);
978
                          $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=5", Globals::$langs->trans("StatusOrderReceivedAll"), 2, Globals::$user->rights->fournisseur->commande->lire);
979
                          $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=6,7", Globals::$langs->trans("StatusOrderCanceled"), 2, Globals::$user->rights->fournisseur->commande->lire);
980
                          $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=9", Globals::$langs->trans("StatusOrderRefused"), 2, Globals::$user->rights->fournisseur->commande->lire);
981
                         */
982
                        $newmenu->add(BASE_URI . "?controller=fourn/commande&method=list&leftmenu=orders_suppliers&statut=2", Globals::$langs->trans("StatusOrderApprovedShort"), 2, Globals::$user->rights->fournisseur->commande->lire);
983
                        $newmenu->add(BASE_URI . "?controller=fourn/commande&method=list&leftmenu=orders_suppliers&statut=3", Globals::$langs->trans("StatusOrderOnProcessShort"), 2, Globals::$user->rights->fournisseur->commande->lire);
984
                        $newmenu->add(BASE_URI . "?controller=fourn/commande&method=list&leftmenu=orders_suppliers&statut=4", Globals::$langs->trans("StatusOrderReceivedPartiallyShort"), 2, Globals::$user->rights->fournisseur->commande->lire);
985
                        $newmenu->add(BASE_URI . "?controller=fourn/commande&method=list&leftmenu=orders_suppliers&statut=5", Globals::$langs->trans("StatusOrderReceivedAll"), 2, Globals::$user->rights->fournisseur->commande->lire);
986
                        $newmenu->add(BASE_URI . "?controller=fourn/commande&method=list&leftmenu=orders_suppliers&statut=6,7", Globals::$langs->trans("StatusOrderCanceled"), 2, Globals::$user->rights->fournisseur->commande->lire);
987
                        $newmenu->add(BASE_URI . "?controller=fourn/commande&method=list&leftmenu=orders_suppliers&statut=9", Globals::$langs->trans("StatusOrderRefused"), 2, Globals::$user->rights->fournisseur->commande->lire);
988
                    }
989
// 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", Globals::$langs->trans("StatusOrderBilled"), 2, Globals::$user->rights->fournisseur->commande->lire);
990
//$newmenu->add("/commande/stats/index.php?leftmenu=orders_suppliers&mode=supplier", Globals::$langs->trans("Statistics"), 1, Globals::$user->rights->fournisseur->commande->lire);
991
                    $newmenu->add(BASE_URI . "?controller=commande/stats&method=index&leftmenu=orders_suppliers&mode=supplier", Globals::$langs->trans("Statistics"), 1, Globals::$user->rights->fournisseur->commande->lire);
992
                }
993
994
// Contrat
995
                if (!empty($conf->contrat->enabled)) {
996
                    Globals::$langs->load("contracts");
997
                    /*
998
                      $newmenu->add("/contrat/index.php?leftmenu=contracts", Globals::$langs->trans("ContractsSubscriptions"), 0, Globals::$user->rights->contrat->lire, '', $mainmenu, 'contracts', 2000);
999
                      $newmenu->add("/contrat/card.php?action=create&leftmenu=contracts", Globals::$langs->trans("NewContractSubscription"), 1, Globals::$user->rights->contrat->creer);
1000
                      $newmenu->add("/contrat/list.php?leftmenu=contracts", Globals::$langs->trans("List"), 1, Globals::$user->rights->contrat->lire);
1001
                      $newmenu->add("/contrat/services_list.php?leftmenu=contracts", Globals::$langs->trans("MenuServices"), 1, Globals::$user->rights->contrat->lire);
1002
                     */
1003
                    $newmenu->add(BASE_URI . "?controller=contrat&method=index&leftmenu=contracts", Globals::$langs->trans("ContractsSubscriptions"), 0, Globals::$user->rights->contrat->lire, '', $mainmenu, 'contracts', 2000);
1004
                    $newmenu->add(BASE_URI . "?controller=contrat&method=card&action=create&leftmenu=contracts", Globals::$langs->trans("NewContractSubscription"), 1, Globals::$user->rights->contrat->creer);
1005
                    $newmenu->add(BASE_URI . "?controller=contrat&method=list&leftmenu=contracts", Globals::$langs->trans("List"), 1, Globals::$user->rights->contrat->lire);
1006
                    $newmenu->add(BASE_URI . "?controller=contrat&method=services_list&leftmenu=contracts", Globals::$langs->trans("MenuServices"), 1, Globals::$user->rights->contrat->lire);
1007
                    if ($usemenuhider || empty($leftmenu) || $leftmenu == "contracts") {
1008
                        /*
1009
                          $newmenu->add("/contrat/services_list.php?leftmenu=contracts&mode=0", Globals::$langs->trans("MenuInactiveServices"), 2, Globals::$user->rights->contrat->lire);
1010
                          $newmenu->add("/contrat/services_list.php?leftmenu=contracts&mode=4", Globals::$langs->trans("MenuRunningServices"), 2, Globals::$user->rights->contrat->lire);
1011
                          $newmenu->add("/contrat/services_list.php?leftmenu=contracts&mode=4&filter=expired", Globals::$langs->trans("MenuExpiredServices"), 2, Globals::$user->rights->contrat->lire);
1012
                          $newmenu->add("/contrat/services_list.php?leftmenu=contracts&mode=5", Globals::$langs->trans("MenuClosedServices"), 2, Globals::$user->rights->contrat->lire);
1013
                         */
1014
                        $newmenu->add(BASE_URI . "?controller=contrat&method=services_list&leftmenu=contracts&mode=0", Globals::$langs->trans("MenuInactiveServices"), 2, Globals::$user->rights->contrat->lire);
1015
                        $newmenu->add(BASE_URI . "?controller=contrat&method=services_list&leftmenu=contracts&mode=4", Globals::$langs->trans("MenuRunningServices"), 2, Globals::$user->rights->contrat->lire);
1016
                        $newmenu->add(BASE_URI . "?controller=contrat&method=services_list&leftmenu=contracts&mode=4&filter=expired", Globals::$langs->trans("MenuExpiredServices"), 2, Globals::$user->rights->contrat->lire);
1017
                        $newmenu->add(BASE_URI . "?controller=contrat&method=services_list&leftmenu=contracts&mode=5", Globals::$langs->trans("MenuClosedServices"), 2, Globals::$user->rights->contrat->lire);
1018
                    }
1019
                }
1020
1021
// Interventions
1022
                if (!empty($conf->ficheinter->enabled)) {
1023
                    Globals::$langs->load("interventions");
1024
                    /*
1025
                      $newmenu->add("/fichinter/index.php?leftmenu=ficheinter", Globals::$langs->trans("Interventions"), 0, Globals::$user->rights->ficheinter->lire, '', $mainmenu, 'ficheinter', 2200);
1026
                      $newmenu->add("/fichinter/card.php?action=create&leftmenu=ficheinter", Globals::$langs->trans("NewIntervention"), 1, Globals::$user->rights->ficheinter->creer, '', '', '', 201);
1027
                      $newmenu->add("/fichinter/list.php?leftmenu=ficheinter", Globals::$langs->trans("List"), 1, Globals::$user->rights->ficheinter->lire, '', '', '', 202);
1028
                      $newmenu->add("/fichinter/card-red.php?leftmenu=ficheinter", Globals::$langs->trans("ModelList"), 1, Globals::$user->rights->ficheinter->lire, '', '', '', 203);
1029
                      $newmenu->add("/fichinter/stats/index.php?leftmenu=ficheinter", Globals::$langs->trans("Statistics"), 1, Globals::$user->rights->fournisseur->commande->lire);
1030
                     */
1031
                    $newmenu->add(BASE_URI . "?controller=fichinter&method=index&leftmenu=ficheinter", Globals::$langs->trans("Interventions"), 0, Globals::$user->rights->ficheinter->lire, '', $mainmenu, 'ficheinter', 2200);
1032
                    $newmenu->add(BASE_URI . "?controller=fichinter&method=card&action=create&leftmenu=ficheinter", Globals::$langs->trans("NewIntervention"), 1, Globals::$user->rights->ficheinter->creer, '', '', '', 201);
1033
                    $newmenu->add(BASE_URI . "?controller=fichinter&method=list&leftmenu=ficheinter", Globals::$langs->trans("List"), 1, Globals::$user->rights->ficheinter->lire, '', '', '', 202);
1034
                    $newmenu->add(BASE_URI . "?controller=fichinter&method=card-red&leftmenu=ficheinter", Globals::$langs->trans("ModelList"), 1, Globals::$user->rights->ficheinter->lire, '', '', '', 203);
1035
                    $newmenu->add(BASE_URI . "?controller=fichinter/stats&method=index&leftmenu=ficheinter", Globals::$langs->trans("Statistics"), 1, Globals::$user->rights->fournisseur->commande->lire);
1036
                }
1037
            }
1038
1039
            /*
1040
             * Menu COMPTA-FINANCIAL
1041
             */
1042
            if ($mainmenu == 'billing') {
1043
                Globals::$langs->load("companies");
1044
1045
// Customers invoices
1046
                if (!empty($conf->facture->enabled)) {
1047
                    Globals::$langs->load("bills");
1048
                    /*
1049
                      $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills", Globals::$langs->trans("BillsCustomers"), 0, Globals::$user->rights->facture->lire, '', $mainmenu, 'customers_bills');
1050
                      $newmenu->add("/compta/facture/card.php?action=create", Globals::$langs->trans("NewBill"), 1, Globals::$user->rights->facture->creer);
1051
                      $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills", Globals::$langs->trans("List"), 1, Globals::$user->rights->facture->lire, '', $mainmenu, 'customers_bills_list');
1052
                     */
1053
                    $newmenu->add(BASE_URI . "?controller=compta/facture&method=list&leftmenu=customers_bills", Globals::$langs->trans("BillsCustomers"), 0, Globals::$user->rights->facture->lire, '', $mainmenu, 'customers_bills');
1054
                    $newmenu->add(BASE_URI . "?controller=compta/facture&method=card&action=create", Globals::$langs->trans("NewBill"), 1, Globals::$user->rights->facture->creer);
1055
                    $newmenu->add(BASE_URI . "?controller=compta/facture&method=list&leftmenu=customers_bills", Globals::$langs->trans("List"), 1, Globals::$user->rights->facture->lire, '', $mainmenu, 'customers_bills_list');
1056
1057
                    if ($usemenuhider || empty($leftmenu) || preg_match('/customers_bills(|_draft|_notpaid|_paid|_canceled)$/', $leftmenu)) {
1058
                        /*
1059
                          $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills_draft&search_status=0", Globals::$langs->trans("BillShortStatusDraft"), 2, Globals::$user->rights->facture->lire);
1060
                          $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills_notpaid&search_status=1", Globals::$langs->trans("BillShortStatusNotPaid"), 2, Globals::$user->rights->facture->lire);
1061
                          $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills_paid&search_status=2", Globals::$langs->trans("BillShortStatusPaid"), 2, Globals::$user->rights->facture->lire);
1062
                          $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills_canceled&search_status=3", Globals::$langs->trans("BillShortStatusCanceled"), 2, Globals::$user->rights->facture->lire);
1063
                         */
1064
                        $newmenu->add(BASE_URI . "?controller=compta/facture&method=list&leftmenu=customers_bills_draft&search_status=0", Globals::$langs->trans("BillShortStatusDraft"), 2, Globals::$user->rights->facture->lire);
1065
                        $newmenu->add(BASE_URI . "?controller=compta/facture&method=list&leftmenu=customers_bills_notpaid&search_status=1", Globals::$langs->trans("BillShortStatusNotPaid"), 2, Globals::$user->rights->facture->lire);
1066
                        $newmenu->add(BASE_URI . "?controller=compta/facture&method=list&leftmenu=customers_bills_paid&search_status=2", Globals::$langs->trans("BillShortStatusPaid"), 2, Globals::$user->rights->facture->lire);
1067
                        $newmenu->add(BASE_URI . "?controller=compta/facture&method=list&leftmenu=customers_bills_canceled&search_status=3", Globals::$langs->trans("BillShortStatusCanceled"), 2, Globals::$user->rights->facture->lire);
1068
                    }
1069
//$newmenu->add("/compta/facture/invoicetemplate_list.php?leftmenu=customers_bills_templates", Globals::$langs->trans("ListOfTemplates"), 1, Globals::$user->rights->facture->creer, '', $mainmenu, 'customers_bills_templates');    // No need to see recurring invoices, if user has no permission to create invoice.
1070
//$newmenu->add("/compta/paiement/list.php?leftmenu=customers_bills_payment", Globals::$langs->trans("Payments"), 1, Globals::$user->rights->facture->lire, '', $mainmenu, 'customers_bills_payment');
1071
                    $newmenu->add(BASE_URI . "?controller=compta/facture&method=invoicetemplate_list&leftmenu=customers_bills_templates", Globals::$langs->trans("ListOfTemplates"), 1, Globals::$user->rights->facture->creer, '', $mainmenu, 'customers_bills_templates');    // No need to see recurring invoices, if user has no permission to create invoice.
1072
                    $newmenu->add(BASE_URI . "?controller=compta/paiement&method=list&leftmenu=customers_bills_payment", Globals::$langs->trans("Payments"), 1, Globals::$user->rights->facture->lire, '', $mainmenu, 'customers_bills_payment');
1073
1074
                    if (!empty(Conf::$global->BILL_ADD_PAYMENT_VALIDATION)) {
1075
//$newmenu->add("/compta/paiement/tovalidate.php?leftmenu=customers_bills_tovalid", Globals::$langs->trans("MenuToValid"), 2, Globals::$user->rights->facture->lire, '', $mainmenu, 'customer_bills_tovalid');
1076
                        $newmenu->add(BASE_URI . "?controller=compta/paiement&method=tovalidate&leftmenu=customers_bills_tovalid", Globals::$langs->trans("MenuToValid"), 2, Globals::$user->rights->facture->lire, '', $mainmenu, 'customer_bills_tovalid');
1077
                    }
1078
//$newmenu->add("/compta/paiement/rapport.php?leftmenu=customers_bills_reports", Globals::$langs->trans("Reportings"), 2, Globals::$user->rights->facture->lire, '', $mainmenu, 'customers_bills_reports');
1079
//$newmenu->add("/compta/facture/stats/index.php?leftmenu=customers_bills_stats", Globals::$langs->trans("Statistics"), 1, Globals::$user->rights->facture->lire, '', $mainmenu, 'customers_bills_stats');
1080
                    $newmenu->add(BASE_URI . "?controller=compta/paiement&method=rapport&leftmenu=customers_bills_reports", Globals::$langs->trans("Reportings"), 2, Globals::$user->rights->facture->lire, '', $mainmenu, 'customers_bills_reports');
1081
                    $newmenu->add(BASE_URI . "?controller=compta/facture/stats&method=index&leftmenu=customers_bills_stats", Globals::$langs->trans("Statistics"), 1, Globals::$user->rights->facture->lire, '', $mainmenu, 'customers_bills_stats');
1082
                }
1083
1084
// Suppliers invoices
1085
                if (!empty($conf->societe->enabled) && !empty($conf->supplier_invoice->enabled)) {
1086
                    Globals::$langs->load("bills");
1087
//$newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills", Globals::$langs->trans("BillsSuppliers"), 0, Globals::$user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills');
1088
//$newmenu->add("/fourn/facture/card.php?leftmenu=suppliers_bills&action=create", Globals::$langs->trans("NewBill"), 1, Globals::$user->rights->fournisseur->facture->creer, '', $mainmenu, 'suppliers_bills_create');
1089
//$newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills", Globals::$langs->trans("List"), 1, Globals::$user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_list');
1090