dolibarr 25.0.0-alpha
index.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
3 * Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2009-2012 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2019-2025 Frédéric France <frederic.france@free.fr>
6 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
28// Load Dolibarr environment
29require '../../main.inc.php';
37require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
38require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
39require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php';
40
41// Load translation files required by the page
42$langs->loadLangs(array("other", "admin"));
43
44$dirstandard = array();
45$dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']);
46foreach ($dirmenus as $dirmenu) {
47 $dirstandard[] = $dirmenu.'standard';
48}
49
50$action = GETPOST('action', 'aZ09');
51$confirm = GETPOST('confirm', 'alpha');
52
53//$menu_handler_top = getDolGlobalString('MAIN_MENU_STANDARD');
54$menu_handler_top = 'all';
55$menu_handler_top = preg_replace('/(_backoffice\.php|_menu\.php)/i', '', $menu_handler_top);
56$menu_handler_top = preg_replace('/(_frontoffice\.php|_menu\.php)/i', '', $menu_handler_top);
57
58$menu_handler = $menu_handler_top;
59
60if (GETPOST("handler_origine")) {
61 $menu_handler = GETPOST("handler_origine");
62}
63if (GETPOST("menu_handler")) {
64 $menu_handler = GETPOST("menu_handler");
65}
66
67$menu_handler_to_search = preg_replace('/(_backoffice|_frontoffice|_menu)?(\.php)?/i', '', $menu_handler);
68
69if (empty($user->admin)) {
71}
72
73
74/*
75 * Actions
76 */
77
78// Build the SQL filter to get the siblings (same parent) of the entry to move, with same rules than tree_recur()
79$sqlsiblings = '';
80if ($action == 'up' || $action == 'down') {
81 $sql = "SELECT m.fk_menu, m.fk_mainmenu, m.fk_leftmenu, p.mainmenu as parent_mainmenu, p.leftmenu as parent_leftmenu, p.type as parent_type";
82 $sql .= " FROM ".MAIN_DB_PREFIX."menu as m";
83 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."menu as p ON p.rowid = m.fk_menu";
84 $sql .= " WHERE m.rowid = ".GETPOSTINT("menuId");
85 $sql .= " AND m.entity = ".((int) $conf->entity);
86 $resql = $db->query($sql);
87 $obj = ($resql ? $db->fetch_object($resql) : null);
88 if ($obj) {
89 if ((int) $obj->fk_menu == -1) {
90 // Parent is defined by its mainmenu/leftmenu codes
91 $parentmainmenu = (string) $obj->fk_mainmenu;
92 $parentleftmenu = (string) $obj->fk_leftmenu;
93 $sqlsiblings = "m.fk_menu IN (SELECT p.rowid FROM ".MAIN_DB_PREFIX."menu as p";
94 $sqlsiblings .= " WHERE p.menu_handler = '".$db->escape($menu_handler_to_search)."' AND p.entity = ".((int) $conf->entity);
95 $sqlsiblings .= " AND p.mainmenu = '".$db->escape($parentmainmenu)."'";
96 $sqlsiblings .= " AND ".($parentleftmenu == '' ? "p.type = 'top' AND (p.leftmenu IS NULL OR p.leftmenu = '')" : "p.leftmenu = '".$db->escape($parentleftmenu)."'").")";
97 } else {
98 // Parent is defined by its id
99 $parentmainmenu = (string) $obj->parent_mainmenu;
100 $parentleftmenu = (string) $obj->parent_leftmenu;
101 $sqlsiblings = "m.fk_menu = ".((int) $obj->fk_menu);
102 }
103 // A left menu entry with an empty leftmenu code can't be the parent of entries linked by code
104 if ((int) $obj->fk_menu != 0 && $parentmainmenu != '' && ((int) $obj->fk_menu == -1 || $parentleftmenu != '' || $obj->parent_type == 'top')) {
105 $sqlsiblings .= " OR (m.fk_menu = -1 AND m.fk_mainmenu = '".$db->escape($parentmainmenu)."'";
106 $sqlsiblings .= " AND ".($parentleftmenu == '' ? "(m.fk_leftmenu IS NULL OR m.fk_leftmenu = '')" : "m.fk_leftmenu = '".$db->escape($parentleftmenu)."'").")";
107 }
108 }
109}
110
111if ($action == 'up') {
112 $current = array();
113 $previous = array();
114
115 // Get current position
116 $sql = "SELECT m.rowid, m.position, m.type, m.fk_menu";
117 $sql .= " FROM ".MAIN_DB_PREFIX."menu as m";
118 $sql .= " WHERE m.rowid = ".GETPOSTINT("menuId");
119 $sql .= " AND m.entity = ".((int) $conf->entity);
120 dol_syslog("admin/menus/index.php ".$sql);
121 $result = $db->query($sql);
122 $num = $db->num_rows($result);
123 $i = 0;
124 while ($i < $num) {
125 $obj = $db->fetch_object($result);
126 $current['rowid'] = (int) $obj->rowid;
127 $current['order'] = (int) $obj->position;
128 $current['type'] = (string) $obj->type;
129 $current['fk_menu'] = (int) $obj->fk_menu;
130 $i++;
131 }
132
133 // Menu before (only the closest one)
134 if (!empty($current) && $sqlsiblings) {
135 $sql = "SELECT m.rowid, m.position";
136 $sql .= " FROM ".MAIN_DB_PREFIX."menu as m";
137 $sql .= " WHERE (m.position < ".((int) $current['order'])." OR (m.position = ".((int) $current['order'])." AND rowid < ".((int) $current['rowid'])."))";
138 $sql .= " AND m.menu_handler='".$db->escape($menu_handler_to_search)."'";
139 $sql .= " AND m.entity = ".((int) $conf->entity);
140 $sql .= " AND m.type = '".$db->escape($current['type'])."'";
141 $sql .= " AND (".$sqlsiblings.")";
142 $sql .= " ORDER BY m.position DESC, m.rowid DESC";
143 $sql .= $db->plimit(1);
144 dol_syslog("admin/menus/index.php ".$sql);
145 $result = $db->query($sql);
146 $num = $db->num_rows($result);
147 $i = 0;
148 while ($i < $num) {
149 $obj = $db->fetch_object($result);
150 $previous['rowid'] = (int) $obj->rowid;
151 $previous['order'] = (int) $obj->position;
152 $i++;
153 }
154 }
155
156 // Swap positions only if there is an entry before (nothing to do for the first entry)
157 if (!empty($current) && !empty($previous)) {
158 $error = 0;
159 $db->begin();
160
161 $sql = "UPDATE ".MAIN_DB_PREFIX."menu as m";
162 $sql .= " SET m.position = ".((int) $previous['order']);
163 $sql .= " WHERE m.rowid = ".((int) $current['rowid']); // Up the selected entry
164 dol_syslog("admin/menus/index.php ".$sql);
165 if (!$db->query($sql)) {
166 $error++;
167 }
168 $sql = "UPDATE ".MAIN_DB_PREFIX."menu as m";
169 $sql .= " SET m.position = ".((int) ($current['order'] != $previous['order'] ? $current['order'] : $current['order'] + 1));
170 $sql .= " WHERE m.rowid = ".((int) $previous['rowid']); // Descend celui du dessus
171 dol_syslog("admin/menus/index.php ".$sql);
172 if (!$error && !$db->query($sql)) {
173 $error++;
174 }
175
176 if ($error) {
177 $db->rollback();
178 setEventMessages($db->lasterror(), null, 'errors');
179 } else {
180 $db->commit();
181 }
182 }
183} elseif ($action == 'down') {
184 $current = array();
185 $next = array();
186
187 // Get current position
188 $sql = "SELECT m.rowid, m.position, m.type, m.fk_menu";
189 $sql .= " FROM ".MAIN_DB_PREFIX."menu as m";
190 $sql .= " WHERE m.rowid = ".GETPOSTINT("menuId");
191 $sql .= " AND m.entity = ".((int) $conf->entity);
192 dol_syslog("admin/menus/index.php ".$sql);
193 $result = $db->query($sql);
194 $num = $db->num_rows($result);
195 $i = 0;
196 while ($i < $num) {
197 $obj = $db->fetch_object($result);
198 $current['rowid'] = (int) $obj->rowid;
199 $current['order'] = (int) $obj->position;
200 $current['type'] = (string) $obj->type;
201 $current['fk_menu'] = (int) $obj->fk_menu;
202 $i++;
203 }
204
205 // Menu after (only the closest one)
206 if (!empty($current) && $sqlsiblings) {
207 $sql = "SELECT m.rowid, m.position";
208 $sql .= " FROM ".MAIN_DB_PREFIX."menu as m";
209 $sql .= " WHERE (m.position > ".((int) $current['order'])." OR (m.position = ".((int) $current['order'])." AND rowid > ".((int) $current['rowid'])."))";
210 $sql .= " AND m.menu_handler='".$db->escape($menu_handler_to_search)."'";
211 $sql .= " AND m.entity = ".((int) $conf->entity);
212 $sql .= " AND m.type = '".$db->escape($current['type'])."'";
213 $sql .= " AND (".$sqlsiblings.")";
214 $sql .= " ORDER BY m.position, m.rowid";
215 $sql .= $db->plimit(1);
216 dol_syslog("admin/menus/index.php ".$sql);
217 $result = $db->query($sql);
218 $num = $db->num_rows($result);
219 $i = 0;
220 while ($i < $num) {
221 $obj = $db->fetch_object($result);
222 $next['rowid'] = (int) $obj->rowid;
223 $next['order'] = (int) $obj->position;
224 $i++;
225 }
226 }
227
228 // Swap positions only if there is an entry after (nothing to do for the last entry)
229 if (!empty($current) && !empty($next)) {
230 $error = 0;
231 $db->begin();
232
233 $sql = "UPDATE ".MAIN_DB_PREFIX."menu as m";
234 $sql .= " SET m.position = ".((int) ($current['order'] != $next['order'] ? $next['order'] : $current['order'] + 1)); // Down the selected entry
235 $sql .= " WHERE m.rowid = ".((int) $current['rowid']);
236 dol_syslog("admin/menus/index.php ".$sql);
237 if (!$db->query($sql)) {
238 $error++;
239 }
240 $sql = "UPDATE ".MAIN_DB_PREFIX."menu as m"; // Up the next entry
241 $sql .= " SET m.position = ".((int) $current['order']);
242 $sql .= " WHERE m.rowid = ".((int) $next['rowid']);
243 dol_syslog("admin/menus/index.php ".$sql);
244 if (!$error && !$db->query($sql)) {
245 $error++;
246 }
247
248 if ($error) {
249 $db->rollback();
250 setEventMessages($db->lasterror(), null, 'errors');
251 } else {
252 $db->commit();
253 }
254 }
255} elseif ($action == 'confirm_delete' && $confirm == 'yes') {
256 $menutodelete = new Menubase($db);
257 $menutodelete->fetch(GETPOSTINT('menuId'));
258
259 if (empty($menutodelete->id) || (int) $menutodelete->entity != (int) $conf->entity) {
260 $langs->load("errors");
261 setEventMessages($langs->trans("ErrorRecordNotFound"), null, 'errors');
262 $action = '';
263 } else {
264 // Count children, linked by fk_menu or by fk_mainmenu/fk_leftmenu (same rules than tree_recur())
265 $sql = "SELECT COUNT(m.rowid) as nb";
266 $sql .= " FROM ".MAIN_DB_PREFIX."menu as m";
267 $sql .= " WHERE m.entity = ".((int) $conf->entity);
268 $sql .= " AND m.menu_handler = '".$db->escape($menutodelete->menu_handler)."'";
269 $sql .= " AND (m.fk_menu = ".((int) $menutodelete->id);
270 if (!empty($menutodelete->mainmenu) && ($menutodelete->type == 'top' || !empty($menutodelete->leftmenu))) {
271 $sql .= " OR (m.fk_menu = -1 AND m.fk_mainmenu = '".$db->escape($menutodelete->mainmenu)."'";
272 if ($menutodelete->type == 'top') {
273 $sql .= " AND (m.fk_leftmenu IS NULL OR m.fk_leftmenu = '')";
274 } else {
275 $sql .= " AND m.fk_leftmenu = '".$db->escape($menutodelete->leftmenu)."'";
276 }
277 $sql .= ")";
278 }
279 $sql .= ")";
280 $nbchildren = -1;
281 $resql = $db->query($sql);
282 if ($resql) {
283 $obj = $db->fetch_object($resql);
284 $nbchildren = (int) $obj->nb;
285 }
286
287 if ($nbchildren < 0) {
288 setEventMessages($db->lasterror(), null, 'errors');
289 $action = '';
290 } elseif ($nbchildren > 0) {
291 $langs->load("errors");
292 setEventMessages($langs->trans("ErrorRecordHasChildren"), null, 'errors');
293 $action = '';
294 } else {
295 $db->begin();
296
297 $result = $menutodelete->delete($user);
298 if ($result > 0) {
299 $db->commit();
300
301 setEventMessages($langs->trans("MenuDeleted"), null, 'mesgs');
302
303 header("Location: ".DOL_URL_ROOT.'/admin/menus/index.php?menu_handler='.urlencode($menu_handler));
304 exit;
305 } else {
306 $db->rollback();
307 setEventMessages($menutodelete->error, $menutodelete->errors, 'errors');
308
309 $reload = 0;
310 $action = '';
311 }
312 }
313 }
314}
315
316
317/*
318 * View
319 */
320
321$form = new Form($db);
322$formadmin = new FormAdmin($db);
323
324$arrayofjs = array('/public/includes/jquery/plugins/jquerytreeview/jquery.treeview.js', '/public/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js');
325$arrayofcss = array('/public/includes/jquery/plugins/jquerytreeview/jquery.treeview.css');
326
327llxHeader('', $langs->trans("Menus"), '', '', 0, 0, $arrayofjs, $arrayofcss, '', 'mod-admin page-menus_index');
328
329
330print load_fiche_titre($langs->trans("Menus"), '', 'title_setup');
331
332
333$h = 0;
334$head = array();
335
336$head[$h][0] = DOL_URL_ROOT."/admin/menus.php";
337$head[$h][1] = $langs->trans("MenuHandlers");
338$head[$h][2] = 'handler';
339$h++;
340
341$head[$h][0] = DOL_URL_ROOT."/admin/menus/index.php";
342$head[$h][1] = $langs->trans("MenuAdmin");
343$head[$h][2] = 'editor';
344$h++;
345
346print dol_get_fiche_head($head, 'editor', '', -1);
347
348print '<div class="info hideonsmartphone">'.$langs->trans("MenusEditorDesc")."</div>\n";
349print "<br>\n";
350
351
352// Confirmation for remove menu entry
353if ($action == 'delete') {
354 $sql = "SELECT m.titre as title";
355 $sql .= " FROM ".MAIN_DB_PREFIX."menu as m";
356 $sql .= " WHERE m.rowid = ".GETPOSTINT('menuId');
357 $sql .= " AND m.entity = ".((int) $conf->entity);
358 $result = $db->query($sql);
359 $obj = ($result ? $db->fetch_object($result) : null);
360
361 if ($obj) {
362 print $form->formconfirm("index.php?menu_handler=".urlencode($menu_handler)."&menuId=".GETPOSTINT('menuId'), $langs->transnoentitiesnoconv("DeleteMenu"), $langs->transnoentitiesnoconv("ConfirmDeleteMenu", $obj->title), "confirm_delete");
363 } else {
364 $langs->load("errors");
365 setEventMessages($langs->trans("ErrorRecordNotFound"), null, 'errors');
366 }
367}
368
369$newcardbutton = '';
370if ($user->admin) {
371 $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/admin/menus/edit.php?menuId=0&action=create&menu_handler='.urlencode($menu_handler).'&backtopage='.urlencode($_SERVER['PHP_SELF']));
372}
373
374print '<form name="newmenu" class="nocellnopadd" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'" spellcheck="false">';
375print '<input type="hidden" action="change_menu_handler">';
376print $langs->trans("MenuHandler").': ';
377$formadmin->select_menu_families($menu_handler.(preg_match('/_menu/', $menu_handler) ? '' : '_menu'), 'menu_handler', $dirstandard);
378print ' &nbsp; <input type="submit" class="button small" value="'.$langs->trans("Refresh").'">';
379
380print '<div class="floatright">';
381print $newcardbutton;
382print '</div>';
383
384print '</form>';
385
386print '<br>';
387
388
389// MENU TREE
390
391
392/*-------------------- MAIN -----------------------
393Array of the menu tree:
394- Is an array in with 2 dimensions.
395- A single line represents an item : data[$x]
396- Each line has 3 data items:
397 - The index of the item;
398 - The index of the item's parent;
399 - The string to show
400i.e.: data[]= array (index, parent index, string )
401*/
402
403// First the root item of the tree must be declared:
404
405$data = array();
406$data[] = array('rowid' => 0, 'fk_menu' => -1, 'title' => 'racine', 'mainmenu' => '', 'leftmenu' => '', 'fk_mainmenu' => '', 'fk_leftmenu' => '');
407
408// Then all child items must be declared
409
410$sql = "SELECT m.rowid, m.titre, m.langs, m.type, m.mainmenu, m.leftmenu, m.fk_menu, m.fk_mainmenu, m.fk_leftmenu, m.position, m.module";
411$sql .= " FROM ".MAIN_DB_PREFIX."menu as m";
412$sql .= " WHERE menu_handler = '".$db->escape($menu_handler_to_search)."'";
413$sql .= " AND entity = ".((int) $conf->entity);
414//$sql.= " AND fk_menu >= 0";
415$sql .= " ORDER BY m.position, m.rowid"; // Order is position then rowid (because we need a sort criteria when position is same)
416
417$res = $db->query($sql);
418if ($res) {
419 $num = $db->num_rows($res);
420
421 $i = 1;
422 while ($menu = $db->fetch_array($res)) {
423 if (!empty($menu['langs'])) {
424 $langs->load($menu['langs']);
425 }
426 $titre = $langs->transnoentitiesnoconv($menu['titre']);
427
428 $entry = '<table class="nobordernopadding centpercent"><tr><td class="tdoverflowmax200">';
429 $entry .= '<strong class="paddingleft"><a href="edit.php?menu_handler='.urlencode($menu_handler_to_search).'&action=edit&token='.newToken().'&menuId='.$menu['rowid'].'">'.dolPrintHTML($titre).'</a></strong>';
430 $entry .= '</td>';
431 $entry .= '<td class="right nowraponall">';
432 $entry .= '<a class="editfielda marginleftonly marginrightonly" href="edit.php?menu_handler='.urlencode($menu_handler_to_search).'&action=edit&token='.newToken().'&menuId='.$menu['rowid'].'">'.img_edit('default', 0, 'class="menuEdit" id="edit'.$menu['rowid'].'"').'</a> ';
433 $entry .= '<a class="marginleftonly marginrightonly" href="edit.php?menu_handler='.urlencode($menu_handler_to_search).'&action=create&token='.newToken().'&menuId='.$menu['rowid'].'">'.img_edit_add('default').'</a> ';
434 $entry .= '<a class="marginleftonly marginrightonly" href="index.php?menu_handler='.urlencode($menu_handler_to_search).'&action=delete&token='.newToken().'&menuId='.$menu['rowid'].'">'.img_delete('default').'</a> ';
435 $entry .= '&nbsp; ';
436 $entry .= '<a class="marginleftonly marginrightonly reposition" href="index.php?menu_handler='.urlencode($menu_handler_to_search).'&action=up&token='.newToken().'&menuId='.$menu['rowid'].'">'.img_picto("Up", "1uparrow").'</a><a class="reposition" href="index.php?menu_handler='.urlencode($menu_handler_to_search).'&action=down&token='.newToken().'&menuId='.$menu['rowid'].'">'.img_picto("Down", "1downarrow").'</a>';
437 $entry .= '</td></tr></table>';
438
439 $buttons = '<a class="editfielda marginleftonly marginrightonly" href="edit.php?menu_handler='.urlencode($menu_handler_to_search).'&action=edit&token='.newToken().'&menuId='.$menu['rowid'].'">'.img_edit('default', 0, 'class="menuEdit" id="edit'.$menu['rowid'].'"').'</a> ';
440 $buttons .= '<a class="marginleftonly marginrightonly" href="edit.php?menu_handler='.urlencode($menu_handler_to_search).'&action=create&token='.newToken().'&menuId='.$menu['rowid'].'">'.img_edit_add('default').'</a> ';
441 $buttons .= '<a class="marginleftonly marginrightonly" href="index.php?menu_handler='.urlencode($menu_handler_to_search).'&action=delete&token='.newToken().'&menuId='.$menu['rowid'].'">'.img_delete('default').'</a> ';
442 $buttons .= '&nbsp; ';
443 $buttons .= '<a class="marginleftonly marginrightonly reposition" href="index.php?menu_handler='.urlencode($menu_handler_to_search).'&action=up&token='.newToken().'&menuId='.$menu['rowid'].'">'.img_picto("Up", "1uparrow").'</a><a class="reposition" href="index.php?menu_handler='.urlencode($menu_handler_to_search).'&action=down&token='.newToken().'&menuId='.$menu['rowid'].'">'.img_picto("Down", "1downarrow").'</a>';
444
445 $data[] = array(
446 'rowid' => (int) $menu['rowid'],
447 'module' => (string) $menu['module'],
448 'fk_menu' => (int) $menu['fk_menu'],
449 'title' => (string) $titre,
450 'mainmenu' => (string) $menu['mainmenu'],
451 'leftmenu' => (string) $menu['leftmenu'],
452 'fk_mainmenu' => (string) $menu['fk_mainmenu'],
453 'fk_leftmenu' => (string) $menu['fk_leftmenu'],
454 'type' => (string) $menu['type'],
455 'position' => (int) $menu['position'],
456 'entry' => $entry,
457 'buttons' => $buttons
458 );
459 $i++;
460 }
461}
462
463global $tree_recur_alreadyadded; // This var was def into tree_recur
464
465//var_dump($data);
466
467print '<div class="div-table-responsive">';
468print '<table class="noborder centpercent">';
469
470print '<tr class="liste_titre">';
471print '<td>'.$langs->trans("TreeMenuPersonalized").'</td>';
472print '<td class="right"><div id="iddivjstreecontrol"><a href="#">'.img_picto($langs->trans("UndoExpandAll"), 'folder', 'class="paddingright"').'</a>';
473print ' | <a href="#">'.img_picto($langs->trans("ExpandAll"), 'folder-open', 'class="paddingright"').'</a></div></td>';
474print '</tr>';
475
476print '<tr>';
477print '<td colspan="2">';
478
479
480//tree_recur($data, $data[0], 0, 'iddivjstree', 0, 1); // use this to get info on name and foreign keys of menu entry
481tree_recur($data, $data[0], 0, 'iddivjstree', 0, 0); // $data[0] is virtual record 'racine'
482
483
484print '</td>';
485print '</tr>';
486
487print '</table>';
488print '</div>';
489
490// Process remaining records (records that are not linked to root by any path)
491$remainingdata = array();
492foreach ($data as $datar) {
493 if (empty($datar['rowid']) || !empty($tree_recur_alreadyadded[$datar['rowid']])) {
494 continue;
495 }
496 $remainingdata[] = $datar;
497}
498
499if (count($remainingdata)) {
500 print '<div class="div-table-responsive">';
501 print '<table class="noborder centpercent">';
502
503 print '<tr class="liste_titre">';
504 print '<td>'.$langs->trans("NotTopTreeMenuPersonalized").'</td>';
505 print '<td class="right"></td>';
506 print '</tr>';
507
508 print '<tr>';
509 print '<td colspan="2">';
510 // Index of existing records, to know if a remaining record has a parent that is a known record
511 $recordsbyid = array();
512 $recordsbycode = array();
513 foreach ($data as $datar) {
514 if (!empty($datar['rowid'])) {
515 $recordsbyid[$datar['rowid']] = 1;
516 if ($datar['leftmenu'] != '') {
517 $recordsbycode[$datar['mainmenu'].'|'.$datar['leftmenu']] = 1;
518 }
519 }
520 }
521
522 // Pass 1 starts a block only for records with no known parent, so children are shown nested under their parent.
523 // Pass 2 shows records not yet output (for example records in a loop of parents).
524 for ($pass = 1; $pass <= 2; $pass++) {
525 foreach ($remainingdata as $datar) {
526 if (!empty($tree_recur_alreadyadded[$datar['rowid']])) {
527 continue;
528 }
529 if ($pass == 1 && (($datar['fk_menu'] > 0 && !empty($recordsbyid[$datar['fk_menu']])) || ($datar['fk_menu'] == -1 && !empty($recordsbycode[$datar['fk_mainmenu'].'|'.$datar['fk_leftmenu']])))) {
530 continue;
531 }
532 $father = array('rowid' => $datar['rowid'], 'title' => "???", 'mainmenu' => $datar['fk_mainmenu'], 'leftmenu' => $datar['fk_leftmenu'], 'fk_mainmenu' => '', 'fk_leftmenu' => '');
533 //print 'Start with rowid='.$datar['rowid'].' mainmenu='.$father ['mainmenu'].' leftmenu='.$father ['leftmenu'].'<br>'."\n";
534 tree_recur($data, $father, 0, 'iddivjstree'.$datar['rowid'], 1, 1);
535 }
536 }
537
538 print '</td>';
539
540 print '</tr>';
541
542 print '</table>';
543 print '</div>';
544}
545
546print '<br>';
547
548// End of page
549llxFooter();
550$db->close();
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to generate html code for admin pages.
Class to manage generation of HTML components Only common components must be here.
Class to manage menu entries.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
Definition html.lib.php:542
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
tree_recur($tab, $pere, $rang, $iddivjstree='iddivjstree', $donoresetalreadyloaded=0, $showfk=0, $moreparam='')
Recursive function to output a tree.