45 public $errors = array();
160 $this->menu_handler = $menu_handler;
173 global $conf, $langs;
176 if (!isset($this->enabled)) $this->enabled =
'1';
177 $this->menu_handler = trim($this->menu_handler);
178 $this->module = trim($this->module);
180 $this->mainmenu = trim($this->mainmenu);
181 $this->leftmenu = trim($this->leftmenu);
182 $this->fk_menu = (int) $this->fk_menu;
183 $this->fk_mainmenu = trim($this->fk_mainmenu);
184 $this->fk_leftmenu = trim($this->fk_leftmenu);
185 $this->position = (int) $this->position;
186 $this->url = trim($this->url);
187 $this->target = trim($this->target);
188 $this->title = trim($this->title);
189 $this->langs = trim($this->langs);
190 $this->perms = trim($this->perms);
191 $this->enabled = trim($this->enabled);
193 if (empty($this->position)) $this->position = 0;
194 if (!$this->level) $this->level = 0;
197 if (empty($this->menu_handler))
return -1;
202 if (in_array($this->
db->type, array(
'pgsql')))
204 $sql =
"SELECT MAX(rowid) as maxrowid FROM ".MAIN_DB_PREFIX.
"menu";
205 $resqlrowid = $this->
db->query($sql);
207 $obj = $this->
db->fetch_object($resqlrowid);
208 $maxrowid = $obj->maxrowid;
211 if (empty($maxrowid)) $maxrowid = 1;
213 $sql =
"SELECT setval('".MAIN_DB_PREFIX.
"menu_rowid_seq', ".($maxrowid).
")";
215 $resqlrowidset = $this->
db->query($sql);
221 $sql =
"SELECT count(*)";
222 $sql .=
" FROM ".MAIN_DB_PREFIX.
"menu";
223 $sql .=
" WHERE menu_handler = '".$this->db->escape($this->menu_handler).
"'";
224 $sql .=
" AND fk_menu = ".((int) $this->fk_menu);
225 $sql .=
" AND position = ".((int) $this->position);
226 $sql .=
" AND url = '".$this->db->escape($this->url).
"'";
227 $sql .=
" AND entity = ".$conf->entity;
229 $result = $this->
db->query($sql);
232 $row = $this->
db->fetch_row($result);
237 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"menu(";
238 $sql .=
"menu_handler,";
245 $sql .=
"fk_mainmenu,";
246 $sql .=
"fk_leftmenu,";
255 $sql .=
") VALUES (";
256 $sql .=
" '".$this->db->escape($this->menu_handler).
"',";
257 $sql .=
" '".$this->db->escape($conf->entity).
"',";
258 $sql .=
" '".$this->db->escape($this->module).
"',";
259 $sql .=
" '".$this->db->escape($this->
type).
"',";
260 $sql .=
" ".($this->mainmenu ?
"'".$this->db->escape($this->mainmenu).
"'" :
"''").
",";
261 $sql .=
" ".($this->leftmenu ?
"'".$this->db->escape($this->leftmenu).
"'" :
"null").
",";
262 $sql .=
" ".((int) $this->fk_menu).
",";
263 $sql .=
" ".($this->fk_mainmenu ?
"'".$this->db->escape($this->fk_mainmenu).
"'" :
"null").
",";
264 $sql .=
" ".($this->fk_leftmenu ?
"'".$this->db->escape($this->fk_leftmenu).
"'" :
"null").
",";
265 $sql .=
" ".((int) $this->position).
",";
266 $sql .=
" '".$this->db->escape($this->url).
"',";
267 $sql .=
" '".$this->db->escape($this->target).
"',";
268 $sql .=
" '".$this->db->escape($this->title).
"',";
269 $sql .=
" '".$this->db->escape($this->langs).
"',";
270 $sql .=
" '".$this->db->escape($this->perms).
"',";
271 $sql .=
" '".$this->db->escape($this->enabled).
"',";
272 $sql .=
" '".$this->db->escape($this->
user).
"'";
275 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
279 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"menu");
280 dol_syslog(get_class($this).
"::create record added has rowid=".$this->
id, LOG_DEBUG);
284 $this->error =
"Error ".$this->db->lasterror();
288 dol_syslog(get_class($this).
"::create menu entry already exists", LOG_WARNING);
289 $this->error =
'Error Menu entry already exists';
304 public function update($user = null, $notrigger = 0)
310 $this->menu_handler = trim($this->menu_handler);
311 $this->module = trim($this->module);
313 $this->mainmenu = trim($this->mainmenu);
314 $this->leftmenu = trim($this->leftmenu);
315 $this->fk_menu = (int) $this->fk_menu;
316 $this->fk_mainmenu = trim($this->fk_mainmenu);
317 $this->fk_leftmenu = trim($this->fk_leftmenu);
318 $this->position = (int) $this->position;
319 $this->url = trim($this->url);
320 $this->target = trim($this->target);
321 $this->title = trim($this->title);
322 $this->langs = trim($this->langs);
323 $this->perms = trim($this->perms);
324 $this->enabled = trim($this->enabled);
331 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"menu SET";
332 $sql .=
" menu_handler='".$this->db->escape($this->menu_handler).
"',";
333 $sql .=
" module='".$this->db->escape($this->module).
"',";
334 $sql .=
" type='".$this->db->escape($this->
type).
"',";
335 $sql .=
" mainmenu='".$this->db->escape($this->mainmenu).
"',";
336 $sql .=
" leftmenu='".$this->db->escape($this->leftmenu).
"',";
337 $sql .=
" fk_menu=".$this->fk_menu.
",";
338 $sql .=
" fk_mainmenu=".($this->fk_mainmenu ?
"'".$this->db->escape($this->fk_mainmenu).
"'" :
"null").
",";
339 $sql .=
" fk_leftmenu=".($this->fk_leftmenu ?
"'".$this->db->escape($this->fk_leftmenu).
"'" :
"null").
",";
340 $sql .=
" position=".($this->position > 0 ? $this->position : 0).
",";
341 $sql .=
" url='".$this->db->escape($this->url).
"',";
342 $sql .=
" target='".$this->db->escape($this->target).
"',";
343 $sql .=
" titre='".$this->db->escape($this->title).
"',";
344 $sql .=
" langs='".$this->db->escape($this->langs).
"',";
345 $sql .=
" perms='".$this->db->escape($this->perms).
"',";
346 $sql .=
" enabled='".$this->db->escape($this->enabled).
"',";
347 $sql .=
" usertype='".$this->db->escape($this->
user).
"'";
348 $sql .=
" WHERE rowid=".$this->id;
350 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
354 $this->error =
"Error ".$this->db->lasterror();
369 public function fetch($id, $user = null)
375 $sql .=
" t.menu_handler,";
376 $sql .=
" t.entity,";
377 $sql .=
" t.module,";
379 $sql .=
" t.mainmenu,";
380 $sql .=
" t.leftmenu,";
381 $sql .=
" t.fk_menu,";
382 $sql .=
" t.fk_mainmenu,";
383 $sql .=
" t.fk_leftmenu,";
384 $sql .=
" t.position,";
386 $sql .=
" t.target,";
387 $sql .=
" t.titre as title,";
390 $sql .=
" t.enabled,";
391 $sql .=
" t.usertype as user,";
393 $sql .=
" FROM ".MAIN_DB_PREFIX.
"menu as t";
394 $sql .=
" WHERE t.rowid = ".$id;
396 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
402 $obj = $this->
db->fetch_object(
$resql);
404 $this->
id = $obj->rowid;
406 $this->menu_handler = $obj->menu_handler;
407 $this->entity = $obj->entity;
408 $this->module = $obj->module;
409 $this->
type = $obj->type;
410 $this->mainmenu = $obj->mainmenu;
411 $this->leftmenu = $obj->leftmenu;
412 $this->fk_menu = $obj->fk_menu;
413 $this->fk_mainmenu = $obj->fk_mainmenu;
414 $this->fk_leftmenu = $obj->fk_leftmenu;
415 $this->position = $obj->position;
416 $this->url = $obj->url;
417 $this->target = $obj->target;
418 $this->title = $obj->title;
419 $this->langs = $obj->langs;
420 $this->perms = $obj->perms;
421 $this->enabled = str_replace(
"\"",
"'", $obj->enabled);
422 $this->
user = $obj->user;
423 $this->tms = $this->
db->jdate($obj->tms);
429 $this->error =
"Error ".$this->db->lasterror();
441 public function delete($user)
445 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"menu";
446 $sql .=
" WHERE rowid=".$this->id;
448 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
452 $this->error =
"Error ".$this->db->lasterror();
471 $this->menu_handler =
'all';
472 $this->module =
'specimen';
474 $this->mainmenu =
'';
475 $this->fk_menu =
'0';
476 $this->position =
'';
477 $this->url =
'http://dummy';
479 $this->title =
'Specimen menu';
481 $this->leftmenu =
'';
499 public function menuTopCharger($mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu)
501 global $langs, $user, $conf;
502 global $mainmenu, $leftmenu;
504 $mainmenu = $mymainmenu;
505 $leftmenu = $myleftmenu;
507 $newTabMenu = array();
508 foreach ($tabMenu as $val)
510 if ($val[
'type'] ==
'top') $newTabMenu[] = $val;
528 public function menuLeftCharger($newmenu, $mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu)
530 global $langs, $user, $conf;
531 global $mainmenu, $leftmenu;
533 $mainmenu = $mymainmenu;
534 $leftmenu = $myleftmenu;
538 foreach ($tabMenu as $key => $val)
541 if (empty($menutopid) && $val[
'type'] ==
'top' && $val[
'mainmenu'] == $mainmenu)
543 $menutopid = $val[
'rowid'];
549 $this->newmenu = $newmenu;
552 $this->
recur($tabMenu, $menutopid, 1);
555 foreach ($tabMenu as $key => $val)
558 if ($val[
'fk_menu'] == -1 && $val[
'fk_mainmenu'] == $mainmenu)
563 if (empty($val[
'fk_leftmenu']))
565 $this->newmenu->add($val[
'url'], $val[
'titre'], 0, $val[
'perms'], $val[
'target'], $val[
'mainmenu'], $val[
'leftmenu'], $val[
'position']);
569 $searchlastsub = 0; $lastid = 0; $nextid = 0; $found = 0;
570 foreach ($this->newmenu->liste as $keyparent => $valparent)
575 if ($valparent[
'level'] >= $searchlastsub) $lastid = $keyparent;
576 if ($valparent[
'level'] < $searchlastsub)
578 $nextid = $keyparent;
582 if ($valparent[
'mainmenu'] == $val[
'fk_mainmenu'] && $valparent[
'leftmenu'] == $val[
'fk_leftmenu'])
586 $searchlastsub = ($valparent[
'level'] + 1);
587 $lastid = $keyparent;
592 if ($found) $this->newmenu->insert($lastid, $val[
'url'], $val[
'titre'], $searchlastsub, $val[
'perms'], $val[
'target'], $val[
'mainmenu'], $val[
'leftmenu'], $val[
'position']);
594 dol_syslog(
"Error. Modules ".$val[
'module'].
" has defined a menu entry with a parent='fk_mainmenu=".$val[
'fk_leftmenu'].
",fk_leftmenu=".$val[
'fk_leftmenu'].
"' and position=".$val[
'position'].
'. The parent was not found. May be you forget it into your definition of menu, or may be the parent has a "position" that is after the child (fix field "position" of parent or child in this case).', LOG_WARNING);
601 return $this->newmenu;
615 public function menuLoad($mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu)
617 global $langs, $user, $conf;
618 global $mainmenu, $leftmenu;
620 $mainmenu = $mymainmenu;
621 $leftmenu = $myleftmenu;
623 $sql =
"SELECT m.rowid, m.type, m.module, m.fk_menu, m.fk_mainmenu, m.fk_leftmenu, m.url, m.titre, m.langs, m.perms, m.enabled, m.target, m.mainmenu, m.leftmenu, m.position";
624 $sql .=
" FROM ".MAIN_DB_PREFIX.
"menu as m";
625 $sql .=
" WHERE m.entity IN (0,".$conf->entity.
")";
626 $sql .=
" AND m.menu_handler IN ('".$this->db->escape($menu_handler).
"','all')";
627 if ($type_user == 0) $sql .=
" AND m.usertype IN (0,2)";
628 if ($type_user == 1) $sql .=
" AND m.usertype IN (1,2)";
629 $sql .=
" ORDER BY m.position, m.rowid";
636 $numa = $this->
db->num_rows(
$resql);
643 $menu = $this->
db->fetch_array(
$resql);
647 if (isset($menu[
'perms']))
649 $tmpcond = $menu[
'perms'];
650 if ($leftmenu ==
'all') $tmpcond = preg_replace(
'/\$leftmenu\s*==\s*["\'a-zA-Z_]+/',
'1==1', $tmpcond);
657 if (isset($menu[
'enabled']))
659 $tmpcond = $menu[
'enabled'];
660 if ($leftmenu ==
'all') $tmpcond = preg_replace(
'/\$leftmenu\s*==\s*["\'a-zA-Z_]+/',
'1==1', $tmpcond);
667 $title = $langs->trans($menu[
'titre']);
669 if ($title == $menu[
'titre'])
671 if (!empty($menu[
'langs']))
674 $langs->load($menu[
'langs']);
677 $substitarray = array(
'__LOGIN__' => $user->login,
'__USER_ID__' => $user->id,
'__USER_SUPERVISOR_ID__' => $user->fk_user);
680 if (preg_match(
"/\//", $menu[
'titre']))
682 $tab_titre = explode(
"/", $menu[
'titre']);
683 $title = $langs->trans($tab_titre[0]).
"/".$langs->trans($tab_titre[1]);
684 } elseif (preg_match(
'/\|\|/', $menu[
'titre']))
687 $tab_title = explode(
"||", $menu[
'titre']);
688 $alt_title = explode(
"@", $tab_title[1]);
689 $title_enabled =
verifCond($alt_title[1]);
690 $title = ($title_enabled ? $langs->trans($alt_title[0]) : $langs->trans($tab_title[0]));
692 $title = $langs->trans($menu[
'titre']);
699 $tabMenu[$b][
'rowid'] = $menu[
'rowid'];
700 $tabMenu[$b][
'module'] = $menu[
'module'];
701 $tabMenu[$b][
'fk_menu'] = $menu[
'fk_menu'];
702 $tabMenu[$b][
'url'] = $menu[
'url'];
703 if (!preg_match(
"/^(http:\/\/|https:\/\/)/i", $tabMenu[$b][
'url']))
705 if (preg_match(
'/\?/', $tabMenu[$b][
'url'])) $tabMenu[$b][
'url'] .=
'&idmenu='.$menu[
'rowid'];
706 else $tabMenu[$b][
'url'] .=
'?idmenu='.$menu[
'rowid'];
708 $tabMenu[$b][
'titre'] = $title;
709 $tabMenu[$b][
'target'] = $menu[
'target'];
710 $tabMenu[$b][
'mainmenu'] = $menu[
'mainmenu'];
711 $tabMenu[$b][
'leftmenu'] = $menu[
'leftmenu'];
712 $tabMenu[$b][
'perms'] = $perms;
713 $tabMenu[$b][
'langs'] = $menu[
'langs'];
714 $tabMenu[$b][
'enabled'] = $enabled;
715 $tabMenu[$b][
'type'] = $menu[
'type'];
716 $tabMenu[$b][
'fk_mainmenu'] = $menu[
'fk_mainmenu'];
717 $tabMenu[$b][
'fk_leftmenu'] = $menu[
'fk_leftmenu'];
718 $tabMenu[$b][
'position'] = (int) $menu[
'position'];
746 private function recur($tab, $pere, $level)
750 for ($x = 0; $x < $num; $x++)
753 if ((($tab[$x][
'fk_menu'] >= 0 && $tab[$x][
'fk_menu'] == $pere)) && $tab[$x][
'enabled'])
755 $this->newmenu->add($tab[$x][
'url'], $tab[$x][
'titre'], ($level - 1), $tab[$x][
'perms'], $tab[$x][
'target'], $tab[$x][
'mainmenu'], $tab[$x][
'leftmenu']);
756 $this->
recur($tab, $tab[$x][
'rowid'], ($level + 1));
verifCond($strRights)
Verify if condition in string is ok or not.
</td >< tdcolspan="3">< spanclass="opacitymedium"></span ></td ></tr >< trclass="liste_total"> CREANCES DETTES< tdcolspan="3"class="right"></td >< tdcolspan="3"class="right"></td ></tr > CREANCES DETTES RECETTES DEPENSES trips CREANCES DETTES Y m expensereport p date_valid Y m expensereport pe datep $db idate($date_start)."' AND $column < p rowid
$conf db
API class for accounts.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->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)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
make_substitutions($text, $substitutionarray, $outputlangs=null)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type