29require
'../../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/treeview.lib.php';
42$langs->loadLangs(array(
"other",
"admin"));
44$dirstandard = array();
45$dirsmartphone = array();
46$dirmenus = array_merge(array(
"/core/menus/"), (array)
$conf->modules_parts[
'menus']);
47foreach ($dirmenus as $dirmenu) {
48 $dirstandard[] = $dirmenu.
'standard';
49 $dirsmartphone[] = $dirmenu.
'smartphone';
52$action =
GETPOST(
'action',
'aZ09');
53$confirm =
GETPOST(
'confirm',
'alpha');
56$menu_handler_top =
'all';
57$menu_handler_top = preg_replace(
'/(_backoffice\.php|_menu\.php)/i',
'', $menu_handler_top);
58$menu_handler_top = preg_replace(
'/(_frontoffice\.php|_menu\.php)/i',
'', $menu_handler_top);
60$menu_handler = $menu_handler_top;
62if (
GETPOST(
"handler_origine")) {
63 $menu_handler =
GETPOST(
"handler_origine");
66 $menu_handler =
GETPOST(
"menu_handler");
69$menu_handler_to_search = preg_replace(
'/(_backoffice|_frontoffice|_menu)?(\.php)?/i',
'', $menu_handler);
71if (empty($user->admin)) {
85 $sql =
"SELECT m.rowid, m.position, m.type, m.fk_menu";
86 $sql .=
" FROM ".MAIN_DB_PREFIX.
"menu as m";
87 $sql .=
" WHERE m.rowid = ".GETPOSTINT(
"menuId");
89 $result = $db->query($sql);
90 $num = $db->num_rows($result);
93 $obj = $db->fetch_object($result);
94 $current[
'rowid'] = (int) $obj->rowid;
95 $current[
'order'] = (int) $obj->position;
96 $current[
'type'] = (string) $obj->type;
97 $current[
'fk_menu'] = (int) $obj->fk_menu;
102 $sql =
"SELECT m.rowid, m.position";
103 $sql .=
" FROM ".MAIN_DB_PREFIX.
"menu as m";
104 $sql .=
" WHERE (m.position < ".($current[
'order']).
" OR (m.position = ".($current[
'order']).
" AND rowid < ".
GETPOSTINT(
"menuId").
"))";
105 $sql .=
" AND m.menu_handler='".$db->escape($menu_handler_to_search).
"'";
106 $sql .=
" AND m.entity = ".$conf->entity;
107 $sql .=
" AND m.type = '".$db->escape($current[
'type']).
"'";
108 $sql .=
" AND m.fk_menu = '".$db->escape($current[
'fk_menu']).
"'";
109 $sql .=
" ORDER BY m.position, m.rowid";
111 $result = $db->query($sql);
112 $num = $db->num_rows($result);
115 $obj = $db->fetch_object($result);
116 $previous[
'rowid'] = (int) $obj->rowid;
117 $previous[
'order'] = (int) $obj->position;
121 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"menu as m";
122 $sql .=
" SET m.position = ".((int) $previous[
'order']);
123 $sql .=
" WHERE m.rowid = ".((int) $current[
'rowid']);
126 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"menu as m";
127 $sql .=
" SET m.position = ".((int) ($current[
'order'] != $previous[
'order'] ? $current[
'order'] : $current[
'order'] + 1));
128 $sql .=
" WHERE m.rowid = ".((int) $previous[
'rowid']);
131} elseif ($action ==
'down') {
136 $sql =
"SELECT m.rowid, m.position, m.type, m.fk_menu";
137 $sql .=
" FROM ".MAIN_DB_PREFIX.
"menu as m";
138 $sql .=
" WHERE m.rowid = ".GETPOSTINT(
"menuId");
140 $result = $db->query($sql);
141 $num = $db->num_rows($result);
144 $obj = $db->fetch_object($result);
145 $current[
'rowid'] = (int) $obj->rowid;
146 $current[
'order'] = (int) $obj->position;
147 $current[
'type'] = (string) $obj->type;
148 $current[
'fk_menu'] = (int) $obj->fk_menu;
153 $sql =
"SELECT m.rowid, m.position";
154 $sql .=
" FROM ".MAIN_DB_PREFIX.
"menu as m";
155 $sql .=
" WHERE (m.position > ".($current[
'order']).
" OR (m.position = ".($current[
'order']).
" AND rowid > ".
GETPOSTINT(
"menuId").
"))";
156 $sql .=
" AND m.menu_handler='".$db->escape($menu_handler_to_search).
"'";
157 $sql .=
" AND m.entity = ".$conf->entity;
158 $sql .=
" AND m.type = '".$db->escape($current[
'type']).
"'";
159 $sql .=
" AND m.fk_menu = '".$db->escape($current[
'fk_menu']).
"'";
160 $sql .=
" ORDER BY m.position, m.rowid";
162 $result = $db->query($sql);
163 $num = $db->num_rows($result);
166 $obj = $db->fetch_object($result);
167 $next[
'rowid'] = (int) $obj->rowid;
168 $next[
'order'] = (int) $obj->position;
172 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"menu as m";
173 $sql .=
" SET m.position = ".((int) ($current[
'order'] != $next[
'order'] ? $next[
'order'] : $current[
'order'] + 1));
174 $sql .=
" WHERE m.rowid = ".((int) $current[
'rowid']);
177 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"menu as m";
178 $sql .=
" SET m.position = ".((int) $current[
'order']);
179 $sql .=
" WHERE m.rowid = ".((int) $next[
'rowid']);
182} elseif ($action ==
'confirm_delete' && $confirm ==
'yes') {
185 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"menu";
186 $sql .=
" WHERE rowid = ".GETPOSTINT(
'menuId');
187 $resql = $db->query($sql);
193 header(
"Location: ".DOL_URL_ROOT.
'/admin/menus/index.php?menu_handler='.$menu_handler);
208$form =
new Form($db);
211$arrayofjs = array(
'/includes/jquery/plugins/jquerytreeview/jquery.treeview.js',
'/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js');
212$arrayofcss = array(
'/includes/jquery/plugins/jquerytreeview/jquery.treeview.css');
214llxHeader(
'', $langs->trans(
"Menus"),
'',
'', 0, 0, $arrayofjs, $arrayofcss,
'',
'mod-admin page-menus_index');
223$head[$h][0] = DOL_URL_ROOT.
"/admin/menus.php";
224$head[$h][1] = $langs->trans(
"MenuHandlers");
225$head[$h][2] =
'handler';
228$head[$h][0] = DOL_URL_ROOT.
"/admin/menus/index.php";
229$head[$h][1] = $langs->trans(
"MenuAdmin");
230$head[$h][2] =
'editor';
235print
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"MenusEditorDesc").
"</span>";
236print
'<br class="hideonsmartphone">'.
"\n";
241if ($action ==
'delete') {
242 $sql =
"SELECT m.titre as title";
243 $sql .=
" FROM ".MAIN_DB_PREFIX.
"menu as m";
244 $sql .=
" WHERE m.rowid = ".GETPOSTINT(
'menuId');
245 $result = $db->query($sql);
246 $obj = $db->fetch_object($result);
248 print $form->formconfirm(
"index.php?menu_handler=".$menu_handler.
"&menuId=".
GETPOSTINT(
'menuId'), $langs->trans(
"DeleteMenu"), $langs->trans(
"ConfirmDeleteMenu", $obj->title),
"confirm_delete");
253 $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']));
256print
'<form name="newmenu" class="nocellnopadd" action="'.$_SERVER[
"PHP_SELF"].
'">';
257print
'<input type="hidden" action="change_menu_handler">';
258print $langs->trans(
"MenuHandler").
': ';
259$formadmin->select_menu_families($menu_handler.(preg_match(
'/_menu/', $menu_handler) ?
'' :
'_menu'),
'menu_handler', array_merge($dirstandard, $dirsmartphone));
260print
' <input type="submit" class="button small" value="'.$langs->trans(
"Refresh").
'">';
262print
'<div class="floatright">';
288$data[] = array(
'rowid' => 0,
'fk_menu' => -1,
'title' =>
'racine',
'mainmenu' =>
'',
'leftmenu' =>
'',
'fk_mainmenu' =>
'',
'fk_leftmenu' =>
'');
292$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";
293$sql .=
" FROM ".MAIN_DB_PREFIX.
"menu as m";
294$sql .=
" WHERE menu_handler = '".$db->escape($menu_handler_to_search).
"'";
295$sql .=
" AND entity = ".$conf->entity;
297$sql .=
" ORDER BY m.position, m.rowid";
299$res = $db->query($sql);
301 $num = $db->num_rows($res);
304 while ($menu = $db->fetch_array($res)) {
305 if (!empty($menu[
'langs'])) {
306 $langs->load($menu[
'langs']);
308 $titre = $langs->trans($menu[
'titre']);
310 $entry =
'<table class="nobordernopadding centpercent"><tr><td class="tdoverflowmax200">';
311 $entry .=
'<strong class="paddingleft"><a href="edit.php?menu_handler='.$menu_handler_to_search.
'&action=edit&token='.
newToken().
'&menuId='.$menu[
'rowid'].
'">'.$titre.
'</a></strong>';
313 $entry .=
'<td class="right nowraponall">';
314 $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> ';
315 $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> ';
316 $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> ';
318 $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>';
319 $entry .=
'</td></tr></table>';
321 $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> ';
322 $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> ';
323 $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> ';
324 $buttons .=
' ';
325 $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>';
328 'rowid' => (
int) $menu[
'rowid'],
329 'module' => (
string) $menu[
'module'],
330 'fk_menu' => (
int) $menu[
'fk_menu'],
331 'title' => (
string) $titre,
332 'mainmenu' => (
string) $menu[
'mainmenu'],
333 'leftmenu' => (
string) $menu[
'leftmenu'],
334 'fk_mainmenu' => (
string) $menu[
'fk_mainmenu'],
335 'fk_leftmenu' => (
string) $menu[
'fk_leftmenu'],
336 'position' => (
int) $menu[
'position'],
338 'buttons' => $buttons
344global $tree_recur_alreadyadded;
348print
'<div class="div-table-responsive">';
349print
'<table class="noborder centpercent">';
351print
'<tr class="liste_titre">';
352print
'<td>'.$langs->trans(
"TreeMenuPersonalized").
'</td>';
353print
'<td class="right"><div id="iddivjstreecontrol"><a href="#">'.img_picto($langs->trans(
"UndoExpandAll"),
'folder',
'class="paddingright"').
'</a>';
354print
' | <a href="#">'.img_picto($langs->trans(
"ExpandAll"),
'folder-open',
'class="paddingright"').
'</a></div></td>';
358print
'<td colspan="2">';
362tree_recur($data, $data[0], 0,
'iddivjstree', 0, 0);
372$remainingdata = array();
373foreach ($data as $datar) {
374 if (empty($datar[
'rowid']) || !empty($tree_recur_alreadyadded[$datar[
'rowid']])) {
377 $remainingdata[] = $datar;
380if (count($remainingdata)) {
381 print
'<div class="div-table-responsive">';
382 print
'<table class="noborder centpercent">';
384 print
'<tr class="liste_titre">';
385 print
'<td>'.$langs->trans(
"NotTopTreeMenuPersonalized").
'</td>';
386 print
'<td class="right"></td>';
390 print
'<td colspan="2">';
391 foreach ($remainingdata as $datar) {
392 $father = array(
'rowid' => $datar[
'rowid'],
'title' =>
"???",
'mainmenu' => $datar[
'fk_mainmenu'],
'leftmenu' => $datar[
'fk_leftmenu'],
'fk_mainmenu' =>
'',
'fk_leftmenu' =>
'');
394 tree_recur($data, $father, 0,
'iddivjstree'.$datar[
'rowid'], 1, 1);
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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
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)
Return value of a param into GET or POST supervariable.
img_edit_add($titlealt='default', $other='')
Show logo +.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.