@@ -85,7 +85,9 @@ discard block |
||
85 | 85 | |
86 | 86 | if ($mode == 'top') |
87 | 87 | { |
88 | - if (empty($noout)) print_start_menu_array_empty(); |
|
88 | + if (empty($noout)) { |
|
89 | + print_start_menu_array_empty(); |
|
90 | + } |
|
89 | 91 | |
90 | 92 | $usemenuhider = (GETPOST('testmenuhider','int') || ! empty($conf->global->MAIN_TESTMENUHIDER)); |
91 | 93 | |
@@ -113,16 +115,28 @@ discard block |
||
113 | 115 | // Output menu entries |
114 | 116 | foreach($this->menu->liste as $menkey => $menuval) |
115 | 117 | { |
116 | - if (empty($noout)) print_start_menu_entry_empty($menuval['idsel'],$menuval['classname'],$menuval['enabled']); |
|
117 | - if (empty($noout)) print_text_menu_entry_empty($menuval['titre'], $menuval['enabled'], ($menuval['url']!='#'?DOL_URL_ROOT:'').$menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target']?$menuval['target']:$atarget)); |
|
118 | - if (empty($noout)) print_end_menu_entry_empty($menuval['enabled']); |
|
118 | + if (empty($noout)) { |
|
119 | + print_start_menu_entry_empty($menuval['idsel'],$menuval['classname'],$menuval['enabled']); |
|
120 | + } |
|
121 | + if (empty($noout)) { |
|
122 | + print_text_menu_entry_empty($menuval['titre'], $menuval['enabled'], ($menuval['url']!='#'?DOL_URL_ROOT:'').$menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target']?$menuval['target']:$atarget)); |
|
123 | + } |
|
124 | + if (empty($noout)) { |
|
125 | + print_end_menu_entry_empty($menuval['enabled']); |
|
126 | + } |
|
119 | 127 | } |
120 | 128 | |
121 | 129 | $showmode=1; |
122 | - if (empty($noout)) print_start_menu_entry_empty('','class="tmenuend"',$showmode); |
|
123 | - if (empty($noout)) print_end_menu_entry_empty($showmode); |
|
130 | + if (empty($noout)) { |
|
131 | + print_start_menu_entry_empty('','class="tmenuend"',$showmode); |
|
132 | + } |
|
133 | + if (empty($noout)) { |
|
134 | + print_end_menu_entry_empty($showmode); |
|
135 | + } |
|
124 | 136 | |
125 | - if (empty($noout)) print_end_menu_array_empty(); |
|
137 | + if (empty($noout)) { |
|
138 | + print_end_menu_array_empty(); |
|
139 | + } |
|
126 | 140 | |
127 | 141 | if ($mode == 'jmobile') |
128 | 142 | { |
@@ -131,10 +145,12 @@ discard block |
||
131 | 145 | } |
132 | 146 | } |
133 | 147 | |
134 | - if ($mode == 'jmobile') // Used to get menu in xml ul/li |
|
148 | + if ($mode == 'jmobile') { |
|
149 | + // Used to get menu in xml ul/li |
|
135 | 150 | { |
136 | 151 | // Home |
137 | 152 | $showmode=1; |
153 | + } |
|
138 | 154 | $classname='class="tmenusel"'; |
139 | 155 | $idsel='home'; |
140 | 156 | |
@@ -145,9 +161,11 @@ discard block |
||
145 | 161 | //var_dump($this->menu->liste);exit; |
146 | 162 | $lastlevel = array(); |
147 | 163 | print '<!-- Generate menu list from menu handler '.$this->name.' -->'."\n"; |
148 | - foreach($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
164 | + foreach($this->menu->liste as $key => $val) { |
|
165 | + // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
149 | 166 | { |
150 | 167 | print '<ul class="ulmenu" data-inset="true">'; |
168 | + } |
|
151 | 169 | print '<li class="lilevel0">'; |
152 | 170 | |
153 | 171 | if ($val['enabled'] == 1) |
@@ -160,7 +178,9 @@ discard block |
||
160 | 178 | print '<a class="alilevel0" href="#">'; |
161 | 179 | |
162 | 180 | // Add font-awesome |
163 | - if ($val['level'] == 0 && $val['mainmenu'] == 'home') print '<span class="fa fa-home fa-fw paddingright" aria-hidden="true"></span>'; |
|
181 | + if ($val['level'] == 0 && $val['mainmenu'] == 'home') { |
|
182 | + print '<span class="fa fa-home fa-fw paddingright" aria-hidden="true"></span>'; |
|
183 | + } |
|
164 | 184 | |
165 | 185 | print $val['titre']; |
166 | 186 | print '</a>'."\n"; |
@@ -204,12 +224,16 @@ discard block |
||
204 | 224 | // We add sub entry |
205 | 225 | print str_pad('',1).'<li class="lilevel1 ui-btn-icon-right ui-btn">'; // ui-btn to highlight on clic |
206 | 226 | print '<a href="'.$relurl.'">'; |
207 | - if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") // No translation |
|
227 | + if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") { |
|
228 | + // No translation |
|
208 | 229 | { |
209 | 230 | if (in_array($val['mainmenu'], array('cashdesk', 'websites'))) print $langs->trans("Access"); |
210 | - else print $langs->trans("Dashboard"); |
|
231 | + } else { |
|
232 | + print $langs->trans("Dashboard"); |
|
233 | + } |
|
234 | + } else { |
|
235 | + print $langs->trans(ucfirst($val['mainmenu'])."Dashboard"); |
|
211 | 236 | } |
212 | - else print $langs->trans(ucfirst($val['mainmenu'])."Dashboard"); |
|
213 | 237 | print '</a>'; |
214 | 238 | print '</li>'."\n"; |
215 | 239 | } |
@@ -219,22 +243,26 @@ discard block |
||
219 | 243 | if ($val['enabled']) |
220 | 244 | { |
221 | 245 | $lastlevel[0]='enabled'; |
222 | - } |
|
223 | - else if ($showmenu) // Not enabled but visible (so greyed) |
|
246 | + } else if ($showmenu) { |
|
247 | + // Not enabled but visible (so greyed) |
|
224 | 248 | { |
225 | 249 | $lastlevel[0]='greyed'; |
226 | 250 | } |
227 | - else |
|
251 | + } else |
|
228 | 252 | { |
229 | 253 | $lastlevel[0]='hidden'; |
230 | 254 | } |
231 | 255 | } |
232 | 256 | |
233 | 257 | $lastlevel2 = array(); |
234 | - foreach($submenu->liste as $key2 => $val2) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
258 | + foreach($submenu->liste as $key2 => $val2) { |
|
259 | + // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
235 | 260 | { |
236 | 261 | $showmenu=true; |
237 | - if (! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($val2['enabled'])) $showmenu=false; |
|
262 | + } |
|
263 | + if (! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($val2['enabled'])) { |
|
264 | + $showmenu=false; |
|
265 | + } |
|
238 | 266 | |
239 | 267 | // If at least one parent is not enabled, we do not show any menu of all children |
240 | 268 | if ($val2['level'] > 0) |
@@ -242,19 +270,25 @@ discard block |
||
242 | 270 | $levelcursor = $val2['level']-1; |
243 | 271 | while ($levelcursor >= 0) |
244 | 272 | { |
245 | - if ($lastlevel2[$levelcursor] != 'enabled') $showmenu=false; |
|
273 | + if ($lastlevel2[$levelcursor] != 'enabled') { |
|
274 | + $showmenu=false; |
|
275 | + } |
|
246 | 276 | $levelcursor--; |
247 | 277 | } |
248 | 278 | } |
249 | 279 | |
250 | - if ($showmenu) // Visible (option to hide when not allowed is off or allowed) |
|
280 | + if ($showmenu) { |
|
281 | + // Visible (option to hide when not allowed is off or allowed) |
|
251 | 282 | { |
252 | 283 | $relurl2=dol_buildpath($val2['url'],1); |
284 | + } |
|
253 | 285 | $relurl2=preg_replace('/__LOGIN__/',$user->login,$relurl2); |
254 | 286 | $relurl2=preg_replace('/__USERID__/',$user->id,$relurl2); |
255 | 287 | $canonurl2=preg_replace('/\?.*$/','',$val2['url']); |
256 | 288 | //var_dump($val2['url'].' - '.$canonurl2.' - '.$val2['level']); |
257 | - if (in_array($canonurl2,array('/admin/index.php','/admin/tools/index.php','/core/tools.php'))) $relurl2=''; |
|
289 | + if (in_array($canonurl2,array('/admin/index.php','/admin/tools/index.php','/core/tools.php'))) { |
|
290 | + $relurl2=''; |
|
291 | + } |
|
258 | 292 | |
259 | 293 | $disabled=''; |
260 | 294 | if (! $val2['enabled']) |
@@ -264,30 +298,34 @@ discard block |
||
264 | 298 | |
265 | 299 | print str_pad('',$val2['level']+1); |
266 | 300 | print '<li class="lilevel'.($val2['level']+1); |
267 | - if ($val2['level']==0) print ' ui-btn-icon-right ui-btn'; // ui-btn to highlight on clic |
|
301 | + if ($val2['level']==0) { |
|
302 | + print ' ui-btn-icon-right ui-btn'; |
|
303 | + } |
|
304 | + // ui-btn to highlight on clic |
|
268 | 305 | print $disabled.'">'; // ui-btn to highlight on clic |
269 | 306 | if ($relurl2) |
270 | 307 | { |
271 | - if ($val2['enabled']) // Allowed |
|
308 | + if ($val2['enabled']) { |
|
309 | + // Allowed |
|
272 | 310 | { |
273 | 311 | print '<a href="'.$relurl2.'"'; |
312 | + } |
|
274 | 313 | //print ' data-ajax="false"'; |
275 | 314 | print '>'; |
276 | 315 | $lastlevel2[$val2['level']]='enabled'; |
277 | - } |
|
278 | - else // Not allowed but visible (greyed) |
|
316 | + } else // Not allowed but visible (greyed) |
|
279 | 317 | { |
280 | 318 | print '<a href="#" class="vsmenudisabled">'; |
281 | 319 | $lastlevel2[$val2['level']]='greyed'; |
282 | 320 | } |
283 | - } |
|
284 | - else |
|
321 | + } else |
|
285 | 322 | { |
286 | - if ($val2['enabled']) // Allowed |
|
323 | + if ($val2['enabled']) { |
|
324 | + // Allowed |
|
287 | 325 | { |
288 | 326 | $lastlevel2[$val2['level']]='enabled'; |
289 | 327 | } |
290 | - else |
|
328 | + } else |
|
291 | 329 | { |
292 | 330 | $lastlevel2[$val2['level']]='greyed'; |
293 | 331 | } |
@@ -297,10 +335,12 @@ discard block |
||
297 | 335 | print $val2['titre']; |
298 | 336 | if ($relurl2) |
299 | 337 | { |
300 | - if ($val2['enabled']) // Allowed |
|
338 | + if ($val2['enabled']) { |
|
339 | + // Allowed |
|
301 | 340 | print '</a>'; |
302 | - else |
|
303 | - print '</a>'; |
|
341 | + } else { |
|
342 | + print '</a>'; |
|
343 | + } |
|
304 | 344 | } |
305 | 345 | print '</li>'."\n"; |
306 | 346 | } |
@@ -361,15 +401,16 @@ discard block |
||
361 | 401 | $lastopened=true; |
362 | 402 | for($j = ($i + 1); $j < $num; $j++) |
363 | 403 | { |
364 | - if (empty($menu_array[$j]['level'])) $lastopened=false; |
|
404 | + if (empty($menu_array[$j]['level'])) { |
|
405 | + $lastopened=false; |
|
406 | + } |
|
365 | 407 | } |
366 | 408 | $alt = 0; // For menu manager "empty", we force to not have blockvmenufirst defined |
367 | 409 | $lastopened = 1; // For menu manager "empty", we force to not have blockvmenulast defined |
368 | 410 | if (($alt%2==0)) |
369 | 411 | { |
370 | 412 | print '<div class="blockvmenub lockvmenuimpair blockvmenuunique'.($lastopened?' blockvmenulast':'').($alt == 1 ? ' blockvmenufirst':'').'">'."\n"; |
371 | - } |
|
372 | - else |
|
413 | + } else |
|
373 | 414 | { |
374 | 415 | print '<div class="blockvmenu blockvmenupair blockvmenuunique'.($lastopened?' blockvmenulast':'').($alt == 1 ? ' blockvmenufirst':'').'">'."\n"; |
375 | 416 | } |
@@ -390,8 +431,7 @@ discard block |
||
390 | 431 | if ($this->menu->liste[$i]['enabled']) |
391 | 432 | { |
392 | 433 | print '<div class="menu_titre">'.$tabstring.'<a class="vmenu" href="'.dol_buildpath($this->menu->liste[$i]['url'],1).'"'.($this->menu->liste[$i]['target']?' target="'.$this->menu->liste[$i]['target'].'"':'').'>'.$this->menu->liste[$i]['titre'].'</a></div>'."\n"; |
393 | - } |
|
394 | - else |
|
434 | + } else |
|
395 | 435 | { |
396 | 436 | print '<div class="menu_titre">'.$tabstring.'<font class="vmenudisabled">'.$this->menu->liste[$i]['titre'].'</font></div>'."\n"; |
397 | 437 | } |
@@ -401,25 +441,34 @@ discard block |
||
401 | 441 | if ($this->menu->liste[$i]['level'] > 0) |
402 | 442 | { |
403 | 443 | $cssmenu = ''; |
404 | - if ($this->menu->liste[$i]['url']) $cssmenu = ' menu_contenu'.dol_string_nospecial(preg_replace('/\.php.*$/','',$this->menu->liste[$i]['url'])); |
|
444 | + if ($this->menu->liste[$i]['url']) { |
|
445 | + $cssmenu = ' menu_contenu'.dol_string_nospecial(preg_replace('/\.php.*$/','',$this->menu->liste[$i]['url'])); |
|
446 | + } |
|
405 | 447 | |
406 | 448 | print '<div class="menu_contenu'.$cssmenu.'">'; |
407 | 449 | |
408 | 450 | if ($this->menu->liste[$i]['enabled']) |
409 | 451 | { |
410 | 452 | print $tabstring; |
411 | - if ($this->menu->liste[$i]['url']) print '<a class="vsmenu" href="'.dol_buildpath($this->menu->liste[$i]['url'],1).'"'.($this->menu->liste[$i]['target']?' target="'.$this->menu->liste[$i]['target'].'"':'').'>'; |
|
412 | - else print '<span class="vsmenu">'; |
|
413 | - if ($this->menu->liste[$i]['url']) print $this->menu->liste[$i]['titre'].'</a>'; |
|
414 | - else print '</span>'; |
|
415 | - } |
|
416 | - else |
|
453 | + if ($this->menu->liste[$i]['url']) { |
|
454 | + print '<a class="vsmenu" href="'.dol_buildpath($this->menu->liste[$i]['url'],1).'"'.($this->menu->liste[$i]['target']?' target="'.$this->menu->liste[$i]['target'].'"':'').'>'; |
|
455 | + } else { |
|
456 | + print '<span class="vsmenu">'; |
|
457 | + } |
|
458 | + if ($this->menu->liste[$i]['url']) { |
|
459 | + print $this->menu->liste[$i]['titre'].'</a>'; |
|
460 | + } else { |
|
461 | + print '</span>'; |
|
462 | + } |
|
463 | + } else |
|
417 | 464 | { |
418 | 465 | print $tabstring.'<font class="vsmenudisabled vsmenudisabledmargin">'.$this->menu->liste[$i]['titre'].'</font>'; |
419 | 466 | } |
420 | 467 | |
421 | 468 | // If title is not pure text and contains a table, no carriage return added |
422 | - if (! strstr($this->menu->liste[$i]['titre'],'<table')) print '<br>'; |
|
469 | + if (! strstr($this->menu->liste[$i]['titre'],'<table')) { |
|
470 | + print '<br>'; |
|
471 | + } |
|
423 | 472 | print '</div>'."\n"; |
424 | 473 | } |
425 | 474 | |
@@ -431,7 +480,9 @@ discard block |
||
431 | 480 | } |
432 | 481 | } |
433 | 482 | |
434 | - if ($altok) print '<div class="blockvmenuend"></div>'; |
|
483 | + if ($altok) { |
|
484 | + print '<div class="blockvmenuend"></div>'; |
|
485 | + } |
|
435 | 486 | } |
436 | 487 | |
437 | 488 | if ($mode == 'jmobile') |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * Constructor |
38 | 38 | * |
39 | 39 | * @param DoliDB $db Database handler |
40 | - * @param int $type_user Type of user |
|
40 | + * @param int $type_user Type of user |
|
41 | 41 | */ |
42 | 42 | function __construct($db, $type_user) |
43 | 43 | { |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | /** |
61 | 61 | * Show menu |
62 | 62 | * |
63 | - * @param string $mode 'top', 'left', 'jmobile' |
|
64 | - * @param array $moredata An array with more data to output |
|
65 | - * @return int 0 or nb of top menu entries if $mode = 'topnb' |
|
63 | + * @param string $mode 'top', 'left', 'jmobile' |
|
64 | + * @param array $moredata An array with more data to output |
|
65 | + * @return int 0 or nb of top menu entries if $mode = 'topnb' |
|
66 | 66 | */ |
67 | 67 | function showmenu($mode, $moredata=null) |
68 | 68 | { |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | |
81 | 81 | if ($mode == 'topnb') |
82 | 82 | { |
83 | - return 1; |
|
83 | + return 1; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | if ($mode == 'top') |
@@ -92,11 +92,11 @@ discard block |
||
92 | 92 | // Show/Hide vertical menu |
93 | 93 | if ($mode != 'jmobile' && $mode != 'topnb' && $usemenuhider && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) |
94 | 94 | { |
95 | - $showmode=1; |
|
96 | - $classname = 'class="tmenu menuhider"'; |
|
97 | - $idsel='menu'; |
|
95 | + $showmode=1; |
|
96 | + $classname = 'class="tmenu menuhider"'; |
|
97 | + $idsel='menu'; |
|
98 | 98 | |
99 | - $this->menu->add('#', '', 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname); |
|
99 | + $this->menu->add('#', '', 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | // Home |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | // Output menu entries |
114 | 114 | foreach($this->menu->liste as $menkey => $menuval) |
115 | 115 | { |
116 | - if (empty($noout)) print_start_menu_entry_empty($menuval['idsel'],$menuval['classname'],$menuval['enabled']); |
|
117 | - if (empty($noout)) print_text_menu_entry_empty($menuval['titre'], $menuval['enabled'], ($menuval['url']!='#'?DOL_URL_ROOT:'').$menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target']?$menuval['target']:$atarget)); |
|
118 | - if (empty($noout)) print_end_menu_entry_empty($menuval['enabled']); |
|
116 | + if (empty($noout)) print_start_menu_entry_empty($menuval['idsel'],$menuval['classname'],$menuval['enabled']); |
|
117 | + if (empty($noout)) print_text_menu_entry_empty($menuval['titre'], $menuval['enabled'], ($menuval['url']!='#'?DOL_URL_ROOT:'').$menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target']?$menuval['target']:$atarget)); |
|
118 | + if (empty($noout)) print_end_menu_entry_empty($menuval['enabled']); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | $showmode=1; |
@@ -133,190 +133,190 @@ discard block |
||
133 | 133 | |
134 | 134 | if ($mode == 'jmobile') // Used to get menu in xml ul/li |
135 | 135 | { |
136 | - // Home |
|
137 | - $showmode=1; |
|
138 | - $classname='class="tmenusel"'; |
|
139 | - $idsel='home'; |
|
140 | - |
|
141 | - $this->menu->add('/index.php', $langs->trans("Home"), 0, $showmode, $this->atarget, 'home', '', 10, $id, $idsel, $classname); |
|
142 | - |
|
143 | - |
|
144 | - // $this->menu->liste is top menu |
|
145 | - //var_dump($this->menu->liste);exit; |
|
146 | - $lastlevel = array(); |
|
147 | - print '<!-- Generate menu list from menu handler '.$this->name.' -->'."\n"; |
|
148 | - foreach($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
149 | - { |
|
150 | - print '<ul class="ulmenu" data-inset="true">'; |
|
151 | - print '<li class="lilevel0">'; |
|
152 | - |
|
153 | - if ($val['enabled'] == 1) |
|
154 | - { |
|
155 | - $relurl=dol_buildpath($val['url'],1); |
|
156 | - $relurl=preg_replace('/__LOGIN__/',$user->login,$relurl); |
|
157 | - $relurl=preg_replace('/__USERID__/',$user->id,$relurl); |
|
158 | - $canonurl=preg_replace('/\?.*$/','',$val['url']); |
|
159 | - |
|
160 | - print '<a class="alilevel0" href="#">'; |
|
161 | - |
|
162 | - // Add font-awesome |
|
163 | - if ($val['level'] == 0 && $val['mainmenu'] == 'home') print '<span class="fa fa-home fa-fw paddingright" aria-hidden="true"></span>'; |
|
164 | - |
|
165 | - print $val['titre']; |
|
166 | - print '</a>'."\n"; |
|
167 | - |
|
168 | - // Search submenu fot this mainmenu entry |
|
169 | - $tmpmainmenu=$val['mainmenu']; |
|
170 | - $tmpleftmenu='all'; |
|
171 | - $submenu=new Menu(); |
|
172 | - |
|
173 | - $langs->load("admin"); // Load translation file admin.lang |
|
174 | - $submenu->add("/admin/index.php?leftmenu=setup", $langs->trans("Setup"),0); |
|
175 | - $submenu->add("/admin/company.php", $langs->trans("MenuCompanySetup"),1); |
|
176 | - $submenu->add("/admin/modules.php", $langs->trans("Modules"),1); |
|
177 | - $submenu->add("/admin/menus.php", $langs->trans("Menus"),1); |
|
178 | - $submenu->add("/admin/ihm.php", $langs->trans("GUISetup"),1); |
|
179 | - $submenu->add("/admin/translation.php?mainmenu=home", $langs->trans("Translation"),1); |
|
180 | - $submenu->add("/admin/defaultvalues.php?mainmenu=home", $langs->trans("DefaultValues"),1); |
|
181 | - |
|
182 | - $submenu->add("/admin/boxes.php", $langs->trans("Boxes"),1); |
|
183 | - $submenu->add("/admin/delais.php",$langs->trans("Alerts"),1); |
|
184 | - $submenu->add("/admin/proxy.php?mainmenu=home", $langs->trans("Security"),1); |
|
185 | - $submenu->add("/admin/limits.php?mainmenu=home", $langs->trans("MenuLimits"),1); |
|
186 | - $submenu->add("/admin/pdf.php?mainmenu=home", $langs->trans("PDF"),1); |
|
187 | - $submenu->add("/admin/mails.php?mainmenu=home", $langs->trans("Emails"),1); |
|
188 | - $submenu->add("/admin/sms.php?mainmenu=home", $langs->trans("SMS"),1); |
|
189 | - $submenu->add("/admin/dict.php?mainmenu=home", $langs->trans("DictionarySetup"),1); |
|
190 | - $submenu->add("/admin/const.php?mainmenu=home", $langs->trans("OtherSetup"),1); |
|
191 | - |
|
192 | - //if ($tmpmainmenu.'-'.$tmpleftmenu == 'home-all') { var_dump($submenu); exit; } |
|
193 | - //if ($tmpmainmenu=='accountancy') { var_dump($submenu->liste); exit; } |
|
194 | - $nexturl=dol_buildpath($submenu->liste[0]['url'],1); |
|
195 | - |
|
196 | - $canonrelurl=preg_replace('/\?.*$/','',$relurl); |
|
197 | - $canonnexturl=preg_replace('/\?.*$/','',$nexturl); |
|
198 | - //var_dump($canonrelurl); |
|
199 | - //var_dump($canonnexturl); |
|
200 | - print '<ul>'."\n"; |
|
201 | - if (($canonrelurl != $canonnexturl && ! in_array($val['mainmenu'],array('tools'))) |
|
202 | - || (strpos($canonrelurl,'/product/index.php') !== false || strpos($canonrelurl,'/compta/bank/list.php') !== false)) |
|
203 | - { |
|
204 | - // We add sub entry |
|
205 | - print str_pad('',1).'<li class="lilevel1 ui-btn-icon-right ui-btn">'; // ui-btn to highlight on clic |
|
206 | - print '<a href="'.$relurl.'">'; |
|
207 | - if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") // No translation |
|
208 | - { |
|
209 | - if (in_array($val['mainmenu'], array('cashdesk', 'websites'))) print $langs->trans("Access"); |
|
210 | - else print $langs->trans("Dashboard"); |
|
211 | - } |
|
212 | - else print $langs->trans(ucfirst($val['mainmenu'])."Dashboard"); |
|
213 | - print '</a>'; |
|
214 | - print '</li>'."\n"; |
|
215 | - } |
|
216 | - |
|
217 | - if ($val['level']==0) |
|
218 | - { |
|
219 | - if ($val['enabled']) |
|
220 | - { |
|
221 | - $lastlevel[0]='enabled'; |
|
222 | - } |
|
223 | - else if ($showmenu) // Not enabled but visible (so greyed) |
|
224 | - { |
|
225 | - $lastlevel[0]='greyed'; |
|
226 | - } |
|
227 | - else |
|
228 | - { |
|
229 | - $lastlevel[0]='hidden'; |
|
230 | - } |
|
231 | - } |
|
232 | - |
|
233 | - $lastlevel2 = array(); |
|
234 | - foreach($submenu->liste as $key2 => $val2) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
235 | - { |
|
236 | - $showmenu=true; |
|
237 | - if (! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($val2['enabled'])) $showmenu=false; |
|
238 | - |
|
239 | - // If at least one parent is not enabled, we do not show any menu of all children |
|
240 | - if ($val2['level'] > 0) |
|
241 | - { |
|
242 | - $levelcursor = $val2['level']-1; |
|
243 | - while ($levelcursor >= 0) |
|
244 | - { |
|
245 | - if ($lastlevel2[$levelcursor] != 'enabled') $showmenu=false; |
|
246 | - $levelcursor--; |
|
247 | - } |
|
248 | - } |
|
249 | - |
|
250 | - if ($showmenu) // Visible (option to hide when not allowed is off or allowed) |
|
251 | - { |
|
252 | - $relurl2=dol_buildpath($val2['url'],1); |
|
253 | - $relurl2=preg_replace('/__LOGIN__/',$user->login,$relurl2); |
|
254 | - $relurl2=preg_replace('/__USERID__/',$user->id,$relurl2); |
|
255 | - $canonurl2=preg_replace('/\?.*$/','',$val2['url']); |
|
256 | - //var_dump($val2['url'].' - '.$canonurl2.' - '.$val2['level']); |
|
257 | - if (in_array($canonurl2,array('/admin/index.php','/admin/tools/index.php','/core/tools.php'))) $relurl2=''; |
|
258 | - |
|
259 | - $disabled=''; |
|
260 | - if (! $val2['enabled']) |
|
261 | - { |
|
262 | - $disabled=" vsmenudisabled"; |
|
263 | - } |
|
264 | - |
|
265 | - print str_pad('',$val2['level']+1); |
|
266 | - print '<li class="lilevel'.($val2['level']+1); |
|
267 | - if ($val2['level']==0) print ' ui-btn-icon-right ui-btn'; // ui-btn to highlight on clic |
|
268 | - print $disabled.'">'; // ui-btn to highlight on clic |
|
269 | - if ($relurl2) |
|
270 | - { |
|
271 | - if ($val2['enabled']) // Allowed |
|
272 | - { |
|
273 | - print '<a href="'.$relurl2.'"'; |
|
274 | - //print ' data-ajax="false"'; |
|
275 | - print '>'; |
|
276 | - $lastlevel2[$val2['level']]='enabled'; |
|
277 | - } |
|
278 | - else // Not allowed but visible (greyed) |
|
279 | - { |
|
280 | - print '<a href="#" class="vsmenudisabled">'; |
|
281 | - $lastlevel2[$val2['level']]='greyed'; |
|
282 | - } |
|
283 | - } |
|
284 | - else |
|
285 | - { |
|
286 | - if ($val2['enabled']) // Allowed |
|
287 | - { |
|
288 | - $lastlevel2[$val2['level']]='enabled'; |
|
289 | - } |
|
290 | - else |
|
291 | - { |
|
292 | - $lastlevel2[$val2['level']]='greyed'; |
|
293 | - } |
|
294 | - } |
|
295 | - //var_dump($val2['level']); |
|
296 | - //var_dump($lastlevel2); |
|
297 | - print $val2['titre']; |
|
298 | - if ($relurl2) |
|
299 | - { |
|
300 | - if ($val2['enabled']) // Allowed |
|
301 | - print '</a>'; |
|
302 | - else |
|
303 | - print '</a>'; |
|
304 | - } |
|
305 | - print '</li>'."\n"; |
|
306 | - } |
|
307 | - |
|
308 | - |
|
309 | - } |
|
310 | - //var_dump($submenu); |
|
311 | - print '</ul>'; |
|
312 | - } |
|
313 | - if ($val['enabled'] == 2) |
|
314 | - { |
|
315 | - print '<font class="vsmenudisabled">'.$val['titre'].'</font>'; |
|
316 | - } |
|
317 | - print '</li>'; |
|
318 | - print '</ul>'."\n"; |
|
319 | - } |
|
136 | + // Home |
|
137 | + $showmode=1; |
|
138 | + $classname='class="tmenusel"'; |
|
139 | + $idsel='home'; |
|
140 | + |
|
141 | + $this->menu->add('/index.php', $langs->trans("Home"), 0, $showmode, $this->atarget, 'home', '', 10, $id, $idsel, $classname); |
|
142 | + |
|
143 | + |
|
144 | + // $this->menu->liste is top menu |
|
145 | + //var_dump($this->menu->liste);exit; |
|
146 | + $lastlevel = array(); |
|
147 | + print '<!-- Generate menu list from menu handler '.$this->name.' -->'."\n"; |
|
148 | + foreach($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
149 | + { |
|
150 | + print '<ul class="ulmenu" data-inset="true">'; |
|
151 | + print '<li class="lilevel0">'; |
|
152 | + |
|
153 | + if ($val['enabled'] == 1) |
|
154 | + { |
|
155 | + $relurl=dol_buildpath($val['url'],1); |
|
156 | + $relurl=preg_replace('/__LOGIN__/',$user->login,$relurl); |
|
157 | + $relurl=preg_replace('/__USERID__/',$user->id,$relurl); |
|
158 | + $canonurl=preg_replace('/\?.*$/','',$val['url']); |
|
159 | + |
|
160 | + print '<a class="alilevel0" href="#">'; |
|
161 | + |
|
162 | + // Add font-awesome |
|
163 | + if ($val['level'] == 0 && $val['mainmenu'] == 'home') print '<span class="fa fa-home fa-fw paddingright" aria-hidden="true"></span>'; |
|
164 | + |
|
165 | + print $val['titre']; |
|
166 | + print '</a>'."\n"; |
|
167 | + |
|
168 | + // Search submenu fot this mainmenu entry |
|
169 | + $tmpmainmenu=$val['mainmenu']; |
|
170 | + $tmpleftmenu='all'; |
|
171 | + $submenu=new Menu(); |
|
172 | + |
|
173 | + $langs->load("admin"); // Load translation file admin.lang |
|
174 | + $submenu->add("/admin/index.php?leftmenu=setup", $langs->trans("Setup"),0); |
|
175 | + $submenu->add("/admin/company.php", $langs->trans("MenuCompanySetup"),1); |
|
176 | + $submenu->add("/admin/modules.php", $langs->trans("Modules"),1); |
|
177 | + $submenu->add("/admin/menus.php", $langs->trans("Menus"),1); |
|
178 | + $submenu->add("/admin/ihm.php", $langs->trans("GUISetup"),1); |
|
179 | + $submenu->add("/admin/translation.php?mainmenu=home", $langs->trans("Translation"),1); |
|
180 | + $submenu->add("/admin/defaultvalues.php?mainmenu=home", $langs->trans("DefaultValues"),1); |
|
181 | + |
|
182 | + $submenu->add("/admin/boxes.php", $langs->trans("Boxes"),1); |
|
183 | + $submenu->add("/admin/delais.php",$langs->trans("Alerts"),1); |
|
184 | + $submenu->add("/admin/proxy.php?mainmenu=home", $langs->trans("Security"),1); |
|
185 | + $submenu->add("/admin/limits.php?mainmenu=home", $langs->trans("MenuLimits"),1); |
|
186 | + $submenu->add("/admin/pdf.php?mainmenu=home", $langs->trans("PDF"),1); |
|
187 | + $submenu->add("/admin/mails.php?mainmenu=home", $langs->trans("Emails"),1); |
|
188 | + $submenu->add("/admin/sms.php?mainmenu=home", $langs->trans("SMS"),1); |
|
189 | + $submenu->add("/admin/dict.php?mainmenu=home", $langs->trans("DictionarySetup"),1); |
|
190 | + $submenu->add("/admin/const.php?mainmenu=home", $langs->trans("OtherSetup"),1); |
|
191 | + |
|
192 | + //if ($tmpmainmenu.'-'.$tmpleftmenu == 'home-all') { var_dump($submenu); exit; } |
|
193 | + //if ($tmpmainmenu=='accountancy') { var_dump($submenu->liste); exit; } |
|
194 | + $nexturl=dol_buildpath($submenu->liste[0]['url'],1); |
|
195 | + |
|
196 | + $canonrelurl=preg_replace('/\?.*$/','',$relurl); |
|
197 | + $canonnexturl=preg_replace('/\?.*$/','',$nexturl); |
|
198 | + //var_dump($canonrelurl); |
|
199 | + //var_dump($canonnexturl); |
|
200 | + print '<ul>'."\n"; |
|
201 | + if (($canonrelurl != $canonnexturl && ! in_array($val['mainmenu'],array('tools'))) |
|
202 | + || (strpos($canonrelurl,'/product/index.php') !== false || strpos($canonrelurl,'/compta/bank/list.php') !== false)) |
|
203 | + { |
|
204 | + // We add sub entry |
|
205 | + print str_pad('',1).'<li class="lilevel1 ui-btn-icon-right ui-btn">'; // ui-btn to highlight on clic |
|
206 | + print '<a href="'.$relurl.'">'; |
|
207 | + if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") // No translation |
|
208 | + { |
|
209 | + if (in_array($val['mainmenu'], array('cashdesk', 'websites'))) print $langs->trans("Access"); |
|
210 | + else print $langs->trans("Dashboard"); |
|
211 | + } |
|
212 | + else print $langs->trans(ucfirst($val['mainmenu'])."Dashboard"); |
|
213 | + print '</a>'; |
|
214 | + print '</li>'."\n"; |
|
215 | + } |
|
216 | + |
|
217 | + if ($val['level']==0) |
|
218 | + { |
|
219 | + if ($val['enabled']) |
|
220 | + { |
|
221 | + $lastlevel[0]='enabled'; |
|
222 | + } |
|
223 | + else if ($showmenu) // Not enabled but visible (so greyed) |
|
224 | + { |
|
225 | + $lastlevel[0]='greyed'; |
|
226 | + } |
|
227 | + else |
|
228 | + { |
|
229 | + $lastlevel[0]='hidden'; |
|
230 | + } |
|
231 | + } |
|
232 | + |
|
233 | + $lastlevel2 = array(); |
|
234 | + foreach($submenu->liste as $key2 => $val2) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
235 | + { |
|
236 | + $showmenu=true; |
|
237 | + if (! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($val2['enabled'])) $showmenu=false; |
|
238 | + |
|
239 | + // If at least one parent is not enabled, we do not show any menu of all children |
|
240 | + if ($val2['level'] > 0) |
|
241 | + { |
|
242 | + $levelcursor = $val2['level']-1; |
|
243 | + while ($levelcursor >= 0) |
|
244 | + { |
|
245 | + if ($lastlevel2[$levelcursor] != 'enabled') $showmenu=false; |
|
246 | + $levelcursor--; |
|
247 | + } |
|
248 | + } |
|
249 | + |
|
250 | + if ($showmenu) // Visible (option to hide when not allowed is off or allowed) |
|
251 | + { |
|
252 | + $relurl2=dol_buildpath($val2['url'],1); |
|
253 | + $relurl2=preg_replace('/__LOGIN__/',$user->login,$relurl2); |
|
254 | + $relurl2=preg_replace('/__USERID__/',$user->id,$relurl2); |
|
255 | + $canonurl2=preg_replace('/\?.*$/','',$val2['url']); |
|
256 | + //var_dump($val2['url'].' - '.$canonurl2.' - '.$val2['level']); |
|
257 | + if (in_array($canonurl2,array('/admin/index.php','/admin/tools/index.php','/core/tools.php'))) $relurl2=''; |
|
258 | + |
|
259 | + $disabled=''; |
|
260 | + if (! $val2['enabled']) |
|
261 | + { |
|
262 | + $disabled=" vsmenudisabled"; |
|
263 | + } |
|
264 | + |
|
265 | + print str_pad('',$val2['level']+1); |
|
266 | + print '<li class="lilevel'.($val2['level']+1); |
|
267 | + if ($val2['level']==0) print ' ui-btn-icon-right ui-btn'; // ui-btn to highlight on clic |
|
268 | + print $disabled.'">'; // ui-btn to highlight on clic |
|
269 | + if ($relurl2) |
|
270 | + { |
|
271 | + if ($val2['enabled']) // Allowed |
|
272 | + { |
|
273 | + print '<a href="'.$relurl2.'"'; |
|
274 | + //print ' data-ajax="false"'; |
|
275 | + print '>'; |
|
276 | + $lastlevel2[$val2['level']]='enabled'; |
|
277 | + } |
|
278 | + else // Not allowed but visible (greyed) |
|
279 | + { |
|
280 | + print '<a href="#" class="vsmenudisabled">'; |
|
281 | + $lastlevel2[$val2['level']]='greyed'; |
|
282 | + } |
|
283 | + } |
|
284 | + else |
|
285 | + { |
|
286 | + if ($val2['enabled']) // Allowed |
|
287 | + { |
|
288 | + $lastlevel2[$val2['level']]='enabled'; |
|
289 | + } |
|
290 | + else |
|
291 | + { |
|
292 | + $lastlevel2[$val2['level']]='greyed'; |
|
293 | + } |
|
294 | + } |
|
295 | + //var_dump($val2['level']); |
|
296 | + //var_dump($lastlevel2); |
|
297 | + print $val2['titre']; |
|
298 | + if ($relurl2) |
|
299 | + { |
|
300 | + if ($val2['enabled']) // Allowed |
|
301 | + print '</a>'; |
|
302 | + else |
|
303 | + print '</a>'; |
|
304 | + } |
|
305 | + print '</li>'."\n"; |
|
306 | + } |
|
307 | + |
|
308 | + |
|
309 | + } |
|
310 | + //var_dump($submenu); |
|
311 | + print '</ul>'; |
|
312 | + } |
|
313 | + if ($val['enabled'] == 2) |
|
314 | + { |
|
315 | + print '<font class="vsmenudisabled">'.$val['titre'].'</font>'; |
|
316 | + } |
|
317 | + print '</li>'; |
|
318 | + print '</ul>'."\n"; |
|
319 | + } |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | if ($mode == 'left') |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | $this->menu->add("/admin/translation.php?mainmenu=home", $langs->trans("Translation"),1); |
334 | 334 | $this->menu->add("/admin/defaultvalues.php?mainmenu=home", $langs->trans("DefaultValues"),1); |
335 | 335 | |
336 | - $this->menu->add("/admin/boxes.php", $langs->trans("Boxes"),1); |
|
336 | + $this->menu->add("/admin/boxes.php", $langs->trans("Boxes"),1); |
|
337 | 337 | $this->menu->add("/admin/delais.php",$langs->trans("Alerts"),1); |
338 | 338 | $this->menu->add("/admin/proxy.php?mainmenu=home", $langs->trans("Security"),1); |
339 | 339 | $this->menu->add("/admin/limits.php?mainmenu=home", $langs->trans("MenuLimits"),1); |
@@ -356,15 +356,15 @@ discard block |
||
356 | 356 | $alt++; |
357 | 357 | if (empty($this->menu->liste[$i]['level'])) |
358 | 358 | { |
359 | - $altok++; |
|
360 | - $blockvmenuopened=true; |
|
359 | + $altok++; |
|
360 | + $blockvmenuopened=true; |
|
361 | 361 | $lastopened=true; |
362 | - for($j = ($i + 1); $j < $num; $j++) |
|
363 | - { |
|
364 | - if (empty($menu_array[$j]['level'])) $lastopened=false; |
|
365 | - } |
|
366 | - $alt = 0; // For menu manager "empty", we force to not have blockvmenufirst defined |
|
367 | - $lastopened = 1; // For menu manager "empty", we force to not have blockvmenulast defined |
|
362 | + for($j = ($i + 1); $j < $num; $j++) |
|
363 | + { |
|
364 | + if (empty($menu_array[$j]['level'])) $lastopened=false; |
|
365 | + } |
|
366 | + $alt = 0; // For menu manager "empty", we force to not have blockvmenufirst defined |
|
367 | + $lastopened = 1; // For menu manager "empty", we force to not have blockvmenulast defined |
|
368 | 368 | if (($alt%2==0)) |
369 | 369 | { |
370 | 370 | print '<div class="blockvmenub lockvmenuimpair blockvmenuunique'.($lastopened?' blockvmenulast':'').($alt == 1 ? ' blockvmenufirst':'').'">'."\n"; |
@@ -400,10 +400,10 @@ discard block |
||
400 | 400 | |
401 | 401 | if ($this->menu->liste[$i]['level'] > 0) |
402 | 402 | { |
403 | - $cssmenu = ''; |
|
404 | - if ($this->menu->liste[$i]['url']) $cssmenu = ' menu_contenu'.dol_string_nospecial(preg_replace('/\.php.*$/','',$this->menu->liste[$i]['url'])); |
|
403 | + $cssmenu = ''; |
|
404 | + if ($this->menu->liste[$i]['url']) $cssmenu = ' menu_contenu'.dol_string_nospecial(preg_replace('/\.php.*$/','',$this->menu->liste[$i]['url'])); |
|
405 | 405 | |
406 | - print '<div class="menu_contenu'.$cssmenu.'">'; |
|
406 | + print '<div class="menu_contenu'.$cssmenu.'">'; |
|
407 | 407 | |
408 | 408 | if ($this->menu->liste[$i]['enabled']) |
409 | 409 | { |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | */ |
509 | 509 | function print_start_menu_array_empty() |
510 | 510 | { |
511 | - global $conf; |
|
511 | + global $conf; |
|
512 | 512 | |
513 | 513 | print '<div class="tmenudiv">'; |
514 | 514 | print '<ul class="tmenu"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)?'':' title="Top menu"').'>'; |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | class MenuManager |
27 | 27 | { |
28 | 28 | var $db; |
29 | - var $type_user=0; // Put 0 for internal users, 1 for external users |
|
30 | - var $atarget=""; // To store default target to use onto links |
|
29 | + var $type_user = 0; // Put 0 for internal users, 1 for external users |
|
30 | + var $atarget = ""; // To store default target to use onto links |
|
31 | 31 | |
32 | 32 | var $menu; |
33 | 33 | var $menu_array_after; |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | */ |
42 | 42 | function __construct($db, $type_user) |
43 | 43 | { |
44 | - $this->type_user=$type_user; |
|
45 | - $this->db=$db; |
|
44 | + $this->type_user = $type_user; |
|
45 | + $this->db = $db; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
@@ -64,18 +64,18 @@ discard block |
||
64 | 64 | * @param array $moredata An array with more data to output |
65 | 65 | * @return int 0 or nb of top menu entries if $mode = 'topnb' |
66 | 66 | */ |
67 | - function showmenu($mode, $moredata=null) |
|
67 | + function showmenu($mode, $moredata = null) |
|
68 | 68 | { |
69 | - global $user,$conf,$langs,$dolibarr_main_db_name; |
|
69 | + global $user, $conf, $langs, $dolibarr_main_db_name; |
|
70 | 70 | |
71 | - $id='mainmenu'; |
|
71 | + $id = 'mainmenu'; |
|
72 | 72 | |
73 | 73 | require_once DOL_DOCUMENT_ROOT.'/core/class/menu.class.php'; |
74 | - $this->menu=new Menu(); |
|
74 | + $this->menu = new Menu(); |
|
75 | 75 | |
76 | - $res='ErrorBadParameterForMode'; |
|
76 | + $res = 'ErrorBadParameterForMode'; |
|
77 | 77 | |
78 | - $noout=0; |
|
78 | + $noout = 0; |
|
79 | 79 | //if ($mode == 'jmobile') $noout=1; |
80 | 80 | |
81 | 81 | if ($mode == 'topnb') |
@@ -87,22 +87,22 @@ discard block |
||
87 | 87 | { |
88 | 88 | if (empty($noout)) print_start_menu_array_empty(); |
89 | 89 | |
90 | - $usemenuhider = (GETPOST('testmenuhider','int') || ! empty($conf->global->MAIN_TESTMENUHIDER)); |
|
90 | + $usemenuhider = (GETPOST('testmenuhider', 'int') || !empty($conf->global->MAIN_TESTMENUHIDER)); |
|
91 | 91 | |
92 | 92 | // Show/Hide vertical menu |
93 | - if ($mode != 'jmobile' && $mode != 'topnb' && $usemenuhider && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) |
|
93 | + if ($mode != 'jmobile' && $mode != 'topnb' && $usemenuhider && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) |
|
94 | 94 | { |
95 | - $showmode=1; |
|
95 | + $showmode = 1; |
|
96 | 96 | $classname = 'class="tmenu menuhider"'; |
97 | - $idsel='menu'; |
|
97 | + $idsel = 'menu'; |
|
98 | 98 | |
99 | 99 | $this->menu->add('#', '', 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname); |
100 | 100 | } |
101 | 101 | |
102 | 102 | // Home |
103 | - $showmode=1; |
|
104 | - $classname='class="tmenusel"'; |
|
105 | - $idsel='home'; |
|
103 | + $showmode = 1; |
|
104 | + $classname = 'class="tmenusel"'; |
|
105 | + $idsel = 'home'; |
|
106 | 106 | |
107 | 107 | $this->menu->add('/index.php', $langs->trans("Home"), 0, $showmode, $this->atarget, 'home', '', 10, $id, $idsel, $classname); |
108 | 108 | |
@@ -111,15 +111,15 @@ discard block |
||
111 | 111 | $this->menu->liste = dol_sort_array($this->menu->liste, 'position'); |
112 | 112 | |
113 | 113 | // Output menu entries |
114 | - foreach($this->menu->liste as $menkey => $menuval) |
|
114 | + foreach ($this->menu->liste as $menkey => $menuval) |
|
115 | 115 | { |
116 | - if (empty($noout)) print_start_menu_entry_empty($menuval['idsel'],$menuval['classname'],$menuval['enabled']); |
|
117 | - if (empty($noout)) print_text_menu_entry_empty($menuval['titre'], $menuval['enabled'], ($menuval['url']!='#'?DOL_URL_ROOT:'').$menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target']?$menuval['target']:$atarget)); |
|
116 | + if (empty($noout)) print_start_menu_entry_empty($menuval['idsel'], $menuval['classname'], $menuval['enabled']); |
|
117 | + if (empty($noout)) print_text_menu_entry_empty($menuval['titre'], $menuval['enabled'], ($menuval['url'] != '#' ?DOL_URL_ROOT:'').$menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target'] ? $menuval['target'] : $atarget)); |
|
118 | 118 | if (empty($noout)) print_end_menu_entry_empty($menuval['enabled']); |
119 | 119 | } |
120 | 120 | |
121 | - $showmode=1; |
|
122 | - if (empty($noout)) print_start_menu_entry_empty('','class="tmenuend"',$showmode); |
|
121 | + $showmode = 1; |
|
122 | + if (empty($noout)) print_start_menu_entry_empty('', 'class="tmenuend"', $showmode); |
|
123 | 123 | if (empty($noout)) print_end_menu_entry_empty($showmode); |
124 | 124 | |
125 | 125 | if (empty($noout)) print_end_menu_array_empty(); |
@@ -134,9 +134,9 @@ discard block |
||
134 | 134 | if ($mode == 'jmobile') // Used to get menu in xml ul/li |
135 | 135 | { |
136 | 136 | // Home |
137 | - $showmode=1; |
|
138 | - $classname='class="tmenusel"'; |
|
139 | - $idsel='home'; |
|
137 | + $showmode = 1; |
|
138 | + $classname = 'class="tmenusel"'; |
|
139 | + $idsel = 'home'; |
|
140 | 140 | |
141 | 141 | $this->menu->add('/index.php', $langs->trans("Home"), 0, $showmode, $this->atarget, 'home', '', 10, $id, $idsel, $classname); |
142 | 142 | |
@@ -145,17 +145,17 @@ discard block |
||
145 | 145 | //var_dump($this->menu->liste);exit; |
146 | 146 | $lastlevel = array(); |
147 | 147 | print '<!-- Generate menu list from menu handler '.$this->name.' -->'."\n"; |
148 | - foreach($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
148 | + foreach ($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
149 | 149 | { |
150 | 150 | print '<ul class="ulmenu" data-inset="true">'; |
151 | 151 | print '<li class="lilevel0">'; |
152 | 152 | |
153 | 153 | if ($val['enabled'] == 1) |
154 | 154 | { |
155 | - $relurl=dol_buildpath($val['url'],1); |
|
156 | - $relurl=preg_replace('/__LOGIN__/',$user->login,$relurl); |
|
157 | - $relurl=preg_replace('/__USERID__/',$user->id,$relurl); |
|
158 | - $canonurl=preg_replace('/\?.*$/','',$val['url']); |
|
155 | + $relurl = dol_buildpath($val['url'], 1); |
|
156 | + $relurl = preg_replace('/__LOGIN__/', $user->login, $relurl); |
|
157 | + $relurl = preg_replace('/__USERID__/', $user->id, $relurl); |
|
158 | + $canonurl = preg_replace('/\?.*$/', '', $val['url']); |
|
159 | 159 | |
160 | 160 | print '<a class="alilevel0" href="#">'; |
161 | 161 | |
@@ -166,43 +166,43 @@ discard block |
||
166 | 166 | print '</a>'."\n"; |
167 | 167 | |
168 | 168 | // Search submenu fot this mainmenu entry |
169 | - $tmpmainmenu=$val['mainmenu']; |
|
170 | - $tmpleftmenu='all'; |
|
171 | - $submenu=new Menu(); |
|
172 | - |
|
173 | - $langs->load("admin"); // Load translation file admin.lang |
|
174 | - $submenu->add("/admin/index.php?leftmenu=setup", $langs->trans("Setup"),0); |
|
175 | - $submenu->add("/admin/company.php", $langs->trans("MenuCompanySetup"),1); |
|
176 | - $submenu->add("/admin/modules.php", $langs->trans("Modules"),1); |
|
177 | - $submenu->add("/admin/menus.php", $langs->trans("Menus"),1); |
|
178 | - $submenu->add("/admin/ihm.php", $langs->trans("GUISetup"),1); |
|
179 | - $submenu->add("/admin/translation.php?mainmenu=home", $langs->trans("Translation"),1); |
|
180 | - $submenu->add("/admin/defaultvalues.php?mainmenu=home", $langs->trans("DefaultValues"),1); |
|
181 | - |
|
182 | - $submenu->add("/admin/boxes.php", $langs->trans("Boxes"),1); |
|
183 | - $submenu->add("/admin/delais.php",$langs->trans("Alerts"),1); |
|
184 | - $submenu->add("/admin/proxy.php?mainmenu=home", $langs->trans("Security"),1); |
|
185 | - $submenu->add("/admin/limits.php?mainmenu=home", $langs->trans("MenuLimits"),1); |
|
186 | - $submenu->add("/admin/pdf.php?mainmenu=home", $langs->trans("PDF"),1); |
|
187 | - $submenu->add("/admin/mails.php?mainmenu=home", $langs->trans("Emails"),1); |
|
188 | - $submenu->add("/admin/sms.php?mainmenu=home", $langs->trans("SMS"),1); |
|
189 | - $submenu->add("/admin/dict.php?mainmenu=home", $langs->trans("DictionarySetup"),1); |
|
190 | - $submenu->add("/admin/const.php?mainmenu=home", $langs->trans("OtherSetup"),1); |
|
169 | + $tmpmainmenu = $val['mainmenu']; |
|
170 | + $tmpleftmenu = 'all'; |
|
171 | + $submenu = new Menu(); |
|
172 | + |
|
173 | + $langs->load("admin"); // Load translation file admin.lang |
|
174 | + $submenu->add("/admin/index.php?leftmenu=setup", $langs->trans("Setup"), 0); |
|
175 | + $submenu->add("/admin/company.php", $langs->trans("MenuCompanySetup"), 1); |
|
176 | + $submenu->add("/admin/modules.php", $langs->trans("Modules"), 1); |
|
177 | + $submenu->add("/admin/menus.php", $langs->trans("Menus"), 1); |
|
178 | + $submenu->add("/admin/ihm.php", $langs->trans("GUISetup"), 1); |
|
179 | + $submenu->add("/admin/translation.php?mainmenu=home", $langs->trans("Translation"), 1); |
|
180 | + $submenu->add("/admin/defaultvalues.php?mainmenu=home", $langs->trans("DefaultValues"), 1); |
|
181 | + |
|
182 | + $submenu->add("/admin/boxes.php", $langs->trans("Boxes"), 1); |
|
183 | + $submenu->add("/admin/delais.php", $langs->trans("Alerts"), 1); |
|
184 | + $submenu->add("/admin/proxy.php?mainmenu=home", $langs->trans("Security"), 1); |
|
185 | + $submenu->add("/admin/limits.php?mainmenu=home", $langs->trans("MenuLimits"), 1); |
|
186 | + $submenu->add("/admin/pdf.php?mainmenu=home", $langs->trans("PDF"), 1); |
|
187 | + $submenu->add("/admin/mails.php?mainmenu=home", $langs->trans("Emails"), 1); |
|
188 | + $submenu->add("/admin/sms.php?mainmenu=home", $langs->trans("SMS"), 1); |
|
189 | + $submenu->add("/admin/dict.php?mainmenu=home", $langs->trans("DictionarySetup"), 1); |
|
190 | + $submenu->add("/admin/const.php?mainmenu=home", $langs->trans("OtherSetup"), 1); |
|
191 | 191 | |
192 | 192 | //if ($tmpmainmenu.'-'.$tmpleftmenu == 'home-all') { var_dump($submenu); exit; } |
193 | 193 | //if ($tmpmainmenu=='accountancy') { var_dump($submenu->liste); exit; } |
194 | - $nexturl=dol_buildpath($submenu->liste[0]['url'],1); |
|
194 | + $nexturl = dol_buildpath($submenu->liste[0]['url'], 1); |
|
195 | 195 | |
196 | - $canonrelurl=preg_replace('/\?.*$/','',$relurl); |
|
197 | - $canonnexturl=preg_replace('/\?.*$/','',$nexturl); |
|
196 | + $canonrelurl = preg_replace('/\?.*$/', '', $relurl); |
|
197 | + $canonnexturl = preg_replace('/\?.*$/', '', $nexturl); |
|
198 | 198 | //var_dump($canonrelurl); |
199 | 199 | //var_dump($canonnexturl); |
200 | 200 | print '<ul>'."\n"; |
201 | - if (($canonrelurl != $canonnexturl && ! in_array($val['mainmenu'],array('tools'))) |
|
202 | - || (strpos($canonrelurl,'/product/index.php') !== false || strpos($canonrelurl,'/compta/bank/list.php') !== false)) |
|
201 | + if (($canonrelurl != $canonnexturl && !in_array($val['mainmenu'], array('tools'))) |
|
202 | + || (strpos($canonrelurl, '/product/index.php') !== false || strpos($canonrelurl, '/compta/bank/list.php') !== false)) |
|
203 | 203 | { |
204 | 204 | // We add sub entry |
205 | - print str_pad('',1).'<li class="lilevel1 ui-btn-icon-right ui-btn">'; // ui-btn to highlight on clic |
|
205 | + print str_pad('', 1).'<li class="lilevel1 ui-btn-icon-right ui-btn">'; // ui-btn to highlight on clic |
|
206 | 206 | print '<a href="'.$relurl.'">'; |
207 | 207 | if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") // No translation |
208 | 208 | { |
@@ -214,58 +214,58 @@ discard block |
||
214 | 214 | print '</li>'."\n"; |
215 | 215 | } |
216 | 216 | |
217 | - if ($val['level']==0) |
|
217 | + if ($val['level'] == 0) |
|
218 | 218 | { |
219 | 219 | if ($val['enabled']) |
220 | 220 | { |
221 | - $lastlevel[0]='enabled'; |
|
221 | + $lastlevel[0] = 'enabled'; |
|
222 | 222 | } |
223 | 223 | else if ($showmenu) // Not enabled but visible (so greyed) |
224 | 224 | { |
225 | - $lastlevel[0]='greyed'; |
|
225 | + $lastlevel[0] = 'greyed'; |
|
226 | 226 | } |
227 | 227 | else |
228 | 228 | { |
229 | - $lastlevel[0]='hidden'; |
|
229 | + $lastlevel[0] = 'hidden'; |
|
230 | 230 | } |
231 | 231 | } |
232 | 232 | |
233 | 233 | $lastlevel2 = array(); |
234 | - foreach($submenu->liste as $key2 => $val2) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
234 | + foreach ($submenu->liste as $key2 => $val2) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
235 | 235 | { |
236 | - $showmenu=true; |
|
237 | - if (! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($val2['enabled'])) $showmenu=false; |
|
236 | + $showmenu = true; |
|
237 | + if (!empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($val2['enabled'])) $showmenu = false; |
|
238 | 238 | |
239 | 239 | // If at least one parent is not enabled, we do not show any menu of all children |
240 | 240 | if ($val2['level'] > 0) |
241 | 241 | { |
242 | - $levelcursor = $val2['level']-1; |
|
242 | + $levelcursor = $val2['level'] - 1; |
|
243 | 243 | while ($levelcursor >= 0) |
244 | 244 | { |
245 | - if ($lastlevel2[$levelcursor] != 'enabled') $showmenu=false; |
|
245 | + if ($lastlevel2[$levelcursor] != 'enabled') $showmenu = false; |
|
246 | 246 | $levelcursor--; |
247 | 247 | } |
248 | 248 | } |
249 | 249 | |
250 | 250 | if ($showmenu) // Visible (option to hide when not allowed is off or allowed) |
251 | 251 | { |
252 | - $relurl2=dol_buildpath($val2['url'],1); |
|
253 | - $relurl2=preg_replace('/__LOGIN__/',$user->login,$relurl2); |
|
254 | - $relurl2=preg_replace('/__USERID__/',$user->id,$relurl2); |
|
255 | - $canonurl2=preg_replace('/\?.*$/','',$val2['url']); |
|
252 | + $relurl2 = dol_buildpath($val2['url'], 1); |
|
253 | + $relurl2 = preg_replace('/__LOGIN__/', $user->login, $relurl2); |
|
254 | + $relurl2 = preg_replace('/__USERID__/', $user->id, $relurl2); |
|
255 | + $canonurl2 = preg_replace('/\?.*$/', '', $val2['url']); |
|
256 | 256 | //var_dump($val2['url'].' - '.$canonurl2.' - '.$val2['level']); |
257 | - if (in_array($canonurl2,array('/admin/index.php','/admin/tools/index.php','/core/tools.php'))) $relurl2=''; |
|
257 | + if (in_array($canonurl2, array('/admin/index.php', '/admin/tools/index.php', '/core/tools.php'))) $relurl2 = ''; |
|
258 | 258 | |
259 | - $disabled=''; |
|
260 | - if (! $val2['enabled']) |
|
259 | + $disabled = ''; |
|
260 | + if (!$val2['enabled']) |
|
261 | 261 | { |
262 | - $disabled=" vsmenudisabled"; |
|
262 | + $disabled = " vsmenudisabled"; |
|
263 | 263 | } |
264 | 264 | |
265 | - print str_pad('',$val2['level']+1); |
|
266 | - print '<li class="lilevel'.($val2['level']+1); |
|
267 | - if ($val2['level']==0) print ' ui-btn-icon-right ui-btn'; // ui-btn to highlight on clic |
|
268 | - print $disabled.'">'; // ui-btn to highlight on clic |
|
265 | + print str_pad('', $val2['level'] + 1); |
|
266 | + print '<li class="lilevel'.($val2['level'] + 1); |
|
267 | + if ($val2['level'] == 0) print ' ui-btn-icon-right ui-btn'; // ui-btn to highlight on clic |
|
268 | + print $disabled.'">'; // ui-btn to highlight on clic |
|
269 | 269 | if ($relurl2) |
270 | 270 | { |
271 | 271 | if ($val2['enabled']) // Allowed |
@@ -273,23 +273,23 @@ discard block |
||
273 | 273 | print '<a href="'.$relurl2.'"'; |
274 | 274 | //print ' data-ajax="false"'; |
275 | 275 | print '>'; |
276 | - $lastlevel2[$val2['level']]='enabled'; |
|
276 | + $lastlevel2[$val2['level']] = 'enabled'; |
|
277 | 277 | } |
278 | 278 | else // Not allowed but visible (greyed) |
279 | 279 | { |
280 | 280 | print '<a href="#" class="vsmenudisabled">'; |
281 | - $lastlevel2[$val2['level']]='greyed'; |
|
281 | + $lastlevel2[$val2['level']] = 'greyed'; |
|
282 | 282 | } |
283 | 283 | } |
284 | 284 | else |
285 | 285 | { |
286 | 286 | if ($val2['enabled']) // Allowed |
287 | 287 | { |
288 | - $lastlevel2[$val2['level']]='enabled'; |
|
288 | + $lastlevel2[$val2['level']] = 'enabled'; |
|
289 | 289 | } |
290 | 290 | else |
291 | 291 | { |
292 | - $lastlevel2[$val2['level']]='greyed'; |
|
292 | + $lastlevel2[$val2['level']] = 'greyed'; |
|
293 | 293 | } |
294 | 294 | } |
295 | 295 | //var_dump($val2['level']); |
@@ -324,24 +324,24 @@ discard block |
||
324 | 324 | // Put here left menu entries |
325 | 325 | // ***** START ***** |
326 | 326 | |
327 | - $langs->load("admin"); // Load translation file admin.lang |
|
328 | - $this->menu->add("/admin/index.php?leftmenu=setup", $langs->trans("Setup"),0); |
|
329 | - $this->menu->add("/admin/company.php", $langs->trans("MenuCompanySetup"),1); |
|
330 | - $this->menu->add("/admin/modules.php", $langs->trans("Modules"),1); |
|
331 | - $this->menu->add("/admin/menus.php", $langs->trans("Menus"),1); |
|
332 | - $this->menu->add("/admin/ihm.php", $langs->trans("GUISetup"),1); |
|
333 | - $this->menu->add("/admin/translation.php?mainmenu=home", $langs->trans("Translation"),1); |
|
334 | - $this->menu->add("/admin/defaultvalues.php?mainmenu=home", $langs->trans("DefaultValues"),1); |
|
335 | - |
|
336 | - $this->menu->add("/admin/boxes.php", $langs->trans("Boxes"),1); |
|
337 | - $this->menu->add("/admin/delais.php",$langs->trans("Alerts"),1); |
|
338 | - $this->menu->add("/admin/proxy.php?mainmenu=home", $langs->trans("Security"),1); |
|
339 | - $this->menu->add("/admin/limits.php?mainmenu=home", $langs->trans("MenuLimits"),1); |
|
340 | - $this->menu->add("/admin/pdf.php?mainmenu=home", $langs->trans("PDF"),1); |
|
341 | - $this->menu->add("/admin/mails.php?mainmenu=home", $langs->trans("Emails"),1); |
|
342 | - $this->menu->add("/admin/sms.php?mainmenu=home", $langs->trans("SMS"),1); |
|
343 | - $this->menu->add("/admin/dict.php?mainmenu=home", $langs->trans("DictionarySetup"),1); |
|
344 | - $this->menu->add("/admin/const.php?mainmenu=home", $langs->trans("OtherSetup"),1); |
|
327 | + $langs->load("admin"); // Load translation file admin.lang |
|
328 | + $this->menu->add("/admin/index.php?leftmenu=setup", $langs->trans("Setup"), 0); |
|
329 | + $this->menu->add("/admin/company.php", $langs->trans("MenuCompanySetup"), 1); |
|
330 | + $this->menu->add("/admin/modules.php", $langs->trans("Modules"), 1); |
|
331 | + $this->menu->add("/admin/menus.php", $langs->trans("Menus"), 1); |
|
332 | + $this->menu->add("/admin/ihm.php", $langs->trans("GUISetup"), 1); |
|
333 | + $this->menu->add("/admin/translation.php?mainmenu=home", $langs->trans("Translation"), 1); |
|
334 | + $this->menu->add("/admin/defaultvalues.php?mainmenu=home", $langs->trans("DefaultValues"), 1); |
|
335 | + |
|
336 | + $this->menu->add("/admin/boxes.php", $langs->trans("Boxes"), 1); |
|
337 | + $this->menu->add("/admin/delais.php", $langs->trans("Alerts"), 1); |
|
338 | + $this->menu->add("/admin/proxy.php?mainmenu=home", $langs->trans("Security"), 1); |
|
339 | + $this->menu->add("/admin/limits.php?mainmenu=home", $langs->trans("MenuLimits"), 1); |
|
340 | + $this->menu->add("/admin/pdf.php?mainmenu=home", $langs->trans("PDF"), 1); |
|
341 | + $this->menu->add("/admin/mails.php?mainmenu=home", $langs->trans("Emails"), 1); |
|
342 | + $this->menu->add("/admin/sms.php?mainmenu=home", $langs->trans("SMS"), 1); |
|
343 | + $this->menu->add("/admin/dict.php?mainmenu=home", $langs->trans("DictionarySetup"), 1); |
|
344 | + $this->menu->add("/admin/const.php?mainmenu=home", $langs->trans("OtherSetup"), 1); |
|
345 | 345 | |
346 | 346 | // ***** END ***** |
347 | 347 | |
@@ -349,47 +349,47 @@ discard block |
||
349 | 349 | |
350 | 350 | if (empty($noout)) |
351 | 351 | { |
352 | - $alt=0; $altok=0; $blockvmenuopened=false; |
|
353 | - $num=count($this->menu->liste); |
|
352 | + $alt = 0; $altok = 0; $blockvmenuopened = false; |
|
353 | + $num = count($this->menu->liste); |
|
354 | 354 | for ($i = 0; $i < $num; $i++) |
355 | 355 | { |
356 | 356 | $alt++; |
357 | 357 | if (empty($this->menu->liste[$i]['level'])) |
358 | 358 | { |
359 | 359 | $altok++; |
360 | - $blockvmenuopened=true; |
|
361 | - $lastopened=true; |
|
362 | - for($j = ($i + 1); $j < $num; $j++) |
|
360 | + $blockvmenuopened = true; |
|
361 | + $lastopened = true; |
|
362 | + for ($j = ($i + 1); $j < $num; $j++) |
|
363 | 363 | { |
364 | - if (empty($menu_array[$j]['level'])) $lastopened=false; |
|
364 | + if (empty($menu_array[$j]['level'])) $lastopened = false; |
|
365 | 365 | } |
366 | - $alt = 0; // For menu manager "empty", we force to not have blockvmenufirst defined |
|
366 | + $alt = 0; // For menu manager "empty", we force to not have blockvmenufirst defined |
|
367 | 367 | $lastopened = 1; // For menu manager "empty", we force to not have blockvmenulast defined |
368 | - if (($alt%2==0)) |
|
368 | + if (($alt % 2 == 0)) |
|
369 | 369 | { |
370 | - print '<div class="blockvmenub lockvmenuimpair blockvmenuunique'.($lastopened?' blockvmenulast':'').($alt == 1 ? ' blockvmenufirst':'').'">'."\n"; |
|
370 | + print '<div class="blockvmenub lockvmenuimpair blockvmenuunique'.($lastopened ? ' blockvmenulast' : '').($alt == 1 ? ' blockvmenufirst' : '').'">'."\n"; |
|
371 | 371 | } |
372 | 372 | else |
373 | 373 | { |
374 | - print '<div class="blockvmenu blockvmenupair blockvmenuunique'.($lastopened?' blockvmenulast':'').($alt == 1 ? ' blockvmenufirst':'').'">'."\n"; |
|
374 | + print '<div class="blockvmenu blockvmenupair blockvmenuunique'.($lastopened ? ' blockvmenulast' : '').($alt == 1 ? ' blockvmenufirst' : '').'">'."\n"; |
|
375 | 375 | } |
376 | 376 | } |
377 | 377 | |
378 | 378 | // Add tabulation |
379 | - $tabstring=''; |
|
380 | - $tabul=($this->menu->liste[$i]['level'] - 1); |
|
379 | + $tabstring = ''; |
|
380 | + $tabul = ($this->menu->liste[$i]['level'] - 1); |
|
381 | 381 | if ($tabul > 0) |
382 | 382 | { |
383 | - for ($j=0; $j < $tabul; $j++) |
|
383 | + for ($j = 0; $j < $tabul; $j++) |
|
384 | 384 | { |
385 | - $tabstring.=' '; |
|
385 | + $tabstring .= ' '; |
|
386 | 386 | } |
387 | 387 | } |
388 | 388 | |
389 | 389 | if ($this->menu->liste[$i]['level'] == 0) { |
390 | 390 | if ($this->menu->liste[$i]['enabled']) |
391 | 391 | { |
392 | - print '<div class="menu_titre">'.$tabstring.'<a class="vmenu" href="'.dol_buildpath($this->menu->liste[$i]['url'],1).'"'.($this->menu->liste[$i]['target']?' target="'.$this->menu->liste[$i]['target'].'"':'').'>'.$this->menu->liste[$i]['titre'].'</a></div>'."\n"; |
|
392 | + print '<div class="menu_titre">'.$tabstring.'<a class="vmenu" href="'.dol_buildpath($this->menu->liste[$i]['url'], 1).'"'.($this->menu->liste[$i]['target'] ? ' target="'.$this->menu->liste[$i]['target'].'"' : '').'>'.$this->menu->liste[$i]['titre'].'</a></div>'."\n"; |
|
393 | 393 | } |
394 | 394 | else |
395 | 395 | { |
@@ -401,14 +401,14 @@ discard block |
||
401 | 401 | if ($this->menu->liste[$i]['level'] > 0) |
402 | 402 | { |
403 | 403 | $cssmenu = ''; |
404 | - if ($this->menu->liste[$i]['url']) $cssmenu = ' menu_contenu'.dol_string_nospecial(preg_replace('/\.php.*$/','',$this->menu->liste[$i]['url'])); |
|
404 | + if ($this->menu->liste[$i]['url']) $cssmenu = ' menu_contenu'.dol_string_nospecial(preg_replace('/\.php.*$/', '', $this->menu->liste[$i]['url'])); |
|
405 | 405 | |
406 | 406 | print '<div class="menu_contenu'.$cssmenu.'">'; |
407 | 407 | |
408 | 408 | if ($this->menu->liste[$i]['enabled']) |
409 | 409 | { |
410 | 410 | print $tabstring; |
411 | - if ($this->menu->liste[$i]['url']) print '<a class="vsmenu" href="'.dol_buildpath($this->menu->liste[$i]['url'],1).'"'.($this->menu->liste[$i]['target']?' target="'.$this->menu->liste[$i]['target'].'"':'').'>'; |
|
411 | + if ($this->menu->liste[$i]['url']) print '<a class="vsmenu" href="'.dol_buildpath($this->menu->liste[$i]['url'], 1).'"'.($this->menu->liste[$i]['target'] ? ' target="'.$this->menu->liste[$i]['target'].'"' : '').'>'; |
|
412 | 412 | else print '<span class="vsmenu">'; |
413 | 413 | if ($this->menu->liste[$i]['url']) print $this->menu->liste[$i]['titre'].'</a>'; |
414 | 414 | else print '</span>'; |
@@ -419,12 +419,12 @@ discard block |
||
419 | 419 | } |
420 | 420 | |
421 | 421 | // If title is not pure text and contains a table, no carriage return added |
422 | - if (! strstr($this->menu->liste[$i]['titre'],'<table')) print '<br>'; |
|
422 | + if (!strstr($this->menu->liste[$i]['titre'], '<table')) print '<br>'; |
|
423 | 423 | print '</div>'."\n"; |
424 | 424 | } |
425 | 425 | |
426 | 426 | // If next is a new block or end |
427 | - if (empty($this->menu->liste[$i+1]['level'])) |
|
427 | + if (empty($this->menu->liste[$i + 1]['level'])) |
|
428 | 428 | { |
429 | 429 | print '<div class="menu_end"></div>'."\n"; |
430 | 430 | print "</div>\n"; |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | global $conf; |
512 | 512 | |
513 | 513 | print '<div class="tmenudiv">'; |
514 | - print '<ul class="tmenu"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)?'':' title="Top menu"').'>'; |
|
514 | + print '<ul class="tmenu"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '' : ' title="Top menu"').'>'; |
|
515 | 515 | } |
516 | 516 | |
517 | 517 | /** |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | * @param int $showmode 0 = hide, 1 = allowed or 2 = not allowed |
523 | 523 | * @return void |
524 | 524 | */ |
525 | -function print_start_menu_entry_empty($idsel,$classname,$showmode) |
|
525 | +function print_start_menu_entry_empty($idsel, $classname, $showmode) |
|
526 | 526 | { |
527 | 527 | if ($showmode) |
528 | 528 | { |
@@ -545,14 +545,14 @@ discard block |
||
545 | 545 | */ |
546 | 546 | function print_text_menu_entry_empty($text, $showmode, $url, $id, $idsel, $classname, $atarget) |
547 | 547 | { |
548 | - global $conf,$langs; |
|
548 | + global $conf, $langs; |
|
549 | 549 | |
550 | 550 | if ($showmode == 1) |
551 | 551 | { |
552 | - print '<a class="tmenuimage" tabindex="-1" href="'.$url.'"'.($atarget?' target="'.$atarget.'"':'').'>'; |
|
552 | + print '<a class="tmenuimage" tabindex="-1" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').'>'; |
|
553 | 553 | print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>'; |
554 | 554 | print '</a>'; |
555 | - print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.$url.'"'.($atarget?' target="'.$atarget.'"':'').'>'; |
|
555 | + print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').'>'; |
|
556 | 556 | print '<span class="mainmenuaspan">'; |
557 | 557 | print $text; |
558 | 558 | print '</span>'; |
@@ -58,11 +58,11 @@ discard block |
||
58 | 58 | // Show/Hide vertical menu |
59 | 59 | if ($mode != 'jmobile' && $mode != 'topnb' && $usemenuhider && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) |
60 | 60 | { |
61 | - $showmode=1; |
|
62 | - $classname = 'class="tmenu menuhider"'; |
|
63 | - $idsel='menu'; |
|
61 | + $showmode=1; |
|
62 | + $classname = 'class="tmenu menuhider"'; |
|
63 | + $idsel='menu'; |
|
64 | 64 | |
65 | - $menu->add('#', '', 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname); |
|
65 | + $menu->add('#', '', 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | $num = count($newTabMenu); |
@@ -77,19 +77,19 @@ discard block |
||
77 | 77 | |
78 | 78 | if (! preg_match("/^(http:\/\/|https:\/\/)/i",$newTabMenu[$i]['url'])) |
79 | 79 | { |
80 | - $tmp=explode('?',$newTabMenu[$i]['url'],2); |
|
80 | + $tmp=explode('?',$newTabMenu[$i]['url'],2); |
|
81 | 81 | $url = $shorturl = $tmp[0]; |
82 | 82 | $param = (isset($tmp[1])?$tmp[1]:''); |
83 | 83 | |
84 | 84 | // Complete param to force leftmenu to '' to close open menu when we click on a link with no leftmenu defined. |
85 | - if ((! preg_match('/mainmenu/i',$param)) && (! preg_match('/leftmenu/i',$param)) && ! empty($newTabMenu[$i]['url'])) |
|
86 | - { |
|
87 | - $param.=($param?'&':'').'mainmenu='.$newTabMenu[$i]['mainmenu'].'&leftmenu='; |
|
88 | - } |
|
89 | - if ((! preg_match('/mainmenu/i',$param)) && (! preg_match('/leftmenu/i',$param)) && empty($newTabMenu[$i]['url'])) |
|
90 | - { |
|
91 | - $param.=($param?'&':'').'leftmenu='; |
|
92 | - } |
|
85 | + if ((! preg_match('/mainmenu/i',$param)) && (! preg_match('/leftmenu/i',$param)) && ! empty($newTabMenu[$i]['url'])) |
|
86 | + { |
|
87 | + $param.=($param?'&':'').'mainmenu='.$newTabMenu[$i]['mainmenu'].'&leftmenu='; |
|
88 | + } |
|
89 | + if ((! preg_match('/mainmenu/i',$param)) && (! preg_match('/leftmenu/i',$param)) && empty($newTabMenu[$i]['url'])) |
|
90 | + { |
|
91 | + $param.=($param?'&':'').'leftmenu='; |
|
92 | + } |
|
93 | 93 | //$url.="idmenu=".$newTabMenu[$i]['rowid']; // Already done by menuLoad |
94 | 94 | $url = dol_buildpath($url,1).($param?'?'.$param:''); |
95 | 95 | //$shorturl = $shorturl.($param?'?'.$param:''); |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | // TODO Find a generic solution |
107 | 107 | if (preg_match('/search_project_user=__search_project_user__/', $shorturl)) |
108 | 108 | { |
109 | - $search_project_user = GETPOST('search_project_user','int'); |
|
110 | - if ($search_project_user) $shorturl=preg_replace('/search_project_user=__search_project_user__/', 'search_project_user='.$search_project_user, $shorturl); |
|
111 | - else $shorturl=preg_replace('/search_project_user=__search_project_user__/', '', $shorturl); |
|
109 | + $search_project_user = GETPOST('search_project_user','int'); |
|
110 | + if ($search_project_user) $shorturl=preg_replace('/search_project_user=__search_project_user__/', 'search_project_user='.$search_project_user, $shorturl); |
|
111 | + else $shorturl=preg_replace('/search_project_user=__search_project_user__/', '', $shorturl); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | // Define the class (top menu selected or not) |
@@ -127,9 +127,9 @@ discard block |
||
127 | 127 | // Output menu entries |
128 | 128 | foreach($menu->liste as $menkey => $menuval) |
129 | 129 | { |
130 | - if (empty($noout)) print_start_menu_entry_auguria($menuval['idsel'],$menuval['classname'],$menuval['enabled']); |
|
131 | - if (empty($noout)) print_text_menu_entry_auguria($menuval['titre'], $menuval['enabled'], ($menuval['url']!='#'?DOL_URL_ROOT:'').$menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target']?$menuval['target']:$atarget)); |
|
132 | - if (empty($noout)) print_end_menu_entry_auguria($menuval['enabled']); |
|
130 | + if (empty($noout)) print_start_menu_entry_auguria($menuval['idsel'],$menuval['classname'],$menuval['enabled']); |
|
131 | + if (empty($noout)) print_text_menu_entry_auguria($menuval['titre'], $menuval['enabled'], ($menuval['url']!='#'?DOL_URL_ROOT:'').$menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target']?$menuval['target']:$atarget)); |
|
132 | + if (empty($noout)) print_end_menu_entry_auguria($menuval['enabled']); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | $showmode=1; |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | */ |
152 | 152 | function print_start_menu_array_auguria() |
153 | 153 | { |
154 | - global $conf; |
|
154 | + global $conf; |
|
155 | 155 | |
156 | 156 | print '<div class="tmenudiv">'; |
157 | 157 | print '<ul class="tmenu"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)?'':' title="Top menu"').'>'; |
@@ -293,22 +293,22 @@ discard block |
||
293 | 293 | |
294 | 294 | if (is_array($moredata) && ! empty($moredata['searchform'])) |
295 | 295 | { |
296 | - print "\n"; |
|
297 | - print "<!-- Begin SearchForm -->\n"; |
|
298 | - print '<div id="blockvmenusearch" class="blockvmenusearch">'."\n"; |
|
299 | - print $moredata['searchform']; |
|
300 | - print '</div>'."\n"; |
|
301 | - print "<!-- End SearchForm -->\n"; |
|
296 | + print "\n"; |
|
297 | + print "<!-- Begin SearchForm -->\n"; |
|
298 | + print '<div id="blockvmenusearch" class="blockvmenusearch">'."\n"; |
|
299 | + print $moredata['searchform']; |
|
300 | + print '</div>'."\n"; |
|
301 | + print "<!-- End SearchForm -->\n"; |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | if (is_array($moredata) && ! empty($moredata['bookmarks'])) |
305 | 305 | { |
306 | - print "\n"; |
|
307 | - print "<!-- Begin Bookmarks -->\n"; |
|
308 | - print '<div id="blockvmenubookmarks" class="blockvmenubookmarks">'."\n"; |
|
309 | - print $moredata['bookmarks']; |
|
310 | - print '</div>'."\n"; |
|
311 | - print "<!-- End Bookmarks -->\n"; |
|
306 | + print "\n"; |
|
307 | + print "<!-- Begin Bookmarks -->\n"; |
|
308 | + print '<div id="blockvmenubookmarks" class="blockvmenubookmarks">'."\n"; |
|
309 | + print $moredata['bookmarks']; |
|
310 | + print '</div>'."\n"; |
|
311 | + print "<!-- End Bookmarks -->\n"; |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | // We update newmenu with entries found into database |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | // We update newmenu for special dynamic menus |
319 | 319 | if ($conf->banque->enabled && $user->rights->banque->lire && $mainmenu == 'bank') // Entry for each bank account |
320 | 320 | { |
321 | - include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Required for to get Account::TYPE_CASH for example |
|
321 | + include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Required for to get Account::TYPE_CASH for example |
|
322 | 322 | |
323 | 323 | $sql = "SELECT rowid, label, courant, rappro, courant"; |
324 | 324 | $sql.= " FROM ".MAIN_DB_PREFIX."bank_account"; |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | $lastopened=true; |
481 | 481 | for($j = ($i + 1); $j < $num; $j++) |
482 | 482 | { |
483 | - if (empty($menu_array[$j]['level'])) $lastopened=false; |
|
483 | + if (empty($menu_array[$j]['level'])) $lastopened=false; |
|
484 | 484 | } |
485 | 485 | if ($altok % 2 == 0) |
486 | 486 | { |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | } |
533 | 533 | else |
534 | 534 | { |
535 | - $lastlevel0='hidden'; |
|
535 | + $lastlevel0='hidden'; |
|
536 | 536 | } |
537 | 537 | if ($showmenu) |
538 | 538 | { |
@@ -37,110 +37,110 @@ discard block |
||
37 | 37 | * @param string $mode 'top', 'topnb', 'left', 'jmobile' |
38 | 38 | * @return int 0 |
39 | 39 | */ |
40 | -function print_auguria_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode='') |
|
40 | +function print_auguria_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 0, $mode = '') |
|
41 | 41 | { |
42 | - global $user,$conf,$langs,$dolibarr_main_db_name; |
|
42 | + global $user, $conf, $langs, $dolibarr_main_db_name; |
|
43 | 43 | |
44 | - $mainmenu=$_SESSION["mainmenu"]; |
|
45 | - $leftmenu=$_SESSION["leftmenu"]; |
|
44 | + $mainmenu = $_SESSION["mainmenu"]; |
|
45 | + $leftmenu = $_SESSION["leftmenu"]; |
|
46 | 46 | |
47 | - $id='mainmenu'; |
|
48 | - $listofmodulesforexternal=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL); |
|
47 | + $id = 'mainmenu'; |
|
48 | + $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); |
|
49 | 49 | |
50 | 50 | // Show personalized menus |
51 | - $menuArbo = new Menubase($db,'auguria'); |
|
52 | - $newTabMenu = $menuArbo->menuTopCharger('', '', $type_user, 'auguria',$tabMenu); |
|
51 | + $menuArbo = new Menubase($db, 'auguria'); |
|
52 | + $newTabMenu = $menuArbo->menuTopCharger('', '', $type_user, 'auguria', $tabMenu); |
|
53 | 53 | |
54 | 54 | if (empty($noout)) print_start_menu_array_auguria(); |
55 | 55 | |
56 | - $usemenuhider = (GETPOST('testmenuhider','int') || ! empty($conf->global->MAIN_TESTMENUHIDER)); |
|
56 | + $usemenuhider = (GETPOST('testmenuhider', 'int') || !empty($conf->global->MAIN_TESTMENUHIDER)); |
|
57 | 57 | |
58 | 58 | // Show/Hide vertical menu |
59 | 59 | if ($mode != 'jmobile' && $mode != 'topnb' && $usemenuhider && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) |
60 | 60 | { |
61 | - $showmode=1; |
|
61 | + $showmode = 1; |
|
62 | 62 | $classname = 'class="tmenu menuhider"'; |
63 | - $idsel='menu'; |
|
63 | + $idsel = 'menu'; |
|
64 | 64 | |
65 | 65 | $menu->add('#', '', 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname); |
66 | 66 | } |
67 | 67 | |
68 | 68 | $num = count($newTabMenu); |
69 | - for($i = 0; $i < $num; $i++) |
|
69 | + for ($i = 0; $i < $num; $i++) |
|
70 | 70 | { |
71 | - $idsel=(empty($newTabMenu[$i]['mainmenu'])?'none':$newTabMenu[$i]['mainmenu']); |
|
71 | + $idsel = (empty($newTabMenu[$i]['mainmenu']) ? 'none' : $newTabMenu[$i]['mainmenu']); |
|
72 | 72 | |
73 | - $showmode=dol_auguria_showmenu($type_user,$newTabMenu[$i],$listofmodulesforexternal); |
|
73 | + $showmode = dol_auguria_showmenu($type_user, $newTabMenu[$i], $listofmodulesforexternal); |
|
74 | 74 | if ($showmode == 1) |
75 | 75 | { |
76 | 76 | // $menu_array[$i]['url'] can be a relative url, a full external url or a dynamic value like '$conf->global->APARAM) |
77 | 77 | if (preg_match('/^\$conf->global->([^\?]+)/', $newTabMenu[$i]['url'], $reg)) |
78 | 78 | { |
79 | - $keyforsconst=$reg[1]; |
|
79 | + $keyforsconst = $reg[1]; |
|
80 | 80 | $newTabMenu[$i]['url'] = $conf->global->$keyforsconst; |
81 | 81 | } |
82 | 82 | |
83 | 83 | $url = $shorturl = $newTabMenu[$i]['url']; |
84 | 84 | |
85 | - if (! preg_match("/^(http:\/\/|https:\/\/)/i",$newTabMenu[$i]['url'])) |
|
85 | + if (!preg_match("/^(http:\/\/|https:\/\/)/i", $newTabMenu[$i]['url'])) |
|
86 | 86 | { |
87 | - $tmp=explode('?',$newTabMenu[$i]['url'],2); |
|
87 | + $tmp = explode('?', $newTabMenu[$i]['url'], 2); |
|
88 | 88 | $url = $shorturl = $tmp[0]; |
89 | - $param = (isset($tmp[1])?$tmp[1]:''); |
|
89 | + $param = (isset($tmp[1]) ? $tmp[1] : ''); |
|
90 | 90 | |
91 | 91 | // Complete param to force leftmenu to '' to close open menu when we click on a link with no leftmenu defined. |
92 | - if ((! preg_match('/mainmenu/i',$param)) && (! preg_match('/leftmenu/i',$param)) && ! empty($newTabMenu[$i]['url'])) |
|
92 | + if ((!preg_match('/mainmenu/i', $param)) && (!preg_match('/leftmenu/i', $param)) && !empty($newTabMenu[$i]['url'])) |
|
93 | 93 | { |
94 | - $param.=($param?'&':'').'mainmenu='.$newTabMenu[$i]['mainmenu'].'&leftmenu='; |
|
94 | + $param .= ($param ? '&' : '').'mainmenu='.$newTabMenu[$i]['mainmenu'].'&leftmenu='; |
|
95 | 95 | } |
96 | - if ((! preg_match('/mainmenu/i',$param)) && (! preg_match('/leftmenu/i',$param)) && empty($newTabMenu[$i]['url'])) |
|
96 | + if ((!preg_match('/mainmenu/i', $param)) && (!preg_match('/leftmenu/i', $param)) && empty($newTabMenu[$i]['url'])) |
|
97 | 97 | { |
98 | - $param.=($param?'&':'').'leftmenu='; |
|
98 | + $param .= ($param ? '&' : '').'leftmenu='; |
|
99 | 99 | } |
100 | 100 | //$url.="idmenu=".$newTabMenu[$i]['rowid']; // Already done by menuLoad |
101 | - $url = dol_buildpath($url,1).($param?'?'.$param:''); |
|
101 | + $url = dol_buildpath($url, 1).($param ? '?'.$param : ''); |
|
102 | 102 | //$shorturl = $shorturl.($param?'?'.$param:''); |
103 | 103 | $shorturl = $url; |
104 | 104 | |
105 | - if (DOL_URL_ROOT) $shorturl = preg_replace('/^'.preg_quote(DOL_URL_ROOT,'/').'/','',$shorturl); |
|
105 | + if (DOL_URL_ROOT) $shorturl = preg_replace('/^'.preg_quote(DOL_URL_ROOT, '/').'/', '', $shorturl); |
|
106 | 106 | } |
107 | 107 | |
108 | - $url=preg_replace('/__LOGIN__/',$user->login,$url); |
|
109 | - $shorturl=preg_replace('/__LOGIN__/',$user->login,$shorturl); |
|
110 | - $url=preg_replace('/__USERID__/',$user->id,$url); |
|
111 | - $shorturl=preg_replace('/__USERID__/',$user->id,$shorturl); |
|
108 | + $url = preg_replace('/__LOGIN__/', $user->login, $url); |
|
109 | + $shorturl = preg_replace('/__LOGIN__/', $user->login, $shorturl); |
|
110 | + $url = preg_replace('/__USERID__/', $user->id, $url); |
|
111 | + $shorturl = preg_replace('/__USERID__/', $user->id, $shorturl); |
|
112 | 112 | |
113 | 113 | // TODO Find a generic solution |
114 | 114 | if (preg_match('/search_project_user=__search_project_user__/', $shorturl)) |
115 | 115 | { |
116 | - $search_project_user = GETPOST('search_project_user','int'); |
|
117 | - if ($search_project_user) $shorturl=preg_replace('/search_project_user=__search_project_user__/', 'search_project_user='.$search_project_user, $shorturl); |
|
118 | - else $shorturl=preg_replace('/search_project_user=__search_project_user__/', '', $shorturl); |
|
116 | + $search_project_user = GETPOST('search_project_user', 'int'); |
|
117 | + if ($search_project_user) $shorturl = preg_replace('/search_project_user=__search_project_user__/', 'search_project_user='.$search_project_user, $shorturl); |
|
118 | + else $shorturl = preg_replace('/search_project_user=__search_project_user__/', '', $shorturl); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | // Define the class (top menu selected or not) |
122 | - if (! empty($_SESSION['idmenu']) && $newTabMenu[$i]['rowid'] == $_SESSION['idmenu']) $classname='class="tmenusel"'; |
|
123 | - else if (! empty($_SESSION["mainmenu"]) && $newTabMenu[$i]['mainmenu'] == $_SESSION["mainmenu"]) $classname='class="tmenusel"'; |
|
124 | - else $classname='class="tmenu"'; |
|
122 | + if (!empty($_SESSION['idmenu']) && $newTabMenu[$i]['rowid'] == $_SESSION['idmenu']) $classname = 'class="tmenusel"'; |
|
123 | + else if (!empty($_SESSION["mainmenu"]) && $newTabMenu[$i]['mainmenu'] == $_SESSION["mainmenu"]) $classname = 'class="tmenusel"'; |
|
124 | + else $classname = 'class="tmenu"'; |
|
125 | 125 | } |
126 | - else if ($showmode == 2) $classname='class="tmenu"'; |
|
126 | + else if ($showmode == 2) $classname = 'class="tmenu"'; |
|
127 | 127 | |
128 | - $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); |
|
128 | + $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); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | // Sort on position |
132 | 132 | $menu->liste = dol_sort_array($menu->liste, 'position'); |
133 | 133 | |
134 | 134 | // Output menu entries |
135 | - foreach($menu->liste as $menkey => $menuval) |
|
135 | + foreach ($menu->liste as $menkey => $menuval) |
|
136 | 136 | { |
137 | - if (empty($noout)) print_start_menu_entry_auguria($menuval['idsel'],$menuval['classname'],$menuval['enabled']); |
|
138 | - if (empty($noout)) print_text_menu_entry_auguria($menuval['titre'], $menuval['enabled'], ($menuval['url']!='#'?DOL_URL_ROOT:'').$menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target']?$menuval['target']:$atarget)); |
|
137 | + if (empty($noout)) print_start_menu_entry_auguria($menuval['idsel'], $menuval['classname'], $menuval['enabled']); |
|
138 | + if (empty($noout)) print_text_menu_entry_auguria($menuval['titre'], $menuval['enabled'], ($menuval['url'] != '#' ?DOL_URL_ROOT:'').$menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target'] ? $menuval['target'] : $atarget)); |
|
139 | 139 | if (empty($noout)) print_end_menu_entry_auguria($menuval['enabled']); |
140 | 140 | } |
141 | 141 | |
142 | - $showmode=1; |
|
143 | - if (empty($noout)) print_start_menu_entry_auguria('','class="tmenuend"',$showmode); |
|
142 | + $showmode = 1; |
|
143 | + if (empty($noout)) print_start_menu_entry_auguria('', 'class="tmenuend"', $showmode); |
|
144 | 144 | if (empty($noout)) print_end_menu_entry_auguria($showmode); |
145 | 145 | |
146 | 146 | if (empty($noout)) print_end_menu_array_auguria(); |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | global $conf; |
162 | 162 | |
163 | 163 | print '<div class="tmenudiv">'; |
164 | - print '<ul class="tmenu"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)?'':' title="Top menu"').'>'; |
|
164 | + print '<ul class="tmenu"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '' : ' title="Top menu"').'>'; |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * @param int $showmode 0 = hide, 1 = allowed or 2 = not allowed |
173 | 173 | * @return void |
174 | 174 | */ |
175 | -function print_start_menu_entry_auguria($idsel,$classname,$showmode) |
|
175 | +function print_start_menu_entry_auguria($idsel, $classname, $showmode) |
|
176 | 176 | { |
177 | 177 | if ($showmode) |
178 | 178 | { |
@@ -199,10 +199,10 @@ discard block |
||
199 | 199 | |
200 | 200 | if ($showmode == 1) |
201 | 201 | { |
202 | - print '<a class="tmenuimage" tabindex="-1" href="'.$url.'"'.($atarget?' target="'.$atarget.'"':'').'>'; |
|
202 | + print '<a class="tmenuimage" tabindex="-1" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').'>'; |
|
203 | 203 | print '<div class="'.$id.' '.$idsel.' topmenuimage"><span class="'.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>'; |
204 | 204 | print '</a>'; |
205 | - print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.$url.'"'.($atarget?' target="'.$atarget.'"':'').'>'; |
|
205 | + print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').'>'; |
|
206 | 206 | print '<span class="mainmenuaspan">'; |
207 | 207 | print $text; |
208 | 208 | print '</span>'; |
@@ -262,31 +262,31 @@ discard block |
||
262 | 262 | * @param array $moredata An array with more data to output |
263 | 263 | * @return int Nb of entries |
264 | 264 | */ |
265 | -function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabMenu,&$menu,$noout=0,$forcemainmenu='',$forceleftmenu='',$moredata=null) |
|
265 | +function print_left_auguria_menu($db, $menu_array_before, $menu_array_after, &$tabMenu, &$menu, $noout = 0, $forcemainmenu = '', $forceleftmenu = '', $moredata = null) |
|
266 | 266 | { |
267 | - global $user,$conf,$langs,$dolibarr_main_db_name,$mysoc; |
|
267 | + global $user, $conf, $langs, $dolibarr_main_db_name, $mysoc; |
|
268 | 268 | |
269 | 269 | $newmenu = $menu; |
270 | 270 | |
271 | - $mainmenu=($forcemainmenu?$forcemainmenu:$_SESSION["mainmenu"]); |
|
272 | - $leftmenu=($forceleftmenu?'':(empty($_SESSION["leftmenu"])?'none':$_SESSION["leftmenu"])); |
|
271 | + $mainmenu = ($forcemainmenu ? $forcemainmenu : $_SESSION["mainmenu"]); |
|
272 | + $leftmenu = ($forceleftmenu ? '' : (empty($_SESSION["leftmenu"]) ? 'none' : $_SESSION["leftmenu"])); |
|
273 | 273 | |
274 | - $usemenuhider = (GETPOST('testmenuhider','int') || ! empty($conf->global->MAIN_TESTMENUHIDER)); |
|
274 | + $usemenuhider = (GETPOST('testmenuhider', 'int') || !empty($conf->global->MAIN_TESTMENUHIDER)); |
|
275 | 275 | global $usemenuhider; |
276 | 276 | |
277 | 277 | // Show logo company |
278 | - if (empty($noout) && ! empty($conf->global->MAIN_SHOW_LOGO) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) |
|
278 | + if (empty($noout) && !empty($conf->global->MAIN_SHOW_LOGO) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) |
|
279 | 279 | { |
280 | - $mysoc->logo_mini=$conf->global->MAIN_INFO_SOCIETE_LOGO_MINI; |
|
281 | - if (! empty($mysoc->logo_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) |
|
280 | + $mysoc->logo_mini = $conf->global->MAIN_INFO_SOCIETE_LOGO_MINI; |
|
281 | + if (!empty($mysoc->logo_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) |
|
282 | 282 | { |
283 | - $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('thumbs/'.$mysoc->logo_mini); |
|
283 | + $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('thumbs/'.$mysoc->logo_mini); |
|
284 | 284 | } |
285 | 285 | else |
286 | 286 | { |
287 | - $urllogo=DOL_URL_ROOT.'/theme/dolibarr_logo.png'; |
|
287 | + $urllogo = DOL_URL_ROOT.'/theme/dolibarr_logo.png'; |
|
288 | 288 | } |
289 | - $title=$langs->trans("GoIntoSetupToChangeLogo"); |
|
289 | + $title = $langs->trans("GoIntoSetupToChangeLogo"); |
|
290 | 290 | print "\n".'<!-- Show logo on menu -->'."\n"; |
291 | 291 | print '<div class="blockvmenuimpair blockvmenulogo">'."\n"; |
292 | 292 | print '<div class="menu_titre" id="menu_titre_logo"></div>'; |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | print '</div>'."\n"; |
299 | 299 | } |
300 | 300 | |
301 | - if (is_array($moredata) && ! empty($moredata['searchform'])) |
|
301 | + if (is_array($moredata) && !empty($moredata['searchform'])) |
|
302 | 302 | { |
303 | 303 | print "\n"; |
304 | 304 | print "<!-- Begin SearchForm -->\n"; |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | print "<!-- End SearchForm -->\n"; |
309 | 309 | } |
310 | 310 | |
311 | - if (is_array($moredata) && ! empty($moredata['bookmarks'])) |
|
311 | + if (is_array($moredata) && !empty($moredata['bookmarks'])) |
|
312 | 312 | { |
313 | 313 | print "\n"; |
314 | 314 | print "<!-- Begin Bookmarks -->\n"; |
@@ -319,19 +319,19 @@ discard block |
||
319 | 319 | } |
320 | 320 | |
321 | 321 | // We update newmenu with entries found into database |
322 | - $menuArbo = new Menubase($db,'auguria'); |
|
323 | - $newmenu = $menuArbo->menuLeftCharger($newmenu,$mainmenu,$leftmenu,($user->societe_id?1:0),'auguria',$tabMenu); |
|
322 | + $menuArbo = new Menubase($db, 'auguria'); |
|
323 | + $newmenu = $menuArbo->menuLeftCharger($newmenu, $mainmenu, $leftmenu, ($user->societe_id ? 1 : 0), 'auguria', $tabMenu); |
|
324 | 324 | |
325 | 325 | // We update newmenu for special dynamic menus |
326 | 326 | if ($conf->banque->enabled && $user->rights->banque->lire && $mainmenu == 'bank') // Entry for each bank account |
327 | 327 | { |
328 | - include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Required for to get Account::TYPE_CASH for example |
|
328 | + include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Required for to get Account::TYPE_CASH for example |
|
329 | 329 | |
330 | 330 | $sql = "SELECT rowid, label, courant, rappro, courant"; |
331 | - $sql.= " FROM ".MAIN_DB_PREFIX."bank_account"; |
|
332 | - $sql.= " WHERE entity = ".$conf->entity; |
|
333 | - $sql.= " AND clos = 0"; |
|
334 | - $sql.= " ORDER BY label"; |
|
331 | + $sql .= " FROM ".MAIN_DB_PREFIX."bank_account"; |
|
332 | + $sql .= " WHERE entity = ".$conf->entity; |
|
333 | + $sql .= " AND clos = 0"; |
|
334 | + $sql .= " ORDER BY label"; |
|
335 | 335 | |
336 | 336 | $resql = $db->query($sql); |
337 | 337 | if ($resql) |
@@ -339,15 +339,15 @@ discard block |
||
339 | 339 | $numr = $db->num_rows($resql); |
340 | 340 | $i = 0; |
341 | 341 | |
342 | - if ($numr > 0) $newmenu->add('/compta/bank/list.php',$langs->trans("BankAccounts"),0,$user->rights->banque->lire); |
|
342 | + if ($numr > 0) $newmenu->add('/compta/bank/list.php', $langs->trans("BankAccounts"), 0, $user->rights->banque->lire); |
|
343 | 343 | |
344 | 344 | while ($i < $numr) |
345 | 345 | { |
346 | 346 | $objp = $db->fetch_object($resql); |
347 | - $newmenu->add('/compta/bank/card.php?id='.$objp->rowid,$objp->label,1,$user->rights->banque->lire); |
|
347 | + $newmenu->add('/compta/bank/card.php?id='.$objp->rowid, $objp->label, 1, $user->rights->banque->lire); |
|
348 | 348 | if ($objp->rappro && $objp->courant != Account::TYPE_CASH && empty($objp->clos)) // If not cash account and not closed and can be reconciliate |
349 | 349 | { |
350 | - $newmenu->add('/compta/bank/bankentries_list.php?id='.$objp->rowid,$langs->trans("Conciliate"),2,$user->rights->banque->consolidate); |
|
350 | + $newmenu->add('/compta/bank/bankentries_list.php?id='.$objp->rowid, $langs->trans("Conciliate"), 2, $user->rights->banque->consolidate); |
|
351 | 351 | } |
352 | 352 | $i++; |
353 | 353 | } |
@@ -356,16 +356,16 @@ discard block |
||
356 | 356 | $db->free($resql); |
357 | 357 | } |
358 | 358 | |
359 | - if (! empty($conf->accounting->enabled) && !empty($user->rights->accounting->mouvements->lire) && $mainmenu == 'accountancy') // Entry in accountancy journal for each bank account |
|
359 | + if (!empty($conf->accounting->enabled) && !empty($user->rights->accounting->mouvements->lire) && $mainmenu == 'accountancy') // Entry in accountancy journal for each bank account |
|
360 | 360 | { |
361 | - $newmenu->add('',$langs->trans("Journalization"),0,$user->rights->accounting->comptarapport->lire,'','accountancy','accountancy'); |
|
361 | + $newmenu->add('', $langs->trans("Journalization"), 0, $user->rights->accounting->comptarapport->lire, '', 'accountancy', 'accountancy'); |
|
362 | 362 | |
363 | 363 | // Multi journal |
364 | 364 | $sql = "SELECT rowid, code, label, nature"; |
365 | - $sql.= " FROM ".MAIN_DB_PREFIX."accounting_journal"; |
|
366 | - $sql.= " WHERE entity = ".$conf->entity; |
|
367 | - $sql.= " AND active = 1"; |
|
368 | - $sql.= " ORDER BY label DESC"; |
|
365 | + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_journal"; |
|
366 | + $sql .= " WHERE entity = ".$conf->entity; |
|
367 | + $sql .= " AND active = 1"; |
|
368 | + $sql .= " ORDER BY label DESC"; |
|
369 | 369 | |
370 | 370 | $resql = $db->query($sql); |
371 | 371 | if ($resql) |
@@ -379,25 +379,25 @@ discard block |
||
379 | 379 | { |
380 | 380 | $objp = $db->fetch_object($resql); |
381 | 381 | |
382 | - $nature=''; |
|
382 | + $nature = ''; |
|
383 | 383 | |
384 | 384 | // Must match array $sourceList defined into journals_list.php |
385 | - if ($objp->nature == 2 && ! empty($conf->facture->enabled)) $nature="sells"; |
|
386 | - if ($objp->nature == 3 && ! empty($conf->fournisseur->enabled)) $nature="purchases"; |
|
387 | - if ($objp->nature == 4 && ! empty($conf->banque->enabled)) $nature="bank"; |
|
388 | - if ($objp->nature == 5 && ! empty($conf->expensereport->enabled)) $nature="expensereports"; |
|
389 | - if ($objp->nature == 1) $nature="various"; |
|
390 | - if ($objp->nature == 9) $nature="hasnew"; |
|
385 | + if ($objp->nature == 2 && !empty($conf->facture->enabled)) $nature = "sells"; |
|
386 | + if ($objp->nature == 3 && !empty($conf->fournisseur->enabled)) $nature = "purchases"; |
|
387 | + if ($objp->nature == 4 && !empty($conf->banque->enabled)) $nature = "bank"; |
|
388 | + if ($objp->nature == 5 && !empty($conf->expensereport->enabled)) $nature = "expensereports"; |
|
389 | + if ($objp->nature == 1) $nature = "various"; |
|
390 | + if ($objp->nature == 9) $nature = "hasnew"; |
|
391 | 391 | |
392 | 392 | // To enable when page exists |
393 | 393 | if ($conf->global->MAIN_FEATURES_LEVEL >= 2) |
394 | 394 | { |
395 | - if ($nature == 'various' || $nature == 'hasnew') $nature=''; |
|
395 | + if ($nature == 'various' || $nature == 'hasnew') $nature = ''; |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | if ($nature) |
399 | 399 | { |
400 | - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy/',$leftmenu)) $newmenu->add('/accountancy/journal/'.$nature.'journal.php?mainmenu=accountancy&leftmenu=accountancy_journal&id_journal='.$objp->rowid,dol_trunc($objp->label,25),2,$user->rights->accounting->comptarapport->lire); |
|
400 | + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy/', $leftmenu)) $newmenu->add('/accountancy/journal/'.$nature.'journal.php?mainmenu=accountancy&leftmenu=accountancy_journal&id_journal='.$objp->rowid, dol_trunc($objp->label, 25), 2, $user->rights->accounting->comptarapport->lire); |
|
401 | 401 | } |
402 | 402 | $i++; |
403 | 403 | } |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | else |
406 | 406 | { |
407 | 407 | // Should not happend. Entries are added |
408 | - $newmenu->add('',$langs->trans("NoJournalDefined"), 2, $user->rights->accounting->comptarapport->lire); |
|
408 | + $newmenu->add('', $langs->trans("NoJournalDefined"), 2, $user->rights->accounting->comptarapport->lire); |
|
409 | 409 | } |
410 | 410 | } |
411 | 411 | else dol_print_error($db); |
@@ -444,17 +444,17 @@ discard block |
||
444 | 444 | |
445 | 445 | if ($conf->ftp->enabled && $mainmenu == 'ftp') // Entry for FTP |
446 | 446 | { |
447 | - $MAXFTP=20; |
|
448 | - $i=1; |
|
447 | + $MAXFTP = 20; |
|
448 | + $i = 1; |
|
449 | 449 | while ($i <= $MAXFTP) |
450 | 450 | { |
451 | - $paramkey='FTP_NAME_'.$i; |
|
451 | + $paramkey = 'FTP_NAME_'.$i; |
|
452 | 452 | //print $paramkey; |
453 | - if (! empty($conf->global->$paramkey)) |
|
453 | + if (!empty($conf->global->$paramkey)) |
|
454 | 454 | { |
455 | - $link="/ftp/index.php?idmenu=".$_SESSION["idmenu"]."&numero_ftp=".$i; |
|
455 | + $link = "/ftp/index.php?idmenu=".$_SESSION["idmenu"]."&numero_ftp=".$i; |
|
456 | 456 | |
457 | - $newmenu->add($link, dol_trunc($conf->global->$paramkey,24)); |
|
457 | + $newmenu->add($link, dol_trunc($conf->global->$paramkey, 24)); |
|
458 | 458 | } |
459 | 459 | $i++; |
460 | 460 | } |
@@ -464,63 +464,63 @@ discard block |
||
464 | 464 | // Build final $menu_array = $menu_array_before +$newmenu->liste + $menu_array_after |
465 | 465 | //var_dump($menu_array_before);exit; |
466 | 466 | //var_dump($menu_array_after);exit; |
467 | - $menu_array=$newmenu->liste; |
|
468 | - if (is_array($menu_array_before)) $menu_array=array_merge($menu_array_before, $menu_array); |
|
469 | - if (is_array($menu_array_after)) $menu_array=array_merge($menu_array, $menu_array_after); |
|
467 | + $menu_array = $newmenu->liste; |
|
468 | + if (is_array($menu_array_before)) $menu_array = array_merge($menu_array_before, $menu_array); |
|
469 | + if (is_array($menu_array_after)) $menu_array = array_merge($menu_array, $menu_array_after); |
|
470 | 470 | //var_dump($menu_array);exit; |
471 | - if (! is_array($menu_array)) return 0; |
|
471 | + if (!is_array($menu_array)) return 0; |
|
472 | 472 | |
473 | 473 | // Show menu |
474 | 474 | if (empty($noout)) |
475 | 475 | { |
476 | - $altok=0; $blockvmenuopened=false; $lastlevel0=''; |
|
477 | - $num=count($menu_array); |
|
476 | + $altok = 0; $blockvmenuopened = false; $lastlevel0 = ''; |
|
477 | + $num = count($menu_array); |
|
478 | 478 | for ($i = 0; $i < $num; $i++) // Loop on each menu entry |
479 | 479 | { |
480 | - $showmenu=true; |
|
481 | - if (! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($menu_array[$i]['enabled'])) $showmenu=false; |
|
480 | + $showmenu = true; |
|
481 | + if (!empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($menu_array[$i]['enabled'])) $showmenu = false; |
|
482 | 482 | |
483 | 483 | // Begin of new left menu block |
484 | 484 | if (empty($menu_array[$i]['level']) && $showmenu) |
485 | 485 | { |
486 | 486 | $altok++; |
487 | - $blockvmenuopened=true; |
|
488 | - $lastopened=true; |
|
489 | - for($j = ($i + 1); $j < $num; $j++) |
|
487 | + $blockvmenuopened = true; |
|
488 | + $lastopened = true; |
|
489 | + for ($j = ($i + 1); $j < $num; $j++) |
|
490 | 490 | { |
491 | - if (empty($menu_array[$j]['level'])) $lastopened=false; |
|
491 | + if (empty($menu_array[$j]['level'])) $lastopened = false; |
|
492 | 492 | } |
493 | 493 | if ($altok % 2 == 0) |
494 | 494 | { |
495 | - print '<div class="blockvmenuimpair'.($lastopened?' blockvmenulast':'').($altok == 1 ? ' blockvmenufirst':'').'">'."\n"; |
|
495 | + print '<div class="blockvmenuimpair'.($lastopened ? ' blockvmenulast' : '').($altok == 1 ? ' blockvmenufirst' : '').'">'."\n"; |
|
496 | 496 | } |
497 | 497 | else |
498 | 498 | { |
499 | - print '<div class="blockvmenupair'.($lastopened?' blockvmenulast':'').($altok == 1 ? ' blockvmenufirst':'').'">'."\n"; |
|
499 | + print '<div class="blockvmenupair'.($lastopened ? ' blockvmenulast' : '').($altok == 1 ? ' blockvmenufirst' : '').'">'."\n"; |
|
500 | 500 | } |
501 | 501 | } |
502 | 502 | |
503 | 503 | // Add tabulation |
504 | - $tabstring=''; |
|
505 | - $tabul=($menu_array[$i]['level'] - 1); |
|
504 | + $tabstring = ''; |
|
505 | + $tabul = ($menu_array[$i]['level'] - 1); |
|
506 | 506 | if ($tabul > 0) |
507 | 507 | { |
508 | - for ($j=0; $j < $tabul; $j++) |
|
508 | + for ($j = 0; $j < $tabul; $j++) |
|
509 | 509 | { |
510 | - $tabstring.=' '; |
|
510 | + $tabstring .= ' '; |
|
511 | 511 | } |
512 | 512 | } |
513 | 513 | |
514 | 514 | // Add mainmenu in GET url. This make to go back on correct menu even when using Back on browser. |
515 | - $url=dol_buildpath($menu_array[$i]['url'],1); |
|
516 | - $url=preg_replace('/__LOGIN__/',$user->login,$url); |
|
517 | - $url=preg_replace('/__USERID__/',$user->id,$url); |
|
515 | + $url = dol_buildpath($menu_array[$i]['url'], 1); |
|
516 | + $url = preg_replace('/__LOGIN__/', $user->login, $url); |
|
517 | + $url = preg_replace('/__USERID__/', $user->id, $url); |
|
518 | 518 | |
519 | - if (! preg_match('/mainmenu=/i',$menu_array[$i]['url'])) |
|
519 | + if (!preg_match('/mainmenu=/i', $menu_array[$i]['url'])) |
|
520 | 520 | { |
521 | - if (! preg_match('/\?/',$url)) $url.='?'; |
|
522 | - else $url.='&'; |
|
523 | - $url.='mainmenu='.$mainmenu; |
|
521 | + if (!preg_match('/\?/', $url)) $url .= '?'; |
|
522 | + else $url .= '&'; |
|
523 | + $url .= 'mainmenu='.$mainmenu; |
|
524 | 524 | } |
525 | 525 | |
526 | 526 | 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'].' -->'."\n"; |
@@ -530,17 +530,17 @@ discard block |
||
530 | 530 | { |
531 | 531 | if ($menu_array[$i]['enabled']) // Enabled so visible |
532 | 532 | { |
533 | - print '<div class="menu_titre">'.$tabstring.'<a class="vmenu" href="'.$url.'"'.($menu_array[$i]['target']?' target="'.$menu_array[$i]['target'].'"':'').'>'.$menu_array[$i]['titre'].'</a></div>'; |
|
534 | - $lastlevel0='enabled'; |
|
533 | + print '<div class="menu_titre">'.$tabstring.'<a class="vmenu" href="'.$url.'"'.($menu_array[$i]['target'] ? ' target="'.$menu_array[$i]['target'].'"' : '').'>'.$menu_array[$i]['titre'].'</a></div>'; |
|
534 | + $lastlevel0 = 'enabled'; |
|
535 | 535 | } |
536 | 536 | else if ($showmenu) // Not enabled but visible (so greyed) |
537 | 537 | { |
538 | 538 | print '<div class="menu_titre">'.$tabstring.'<font class="vmenudisabled">'.$menu_array[$i]['titre'].'</font></div>'."\n"; |
539 | - $lastlevel0='greyed'; |
|
539 | + $lastlevel0 = 'greyed'; |
|
540 | 540 | } |
541 | 541 | else |
542 | 542 | { |
543 | - $lastlevel0='hidden'; |
|
543 | + $lastlevel0 = 'hidden'; |
|
544 | 544 | } |
545 | 545 | if ($showmenu) |
546 | 546 | { |
@@ -551,18 +551,18 @@ discard block |
||
551 | 551 | if ($menu_array[$i]['level'] > 0) |
552 | 552 | { |
553 | 553 | $cssmenu = ''; |
554 | - if ($menu_array[$i]['url']) $cssmenu = ' menu_contenu'.dol_string_nospecial(preg_replace('/\.php.*$/','',$menu_array[$i]['url'])); |
|
554 | + if ($menu_array[$i]['url']) $cssmenu = ' menu_contenu'.dol_string_nospecial(preg_replace('/\.php.*$/', '', $menu_array[$i]['url'])); |
|
555 | 555 | |
556 | 556 | if ($menu_array[$i]['enabled'] && $lastlevel0 == 'enabled') // Enabled so visible, except if parent was not enabled. |
557 | 557 | { |
558 | 558 | print '<div class="menu_contenu'.$cssmenu.'">'.$tabstring; |
559 | - if ($menu_array[$i]['url']) print '<a class="vsmenu" href="'.$url.'"'.($menu_array[$i]['target']?' target="'.$menu_array[$i]['target'].'"':'').'>'; |
|
559 | + if ($menu_array[$i]['url']) print '<a class="vsmenu" href="'.$url.'"'.($menu_array[$i]['target'] ? ' target="'.$menu_array[$i]['target'].'"' : '').'>'; |
|
560 | 560 | else print '<span class="vsmenu">'; |
561 | 561 | print $menu_array[$i]['titre']; |
562 | 562 | if ($menu_array[$i]['url']) print '</a>'; |
563 | 563 | else print '</span>'; |
564 | 564 | // If title is not pure text and contains a table, no carriage return added |
565 | - if (! strstr($menu_array[$i]['titre'],'<table')) print '<br>'; |
|
565 | + if (!strstr($menu_array[$i]['titre'], '<table')) print '<br>'; |
|
566 | 566 | print '</div>'."\n"; |
567 | 567 | } |
568 | 568 | else if ($showmenu && $lastlevel0 == 'enabled') // Not enabled but visible (so greyed), except if parent was not enabled. |
@@ -572,15 +572,15 @@ discard block |
||
572 | 572 | } |
573 | 573 | |
574 | 574 | // If next is a new block or if there is nothing after |
575 | - if (empty($menu_array[$i+1]['level'])) // End menu block |
|
575 | + if (empty($menu_array[$i + 1]['level'])) // End menu block |
|
576 | 576 | { |
577 | 577 | if ($showmenu) |
578 | 578 | print '<div class="menu_end"></div>'."\n"; |
579 | - if ($blockvmenuopened) { print '</div>'."\n"; $blockvmenuopened=false; } |
|
579 | + if ($blockvmenuopened) { print '</div>'."\n"; $blockvmenuopened = false; } |
|
580 | 580 | } |
581 | 581 | } |
582 | 582 | |
583 | - if ($altok) print '<div class="blockvmenuend"></div>'; // End menu block |
|
583 | + if ($altok) print '<div class="blockvmenuend"></div>'; // End menu block |
|
584 | 584 | } |
585 | 585 | |
586 | 586 | return count($menu_array); |
@@ -601,21 +601,21 @@ discard block |
||
601 | 601 | |
602 | 602 | //print 'type_user='.$type_user.' module='.$menuentry['module'].' enabled='.$menuentry['enabled'].' perms='.$menuentry['perms']; |
603 | 603 | //print 'ok='.in_array($menuentry['module'], $listofmodulesforexternal); |
604 | - if (empty($menuentry['enabled'])) return 0; // Entry disabled by condition |
|
604 | + if (empty($menuentry['enabled'])) return 0; // Entry disabled by condition |
|
605 | 605 | if ($type_user && $menuentry['module']) |
606 | 606 | { |
607 | - $tmploops=explode('|',$menuentry['module']); |
|
608 | - $found=0; |
|
609 | - foreach($tmploops as $tmploop) |
|
607 | + $tmploops = explode('|', $menuentry['module']); |
|
608 | + $found = 0; |
|
609 | + foreach ($tmploops as $tmploop) |
|
610 | 610 | { |
611 | 611 | if (in_array($tmploop, $listofmodulesforexternal)) { |
612 | 612 | $found++; break; |
613 | 613 | } |
614 | 614 | } |
615 | - if (! $found) return 0; // Entry is for menus all excluded to external users |
|
615 | + if (!$found) return 0; // Entry is for menus all excluded to external users |
|
616 | 616 | } |
617 | - if (! $menuentry['perms'] && $type_user) return 0; // No permissions and user is external |
|
618 | - if (! $menuentry['perms'] && ! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED)) return 0; // No permissions and option to hide when not allowed, even for internal user, is on |
|
619 | - if (! $menuentry['perms']) return 2; // No permissions and user is external |
|
617 | + if (!$menuentry['perms'] && $type_user) return 0; // No permissions and user is external |
|
618 | + if (!$menuentry['perms'] && !empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED)) return 0; // No permissions and option to hide when not allowed, even for internal user, is on |
|
619 | + if (!$menuentry['perms']) return 2; // No permissions and user is external |
|
620 | 620 | return 1; |
621 | 621 | } |
@@ -51,7 +51,9 @@ discard block |
||
51 | 51 | $menuArbo = new Menubase($db,'auguria'); |
52 | 52 | $newTabMenu = $menuArbo->menuTopCharger('', '', $type_user, 'auguria',$tabMenu); |
53 | 53 | |
54 | - if (empty($noout)) print_start_menu_array_auguria(); |
|
54 | + if (empty($noout)) { |
|
55 | + print_start_menu_array_auguria(); |
|
56 | + } |
|
55 | 57 | |
56 | 58 | $usemenuhider = (GETPOST('testmenuhider','int') || ! empty($conf->global->MAIN_TESTMENUHIDER)); |
57 | 59 | |
@@ -102,7 +104,9 @@ discard block |
||
102 | 104 | //$shorturl = $shorturl.($param?'?'.$param:''); |
103 | 105 | $shorturl = $url; |
104 | 106 | |
105 | - if (DOL_URL_ROOT) $shorturl = preg_replace('/^'.preg_quote(DOL_URL_ROOT,'/').'/','',$shorturl); |
|
107 | + if (DOL_URL_ROOT) { |
|
108 | + $shorturl = preg_replace('/^'.preg_quote(DOL_URL_ROOT,'/').'/','',$shorturl); |
|
109 | + } |
|
106 | 110 | } |
107 | 111 | |
108 | 112 | $url=preg_replace('/__LOGIN__/',$user->login,$url); |
@@ -114,16 +118,24 @@ discard block |
||
114 | 118 | if (preg_match('/search_project_user=__search_project_user__/', $shorturl)) |
115 | 119 | { |
116 | 120 | $search_project_user = GETPOST('search_project_user','int'); |
117 | - if ($search_project_user) $shorturl=preg_replace('/search_project_user=__search_project_user__/', 'search_project_user='.$search_project_user, $shorturl); |
|
118 | - else $shorturl=preg_replace('/search_project_user=__search_project_user__/', '', $shorturl); |
|
121 | + if ($search_project_user) { |
|
122 | + $shorturl=preg_replace('/search_project_user=__search_project_user__/', 'search_project_user='.$search_project_user, $shorturl); |
|
123 | + } else { |
|
124 | + $shorturl=preg_replace('/search_project_user=__search_project_user__/', '', $shorturl); |
|
125 | + } |
|
119 | 126 | } |
120 | 127 | |
121 | 128 | // Define the class (top menu selected or not) |
122 | - if (! empty($_SESSION['idmenu']) && $newTabMenu[$i]['rowid'] == $_SESSION['idmenu']) $classname='class="tmenusel"'; |
|
123 | - else if (! empty($_SESSION["mainmenu"]) && $newTabMenu[$i]['mainmenu'] == $_SESSION["mainmenu"]) $classname='class="tmenusel"'; |
|
124 | - else $classname='class="tmenu"'; |
|
129 | + if (! empty($_SESSION['idmenu']) && $newTabMenu[$i]['rowid'] == $_SESSION['idmenu']) { |
|
130 | + $classname='class="tmenusel"'; |
|
131 | + } else if (! empty($_SESSION["mainmenu"]) && $newTabMenu[$i]['mainmenu'] == $_SESSION["mainmenu"]) { |
|
132 | + $classname='class="tmenusel"'; |
|
133 | + } else { |
|
134 | + $classname='class="tmenu"'; |
|
135 | + } |
|
136 | + } else if ($showmode == 2) { |
|
137 | + $classname='class="tmenu"'; |
|
125 | 138 | } |
126 | - else if ($showmode == 2) $classname='class="tmenu"'; |
|
127 | 139 | |
128 | 140 | $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); |
129 | 141 | } |
@@ -134,16 +146,28 @@ discard block |
||
134 | 146 | // Output menu entries |
135 | 147 | foreach($menu->liste as $menkey => $menuval) |
136 | 148 | { |
137 | - if (empty($noout)) print_start_menu_entry_auguria($menuval['idsel'],$menuval['classname'],$menuval['enabled']); |
|
138 | - if (empty($noout)) print_text_menu_entry_auguria($menuval['titre'], $menuval['enabled'], ($menuval['url']!='#'?DOL_URL_ROOT:'').$menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target']?$menuval['target']:$atarget)); |
|
139 | - if (empty($noout)) print_end_menu_entry_auguria($menuval['enabled']); |
|
149 | + if (empty($noout)) { |
|
150 | + print_start_menu_entry_auguria($menuval['idsel'],$menuval['classname'],$menuval['enabled']); |
|
151 | + } |
|
152 | + if (empty($noout)) { |
|
153 | + print_text_menu_entry_auguria($menuval['titre'], $menuval['enabled'], ($menuval['url']!='#'?DOL_URL_ROOT:'').$menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target']?$menuval['target']:$atarget)); |
|
154 | + } |
|
155 | + if (empty($noout)) { |
|
156 | + print_end_menu_entry_auguria($menuval['enabled']); |
|
157 | + } |
|
140 | 158 | } |
141 | 159 | |
142 | 160 | $showmode=1; |
143 | - if (empty($noout)) print_start_menu_entry_auguria('','class="tmenuend"',$showmode); |
|
144 | - if (empty($noout)) print_end_menu_entry_auguria($showmode); |
|
161 | + if (empty($noout)) { |
|
162 | + print_start_menu_entry_auguria('','class="tmenuend"',$showmode); |
|
163 | + } |
|
164 | + if (empty($noout)) { |
|
165 | + print_end_menu_entry_auguria($showmode); |
|
166 | + } |
|
145 | 167 | |
146 | - if (empty($noout)) print_end_menu_array_auguria(); |
|
168 | + if (empty($noout)) { |
|
169 | + print_end_menu_array_auguria(); |
|
170 | + } |
|
147 | 171 | |
148 | 172 | print "\n"; |
149 | 173 | |
@@ -281,8 +305,7 @@ discard block |
||
281 | 305 | if (! empty($mysoc->logo_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) |
282 | 306 | { |
283 | 307 | $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('thumbs/'.$mysoc->logo_mini); |
284 | - } |
|
285 | - else |
|
308 | + } else |
|
286 | 309 | { |
287 | 310 | $urllogo=DOL_URL_ROOT.'/theme/dolibarr_logo.png'; |
288 | 311 | } |
@@ -323,9 +346,12 @@ discard block |
||
323 | 346 | $newmenu = $menuArbo->menuLeftCharger($newmenu,$mainmenu,$leftmenu,($user->societe_id?1:0),'auguria',$tabMenu); |
324 | 347 | |
325 | 348 | // We update newmenu for special dynamic menus |
326 | - if ($conf->banque->enabled && $user->rights->banque->lire && $mainmenu == 'bank') // Entry for each bank account |
|
349 | + if ($conf->banque->enabled && $user->rights->banque->lire && $mainmenu == 'bank') { |
|
350 | + // Entry for each bank account |
|
327 | 351 | { |
328 | - include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Required for to get Account::TYPE_CASH for example |
|
352 | + include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; |
|
353 | + } |
|
354 | + // Required for to get Account::TYPE_CASH for example |
|
329 | 355 | |
330 | 356 | $sql = "SELECT rowid, label, courant, rappro, courant"; |
331 | 357 | $sql.= " FROM ".MAIN_DB_PREFIX."bank_account"; |
@@ -339,26 +365,33 @@ discard block |
||
339 | 365 | $numr = $db->num_rows($resql); |
340 | 366 | $i = 0; |
341 | 367 | |
342 | - if ($numr > 0) $newmenu->add('/compta/bank/list.php',$langs->trans("BankAccounts"),0,$user->rights->banque->lire); |
|
368 | + if ($numr > 0) { |
|
369 | + $newmenu->add('/compta/bank/list.php',$langs->trans("BankAccounts"),0,$user->rights->banque->lire); |
|
370 | + } |
|
343 | 371 | |
344 | 372 | while ($i < $numr) |
345 | 373 | { |
346 | 374 | $objp = $db->fetch_object($resql); |
347 | 375 | $newmenu->add('/compta/bank/card.php?id='.$objp->rowid,$objp->label,1,$user->rights->banque->lire); |
348 | - if ($objp->rappro && $objp->courant != Account::TYPE_CASH && empty($objp->clos)) // If not cash account and not closed and can be reconciliate |
|
376 | + if ($objp->rappro && $objp->courant != Account::TYPE_CASH && empty($objp->clos)) { |
|
377 | + // If not cash account and not closed and can be reconciliate |
|
349 | 378 | { |
350 | 379 | $newmenu->add('/compta/bank/bankentries_list.php?id='.$objp->rowid,$langs->trans("Conciliate"),2,$user->rights->banque->consolidate); |
351 | 380 | } |
381 | + } |
|
352 | 382 | $i++; |
353 | 383 | } |
384 | + } else { |
|
385 | + dol_print_error($db); |
|
354 | 386 | } |
355 | - else dol_print_error($db); |
|
356 | 387 | $db->free($resql); |
357 | 388 | } |
358 | 389 | |
359 | - if (! empty($conf->accounting->enabled) && !empty($user->rights->accounting->mouvements->lire) && $mainmenu == 'accountancy') // Entry in accountancy journal for each bank account |
|
390 | + if (! empty($conf->accounting->enabled) && !empty($user->rights->accounting->mouvements->lire) && $mainmenu == 'accountancy') { |
|
391 | + // Entry in accountancy journal for each bank account |
|
360 | 392 | { |
361 | 393 | $newmenu->add('',$langs->trans("Journalization"),0,$user->rights->accounting->comptarapport->lire,'','accountancy','accountancy'); |
394 | + } |
|
362 | 395 | |
363 | 396 | // Multi journal |
364 | 397 | $sql = "SELECT rowid, code, label, nature"; |
@@ -382,33 +415,49 @@ discard block |
||
382 | 415 | $nature=''; |
383 | 416 | |
384 | 417 | // Must match array $sourceList defined into journals_list.php |
385 | - if ($objp->nature == 2 && ! empty($conf->facture->enabled)) $nature="sells"; |
|
386 | - if ($objp->nature == 3 && ! empty($conf->fournisseur->enabled)) $nature="purchases"; |
|
387 | - if ($objp->nature == 4 && ! empty($conf->banque->enabled)) $nature="bank"; |
|
388 | - if ($objp->nature == 5 && ! empty($conf->expensereport->enabled)) $nature="expensereports"; |
|
389 | - if ($objp->nature == 1) $nature="various"; |
|
390 | - if ($objp->nature == 9) $nature="hasnew"; |
|
418 | + if ($objp->nature == 2 && ! empty($conf->facture->enabled)) { |
|
419 | + $nature="sells"; |
|
420 | + } |
|
421 | + if ($objp->nature == 3 && ! empty($conf->fournisseur->enabled)) { |
|
422 | + $nature="purchases"; |
|
423 | + } |
|
424 | + if ($objp->nature == 4 && ! empty($conf->banque->enabled)) { |
|
425 | + $nature="bank"; |
|
426 | + } |
|
427 | + if ($objp->nature == 5 && ! empty($conf->expensereport->enabled)) { |
|
428 | + $nature="expensereports"; |
|
429 | + } |
|
430 | + if ($objp->nature == 1) { |
|
431 | + $nature="various"; |
|
432 | + } |
|
433 | + if ($objp->nature == 9) { |
|
434 | + $nature="hasnew"; |
|
435 | + } |
|
391 | 436 | |
392 | 437 | // To enable when page exists |
393 | 438 | if ($conf->global->MAIN_FEATURES_LEVEL >= 2) |
394 | 439 | { |
395 | - if ($nature == 'various' || $nature == 'hasnew') $nature=''; |
|
440 | + if ($nature == 'various' || $nature == 'hasnew') { |
|
441 | + $nature=''; |
|
442 | + } |
|
396 | 443 | } |
397 | 444 | |
398 | 445 | if ($nature) |
399 | 446 | { |
400 | - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy/',$leftmenu)) $newmenu->add('/accountancy/journal/'.$nature.'journal.php?mainmenu=accountancy&leftmenu=accountancy_journal&id_journal='.$objp->rowid,dol_trunc($objp->label,25),2,$user->rights->accounting->comptarapport->lire); |
|
447 | + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy/',$leftmenu)) { |
|
448 | + $newmenu->add('/accountancy/journal/'.$nature.'journal.php?mainmenu=accountancy&leftmenu=accountancy_journal&id_journal='.$objp->rowid,dol_trunc($objp->label,25),2,$user->rights->accounting->comptarapport->lire); |
|
449 | + } |
|
401 | 450 | } |
402 | 451 | $i++; |
403 | 452 | } |
404 | - } |
|
405 | - else |
|
453 | + } else |
|
406 | 454 | { |
407 | 455 | // Should not happend. Entries are added |
408 | 456 | $newmenu->add('',$langs->trans("NoJournalDefined"), 2, $user->rights->accounting->comptarapport->lire); |
409 | 457 | } |
458 | + } else { |
|
459 | + dol_print_error($db); |
|
410 | 460 | } |
411 | - else dol_print_error($db); |
|
412 | 461 | $db->free($resql); |
413 | 462 | |
414 | 463 | /* |
@@ -442,9 +491,11 @@ discard block |
||
442 | 491 | */ |
443 | 492 | } |
444 | 493 | |
445 | - if ($conf->ftp->enabled && $mainmenu == 'ftp') // Entry for FTP |
|
494 | + if ($conf->ftp->enabled && $mainmenu == 'ftp') { |
|
495 | + // Entry for FTP |
|
446 | 496 | { |
447 | 497 | $MAXFTP=20; |
498 | + } |
|
448 | 499 | $i=1; |
449 | 500 | while ($i <= $MAXFTP) |
450 | 501 | { |
@@ -465,20 +516,30 @@ discard block |
||
465 | 516 | //var_dump($menu_array_before);exit; |
466 | 517 | //var_dump($menu_array_after);exit; |
467 | 518 | $menu_array=$newmenu->liste; |
468 | - if (is_array($menu_array_before)) $menu_array=array_merge($menu_array_before, $menu_array); |
|
469 | - if (is_array($menu_array_after)) $menu_array=array_merge($menu_array, $menu_array_after); |
|
519 | + if (is_array($menu_array_before)) { |
|
520 | + $menu_array=array_merge($menu_array_before, $menu_array); |
|
521 | + } |
|
522 | + if (is_array($menu_array_after)) { |
|
523 | + $menu_array=array_merge($menu_array, $menu_array_after); |
|
524 | + } |
|
470 | 525 | //var_dump($menu_array);exit; |
471 | - if (! is_array($menu_array)) return 0; |
|
526 | + if (! is_array($menu_array)) { |
|
527 | + return 0; |
|
528 | + } |
|
472 | 529 | |
473 | 530 | // Show menu |
474 | 531 | if (empty($noout)) |
475 | 532 | { |
476 | 533 | $altok=0; $blockvmenuopened=false; $lastlevel0=''; |
477 | 534 | $num=count($menu_array); |
478 | - for ($i = 0; $i < $num; $i++) // Loop on each menu entry |
|
535 | + for ($i = 0; $i < $num; $i++) { |
|
536 | + // Loop on each menu entry |
|
479 | 537 | { |
480 | 538 | $showmenu=true; |
481 | - if (! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($menu_array[$i]['enabled'])) $showmenu=false; |
|
539 | + } |
|
540 | + if (! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($menu_array[$i]['enabled'])) { |
|
541 | + $showmenu=false; |
|
542 | + } |
|
482 | 543 | |
483 | 544 | // Begin of new left menu block |
484 | 545 | if (empty($menu_array[$i]['level']) && $showmenu) |
@@ -488,13 +549,14 @@ discard block |
||
488 | 549 | $lastopened=true; |
489 | 550 | for($j = ($i + 1); $j < $num; $j++) |
490 | 551 | { |
491 | - if (empty($menu_array[$j]['level'])) $lastopened=false; |
|
552 | + if (empty($menu_array[$j]['level'])) { |
|
553 | + $lastopened=false; |
|
554 | + } |
|
492 | 555 | } |
493 | 556 | if ($altok % 2 == 0) |
494 | 557 | { |
495 | 558 | print '<div class="blockvmenuimpair'.($lastopened?' blockvmenulast':'').($altok == 1 ? ' blockvmenufirst':'').'">'."\n"; |
496 | - } |
|
497 | - else |
|
559 | + } else |
|
498 | 560 | { |
499 | 561 | print '<div class="blockvmenupair'.($lastopened?' blockvmenulast':'').($altok == 1 ? ' blockvmenufirst':'').'">'."\n"; |
500 | 562 | } |
@@ -518,8 +580,11 @@ discard block |
||
518 | 580 | |
519 | 581 | if (! preg_match('/mainmenu=/i',$menu_array[$i]['url'])) |
520 | 582 | { |
521 | - if (! preg_match('/\?/',$url)) $url.='?'; |
|
522 | - else $url.='&'; |
|
583 | + if (! preg_match('/\?/',$url)) { |
|
584 | + $url.='?'; |
|
585 | + } else { |
|
586 | + $url.='&'; |
|
587 | + } |
|
523 | 588 | $url.='mainmenu='.$mainmenu; |
524 | 589 | } |
525 | 590 | |
@@ -528,17 +593,19 @@ discard block |
||
528 | 593 | // Menu level 0 |
529 | 594 | if ($menu_array[$i]['level'] == 0) |
530 | 595 | { |
531 | - if ($menu_array[$i]['enabled']) // Enabled so visible |
|
596 | + if ($menu_array[$i]['enabled']) { |
|
597 | + // Enabled so visible |
|
532 | 598 | { |
533 | 599 | print '<div class="menu_titre">'.$tabstring.'<a class="vmenu" href="'.$url.'"'.($menu_array[$i]['target']?' target="'.$menu_array[$i]['target'].'"':'').'>'.$menu_array[$i]['titre'].'</a></div>'; |
534 | - $lastlevel0='enabled'; |
|
535 | 600 | } |
536 | - else if ($showmenu) // Not enabled but visible (so greyed) |
|
601 | + $lastlevel0='enabled'; |
|
602 | + } else if ($showmenu) { |
|
603 | + // Not enabled but visible (so greyed) |
|
537 | 604 | { |
538 | 605 | print '<div class="menu_titre">'.$tabstring.'<font class="vmenudisabled">'.$menu_array[$i]['titre'].'</font></div>'."\n"; |
539 | - $lastlevel0='greyed'; |
|
540 | 606 | } |
541 | - else |
|
607 | + $lastlevel0='greyed'; |
|
608 | + } else |
|
542 | 609 | { |
543 | 610 | $lastlevel0='hidden'; |
544 | 611 | } |
@@ -551,36 +618,54 @@ discard block |
||
551 | 618 | if ($menu_array[$i]['level'] > 0) |
552 | 619 | { |
553 | 620 | $cssmenu = ''; |
554 | - if ($menu_array[$i]['url']) $cssmenu = ' menu_contenu'.dol_string_nospecial(preg_replace('/\.php.*$/','',$menu_array[$i]['url'])); |
|
621 | + if ($menu_array[$i]['url']) { |
|
622 | + $cssmenu = ' menu_contenu'.dol_string_nospecial(preg_replace('/\.php.*$/','',$menu_array[$i]['url'])); |
|
623 | + } |
|
555 | 624 | |
556 | - if ($menu_array[$i]['enabled'] && $lastlevel0 == 'enabled') // Enabled so visible, except if parent was not enabled. |
|
625 | + if ($menu_array[$i]['enabled'] && $lastlevel0 == 'enabled') { |
|
626 | + // Enabled so visible, except if parent was not enabled. |
|
557 | 627 | { |
558 | 628 | print '<div class="menu_contenu'.$cssmenu.'">'.$tabstring; |
559 | - if ($menu_array[$i]['url']) print '<a class="vsmenu" href="'.$url.'"'.($menu_array[$i]['target']?' target="'.$menu_array[$i]['target'].'"':'').'>'; |
|
560 | - else print '<span class="vsmenu">'; |
|
629 | + } |
|
630 | + if ($menu_array[$i]['url']) { |
|
631 | + print '<a class="vsmenu" href="'.$url.'"'.($menu_array[$i]['target']?' target="'.$menu_array[$i]['target'].'"':'').'>'; |
|
632 | + } else { |
|
633 | + print '<span class="vsmenu">'; |
|
634 | + } |
|
561 | 635 | print $menu_array[$i]['titre']; |
562 | - if ($menu_array[$i]['url']) print '</a>'; |
|
563 | - else print '</span>'; |
|
636 | + if ($menu_array[$i]['url']) { |
|
637 | + print '</a>'; |
|
638 | + } else { |
|
639 | + print '</span>'; |
|
640 | + } |
|
564 | 641 | // If title is not pure text and contains a table, no carriage return added |
565 | - if (! strstr($menu_array[$i]['titre'],'<table')) print '<br>'; |
|
642 | + if (! strstr($menu_array[$i]['titre'],'<table')) { |
|
643 | + print '<br>'; |
|
644 | + } |
|
566 | 645 | print '</div>'."\n"; |
567 | - } |
|
568 | - else if ($showmenu && $lastlevel0 == 'enabled') // Not enabled but visible (so greyed), except if parent was not enabled. |
|
646 | + } else if ($showmenu && $lastlevel0 == 'enabled') { |
|
647 | + // Not enabled but visible (so greyed), except if parent was not enabled. |
|
569 | 648 | { |
570 | 649 | print '<div class="menu_contenu'.$cssmenu.'">'.$tabstring.'<font class="vsmenudisabled vsmenudisabledmargin">'.$menu_array[$i]['titre'].'</font><br></div>'."\n"; |
571 | 650 | } |
651 | + } |
|
572 | 652 | } |
573 | 653 | |
574 | 654 | // If next is a new block or if there is nothing after |
575 | - if (empty($menu_array[$i+1]['level'])) // End menu block |
|
655 | + if (empty($menu_array[$i+1]['level'])) { |
|
656 | + // End menu block |
|
576 | 657 | { |
577 | 658 | if ($showmenu) |
578 | 659 | print '<div class="menu_end"></div>'."\n"; |
660 | + } |
|
579 | 661 | if ($blockvmenuopened) { print '</div>'."\n"; $blockvmenuopened=false; } |
580 | 662 | } |
581 | 663 | } |
582 | 664 | |
583 | - if ($altok) print '<div class="blockvmenuend"></div>'; // End menu block |
|
665 | + if ($altok) { |
|
666 | + print '<div class="blockvmenuend"></div>'; |
|
667 | + } |
|
668 | + // End menu block |
|
584 | 669 | } |
585 | 670 | |
586 | 671 | return count($menu_array); |
@@ -601,7 +686,10 @@ discard block |
||
601 | 686 | |
602 | 687 | //print 'type_user='.$type_user.' module='.$menuentry['module'].' enabled='.$menuentry['enabled'].' perms='.$menuentry['perms']; |
603 | 688 | //print 'ok='.in_array($menuentry['module'], $listofmodulesforexternal); |
604 | - if (empty($menuentry['enabled'])) return 0; // Entry disabled by condition |
|
689 | + if (empty($menuentry['enabled'])) { |
|
690 | + return 0; |
|
691 | + } |
|
692 | + // Entry disabled by condition |
|
605 | 693 | if ($type_user && $menuentry['module']) |
606 | 694 | { |
607 | 695 | $tmploops=explode('|',$menuentry['module']); |
@@ -612,10 +700,22 @@ discard block |
||
612 | 700 | $found++; break; |
613 | 701 | } |
614 | 702 | } |
615 | - if (! $found) return 0; // Entry is for menus all excluded to external users |
|
703 | + if (! $found) { |
|
704 | + return 0; |
|
705 | + } |
|
706 | + // Entry is for menus all excluded to external users |
|
707 | + } |
|
708 | + if (! $menuentry['perms'] && $type_user) { |
|
709 | + return 0; |
|
710 | + } |
|
711 | + // No permissions and user is external |
|
712 | + if (! $menuentry['perms'] && ! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED)) { |
|
713 | + return 0; |
|
714 | + } |
|
715 | + // No permissions and option to hide when not allowed, even for internal user, is on |
|
716 | + if (! $menuentry['perms']) { |
|
717 | + return 2; |
|
616 | 718 | } |
617 | - if (! $menuentry['perms'] && $type_user) return 0; // No permissions and user is external |
|
618 | - if (! $menuentry['perms'] && ! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED)) return 0; // No permissions and option to hide when not allowed, even for internal user, is on |
|
619 | - if (! $menuentry['perms']) return 2; // No permissions and user is external |
|
719 | + // No permissions and user is external |
|
620 | 720 | return 1; |
621 | 721 | } |
@@ -61,8 +61,12 @@ discard block |
||
61 | 61 | function loadMenu($forcemainmenu='',$forceleftmenu='') |
62 | 62 | { |
63 | 63 | // On sauve en session le menu principal choisi |
64 | - if (isset($_GET["mainmenu"])) $_SESSION["mainmenu"]=$_GET["mainmenu"]; |
|
65 | - if (isset($_GET["idmenu"])) $_SESSION["idmenu"]=$_GET["idmenu"]; |
|
64 | + if (isset($_GET["mainmenu"])) { |
|
65 | + $_SESSION["mainmenu"]=$_GET["mainmenu"]; |
|
66 | + } |
|
67 | + if (isset($_GET["idmenu"])) { |
|
68 | + $_SESSION["idmenu"]=$_GET["idmenu"]; |
|
69 | + } |
|
66 | 70 | |
67 | 71 | // Read mainmenu and leftmenu that define which menu to show |
68 | 72 | if (isset($_GET["mainmenu"])) |
@@ -71,13 +75,14 @@ discard block |
||
71 | 75 | $mainmenu=$_GET["mainmenu"]; |
72 | 76 | $_SESSION["mainmenu"]=$mainmenu; |
73 | 77 | $_SESSION["leftmenuopened"]=""; |
74 | - } |
|
75 | - else |
|
78 | + } else |
|
76 | 79 | { |
77 | 80 | // On va le chercher en session si non defini par le lien |
78 | 81 | $mainmenu=isset($_SESSION["mainmenu"])?$_SESSION["mainmenu"]:''; |
79 | 82 | } |
80 | - if (! empty($forcemainmenu)) $mainmenu=$forcemainmenu; |
|
83 | + if (! empty($forcemainmenu)) { |
|
84 | + $mainmenu=$forcemainmenu; |
|
85 | + } |
|
81 | 86 | |
82 | 87 | if (isset($_GET["leftmenu"])) |
83 | 88 | { |
@@ -85,12 +90,13 @@ discard block |
||
85 | 90 | $leftmenu=$_GET["leftmenu"]; |
86 | 91 | $_SESSION["leftmenu"]=$leftmenu; |
87 | 92 | |
88 | - if ($_SESSION["leftmenuopened"]==$leftmenu) // To collapse |
|
93 | + if ($_SESSION["leftmenuopened"]==$leftmenu) { |
|
94 | + // To collapse |
|
89 | 95 | { |
90 | 96 | //$leftmenu=""; |
91 | 97 | $_SESSION["leftmenuopened"]=""; |
92 | 98 | } |
93 | - else |
|
99 | + } else |
|
94 | 100 | { |
95 | 101 | $_SESSION["leftmenuopened"]=$leftmenu; |
96 | 102 | } |
@@ -98,7 +104,9 @@ discard block |
||
98 | 104 | // On va le chercher en session si non defini par le lien |
99 | 105 | $leftmenu=isset($_SESSION["leftmenu"])?$_SESSION["leftmenu"]:''; |
100 | 106 | } |
101 | - if (! empty($forceleftmenu)) $leftmenu=$forceleftmenu; |
|
107 | + if (! empty($forceleftmenu)) { |
|
108 | + $leftmenu=$forceleftmenu; |
|
109 | + } |
|
102 | 110 | |
103 | 111 | require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php'; |
104 | 112 | $tabMenu=array(); |
@@ -134,14 +142,21 @@ discard block |
||
134 | 142 | |
135 | 143 | if (empty($conf->global->MAIN_MENU_INVERT)) |
136 | 144 | { |
137 | - if ($mode == 'top') print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,0,$mode); |
|
138 | - if ($mode == 'left') print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu,0,'','',$moredata); |
|
139 | - } |
|
140 | - else |
|
145 | + if ($mode == 'top') { |
|
146 | + print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,0,$mode); |
|
147 | + } |
|
148 | + if ($mode == 'left') { |
|
149 | + print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu,0,'','',$moredata); |
|
150 | + } |
|
151 | + } else |
|
141 | 152 | { |
142 | 153 | $conf->global->MAIN_SHOW_LOGO=0; |
143 | - if ($mode == 'top') print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu,0); |
|
144 | - if ($mode == 'left') print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,0,$mode); |
|
154 | + if ($mode == 'top') { |
|
155 | + print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu,0); |
|
156 | + } |
|
157 | + if ($mode == 'left') { |
|
158 | + print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,0,$mode); |
|
159 | + } |
|
145 | 160 | } |
146 | 161 | |
147 | 162 | if ($mode == 'topnb') |
@@ -150,17 +165,22 @@ discard block |
||
150 | 165 | return $this->menu->getNbOfVisibleMenuEntries(); |
151 | 166 | } |
152 | 167 | |
153 | - if ($mode == 'jmobile') // Used to get menu in xml ul/li |
|
168 | + if ($mode == 'jmobile') { |
|
169 | + // Used to get menu in xml ul/li |
|
154 | 170 | { |
155 | - print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,1,$mode); // Fill this->menu that is empty with top menu |
|
171 | + print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,1,$mode); |
|
172 | + } |
|
173 | + // Fill this->menu that is empty with top menu |
|
156 | 174 | |
157 | 175 | // $this->menu->liste is top menu |
158 | 176 | //var_dump($this->menu->liste);exit; |
159 | 177 | $lastlevel = array(); |
160 | 178 | print '<!-- Generate menu list from menu handler '.$this->name.' -->'."\n"; |
161 | - foreach($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
179 | + foreach($this->menu->liste as $key => $val) { |
|
180 | + // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
162 | 181 | { |
163 | 182 | print '<ul class="ulmenu" data-inset="true">'; |
183 | + } |
|
164 | 184 | print '<li class="lilevel0">'; |
165 | 185 | |
166 | 186 | if ($val['enabled'] == 1) |
@@ -173,7 +193,9 @@ discard block |
||
173 | 193 | print '<a class="alilevel0" href="#">'; |
174 | 194 | |
175 | 195 | // Add font-awesome |
176 | - if ($val['level'] == 0 && $val['mainmenu'] == 'home') print '<span class="fa fa-home fa-fw paddingright" aria-hidden="true"></span>'; |
|
196 | + if ($val['level'] == 0 && $val['mainmenu'] == 'home') { |
|
197 | + print '<span class="fa fa-home fa-fw paddingright" aria-hidden="true"></span>'; |
|
198 | + } |
|
177 | 199 | |
178 | 200 | print $val['titre']; |
179 | 201 | print '</a>'."\n"; |
@@ -198,12 +220,16 @@ discard block |
||
198 | 220 | // We add sub entry |
199 | 221 | print str_pad('',1).'<li class="lilevel1 ui-btn-icon-right ui-btn">'; // ui-btn to highlight on clic |
200 | 222 | print '<a href="'.$relurl.'">'; |
201 | - if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") // No translation |
|
223 | + if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") { |
|
224 | + // No translation |
|
202 | 225 | { |
203 | 226 | if (in_array($val['mainmenu'], array('cashdesk', 'websites'))) print $langs->trans("Access"); |
204 | - else print $langs->trans("Dashboard"); |
|
227 | + } else { |
|
228 | + print $langs->trans("Dashboard"); |
|
229 | + } |
|
230 | + } else { |
|
231 | + print $langs->trans(ucfirst($val['mainmenu'])."Dashboard"); |
|
205 | 232 | } |
206 | - else print $langs->trans(ucfirst($val['mainmenu'])."Dashboard"); |
|
207 | 233 | print '</a>'; |
208 | 234 | print '</li>'."\n"; |
209 | 235 | } |
@@ -213,22 +239,26 @@ discard block |
||
213 | 239 | if ($val['enabled']) |
214 | 240 | { |
215 | 241 | $lastlevel[0]='enabled'; |
216 | - } |
|
217 | - else if ($showmenu) // Not enabled but visible (so greyed) |
|
242 | + } else if ($showmenu) { |
|
243 | + // Not enabled but visible (so greyed) |
|
218 | 244 | { |
219 | 245 | $lastlevel[0]='greyed'; |
220 | 246 | } |
221 | - else |
|
247 | + } else |
|
222 | 248 | { |
223 | 249 | $lastlevel[0]='hidden'; |
224 | 250 | } |
225 | 251 | } |
226 | 252 | |
227 | 253 | $lastlevel2 = array(); |
228 | - foreach($submenu->liste as $key2 => $val2) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
254 | + foreach($submenu->liste as $key2 => $val2) { |
|
255 | + // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
229 | 256 | { |
230 | 257 | $showmenu=true; |
231 | - if (! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($val2['enabled'])) $showmenu=false; |
|
258 | + } |
|
259 | + if (! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($val2['enabled'])) { |
|
260 | + $showmenu=false; |
|
261 | + } |
|
232 | 262 | |
233 | 263 | // If at least one parent is not enabled, we do not show any menu of all children |
234 | 264 | if ($val2['level'] > 0) |
@@ -236,19 +266,25 @@ discard block |
||
236 | 266 | $levelcursor = $val2['level']-1; |
237 | 267 | while ($levelcursor >= 0) |
238 | 268 | { |
239 | - if ($lastlevel2[$levelcursor] != 'enabled') $showmenu=false; |
|
269 | + if ($lastlevel2[$levelcursor] != 'enabled') { |
|
270 | + $showmenu=false; |
|
271 | + } |
|
240 | 272 | $levelcursor--; |
241 | 273 | } |
242 | 274 | } |
243 | 275 | |
244 | - if ($showmenu) // Visible (option to hide when not allowed is off or allowed) |
|
276 | + if ($showmenu) { |
|
277 | + // Visible (option to hide when not allowed is off or allowed) |
|
245 | 278 | { |
246 | 279 | $relurl2=dol_buildpath($val2['url'],1); |
280 | + } |
|
247 | 281 | $relurl2=preg_replace('/__LOGIN__/',$user->login,$relurl2); |
248 | 282 | $relurl2=preg_replace('/__USERID__/',$user->id,$relurl2); |
249 | 283 | $canonurl2=preg_replace('/\?.*$/','',$val2['url']); |
250 | 284 | //var_dump($val2['url'].' - '.$canonurl2.' - '.$val2['level']); |
251 | - if (in_array($canonurl2,array('/admin/index.php','/admin/tools/index.php','/core/tools.php'))) $relurl2=''; |
|
285 | + if (in_array($canonurl2,array('/admin/index.php','/admin/tools/index.php','/core/tools.php'))) { |
|
286 | + $relurl2=''; |
|
287 | + } |
|
252 | 288 | |
253 | 289 | $disabled=''; |
254 | 290 | if (! $val2['enabled']) |
@@ -258,30 +294,34 @@ discard block |
||
258 | 294 | |
259 | 295 | print str_pad('',$val2['level']+1); |
260 | 296 | print '<li class="lilevel'.($val2['level']+1); |
261 | - if ($val2['level']==0) print ' ui-btn-icon-right ui-btn'; // ui-btn to highlight on clic |
|
297 | + if ($val2['level']==0) { |
|
298 | + print ' ui-btn-icon-right ui-btn'; |
|
299 | + } |
|
300 | + // ui-btn to highlight on clic |
|
262 | 301 | print $disabled.'">'; // ui-btn to highlight on clic |
263 | 302 | if ($relurl2) |
264 | 303 | { |
265 | - if ($val2['enabled']) // Allowed |
|
304 | + if ($val2['enabled']) { |
|
305 | + // Allowed |
|
266 | 306 | { |
267 | 307 | print '<a href="'.$relurl2.'"'; |
308 | + } |
|
268 | 309 | //print ' data-ajax="false"'; |
269 | 310 | print '>'; |
270 | 311 | $lastlevel2[$val2['level']]='enabled'; |
271 | - } |
|
272 | - else // Not allowed but visible (greyed) |
|
312 | + } else // Not allowed but visible (greyed) |
|
273 | 313 | { |
274 | 314 | print '<a href="#" class="vsmenudisabled">'; |
275 | 315 | $lastlevel2[$val2['level']]='greyed'; |
276 | 316 | } |
277 | - } |
|
278 | - else |
|
317 | + } else |
|
279 | 318 | { |
280 | - if ($val2['enabled']) // Allowed |
|
319 | + if ($val2['enabled']) { |
|
320 | + // Allowed |
|
281 | 321 | { |
282 | 322 | $lastlevel2[$val2['level']]='enabled'; |
283 | 323 | } |
284 | - else |
|
324 | + } else |
|
285 | 325 | { |
286 | 326 | $lastlevel2[$val2['level']]='greyed'; |
287 | 327 | } |
@@ -291,10 +331,12 @@ discard block |
||
291 | 331 | print $val2['titre']; |
292 | 332 | if ($relurl2) |
293 | 333 | { |
294 | - if ($val2['enabled']) // Allowed |
|
295 | - print '</a>'; |
|
296 | - else |
|
334 | + if ($val2['enabled']) { |
|
335 | + // Allowed |
|
297 | 336 | print '</a>'; |
337 | + } else { |
|
338 | + print '</a>'; |
|
339 | + } |
|
298 | 340 | } |
299 | 341 | print '</li>'."\n"; |
300 | 342 | } |
@@ -32,292 +32,292 @@ |
||
32 | 32 | var $atarget=""; // To store default target to use onto links |
33 | 33 | var $name="eldy"; |
34 | 34 | |
35 | - var $menu_array; |
|
36 | - var $menu_array_after; |
|
35 | + var $menu_array; |
|
36 | + var $menu_array_after; |
|
37 | 37 | |
38 | - var $tabMenu; |
|
38 | + var $tabMenu; |
|
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * Constructor |
|
43 | - * |
|
41 | + /** |
|
42 | + * Constructor |
|
43 | + * |
|
44 | 44 | * @param DoliDB $db Database handler |
45 | - * @param int $type_user Type of user |
|
46 | - */ |
|
47 | - function __construct($db, $type_user) |
|
48 | - { |
|
49 | - $this->type_user=$type_user; |
|
50 | - $this->db=$db; |
|
51 | - } |
|
52 | - |
|
53 | - |
|
54 | - /** |
|
55 | - * Load this->tabMenu |
|
56 | - * |
|
57 | - * @param string $forcemainmenu To force mainmenu to load |
|
58 | - * @param string $forceleftmenu To force leftmenu to load |
|
59 | - * @return void |
|
60 | - */ |
|
61 | - function loadMenu($forcemainmenu='',$forceleftmenu='') |
|
62 | - { |
|
45 | + * @param int $type_user Type of user |
|
46 | + */ |
|
47 | + function __construct($db, $type_user) |
|
48 | + { |
|
49 | + $this->type_user=$type_user; |
|
50 | + $this->db=$db; |
|
51 | + } |
|
52 | + |
|
53 | + |
|
54 | + /** |
|
55 | + * Load this->tabMenu |
|
56 | + * |
|
57 | + * @param string $forcemainmenu To force mainmenu to load |
|
58 | + * @param string $forceleftmenu To force leftmenu to load |
|
59 | + * @return void |
|
60 | + */ |
|
61 | + function loadMenu($forcemainmenu='',$forceleftmenu='') |
|
62 | + { |
|
63 | 63 | // On sauve en session le menu principal choisi |
64 | 64 | if (isset($_GET["mainmenu"])) $_SESSION["mainmenu"]=$_GET["mainmenu"]; |
65 | 65 | if (isset($_GET["idmenu"])) $_SESSION["idmenu"]=$_GET["idmenu"]; |
66 | 66 | |
67 | 67 | // Read mainmenu and leftmenu that define which menu to show |
68 | - if (isset($_GET["mainmenu"])) |
|
69 | - { |
|
70 | - // On sauve en session le menu principal choisi |
|
71 | - $mainmenu=$_GET["mainmenu"]; |
|
72 | - $_SESSION["mainmenu"]=$mainmenu; |
|
73 | - $_SESSION["leftmenuopened"]=""; |
|
74 | - } |
|
75 | - else |
|
76 | - { |
|
77 | - // On va le chercher en session si non defini par le lien |
|
78 | - $mainmenu=isset($_SESSION["mainmenu"])?$_SESSION["mainmenu"]:''; |
|
79 | - } |
|
80 | - if (! empty($forcemainmenu)) $mainmenu=$forcemainmenu; |
|
81 | - |
|
82 | - if (isset($_GET["leftmenu"])) |
|
83 | - { |
|
84 | - // On sauve en session le menu principal choisi |
|
85 | - $leftmenu=$_GET["leftmenu"]; |
|
86 | - $_SESSION["leftmenu"]=$leftmenu; |
|
87 | - |
|
88 | - if ($_SESSION["leftmenuopened"]==$leftmenu) // To collapse |
|
89 | - { |
|
90 | - //$leftmenu=""; |
|
91 | - $_SESSION["leftmenuopened"]=""; |
|
92 | - } |
|
93 | - else |
|
94 | - { |
|
95 | - $_SESSION["leftmenuopened"]=$leftmenu; |
|
96 | - } |
|
97 | - } else { |
|
98 | - // On va le chercher en session si non defini par le lien |
|
99 | - $leftmenu=isset($_SESSION["leftmenu"])?$_SESSION["leftmenu"]:''; |
|
100 | - } |
|
101 | - if (! empty($forceleftmenu)) $leftmenu=$forceleftmenu; |
|
102 | - |
|
103 | - require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php'; |
|
104 | - $tabMenu=array(); |
|
105 | - $menuArbo = new Menubase($this->db,'eldy'); |
|
106 | - $menuArbo->menuLoad($mainmenu, $leftmenu, $this->type_user, 'eldy', $tabMenu); |
|
107 | - $this->tabMenu=$tabMenu; |
|
108 | - |
|
109 | - //if ($forcemainmenu == 'all') { var_dump($this->tabMenu); exit; } |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - /** |
|
114 | - * Show menu |
|
115 | - * |
|
116 | - * @param string $mode 'top', 'topnb', 'left', 'jmobile' (used to get full xml ul/li menu) |
|
117 | - * @param array $moredata An array with more data to output |
|
118 | - * @return int 0 or nb of top menu entries if $mode = 'topnb' |
|
119 | - */ |
|
120 | - function showmenu($mode, $moredata=null) |
|
121 | - { |
|
122 | - global $conf, $langs, $user; |
|
123 | - |
|
124 | - require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/eldy.lib.php'; |
|
125 | - |
|
126 | - if ($this->type_user == 1) |
|
127 | - { |
|
128 | - $conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED=1; |
|
129 | - $conf->global->MAIN_SEARCHFORM_CONTACT_DISABLED=1; |
|
130 | - } |
|
68 | + if (isset($_GET["mainmenu"])) |
|
69 | + { |
|
70 | + // On sauve en session le menu principal choisi |
|
71 | + $mainmenu=$_GET["mainmenu"]; |
|
72 | + $_SESSION["mainmenu"]=$mainmenu; |
|
73 | + $_SESSION["leftmenuopened"]=""; |
|
74 | + } |
|
75 | + else |
|
76 | + { |
|
77 | + // On va le chercher en session si non defini par le lien |
|
78 | + $mainmenu=isset($_SESSION["mainmenu"])?$_SESSION["mainmenu"]:''; |
|
79 | + } |
|
80 | + if (! empty($forcemainmenu)) $mainmenu=$forcemainmenu; |
|
81 | + |
|
82 | + if (isset($_GET["leftmenu"])) |
|
83 | + { |
|
84 | + // On sauve en session le menu principal choisi |
|
85 | + $leftmenu=$_GET["leftmenu"]; |
|
86 | + $_SESSION["leftmenu"]=$leftmenu; |
|
87 | + |
|
88 | + if ($_SESSION["leftmenuopened"]==$leftmenu) // To collapse |
|
89 | + { |
|
90 | + //$leftmenu=""; |
|
91 | + $_SESSION["leftmenuopened"]=""; |
|
92 | + } |
|
93 | + else |
|
94 | + { |
|
95 | + $_SESSION["leftmenuopened"]=$leftmenu; |
|
96 | + } |
|
97 | + } else { |
|
98 | + // On va le chercher en session si non defini par le lien |
|
99 | + $leftmenu=isset($_SESSION["leftmenu"])?$_SESSION["leftmenu"]:''; |
|
100 | + } |
|
101 | + if (! empty($forceleftmenu)) $leftmenu=$forceleftmenu; |
|
102 | + |
|
103 | + require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php'; |
|
104 | + $tabMenu=array(); |
|
105 | + $menuArbo = new Menubase($this->db,'eldy'); |
|
106 | + $menuArbo->menuLoad($mainmenu, $leftmenu, $this->type_user, 'eldy', $tabMenu); |
|
107 | + $this->tabMenu=$tabMenu; |
|
108 | + |
|
109 | + //if ($forcemainmenu == 'all') { var_dump($this->tabMenu); exit; } |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + /** |
|
114 | + * Show menu |
|
115 | + * |
|
116 | + * @param string $mode 'top', 'topnb', 'left', 'jmobile' (used to get full xml ul/li menu) |
|
117 | + * @param array $moredata An array with more data to output |
|
118 | + * @return int 0 or nb of top menu entries if $mode = 'topnb' |
|
119 | + */ |
|
120 | + function showmenu($mode, $moredata=null) |
|
121 | + { |
|
122 | + global $conf, $langs, $user; |
|
123 | + |
|
124 | + require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/eldy.lib.php'; |
|
125 | + |
|
126 | + if ($this->type_user == 1) |
|
127 | + { |
|
128 | + $conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED=1; |
|
129 | + $conf->global->MAIN_SEARCHFORM_CONTACT_DISABLED=1; |
|
130 | + } |
|
131 | 131 | |
132 | 132 | require_once DOL_DOCUMENT_ROOT.'/core/class/menu.class.php'; |
133 | - $this->menu=new Menu(); |
|
134 | - |
|
135 | - if (empty($conf->global->MAIN_MENU_INVERT)) |
|
136 | - { |
|
137 | - if ($mode == 'top') print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,0,$mode); |
|
138 | - if ($mode == 'left') print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu,0,'','',$moredata); |
|
139 | - } |
|
140 | - else |
|
133 | + $this->menu=new Menu(); |
|
134 | + |
|
135 | + if (empty($conf->global->MAIN_MENU_INVERT)) |
|
136 | + { |
|
137 | + if ($mode == 'top') print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,0,$mode); |
|
138 | + if ($mode == 'left') print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu,0,'','',$moredata); |
|
139 | + } |
|
140 | + else |
|
141 | 141 | { |
142 | - $conf->global->MAIN_SHOW_LOGO=0; |
|
143 | - if ($mode == 'top') print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu,0); |
|
144 | - if ($mode == 'left') print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,0,$mode); |
|
142 | + $conf->global->MAIN_SHOW_LOGO=0; |
|
143 | + if ($mode == 'top') print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu,0); |
|
144 | + if ($mode == 'left') print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,0,$mode); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | if ($mode == 'topnb') |
148 | 148 | { |
149 | - print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,1,$mode); // no output |
|
150 | - return $this->menu->getNbOfVisibleMenuEntries(); |
|
149 | + print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,1,$mode); // no output |
|
150 | + return $this->menu->getNbOfVisibleMenuEntries(); |
|
151 | 151 | } |
152 | 152 | |
153 | - if ($mode == 'jmobile') // Used to get menu in xml ul/li |
|
154 | - { |
|
155 | - print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,1,$mode); // Fill this->menu that is empty with top menu |
|
156 | - |
|
157 | - // $this->menu->liste is top menu |
|
158 | - //var_dump($this->menu->liste);exit; |
|
159 | - $lastlevel = array(); |
|
160 | - print '<!-- Generate menu list from menu handler '.$this->name.' -->'."\n"; |
|
161 | - foreach($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
162 | - { |
|
163 | - print '<ul class="ulmenu" data-inset="true">'; |
|
164 | - print '<li class="lilevel0">'; |
|
165 | - |
|
166 | - if ($val['enabled'] == 1) |
|
167 | - { |
|
153 | + if ($mode == 'jmobile') // Used to get menu in xml ul/li |
|
154 | + { |
|
155 | + print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,1,$mode); // Fill this->menu that is empty with top menu |
|
156 | + |
|
157 | + // $this->menu->liste is top menu |
|
158 | + //var_dump($this->menu->liste);exit; |
|
159 | + $lastlevel = array(); |
|
160 | + print '<!-- Generate menu list from menu handler '.$this->name.' -->'."\n"; |
|
161 | + foreach($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
162 | + { |
|
163 | + print '<ul class="ulmenu" data-inset="true">'; |
|
164 | + print '<li class="lilevel0">'; |
|
165 | + |
|
166 | + if ($val['enabled'] == 1) |
|
167 | + { |
|
168 | 168 | $relurl=dol_buildpath($val['url'],1); |
169 | 169 | $relurl=preg_replace('/__LOGIN__/',$user->login,$relurl); |
170 | 170 | $relurl=preg_replace('/__USERID__/',$user->id,$relurl); |
171 | 171 | $canonurl=preg_replace('/\?.*$/','',$val['url']); |
172 | 172 | |
173 | - print '<a class="alilevel0" href="#">'; |
|
173 | + print '<a class="alilevel0" href="#">'; |
|
174 | 174 | |
175 | 175 | // Add font-awesome |
176 | 176 | if ($val['level'] == 0 && $val['mainmenu'] == 'home') print '<span class="fa fa-home fa-fw paddingright" aria-hidden="true"></span>'; |
177 | 177 | |
178 | 178 | print $val['titre']; |
179 | - print '</a>'."\n"; |
|
180 | - |
|
181 | - // Search submenu fot this mainmenu entry |
|
182 | - $tmpmainmenu=$val['mainmenu']; |
|
183 | - $tmpleftmenu='all'; |
|
184 | - $submenu=new Menu(); |
|
185 | - print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$submenu,1,$tmpmainmenu,$tmpleftmenu); // Fill $submenu (example with tmpmainmenu='home' tmpleftmenu='all', return left menu tree of Home) |
|
186 | - //if ($tmpmainmenu.'-'.$tmpleftmenu == 'home-all') { var_dump($submenu); exit; } |
|
187 | - //if ($tmpmainmenu=='accountancy') { var_dump($submenu->liste); exit; } |
|
188 | - $nexturl=dol_buildpath($submenu->liste[0]['url'],1); |
|
189 | - |
|
190 | - $canonrelurl=preg_replace('/\?.*$/','',$relurl); |
|
191 | - $canonnexturl=preg_replace('/\?.*$/','',$nexturl); |
|
192 | - //var_dump($canonrelurl); |
|
193 | - //var_dump($canonnexturl); |
|
194 | - print '<ul>'."\n"; |
|
195 | - if (($canonrelurl != $canonnexturl && ! in_array($val['mainmenu'],array('tools'))) |
|
196 | - || (strpos($canonrelurl,'/product/index.php') !== false || strpos($canonrelurl,'/compta/bank/list.php') !== false)) |
|
179 | + print '</a>'."\n"; |
|
180 | + |
|
181 | + // Search submenu fot this mainmenu entry |
|
182 | + $tmpmainmenu=$val['mainmenu']; |
|
183 | + $tmpleftmenu='all'; |
|
184 | + $submenu=new Menu(); |
|
185 | + print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$submenu,1,$tmpmainmenu,$tmpleftmenu); // Fill $submenu (example with tmpmainmenu='home' tmpleftmenu='all', return left menu tree of Home) |
|
186 | + //if ($tmpmainmenu.'-'.$tmpleftmenu == 'home-all') { var_dump($submenu); exit; } |
|
187 | + //if ($tmpmainmenu=='accountancy') { var_dump($submenu->liste); exit; } |
|
188 | + $nexturl=dol_buildpath($submenu->liste[0]['url'],1); |
|
189 | + |
|
190 | + $canonrelurl=preg_replace('/\?.*$/','',$relurl); |
|
191 | + $canonnexturl=preg_replace('/\?.*$/','',$nexturl); |
|
192 | + //var_dump($canonrelurl); |
|
193 | + //var_dump($canonnexturl); |
|
194 | + print '<ul>'."\n"; |
|
195 | + if (($canonrelurl != $canonnexturl && ! in_array($val['mainmenu'],array('tools'))) |
|
196 | + || (strpos($canonrelurl,'/product/index.php') !== false || strpos($canonrelurl,'/compta/bank/list.php') !== false)) |
|
197 | + { |
|
198 | + // We add sub entry |
|
199 | + print str_pad('',1).'<li class="lilevel1 ui-btn-icon-right ui-btn">'; // ui-btn to highlight on clic |
|
200 | + print '<a href="'.$relurl.'">'; |
|
201 | + if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") // No translation |
|
202 | + { |
|
203 | + if (in_array($val['mainmenu'], array('cashdesk', 'websites'))) print $langs->trans("Access"); |
|
204 | + else print $langs->trans("Dashboard"); |
|
205 | + } |
|
206 | + else print $langs->trans(ucfirst($val['mainmenu'])."Dashboard"); |
|
207 | + print '</a>'; |
|
208 | + print '</li>'."\n"; |
|
209 | + } |
|
210 | + |
|
211 | + if ($val['level']==0) |
|
197 | 212 | { |
198 | - // We add sub entry |
|
199 | - print str_pad('',1).'<li class="lilevel1 ui-btn-icon-right ui-btn">'; // ui-btn to highlight on clic |
|
200 | - print '<a href="'.$relurl.'">'; |
|
201 | - if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") // No translation |
|
202 | - { |
|
203 | - if (in_array($val['mainmenu'], array('cashdesk', 'websites'))) print $langs->trans("Access"); |
|
204 | - else print $langs->trans("Dashboard"); |
|
205 | - } |
|
206 | - else print $langs->trans(ucfirst($val['mainmenu'])."Dashboard"); |
|
207 | - print '</a>'; |
|
208 | - print '</li>'."\n"; |
|
209 | - } |
|
210 | - |
|
211 | - if ($val['level']==0) |
|
212 | - { |
|
213 | - if ($val['enabled']) |
|
214 | - { |
|
215 | - $lastlevel[0]='enabled'; |
|
216 | - } |
|
217 | - else if ($showmenu) // Not enabled but visible (so greyed) |
|
218 | - { |
|
219 | - $lastlevel[0]='greyed'; |
|
220 | - } |
|
221 | - else |
|
222 | - { |
|
223 | - $lastlevel[0]='hidden'; |
|
224 | - } |
|
225 | - } |
|
226 | - |
|
227 | - $lastlevel2 = array(); |
|
228 | - foreach($submenu->liste as $key2 => $val2) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
229 | - { |
|
213 | + if ($val['enabled']) |
|
214 | + { |
|
215 | + $lastlevel[0]='enabled'; |
|
216 | + } |
|
217 | + else if ($showmenu) // Not enabled but visible (so greyed) |
|
218 | + { |
|
219 | + $lastlevel[0]='greyed'; |
|
220 | + } |
|
221 | + else |
|
222 | + { |
|
223 | + $lastlevel[0]='hidden'; |
|
224 | + } |
|
225 | + } |
|
226 | + |
|
227 | + $lastlevel2 = array(); |
|
228 | + foreach($submenu->liste as $key2 => $val2) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
229 | + { |
|
230 | 230 | $showmenu=true; |
231 | 231 | if (! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($val2['enabled'])) $showmenu=false; |
232 | 232 | |
233 | 233 | // If at least one parent is not enabled, we do not show any menu of all children |
234 | 234 | if ($val2['level'] > 0) |
235 | 235 | { |
236 | - $levelcursor = $val2['level']-1; |
|
237 | - while ($levelcursor >= 0) |
|
238 | - { |
|
239 | - if ($lastlevel2[$levelcursor] != 'enabled') $showmenu=false; |
|
240 | - $levelcursor--; |
|
241 | - } |
|
236 | + $levelcursor = $val2['level']-1; |
|
237 | + while ($levelcursor >= 0) |
|
238 | + { |
|
239 | + if ($lastlevel2[$levelcursor] != 'enabled') $showmenu=false; |
|
240 | + $levelcursor--; |
|
241 | + } |
|
242 | 242 | } |
243 | 243 | |
244 | - if ($showmenu) // Visible (option to hide when not allowed is off or allowed) |
|
245 | - { |
|
246 | - $relurl2=dol_buildpath($val2['url'],1); |
|
247 | - $relurl2=preg_replace('/__LOGIN__/',$user->login,$relurl2); |
|
248 | - $relurl2=preg_replace('/__USERID__/',$user->id,$relurl2); |
|
249 | - $canonurl2=preg_replace('/\?.*$/','',$val2['url']); |
|
250 | - //var_dump($val2['url'].' - '.$canonurl2.' - '.$val2['level']); |
|
251 | - if (in_array($canonurl2,array('/admin/index.php','/admin/tools/index.php','/core/tools.php'))) $relurl2=''; |
|
252 | - |
|
253 | - $disabled=''; |
|
254 | - if (! $val2['enabled']) |
|
255 | - { |
|
256 | - $disabled=" vsmenudisabled"; |
|
257 | - } |
|
258 | - |
|
259 | - print str_pad('',$val2['level']+1); |
|
260 | - print '<li class="lilevel'.($val2['level']+1); |
|
261 | - if ($val2['level']==0) print ' ui-btn-icon-right ui-btn'; // ui-btn to highlight on clic |
|
262 | - print $disabled.'">'; // ui-btn to highlight on clic |
|
263 | - if ($relurl2) |
|
264 | - { |
|
265 | - if ($val2['enabled']) // Allowed |
|
266 | - { |
|
267 | - print '<a href="'.$relurl2.'"'; |
|
268 | - //print ' data-ajax="false"'; |
|
269 | - print '>'; |
|
270 | - $lastlevel2[$val2['level']]='enabled'; |
|
271 | - } |
|
272 | - else // Not allowed but visible (greyed) |
|
273 | - { |
|
274 | - print '<a href="#" class="vsmenudisabled">'; |
|
275 | - $lastlevel2[$val2['level']]='greyed'; |
|
276 | - } |
|
277 | - } |
|
278 | - else |
|
279 | - { |
|
280 | - if ($val2['enabled']) // Allowed |
|
281 | - { |
|
282 | - $lastlevel2[$val2['level']]='enabled'; |
|
283 | - } |
|
284 | - else |
|
285 | - { |
|
286 | - $lastlevel2[$val2['level']]='greyed'; |
|
287 | - } |
|
288 | - } |
|
289 | - //var_dump($val2['level']); |
|
290 | - //var_dump($lastlevel2); |
|
291 | - print $val2['titre']; |
|
292 | - if ($relurl2) |
|
293 | - { |
|
294 | - if ($val2['enabled']) // Allowed |
|
295 | - print '</a>'; |
|
296 | - else |
|
297 | - print '</a>'; |
|
298 | - } |
|
299 | - print '</li>'."\n"; |
|
300 | - } |
|
301 | - |
|
302 | - |
|
303 | - } |
|
304 | - //var_dump($submenu); |
|
305 | - print '</ul>'; |
|
306 | - } |
|
307 | - if ($val['enabled'] == 2) |
|
308 | - { |
|
309 | - print '<font class="vsmenudisabled">'.$val['titre'].'</font>'; |
|
310 | - } |
|
311 | - print '</li>'; |
|
312 | - print '</ul>'."\n"; |
|
313 | - } |
|
314 | - } |
|
315 | - |
|
316 | - unset($this->menu); |
|
317 | - |
|
318 | - //print 'xx'.$mode; |
|
319 | - return 0; |
|
320 | - } |
|
244 | + if ($showmenu) // Visible (option to hide when not allowed is off or allowed) |
|
245 | + { |
|
246 | + $relurl2=dol_buildpath($val2['url'],1); |
|
247 | + $relurl2=preg_replace('/__LOGIN__/',$user->login,$relurl2); |
|
248 | + $relurl2=preg_replace('/__USERID__/',$user->id,$relurl2); |
|
249 | + $canonurl2=preg_replace('/\?.*$/','',$val2['url']); |
|
250 | + //var_dump($val2['url'].' - '.$canonurl2.' - '.$val2['level']); |
|
251 | + if (in_array($canonurl2,array('/admin/index.php','/admin/tools/index.php','/core/tools.php'))) $relurl2=''; |
|
252 | + |
|
253 | + $disabled=''; |
|
254 | + if (! $val2['enabled']) |
|
255 | + { |
|
256 | + $disabled=" vsmenudisabled"; |
|
257 | + } |
|
258 | + |
|
259 | + print str_pad('',$val2['level']+1); |
|
260 | + print '<li class="lilevel'.($val2['level']+1); |
|
261 | + if ($val2['level']==0) print ' ui-btn-icon-right ui-btn'; // ui-btn to highlight on clic |
|
262 | + print $disabled.'">'; // ui-btn to highlight on clic |
|
263 | + if ($relurl2) |
|
264 | + { |
|
265 | + if ($val2['enabled']) // Allowed |
|
266 | + { |
|
267 | + print '<a href="'.$relurl2.'"'; |
|
268 | + //print ' data-ajax="false"'; |
|
269 | + print '>'; |
|
270 | + $lastlevel2[$val2['level']]='enabled'; |
|
271 | + } |
|
272 | + else // Not allowed but visible (greyed) |
|
273 | + { |
|
274 | + print '<a href="#" class="vsmenudisabled">'; |
|
275 | + $lastlevel2[$val2['level']]='greyed'; |
|
276 | + } |
|
277 | + } |
|
278 | + else |
|
279 | + { |
|
280 | + if ($val2['enabled']) // Allowed |
|
281 | + { |
|
282 | + $lastlevel2[$val2['level']]='enabled'; |
|
283 | + } |
|
284 | + else |
|
285 | + { |
|
286 | + $lastlevel2[$val2['level']]='greyed'; |
|
287 | + } |
|
288 | + } |
|
289 | + //var_dump($val2['level']); |
|
290 | + //var_dump($lastlevel2); |
|
291 | + print $val2['titre']; |
|
292 | + if ($relurl2) |
|
293 | + { |
|
294 | + if ($val2['enabled']) // Allowed |
|
295 | + print '</a>'; |
|
296 | + else |
|
297 | + print '</a>'; |
|
298 | + } |
|
299 | + print '</li>'."\n"; |
|
300 | + } |
|
301 | + |
|
302 | + |
|
303 | + } |
|
304 | + //var_dump($submenu); |
|
305 | + print '</ul>'; |
|
306 | + } |
|
307 | + if ($val['enabled'] == 2) |
|
308 | + { |
|
309 | + print '<font class="vsmenudisabled">'.$val['titre'].'</font>'; |
|
310 | + } |
|
311 | + print '</li>'; |
|
312 | + print '</ul>'."\n"; |
|
313 | + } |
|
314 | + } |
|
315 | + |
|
316 | + unset($this->menu); |
|
317 | + |
|
318 | + //print 'xx'.$mode; |
|
319 | + return 0; |
|
320 | + } |
|
321 | 321 | |
322 | 322 | } |
323 | 323 |
@@ -28,9 +28,9 @@ discard block |
||
28 | 28 | class MenuManager |
29 | 29 | { |
30 | 30 | var $db; |
31 | - var $type_user; // Put 0 for internal users, 1 for external users |
|
32 | - var $atarget=""; // To store default target to use onto links |
|
33 | - var $name="eldy"; |
|
31 | + var $type_user; // Put 0 for internal users, 1 for external users |
|
32 | + var $atarget = ""; // To store default target to use onto links |
|
33 | + var $name = "eldy"; |
|
34 | 34 | |
35 | 35 | var $menu_array; |
36 | 36 | var $menu_array_after; |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | */ |
47 | 47 | function __construct($db, $type_user) |
48 | 48 | { |
49 | - $this->type_user=$type_user; |
|
50 | - $this->db=$db; |
|
49 | + $this->type_user = $type_user; |
|
50 | + $this->db = $db; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | |
@@ -58,53 +58,53 @@ discard block |
||
58 | 58 | * @param string $forceleftmenu To force leftmenu to load |
59 | 59 | * @return void |
60 | 60 | */ |
61 | - function loadMenu($forcemainmenu='',$forceleftmenu='') |
|
61 | + function loadMenu($forcemainmenu = '', $forceleftmenu = '') |
|
62 | 62 | { |
63 | 63 | // On sauve en session le menu principal choisi |
64 | - if (isset($_GET["mainmenu"])) $_SESSION["mainmenu"]=$_GET["mainmenu"]; |
|
65 | - if (isset($_GET["idmenu"])) $_SESSION["idmenu"]=$_GET["idmenu"]; |
|
64 | + if (isset($_GET["mainmenu"])) $_SESSION["mainmenu"] = $_GET["mainmenu"]; |
|
65 | + if (isset($_GET["idmenu"])) $_SESSION["idmenu"] = $_GET["idmenu"]; |
|
66 | 66 | |
67 | 67 | // Read mainmenu and leftmenu that define which menu to show |
68 | 68 | if (isset($_GET["mainmenu"])) |
69 | 69 | { |
70 | 70 | // On sauve en session le menu principal choisi |
71 | - $mainmenu=$_GET["mainmenu"]; |
|
72 | - $_SESSION["mainmenu"]=$mainmenu; |
|
73 | - $_SESSION["leftmenuopened"]=""; |
|
71 | + $mainmenu = $_GET["mainmenu"]; |
|
72 | + $_SESSION["mainmenu"] = $mainmenu; |
|
73 | + $_SESSION["leftmenuopened"] = ""; |
|
74 | 74 | } |
75 | 75 | else |
76 | 76 | { |
77 | 77 | // On va le chercher en session si non defini par le lien |
78 | - $mainmenu=isset($_SESSION["mainmenu"])?$_SESSION["mainmenu"]:''; |
|
78 | + $mainmenu = isset($_SESSION["mainmenu"]) ? $_SESSION["mainmenu"] : ''; |
|
79 | 79 | } |
80 | - if (! empty($forcemainmenu)) $mainmenu=$forcemainmenu; |
|
80 | + if (!empty($forcemainmenu)) $mainmenu = $forcemainmenu; |
|
81 | 81 | |
82 | 82 | if (isset($_GET["leftmenu"])) |
83 | 83 | { |
84 | 84 | // On sauve en session le menu principal choisi |
85 | - $leftmenu=$_GET["leftmenu"]; |
|
86 | - $_SESSION["leftmenu"]=$leftmenu; |
|
85 | + $leftmenu = $_GET["leftmenu"]; |
|
86 | + $_SESSION["leftmenu"] = $leftmenu; |
|
87 | 87 | |
88 | - if ($_SESSION["leftmenuopened"]==$leftmenu) // To collapse |
|
88 | + if ($_SESSION["leftmenuopened"] == $leftmenu) // To collapse |
|
89 | 89 | { |
90 | 90 | //$leftmenu=""; |
91 | - $_SESSION["leftmenuopened"]=""; |
|
91 | + $_SESSION["leftmenuopened"] = ""; |
|
92 | 92 | } |
93 | 93 | else |
94 | 94 | { |
95 | - $_SESSION["leftmenuopened"]=$leftmenu; |
|
95 | + $_SESSION["leftmenuopened"] = $leftmenu; |
|
96 | 96 | } |
97 | 97 | } else { |
98 | 98 | // On va le chercher en session si non defini par le lien |
99 | - $leftmenu=isset($_SESSION["leftmenu"])?$_SESSION["leftmenu"]:''; |
|
99 | + $leftmenu = isset($_SESSION["leftmenu"]) ? $_SESSION["leftmenu"] : ''; |
|
100 | 100 | } |
101 | - if (! empty($forceleftmenu)) $leftmenu=$forceleftmenu; |
|
101 | + if (!empty($forceleftmenu)) $leftmenu = $forceleftmenu; |
|
102 | 102 | |
103 | 103 | require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php'; |
104 | - $tabMenu=array(); |
|
105 | - $menuArbo = new Menubase($this->db,'eldy'); |
|
104 | + $tabMenu = array(); |
|
105 | + $menuArbo = new Menubase($this->db, 'eldy'); |
|
106 | 106 | $menuArbo->menuLoad($mainmenu, $leftmenu, $this->type_user, 'eldy', $tabMenu); |
107 | - $this->tabMenu=$tabMenu; |
|
107 | + $this->tabMenu = $tabMenu; |
|
108 | 108 | |
109 | 109 | //if ($forcemainmenu == 'all') { var_dump($this->tabMenu); exit; } |
110 | 110 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @param array $moredata An array with more data to output |
118 | 118 | * @return int 0 or nb of top menu entries if $mode = 'topnb' |
119 | 119 | */ |
120 | - function showmenu($mode, $moredata=null) |
|
120 | + function showmenu($mode, $moredata = null) |
|
121 | 121 | { |
122 | 122 | global $conf, $langs, $user; |
123 | 123 | |
@@ -125,50 +125,50 @@ discard block |
||
125 | 125 | |
126 | 126 | if ($this->type_user == 1) |
127 | 127 | { |
128 | - $conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED=1; |
|
129 | - $conf->global->MAIN_SEARCHFORM_CONTACT_DISABLED=1; |
|
128 | + $conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED = 1; |
|
129 | + $conf->global->MAIN_SEARCHFORM_CONTACT_DISABLED = 1; |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | require_once DOL_DOCUMENT_ROOT.'/core/class/menu.class.php'; |
133 | - $this->menu=new Menu(); |
|
133 | + $this->menu = new Menu(); |
|
134 | 134 | |
135 | 135 | if (empty($conf->global->MAIN_MENU_INVERT)) |
136 | 136 | { |
137 | - if ($mode == 'top') print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,0,$mode); |
|
138 | - if ($mode == 'left') print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu,0,'','',$moredata); |
|
137 | + if ($mode == 'top') print_eldy_menu($this->db, $this->atarget, $this->type_user, $this->tabMenu, $this->menu, 0, $mode); |
|
138 | + if ($mode == 'left') print_left_eldy_menu($this->db, $this->menu_array, $this->menu_array_after, $this->tabMenu, $this->menu, 0, '', '', $moredata); |
|
139 | 139 | } |
140 | 140 | else |
141 | 141 | { |
142 | - $conf->global->MAIN_SHOW_LOGO=0; |
|
143 | - if ($mode == 'top') print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu,0); |
|
144 | - if ($mode == 'left') print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,0,$mode); |
|
142 | + $conf->global->MAIN_SHOW_LOGO = 0; |
|
143 | + if ($mode == 'top') print_left_eldy_menu($this->db, $this->menu_array, $this->menu_array_after, $this->tabMenu, $this->menu, 0); |
|
144 | + if ($mode == 'left') print_eldy_menu($this->db, $this->atarget, $this->type_user, $this->tabMenu, $this->menu, 0, $mode); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | if ($mode == 'topnb') |
148 | 148 | { |
149 | - print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,1,$mode); // no output |
|
149 | + print_eldy_menu($this->db, $this->atarget, $this->type_user, $this->tabMenu, $this->menu, 1, $mode); // no output |
|
150 | 150 | return $this->menu->getNbOfVisibleMenuEntries(); |
151 | 151 | } |
152 | 152 | |
153 | 153 | if ($mode == 'jmobile') // Used to get menu in xml ul/li |
154 | 154 | { |
155 | - print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,1,$mode); // Fill this->menu that is empty with top menu |
|
155 | + print_eldy_menu($this->db, $this->atarget, $this->type_user, $this->tabMenu, $this->menu, 1, $mode); // Fill this->menu that is empty with top menu |
|
156 | 156 | |
157 | 157 | // $this->menu->liste is top menu |
158 | 158 | //var_dump($this->menu->liste);exit; |
159 | 159 | $lastlevel = array(); |
160 | 160 | print '<!-- Generate menu list from menu handler '.$this->name.' -->'."\n"; |
161 | - foreach($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
161 | + foreach ($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
162 | 162 | { |
163 | 163 | print '<ul class="ulmenu" data-inset="true">'; |
164 | 164 | print '<li class="lilevel0">'; |
165 | 165 | |
166 | 166 | if ($val['enabled'] == 1) |
167 | 167 | { |
168 | - $relurl=dol_buildpath($val['url'],1); |
|
169 | - $relurl=preg_replace('/__LOGIN__/',$user->login,$relurl); |
|
170 | - $relurl=preg_replace('/__USERID__/',$user->id,$relurl); |
|
171 | - $canonurl=preg_replace('/\?.*$/','',$val['url']); |
|
168 | + $relurl = dol_buildpath($val['url'], 1); |
|
169 | + $relurl = preg_replace('/__LOGIN__/', $user->login, $relurl); |
|
170 | + $relurl = preg_replace('/__USERID__/', $user->id, $relurl); |
|
171 | + $canonurl = preg_replace('/\?.*$/', '', $val['url']); |
|
172 | 172 | |
173 | 173 | print '<a class="alilevel0" href="#">'; |
174 | 174 | |
@@ -179,24 +179,24 @@ discard block |
||
179 | 179 | print '</a>'."\n"; |
180 | 180 | |
181 | 181 | // Search submenu fot this mainmenu entry |
182 | - $tmpmainmenu=$val['mainmenu']; |
|
183 | - $tmpleftmenu='all'; |
|
184 | - $submenu=new Menu(); |
|
185 | - print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$submenu,1,$tmpmainmenu,$tmpleftmenu); // Fill $submenu (example with tmpmainmenu='home' tmpleftmenu='all', return left menu tree of Home) |
|
182 | + $tmpmainmenu = $val['mainmenu']; |
|
183 | + $tmpleftmenu = 'all'; |
|
184 | + $submenu = new Menu(); |
|
185 | + print_left_eldy_menu($this->db, $this->menu_array, $this->menu_array_after, $this->tabMenu, $submenu, 1, $tmpmainmenu, $tmpleftmenu); // Fill $submenu (example with tmpmainmenu='home' tmpleftmenu='all', return left menu tree of Home) |
|
186 | 186 | //if ($tmpmainmenu.'-'.$tmpleftmenu == 'home-all') { var_dump($submenu); exit; } |
187 | 187 | //if ($tmpmainmenu=='accountancy') { var_dump($submenu->liste); exit; } |
188 | - $nexturl=dol_buildpath($submenu->liste[0]['url'],1); |
|
188 | + $nexturl = dol_buildpath($submenu->liste[0]['url'], 1); |
|
189 | 189 | |
190 | - $canonrelurl=preg_replace('/\?.*$/','',$relurl); |
|
191 | - $canonnexturl=preg_replace('/\?.*$/','',$nexturl); |
|
190 | + $canonrelurl = preg_replace('/\?.*$/', '', $relurl); |
|
191 | + $canonnexturl = preg_replace('/\?.*$/', '', $nexturl); |
|
192 | 192 | //var_dump($canonrelurl); |
193 | 193 | //var_dump($canonnexturl); |
194 | 194 | print '<ul>'."\n"; |
195 | - if (($canonrelurl != $canonnexturl && ! in_array($val['mainmenu'],array('tools'))) |
|
196 | - || (strpos($canonrelurl,'/product/index.php') !== false || strpos($canonrelurl,'/compta/bank/list.php') !== false)) |
|
195 | + if (($canonrelurl != $canonnexturl && !in_array($val['mainmenu'], array('tools'))) |
|
196 | + || (strpos($canonrelurl, '/product/index.php') !== false || strpos($canonrelurl, '/compta/bank/list.php') !== false)) |
|
197 | 197 | { |
198 | 198 | // We add sub entry |
199 | - print str_pad('',1).'<li class="lilevel1 ui-btn-icon-right ui-btn">'; // ui-btn to highlight on clic |
|
199 | + print str_pad('', 1).'<li class="lilevel1 ui-btn-icon-right ui-btn">'; // ui-btn to highlight on clic |
|
200 | 200 | print '<a href="'.$relurl.'">'; |
201 | 201 | if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") // No translation |
202 | 202 | { |
@@ -208,58 +208,58 @@ discard block |
||
208 | 208 | print '</li>'."\n"; |
209 | 209 | } |
210 | 210 | |
211 | - if ($val['level']==0) |
|
211 | + if ($val['level'] == 0) |
|
212 | 212 | { |
213 | 213 | if ($val['enabled']) |
214 | 214 | { |
215 | - $lastlevel[0]='enabled'; |
|
215 | + $lastlevel[0] = 'enabled'; |
|
216 | 216 | } |
217 | 217 | else if ($showmenu) // Not enabled but visible (so greyed) |
218 | 218 | { |
219 | - $lastlevel[0]='greyed'; |
|
219 | + $lastlevel[0] = 'greyed'; |
|
220 | 220 | } |
221 | 221 | else |
222 | 222 | { |
223 | - $lastlevel[0]='hidden'; |
|
223 | + $lastlevel[0] = 'hidden'; |
|
224 | 224 | } |
225 | 225 | } |
226 | 226 | |
227 | 227 | $lastlevel2 = array(); |
228 | - foreach($submenu->liste as $key2 => $val2) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
228 | + foreach ($submenu->liste as $key2 => $val2) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
229 | 229 | { |
230 | - $showmenu=true; |
|
231 | - if (! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($val2['enabled'])) $showmenu=false; |
|
230 | + $showmenu = true; |
|
231 | + if (!empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($val2['enabled'])) $showmenu = false; |
|
232 | 232 | |
233 | 233 | // If at least one parent is not enabled, we do not show any menu of all children |
234 | 234 | if ($val2['level'] > 0) |
235 | 235 | { |
236 | - $levelcursor = $val2['level']-1; |
|
236 | + $levelcursor = $val2['level'] - 1; |
|
237 | 237 | while ($levelcursor >= 0) |
238 | 238 | { |
239 | - if ($lastlevel2[$levelcursor] != 'enabled') $showmenu=false; |
|
239 | + if ($lastlevel2[$levelcursor] != 'enabled') $showmenu = false; |
|
240 | 240 | $levelcursor--; |
241 | 241 | } |
242 | 242 | } |
243 | 243 | |
244 | 244 | if ($showmenu) // Visible (option to hide when not allowed is off or allowed) |
245 | 245 | { |
246 | - $relurl2=dol_buildpath($val2['url'],1); |
|
247 | - $relurl2=preg_replace('/__LOGIN__/',$user->login,$relurl2); |
|
248 | - $relurl2=preg_replace('/__USERID__/',$user->id,$relurl2); |
|
249 | - $canonurl2=preg_replace('/\?.*$/','',$val2['url']); |
|
246 | + $relurl2 = dol_buildpath($val2['url'], 1); |
|
247 | + $relurl2 = preg_replace('/__LOGIN__/', $user->login, $relurl2); |
|
248 | + $relurl2 = preg_replace('/__USERID__/', $user->id, $relurl2); |
|
249 | + $canonurl2 = preg_replace('/\?.*$/', '', $val2['url']); |
|
250 | 250 | //var_dump($val2['url'].' - '.$canonurl2.' - '.$val2['level']); |
251 | - if (in_array($canonurl2,array('/admin/index.php','/admin/tools/index.php','/core/tools.php'))) $relurl2=''; |
|
251 | + if (in_array($canonurl2, array('/admin/index.php', '/admin/tools/index.php', '/core/tools.php'))) $relurl2 = ''; |
|
252 | 252 | |
253 | - $disabled=''; |
|
254 | - if (! $val2['enabled']) |
|
253 | + $disabled = ''; |
|
254 | + if (!$val2['enabled']) |
|
255 | 255 | { |
256 | - $disabled=" vsmenudisabled"; |
|
256 | + $disabled = " vsmenudisabled"; |
|
257 | 257 | } |
258 | 258 | |
259 | - print str_pad('',$val2['level']+1); |
|
260 | - print '<li class="lilevel'.($val2['level']+1); |
|
261 | - if ($val2['level']==0) print ' ui-btn-icon-right ui-btn'; // ui-btn to highlight on clic |
|
262 | - print $disabled.'">'; // ui-btn to highlight on clic |
|
259 | + print str_pad('', $val2['level'] + 1); |
|
260 | + print '<li class="lilevel'.($val2['level'] + 1); |
|
261 | + if ($val2['level'] == 0) print ' ui-btn-icon-right ui-btn'; // ui-btn to highlight on clic |
|
262 | + print $disabled.'">'; // ui-btn to highlight on clic |
|
263 | 263 | if ($relurl2) |
264 | 264 | { |
265 | 265 | if ($val2['enabled']) // Allowed |
@@ -267,23 +267,23 @@ discard block |
||
267 | 267 | print '<a href="'.$relurl2.'"'; |
268 | 268 | //print ' data-ajax="false"'; |
269 | 269 | print '>'; |
270 | - $lastlevel2[$val2['level']]='enabled'; |
|
270 | + $lastlevel2[$val2['level']] = 'enabled'; |
|
271 | 271 | } |
272 | 272 | else // Not allowed but visible (greyed) |
273 | 273 | { |
274 | 274 | print '<a href="#" class="vsmenudisabled">'; |
275 | - $lastlevel2[$val2['level']]='greyed'; |
|
275 | + $lastlevel2[$val2['level']] = 'greyed'; |
|
276 | 276 | } |
277 | 277 | } |
278 | 278 | else |
279 | 279 | { |
280 | 280 | if ($val2['enabled']) // Allowed |
281 | 281 | { |
282 | - $lastlevel2[$val2['level']]='enabled'; |
|
282 | + $lastlevel2[$val2['level']] = 'enabled'; |
|
283 | 283 | } |
284 | 284 | else |
285 | 285 | { |
286 | - $lastlevel2[$val2['level']]='greyed'; |
|
286 | + $lastlevel2[$val2['level']] = 'greyed'; |
|
287 | 287 | } |
288 | 288 | } |
289 | 289 | //var_dump($val2['level']); |
@@ -64,8 +64,12 @@ discard block |
||
64 | 64 | global $conf, $user, $langs; |
65 | 65 | |
66 | 66 | // On sauve en session le menu principal choisi |
67 | - if (isset($_GET["mainmenu"])) $_SESSION["mainmenu"]=$_GET["mainmenu"]; |
|
68 | - if (isset($_GET["idmenu"])) $_SESSION["idmenu"]=$_GET["idmenu"]; |
|
67 | + if (isset($_GET["mainmenu"])) { |
|
68 | + $_SESSION["mainmenu"]=$_GET["mainmenu"]; |
|
69 | + } |
|
70 | + if (isset($_GET["idmenu"])) { |
|
71 | + $_SESSION["idmenu"]=$_GET["idmenu"]; |
|
72 | + } |
|
69 | 73 | |
70 | 74 | // Read mainmenu and leftmenu that define which menu to show |
71 | 75 | if (isset($_GET["mainmenu"])) |
@@ -74,13 +78,14 @@ discard block |
||
74 | 78 | $mainmenu=$_GET["mainmenu"]; |
75 | 79 | $_SESSION["mainmenu"]=$mainmenu; |
76 | 80 | $_SESSION["leftmenuopened"]=""; |
77 | - } |
|
78 | - else |
|
81 | + } else |
|
79 | 82 | { |
80 | 83 | // On va le chercher en session si non defini par le lien |
81 | 84 | $mainmenu=isset($_SESSION["mainmenu"])?$_SESSION["mainmenu"]:''; |
82 | 85 | } |
83 | - if (! empty($forcemainmenu)) $mainmenu=$forcemainmenu; |
|
86 | + if (! empty($forcemainmenu)) { |
|
87 | + $mainmenu=$forcemainmenu; |
|
88 | + } |
|
84 | 89 | |
85 | 90 | if (isset($_GET["leftmenu"])) |
86 | 91 | { |
@@ -88,12 +93,13 @@ discard block |
||
88 | 93 | $leftmenu=$_GET["leftmenu"]; |
89 | 94 | $_SESSION["leftmenu"]=$leftmenu; |
90 | 95 | |
91 | - if ($_SESSION["leftmenuopened"]==$leftmenu) // To collapse |
|
96 | + if ($_SESSION["leftmenuopened"]==$leftmenu) { |
|
97 | + // To collapse |
|
92 | 98 | { |
93 | 99 | //$leftmenu=""; |
94 | 100 | $_SESSION["leftmenuopened"]=""; |
95 | 101 | } |
96 | - else |
|
102 | + } else |
|
97 | 103 | { |
98 | 104 | $_SESSION["leftmenuopened"]=$leftmenu; |
99 | 105 | } |
@@ -101,7 +107,9 @@ discard block |
||
101 | 107 | // On va le chercher en session si non defini par le lien |
102 | 108 | $leftmenu=isset($_SESSION["leftmenu"])?$_SESSION["leftmenu"]:''; |
103 | 109 | } |
104 | - if (! empty($forceleftmenu)) $leftmenu=$forceleftmenu; |
|
110 | + if (! empty($forceleftmenu)) { |
|
111 | + $leftmenu=$forceleftmenu; |
|
112 | + } |
|
105 | 113 | |
106 | 114 | require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php'; |
107 | 115 | $tabMenu=array(); |
@@ -134,8 +142,12 @@ discard block |
||
134 | 142 | require_once DOL_DOCUMENT_ROOT.'/core/class/menu.class.php'; |
135 | 143 | $this->menu=new Menu(); |
136 | 144 | |
137 | - if ($mode == 'top') print_auguria_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,0,$mode); |
|
138 | - if ($mode == 'left') print_left_auguria_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu,0,'','',$moredata); |
|
145 | + if ($mode == 'top') { |
|
146 | + print_auguria_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,0,$mode); |
|
147 | + } |
|
148 | + if ($mode == 'left') { |
|
149 | + print_left_auguria_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu,0,'','',$moredata); |
|
150 | + } |
|
139 | 151 | |
140 | 152 | if ($mode == 'topnb') |
141 | 153 | { |
@@ -143,17 +155,21 @@ discard block |
||
143 | 155 | return $this->menu->getNbOfVisibleMenuEntries(); |
144 | 156 | } |
145 | 157 | |
146 | - if ($mode == 'jmobile') // Used to get menu in xml ul/li |
|
158 | + if ($mode == 'jmobile') { |
|
159 | + // Used to get menu in xml ul/li |
|
147 | 160 | { |
148 | 161 | print_auguria_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,1,$mode); |
162 | + } |
|
149 | 163 | |
150 | 164 | // $this->menu->liste is top menu |
151 | 165 | //var_dump($this->menu->liste);exit; |
152 | 166 | $lastlevel = array(); |
153 | 167 | print '<!-- Generate menu list from menu handler '.$this->name.' -->'."\n"; |
154 | - foreach($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
168 | + foreach($this->menu->liste as $key => $val) { |
|
169 | + // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
155 | 170 | { |
156 | 171 | print '<ul class="ulmenu" data-inset="true">'; |
172 | + } |
|
157 | 173 | print '<li class="lilevel0">'; |
158 | 174 | if ($val['enabled'] == 1) |
159 | 175 | { |
@@ -165,7 +181,9 @@ discard block |
||
165 | 181 | print '<a class="alilevel0" href="#">'; |
166 | 182 | |
167 | 183 | // Add font-awesome |
168 | - if ($val['level'] == 0 && $val['mainmenu'] == 'home') print '<span class="fa fa-home fa-fw paddingright" aria-hidden="true"></span>'; |
|
184 | + if ($val['level'] == 0 && $val['mainmenu'] == 'home') { |
|
185 | + print '<span class="fa fa-home fa-fw paddingright" aria-hidden="true"></span>'; |
|
186 | + } |
|
169 | 187 | |
170 | 188 | print $val['titre']; |
171 | 189 | print '</a>'."\n"; |
@@ -188,12 +206,16 @@ discard block |
||
188 | 206 | // We add sub entry |
189 | 207 | print str_pad('',1).'<li class="lilevel1 ui-btn-icon-right ui-btn">'; // ui-btn to highlight on clic |
190 | 208 | print '<a href="'.$relurl.'">'; |
191 | - if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") // No translation |
|
209 | + if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") { |
|
210 | + // No translation |
|
192 | 211 | { |
193 | 212 | if (in_array($val['mainmenu'], array('cashdesk', 'websites'))) print $langs->trans("Access"); |
194 | - else print $langs->trans("Dashboard"); |
|
195 | - } |
|
196 | - else print $langs->trans(ucfirst($val['mainmenu'])."Dashboard"); |
|
213 | + } else { |
|
214 | + print $langs->trans("Dashboard"); |
|
215 | + } |
|
216 | + } else { |
|
217 | + print $langs->trans(ucfirst($val['mainmenu'])."Dashboard"); |
|
218 | + } |
|
197 | 219 | print '</a>'; |
198 | 220 | print '</li>'."\n"; |
199 | 221 | } |
@@ -203,22 +225,26 @@ discard block |
||
203 | 225 | if ($val['enabled']) |
204 | 226 | { |
205 | 227 | $lastlevel[0]='enabled'; |
206 | - } |
|
207 | - else if ($showmenu) // Not enabled but visible (so greyed) |
|
228 | + } else if ($showmenu) { |
|
229 | + // Not enabled but visible (so greyed) |
|
208 | 230 | { |
209 | 231 | $lastlevel[0]='greyed'; |
210 | 232 | } |
211 | - else |
|
233 | + } else |
|
212 | 234 | { |
213 | 235 | $lastlevel[0]='hidden'; |
214 | 236 | } |
215 | 237 | } |
216 | 238 | |
217 | 239 | $lastlevel2 = array(); |
218 | - foreach($submenu->liste as $key2 => $val2) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
240 | + foreach($submenu->liste as $key2 => $val2) { |
|
241 | + // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
219 | 242 | { |
220 | 243 | $showmenu=true; |
221 | - if (! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($val2['enabled'])) $showmenu=false; |
|
244 | + } |
|
245 | + if (! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($val2['enabled'])) { |
|
246 | + $showmenu=false; |
|
247 | + } |
|
222 | 248 | |
223 | 249 | // If at least one parent is not enabled, we do not show any menu of all children |
224 | 250 | if ($val2['level'] > 0) |
@@ -226,19 +252,25 @@ discard block |
||
226 | 252 | $levelcursor = $val2['level']-1; |
227 | 253 | while ($levelcursor >= 0) |
228 | 254 | { |
229 | - if ($lastlevel2[$levelcursor] != 'enabled') $showmenu=false; |
|
255 | + if ($lastlevel2[$levelcursor] != 'enabled') { |
|
256 | + $showmenu=false; |
|
257 | + } |
|
230 | 258 | $levelcursor--; |
231 | 259 | } |
232 | 260 | } |
233 | 261 | |
234 | - if ($showmenu) // Visible (option to hide when not allowed is off or allowed) |
|
262 | + if ($showmenu) { |
|
263 | + // Visible (option to hide when not allowed is off or allowed) |
|
235 | 264 | { |
236 | 265 | $relurl2=dol_buildpath($val2['url'],1); |
266 | + } |
|
237 | 267 | $relurl2=preg_replace('/__LOGIN__/',$user->login,$relurl2); |
238 | 268 | $relurl2=preg_replace('/__USERID__/',$user->id,$relurl2); |
239 | 269 | $canonurl2=preg_replace('/\?.*$/','',$val2['url']); |
240 | 270 | //var_dump($val2['url'].' - '.$canonurl2.' - '.$val2['level']); |
241 | - if (in_array($canonurl2,array('/admin/index.php','/admin/tools/index.php','/core/tools.php'))) $relurl2=''; |
|
271 | + if (in_array($canonurl2,array('/admin/index.php','/admin/tools/index.php','/core/tools.php'))) { |
|
272 | + $relurl2=''; |
|
273 | + } |
|
242 | 274 | |
243 | 275 | $disabled=''; |
244 | 276 | if (! $val2['enabled']) |
@@ -248,30 +280,34 @@ discard block |
||
248 | 280 | |
249 | 281 | print str_pad('',$val2['level']+1); |
250 | 282 | print '<li class="lilevel'.($val2['level']+1); |
251 | - if ($val2['level']==0) print ' ui-btn-icon-right ui-btn'; // ui-btn to highlight on clic |
|
283 | + if ($val2['level']==0) { |
|
284 | + print ' ui-btn-icon-right ui-btn'; |
|
285 | + } |
|
286 | + // ui-btn to highlight on clic |
|
252 | 287 | print $disabled.'">'; // ui-btn to highlight on clic |
253 | 288 | if ($relurl2) |
254 | 289 | { |
255 | - if ($val2['enabled']) // Allowed |
|
290 | + if ($val2['enabled']) { |
|
291 | + // Allowed |
|
256 | 292 | { |
257 | 293 | print '<a href="'.$relurl2.'"'; |
294 | + } |
|
258 | 295 | //print ' data-ajax="false"'; |
259 | 296 | print '>'; |
260 | 297 | $lastlevel2[$val2['level']]='enabled'; |
261 | - } |
|
262 | - else // Not allowed but visible (greyed) |
|
298 | + } else // Not allowed but visible (greyed) |
|
263 | 299 | { |
264 | 300 | print '<a href="#" class="vsmenudisabled">'; |
265 | 301 | $lastlevel2[$val2['level']]='greyed'; |
266 | 302 | } |
267 | - } |
|
268 | - else |
|
303 | + } else |
|
269 | 304 | { |
270 | - if ($val2['enabled']) // Allowed |
|
305 | + if ($val2['enabled']) { |
|
306 | + // Allowed |
|
271 | 307 | { |
272 | 308 | $lastlevel2[$val2['level']]='enabled'; |
273 | 309 | } |
274 | - else |
|
310 | + } else |
|
275 | 311 | { |
276 | 312 | $lastlevel2[$val2['level']]='greyed'; |
277 | 313 | } |
@@ -279,10 +315,12 @@ discard block |
||
279 | 315 | print $val2['titre']; |
280 | 316 | if ($relurl2) |
281 | 317 | { |
282 | - if ($val2['enabled']) // Allowed |
|
283 | - print '</a>'; |
|
284 | - else |
|
318 | + if ($val2['enabled']) { |
|
319 | + // Allowed |
|
285 | 320 | print '</a>'; |
321 | + } else { |
|
322 | + print '</a>'; |
|
323 | + } |
|
286 | 324 | } |
287 | 325 | print '</li>'."\n"; |
288 | 326 | } |
@@ -39,17 +39,17 @@ discard block |
||
39 | 39 | var $tabMenu; |
40 | 40 | |
41 | 41 | |
42 | - /** |
|
43 | - * Constructor |
|
44 | - * |
|
42 | + /** |
|
43 | + * Constructor |
|
44 | + * |
|
45 | 45 | * @param DoliDB $db Database handler |
46 | - * @param int $type_user Type of user |
|
47 | - */ |
|
48 | - function __construct($db, $type_user) |
|
49 | - { |
|
50 | - $this->type_user=$type_user; |
|
51 | - $this->db=$db; |
|
52 | - } |
|
46 | + * @param int $type_user Type of user |
|
47 | + */ |
|
48 | + function __construct($db, $type_user) |
|
49 | + { |
|
50 | + $this->type_user=$type_user; |
|
51 | + $this->db=$db; |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | 55 | /** |
@@ -61,245 +61,245 @@ discard block |
||
61 | 61 | */ |
62 | 62 | function loadMenu($forcemainmenu='',$forceleftmenu='') |
63 | 63 | { |
64 | - global $conf, $user, $langs; |
|
64 | + global $conf, $user, $langs; |
|
65 | 65 | |
66 | 66 | // On sauve en session le menu principal choisi |
67 | - if (isset($_GET["mainmenu"])) $_SESSION["mainmenu"]=$_GET["mainmenu"]; |
|
68 | - if (isset($_GET["idmenu"])) $_SESSION["idmenu"]=$_GET["idmenu"]; |
|
69 | - |
|
70 | - // Read mainmenu and leftmenu that define which menu to show |
|
71 | - if (isset($_GET["mainmenu"])) |
|
72 | - { |
|
73 | - // On sauve en session le menu principal choisi |
|
74 | - $mainmenu=$_GET["mainmenu"]; |
|
75 | - $_SESSION["mainmenu"]=$mainmenu; |
|
76 | - $_SESSION["leftmenuopened"]=""; |
|
77 | - } |
|
78 | - else |
|
79 | - { |
|
80 | - // On va le chercher en session si non defini par le lien |
|
81 | - $mainmenu=isset($_SESSION["mainmenu"])?$_SESSION["mainmenu"]:''; |
|
82 | - } |
|
67 | + if (isset($_GET["mainmenu"])) $_SESSION["mainmenu"]=$_GET["mainmenu"]; |
|
68 | + if (isset($_GET["idmenu"])) $_SESSION["idmenu"]=$_GET["idmenu"]; |
|
69 | + |
|
70 | + // Read mainmenu and leftmenu that define which menu to show |
|
71 | + if (isset($_GET["mainmenu"])) |
|
72 | + { |
|
73 | + // On sauve en session le menu principal choisi |
|
74 | + $mainmenu=$_GET["mainmenu"]; |
|
75 | + $_SESSION["mainmenu"]=$mainmenu; |
|
76 | + $_SESSION["leftmenuopened"]=""; |
|
77 | + } |
|
78 | + else |
|
79 | + { |
|
80 | + // On va le chercher en session si non defini par le lien |
|
81 | + $mainmenu=isset($_SESSION["mainmenu"])?$_SESSION["mainmenu"]:''; |
|
82 | + } |
|
83 | 83 | if (! empty($forcemainmenu)) $mainmenu=$forcemainmenu; |
84 | 84 | |
85 | - if (isset($_GET["leftmenu"])) |
|
86 | - { |
|
87 | - // On sauve en session le menu principal choisi |
|
88 | - $leftmenu=$_GET["leftmenu"]; |
|
89 | - $_SESSION["leftmenu"]=$leftmenu; |
|
90 | - |
|
91 | - if ($_SESSION["leftmenuopened"]==$leftmenu) // To collapse |
|
92 | - { |
|
93 | - //$leftmenu=""; |
|
94 | - $_SESSION["leftmenuopened"]=""; |
|
95 | - } |
|
96 | - else |
|
97 | - { |
|
98 | - $_SESSION["leftmenuopened"]=$leftmenu; |
|
99 | - } |
|
100 | - } else { |
|
101 | - // On va le chercher en session si non defini par le lien |
|
102 | - $leftmenu=isset($_SESSION["leftmenu"])?$_SESSION["leftmenu"]:''; |
|
103 | - } |
|
104 | - if (! empty($forceleftmenu)) $leftmenu=$forceleftmenu; |
|
105 | - |
|
106 | - require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php'; |
|
107 | - $tabMenu=array(); |
|
108 | - $menuArbo = new Menubase($this->db,'auguria'); |
|
109 | - $menuArbo->menuLoad($mainmenu, $leftmenu, $this->type_user, 'auguria', $tabMenu); |
|
110 | - |
|
111 | - $this->tabMenu=$tabMenu; |
|
112 | - } |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * Show menu |
|
117 | - * |
|
118 | - * @param string $mode 'top', 'left', 'jmobile' (used to get full xml ul/li menu) |
|
119 | - * @param array $moredata An array with more data to output |
|
120 | - * @return int 0 or nb of top menu entries if $mode = 'topnb' |
|
85 | + if (isset($_GET["leftmenu"])) |
|
86 | + { |
|
87 | + // On sauve en session le menu principal choisi |
|
88 | + $leftmenu=$_GET["leftmenu"]; |
|
89 | + $_SESSION["leftmenu"]=$leftmenu; |
|
90 | + |
|
91 | + if ($_SESSION["leftmenuopened"]==$leftmenu) // To collapse |
|
92 | + { |
|
93 | + //$leftmenu=""; |
|
94 | + $_SESSION["leftmenuopened"]=""; |
|
95 | + } |
|
96 | + else |
|
97 | + { |
|
98 | + $_SESSION["leftmenuopened"]=$leftmenu; |
|
99 | + } |
|
100 | + } else { |
|
101 | + // On va le chercher en session si non defini par le lien |
|
102 | + $leftmenu=isset($_SESSION["leftmenu"])?$_SESSION["leftmenu"]:''; |
|
103 | + } |
|
104 | + if (! empty($forceleftmenu)) $leftmenu=$forceleftmenu; |
|
105 | + |
|
106 | + require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php'; |
|
107 | + $tabMenu=array(); |
|
108 | + $menuArbo = new Menubase($this->db,'auguria'); |
|
109 | + $menuArbo->menuLoad($mainmenu, $leftmenu, $this->type_user, 'auguria', $tabMenu); |
|
110 | + |
|
111 | + $this->tabMenu=$tabMenu; |
|
112 | + } |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * Show menu |
|
117 | + * |
|
118 | + * @param string $mode 'top', 'left', 'jmobile' (used to get full xml ul/li menu) |
|
119 | + * @param array $moredata An array with more data to output |
|
120 | + * @return int 0 or nb of top menu entries if $mode = 'topnb' |
|
121 | 121 | */ |
122 | 122 | function showmenu($mode, $moredata=null) |
123 | 123 | { |
124 | - global $conf, $langs, $user; |
|
124 | + global $conf, $langs, $user; |
|
125 | 125 | |
126 | - require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/auguria.lib.php'; |
|
126 | + require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/auguria.lib.php'; |
|
127 | 127 | |
128 | - if ($this->type_user == 1) |
|
129 | - { |
|
130 | - $conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED=1; |
|
131 | - $conf->global->MAIN_SEARCHFORM_CONTACT_DISABLED=1; |
|
132 | - } |
|
128 | + if ($this->type_user == 1) |
|
129 | + { |
|
130 | + $conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED=1; |
|
131 | + $conf->global->MAIN_SEARCHFORM_CONTACT_DISABLED=1; |
|
132 | + } |
|
133 | 133 | |
134 | 134 | require_once DOL_DOCUMENT_ROOT.'/core/class/menu.class.php'; |
135 | - $this->menu=new Menu(); |
|
135 | + $this->menu=new Menu(); |
|
136 | 136 | |
137 | - if ($mode == 'top') print_auguria_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,0,$mode); |
|
138 | - if ($mode == 'left') print_left_auguria_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu,0,'','',$moredata); |
|
137 | + if ($mode == 'top') print_auguria_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,0,$mode); |
|
138 | + if ($mode == 'left') print_left_auguria_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu,0,'','',$moredata); |
|
139 | 139 | |
140 | 140 | if ($mode == 'topnb') |
141 | 141 | { |
142 | - print_auguria_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,1,$mode); |
|
143 | - return $this->menu->getNbOfVisibleMenuEntries(); |
|
142 | + print_auguria_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,1,$mode); |
|
143 | + return $this->menu->getNbOfVisibleMenuEntries(); |
|
144 | 144 | } |
145 | 145 | |
146 | - if ($mode == 'jmobile') // Used to get menu in xml ul/li |
|
147 | - { |
|
148 | - print_auguria_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,1,$mode); |
|
149 | - |
|
150 | - // $this->menu->liste is top menu |
|
151 | - //var_dump($this->menu->liste);exit; |
|
152 | - $lastlevel = array(); |
|
153 | - print '<!-- Generate menu list from menu handler '.$this->name.' -->'."\n"; |
|
154 | - foreach($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
155 | - { |
|
156 | - print '<ul class="ulmenu" data-inset="true">'; |
|
157 | - print '<li class="lilevel0">'; |
|
158 | - if ($val['enabled'] == 1) |
|
159 | - { |
|
160 | - $relurl=dol_buildpath($val['url'],1); |
|
161 | - $relurl=preg_replace('/__LOGIN__/',$user->login,$relurl); |
|
162 | - $relurl=preg_replace('/__USERID__/',$user->id,$relurl); |
|
163 | - $canonurl=preg_replace('/\?.*$/','',$val['url']); |
|
164 | - |
|
165 | - print '<a class="alilevel0" href="#">'; |
|
146 | + if ($mode == 'jmobile') // Used to get menu in xml ul/li |
|
147 | + { |
|
148 | + print_auguria_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,1,$mode); |
|
149 | + |
|
150 | + // $this->menu->liste is top menu |
|
151 | + //var_dump($this->menu->liste);exit; |
|
152 | + $lastlevel = array(); |
|
153 | + print '<!-- Generate menu list from menu handler '.$this->name.' -->'."\n"; |
|
154 | + foreach($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
155 | + { |
|
156 | + print '<ul class="ulmenu" data-inset="true">'; |
|
157 | + print '<li class="lilevel0">'; |
|
158 | + if ($val['enabled'] == 1) |
|
159 | + { |
|
160 | + $relurl=dol_buildpath($val['url'],1); |
|
161 | + $relurl=preg_replace('/__LOGIN__/',$user->login,$relurl); |
|
162 | + $relurl=preg_replace('/__USERID__/',$user->id,$relurl); |
|
163 | + $canonurl=preg_replace('/\?.*$/','',$val['url']); |
|
164 | + |
|
165 | + print '<a class="alilevel0" href="#">'; |
|
166 | 166 | |
167 | 167 | // Add font-awesome |
168 | 168 | if ($val['level'] == 0 && $val['mainmenu'] == 'home') print '<span class="fa fa-home fa-fw paddingright" aria-hidden="true"></span>'; |
169 | 169 | |
170 | 170 | print $val['titre']; |
171 | - print '</a>'."\n"; |
|
172 | - |
|
173 | - // Search submenu fot this mainmenu entry |
|
174 | - $tmpmainmenu=$val['mainmenu']; |
|
175 | - $tmpleftmenu='all'; |
|
176 | - $submenu=new Menu(); |
|
177 | - print_left_auguria_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$submenu,1,$tmpmainmenu,$tmpleftmenu); |
|
178 | - $nexturl=dol_buildpath($submenu->liste[0]['url'],1); |
|
179 | - |
|
180 | - $canonrelurl=preg_replace('/\?.*$/','',$relurl); |
|
181 | - $canonnexturl=preg_replace('/\?.*$/','',$nexturl); |
|
182 | - //var_dump($canonrelurl); |
|
183 | - //var_dump($canonnexturl); |
|
184 | - print '<ul>'."\n"; |
|
185 | - if (($canonrelurl != $canonnexturl && ! in_array($val['mainmenu'],array('tools'))) |
|
186 | - || (strpos($canonrelurl,'/product/index.php') !== false || strpos($canonrelurl,'/compta/bank/list.php') !== false)) |
|
171 | + print '</a>'."\n"; |
|
172 | + |
|
173 | + // Search submenu fot this mainmenu entry |
|
174 | + $tmpmainmenu=$val['mainmenu']; |
|
175 | + $tmpleftmenu='all'; |
|
176 | + $submenu=new Menu(); |
|
177 | + print_left_auguria_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$submenu,1,$tmpmainmenu,$tmpleftmenu); |
|
178 | + $nexturl=dol_buildpath($submenu->liste[0]['url'],1); |
|
179 | + |
|
180 | + $canonrelurl=preg_replace('/\?.*$/','',$relurl); |
|
181 | + $canonnexturl=preg_replace('/\?.*$/','',$nexturl); |
|
182 | + //var_dump($canonrelurl); |
|
183 | + //var_dump($canonnexturl); |
|
184 | + print '<ul>'."\n"; |
|
185 | + if (($canonrelurl != $canonnexturl && ! in_array($val['mainmenu'],array('tools'))) |
|
186 | + || (strpos($canonrelurl,'/product/index.php') !== false || strpos($canonrelurl,'/compta/bank/list.php') !== false)) |
|
187 | 187 | { |
188 | 188 | // We add sub entry |
189 | 189 | print str_pad('',1).'<li class="lilevel1 ui-btn-icon-right ui-btn">'; // ui-btn to highlight on clic |
190 | 190 | print '<a href="'.$relurl.'">'; |
191 | - if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") // No translation |
|
192 | - { |
|
193 | - if (in_array($val['mainmenu'], array('cashdesk', 'websites'))) print $langs->trans("Access"); |
|
194 | - else print $langs->trans("Dashboard"); |
|
195 | - } |
|
191 | + if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") // No translation |
|
192 | + { |
|
193 | + if (in_array($val['mainmenu'], array('cashdesk', 'websites'))) print $langs->trans("Access"); |
|
194 | + else print $langs->trans("Dashboard"); |
|
195 | + } |
|
196 | 196 | else print $langs->trans(ucfirst($val['mainmenu'])."Dashboard"); |
197 | 197 | print '</a>'; |
198 | 198 | print '</li>'."\n"; |
199 | - } |
|
199 | + } |
|
200 | 200 | |
201 | - if ($val['level']==0) |
|
201 | + if ($val['level']==0) |
|
202 | 202 | { |
203 | - if ($val['enabled']) |
|
204 | - { |
|
205 | - $lastlevel[0]='enabled'; |
|
206 | - } |
|
207 | - else if ($showmenu) // Not enabled but visible (so greyed) |
|
208 | - { |
|
209 | - $lastlevel[0]='greyed'; |
|
210 | - } |
|
211 | - else |
|
212 | - { |
|
213 | - $lastlevel[0]='hidden'; |
|
214 | - } |
|
203 | + if ($val['enabled']) |
|
204 | + { |
|
205 | + $lastlevel[0]='enabled'; |
|
206 | + } |
|
207 | + else if ($showmenu) // Not enabled but visible (so greyed) |
|
208 | + { |
|
209 | + $lastlevel[0]='greyed'; |
|
210 | + } |
|
211 | + else |
|
212 | + { |
|
213 | + $lastlevel[0]='hidden'; |
|
214 | + } |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | $lastlevel2 = array(); |
218 | 218 | foreach($submenu->liste as $key2 => $val2) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
219 | - { |
|
219 | + { |
|
220 | 220 | $showmenu=true; |
221 | 221 | if (! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($val2['enabled'])) $showmenu=false; |
222 | 222 | |
223 | - // If at least one parent is not enabled, we do not show any menu of all children |
|
223 | + // If at least one parent is not enabled, we do not show any menu of all children |
|
224 | 224 | if ($val2['level'] > 0) |
225 | 225 | { |
226 | - $levelcursor = $val2['level']-1; |
|
227 | - while ($levelcursor >= 0) |
|
228 | - { |
|
229 | - if ($lastlevel2[$levelcursor] != 'enabled') $showmenu=false; |
|
230 | - $levelcursor--; |
|
231 | - } |
|
226 | + $levelcursor = $val2['level']-1; |
|
227 | + while ($levelcursor >= 0) |
|
228 | + { |
|
229 | + if ($lastlevel2[$levelcursor] != 'enabled') $showmenu=false; |
|
230 | + $levelcursor--; |
|
231 | + } |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | if ($showmenu) // Visible (option to hide when not allowed is off or allowed) |
235 | - { |
|
236 | - $relurl2=dol_buildpath($val2['url'],1); |
|
237 | - $relurl2=preg_replace('/__LOGIN__/',$user->login,$relurl2); |
|
238 | - $relurl2=preg_replace('/__USERID__/',$user->id,$relurl2); |
|
239 | - $canonurl2=preg_replace('/\?.*$/','',$val2['url']); |
|
240 | - //var_dump($val2['url'].' - '.$canonurl2.' - '.$val2['level']); |
|
241 | - if (in_array($canonurl2,array('/admin/index.php','/admin/tools/index.php','/core/tools.php'))) $relurl2=''; |
|
242 | - |
|
243 | - $disabled=''; |
|
244 | - if (! $val2['enabled']) |
|
245 | - { |
|
246 | - $disabled=" vsmenudisabled"; |
|
247 | - } |
|
248 | - |
|
249 | - print str_pad('',$val2['level']+1); |
|
250 | - print '<li class="lilevel'.($val2['level']+1); |
|
251 | - if ($val2['level']==0) print ' ui-btn-icon-right ui-btn'; // ui-btn to highlight on clic |
|
252 | - print $disabled.'">'; // ui-btn to highlight on clic |
|
253 | - if ($relurl2) |
|
254 | - { |
|
255 | - if ($val2['enabled']) // Allowed |
|
256 | - { |
|
257 | - print '<a href="'.$relurl2.'"'; |
|
258 | - //print ' data-ajax="false"'; |
|
259 | - print '>'; |
|
260 | - $lastlevel2[$val2['level']]='enabled'; |
|
261 | - } |
|
262 | - else // Not allowed but visible (greyed) |
|
263 | - { |
|
264 | - print '<a href="#" class="vsmenudisabled">'; |
|
265 | - $lastlevel2[$val2['level']]='greyed'; |
|
266 | - } |
|
267 | - } |
|
268 | - else |
|
269 | - { |
|
270 | - if ($val2['enabled']) // Allowed |
|
271 | - { |
|
272 | - $lastlevel2[$val2['level']]='enabled'; |
|
273 | - } |
|
274 | - else |
|
275 | - { |
|
276 | - $lastlevel2[$val2['level']]='greyed'; |
|
277 | - } |
|
278 | - } |
|
279 | - print $val2['titre']; |
|
280 | - if ($relurl2) |
|
281 | - { |
|
282 | - if ($val2['enabled']) // Allowed |
|
283 | - print '</a>'; |
|
284 | - else |
|
285 | - print '</a>'; |
|
286 | - } |
|
287 | - print '</li>'."\n"; |
|
288 | - } |
|
289 | - } |
|
290 | - //var_dump($submenu); |
|
291 | - print '</ul>'; |
|
292 | - } |
|
293 | - if ($val['enabled'] == 2) |
|
294 | - { |
|
295 | - print '<font class="vsmenudisabled">'.$val['titre'].'</font>'; |
|
296 | - } |
|
297 | - print '</li>'; |
|
298 | - print '</ul>'."\n"; |
|
299 | - } |
|
300 | - } |
|
301 | - |
|
302 | - unset($this->menu); |
|
303 | - } |
|
235 | + { |
|
236 | + $relurl2=dol_buildpath($val2['url'],1); |
|
237 | + $relurl2=preg_replace('/__LOGIN__/',$user->login,$relurl2); |
|
238 | + $relurl2=preg_replace('/__USERID__/',$user->id,$relurl2); |
|
239 | + $canonurl2=preg_replace('/\?.*$/','',$val2['url']); |
|
240 | + //var_dump($val2['url'].' - '.$canonurl2.' - '.$val2['level']); |
|
241 | + if (in_array($canonurl2,array('/admin/index.php','/admin/tools/index.php','/core/tools.php'))) $relurl2=''; |
|
242 | + |
|
243 | + $disabled=''; |
|
244 | + if (! $val2['enabled']) |
|
245 | + { |
|
246 | + $disabled=" vsmenudisabled"; |
|
247 | + } |
|
248 | + |
|
249 | + print str_pad('',$val2['level']+1); |
|
250 | + print '<li class="lilevel'.($val2['level']+1); |
|
251 | + if ($val2['level']==0) print ' ui-btn-icon-right ui-btn'; // ui-btn to highlight on clic |
|
252 | + print $disabled.'">'; // ui-btn to highlight on clic |
|
253 | + if ($relurl2) |
|
254 | + { |
|
255 | + if ($val2['enabled']) // Allowed |
|
256 | + { |
|
257 | + print '<a href="'.$relurl2.'"'; |
|
258 | + //print ' data-ajax="false"'; |
|
259 | + print '>'; |
|
260 | + $lastlevel2[$val2['level']]='enabled'; |
|
261 | + } |
|
262 | + else // Not allowed but visible (greyed) |
|
263 | + { |
|
264 | + print '<a href="#" class="vsmenudisabled">'; |
|
265 | + $lastlevel2[$val2['level']]='greyed'; |
|
266 | + } |
|
267 | + } |
|
268 | + else |
|
269 | + { |
|
270 | + if ($val2['enabled']) // Allowed |
|
271 | + { |
|
272 | + $lastlevel2[$val2['level']]='enabled'; |
|
273 | + } |
|
274 | + else |
|
275 | + { |
|
276 | + $lastlevel2[$val2['level']]='greyed'; |
|
277 | + } |
|
278 | + } |
|
279 | + print $val2['titre']; |
|
280 | + if ($relurl2) |
|
281 | + { |
|
282 | + if ($val2['enabled']) // Allowed |
|
283 | + print '</a>'; |
|
284 | + else |
|
285 | + print '</a>'; |
|
286 | + } |
|
287 | + print '</li>'."\n"; |
|
288 | + } |
|
289 | + } |
|
290 | + //var_dump($submenu); |
|
291 | + print '</ul>'; |
|
292 | + } |
|
293 | + if ($val['enabled'] == 2) |
|
294 | + { |
|
295 | + print '<font class="vsmenudisabled">'.$val['titre'].'</font>'; |
|
296 | + } |
|
297 | + print '</li>'; |
|
298 | + print '</ul>'."\n"; |
|
299 | + } |
|
300 | + } |
|
301 | + |
|
302 | + unset($this->menu); |
|
303 | + } |
|
304 | 304 | } |
305 | 305 |
@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | class MenuManager |
30 | 30 | { |
31 | 31 | var $db; |
32 | - var $type_user; // Put 0 for internal users, 1 for external users |
|
33 | - var $atarget=""; // To store default target to use onto links |
|
34 | - var $name="auguria"; |
|
32 | + var $type_user; // Put 0 for internal users, 1 for external users |
|
33 | + var $atarget = ""; // To store default target to use onto links |
|
34 | + var $name = "auguria"; |
|
35 | 35 | |
36 | 36 | var $menu_array; |
37 | 37 | var $menu_array_after; |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | */ |
48 | 48 | function __construct($db, $type_user) |
49 | 49 | { |
50 | - $this->type_user=$type_user; |
|
51 | - $this->db=$db; |
|
50 | + $this->type_user = $type_user; |
|
51 | + $this->db = $db; |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
@@ -59,56 +59,56 @@ discard block |
||
59 | 59 | * @param string $forceleftmenu To force leftmenu to load |
60 | 60 | * @return void |
61 | 61 | */ |
62 | - function loadMenu($forcemainmenu='',$forceleftmenu='') |
|
62 | + function loadMenu($forcemainmenu = '', $forceleftmenu = '') |
|
63 | 63 | { |
64 | 64 | global $conf, $user, $langs; |
65 | 65 | |
66 | 66 | // On sauve en session le menu principal choisi |
67 | - if (isset($_GET["mainmenu"])) $_SESSION["mainmenu"]=$_GET["mainmenu"]; |
|
68 | - if (isset($_GET["idmenu"])) $_SESSION["idmenu"]=$_GET["idmenu"]; |
|
67 | + if (isset($_GET["mainmenu"])) $_SESSION["mainmenu"] = $_GET["mainmenu"]; |
|
68 | + if (isset($_GET["idmenu"])) $_SESSION["idmenu"] = $_GET["idmenu"]; |
|
69 | 69 | |
70 | 70 | // Read mainmenu and leftmenu that define which menu to show |
71 | 71 | if (isset($_GET["mainmenu"])) |
72 | 72 | { |
73 | 73 | // On sauve en session le menu principal choisi |
74 | - $mainmenu=$_GET["mainmenu"]; |
|
75 | - $_SESSION["mainmenu"]=$mainmenu; |
|
76 | - $_SESSION["leftmenuopened"]=""; |
|
74 | + $mainmenu = $_GET["mainmenu"]; |
|
75 | + $_SESSION["mainmenu"] = $mainmenu; |
|
76 | + $_SESSION["leftmenuopened"] = ""; |
|
77 | 77 | } |
78 | 78 | else |
79 | 79 | { |
80 | 80 | // On va le chercher en session si non defini par le lien |
81 | - $mainmenu=isset($_SESSION["mainmenu"])?$_SESSION["mainmenu"]:''; |
|
81 | + $mainmenu = isset($_SESSION["mainmenu"]) ? $_SESSION["mainmenu"] : ''; |
|
82 | 82 | } |
83 | - if (! empty($forcemainmenu)) $mainmenu=$forcemainmenu; |
|
83 | + if (!empty($forcemainmenu)) $mainmenu = $forcemainmenu; |
|
84 | 84 | |
85 | 85 | if (isset($_GET["leftmenu"])) |
86 | 86 | { |
87 | 87 | // On sauve en session le menu principal choisi |
88 | - $leftmenu=$_GET["leftmenu"]; |
|
89 | - $_SESSION["leftmenu"]=$leftmenu; |
|
88 | + $leftmenu = $_GET["leftmenu"]; |
|
89 | + $_SESSION["leftmenu"] = $leftmenu; |
|
90 | 90 | |
91 | - if ($_SESSION["leftmenuopened"]==$leftmenu) // To collapse |
|
91 | + if ($_SESSION["leftmenuopened"] == $leftmenu) // To collapse |
|
92 | 92 | { |
93 | 93 | //$leftmenu=""; |
94 | - $_SESSION["leftmenuopened"]=""; |
|
94 | + $_SESSION["leftmenuopened"] = ""; |
|
95 | 95 | } |
96 | 96 | else |
97 | 97 | { |
98 | - $_SESSION["leftmenuopened"]=$leftmenu; |
|
98 | + $_SESSION["leftmenuopened"] = $leftmenu; |
|
99 | 99 | } |
100 | 100 | } else { |
101 | 101 | // On va le chercher en session si non defini par le lien |
102 | - $leftmenu=isset($_SESSION["leftmenu"])?$_SESSION["leftmenu"]:''; |
|
102 | + $leftmenu = isset($_SESSION["leftmenu"]) ? $_SESSION["leftmenu"] : ''; |
|
103 | 103 | } |
104 | - if (! empty($forceleftmenu)) $leftmenu=$forceleftmenu; |
|
104 | + if (!empty($forceleftmenu)) $leftmenu = $forceleftmenu; |
|
105 | 105 | |
106 | 106 | require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php'; |
107 | - $tabMenu=array(); |
|
108 | - $menuArbo = new Menubase($this->db,'auguria'); |
|
107 | + $tabMenu = array(); |
|
108 | + $menuArbo = new Menubase($this->db, 'auguria'); |
|
109 | 109 | $menuArbo->menuLoad($mainmenu, $leftmenu, $this->type_user, 'auguria', $tabMenu); |
110 | 110 | |
111 | - $this->tabMenu=$tabMenu; |
|
111 | + $this->tabMenu = $tabMenu; |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @param array $moredata An array with more data to output |
120 | 120 | * @return int 0 or nb of top menu entries if $mode = 'topnb' |
121 | 121 | */ |
122 | - function showmenu($mode, $moredata=null) |
|
122 | + function showmenu($mode, $moredata = null) |
|
123 | 123 | { |
124 | 124 | global $conf, $langs, $user; |
125 | 125 | |
@@ -127,40 +127,40 @@ discard block |
||
127 | 127 | |
128 | 128 | if ($this->type_user == 1) |
129 | 129 | { |
130 | - $conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED=1; |
|
131 | - $conf->global->MAIN_SEARCHFORM_CONTACT_DISABLED=1; |
|
130 | + $conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED = 1; |
|
131 | + $conf->global->MAIN_SEARCHFORM_CONTACT_DISABLED = 1; |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | require_once DOL_DOCUMENT_ROOT.'/core/class/menu.class.php'; |
135 | - $this->menu=new Menu(); |
|
135 | + $this->menu = new Menu(); |
|
136 | 136 | |
137 | - if ($mode == 'top') print_auguria_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,0,$mode); |
|
138 | - if ($mode == 'left') print_left_auguria_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu,0,'','',$moredata); |
|
137 | + if ($mode == 'top') print_auguria_menu($this->db, $this->atarget, $this->type_user, $this->tabMenu, $this->menu, 0, $mode); |
|
138 | + if ($mode == 'left') print_left_auguria_menu($this->db, $this->menu_array, $this->menu_array_after, $this->tabMenu, $this->menu, 0, '', '', $moredata); |
|
139 | 139 | |
140 | 140 | if ($mode == 'topnb') |
141 | 141 | { |
142 | - print_auguria_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,1,$mode); |
|
142 | + print_auguria_menu($this->db, $this->atarget, $this->type_user, $this->tabMenu, $this->menu, 1, $mode); |
|
143 | 143 | return $this->menu->getNbOfVisibleMenuEntries(); |
144 | 144 | } |
145 | 145 | |
146 | 146 | if ($mode == 'jmobile') // Used to get menu in xml ul/li |
147 | 147 | { |
148 | - print_auguria_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,1,$mode); |
|
148 | + print_auguria_menu($this->db, $this->atarget, $this->type_user, $this->tabMenu, $this->menu, 1, $mode); |
|
149 | 149 | |
150 | 150 | // $this->menu->liste is top menu |
151 | 151 | //var_dump($this->menu->liste);exit; |
152 | 152 | $lastlevel = array(); |
153 | 153 | print '<!-- Generate menu list from menu handler '.$this->name.' -->'."\n"; |
154 | - foreach($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
154 | + foreach ($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
155 | 155 | { |
156 | 156 | print '<ul class="ulmenu" data-inset="true">'; |
157 | 157 | print '<li class="lilevel0">'; |
158 | 158 | if ($val['enabled'] == 1) |
159 | 159 | { |
160 | - $relurl=dol_buildpath($val['url'],1); |
|
161 | - $relurl=preg_replace('/__LOGIN__/',$user->login,$relurl); |
|
162 | - $relurl=preg_replace('/__USERID__/',$user->id,$relurl); |
|
163 | - $canonurl=preg_replace('/\?.*$/','',$val['url']); |
|
160 | + $relurl = dol_buildpath($val['url'], 1); |
|
161 | + $relurl = preg_replace('/__LOGIN__/', $user->login, $relurl); |
|
162 | + $relurl = preg_replace('/__USERID__/', $user->id, $relurl); |
|
163 | + $canonurl = preg_replace('/\?.*$/', '', $val['url']); |
|
164 | 164 | |
165 | 165 | print '<a class="alilevel0" href="#">'; |
166 | 166 | |
@@ -171,22 +171,22 @@ discard block |
||
171 | 171 | print '</a>'."\n"; |
172 | 172 | |
173 | 173 | // Search submenu fot this mainmenu entry |
174 | - $tmpmainmenu=$val['mainmenu']; |
|
175 | - $tmpleftmenu='all'; |
|
176 | - $submenu=new Menu(); |
|
177 | - print_left_auguria_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$submenu,1,$tmpmainmenu,$tmpleftmenu); |
|
178 | - $nexturl=dol_buildpath($submenu->liste[0]['url'],1); |
|
179 | - |
|
180 | - $canonrelurl=preg_replace('/\?.*$/','',$relurl); |
|
181 | - $canonnexturl=preg_replace('/\?.*$/','',$nexturl); |
|
174 | + $tmpmainmenu = $val['mainmenu']; |
|
175 | + $tmpleftmenu = 'all'; |
|
176 | + $submenu = new Menu(); |
|
177 | + print_left_auguria_menu($this->db, $this->menu_array, $this->menu_array_after, $this->tabMenu, $submenu, 1, $tmpmainmenu, $tmpleftmenu); |
|
178 | + $nexturl = dol_buildpath($submenu->liste[0]['url'], 1); |
|
179 | + |
|
180 | + $canonrelurl = preg_replace('/\?.*$/', '', $relurl); |
|
181 | + $canonnexturl = preg_replace('/\?.*$/', '', $nexturl); |
|
182 | 182 | //var_dump($canonrelurl); |
183 | 183 | //var_dump($canonnexturl); |
184 | 184 | print '<ul>'."\n"; |
185 | - if (($canonrelurl != $canonnexturl && ! in_array($val['mainmenu'],array('tools'))) |
|
186 | - || (strpos($canonrelurl,'/product/index.php') !== false || strpos($canonrelurl,'/compta/bank/list.php') !== false)) |
|
185 | + if (($canonrelurl != $canonnexturl && !in_array($val['mainmenu'], array('tools'))) |
|
186 | + || (strpos($canonrelurl, '/product/index.php') !== false || strpos($canonrelurl, '/compta/bank/list.php') !== false)) |
|
187 | 187 | { |
188 | 188 | // We add sub entry |
189 | - print str_pad('',1).'<li class="lilevel1 ui-btn-icon-right ui-btn">'; // ui-btn to highlight on clic |
|
189 | + print str_pad('', 1).'<li class="lilevel1 ui-btn-icon-right ui-btn">'; // ui-btn to highlight on clic |
|
190 | 190 | print '<a href="'.$relurl.'">'; |
191 | 191 | if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") // No translation |
192 | 192 | { |
@@ -198,58 +198,58 @@ discard block |
||
198 | 198 | print '</li>'."\n"; |
199 | 199 | } |
200 | 200 | |
201 | - if ($val['level']==0) |
|
201 | + if ($val['level'] == 0) |
|
202 | 202 | { |
203 | 203 | if ($val['enabled']) |
204 | 204 | { |
205 | - $lastlevel[0]='enabled'; |
|
205 | + $lastlevel[0] = 'enabled'; |
|
206 | 206 | } |
207 | 207 | else if ($showmenu) // Not enabled but visible (so greyed) |
208 | 208 | { |
209 | - $lastlevel[0]='greyed'; |
|
209 | + $lastlevel[0] = 'greyed'; |
|
210 | 210 | } |
211 | 211 | else |
212 | 212 | { |
213 | - $lastlevel[0]='hidden'; |
|
213 | + $lastlevel[0] = 'hidden'; |
|
214 | 214 | } |
215 | 215 | } |
216 | 216 | |
217 | 217 | $lastlevel2 = array(); |
218 | - foreach($submenu->liste as $key2 => $val2) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
218 | + foreach ($submenu->liste as $key2 => $val2) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
219 | 219 | { |
220 | - $showmenu=true; |
|
221 | - if (! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($val2['enabled'])) $showmenu=false; |
|
220 | + $showmenu = true; |
|
221 | + if (!empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($val2['enabled'])) $showmenu = false; |
|
222 | 222 | |
223 | 223 | // If at least one parent is not enabled, we do not show any menu of all children |
224 | 224 | if ($val2['level'] > 0) |
225 | 225 | { |
226 | - $levelcursor = $val2['level']-1; |
|
226 | + $levelcursor = $val2['level'] - 1; |
|
227 | 227 | while ($levelcursor >= 0) |
228 | 228 | { |
229 | - if ($lastlevel2[$levelcursor] != 'enabled') $showmenu=false; |
|
229 | + if ($lastlevel2[$levelcursor] != 'enabled') $showmenu = false; |
|
230 | 230 | $levelcursor--; |
231 | 231 | } |
232 | 232 | } |
233 | 233 | |
234 | 234 | if ($showmenu) // Visible (option to hide when not allowed is off or allowed) |
235 | 235 | { |
236 | - $relurl2=dol_buildpath($val2['url'],1); |
|
237 | - $relurl2=preg_replace('/__LOGIN__/',$user->login,$relurl2); |
|
238 | - $relurl2=preg_replace('/__USERID__/',$user->id,$relurl2); |
|
239 | - $canonurl2=preg_replace('/\?.*$/','',$val2['url']); |
|
236 | + $relurl2 = dol_buildpath($val2['url'], 1); |
|
237 | + $relurl2 = preg_replace('/__LOGIN__/', $user->login, $relurl2); |
|
238 | + $relurl2 = preg_replace('/__USERID__/', $user->id, $relurl2); |
|
239 | + $canonurl2 = preg_replace('/\?.*$/', '', $val2['url']); |
|
240 | 240 | //var_dump($val2['url'].' - '.$canonurl2.' - '.$val2['level']); |
241 | - if (in_array($canonurl2,array('/admin/index.php','/admin/tools/index.php','/core/tools.php'))) $relurl2=''; |
|
241 | + if (in_array($canonurl2, array('/admin/index.php', '/admin/tools/index.php', '/core/tools.php'))) $relurl2 = ''; |
|
242 | 242 | |
243 | - $disabled=''; |
|
244 | - if (! $val2['enabled']) |
|
243 | + $disabled = ''; |
|
244 | + if (!$val2['enabled']) |
|
245 | 245 | { |
246 | - $disabled=" vsmenudisabled"; |
|
246 | + $disabled = " vsmenudisabled"; |
|
247 | 247 | } |
248 | 248 | |
249 | - print str_pad('',$val2['level']+1); |
|
250 | - print '<li class="lilevel'.($val2['level']+1); |
|
251 | - if ($val2['level']==0) print ' ui-btn-icon-right ui-btn'; // ui-btn to highlight on clic |
|
252 | - print $disabled.'">'; // ui-btn to highlight on clic |
|
249 | + print str_pad('', $val2['level'] + 1); |
|
250 | + print '<li class="lilevel'.($val2['level'] + 1); |
|
251 | + if ($val2['level'] == 0) print ' ui-btn-icon-right ui-btn'; // ui-btn to highlight on clic |
|
252 | + print $disabled.'">'; // ui-btn to highlight on clic |
|
253 | 253 | if ($relurl2) |
254 | 254 | { |
255 | 255 | if ($val2['enabled']) // Allowed |
@@ -257,23 +257,23 @@ discard block |
||
257 | 257 | print '<a href="'.$relurl2.'"'; |
258 | 258 | //print ' data-ajax="false"'; |
259 | 259 | print '>'; |
260 | - $lastlevel2[$val2['level']]='enabled'; |
|
260 | + $lastlevel2[$val2['level']] = 'enabled'; |
|
261 | 261 | } |
262 | 262 | else // Not allowed but visible (greyed) |
263 | 263 | { |
264 | 264 | print '<a href="#" class="vsmenudisabled">'; |
265 | - $lastlevel2[$val2['level']]='greyed'; |
|
265 | + $lastlevel2[$val2['level']] = 'greyed'; |
|
266 | 266 | } |
267 | 267 | } |
268 | 268 | else |
269 | 269 | { |
270 | 270 | if ($val2['enabled']) // Allowed |
271 | 271 | { |
272 | - $lastlevel2[$val2['level']]='enabled'; |
|
272 | + $lastlevel2[$val2['level']] = 'enabled'; |
|
273 | 273 | } |
274 | 274 | else |
275 | 275 | { |
276 | - $lastlevel2[$val2['level']]='greyed'; |
|
276 | + $lastlevel2[$val2['level']] = 'greyed'; |
|
277 | 277 | } |
278 | 278 | } |
279 | 279 | print $val2['titre']; |
@@ -51,11 +51,11 @@ discard block |
||
51 | 51 | */ |
52 | 52 | function __construct($db,$param) |
53 | 53 | { |
54 | - global $user; |
|
54 | + global $user; |
|
55 | 55 | |
56 | - $this->db=$db; |
|
56 | + $this->db=$db; |
|
57 | 57 | |
58 | - $this->hidden=! ($user->rights->ficheinter->lire); |
|
58 | + $this->hidden=! ($user->rights->ficheinter->lire); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @param int $max Maximum number of records to load |
65 | 65 | * @return void |
66 | - */ |
|
66 | + */ |
|
67 | 67 | function loadBox($max=10) |
68 | 68 | { |
69 | 69 | global $user, $langs, $db, $conf; |
@@ -150,8 +150,8 @@ discard block |
||
150 | 150 | else |
151 | 151 | { |
152 | 152 | $this->info_box_contents[0][0] = array( |
153 | - 'td' => 'align="left" class="nohover opacitymedium"', |
|
154 | - 'text' => $langs->trans("ReadPermissionNotAllowed") |
|
153 | + 'td' => 'align="left" class="nohover opacitymedium"', |
|
154 | + 'text' => $langs->trans("ReadPermissionNotAllowed") |
|
155 | 155 | ); |
156 | 156 | } |
157 | 157 | } |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | * @param int $nooutput No print, only return string |
165 | 165 | * @return string |
166 | 166 | */ |
167 | - function showBox($head = null, $contents = null, $nooutput=0) |
|
168 | - { |
|
167 | + function showBox($head = null, $contents = null, $nooutput=0) |
|
168 | + { |
|
169 | 169 | return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
170 | 170 | } |
171 | 171 |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | */ |
32 | 32 | class box_ficheinter extends ModeleBoxes |
33 | 33 | { |
34 | - var $boxcode="ficheinter"; |
|
35 | - var $boximg="object_intervention"; |
|
36 | - var $boxlabel="BoxFicheInter"; |
|
37 | - var $depends = array("ficheinter"); // conf->contrat->enabled |
|
34 | + var $boxcode = "ficheinter"; |
|
35 | + var $boximg = "object_intervention"; |
|
36 | + var $boxlabel = "BoxFicheInter"; |
|
37 | + var $depends = array("ficheinter"); // conf->contrat->enabled |
|
38 | 38 | |
39 | 39 | var $db; |
40 | 40 | var $param; |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | * @param DoliDB $db Database handler |
50 | 50 | * @param string $param More parameters |
51 | 51 | */ |
52 | - function __construct($db,$param) |
|
52 | + function __construct($db, $param) |
|
53 | 53 | { |
54 | 54 | global $user; |
55 | 55 | |
56 | - $this->db=$db; |
|
56 | + $this->db = $db; |
|
57 | 57 | |
58 | - $this->hidden=! ($user->rights->ficheinter->lire); |
|
58 | + $this->hidden = !($user->rights->ficheinter->lire); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -64,57 +64,57 @@ discard block |
||
64 | 64 | * @param int $max Maximum number of records to load |
65 | 65 | * @return void |
66 | 66 | */ |
67 | - function loadBox($max=10) |
|
67 | + function loadBox($max = 10) |
|
68 | 68 | { |
69 | 69 | global $user, $langs, $db, $conf; |
70 | 70 | |
71 | - $this->max=$max; |
|
71 | + $this->max = $max; |
|
72 | 72 | |
73 | 73 | include_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; |
74 | - $ficheinterstatic=new Fichinter($db); |
|
74 | + $ficheinterstatic = new Fichinter($db); |
|
75 | 75 | |
76 | - $this->info_box_head = array('text' => $langs->trans("BoxTitleLastFicheInter",$max)); |
|
76 | + $this->info_box_head = array('text' => $langs->trans("BoxTitleLastFicheInter", $max)); |
|
77 | 77 | |
78 | 78 | if ($user->rights->ficheinter->lire) |
79 | 79 | { |
80 | 80 | $sql = "SELECT f.rowid, f.ref, f.fk_soc, f.fk_statut,"; |
81 | - $sql.= " f.datec,"; |
|
82 | - $sql.= " f.date_valid as datev,"; |
|
83 | - $sql.= " f.tms as datem,"; |
|
84 | - $sql.= " s.nom as name, s.rowid as socid, s.client"; |
|
85 | - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
86 | - if (! $user->rights->societe->client->voir) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
87 | - $sql.= ", ".MAIN_DB_PREFIX."fichinter as f"; |
|
88 | - $sql.= " WHERE f.fk_soc = s.rowid "; |
|
89 | - $sql.= " AND f.entity = ".$conf->entity; |
|
90 | - if (! $user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
91 | - if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; |
|
92 | - $sql.= " ORDER BY f.tms DESC"; |
|
93 | - $sql.= $db->plimit($max, 0); |
|
81 | + $sql .= " f.datec,"; |
|
82 | + $sql .= " f.date_valid as datev,"; |
|
83 | + $sql .= " f.tms as datem,"; |
|
84 | + $sql .= " s.nom as name, s.rowid as socid, s.client"; |
|
85 | + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
86 | + if (!$user->rights->societe->client->voir) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
87 | + $sql .= ", ".MAIN_DB_PREFIX."fichinter as f"; |
|
88 | + $sql .= " WHERE f.fk_soc = s.rowid "; |
|
89 | + $sql .= " AND f.entity = ".$conf->entity; |
|
90 | + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
91 | + if ($user->societe_id) $sql .= " AND s.rowid = ".$user->societe_id; |
|
92 | + $sql .= " ORDER BY f.tms DESC"; |
|
93 | + $sql .= $db->plimit($max, 0); |
|
94 | 94 | |
95 | 95 | dol_syslog(get_class($this).'::loadBox', LOG_DEBUG); |
96 | 96 | $resql = $db->query($sql); |
97 | 97 | if ($resql) |
98 | 98 | { |
99 | 99 | $num = $db->num_rows($resql); |
100 | - $now=dol_now(); |
|
100 | + $now = dol_now(); |
|
101 | 101 | |
102 | 102 | $i = 0; |
103 | 103 | |
104 | 104 | while ($i < $num) |
105 | 105 | { |
106 | 106 | $objp = $db->fetch_object($resql); |
107 | - $datec=$db->jdate($objp->datec); |
|
107 | + $datec = $db->jdate($objp->datec); |
|
108 | 108 | |
109 | - $ficheinterstatic->statut=$objp->fk_statut; |
|
110 | - $ficheinterstatic->id=$objp->rowid; |
|
109 | + $ficheinterstatic->statut = $objp->fk_statut; |
|
110 | + $ficheinterstatic->id = $objp->rowid; |
|
111 | 111 | |
112 | 112 | $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', |
113 | 113 | 'logo' => $this->boximg, |
114 | 114 | 'url' => DOL_URL_ROOT."/fichinter/card.php?id=".$objp->rowid); |
115 | 115 | |
116 | 116 | $this->info_box_contents[$i][1] = array('td' => '', |
117 | - 'text' => ($objp->ref?$objp->ref:$objp->rowid), // Some interventions have no ref |
|
117 | + 'text' => ($objp->ref ? $objp->ref : $objp->rowid), // Some interventions have no ref |
|
118 | 118 | 'url' => DOL_URL_ROOT."/fichinter/card.php?id=".$objp->rowid); |
119 | 119 | |
120 | 120 | $this->info_box_contents[$i][2] = array('td' => 'align="left" width="16"', |
@@ -122,11 +122,11 @@ discard block |
||
122 | 122 | 'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid); |
123 | 123 | |
124 | 124 | $this->info_box_contents[$i][3] = array('td' => '', |
125 | - 'text' => dol_trunc($objp->name,40), |
|
125 | + 'text' => dol_trunc($objp->name, 40), |
|
126 | 126 | 'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid); |
127 | 127 | |
128 | 128 | $this->info_box_contents[$i][4] = array('td' => 'class="right"', |
129 | - 'text' => dol_print_date($datec,'day')); |
|
129 | + 'text' => dol_print_date($datec, 'day')); |
|
130 | 130 | |
131 | 131 | $this->info_box_contents[$i][5] = array('td' => 'align="right" class="nowrap"', |
132 | 132 | 'text' => $ficheinterstatic->getLibStatut(6), |
@@ -136,13 +136,13 @@ discard block |
||
136 | 136 | $i++; |
137 | 137 | } |
138 | 138 | |
139 | - if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedInterventions")); |
|
139 | + if ($num == 0) $this->info_box_contents[$i][0] = array('td' => 'align="center"', 'text'=>$langs->trans("NoRecordedInterventions")); |
|
140 | 140 | |
141 | 141 | $db->free($resql); |
142 | 142 | } |
143 | 143 | else |
144 | 144 | { |
145 | - $this->info_box_contents[0][0] = array( 'td' => '', |
|
145 | + $this->info_box_contents[0][0] = array('td' => '', |
|
146 | 146 | 'maxlength'=>500, |
147 | 147 | 'text' => ($db->error().' sql='.$sql)); |
148 | 148 | } |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | * @param int $nooutput No print, only return string |
165 | 165 | * @return string |
166 | 166 | */ |
167 | - function showBox($head = null, $contents = null, $nooutput=0) |
|
167 | + function showBox($head = null, $contents = null, $nooutput = 0) |
|
168 | 168 | { |
169 | 169 | return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
170 | 170 | } |
@@ -83,12 +83,18 @@ discard block |
||
83 | 83 | $sql.= " f.tms as datem,"; |
84 | 84 | $sql.= " s.nom as name, s.rowid as socid, s.client"; |
85 | 85 | $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
86 | - if (! $user->rights->societe->client->voir) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
86 | + if (! $user->rights->societe->client->voir) { |
|
87 | + $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
88 | + } |
|
87 | 89 | $sql.= ", ".MAIN_DB_PREFIX."fichinter as f"; |
88 | 90 | $sql.= " WHERE f.fk_soc = s.rowid "; |
89 | 91 | $sql.= " AND f.entity = ".$conf->entity; |
90 | - if (! $user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
91 | - if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; |
|
92 | + if (! $user->rights->societe->client->voir && !$user->societe_id) { |
|
93 | + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
94 | + } |
|
95 | + if($user->societe_id) { |
|
96 | + $sql.= " AND s.rowid = ".$user->societe_id; |
|
97 | + } |
|
92 | 98 | $sql.= " ORDER BY f.tms DESC"; |
93 | 99 | $sql.= $db->plimit($max, 0); |
94 | 100 | |
@@ -136,18 +142,18 @@ discard block |
||
136 | 142 | $i++; |
137 | 143 | } |
138 | 144 | |
139 | - if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedInterventions")); |
|
145 | + if ($num==0) { |
|
146 | + $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedInterventions")); |
|
147 | + } |
|
140 | 148 | |
141 | 149 | $db->free($resql); |
142 | - } |
|
143 | - else |
|
150 | + } else |
|
144 | 151 | { |
145 | 152 | $this->info_box_contents[0][0] = array( 'td' => '', |
146 | 153 | 'maxlength'=>500, |
147 | 154 | 'text' => ($db->error().' sql='.$sql)); |
148 | 155 | } |
149 | - } |
|
150 | - else |
|
156 | + } else |
|
151 | 157 | { |
152 | 158 | $this->info_box_contents[0][0] = array( |
153 | 159 | 'td' => 'align="left" class="nohover opacitymedium"', |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * Constructor |
51 | 51 | * |
52 | 52 | * @param DoliDB $db Database handler |
53 | - * @param string $param More parameters |
|
53 | + * @param string $param More parameters |
|
54 | 54 | */ |
55 | 55 | function __construct($db,$param='') |
56 | 56 | { |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * Load data into info_box_contents array to show array later. |
70 | 70 | * |
71 | 71 | * @param int $max Maximum number of records to load |
72 | - * @return void |
|
72 | + * @return void |
|
73 | 73 | */ |
74 | 74 | function loadBox($max=5) |
75 | 75 | { |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | |
80 | 80 | $this->info_box_head = array('text' => $langs->trans("BoxTitleCurrentAccounts")); |
81 | 81 | |
82 | - if ($user->rights->banque->lire) { |
|
82 | + if ($user->rights->banque->lire) { |
|
83 | 83 | $sql = "SELECT rowid, ref, label, bank, number, courant, clos, rappro, url,"; |
84 | 84 | $sql.= " code_banque, code_guichet, cle_rib, bic, iban_prefix as iban,"; |
85 | 85 | $sql.= " domiciliation, proprio, owner_address,"; |
@@ -92,78 +92,78 @@ discard block |
||
92 | 92 | $sql.= " ORDER BY label"; |
93 | 93 | $sql.= $db->plimit($max, 0); |
94 | 94 | |
95 | - dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); |
|
96 | - $result = $db->query($sql); |
|
97 | - if ($result) { |
|
98 | - $num = $db->num_rows($result); |
|
95 | + dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); |
|
96 | + $result = $db->query($sql); |
|
97 | + if ($result) { |
|
98 | + $num = $db->num_rows($result); |
|
99 | 99 | |
100 | - $line = 0; |
|
101 | - $solde_total = array(); |
|
100 | + $line = 0; |
|
101 | + $solde_total = array(); |
|
102 | 102 | |
103 | - $account_static = new Account($db); |
|
104 | - while ($line < $num) { |
|
105 | - $objp = $db->fetch_object($result); |
|
103 | + $account_static = new Account($db); |
|
104 | + while ($line < $num) { |
|
105 | + $objp = $db->fetch_object($result); |
|
106 | 106 | |
107 | - $account_static->id = $objp->rowid; |
|
107 | + $account_static->id = $objp->rowid; |
|
108 | 108 | $account_static->ref = $objp->ref; |
109 | - $account_static->label = $objp->label; |
|
110 | - $account_static->number = $objp->number; |
|
111 | - $solde=$account_static->solde(0); |
|
112 | - |
|
113 | - $solde_total[$objp->currency_code] += $solde; |
|
114 | - |
|
115 | - $this->info_box_contents[$line][] = array( |
|
116 | - 'td' => '', |
|
117 | - 'text' => $account_static->getNomUrl(1), |
|
118 | - 'asis' => 1, |
|
119 | - ); |
|
120 | - |
|
121 | - $this->info_box_contents[$line][] = array( |
|
122 | - 'td' => '', |
|
123 | - 'text' => $objp->number, |
|
124 | - ); |
|
125 | - |
|
126 | - $this->info_box_contents[$line][] = array( |
|
127 | - 'td' => 'class="right"', |
|
128 | - 'text' => price($solde, 0, $langs, 0, -1, -1, $objp->currency_code) |
|
129 | - ); |
|
130 | - |
|
131 | - $line++; |
|
132 | - } |
|
133 | - |
|
134 | - // Total |
|
135 | - foreach ($solde_total as $key=>$solde) { |
|
136 | - $this->info_box_contents[$line][] = array( |
|
137 | - 'tr' => 'class="liste_total"', |
|
138 | - 'td' => 'align="left" class="liste_total"', |
|
139 | - 'text' => $langs->trans('Total').' '.$key, |
|
140 | - ); |
|
141 | - $this->info_box_contents[$line][] = array( |
|
142 | - 'td' => 'align="right" class="liste_total"', |
|
143 | - 'text' => ' ' |
|
144 | - ); |
|
145 | - |
|
146 | - $this->info_box_contents[$line][] = array( |
|
147 | - 'td' => 'align="right" class="liste_total"', |
|
148 | - 'text' => price($solde, 0, $langs, 0, -1, -1, $key) |
|
149 | - ); |
|
150 | - $line++; |
|
151 | - } |
|
152 | - |
|
153 | - $db->free($result); |
|
154 | - } else { |
|
155 | - $this->info_box_contents[0][0] = array( |
|
156 | - 'td' => '', |
|
157 | - 'maxlength'=>500, |
|
158 | - 'text' => ($db->error().' sql='.$sql), |
|
159 | - ); |
|
160 | - } |
|
161 | - } else { |
|
162 | - $this->info_box_contents[0][0] = array( |
|
163 | - 'td' => 'align="left" class="nohover opacitymedium"', |
|
164 | - 'text' => $langs->trans("ReadPermissionNotAllowed") |
|
165 | - ); |
|
166 | - } |
|
109 | + $account_static->label = $objp->label; |
|
110 | + $account_static->number = $objp->number; |
|
111 | + $solde=$account_static->solde(0); |
|
112 | + |
|
113 | + $solde_total[$objp->currency_code] += $solde; |
|
114 | + |
|
115 | + $this->info_box_contents[$line][] = array( |
|
116 | + 'td' => '', |
|
117 | + 'text' => $account_static->getNomUrl(1), |
|
118 | + 'asis' => 1, |
|
119 | + ); |
|
120 | + |
|
121 | + $this->info_box_contents[$line][] = array( |
|
122 | + 'td' => '', |
|
123 | + 'text' => $objp->number, |
|
124 | + ); |
|
125 | + |
|
126 | + $this->info_box_contents[$line][] = array( |
|
127 | + 'td' => 'class="right"', |
|
128 | + 'text' => price($solde, 0, $langs, 0, -1, -1, $objp->currency_code) |
|
129 | + ); |
|
130 | + |
|
131 | + $line++; |
|
132 | + } |
|
133 | + |
|
134 | + // Total |
|
135 | + foreach ($solde_total as $key=>$solde) { |
|
136 | + $this->info_box_contents[$line][] = array( |
|
137 | + 'tr' => 'class="liste_total"', |
|
138 | + 'td' => 'align="left" class="liste_total"', |
|
139 | + 'text' => $langs->trans('Total').' '.$key, |
|
140 | + ); |
|
141 | + $this->info_box_contents[$line][] = array( |
|
142 | + 'td' => 'align="right" class="liste_total"', |
|
143 | + 'text' => ' ' |
|
144 | + ); |
|
145 | + |
|
146 | + $this->info_box_contents[$line][] = array( |
|
147 | + 'td' => 'align="right" class="liste_total"', |
|
148 | + 'text' => price($solde, 0, $langs, 0, -1, -1, $key) |
|
149 | + ); |
|
150 | + $line++; |
|
151 | + } |
|
152 | + |
|
153 | + $db->free($result); |
|
154 | + } else { |
|
155 | + $this->info_box_contents[0][0] = array( |
|
156 | + 'td' => '', |
|
157 | + 'maxlength'=>500, |
|
158 | + 'text' => ($db->error().' sql='.$sql), |
|
159 | + ); |
|
160 | + } |
|
161 | + } else { |
|
162 | + $this->info_box_contents[0][0] = array( |
|
163 | + 'td' => 'align="left" class="nohover opacitymedium"', |
|
164 | + 'text' => $langs->trans("ReadPermissionNotAllowed") |
|
165 | + ); |
|
166 | + } |
|
167 | 167 | |
168 | 168 | } |
169 | 169 | |
@@ -175,8 +175,8 @@ discard block |
||
175 | 175 | * @param int $nooutput No print, only return string |
176 | 176 | * @return string |
177 | 177 | */ |
178 | - function showBox($head = null, $contents = null, $nooutput=0) |
|
179 | - { |
|
178 | + function showBox($head = null, $contents = null, $nooutput=0) |
|
179 | + { |
|
180 | 180 | return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
181 | 181 | } |
182 | 182 |
@@ -33,10 +33,10 @@ discard block |
||
33 | 33 | */ |
34 | 34 | class box_comptes extends ModeleBoxes |
35 | 35 | { |
36 | - var $boxcode="currentaccounts"; |
|
37 | - var $boximg="object_bill"; |
|
38 | - var $boxlabel="BoxCurrentAccounts"; |
|
39 | - var $depends = array("banque"); // Box active if module banque active |
|
36 | + var $boxcode = "currentaccounts"; |
|
37 | + var $boximg = "object_bill"; |
|
38 | + var $boxlabel = "BoxCurrentAccounts"; |
|
39 | + var $depends = array("banque"); // Box active if module banque active |
|
40 | 40 | |
41 | 41 | var $db; |
42 | 42 | var $param; |
@@ -52,17 +52,17 @@ discard block |
||
52 | 52 | * @param DoliDB $db Database handler |
53 | 53 | * @param string $param More parameters |
54 | 54 | */ |
55 | - function __construct($db,$param='') |
|
55 | + function __construct($db, $param = '') |
|
56 | 56 | { |
57 | 57 | global $conf, $user; |
58 | 58 | |
59 | 59 | $this->db = $db; |
60 | 60 | |
61 | 61 | // disable module for such cases |
62 | - $listofmodulesforexternal=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL); |
|
63 | - if (! in_array('banque',$listofmodulesforexternal) && ! empty($user->societe_id)) $this->enabled=0; // disabled for external users |
|
62 | + $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); |
|
63 | + if (!in_array('banque', $listofmodulesforexternal) && !empty($user->societe_id)) $this->enabled = 0; // disabled for external users |
|
64 | 64 | |
65 | - $this->hidden = ! ($user->rights->banque->lire); |
|
65 | + $this->hidden = !($user->rights->banque->lire); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -71,26 +71,26 @@ discard block |
||
71 | 71 | * @param int $max Maximum number of records to load |
72 | 72 | * @return void |
73 | 73 | */ |
74 | - function loadBox($max=5) |
|
74 | + function loadBox($max = 5) |
|
75 | 75 | { |
76 | 76 | global $user, $langs, $db, $conf; |
77 | 77 | |
78 | - $this->max=$max; |
|
78 | + $this->max = $max; |
|
79 | 79 | |
80 | 80 | $this->info_box_head = array('text' => $langs->trans("BoxTitleCurrentAccounts")); |
81 | 81 | |
82 | 82 | if ($user->rights->banque->lire) { |
83 | 83 | $sql = "SELECT rowid, ref, label, bank, number, courant, clos, rappro, url,"; |
84 | - $sql.= " code_banque, code_guichet, cle_rib, bic, iban_prefix as iban,"; |
|
85 | - $sql.= " domiciliation, proprio, owner_address,"; |
|
86 | - $sql.= " account_number, currency_code,"; |
|
87 | - $sql.= " min_allowed, min_desired, comment"; |
|
88 | - $sql.= " FROM ".MAIN_DB_PREFIX."bank_account"; |
|
89 | - $sql.= " WHERE entity = ".$conf->entity; |
|
90 | - $sql.= " AND clos = 0"; |
|
84 | + $sql .= " code_banque, code_guichet, cle_rib, bic, iban_prefix as iban,"; |
|
85 | + $sql .= " domiciliation, proprio, owner_address,"; |
|
86 | + $sql .= " account_number, currency_code,"; |
|
87 | + $sql .= " min_allowed, min_desired, comment"; |
|
88 | + $sql .= " FROM ".MAIN_DB_PREFIX."bank_account"; |
|
89 | + $sql .= " WHERE entity = ".$conf->entity; |
|
90 | + $sql .= " AND clos = 0"; |
|
91 | 91 | //$sql.= " AND courant = 1"; |
92 | - $sql.= " ORDER BY label"; |
|
93 | - $sql.= $db->plimit($max, 0); |
|
92 | + $sql .= " ORDER BY label"; |
|
93 | + $sql .= $db->plimit($max, 0); |
|
94 | 94 | |
95 | 95 | dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); |
96 | 96 | $result = $db->query($sql); |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $account_static->ref = $objp->ref; |
109 | 109 | $account_static->label = $objp->label; |
110 | 110 | $account_static->number = $objp->number; |
111 | - $solde=$account_static->solde(0); |
|
111 | + $solde = $account_static->solde(0); |
|
112 | 112 | |
113 | 113 | $solde_total[$objp->currency_code] += $solde; |
114 | 114 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | * @param int $nooutput No print, only return string |
176 | 176 | * @return string |
177 | 177 | */ |
178 | - function showBox($head = null, $contents = null, $nooutput=0) |
|
178 | + function showBox($head = null, $contents = null, $nooutput = 0) |
|
179 | 179 | { |
180 | 180 | return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
181 | 181 | } |
@@ -60,7 +60,10 @@ |
||
60 | 60 | |
61 | 61 | // disable module for such cases |
62 | 62 | $listofmodulesforexternal=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL); |
63 | - if (! in_array('banque',$listofmodulesforexternal) && ! empty($user->societe_id)) $this->enabled=0; // disabled for external users |
|
63 | + if (! in_array('banque',$listofmodulesforexternal) && ! empty($user->societe_id)) { |
|
64 | + $this->enabled=0; |
|
65 | + } |
|
66 | + // disabled for external users |
|
64 | 67 | |
65 | 68 | $this->hidden = ! ($user->rights->banque->lire); |
66 | 69 | } |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | */ |
56 | 56 | function __construct($db,$param='') |
57 | 57 | { |
58 | - global $user; |
|
58 | + global $user; |
|
59 | 59 | |
60 | - $this->db = $db; |
|
60 | + $this->db = $db; |
|
61 | 61 | |
62 | 62 | $this->hidden = ! (($user->rights->produit->lire || $user->rights->service->lire) && $user->rights->stock->lire); |
63 | 63 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * Load data into info_box_contents array to show array later. |
67 | 67 | * |
68 | 68 | * @param int $max Maximum number of records to load |
69 | - * @return void |
|
69 | + * @return void |
|
70 | 70 | */ |
71 | 71 | function loadBox($max=5) |
72 | 72 | { |
@@ -90,13 +90,13 @@ discard block |
||
90 | 90 | if (empty($user->rights->produit->lire)) $sql.=' AND p.fk_product_type != 0'; |
91 | 91 | if (empty($user->rights->service->lire)) $sql.=' AND p.fk_product_type != 1'; |
92 | 92 | // Add where from hooks |
93 | - if (is_object($hookmanager)) |
|
94 | - { |
|
95 | - $parameters=array('boxproductalertstocklist'=>1); |
|
96 | - $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook |
|
97 | - $sql.=$hookmanager->resPrint; |
|
98 | - } |
|
99 | - $sql.= " GROUP BY p.rowid, p.ref, p.label, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.seuil_stock_alerte, p.entity"; |
|
93 | + if (is_object($hookmanager)) |
|
94 | + { |
|
95 | + $parameters=array('boxproductalertstocklist'=>1); |
|
96 | + $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook |
|
97 | + $sql.=$hookmanager->resPrint; |
|
98 | + } |
|
99 | + $sql.= " GROUP BY p.rowid, p.ref, p.label, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.seuil_stock_alerte, p.entity"; |
|
100 | 100 | $sql.= " HAVING SUM(".$db->ifsql("s.reel IS NULL","0","s.reel").") < p.seuil_stock_alerte"; |
101 | 101 | $sql.= $db->order('p.seuil_stock_alerte', 'DESC'); |
102 | 102 | $sql.= $db->plimit($max, 0); |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | $langs->load("stocks"); |
108 | 108 | $num = $db->num_rows($result); |
109 | 109 | $line = 0; |
110 | - while ($line < $num) { |
|
110 | + while ($line < $num) { |
|
111 | 111 | $objp = $db->fetch_object($result); |
112 | 112 | $datem=$db->jdate($objp->tms); |
113 | 113 | |
@@ -128,34 +128,34 @@ discard block |
||
128 | 128 | $objp->label = $objtp->label; |
129 | 129 | } |
130 | 130 | } |
131 | - $productstatic->id = $objp->rowid; |
|
132 | - $productstatic->ref = $objp->ref; |
|
133 | - $productstatic->type = $objp->fk_product_type; |
|
134 | - $productstatic->label = $objp->label; |
|
131 | + $productstatic->id = $objp->rowid; |
|
132 | + $productstatic->ref = $objp->ref; |
|
133 | + $productstatic->type = $objp->fk_product_type; |
|
134 | + $productstatic->label = $objp->label; |
|
135 | 135 | $productstatic->entity = $objp->entity; |
136 | 136 | |
137 | - $this->info_box_contents[$line][] = array( |
|
138 | - 'td' => '', |
|
139 | - 'text' => $productstatic->getNomUrl(1), |
|
140 | - 'asis' => 1, |
|
141 | - ); |
|
142 | - |
|
143 | - $this->info_box_contents[$line][] = array( |
|
144 | - 'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', |
|
145 | - 'text' => $objp->label, |
|
146 | - ); |
|
147 | - |
|
148 | - if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression)) |
|
149 | - { |
|
150 | - $price_base_type=$langs->trans($objp->price_base_type); |
|
151 | - $price=($objp->price_base_type == 'HT')?price($objp->price):$price=price($objp->price_ttc); |
|
152 | - } |
|
153 | - else //Parse the dynamic price |
|
154 | - { |
|
137 | + $this->info_box_contents[$line][] = array( |
|
138 | + 'td' => '', |
|
139 | + 'text' => $productstatic->getNomUrl(1), |
|
140 | + 'asis' => 1, |
|
141 | + ); |
|
142 | + |
|
143 | + $this->info_box_contents[$line][] = array( |
|
144 | + 'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', |
|
145 | + 'text' => $objp->label, |
|
146 | + ); |
|
147 | + |
|
148 | + if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression)) |
|
149 | + { |
|
150 | + $price_base_type=$langs->trans($objp->price_base_type); |
|
151 | + $price=($objp->price_base_type == 'HT')?price($objp->price):$price=price($objp->price_ttc); |
|
152 | + } |
|
153 | + else //Parse the dynamic price |
|
154 | + { |
|
155 | 155 | $productstatic->fetch($objp->rowid, '', '', 1); |
156 | - $priceparser = new PriceParser($this->db); |
|
157 | - $price_result = $priceparser->parseProduct($productstatic); |
|
158 | - if ($price_result >= 0) { |
|
156 | + $priceparser = new PriceParser($this->db); |
|
157 | + $price_result = $priceparser->parseProduct($productstatic); |
|
158 | + if ($price_result >= 0) { |
|
159 | 159 | if ($objp->price_base_type == 'HT') |
160 | 160 | { |
161 | 161 | $price_base_type=$langs->trans("HT"); |
@@ -166,60 +166,60 @@ discard block |
||
166 | 166 | $price_base_type=$langs->trans("TTC"); |
167 | 167 | } |
168 | 168 | $price=price($price_result); |
169 | - } |
|
170 | - } |
|
169 | + } |
|
170 | + } |
|
171 | 171 | |
172 | - $this->info_box_contents[$line][] = array( |
|
173 | - 'td' => 'class="right"', |
|
174 | - 'text' => $price, |
|
175 | - ); |
|
172 | + $this->info_box_contents[$line][] = array( |
|
173 | + 'td' => 'class="right"', |
|
174 | + 'text' => $price, |
|
175 | + ); |
|
176 | 176 | |
177 | - $this->info_box_contents[$line][] = array( |
|
178 | - 'td' => 'class="nowrap"', |
|
179 | - 'text' => $price_base_type, |
|
180 | - ); |
|
177 | + $this->info_box_contents[$line][] = array( |
|
178 | + 'td' => 'class="nowrap"', |
|
179 | + 'text' => $price_base_type, |
|
180 | + ); |
|
181 | 181 | |
182 | 182 | $this->info_box_contents[$line][] = array( |
183 | - 'td' => 'align="center"', |
|
184 | - 'text' => $objp->total_stock . ' / '.$objp->seuil_stock_alerte, |
|
183 | + 'td' => 'align="center"', |
|
184 | + 'text' => $objp->total_stock . ' / '.$objp->seuil_stock_alerte, |
|
185 | 185 | 'text2'=>img_warning($langs->transnoentitiesnoconv("StockLowerThanLimit", $objp->seuil_stock_alerte))); |
186 | 186 | |
187 | 187 | $this->info_box_contents[$line][] = array( |
188 | - 'td' => 'align="right" width="18"', |
|
189 | - 'text' => '<span class="statusrefsell">'.$productstatic->LibStatut($objp->tosell,3,0).'<span>', |
|
190 | - 'asis' => 1 |
|
188 | + 'td' => 'align="right" width="18"', |
|
189 | + 'text' => '<span class="statusrefsell">'.$productstatic->LibStatut($objp->tosell,3,0).'<span>', |
|
190 | + 'asis' => 1 |
|
191 | 191 | ); |
192 | 192 | |
193 | - $this->info_box_contents[$line][] = array( |
|
194 | - 'td' => 'align="right" width="18"', |
|
195 | - 'text' => '<span class="statusrefbuy">'.$productstatic->LibStatut($objp->tobuy,3,0).'<span>', |
|
196 | - 'asis' => 1 |
|
197 | - ); |
|
193 | + $this->info_box_contents[$line][] = array( |
|
194 | + 'td' => 'align="right" width="18"', |
|
195 | + 'text' => '<span class="statusrefbuy">'.$productstatic->LibStatut($objp->tobuy,3,0).'<span>', |
|
196 | + 'asis' => 1 |
|
197 | + ); |
|
198 | 198 | |
199 | - $line++; |
|
200 | - } |
|
201 | - if ($num==0) |
|
202 | - $this->info_box_contents[$line][0] = array( |
|
203 | - 'td' => 'align="center"', |
|
204 | - 'text'=>$langs->trans("NoTooLowStockProducts"), |
|
205 | - ); |
|
199 | + $line++; |
|
200 | + } |
|
201 | + if ($num==0) |
|
202 | + $this->info_box_contents[$line][0] = array( |
|
203 | + 'td' => 'align="center"', |
|
204 | + 'text'=>$langs->trans("NoTooLowStockProducts"), |
|
205 | + ); |
|
206 | 206 | |
207 | 207 | $db->free($result); |
208 | 208 | } |
209 | 209 | else |
210 | 210 | { |
211 | 211 | $this->info_box_contents[0][0] = array( |
212 | - 'td' => '', |
|
213 | - 'maxlength'=>500, |
|
214 | - 'text' => ($db->error().' sql='.$sql), |
|
215 | - ); |
|
212 | + 'td' => '', |
|
213 | + 'maxlength'=>500, |
|
214 | + 'text' => ($db->error().' sql='.$sql), |
|
215 | + ); |
|
216 | 216 | } |
217 | 217 | } |
218 | 218 | else { |
219 | - $this->info_box_contents[0][0] = array( |
|
220 | - 'td' => 'align="left" class="nohover opacitymedium"', |
|
221 | - 'text' => $langs->trans("ReadPermissionNotAllowed") |
|
222 | - ); |
|
219 | + $this->info_box_contents[0][0] = array( |
|
220 | + 'td' => 'align="left" class="nohover opacitymedium"', |
|
221 | + 'text' => $langs->trans("ReadPermissionNotAllowed") |
|
222 | + ); |
|
223 | 223 | } |
224 | 224 | } |
225 | 225 | |
@@ -231,9 +231,9 @@ discard block |
||
231 | 231 | * @param int $nooutput No print, only return string |
232 | 232 | * @return string |
233 | 233 | */ |
234 | - function showBox($head = null, $contents = null, $nooutput=0) |
|
235 | - { |
|
236 | - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
|
234 | + function showBox($head = null, $contents = null, $nooutput=0) |
|
235 | + { |
|
236 | + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | } |
@@ -87,8 +87,12 @@ discard block |
||
87 | 87 | $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as s on p.rowid = s.fk_product"; |
88 | 88 | $sql.= ' WHERE p.entity IN ('.getEntity($productstatic->element, 1).')'; |
89 | 89 | $sql.= " AND p.tosell = 1 AND p.seuil_stock_alerte > 0"; |
90 | - if (empty($user->rights->produit->lire)) $sql.=' AND p.fk_product_type != 0'; |
|
91 | - if (empty($user->rights->service->lire)) $sql.=' AND p.fk_product_type != 1'; |
|
90 | + if (empty($user->rights->produit->lire)) { |
|
91 | + $sql.=' AND p.fk_product_type != 0'; |
|
92 | + } |
|
93 | + if (empty($user->rights->service->lire)) { |
|
94 | + $sql.=' AND p.fk_product_type != 1'; |
|
95 | + } |
|
92 | 96 | // Add where from hooks |
93 | 97 | if (is_object($hookmanager)) |
94 | 98 | { |
@@ -112,9 +116,11 @@ discard block |
||
112 | 116 | $datem=$db->jdate($objp->tms); |
113 | 117 | |
114 | 118 | // Multilangs |
115 | - if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active |
|
119 | + if (! empty($conf->global->MAIN_MULTILANGS)) { |
|
120 | + // si l'option est active |
|
116 | 121 | { |
117 | 122 | $sqld = "SELECT label"; |
123 | + } |
|
118 | 124 | $sqld.= " FROM ".MAIN_DB_PREFIX."product_lang"; |
119 | 125 | $sqld.= " WHERE fk_product=".$objp->rowid; |
120 | 126 | $sqld.= " AND lang='". $langs->getDefaultLang() ."'"; |
@@ -124,8 +130,9 @@ discard block |
||
124 | 130 | if ($resultd) |
125 | 131 | { |
126 | 132 | $objtp = $db->fetch_object($resultd); |
127 | - if (isset($objtp->label) && $objtp->label != '') |
|
128 | - $objp->label = $objtp->label; |
|
133 | + if (isset($objtp->label) && $objtp->label != '') { |
|
134 | + $objp->label = $objtp->label; |
|
135 | + } |
|
129 | 136 | } |
130 | 137 | } |
131 | 138 | $productstatic->id = $objp->rowid; |
@@ -149,8 +156,7 @@ discard block |
||
149 | 156 | { |
150 | 157 | $price_base_type=$langs->trans($objp->price_base_type); |
151 | 158 | $price=($objp->price_base_type == 'HT')?price($objp->price):$price=price($objp->price_ttc); |
152 | - } |
|
153 | - else //Parse the dynamic price |
|
159 | + } else //Parse the dynamic price |
|
154 | 160 | { |
155 | 161 | $productstatic->fetch($objp->rowid, '', '', 1); |
156 | 162 | $priceparser = new PriceParser($this->db); |
@@ -159,8 +165,7 @@ discard block |
||
159 | 165 | if ($objp->price_base_type == 'HT') |
160 | 166 | { |
161 | 167 | $price_base_type=$langs->trans("HT"); |
162 | - } |
|
163 | - else |
|
168 | + } else |
|
164 | 169 | { |
165 | 170 | $price_result = $price_result * (1 + ($productstatic->tva_tx / 100)); |
166 | 171 | $price_base_type=$langs->trans("TTC"); |
@@ -198,15 +203,15 @@ discard block |
||
198 | 203 | |
199 | 204 | $line++; |
200 | 205 | } |
201 | - if ($num==0) |
|
202 | - $this->info_box_contents[$line][0] = array( |
|
206 | + if ($num==0) { |
|
207 | + $this->info_box_contents[$line][0] = array( |
|
203 | 208 | 'td' => 'align="center"', |
204 | 209 | 'text'=>$langs->trans("NoTooLowStockProducts"), |
205 | 210 | ); |
211 | + } |
|
206 | 212 | |
207 | 213 | $db->free($result); |
208 | - } |
|
209 | - else |
|
214 | + } else |
|
210 | 215 | { |
211 | 216 | $this->info_box_contents[0][0] = array( |
212 | 217 | 'td' => '', |
@@ -214,8 +219,7 @@ discard block |
||
214 | 219 | 'text' => ($db->error().' sql='.$sql), |
215 | 220 | ); |
216 | 221 | } |
217 | - } |
|
218 | - else { |
|
222 | + } else { |
|
219 | 223 | $this->info_box_contents[0][0] = array( |
220 | 224 | 'td' => 'align="left" class="nohover opacitymedium"', |
221 | 225 | 'text' => $langs->trans("ReadPermissionNotAllowed") |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | */ |
36 | 36 | class box_produits_alerte_stock extends ModeleBoxes |
37 | 37 | { |
38 | - var $boxcode="productsalertstock"; |
|
39 | - var $boximg="object_product"; |
|
40 | - var $boxlabel="BoxProductsAlertStock"; |
|
38 | + var $boxcode = "productsalertstock"; |
|
39 | + var $boximg = "object_product"; |
|
40 | + var $boxlabel = "BoxProductsAlertStock"; |
|
41 | 41 | var $depends = array("produit"); |
42 | 42 | |
43 | 43 | var $db; |
@@ -53,13 +53,13 @@ discard block |
||
53 | 53 | * @param DoliDB $db Database handler |
54 | 54 | * @param string $param More parameters |
55 | 55 | */ |
56 | - function __construct($db,$param='') |
|
56 | + function __construct($db, $param = '') |
|
57 | 57 | { |
58 | 58 | global $user; |
59 | 59 | |
60 | 60 | $this->db = $db; |
61 | 61 | |
62 | - $this->hidden = ! (($user->rights->produit->lire || $user->rights->service->lire) && $user->rights->stock->lire); |
|
62 | + $this->hidden = !(($user->rights->produit->lire || $user->rights->service->lire) && $user->rights->stock->lire); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -68,38 +68,38 @@ discard block |
||
68 | 68 | * @param int $max Maximum number of records to load |
69 | 69 | * @return void |
70 | 70 | */ |
71 | - function loadBox($max=5) |
|
71 | + function loadBox($max = 5) |
|
72 | 72 | { |
73 | 73 | global $user, $langs, $db, $conf, $hookmanager; |
74 | 74 | |
75 | - $this->max=$max; |
|
75 | + $this->max = $max; |
|
76 | 76 | |
77 | 77 | include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; |
78 | - $productstatic=new Product($db); |
|
78 | + $productstatic = new Product($db); |
|
79 | 79 | |
80 | - $this->info_box_head = array('text' => $langs->trans("BoxTitleProductsAlertStock",$max)); |
|
80 | + $this->info_box_head = array('text' => $langs->trans("BoxTitleProductsAlertStock", $max)); |
|
81 | 81 | |
82 | 82 | if (($user->rights->produit->lire || $user->rights->service->lire) && $user->rights->stock->lire) |
83 | 83 | { |
84 | 84 | $sql = "SELECT p.rowid, p.label, p.price, p.ref, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.seuil_stock_alerte, p.entity,"; |
85 | - $sql.= " SUM(".$db->ifsql("s.reel IS NULL","0","s.reel").") as total_stock"; |
|
86 | - $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; |
|
87 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as s on p.rowid = s.fk_product"; |
|
88 | - $sql.= ' WHERE p.entity IN ('.getEntity($productstatic->element, 1).')'; |
|
89 | - $sql.= " AND p.tosell = 1 AND p.seuil_stock_alerte > 0"; |
|
90 | - if (empty($user->rights->produit->lire)) $sql.=' AND p.fk_product_type != 0'; |
|
91 | - if (empty($user->rights->service->lire)) $sql.=' AND p.fk_product_type != 1'; |
|
85 | + $sql .= " SUM(".$db->ifsql("s.reel IS NULL", "0", "s.reel").") as total_stock"; |
|
86 | + $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; |
|
87 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as s on p.rowid = s.fk_product"; |
|
88 | + $sql .= ' WHERE p.entity IN ('.getEntity($productstatic->element, 1).')'; |
|
89 | + $sql .= " AND p.tosell = 1 AND p.seuil_stock_alerte > 0"; |
|
90 | + if (empty($user->rights->produit->lire)) $sql .= ' AND p.fk_product_type != 0'; |
|
91 | + if (empty($user->rights->service->lire)) $sql .= ' AND p.fk_product_type != 1'; |
|
92 | 92 | // Add where from hooks |
93 | 93 | if (is_object($hookmanager)) |
94 | 94 | { |
95 | - $parameters=array('boxproductalertstocklist'=>1); |
|
96 | - $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook |
|
97 | - $sql.=$hookmanager->resPrint; |
|
95 | + $parameters = array('boxproductalertstocklist'=>1); |
|
96 | + $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook |
|
97 | + $sql .= $hookmanager->resPrint; |
|
98 | 98 | } |
99 | - $sql.= " GROUP BY p.rowid, p.ref, p.label, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.seuil_stock_alerte, p.entity"; |
|
100 | - $sql.= " HAVING SUM(".$db->ifsql("s.reel IS NULL","0","s.reel").") < p.seuil_stock_alerte"; |
|
101 | - $sql.= $db->order('p.seuil_stock_alerte', 'DESC'); |
|
102 | - $sql.= $db->plimit($max, 0); |
|
99 | + $sql .= " GROUP BY p.rowid, p.ref, p.label, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.seuil_stock_alerte, p.entity"; |
|
100 | + $sql .= " HAVING SUM(".$db->ifsql("s.reel IS NULL", "0", "s.reel").") < p.seuil_stock_alerte"; |
|
101 | + $sql .= $db->order('p.seuil_stock_alerte', 'DESC'); |
|
102 | + $sql .= $db->plimit($max, 0); |
|
103 | 103 | |
104 | 104 | $result = $db->query($sql); |
105 | 105 | if ($result) |
@@ -109,16 +109,16 @@ discard block |
||
109 | 109 | $line = 0; |
110 | 110 | while ($line < $num) { |
111 | 111 | $objp = $db->fetch_object($result); |
112 | - $datem=$db->jdate($objp->tms); |
|
112 | + $datem = $db->jdate($objp->tms); |
|
113 | 113 | |
114 | 114 | // Multilangs |
115 | - if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active |
|
115 | + if (!empty($conf->global->MAIN_MULTILANGS)) // si l'option est active |
|
116 | 116 | { |
117 | 117 | $sqld = "SELECT label"; |
118 | - $sqld.= " FROM ".MAIN_DB_PREFIX."product_lang"; |
|
119 | - $sqld.= " WHERE fk_product=".$objp->rowid; |
|
120 | - $sqld.= " AND lang='". $langs->getDefaultLang() ."'"; |
|
121 | - $sqld.= " LIMIT 1"; |
|
118 | + $sqld .= " FROM ".MAIN_DB_PREFIX."product_lang"; |
|
119 | + $sqld .= " WHERE fk_product=".$objp->rowid; |
|
120 | + $sqld .= " AND lang='".$langs->getDefaultLang()."'"; |
|
121 | + $sqld .= " LIMIT 1"; |
|
122 | 122 | |
123 | 123 | $resultd = $db->query($sqld); |
124 | 124 | if ($resultd) |
@@ -147,8 +147,8 @@ discard block |
||
147 | 147 | |
148 | 148 | if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression)) |
149 | 149 | { |
150 | - $price_base_type=$langs->trans($objp->price_base_type); |
|
151 | - $price=($objp->price_base_type == 'HT')?price($objp->price):$price=price($objp->price_ttc); |
|
150 | + $price_base_type = $langs->trans($objp->price_base_type); |
|
151 | + $price = ($objp->price_base_type == 'HT') ?price($objp->price) : $price = price($objp->price_ttc); |
|
152 | 152 | } |
153 | 153 | else //Parse the dynamic price |
154 | 154 | { |
@@ -158,14 +158,14 @@ discard block |
||
158 | 158 | if ($price_result >= 0) { |
159 | 159 | if ($objp->price_base_type == 'HT') |
160 | 160 | { |
161 | - $price_base_type=$langs->trans("HT"); |
|
161 | + $price_base_type = $langs->trans("HT"); |
|
162 | 162 | } |
163 | 163 | else |
164 | 164 | { |
165 | 165 | $price_result = $price_result * (1 + ($productstatic->tva_tx / 100)); |
166 | - $price_base_type=$langs->trans("TTC"); |
|
166 | + $price_base_type = $langs->trans("TTC"); |
|
167 | 167 | } |
168 | - $price=price($price_result); |
|
168 | + $price = price($price_result); |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 | |
@@ -181,24 +181,24 @@ discard block |
||
181 | 181 | |
182 | 182 | $this->info_box_contents[$line][] = array( |
183 | 183 | 'td' => 'align="center"', |
184 | - 'text' => $objp->total_stock . ' / '.$objp->seuil_stock_alerte, |
|
184 | + 'text' => $objp->total_stock.' / '.$objp->seuil_stock_alerte, |
|
185 | 185 | 'text2'=>img_warning($langs->transnoentitiesnoconv("StockLowerThanLimit", $objp->seuil_stock_alerte))); |
186 | 186 | |
187 | 187 | $this->info_box_contents[$line][] = array( |
188 | 188 | 'td' => 'align="right" width="18"', |
189 | - 'text' => '<span class="statusrefsell">'.$productstatic->LibStatut($objp->tosell,3,0).'<span>', |
|
189 | + 'text' => '<span class="statusrefsell">'.$productstatic->LibStatut($objp->tosell, 3, 0).'<span>', |
|
190 | 190 | 'asis' => 1 |
191 | 191 | ); |
192 | 192 | |
193 | 193 | $this->info_box_contents[$line][] = array( |
194 | 194 | 'td' => 'align="right" width="18"', |
195 | - 'text' => '<span class="statusrefbuy">'.$productstatic->LibStatut($objp->tobuy,3,0).'<span>', |
|
195 | + 'text' => '<span class="statusrefbuy">'.$productstatic->LibStatut($objp->tobuy, 3, 0).'<span>', |
|
196 | 196 | 'asis' => 1 |
197 | 197 | ); |
198 | 198 | |
199 | 199 | $line++; |
200 | 200 | } |
201 | - if ($num==0) |
|
201 | + if ($num == 0) |
|
202 | 202 | $this->info_box_contents[$line][0] = array( |
203 | 203 | 'td' => 'align="center"', |
204 | 204 | 'text'=>$langs->trans("NoTooLowStockProducts"), |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * @param int $nooutput No print, only return string |
232 | 232 | * @return string |
233 | 233 | */ |
234 | - function showBox($head = null, $contents = null, $nooutput=0) |
|
234 | + function showBox($head = null, $contents = null, $nooutput = 0) |
|
235 | 235 | { |
236 | 236 | return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
237 | 237 | } |
@@ -51,18 +51,18 @@ discard block |
||
51 | 51 | */ |
52 | 52 | function __construct($db,$param) |
53 | 53 | { |
54 | - global $user; |
|
54 | + global $user; |
|
55 | 55 | |
56 | - $this->db=$db; |
|
56 | + $this->db=$db; |
|
57 | 57 | |
58 | - $this->hidden=! ($user->rights->fournisseur->facture->lire); |
|
58 | + $this->hidden=! ($user->rights->fournisseur->facture->lire); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
62 | 62 | * Load data into info_box_contents array to show array later. |
63 | 63 | * |
64 | 64 | * @param int $max Maximum number of records to load |
65 | - * @return void |
|
65 | + * @return void |
|
66 | 66 | */ |
67 | 67 | function loadBox($max=5) |
68 | 68 | { |
@@ -71,10 +71,10 @@ discard block |
||
71 | 71 | $this->max=$max; |
72 | 72 | |
73 | 73 | include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; |
74 | - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; |
|
74 | + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; |
|
75 | 75 | |
76 | - $facturestatic = new FactureFournisseur($db); |
|
77 | - $thirdpartytmp = new Fournisseur($db); |
|
76 | + $facturestatic = new FactureFournisseur($db); |
|
77 | + $thirdpartytmp = new Fournisseur($db); |
|
78 | 78 | |
79 | 79 | $this->info_box_head = array( |
80 | 80 | 'text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."SupplierBills",$max) |
@@ -83,12 +83,12 @@ discard block |
||
83 | 83 | if ($user->rights->fournisseur->facture->lire) |
84 | 84 | { |
85 | 85 | $sql = "SELECT s.nom as name, s.rowid as socid,"; |
86 | - $sql.= " s.code_fournisseur,"; |
|
87 | - $sql.= " s.logo,"; |
|
86 | + $sql.= " s.code_fournisseur,"; |
|
87 | + $sql.= " s.logo,"; |
|
88 | 88 | $sql.= " f.rowid as facid, f.ref, f.ref_supplier,"; |
89 | - $sql.= " f.total_ht,"; |
|
90 | - $sql.= " f.total_tva,"; |
|
91 | - $sql.= " f.total_ttc,"; |
|
89 | + $sql.= " f.total_ht,"; |
|
90 | + $sql.= " f.total_tva,"; |
|
91 | + $sql.= " f.total_ttc,"; |
|
92 | 92 | $sql.= " f.paye, f.fk_statut,"; |
93 | 93 | $sql.= ' f.datef as df,'; |
94 | 94 | $sql.= ' f.datec as datec,'; |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | $sql.= " AND f.entity = ".$conf->entity; |
101 | 101 | if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
102 | 102 | if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; |
103 | - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY f.datef DESC, f.ref DESC "; |
|
104 | - else $sql.= " ORDER BY f.tms DESC, f.ref DESC "; |
|
103 | + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY f.datef DESC, f.ref DESC "; |
|
104 | + else $sql.= " ORDER BY f.tms DESC, f.ref DESC "; |
|
105 | 105 | $sql.= $db->plimit($max, 0); |
106 | 106 | |
107 | 107 | $result = $db->query($sql); |
@@ -112,92 +112,92 @@ discard block |
||
112 | 112 | $line = 0; |
113 | 113 | $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; |
114 | 114 | |
115 | - while ($line < $num) { |
|
115 | + while ($line < $num) { |
|
116 | 116 | $objp = $db->fetch_object($result); |
117 | 117 | $datelimite=$db->jdate($objp->datelimite); |
118 | 118 | $date=$db->jdate($objp->df); |
119 | 119 | $datem=$db->jdate($objp->tms); |
120 | - $facturestatic->id = $objp->facid; |
|
121 | - $facturestatic->ref = $objp->ref; |
|
122 | - $facturestatic->total_ht = $objp->total_ht; |
|
123 | - $facturestatic->total_tva = $objp->total_tva; |
|
124 | - $facturestatic->total_ttc = $objp->total_ttc; |
|
125 | - $facturestatic->date_echeance = $datelimite; |
|
126 | - $facturestatic->statut = $objp->fk_statut; |
|
127 | - $thirdpartytmp->id = $objp->socid; |
|
128 | - $thirdpartytmp->name = $objp->name; |
|
129 | - $thirdpartytmp->fournisseur = 1; |
|
130 | - $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; |
|
131 | - $thirdpartytmp->logo = $objp->logo; |
|
120 | + $facturestatic->id = $objp->facid; |
|
121 | + $facturestatic->ref = $objp->ref; |
|
122 | + $facturestatic->total_ht = $objp->total_ht; |
|
123 | + $facturestatic->total_tva = $objp->total_tva; |
|
124 | + $facturestatic->total_ttc = $objp->total_ttc; |
|
125 | + $facturestatic->date_echeance = $datelimite; |
|
126 | + $facturestatic->statut = $objp->fk_statut; |
|
127 | + $thirdpartytmp->id = $objp->socid; |
|
128 | + $thirdpartytmp->name = $objp->name; |
|
129 | + $thirdpartytmp->fournisseur = 1; |
|
130 | + $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; |
|
131 | + $thirdpartytmp->logo = $objp->logo; |
|
132 | 132 | |
133 | 133 | $late = ''; |
134 | 134 | |
135 | 135 | if ($facturestatic->hasDelay()) { |
136 | - $late=img_warning(sprintf($l_due_date, dol_print_date($datelimite,'day'))); |
|
137 | - } |
|
138 | - |
|
139 | - $this->info_box_contents[$line][] = array( |
|
140 | - 'td' => '', |
|
141 | - 'text' => $facturestatic->getNomUrl(1), |
|
142 | - 'text2'=> $late, |
|
143 | - 'asis' => 1, |
|
144 | - ); |
|
145 | - |
|
146 | - $this->info_box_contents[$line][] = array( |
|
147 | - 'td' => '', |
|
148 | - 'text' => $objp->ref_supplier, |
|
149 | - 'tooltip' => $langs->trans('SupplierInvoice').': '.($objp->ref?$objp->ref:$objp->facid).'<br>'.$langs->trans('RefSupplier').': '.$objp->ref_supplier, |
|
150 | - 'url' => DOL_URL_ROOT."/fourn/facture/card.php?facid=".$objp->facid, |
|
151 | - ); |
|
152 | - |
|
153 | - $this->info_box_contents[$line][] = array( |
|
154 | - 'td' => '', |
|
155 | - 'text' => $thirdpartytmp->getNomUrl(1, 'supplier'), |
|
156 | - 'asis' => 1, |
|
157 | - ); |
|
158 | - |
|
159 | - $this->info_box_contents[$line][] = array( |
|
160 | - 'td' => 'class="right"', |
|
161 | - 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), |
|
162 | - ); |
|
163 | - |
|
164 | - $this->info_box_contents[$line][] = array( |
|
165 | - 'td' => 'class="right"', |
|
166 | - 'text' => dol_print_date($date,'day'), |
|
167 | - ); |
|
168 | - |
|
169 | - $fac = new FactureFournisseur($db); |
|
170 | - $fac->fetch($objp->facid); |
|
171 | - $alreadypaid=$fac->getSommePaiement(); |
|
172 | - $this->info_box_contents[$line][] = array( |
|
173 | - 'td' => 'align="right" width="18"', |
|
174 | - 'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3,$alreadypaid,$objp->type), |
|
175 | - ); |
|
176 | - |
|
177 | - $line++; |
|
178 | - } |
|
179 | - |
|
180 | - if ($num==0) |
|
181 | - $this->info_box_contents[$line][0] = array( |
|
182 | - 'td' => 'align="center"', |
|
183 | - 'text'=>$langs->trans("NoModifiedSupplierBills"), |
|
184 | - ); |
|
185 | - |
|
186 | - $db->free($result); |
|
187 | - } else { |
|
188 | - $this->info_box_contents[0][0] = array( |
|
189 | - 'td' => '', |
|
190 | - 'maxlength'=>500, |
|
191 | - 'text' => ($db->error().' sql='.$sql), |
|
192 | - ); |
|
193 | - } |
|
194 | - } else { |
|
195 | - $this->info_box_contents[0][0] = array( |
|
196 | - 'td' => 'align="left" class="nohover opacitymedium"', |
|
197 | - 'text' => $langs->transnoentities("ReadPermissionNotAllowed") |
|
198 | - ); |
|
199 | - } |
|
200 | - } |
|
136 | + $late=img_warning(sprintf($l_due_date, dol_print_date($datelimite,'day'))); |
|
137 | + } |
|
138 | + |
|
139 | + $this->info_box_contents[$line][] = array( |
|
140 | + 'td' => '', |
|
141 | + 'text' => $facturestatic->getNomUrl(1), |
|
142 | + 'text2'=> $late, |
|
143 | + 'asis' => 1, |
|
144 | + ); |
|
145 | + |
|
146 | + $this->info_box_contents[$line][] = array( |
|
147 | + 'td' => '', |
|
148 | + 'text' => $objp->ref_supplier, |
|
149 | + 'tooltip' => $langs->trans('SupplierInvoice').': '.($objp->ref?$objp->ref:$objp->facid).'<br>'.$langs->trans('RefSupplier').': '.$objp->ref_supplier, |
|
150 | + 'url' => DOL_URL_ROOT."/fourn/facture/card.php?facid=".$objp->facid, |
|
151 | + ); |
|
152 | + |
|
153 | + $this->info_box_contents[$line][] = array( |
|
154 | + 'td' => '', |
|
155 | + 'text' => $thirdpartytmp->getNomUrl(1, 'supplier'), |
|
156 | + 'asis' => 1, |
|
157 | + ); |
|
158 | + |
|
159 | + $this->info_box_contents[$line][] = array( |
|
160 | + 'td' => 'class="right"', |
|
161 | + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), |
|
162 | + ); |
|
163 | + |
|
164 | + $this->info_box_contents[$line][] = array( |
|
165 | + 'td' => 'class="right"', |
|
166 | + 'text' => dol_print_date($date,'day'), |
|
167 | + ); |
|
168 | + |
|
169 | + $fac = new FactureFournisseur($db); |
|
170 | + $fac->fetch($objp->facid); |
|
171 | + $alreadypaid=$fac->getSommePaiement(); |
|
172 | + $this->info_box_contents[$line][] = array( |
|
173 | + 'td' => 'align="right" width="18"', |
|
174 | + 'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3,$alreadypaid,$objp->type), |
|
175 | + ); |
|
176 | + |
|
177 | + $line++; |
|
178 | + } |
|
179 | + |
|
180 | + if ($num==0) |
|
181 | + $this->info_box_contents[$line][0] = array( |
|
182 | + 'td' => 'align="center"', |
|
183 | + 'text'=>$langs->trans("NoModifiedSupplierBills"), |
|
184 | + ); |
|
185 | + |
|
186 | + $db->free($result); |
|
187 | + } else { |
|
188 | + $this->info_box_contents[0][0] = array( |
|
189 | + 'td' => '', |
|
190 | + 'maxlength'=>500, |
|
191 | + 'text' => ($db->error().' sql='.$sql), |
|
192 | + ); |
|
193 | + } |
|
194 | + } else { |
|
195 | + $this->info_box_contents[0][0] = array( |
|
196 | + 'td' => 'align="left" class="nohover opacitymedium"', |
|
197 | + 'text' => $langs->transnoentities("ReadPermissionNotAllowed") |
|
198 | + ); |
|
199 | + } |
|
200 | + } |
|
201 | 201 | |
202 | 202 | /** |
203 | 203 | * Method to show box |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | * @param int $nooutput No print, only return string |
208 | 208 | * @return string |
209 | 209 | */ |
210 | - function showBox($head = null, $contents = null, $nooutput=0) |
|
211 | - { |
|
210 | + function showBox($head = null, $contents = null, $nooutput=0) |
|
211 | + { |
|
212 | 212 | return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
213 | 213 | } |
214 | 214 |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | */ |
32 | 32 | class box_factures_fourn extends ModeleBoxes |
33 | 33 | { |
34 | - var $boxcode="lastsupplierbills"; |
|
35 | - var $boximg="object_bill"; |
|
36 | - var $boxlabel="BoxLastSupplierBills"; |
|
37 | - var $depends = array("facture","fournisseur"); |
|
34 | + var $boxcode = "lastsupplierbills"; |
|
35 | + var $boximg = "object_bill"; |
|
36 | + var $boxlabel = "BoxLastSupplierBills"; |
|
37 | + var $depends = array("facture", "fournisseur"); |
|
38 | 38 | |
39 | 39 | var $db; |
40 | 40 | var $param; |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | * @param DoliDB $db Database handler |
50 | 50 | * @param string $param More parameters |
51 | 51 | */ |
52 | - function __construct($db,$param) |
|
52 | + function __construct($db, $param) |
|
53 | 53 | { |
54 | 54 | global $user; |
55 | 55 | |
56 | - $this->db=$db; |
|
56 | + $this->db = $db; |
|
57 | 57 | |
58 | - $this->hidden=! ($user->rights->fournisseur->facture->lire); |
|
58 | + $this->hidden = !($user->rights->fournisseur->facture->lire); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | * @param int $max Maximum number of records to load |
65 | 65 | * @return void |
66 | 66 | */ |
67 | - function loadBox($max=5) |
|
67 | + function loadBox($max = 5) |
|
68 | 68 | { |
69 | 69 | global $conf, $user, $langs, $db; |
70 | 70 | |
71 | - $this->max=$max; |
|
71 | + $this->max = $max; |
|
72 | 72 | |
73 | 73 | include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; |
74 | 74 | include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; |
@@ -77,32 +77,32 @@ discard block |
||
77 | 77 | $thirdpartytmp = new Fournisseur($db); |
78 | 78 | |
79 | 79 | $this->info_box_head = array( |
80 | - 'text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."SupplierBills",$max) |
|
80 | + 'text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."SupplierBills", $max) |
|
81 | 81 | ); |
82 | 82 | |
83 | 83 | if ($user->rights->fournisseur->facture->lire) |
84 | 84 | { |
85 | 85 | $sql = "SELECT s.nom as name, s.rowid as socid,"; |
86 | - $sql.= " s.code_fournisseur,"; |
|
87 | - $sql.= " s.logo,"; |
|
88 | - $sql.= " f.rowid as facid, f.ref, f.ref_supplier,"; |
|
89 | - $sql.= " f.total_ht,"; |
|
90 | - $sql.= " f.total_tva,"; |
|
91 | - $sql.= " f.total_ttc,"; |
|
92 | - $sql.= " f.paye, f.fk_statut,"; |
|
93 | - $sql.= ' f.datef as df,'; |
|
94 | - $sql.= ' f.datec as datec,'; |
|
95 | - $sql.= ' f.date_lim_reglement as datelimite, f.tms, f.type'; |
|
96 | - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
97 | - $sql.= ", ".MAIN_DB_PREFIX."facture_fourn as f"; |
|
98 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
99 | - $sql.= " WHERE f.fk_soc = s.rowid"; |
|
100 | - $sql.= " AND f.entity = ".$conf->entity; |
|
101 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
102 | - if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; |
|
103 | - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY f.datef DESC, f.ref DESC "; |
|
104 | - else $sql.= " ORDER BY f.tms DESC, f.ref DESC "; |
|
105 | - $sql.= $db->plimit($max, 0); |
|
86 | + $sql .= " s.code_fournisseur,"; |
|
87 | + $sql .= " s.logo,"; |
|
88 | + $sql .= " f.rowid as facid, f.ref, f.ref_supplier,"; |
|
89 | + $sql .= " f.total_ht,"; |
|
90 | + $sql .= " f.total_tva,"; |
|
91 | + $sql .= " f.total_ttc,"; |
|
92 | + $sql .= " f.paye, f.fk_statut,"; |
|
93 | + $sql .= ' f.datef as df,'; |
|
94 | + $sql .= ' f.datec as datec,'; |
|
95 | + $sql .= ' f.date_lim_reglement as datelimite, f.tms, f.type'; |
|
96 | + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
97 | + $sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f"; |
|
98 | + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
99 | + $sql .= " WHERE f.fk_soc = s.rowid"; |
|
100 | + $sql .= " AND f.entity = ".$conf->entity; |
|
101 | + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
102 | + if ($user->societe_id) $sql .= " AND s.rowid = ".$user->societe_id; |
|
103 | + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY f.datef DESC, f.ref DESC "; |
|
104 | + else $sql .= " ORDER BY f.tms DESC, f.ref DESC "; |
|
105 | + $sql .= $db->plimit($max, 0); |
|
106 | 106 | |
107 | 107 | $result = $db->query($sql); |
108 | 108 | if ($result) |
@@ -110,13 +110,13 @@ discard block |
||
110 | 110 | $num = $db->num_rows($result); |
111 | 111 | |
112 | 112 | $line = 0; |
113 | - $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; |
|
113 | + $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; |
|
114 | 114 | |
115 | 115 | while ($line < $num) { |
116 | 116 | $objp = $db->fetch_object($result); |
117 | - $datelimite=$db->jdate($objp->datelimite); |
|
118 | - $date=$db->jdate($objp->df); |
|
119 | - $datem=$db->jdate($objp->tms); |
|
117 | + $datelimite = $db->jdate($objp->datelimite); |
|
118 | + $date = $db->jdate($objp->df); |
|
119 | + $datem = $db->jdate($objp->tms); |
|
120 | 120 | $facturestatic->id = $objp->facid; |
121 | 121 | $facturestatic->ref = $objp->ref; |
122 | 122 | $facturestatic->total_ht = $objp->total_ht; |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | $late = ''; |
134 | 134 | |
135 | 135 | if ($facturestatic->hasDelay()) { |
136 | - $late=img_warning(sprintf($l_due_date, dol_print_date($datelimite,'day'))); |
|
136 | + $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | $this->info_box_contents[$line][] = array( |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | $this->info_box_contents[$line][] = array( |
147 | 147 | 'td' => '', |
148 | 148 | 'text' => $objp->ref_supplier, |
149 | - 'tooltip' => $langs->trans('SupplierInvoice').': '.($objp->ref?$objp->ref:$objp->facid).'<br>'.$langs->trans('RefSupplier').': '.$objp->ref_supplier, |
|
149 | + 'tooltip' => $langs->trans('SupplierInvoice').': '.($objp->ref ? $objp->ref : $objp->facid).'<br>'.$langs->trans('RefSupplier').': '.$objp->ref_supplier, |
|
150 | 150 | 'url' => DOL_URL_ROOT."/fourn/facture/card.php?facid=".$objp->facid, |
151 | 151 | ); |
152 | 152 | |
@@ -163,21 +163,21 @@ discard block |
||
163 | 163 | |
164 | 164 | $this->info_box_contents[$line][] = array( |
165 | 165 | 'td' => 'class="right"', |
166 | - 'text' => dol_print_date($date,'day'), |
|
166 | + 'text' => dol_print_date($date, 'day'), |
|
167 | 167 | ); |
168 | 168 | |
169 | 169 | $fac = new FactureFournisseur($db); |
170 | 170 | $fac->fetch($objp->facid); |
171 | - $alreadypaid=$fac->getSommePaiement(); |
|
171 | + $alreadypaid = $fac->getSommePaiement(); |
|
172 | 172 | $this->info_box_contents[$line][] = array( |
173 | 173 | 'td' => 'align="right" width="18"', |
174 | - 'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3,$alreadypaid,$objp->type), |
|
174 | + 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3, $alreadypaid, $objp->type), |
|
175 | 175 | ); |
176 | 176 | |
177 | 177 | $line++; |
178 | 178 | } |
179 | 179 | |
180 | - if ($num==0) |
|
180 | + if ($num == 0) |
|
181 | 181 | $this->info_box_contents[$line][0] = array( |
182 | 182 | 'td' => 'align="center"', |
183 | 183 | 'text'=>$langs->trans("NoModifiedSupplierBills"), |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * @param int $nooutput No print, only return string |
208 | 208 | * @return string |
209 | 209 | */ |
210 | - function showBox($head = null, $contents = null, $nooutput=0) |
|
210 | + function showBox($head = null, $contents = null, $nooutput = 0) |
|
211 | 211 | { |
212 | 212 | return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
213 | 213 | } |
@@ -95,13 +95,22 @@ discard block |
||
95 | 95 | $sql.= ' f.date_lim_reglement as datelimite, f.tms, f.type'; |
96 | 96 | $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
97 | 97 | $sql.= ", ".MAIN_DB_PREFIX."facture_fourn as f"; |
98 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
98 | + if (!$user->rights->societe->client->voir && !$user->societe_id) { |
|
99 | + $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
100 | + } |
|
99 | 101 | $sql.= " WHERE f.fk_soc = s.rowid"; |
100 | 102 | $sql.= " AND f.entity = ".$conf->entity; |
101 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
102 | - if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; |
|
103 | - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY f.datef DESC, f.ref DESC "; |
|
104 | - else $sql.= " ORDER BY f.tms DESC, f.ref DESC "; |
|
103 | + if (!$user->rights->societe->client->voir && !$user->societe_id) { |
|
104 | + $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
105 | + } |
|
106 | + if($user->societe_id) { |
|
107 | + $sql.= " AND s.rowid = ".$user->societe_id; |
|
108 | + } |
|
109 | + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) { |
|
110 | + $sql.= " ORDER BY f.datef DESC, f.ref DESC "; |
|
111 | + } else { |
|
112 | + $sql.= " ORDER BY f.tms DESC, f.ref DESC "; |
|
113 | + } |
|
105 | 114 | $sql.= $db->plimit($max, 0); |
106 | 115 | |
107 | 116 | $result = $db->query($sql); |
@@ -177,11 +186,12 @@ discard block |
||
177 | 186 | $line++; |
178 | 187 | } |
179 | 188 | |
180 | - if ($num==0) |
|
181 | - $this->info_box_contents[$line][0] = array( |
|
189 | + if ($num==0) { |
|
190 | + $this->info_box_contents[$line][0] = array( |
|
182 | 191 | 'td' => 'align="center"', |
183 | 192 | 'text'=>$langs->trans("NoModifiedSupplierBills"), |
184 | 193 | ); |
194 | + } |
|
185 | 195 | |
186 | 196 | $db->free($result); |
187 | 197 | } else { |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * Constructor |
50 | 50 | * |
51 | 51 | * @param DoliDB $db Database handler |
52 | - * @param string $param More parameters |
|
52 | + * @param string $param More parameters |
|
53 | 53 | */ |
54 | 54 | function __construct($db,$param='') |
55 | 55 | { |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * Load data into info_box_contents array to show array later. |
69 | 69 | * |
70 | 70 | * @param int $max Maximum number of records to load |
71 | - * @return void |
|
71 | + * @return void |
|
72 | 72 | */ |
73 | 73 | function loadBox($max=5) |
74 | 74 | { |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | |
78 | 78 | $this->max=$max; |
79 | 79 | |
80 | - include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; |
|
81 | - $memberstatic=new Adherent($db); |
|
80 | + include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; |
|
81 | + $memberstatic=new Adherent($db); |
|
82 | 82 | |
83 | 83 | $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedMembers",$max)); |
84 | 84 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $memberstatic->lastname=$objp->lastname; |
109 | 109 | $memberstatic->firstname=$objp->firstname; |
110 | 110 | $memberstatic->id = $objp->rowid; |
111 | - $memberstatic->ref = $objp->rowid; |
|
111 | + $memberstatic->ref = $objp->rowid; |
|
112 | 112 | |
113 | 113 | if (! empty($objp->fk_soc)) { |
114 | 114 | $memberstatic->socid = $objp->fk_soc; |
@@ -118,53 +118,53 @@ discard block |
||
118 | 118 | $memberstatic->name=$objp->company; |
119 | 119 | } |
120 | 120 | |
121 | - $this->info_box_contents[$line][] = array( |
|
122 | - 'td' => '', |
|
123 | - 'text' => $memberstatic->getNomUrl(1), |
|
124 | - 'asis' => 1, |
|
125 | - ); |
|
126 | - |
|
127 | - $this->info_box_contents[$line][] = array( |
|
128 | - 'td' => '', |
|
129 | - 'text' => $memberstatic->getFullName($langs), |
|
130 | - 'url' => DOL_URL_ROOT."/adherents/card.php?rowid=".$objp->rowid, |
|
131 | - ); |
|
132 | - |
|
133 | - $this->info_box_contents[$line][] = array( |
|
134 | - 'td' => 'class="right"', |
|
135 | - 'text' => dol_print_date($datem, "day"), |
|
136 | - ); |
|
137 | - |
|
138 | - $this->info_box_contents[$line][] = array( |
|
139 | - 'td' => 'align="right" width="18"', |
|
140 | - 'text' => $memberstatic->LibStatut($objp->status,$objp->subscription,$db->jdate($objp->date_end_subscription),3), |
|
141 | - ); |
|
142 | - |
|
143 | - $line++; |
|
144 | - } |
|
145 | - |
|
146 | - if ($num==0) |
|
147 | - $this->info_box_contents[$line][0] = array( |
|
148 | - 'td' => 'align="center"', |
|
149 | - 'text'=>$langs->trans("NoRecordedCustomers"), |
|
150 | - ); |
|
151 | - |
|
152 | - $db->free($result); |
|
153 | - } else { |
|
154 | - $this->info_box_contents[0][0] = array( |
|
155 | - 'td' => '', |
|
156 | - 'maxlength'=>500, |
|
157 | - 'text' => ($db->error().' sql='.$sql), |
|
158 | - ); |
|
159 | - } |
|
160 | - } else { |
|
161 | - $this->info_box_contents[0][0] = array( |
|
162 | - 'td' => 'align="left" class="nohover opacitymedium"', |
|
163 | - 'text' => $langs->trans("ReadPermissionNotAllowed") |
|
164 | - ); |
|
165 | - } |
|
166 | - |
|
167 | - } |
|
121 | + $this->info_box_contents[$line][] = array( |
|
122 | + 'td' => '', |
|
123 | + 'text' => $memberstatic->getNomUrl(1), |
|
124 | + 'asis' => 1, |
|
125 | + ); |
|
126 | + |
|
127 | + $this->info_box_contents[$line][] = array( |
|
128 | + 'td' => '', |
|
129 | + 'text' => $memberstatic->getFullName($langs), |
|
130 | + 'url' => DOL_URL_ROOT."/adherents/card.php?rowid=".$objp->rowid, |
|
131 | + ); |
|
132 | + |
|
133 | + $this->info_box_contents[$line][] = array( |
|
134 | + 'td' => 'class="right"', |
|
135 | + 'text' => dol_print_date($datem, "day"), |
|
136 | + ); |
|
137 | + |
|
138 | + $this->info_box_contents[$line][] = array( |
|
139 | + 'td' => 'align="right" width="18"', |
|
140 | + 'text' => $memberstatic->LibStatut($objp->status,$objp->subscription,$db->jdate($objp->date_end_subscription),3), |
|
141 | + ); |
|
142 | + |
|
143 | + $line++; |
|
144 | + } |
|
145 | + |
|
146 | + if ($num==0) |
|
147 | + $this->info_box_contents[$line][0] = array( |
|
148 | + 'td' => 'align="center"', |
|
149 | + 'text'=>$langs->trans("NoRecordedCustomers"), |
|
150 | + ); |
|
151 | + |
|
152 | + $db->free($result); |
|
153 | + } else { |
|
154 | + $this->info_box_contents[0][0] = array( |
|
155 | + 'td' => '', |
|
156 | + 'maxlength'=>500, |
|
157 | + 'text' => ($db->error().' sql='.$sql), |
|
158 | + ); |
|
159 | + } |
|
160 | + } else { |
|
161 | + $this->info_box_contents[0][0] = array( |
|
162 | + 'td' => 'align="left" class="nohover opacitymedium"', |
|
163 | + 'text' => $langs->trans("ReadPermissionNotAllowed") |
|
164 | + ); |
|
165 | + } |
|
166 | + |
|
167 | + } |
|
168 | 168 | |
169 | 169 | /** |
170 | 170 | * Method to show box |
@@ -174,8 +174,8 @@ discard block |
||
174 | 174 | * @param int $nooutput No print, only return string |
175 | 175 | * @return string |
176 | 176 | */ |
177 | - function showBox($head = null, $contents = null, $nooutput=0) |
|
178 | - { |
|
177 | + function showBox($head = null, $contents = null, $nooutput=0) |
|
178 | + { |
|
179 | 179 | return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
180 | 180 | } |
181 | 181 |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | */ |
33 | 33 | class box_members extends ModeleBoxes |
34 | 34 | { |
35 | - var $boxcode="lastmembers"; |
|
36 | - var $boximg="object_user"; |
|
37 | - var $boxlabel="BoxLastMembers"; |
|
35 | + var $boxcode = "lastmembers"; |
|
36 | + var $boximg = "object_user"; |
|
37 | + var $boxlabel = "BoxLastMembers"; |
|
38 | 38 | var $depends = array("adherent"); |
39 | 39 | |
40 | 40 | var $db; |
@@ -51,17 +51,17 @@ discard block |
||
51 | 51 | * @param DoliDB $db Database handler |
52 | 52 | * @param string $param More parameters |
53 | 53 | */ |
54 | - function __construct($db,$param='') |
|
54 | + function __construct($db, $param = '') |
|
55 | 55 | { |
56 | 56 | global $conf, $user; |
57 | 57 | |
58 | 58 | $this->db = $db; |
59 | 59 | |
60 | 60 | // disable module for such cases |
61 | - $listofmodulesforexternal=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL); |
|
62 | - if (! in_array('adherent',$listofmodulesforexternal) && ! empty($user->societe_id)) $this->enabled=0; // disabled for external users |
|
61 | + $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); |
|
62 | + if (!in_array('adherent', $listofmodulesforexternal) && !empty($user->societe_id)) $this->enabled = 0; // disabled for external users |
|
63 | 63 | |
64 | - $this->hidden=! ($user->rights->adherent->lire); |
|
64 | + $this->hidden = !($user->rights->adherent->lire); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -70,28 +70,28 @@ discard block |
||
70 | 70 | * @param int $max Maximum number of records to load |
71 | 71 | * @return void |
72 | 72 | */ |
73 | - function loadBox($max=5) |
|
73 | + function loadBox($max = 5) |
|
74 | 74 | { |
75 | 75 | global $user, $langs, $db, $conf; |
76 | 76 | $langs->load("boxes"); |
77 | 77 | |
78 | - $this->max=$max; |
|
78 | + $this->max = $max; |
|
79 | 79 | |
80 | 80 | include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; |
81 | - $memberstatic=new Adherent($db); |
|
81 | + $memberstatic = new Adherent($db); |
|
82 | 82 | |
83 | - $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedMembers",$max)); |
|
83 | + $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedMembers", $max)); |
|
84 | 84 | |
85 | 85 | if ($user->rights->adherent->lire) |
86 | 86 | { |
87 | 87 | $sql = "SELECT a.rowid, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; |
88 | - $sql.= " a.datec, a.tms, a.statut as status, a.datefin as date_end_subscription,"; |
|
89 | - $sql.= " t.subscription"; |
|
90 | - $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as t"; |
|
91 | - $sql.= " WHERE a.entity = ".$conf->entity; |
|
92 | - $sql.= " AND a.fk_adherent_type = t.rowid"; |
|
93 | - $sql.= " ORDER BY a.tms DESC"; |
|
94 | - $sql.= $db->plimit($max, 0); |
|
88 | + $sql .= " a.datec, a.tms, a.statut as status, a.datefin as date_end_subscription,"; |
|
89 | + $sql .= " t.subscription"; |
|
90 | + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as t"; |
|
91 | + $sql .= " WHERE a.entity = ".$conf->entity; |
|
92 | + $sql .= " AND a.fk_adherent_type = t.rowid"; |
|
93 | + $sql .= " ORDER BY a.tms DESC"; |
|
94 | + $sql .= $db->plimit($max, 0); |
|
95 | 95 | |
96 | 96 | $result = $db->query($sql); |
97 | 97 | if ($result) |
@@ -102,20 +102,20 @@ discard block |
||
102 | 102 | while ($line < $num) |
103 | 103 | { |
104 | 104 | $objp = $db->fetch_object($result); |
105 | - $datec=$db->jdate($objp->datec); |
|
106 | - $datem=$db->jdate($objp->tms); |
|
105 | + $datec = $db->jdate($objp->datec); |
|
106 | + $datem = $db->jdate($objp->tms); |
|
107 | 107 | |
108 | - $memberstatic->lastname=$objp->lastname; |
|
109 | - $memberstatic->firstname=$objp->firstname; |
|
108 | + $memberstatic->lastname = $objp->lastname; |
|
109 | + $memberstatic->firstname = $objp->firstname; |
|
110 | 110 | $memberstatic->id = $objp->rowid; |
111 | 111 | $memberstatic->ref = $objp->rowid; |
112 | 112 | |
113 | - if (! empty($objp->fk_soc)) { |
|
113 | + if (!empty($objp->fk_soc)) { |
|
114 | 114 | $memberstatic->socid = $objp->fk_soc; |
115 | 115 | $memberstatic->fetch_thirdparty(); |
116 | - $memberstatic->name=$memberstatic->thirdparty->name; |
|
116 | + $memberstatic->name = $memberstatic->thirdparty->name; |
|
117 | 117 | } else { |
118 | - $memberstatic->name=$objp->company; |
|
118 | + $memberstatic->name = $objp->company; |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | $this->info_box_contents[$line][] = array( |
@@ -137,13 +137,13 @@ discard block |
||
137 | 137 | |
138 | 138 | $this->info_box_contents[$line][] = array( |
139 | 139 | 'td' => 'align="right" width="18"', |
140 | - 'text' => $memberstatic->LibStatut($objp->status,$objp->subscription,$db->jdate($objp->date_end_subscription),3), |
|
140 | + 'text' => $memberstatic->LibStatut($objp->status, $objp->subscription, $db->jdate($objp->date_end_subscription), 3), |
|
141 | 141 | ); |
142 | 142 | |
143 | 143 | $line++; |
144 | 144 | } |
145 | 145 | |
146 | - if ($num==0) |
|
146 | + if ($num == 0) |
|
147 | 147 | $this->info_box_contents[$line][0] = array( |
148 | 148 | 'td' => 'align="center"', |
149 | 149 | 'text'=>$langs->trans("NoRecordedCustomers"), |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * @param int $nooutput No print, only return string |
175 | 175 | * @return string |
176 | 176 | */ |
177 | - function showBox($head = null, $contents = null, $nooutput=0) |
|
177 | + function showBox($head = null, $contents = null, $nooutput = 0) |
|
178 | 178 | { |
179 | 179 | return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
180 | 180 | } |
@@ -59,7 +59,10 @@ discard block |
||
59 | 59 | |
60 | 60 | // disable module for such cases |
61 | 61 | $listofmodulesforexternal=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL); |
62 | - if (! in_array('adherent',$listofmodulesforexternal) && ! empty($user->societe_id)) $this->enabled=0; // disabled for external users |
|
62 | + if (! in_array('adherent',$listofmodulesforexternal) && ! empty($user->societe_id)) { |
|
63 | + $this->enabled=0; |
|
64 | + } |
|
65 | + // disabled for external users |
|
63 | 66 | |
64 | 67 | $this->hidden=! ($user->rights->adherent->lire); |
65 | 68 | } |
@@ -143,11 +146,12 @@ discard block |
||
143 | 146 | $line++; |
144 | 147 | } |
145 | 148 | |
146 | - if ($num==0) |
|
147 | - $this->info_box_contents[$line][0] = array( |
|
149 | + if ($num==0) { |
|
150 | + $this->info_box_contents[$line][0] = array( |
|
148 | 151 | 'td' => 'align="center"', |
149 | 152 | 'text'=>$langs->trans("NoRecordedCustomers"), |
150 | 153 | ); |
154 | + } |
|
151 | 155 | |
152 | 156 | $db->free($result); |
153 | 157 | } else { |