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';
41$langs->loadLangs(array(
"other",
"admin"));
43$dirstandard = array();
44$dirsmartphone = array();
45$dirmenus = array_merge(array(
"/core/menus/"), (array) $conf->modules_parts[
'menus']);
46foreach ($dirmenus as $dirmenu) {
47 $dirstandard[] = $dirmenu.
'standard';
48 $dirsmartphone[] = $dirmenu.
'smartphone';
51$action =
GETPOST(
'action',
'aZ09');
52$confirm =
GETPOST(
'confirm',
'alpha');
55$menu_handler_top =
'all';
56$menu_handler_top = preg_replace(
'/(_backoffice\.php|_menu\.php)/i',
'', $menu_handler_top);
57$menu_handler_top = preg_replace(
'/(_frontoffice\.php|_menu\.php)/i',
'', $menu_handler_top);
59$menu_handler = $menu_handler_top;
61if (
GETPOST(
"handler_origine")) {
62 $menu_handler =
GETPOST(
"handler_origine");
65 $menu_handler =
GETPOST(
"menu_handler");
68$menu_handler_to_search = preg_replace(
'/(_backoffice|_frontoffice|_menu)?(\.php)?/i',
'', $menu_handler);
70if (empty($user->admin)) {
84 $sql =
"SELECT m.rowid, m.position, m.type, m.fk_menu";
85 $sql .=
" FROM ".MAIN_DB_PREFIX.
"menu as m";
86 $sql .=
" WHERE m.rowid = ".GETPOSTINT(
"menuId");
88 $result = $db->query($sql);
89 $num = $db->num_rows($result);
92 $obj = $db->fetch_object($result);
93 $current[
'rowid'] = (int) $obj->rowid;
94 $current[
'order'] = (int) $obj->position;
95 $current[
'type'] = (string) $obj->type;
96 $current[
'fk_menu'] = (int) $obj->fk_menu;
101 $sql =
"SELECT m.rowid, m.position";
102 $sql .=
" FROM ".MAIN_DB_PREFIX.
"menu as m";
103 $sql .=
" WHERE (m.position < ".($current[
'order']).
" OR (m.position = ".($current[
'order']).
" AND rowid < ".
GETPOSTINT(
"menuId").
"))";
104 $sql .=
" AND m.menu_handler='".$db->escape($menu_handler_to_search).
"'";
105 $sql .=
" AND m.entity = ".$conf->entity;
106 $sql .=
" AND m.type = '".$db->escape($current[
'type']).
"'";
107 $sql .=
" AND m.fk_menu = '".$db->escape((
string) $current[
'fk_menu']).
"'";
108 $sql .=
" ORDER BY m.position, m.rowid";
110 $result = $db->query($sql);
111 $num = $db->num_rows($result);
114 $obj = $db->fetch_object($result);
115 $previous[
'rowid'] = (int) $obj->rowid;
116 $previous[
'order'] = (int) $obj->position;
120 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"menu as m";
121 $sql .=
" SET m.position = ".((int) $previous[
'order']);
122 $sql .=
" WHERE m.rowid = ".((int) $current[
'rowid']);
125 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"menu as m";
126 $sql .=
" SET m.position = ".((int) ($current[
'order'] != $previous[
'order'] ? $current[
'order'] : $current[
'order'] + 1));
127 $sql .=
" WHERE m.rowid = ".((int) $previous[
'rowid']);
130} elseif ($action ==
'down') {
135 $sql =
"SELECT m.rowid, m.position, m.type, m.fk_menu";
136 $sql .=
" FROM ".MAIN_DB_PREFIX.
"menu as m";
137 $sql .=
" WHERE m.rowid = ".GETPOSTINT(
"menuId");
139 $result = $db->query($sql);
140 $num = $db->num_rows($result);
143 $obj = $db->fetch_object($result);
144 $current[
'rowid'] = (int) $obj->rowid;
145 $current[
'order'] = (int) $obj->position;
146 $current[
'type'] = (string) $obj->type;
147 $current[
'fk_menu'] = (int) $obj->fk_menu;
152 $sql =
"SELECT m.rowid, m.position";
153 $sql .=
" FROM ".MAIN_DB_PREFIX.
"menu as m";
154 $sql .=
" WHERE (m.position > ".($current[
'order']).
" OR (m.position = ".($current[
'order']).
" AND rowid > ".
GETPOSTINT(
"menuId").
"))";
155 $sql .=
" AND m.menu_handler='".$db->escape($menu_handler_to_search).
"'";
156 $sql .=
" AND m.entity = ".$conf->entity;
157 $sql .=
" AND m.type = '".$db->escape($current[
'type']).
"'";
158 $sql .=
" AND m.fk_menu = '".$db->escape((
string) $current[
'fk_menu']).
"'";
159 $sql .=
" ORDER BY m.position, m.rowid";
161 $result = $db->query($sql);
162 $num = $db->num_rows($result);
165 $obj = $db->fetch_object($result);
166 $next[
'rowid'] = (int) $obj->rowid;
167 $next[
'order'] = (int) $obj->position;
171 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"menu as m";
172 $sql .=
" SET m.position = ".((int) ($current[
'order'] != $next[
'order'] ? $next[
'order'] : $current[
'order'] + 1));
173 $sql .=
" WHERE m.rowid = ".((int) $current[
'rowid']);
176 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"menu as m";
177 $sql .=
" SET m.position = ".((int) $current[
'order']);
178 $sql .=
" WHERE m.rowid = ".((int) $next[
'rowid']);
181} elseif ($action ==
'confirm_delete' && $confirm ==
'yes') {
184 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"menu";
185 $sql .=
" WHERE rowid = ".GETPOSTINT(
'menuId');
186 $resql = $db->query($sql);
192 header(
"Location: ".DOL_URL_ROOT.
'/admin/menus/index.php?menu_handler='.$menu_handler);
207$form =
new Form($db);
210$arrayofjs = array(
'/includes/jquery/plugins/jquerytreeview/jquery.treeview.js',
'/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js');
211$arrayofcss = array(
'/includes/jquery/plugins/jquerytreeview/jquery.treeview.css');
213llxHeader(
'', $langs->trans(
"Menus"),
'',
'', 0, 0, $arrayofjs, $arrayofcss,
'',
'mod-admin page-menus_index');
222$head[$h][0] = DOL_URL_ROOT.
"/admin/menus.php";
223$head[$h][1] = $langs->trans(
"MenuHandlers");
224$head[$h][2] =
'handler';
227$head[$h][0] = DOL_URL_ROOT.
"/admin/menus/index.php";
228$head[$h][1] = $langs->trans(
"MenuAdmin");
229$head[$h][2] =
'editor';
234print
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"MenusEditorDesc").
"</span>";
235print
'<br class="hideonsmartphone">'.
"\n";
240if ($action ==
'delete') {
241 $sql =
"SELECT m.titre as title";
242 $sql .=
" FROM ".MAIN_DB_PREFIX.
"menu as m";
243 $sql .=
" WHERE m.rowid = ".GETPOSTINT(
'menuId');
244 $result = $db->query($sql);
245 $obj = $db->fetch_object($result);
247 print $form->formconfirm(
"index.php?menu_handler=".$menu_handler.
"&menuId=".
GETPOSTINT(
'menuId'), $langs->transnoentitiesnoconv(
"DeleteMenu"), $langs->transnoentitiesnoconv(
"ConfirmDeleteMenu", $obj->title),
"confirm_delete");
252 $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']));
255print
'<form name="newmenu" class="nocellnopadd" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
256print
'<input type="hidden" action="change_menu_handler">';
257print $langs->trans(
"MenuHandler").
': ';
258$formadmin->select_menu_families($menu_handler.(preg_match(
'/_menu/', $menu_handler) ?
'' :
'_menu'),
'menu_handler', array_merge($dirstandard, $dirsmartphone));
259print
' <input type="submit" class="button small" value="'.$langs->trans(
"Refresh").
'">';
261print
'<div class="floatright">';
287$data[] = array(
'rowid' => 0,
'fk_menu' => -1,
'title' =>
'racine',
'mainmenu' =>
'',
'leftmenu' =>
'',
'fk_mainmenu' =>
'',
'fk_leftmenu' =>
'');
291$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";
292$sql .=
" FROM ".MAIN_DB_PREFIX.
"menu as m";
293$sql .=
" WHERE menu_handler = '".$db->escape($menu_handler_to_search).
"'";
294$sql .=
" AND entity = ".$conf->entity;
296$sql .=
" ORDER BY m.position, m.rowid";
298$res = $db->query($sql);
300 $num = $db->num_rows($res);
303 while ($menu = $db->fetch_array($res)) {
304 if (!empty($menu[
'langs'])) {
305 $langs->load($menu[
'langs']);
307 $titre = $langs->trans($menu[
'titre']);
309 $entry =
'<table class="nobordernopadding centpercent"><tr><td class="tdoverflowmax200">';
310 $entry .=
'<strong class="paddingleft"><a href="edit.php?menu_handler='.$menu_handler_to_search.
'&action=edit&token='.
newToken().
'&menuId='.$menu[
'rowid'].
'">'.$titre.
'</a></strong>';
312 $entry .=
'<td class="right nowraponall">';
313 $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> ';
314 $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> ';
315 $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> ';
317 $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>';
318 $entry .=
'</td></tr></table>';
320 $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> ';
321 $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> ';
322 $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> ';
323 $buttons .=
' ';
324 $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>';
327 'rowid' => (
int) $menu[
'rowid'],
328 'module' => (
string) $menu[
'module'],
329 'fk_menu' => (
int) $menu[
'fk_menu'],
330 'title' => (
string) $titre,
331 'mainmenu' => (
string) $menu[
'mainmenu'],
332 'leftmenu' => (
string) $menu[
'leftmenu'],
333 'fk_mainmenu' => (
string) $menu[
'fk_mainmenu'],
334 'fk_leftmenu' => (
string) $menu[
'fk_leftmenu'],
335 'position' => (
int) $menu[
'position'],
337 'buttons' => $buttons
343global $tree_recur_alreadyadded;
347print
'<div class="div-table-responsive">';
348print
'<table class="noborder centpercent">';
350print
'<tr class="liste_titre">';
351print
'<td>'.$langs->trans(
"TreeMenuPersonalized").
'</td>';
352print
'<td class="right"><div id="iddivjstreecontrol"><a href="#">'.img_picto($langs->trans(
"UndoExpandAll"),
'folder',
'class="paddingright"').
'</a>';
353print
' | <a href="#">'.img_picto($langs->trans(
"ExpandAll"),
'folder-open',
'class="paddingright"').
'</a></div></td>';
357print
'<td colspan="2">';
361tree_recur($data, $data[0], 0,
'iddivjstree', 0, 0);
371$remainingdata = array();
372foreach ($data as $datar) {
373 if (empty($datar[
'rowid']) || !empty($tree_recur_alreadyadded[$datar[
'rowid']])) {
376 $remainingdata[] = $datar;
379if (count($remainingdata)) {
380 print
'<div class="div-table-responsive">';
381 print
'<table class="noborder centpercent">';
383 print
'<tr class="liste_titre">';
384 print
'<td>'.$langs->trans(
"NotTopTreeMenuPersonalized").
'</td>';
385 print
'<td class="right"></td>';
389 print
'<td colspan="2">';
390 foreach ($remainingdata as $datar) {
391 $father = array(
'rowid' => $datar[
'rowid'],
'title' =>
"???",
'mainmenu' => $datar[
'fk_mainmenu'],
'leftmenu' => $datar[
'fk_leftmenu'],
'fk_mainmenu' =>
'',
'fk_leftmenu' =>
'');
393 tree_recur($data, $father, 0,
'iddivjstree'.$datar[
'rowid'], 1, 1);
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
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, $morecssdiv='')
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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
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.
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.