28require
'../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/treeview.lib.php';
33$langs->loadLangs(array(
"other",
"admin"));
39$dirstandard = array();
40$dirsmartphone = array();
41$dirmenus = array_merge(array(
"/core/menus/"), (array) $conf->modules_parts[
'menus']);
42foreach ($dirmenus as $dirmenu) {
43 $dirstandard[] = $dirmenu.
'standard';
44 $dirsmartphone[] = $dirmenu.
'smartphone';
47$action =
GETPOST(
'action',
'aZ09');
48$confirm =
GETPOST(
'confirm',
'alpha');
50$menu_handler_top = $conf->global->MAIN_MENU_STANDARD;
51$menu_handler_smartphone = $conf->global->MAIN_MENU_SMARTPHONE;
52$menu_handler_top = preg_replace(
'/(_backoffice\.php|_menu\.php)/i',
'', $menu_handler_top);
53$menu_handler_top = preg_replace(
'/(_frontoffice\.php|_menu\.php)/i',
'', $menu_handler_top);
54$menu_handler_smartphone = preg_replace(
'/(_backoffice\.php|_menu\.php)/i',
'', $menu_handler_smartphone);
55$menu_handler_smartphone = preg_replace(
'/(_frontoffice\.php|_menu\.php)/i',
'', $menu_handler_smartphone);
57$menu_handler = $menu_handler_top;
59if (
GETPOST(
"handler_origine")) {
60 $menu_handler =
GETPOST(
"handler_origine");
63 $menu_handler =
GETPOST(
"menu_handler");
66$menu_handler_to_search = preg_replace(
'/(_backoffice|_frontoffice|_menu)?(\.php)?/i',
'', $menu_handler);
78 $sql =
"SELECT m.rowid, m.position, m.type, m.fk_menu";
79 $sql .=
" FROM ".MAIN_DB_PREFIX.
"menu as m";
80 $sql .=
" WHERE m.rowid = ".GETPOST(
"menuId",
"int");
82 $result = $db->query($sql);
83 $num = $db->num_rows($result);
86 $obj = $db->fetch_object($result);
87 $current[
'rowid'] = $obj->rowid;
88 $current[
'order'] = $obj->position;
89 $current[
'type'] = $obj->type;
90 $current[
'fk_menu'] = $obj->fk_menu;
95 $sql =
"SELECT m.rowid, m.position";
96 $sql .=
" FROM ".MAIN_DB_PREFIX.
"menu as m";
97 $sql .=
" WHERE (m.position < ".($current[
'order']).
" OR (m.position = ".($current[
'order']).
" AND rowid < ".
GETPOST(
"menuId",
"int").
"))";
98 $sql .=
" AND m.menu_handler='".$db->escape($menu_handler_to_search).
"'";
99 $sql .=
" AND m.entity = ".$conf->entity;
100 $sql .=
" AND m.type = '".$db->escape($current[
'type']).
"'";
101 $sql .=
" AND m.fk_menu = '".$db->escape($current[
'fk_menu']).
"'";
102 $sql .=
" ORDER BY m.position, m.rowid";
104 $result = $db->query($sql);
105 $num = $db->num_rows($result);
108 $obj = $db->fetch_object($result);
109 $previous[
'rowid'] = $obj->rowid;
110 $previous[
'order'] = $obj->position;
114 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"menu as m";
115 $sql .=
" SET m.position = ".((int) $previous[
'order']);
116 $sql .=
" WHERE m.rowid = ".((int) $current[
'rowid']);
119 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"menu as m";
120 $sql .=
" SET m.position = ".((int) ($current[
'order'] != $previous[
'order'] ? $current[
'order'] : $current[
'order'] + 1));
121 $sql .=
" WHERE m.rowid = ".((int) $previous[
'rowid']);
124} elseif ($action ==
'down') {
129 $sql =
"SELECT m.rowid, m.position, m.type, m.fk_menu";
130 $sql .=
" FROM ".MAIN_DB_PREFIX.
"menu as m";
131 $sql .=
" WHERE m.rowid = ".GETPOST(
"menuId",
"int");
133 $result = $db->query($sql);
134 $num = $db->num_rows($result);
137 $obj = $db->fetch_object($result);
138 $current[
'rowid'] = $obj->rowid;
139 $current[
'order'] = $obj->position;
140 $current[
'type'] = $obj->type;
141 $current[
'fk_menu'] = $obj->fk_menu;
146 $sql =
"SELECT m.rowid, m.position";
147 $sql .=
" FROM ".MAIN_DB_PREFIX.
"menu as m";
148 $sql .=
" WHERE (m.position > ".($current[
'order']).
" OR (m.position = ".($current[
'order']).
" AND rowid > ".
GETPOST(
"menuId",
"int").
"))";
149 $sql .=
" AND m.menu_handler='".$db->escape($menu_handler_to_search).
"'";
150 $sql .=
" AND m.entity = ".$conf->entity;
151 $sql .=
" AND m.type = '".$db->escape($current[
'type']).
"'";
152 $sql .=
" AND m.fk_menu = '".$db->escape($current[
'fk_menu']).
"'";
153 $sql .=
" ORDER BY m.position, m.rowid";
155 $result = $db->query($sql);
156 $num = $db->num_rows($result);
159 $obj = $db->fetch_object($result);
160 $next[
'rowid'] = $obj->rowid;
161 $next[
'order'] = $obj->position;
165 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"menu as m";
166 $sql .=
" SET m.position = ".((int) ($current[
'order'] != $next[
'order'] ? $next[
'order'] : $current[
'order'] + 1));
167 $sql .=
" WHERE m.rowid = ".((int) $current[
'rowid']);
170 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"menu as m";
171 $sql .=
" SET m.position = ".((int) $current[
'order']);
172 $sql .=
" WHERE m.rowid = ".((int) $next[
'rowid']);
175} elseif ($action ==
'confirm_delete' && $confirm ==
'yes') {
178 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"menu";
179 $sql .=
" WHERE rowid = ".GETPOST(
'menuId',
'int');
180 $resql = $db->query($sql);
186 header(
"Location: ".DOL_URL_ROOT.
'/admin/menus/index.php?menu_handler='.$menu_handler);
201$form =
new Form($db);
204$arrayofjs = array(
'/includes/jquery/plugins/jquerytreeview/jquery.treeview.js',
'/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js');
205$arrayofcss = array(
'/includes/jquery/plugins/jquerytreeview/jquery.treeview.css');
207llxHeader(
'', $langs->trans(
"Menus"),
'',
'', 0, 0, $arrayofjs, $arrayofcss);
215$head[$h][0] = DOL_URL_ROOT.
"/admin/menus.php";
216$head[$h][1] = $langs->trans(
"MenuHandlers");
217$head[$h][2] =
'handler';
220$head[$h][0] = DOL_URL_ROOT.
"/admin/menus/index.php";
221$head[$h][1] = $langs->trans(
"MenuAdmin");
222$head[$h][2] =
'editor';
227print
'<span class="opacitymedium">'.$langs->trans(
"MenusEditorDesc").
"</span><br>\n";
232if ($action ==
'delete') {
233 $sql =
"SELECT m.titre as title";
234 $sql .=
" FROM ".MAIN_DB_PREFIX.
"menu as m";
235 $sql .=
" WHERE m.rowid = ".GETPOST(
'menuId',
'int');
236 $result = $db->query($sql);
237 $obj = $db->fetch_object($result);
239 print $form->formconfirm(
"index.php?menu_handler=".$menu_handler.
"&menuId=".
GETPOST(
'menuId',
'int'), $langs->trans(
"DeleteMenu"), $langs->trans(
"ConfirmDeleteMenu", $obj->title),
"confirm_delete");
244 $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']));
247print
'<form name="newmenu" class="nocellnopadd" action="'.$_SERVER[
"PHP_SELF"].
'">';
248print
'<input type="hidden" action="change_menu_handler">';
249print $langs->trans(
"MenuHandler").
': ';
250$formadmin->select_menu_families($menu_handler.(preg_match(
'/_menu/', $menu_handler) ?
'' :
'_menu'),
'menu_handler', array_merge($dirstandard, $dirsmartphone));
251print
' <input type="submit" class="button" value="'.$langs->trans(
"Refresh").
'">';
253print
'<div class="floatright">';
261print
'<table class="noborder centpercent">';
263print
'<tr class="liste_titre">';
264print
'<td>'.$langs->trans(
"TreeMenuPersonalized").
'</td>';
265print
'<td class="right"><div id="iddivjstreecontrol"><a href="#">'.img_picto(
'',
'folder',
'class="paddingright"').$langs->trans(
"UndoExpandAll").
'</a>';
266print
' | <a href="#">'.img_picto(
'',
'folder-open',
'class="paddingright"').$langs->trans(
"ExpandAll").
'</a></div></td>';
270print
'<td colspan="2">';
276if ($conf->use_javascript_ajax) {
290 $data[] = array(
'rowid'=>0,
'fk_menu'=>-1,
'title'=>
"racine",
'mainmenu'=>
'',
'leftmenu'=>
'',
'fk_mainmenu'=>
'',
'fk_leftmenu'=>
'');
294 $sql =
"SELECT m.rowid, m.titre, m.langs, m.mainmenu, m.leftmenu, m.fk_menu, m.fk_mainmenu, m.fk_leftmenu, m.position, m.module";
295 $sql .=
" FROM ".MAIN_DB_PREFIX.
"menu as m";
296 $sql .=
" WHERE menu_handler = '".$db->escape($menu_handler_to_search).
"'";
297 $sql .=
" AND entity = ".$conf->entity;
299 $sql .=
" ORDER BY m.position, m.rowid";
301 $res = $db->query($sql);
303 $num = $db->num_rows($res);
306 while ($menu = $db->fetch_array($res)) {
307 if (!empty($menu[
'langs'])) {
308 $langs->load($menu[
'langs']);
310 $titre = $langs->trans($menu[
'titre']);
312 $entry =
'<table class="nobordernopadding centpercent"><tr><td>';
313 $entry .=
'<strong> <a href="edit.php?menu_handler='.$menu_handler_to_search.
'&action=edit&token='.newToken().
'&menuId='.$menu[
'rowid'].
'">'.$titre.
'</a></strong>';
314 $entry .=
'</td><td class="right">';
315 $entry .=
'<a class="editfielda marginleftonly marginrightonly" href="edit.php?menu_handler='.$menu_handler_to_search.
'&action=edit&token='.newToken().
'&menuId='.$menu[
'rowid'].
'">'.
img_edit(
'default', 0,
'class="menuEdit" id="edit'.$menu[
'rowid'].
'"').
'</a> ';
316 $entry .=
'<a class="marginleftonly marginrightonly" href="edit.php?menu_handler='.$menu_handler_to_search.
'&action=create&token='.newToken().
'&menuId='.$menu[
'rowid'].
'">'.
img_edit_add(
'default').
'</a> ';
317 $entry .=
'<a class="marginleftonly marginrightonly" href="index.php?menu_handler='.$menu_handler_to_search.
'&action=delete&token='.newToken().
'&menuId='.$menu[
'rowid'].
'">'.
img_delete(
'default').
'</a> ';
319 $entry .=
'<a class="marginleftonly marginrightonly" href="index.php?menu_handler='.$menu_handler_to_search.
'&action=up&token='.newToken().
'&menuId='.$menu[
'rowid'].
'">'.
img_picto(
"Up",
"1uparrow").
'</a><a href="index.php?menu_handler='.$menu_handler_to_search.
'&action=down&menuId='.$menu[
'rowid'].
'">'.
img_picto(
"Down",
"1downarrow").
'</a>';
320 $entry .=
'</td></tr></table>';
322 $buttons =
'<a class="editfielda marginleftonly marginrightonly" href="edit.php?menu_handler='.$menu_handler_to_search.
'&action=edit&token='.newToken().
'&menuId='.$menu[
'rowid'].
'">'.
img_edit(
'default', 0,
'class="menuEdit" id="edit'.$menu[
'rowid'].
'"').
'</a> ';
323 $buttons .=
'<a class="marginleftonly marginrightonly" href="edit.php?menu_handler='.$menu_handler_to_search.
'&action=create&token='.newToken().
'&menuId='.$menu[
'rowid'].
'">'.
img_edit_add(
'default').
'</a> ';
324 $buttons .=
'<a class="marginleftonly marginrightonly" href="index.php?menu_handler='.$menu_handler_to_search.
'&action=delete&token='.newToken().
'&menuId='.$menu[
'rowid'].
'">'.
img_delete(
'default').
'</a> ';
325 $buttons .=
' ';
326 $buttons .=
'<a class="marginleftonly marginrightonly" href="index.php?menu_handler='.$menu_handler_to_search.
'&action=up&token='.newToken().
'&menuId='.$menu[
'rowid'].
'">'.
img_picto(
"Up",
"1uparrow").
'</a><a href="index.php?menu_handler='.$menu_handler_to_search.
'&action=down&menuId='.$menu[
'rowid'].
'">'.
img_picto(
"Down",
"1downarrow").
'</a>';
329 'rowid'=>$menu[
'rowid'],
330 'module'=>$menu[
'module'],
331 'fk_menu'=>$menu[
'fk_menu'],
333 'mainmenu'=>$menu[
'mainmenu'],
334 'leftmenu'=>$menu[
'leftmenu'],
335 'fk_mainmenu'=>$menu[
'fk_mainmenu'],
336 'fk_leftmenu'=>$menu[
'fk_leftmenu'],
337 'position'=>$menu[
'position'],
345 global $tree_recur_alreadyadded;
351 tree_recur($data, $data[0], 0,
'iddivjstree', 0, 0);
362 $remainingdata = array();
363 foreach ($data as $datar) {
364 if (empty($datar[
'rowid']) || !empty($tree_recur_alreadyadded[$datar[
'rowid']])) {
367 $remainingdata[] = $datar;
370 if (count($remainingdata)) {
371 print
'<table class="noborder centpercent">';
373 print
'<tr class="liste_titre">';
374 print
'<td>'.$langs->trans(
"NotTopTreeMenuPersonalized").
'</td>';
375 print
'<td class="right"></td>';
379 print
'<td colspan="2">';
380 foreach ($remainingdata as $datar) {
381 $father = array(
'rowid'=>$datar[
'rowid'],
'title'=>
"???",
'mainmenu'=>$datar[
'fk_mainmenu'],
'leftmenu'=>$datar[
'fk_leftmenu'],
'fk_mainmenu'=>
'',
'fk_leftmenu'=>
'');
383 tree_recur($data, $father, 0,
'iddivjstree'.$datar[
'rowid'], 1, 1);
395 $langs->load(
"errors");
396 setEventMessages($langs->trans(
"ErrorFeatureNeedJavascript"),
null,
'errors');
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
img_edit_add($titlealt='default', $other='')
Show logo +.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
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.