dolibarr  9.0.0
auguria.lib.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2010-2013 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  * or see http://www.gnu.org/
18  */
19 
24 require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php';
25 
26 
27 
40 function print_auguria_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode='')
41 {
42  global $user,$conf,$langs,$dolibarr_main_db_name;
43 
44  $mainmenu=$_SESSION["mainmenu"];
45  $leftmenu=$_SESSION["leftmenu"];
46 
47  $id='mainmenu';
48  $listofmodulesforexternal=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL);
49 
50  // Show personalized menus
51  $menuArbo = new Menubase($db,'auguria');
52  $newTabMenu = $menuArbo->menuTopCharger('', '', $type_user, 'auguria',$tabMenu);
53 
54  if (empty($noout)) print_start_menu_array_auguria();
55 
56  $usemenuhider = (GETPOST('testmenuhider','int') || ! empty($conf->global->MAIN_TESTMENUHIDER));
57 
58  // Show/Hide vertical menu
59  if ($mode != 'jmobile' && $mode != 'topnb' && $usemenuhider && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
60  {
61  $showmode=1;
62  $classname = 'class="tmenu menuhider"';
63  $idsel='menu';
64 
65  $menu->add('#', '', 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname);
66  }
67 
68  $num = count($newTabMenu);
69  for($i = 0; $i < $num; $i++)
70  {
71  $idsel=(empty($newTabMenu[$i]['mainmenu'])?'none':$newTabMenu[$i]['mainmenu']);
72 
73  $showmode=dol_auguria_showmenu($type_user,$newTabMenu[$i],$listofmodulesforexternal);
74  if ($showmode == 1)
75  {
76  $substitarray = array('__LOGIN__' => $user->login, '__USER_ID__' => $user->id, '__USER_SUPERVISOR_ID__' => $user->fk_user);
77  $substitarray['__USERID__'] = $user->id; // For backward compatibility
78  $newTabMenu[$i]['url'] = make_substitutions($newTabMenu[$i]['url'], $substitarray);
79 
80  $url = $shorturl = $newTabMenu[$i]['url'];
81 
82  if (! preg_match("/^(http:\/\/|https:\/\/)/i",$newTabMenu[$i]['url']))
83  {
84  $tmp=explode('?',$newTabMenu[$i]['url'],2);
85  $url = $shorturl = $tmp[0];
86  $param = (isset($tmp[1])?$tmp[1]:'');
87 
88  // Complete param to force leftmenu to '' to close open menu when we click on a link with no leftmenu defined.
89  if ((! preg_match('/mainmenu/i',$param)) && (! preg_match('/leftmenu/i',$param)) && ! empty($newTabMenu[$i]['url']))
90  {
91  $param.=($param?'&':'').'mainmenu='.$newTabMenu[$i]['mainmenu'].'&leftmenu=';
92  }
93  if ((! preg_match('/mainmenu/i',$param)) && (! preg_match('/leftmenu/i',$param)) && empty($newTabMenu[$i]['url']))
94  {
95  $param.=($param?'&':'').'leftmenu=';
96  }
97  //$url.="idmenu=".$newTabMenu[$i]['rowid']; // Already done by menuLoad
98  $url = dol_buildpath($url,1).($param?'?'.$param:'');
99  //$shorturl = $shorturl.($param?'?'.$param:'');
100  $shorturl = $url;
101 
102  if (DOL_URL_ROOT) $shorturl = preg_replace('/^'.preg_quote(DOL_URL_ROOT,'/').'/','',$shorturl);
103  }
104 
105  // TODO Find a generic solution
106  if (preg_match('/search_project_user=__search_project_user__/', $shorturl))
107  {
108  $search_project_user = GETPOST('search_project_user','int');
109  if ($search_project_user) $shorturl=preg_replace('/search_project_user=__search_project_user__/', 'search_project_user='.$search_project_user, $shorturl);
110  else $shorturl=preg_replace('/search_project_user=__search_project_user__/', '', $shorturl);
111  }
112 
113  // Define the class (top menu selected or not)
114  if (! empty($_SESSION['idmenu']) && $newTabMenu[$i]['rowid'] == $_SESSION['idmenu']) $classname='class="tmenusel"';
115  else if (! empty($_SESSION["mainmenu"]) && $newTabMenu[$i]['mainmenu'] == $_SESSION["mainmenu"]) $classname='class="tmenusel"';
116  else $classname='class="tmenu"';
117  }
118  else if ($showmode == 2) $classname='class="tmenu"';
119 
120  $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);
121  }
122 
123  // Sort on position
124  $menu->liste = dol_sort_array($menu->liste, 'position');
125 
126  // Output menu entries
127  foreach($menu->liste as $menkey => $menuval)
128  {
129  if (empty($noout)) print_start_menu_entry_auguria($menuval['idsel'],$menuval['classname'],$menuval['enabled']);
130  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));
131  if (empty($noout)) print_end_menu_entry_auguria($menuval['enabled']);
132  }
133 
134  $showmode=1;
135  if (empty($noout)) print_start_menu_entry_auguria('','class="tmenuend"',$showmode);
136  if (empty($noout)) print_end_menu_entry_auguria($showmode);
137 
138  if (empty($noout)) print_end_menu_array_auguria();
139 
140  print "\n";
141 
142  return 0;
143 }
144 
145 
152 {
153  global $conf;
154 
155  print '<div class="tmenudiv">';
156  print '<ul role="navigation" class="tmenu"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)?'':' title="Top menu"').'>';
157 }
158 
167 function print_start_menu_entry_auguria($idsel,$classname,$showmode)
168 {
169  if ($showmode)
170  {
171  print '<li '.$classname.' id="mainmenutd_'.$idsel.'">';
172  //print '<div class="tmenuleft tmenusep"></div>';
173  print '<div class="tmenucenter">';
174  }
175 }
176 
189 function print_text_menu_entry_auguria($text, $showmode, $url, $id, $idsel, $classname, $atarget)
190 {
191  global $langs;
192 
193  if ($showmode == 1)
194  {
195  print '<a class="tmenuimage" tabindex="-1" href="'.$url.'"'.($atarget?' target="'.$atarget.'"':'').'>';
196  print '<div class="'.$id.' '.$idsel.' topmenuimage"><span class="'.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
197  print '</a>';
198  print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.$url.'"'.($atarget?' target="'.$atarget.'"':'').'>';
199  print '<span class="mainmenuaspan">';
200  print $text;
201  print '</span>';
202  print '</a>';
203  }
204  if ($showmode == 2)
205  {
206  print '<div class="'.$id.' '.$idsel.' topmenuimage tmenudisabled"><span class="'.$id.'" id="mainmenuspan_'.$idsel.'"></span></div>';
207  print '<a class="tmenudisabled" id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">';
208  print '<span class="mainmenuaspan">';
209  print $text;
210  print '</span>';
211  print '</a>';
212  }
213 }
214 
221 function print_end_menu_entry_auguria($showmode)
222 {
223  if ($showmode)
224  {
225  print '</div></li>';
226  }
227  print "\n";
228 }
229 
236 {
237  print '</ul>';
238  print '</div>';
239  print "\n";
240 }
241 
242 
243 
258 function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabMenu,&$menu,$noout=0,$forcemainmenu='',$forceleftmenu='',$moredata=null)
259 {
260  global $user,$conf,$langs,$dolibarr_main_db_name,$mysoc;
261 
262  $newmenu = $menu;
263 
264  $mainmenu=($forcemainmenu?$forcemainmenu:$_SESSION["mainmenu"]);
265  $leftmenu=($forceleftmenu?'':(empty($_SESSION["leftmenu"])?'none':$_SESSION["leftmenu"]));
266 
267  $usemenuhider = (GETPOST('testmenuhider','int') || ! empty($conf->global->MAIN_TESTMENUHIDER));
268  global $usemenuhider;
269 
270  // Show logo company
271  if (empty($noout) && ! empty($conf->global->MAIN_SHOW_LOGO) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
272  {
273  $mysoc->logo_mini=$conf->global->MAIN_INFO_SOCIETE_LOGO_MINI;
274  if (! empty($mysoc->logo_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini))
275  {
276  $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_mini);
277  }
278  else
279  {
280  $urllogo=DOL_URL_ROOT.'/theme/dolibarr_logo.png';
281  }
282  $title=$langs->trans("GoIntoSetupToChangeLogo");
283  print "\n".'<!-- Show logo on menu -->'."\n";
284  print '<div class="blockvmenuimpair blockvmenulogo">'."\n";
285  print '<div class="menu_titre" id="menu_titre_logo"></div>';
286  print '<div class="menu_top" id="menu_top_logo"></div>';
287  print '<div class="menu_contenu" id="menu_contenu_logo">';
288  print '<div class="center"><img title="'.dol_escape_htmltag($title).'" alt="" src="'.$urllogo.'" style="max-width: 70%"></div>'."\n";
289  print '</div>';
290  print '<div class="menu_end" id="menu_end_logo"></div>';
291  print '</div>'."\n";
292  }
293 
294  if (is_array($moredata) && ! empty($moredata['searchform'])) // searchform can contains select2 code or link to show old search form or link to switch on search page
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";
302  }
303 
304  if (is_array($moredata) && ! empty($moredata['bookmarks']))
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";
312  }
313 
314  // We update newmenu with entries found into database
315  $menuArbo = new Menubase($db,'auguria');
316  $newmenu = $menuArbo->menuLeftCharger($newmenu,$mainmenu,$leftmenu,($user->societe_id?1:0),'auguria',$tabMenu);
317 
318  // We update newmenu for special dynamic menus
319  if ($conf->banque->enabled && $user->rights->banque->lire && $mainmenu == 'bank') // Entry for each bank account
320  {
321  include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Required for to get Account::TYPE_CASH for example
322 
323  $sql = "SELECT rowid, label, courant, rappro, courant";
324  $sql.= " FROM ".MAIN_DB_PREFIX."bank_account";
325  $sql.= " WHERE entity = ".$conf->entity;
326  $sql.= " AND clos = 0";
327  $sql.= " ORDER BY label";
328 
329  $resql = $db->query($sql);
330  if ($resql)
331  {
332  $numr = $db->num_rows($resql);
333  $i = 0;
334 
335  if ($numr > 0) $newmenu->add('/compta/bank/list.php',$langs->trans("BankAccounts"),0,$user->rights->banque->lire);
336 
337  while ($i < $numr)
338  {
339  $objp = $db->fetch_object($resql);
340  $newmenu->add('/compta/bank/card.php?id='.$objp->rowid,$objp->label,1,$user->rights->banque->lire);
341  if ($objp->rappro && $objp->courant != Account::TYPE_CASH && empty($objp->clos)) // If not cash account and not closed and can be reconciliate
342  {
343  $newmenu->add('/compta/bank/bankentries_list.php?id='.$objp->rowid,$langs->trans("Conciliate"),2,$user->rights->banque->consolidate);
344  }
345  $i++;
346  }
347  }
348  else dol_print_error($db);
349  $db->free($resql);
350  }
351 
352  if (! empty($conf->accounting->enabled) && !empty($user->rights->accounting->mouvements->lire) && $mainmenu == 'accountancy') // Entry in accountancy journal for each bank account
353  {
354  $newmenu->add('',$langs->trans("Journalization"),0,$user->rights->accounting->comptarapport->lire,'','accountancy','accountancy');
355 
356  // Multi journal
357  $sql = "SELECT rowid, code, label, nature";
358  $sql.= " FROM ".MAIN_DB_PREFIX."accounting_journal";
359  $sql.= " WHERE entity = ".$conf->entity;
360  $sql.= " AND active = 1";
361  $sql.= " ORDER BY label DESC";
362 
363  $resql = $db->query($sql);
364  if ($resql)
365  {
366  $numr = $db->num_rows($resql);
367  $i = 0;
368 
369  if ($numr > 0)
370  {
371  while ($i < $numr)
372  {
373  $objp = $db->fetch_object($resql);
374 
375  $nature='';
376 
377  // Must match array $sourceList defined into journals_list.php
378  if ($objp->nature == 2 && ! empty($conf->facture->enabled)) $nature="sells";
379  if ($objp->nature == 3 && ! empty($conf->fournisseur->enabled)) $nature="purchases";
380  if ($objp->nature == 4 && ! empty($conf->banque->enabled)) $nature="bank";
381  if ($objp->nature == 5 && ! empty($conf->expensereport->enabled)) $nature="expensereports";
382  if ($objp->nature == 1) $nature="various";
383  if ($objp->nature == 8) $nature="inventory";
384  if ($objp->nature == 9) $nature="hasnew";
385 
386  // To enable when page exists
387  if (! empty($conf->global->ACCOUNTANCY_SHOW_DEVELOP_JOURNAL))
388  {
389  if ($nature == 'various' || $nature == 'hasnew' || $nature == 'inventory') $nature='';
390  }
391 
392  if ($nature)
393  {
394  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);
395  }
396  $i++;
397  }
398  }
399  else
400  {
401  // Should not happend. Entries are added
402  $newmenu->add('',$langs->trans("NoJournalDefined"), 2, $user->rights->accounting->comptarapport->lire);
403  }
404  }
405  else dol_print_error($db);
406  $db->free($resql);
407 
408  /*
409  $sql = "SELECT rowid, label, accountancy_journal";
410  $sql.= " FROM ".MAIN_DB_PREFIX."bank_account";
411  $sql.= " WHERE entity = ".$conf->entity;
412  $sql.= " AND clos = 0";
413  $sql.= " ORDER BY label";
414 
415  $resql = $db->query($sql);
416  if ($resql)
417  {
418  $numr = $db->num_rows($resql);
419  $i = 0;
420 
421  if ($numr > 0)
422  while ($i < $numr)
423  {
424  $objp = $db->fetch_object($resql);
425  $newmenu->add('/accountancy/journal/bankjournal.php?id_account='.$objp->rowid, $langs->trans("Journal").' - '.$objp->label, 1, $user->rights->accounting->comptarapport->lire,'','accountancy','accountancy_journal');
426  $i++;
427  }
428  }
429  else dol_print_error($db);
430  $db->free($resql);
431 
432  // Add other journal
433  $newmenu->add("/accountancy/journal/sellsjournal.php?leftmenu=journal",$langs->trans("SellsJournal"),1,$user->rights->accounting->comptarapport->lire,'','accountancy','accountancy_journal');
434  $newmenu->add("/accountancy/journal/purchasesjournal.php?leftmenu=journal",$langs->trans("PurchasesJournal"),1,$user->rights->accounting->comptarapport->lire,'','accountancy','accountancy_journal');
435  $newmenu->add("/accountancy/journal/expensereportsjournal.php?leftmenu=journal",$langs->trans("ExpenseReportsJournal"),1,$user->rights->accounting->comptarapport->lire,'','accountancy','accountancy_journal');
436  */
437  }
438 
439  if ($conf->ftp->enabled && $mainmenu == 'ftp') // Entry for FTP
440  {
441  $MAXFTP=20;
442  $i=1;
443  while ($i <= $MAXFTP)
444  {
445  $paramkey='FTP_NAME_'.$i;
446  //print $paramkey;
447  if (! empty($conf->global->$paramkey))
448  {
449  $link="/ftp/index.php?idmenu=".$_SESSION["idmenu"]."&numero_ftp=".$i;
450 
451  $newmenu->add($link, dol_trunc($conf->global->$paramkey,24));
452  }
453  $i++;
454  }
455  }
456 
457 
458  // Build final $menu_array = $menu_array_before +$newmenu->liste + $menu_array_after
459  //var_dump($menu_array_before);exit;
460  //var_dump($menu_array_after);exit;
461  $menu_array=$newmenu->liste;
462  if (is_array($menu_array_before)) $menu_array=array_merge($menu_array_before, $menu_array);
463  if (is_array($menu_array_after)) $menu_array=array_merge($menu_array, $menu_array_after);
464  //var_dump($menu_array);exit;
465  if (! is_array($menu_array)) return 0;
466 
467  // Show menu
468  $invert=empty($conf->global->MAIN_MENU_INVERT)?"":"invert";
469  if (empty($noout))
470  {
471  $altok=0; $blockvmenuopened=false; $lastlevel0='';
472  $num=count($menu_array);
473  for ($i = 0; $i < $num; $i++) // Loop on each menu entry
474  {
475  $showmenu=true;
476  if (! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($menu_array[$i]['enabled'])) $showmenu=false;
477 
478  // Begin of new left menu block
479  if (empty($menu_array[$i]['level']) && $showmenu)
480  {
481  $altok++;
482  $blockvmenuopened=true;
483  $lastopened=true;
484  for($j = ($i + 1); $j < $num; $j++)
485  {
486  if (empty($menu_array[$j]['level'])) $lastopened=false;
487  }
488  if ($altok % 2 == 0)
489  {
490  print '<div class="blockvmenu blockvmenuimpair'.$invert.($lastopened?' blockvmenulast':'').($altok == 1 ? ' blockvmenufirst':'').'">'."\n";
491  }
492  else
493  {
494  print '<div class="blockvmenu blockvmenupair'.$invert.($lastopened?' blockvmenulast':'').($altok == 1 ? ' blockvmenufirst':'').'">'."\n";
495  }
496  }
497 
498  // Add tabulation
499  $tabstring='';
500  $tabul=($menu_array[$i]['level'] - 1);
501  if ($tabul > 0)
502  {
503  for ($j=0; $j < $tabul; $j++)
504  {
505  $tabstring.='&nbsp;&nbsp;&nbsp;';
506  }
507  }
508 
509  // $menu_array[$i]['url'] can be a relative url, a full external url. We try substitution
510  $substitarray = array('__LOGIN__' => $user->login, '__USER_ID__' => $user->id, '__USER_SUPERVISOR_ID__' => $user->fk_user);
511  $substitarray['__USERID__'] = $user->id; // For backward compatibility
512  $menu_array[$i]['url'] = make_substitutions($menu_array[$i]['url'], $substitarray);
513 
514  $url = $shorturl = $shorturlwithoutparam = $menu_array[$i]['url'];
515  if (! preg_match("/^(http:\/\/|https:\/\/)/i",$menu_array[$i]['url']))
516  {
517  $tmp=explode('?',$menu_array[$i]['url'],2);
518  $url = $shorturl = $tmp[0];
519  $param = (isset($tmp[1])?$tmp[1]:''); // params in url of the menu link
520 
521  // Complete param to force leftmenu to '' to close open menu when we click on a link with no leftmenu defined.
522  if ((! preg_match('/mainmenu/i',$param)) && (! preg_match('/leftmenu/i',$param)) && ! empty($menu_array[$i]['mainmenu']))
523  {
524  $param.=($param?'&':'').'mainmenu='.$menu_array[$i]['mainmenu'].'&leftmenu=';
525  }
526  if ((! preg_match('/mainmenu/i',$param)) && (! preg_match('/leftmenu/i',$param)) && empty($menu_array[$i]['mainmenu']))
527  {
528  $param.=($param?'&':'').'leftmenu=';
529  }
530  //$url.="idmenu=".$menu_array[$i]['rowid']; // Already done by menuLoad
531  $url = dol_buildpath($url,1).($param?'?'.$param:'');
532  $shorturlwithoutparam = $shorturl;
533  $shorturl = $shorturl.($param?'?'.$param:'');
534  }
535 
536 
537  print '<!-- Process menu entry with mainmenu='.$menu_array[$i]['mainmenu'].', leftmenu='.$menu_array[$i]['leftmenu'].', level='.$menu_array[$i]['level'].' enabled='.$menu_array[$i]['enabled'].', position='.$menu_array[$i]['position'].' -->'."\n";
538 
539  // Menu level 0
540  if ($menu_array[$i]['level'] == 0)
541  {
542  if ($menu_array[$i]['enabled']) // Enabled so visible
543  {
544  print '<div class="menu_titre">'.$tabstring;
545  if ($shorturlwithoutparam) print '<a class="vmenu" href="'.$url.'"'.($menu_array[$i]['target']?' target="'.$menu_array[$i]['target'].'"':'').'>';
546  else print '<span class="vmenu">';
547  print ($menu_array[$i]['prefix']?$menu_array[$i]['prefix']:'').$menu_array[$i]['titre'];
548  if ($shorturlwithoutparam) print '</a>';
549  else print '</span>';
550  print '</div>'."\n";
551  $lastlevel0='enabled';
552  }
553  else if ($showmenu) // Not enabled but visible (so greyed)
554  {
555  print '<div class="menu_titre">'.$tabstring.'<font class="vmenudisabled">'.$menu_array[$i]['titre'].'</font></div>'."\n";
556  $lastlevel0='greyed';
557  }
558  else
559  {
560  $lastlevel0='hidden';
561  }
562  if ($showmenu)
563  {
564  print '<div class="menu_top"></div>'."\n";
565  }
566  }
567 
568  // Menu level > 0
569  if ($menu_array[$i]['level'] > 0)
570  {
571  $cssmenu = '';
572  if ($menu_array[$i]['url']) $cssmenu = ' menu_contenu'.dol_string_nospecial(preg_replace('/\.php.*$/','',$menu_array[$i]['url']));
573 
574  if ($menu_array[$i]['enabled'] && $lastlevel0 == 'enabled') // Enabled so visible, except if parent was not enabled.
575  {
576  print '<div class="menu_contenu'.$cssmenu.'">'.$tabstring;
577  if ($shorturlwithoutparam) print '<a class="vsmenu" href="'.$url.'"'.($menu_array[$i]['target']?' target="'.$menu_array[$i]['target'].'"':'').'>';
578  else print '<span class="vsmenu">';
579  print $menu_array[$i]['titre'];
580  if ($shorturlwithoutparam) print '</a>';
581  else print '</span>';
582  // If title is not pure text and contains a table, no carriage return added
583  if (! strstr($menu_array[$i]['titre'],'<table')) print '<br>';
584  print '</div>'."\n";
585  }
586  else if ($showmenu && $lastlevel0 == 'enabled') // Not enabled but visible (so greyed), except if parent was not enabled.
587  {
588  print '<div class="menu_contenu'.$cssmenu.'">'.$tabstring.'<font class="vsmenudisabled vsmenudisabledmargin">'.$menu_array[$i]['titre'].'</font><br></div>'."\n";
589  }
590  }
591 
592  // If next is a new block or if there is nothing after
593  if (empty($menu_array[$i+1]['level'])) // End menu block
594  {
595  if ($showmenu)
596  print '<div class="menu_end"></div>'."\n";
597  if ($blockvmenuopened) { print '</div>'."\n"; $blockvmenuopened=false; }
598  }
599  }
600 
601  if ($altok) print '<div class="blockvmenuend"></div>'; // End menu block
602  }
603 
604  return count($menu_array);
605 }
606 
607 
616 function dol_auguria_showmenu($type_user, &$menuentry, &$listofmodulesforexternal)
617 {
618  global $conf;
619 
620  //print 'type_user='.$type_user.' module='.$menuentry['module'].' enabled='.$menuentry['enabled'].' perms='.$menuentry['perms'];
621  //print 'ok='.in_array($menuentry['module'], $listofmodulesforexternal);
622  if (empty($menuentry['enabled'])) return 0; // Entry disabled by condition
623  if ($type_user && $menuentry['module'])
624  {
625  $tmploops=explode('|',$menuentry['module']);
626  $found=0;
627  foreach($tmploops as $tmploop)
628  {
629  if (in_array($tmploop, $listofmodulesforexternal)) {
630  $found++; break;
631  }
632  }
633  if (! $found) return 0; // Entry is for menus all excluded to external users
634  }
635  if (! $menuentry['perms'] && $type_user) return 0; // No permissions and user is external
636  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
637  if (! $menuentry['perms']) return 2; // No permissions and user is external
638  return 1;
639 }
print_start_menu_entry_auguria($idsel, $classname, $showmode)
Output start menu entry.
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
Definition: index.php:91
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding &#39;...&#39; if string larger than length.
if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) if(! empty($conf->don->enabled) && $user->rights->societe->lire) if(! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) if(! empty($conf->facture->enabled) &&! empty($conf->commande->enabled) && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1053
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
dol_auguria_showmenu($type_user, &$menuentry, &$listofmodulesforexternal)
Function to test if an entry is enabled or not.
Class to manage menu entries.
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
print_text_menu_entry_auguria($text, $showmode, $url, $id, $idsel, $classname, $atarget)
Output menu entry.
print_start_menu_array_auguria()
Output start menu array.
const TYPE_CASH
Cash account.
print_auguria_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout=0, $mode='')
Core function to output top menu auguria.
Definition: auguria.lib.php:40
print_end_menu_entry_auguria($showmode)
Output end menu entry.
make_substitutions($text, $substitutionarray, $outputlangs=null)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
print_end_menu_array_auguria()
Output menu array.
print_left_auguria_menu($db, $menu_array_before, $menu_array_after, &$tabMenu, &$menu, $noout=0, $forcemainmenu='', $forceleftmenu='', $moredata=null)
Core function to output left menu auguria.