27 require
'../../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/treeview.lib.php';
32 $langs->loadLangs(array(
"other",
"admin"));
36 $dirstandard = array();
37 $dirsmartphone = array();
38 $dirmenus = array_merge(array(
"/core/menus/"), (array) $conf->modules_parts[
'menus']);
39 foreach ($dirmenus as $dirmenu)
41 $dirstandard[] = $dirmenu.
'standard';
42 $dirsmartphone[] = $dirmenu.
'smartphone';
45 $action =
GETPOST(
'action',
'aZ09');
46 $confirm =
GETPOST(
'confirm',
'alpha');
48 $menu_handler_top = $conf->global->MAIN_MENU_STANDARD;
49 $menu_handler_smartphone = $conf->global->MAIN_MENU_SMARTPHONE;
50 $menu_handler_top = preg_replace(
'/(_backoffice\.php|_menu\.php)/i',
'', $menu_handler_top);
51 $menu_handler_top = preg_replace(
'/(_frontoffice\.php|_menu\.php)/i',
'', $menu_handler_top);
52 $menu_handler_smartphone = preg_replace(
'/(_backoffice\.php|_menu\.php)/i',
'', $menu_handler_smartphone);
53 $menu_handler_smartphone = preg_replace(
'/(_frontoffice\.php|_menu\.php)/i',
'', $menu_handler_smartphone);
55 $menu_handler = $menu_handler_top;
57 if (
GETPOST(
"handler_origine")) $menu_handler =
GETPOST(
"handler_origine");
58 if (
GETPOST(
"menu_handler")) $menu_handler =
GETPOST(
"menu_handler");
60 $menu_handler_to_search = preg_replace(
'/(_backoffice|_frontoffice|_menu)?(\.php)?/i',
'', $menu_handler);
73 $sql =
"SELECT m.rowid, m.position, m.type, m.fk_menu";
74 $sql .=
" FROM ".MAIN_DB_PREFIX.
"menu as m";
75 $sql .=
" WHERE m.rowid = ".GETPOST(
"menuId",
"int");
77 $result = $db->query($sql);
78 $num = $db->num_rows($result);
82 $obj = $db->fetch_object($result);
83 $current[
'rowid'] = $obj->rowid;
84 $current[
'order'] = $obj->position;
85 $current[
'type'] = $obj->type;
86 $current[
'fk_menu'] = $obj->fk_menu;
91 $sql =
"SELECT m.rowid, m.position";
92 $sql .=
" FROM ".MAIN_DB_PREFIX.
"menu as m";
93 $sql .=
" WHERE (m.position < ".($current[
'order']).
" OR (m.position = ".($current[
'order']).
" AND rowid < ".
GETPOST(
"menuId",
"int").
"))";
94 $sql .=
" AND m.menu_handler='".$db->escape($menu_handler_to_search).
"'";
95 $sql .=
" AND m.entity = ".$conf->entity;
96 $sql .=
" AND m.type = '".$db->escape($current[
'type']).
"'";
97 $sql .=
" AND m.fk_menu = '".$db->escape($current[
'fk_menu']).
"'";
98 $sql .=
" ORDER BY m.position, m.rowid";
100 $result = $db->query($sql);
101 $num = $db->num_rows($result);
105 $obj = $db->fetch_object($result);
106 $previous[
'rowid'] = $obj->rowid;
107 $previous[
'order'] = $obj->position;
111 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"menu as m";
112 $sql .=
" SET m.position = ".$previous[
'order'];
113 $sql .=
" WHERE m.rowid = ".$current[
'rowid'];
116 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"menu as m";
117 $sql .=
" SET m.position = ".($current[
'order'] != $previous[
'order'] ? $current[
'order'] : $current[
'order'] + 1);
118 $sql .=
" WHERE m.rowid = ".$previous[
'rowid'];
121 } elseif ($action ==
'down')
127 $sql =
"SELECT m.rowid, m.position, m.type, m.fk_menu";
128 $sql .=
" FROM ".MAIN_DB_PREFIX.
"menu as m";
129 $sql .=
" WHERE m.rowid = ".GETPOST(
"menuId",
"int");
131 $result = $db->query($sql);
132 $num = $db->num_rows($result);
136 $obj = $db->fetch_object($result);
137 $current[
'rowid'] = $obj->rowid;
138 $current[
'order'] = $obj->position;
139 $current[
'type'] = $obj->type;
140 $current[
'fk_menu'] = $obj->fk_menu;
145 $sql =
"SELECT m.rowid, m.position";
146 $sql .=
" FROM ".MAIN_DB_PREFIX.
"menu as m";
147 $sql .=
" WHERE (m.position > ".($current[
'order']).
" OR (m.position = ".($current[
'order']).
" AND rowid > ".
GETPOST(
"menuId",
"int").
"))";
148 $sql .=
" AND m.menu_handler='".$db->escape($menu_handler_to_search).
"'";
149 $sql .=
" AND m.entity = ".$conf->entity;
150 $sql .=
" AND m.type = '".$db->escape($current[
'type']).
"'";
151 $sql .=
" AND m.fk_menu = '".$db->escape($current[
'fk_menu']).
"'";
152 $sql .=
" ORDER BY m.position, m.rowid";
154 $result = $db->query($sql);
155 $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 = ".($current[
'order'] != $next[
'order'] ? $next[
'order'] : $current[
'order'] + 1);
167 $sql .=
" WHERE m.rowid = ".$current[
'rowid'];
170 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"menu as m";
171 $sql .=
" SET m.position = ".$current[
'order'];
172 $sql .=
" WHERE m.rowid = ".$next[
'rowid'];
175 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes')
179 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"menu";
180 $sql .=
" WHERE rowid = ".GETPOST(
'menuId',
'int');
181 $resql = $db->query($sql);
188 header(
"Location: ".DOL_URL_ROOT.
'/admin/menus/index.php?menu_handler='.$menu_handler);
203 $form =
new Form($db);
206 $arrayofjs = array(
'/includes/jquery/plugins/jquerytreeview/jquery.treeview.js',
'/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js');
207 $arrayofcss = array(
'/includes/jquery/plugins/jquerytreeview/jquery.treeview.css');
209 llxHeader(
'', $langs->trans(
"Menus"),
'',
'', 0, 0, $arrayofjs, $arrayofcss);
217 $head[$h][0] = DOL_URL_ROOT.
"/admin/menus.php";
218 $head[$h][1] = $langs->trans(
"MenuHandlers");
219 $head[$h][2] =
'handler';
222 $head[$h][0] = DOL_URL_ROOT.
"/admin/menus/index.php";
223 $head[$h][1] = $langs->trans(
"MenuAdmin");
224 $head[$h][2] =
'editor';
229 print '<span class="opacitymedium">'.$langs->trans(
"MenusEditorDesc").
"</span><br>\n";
234 if ($action ==
'delete')
236 $sql =
"SELECT m.titre as title";
237 $sql .=
" FROM ".MAIN_DB_PREFIX.
"menu as m";
238 $sql .=
" WHERE m.rowid = ".GETPOST(
'menuId',
'int');
239 $result = $db->query($sql);
240 $obj = $db->fetch_object($result);
242 print $form->formconfirm(
"index.php?menu_handler=".$menu_handler.
"&menuId=".
GETPOST(
'menuId',
'int'), $langs->trans(
"DeleteMenu"), $langs->trans(
"ConfirmDeleteMenu", $obj->title),
"confirm_delete");
248 $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']));
251 print '<form name="newmenu" class="nocellnopadd" action="'.$_SERVER[
"PHP_SELF"].
'">';
252 print '<input type="hidden" action="change_menu_handler">';
253 print $langs->trans(
"MenuHandler").
': ';
254 $formadmin->select_menu_families($menu_handler.(preg_match(
'/_menu/', $menu_handler) ?
'' :
'_menu'),
'menu_handler', array_merge($dirstandard, $dirsmartphone));
255 print ' <input type="submit" class="button" value="'.$langs->trans(
"Refresh").
'">';
257 print '<div class="floatright">';
258 print $newcardbutton;
265 print '<table class="noborder centpercent">';
267 print '<tr class="liste_titre">';
268 print '<td>'.$langs->trans(
"TreeMenuPersonalized").
'</td>';
269 print '<td class="right"><div id="iddivjstreecontrol"><a href="#">'.img_picto(
'',
'folder',
'class="paddingright"').$langs->trans(
"UndoExpandAll").
'</a>';
270 print ' | <a href="#">'.img_picto(
'',
'folder-open',
'class="paddingright"').$langs->trans(
"ExpandAll").
'</a></div></td>';
274 print '<td colspan="2">';
280 if ($conf->use_javascript_ajax)
295 $data[] = array(
'rowid'=>0,
'fk_menu'=>-1,
'title'=>
"racine",
'mainmenu'=>
'',
'leftmenu'=>
'',
'fk_mainmenu'=>
'',
'fk_leftmenu'=>
'');
299 $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";
300 $sql .=
" FROM ".MAIN_DB_PREFIX.
"menu as m";
301 $sql .=
" WHERE menu_handler = '".$db->escape($menu_handler_to_search).
"'";
302 $sql .=
" AND entity = ".$conf->entity;
304 $sql .=
" ORDER BY m.position, m.rowid";
306 $res = $db->query($sql);
309 $num = $db->num_rows($res);
312 while ($menu = $db->fetch_array($res))
314 if (!empty($menu[
'langs'])) $langs->load($menu[
'langs']);
315 $titre = $langs->trans($menu[
'titre']);
317 $entry =
'<table class="nobordernopadding centpercent"><tr><td>';
318 $entry .=
'<strong> <a href="edit.php?menu_handler='.$menu_handler_to_search.
'&action=edit&token='.
newToken().
'&menuId='.$menu[
'rowid'].
'">'.$titre.
'</a></strong>';
319 $entry .=
'</td><td class="right">';
320 $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> ';
321 $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> ';
322 $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> ';
323 $entry .=
' ';
324 $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>';
325 $entry .=
'</td></tr></table>';
327 $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> ';
328 $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> ';
329 $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> ';
330 $buttons .=
' ';
331 $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>';
334 'rowid'=>$menu[
'rowid'],
335 'module'=>$menu[
'module'],
336 'fk_menu'=>$menu[
'fk_menu'],
338 'mainmenu'=>$menu[
'mainmenu'],
339 'leftmenu'=>$menu[
'leftmenu'],
340 'fk_mainmenu'=>$menu[
'fk_mainmenu'],
341 'fk_leftmenu'=>$menu[
'fk_leftmenu'],
342 'position'=>$menu[
'position'],
350 global $tree_recur_alreadyadded;
356 tree_recur($data, $data[0], 0,
'iddivjstree', 0, 0);
367 $remainingdata = array();
368 foreach ($data as $datar)
370 if (empty($datar[
'rowid']) || $tree_recur_alreadyadded[$datar[
'rowid']])
continue;
371 $remainingdata[] = $datar;
374 if (count($remainingdata))
376 print '<table class="noborder centpercent">';
378 print '<tr class="liste_titre">';
379 print '<td>'.$langs->trans(
"NotTopTreeMenuPersonalized").
'</td>';
380 print '<td class="right"></td>';
384 print '<td colspan="2">';
385 foreach ($remainingdata as $datar)
387 $father = array(
'rowid'=>$datar[
'rowid'],
'title'=>
"???",
'mainmenu'=>$datar[
'fk_mainmenu'],
'leftmenu'=>$datar[
'fk_leftmenu'],
'fk_mainmenu'=>
'',
'fk_leftmenu'=>
'');
389 tree_recur($data, $father, 0,
'iddivjstree'.$datar[
'rowid'], 1, 1);
401 $langs->load(
"errors");
402 setEventMessages($langs->trans(
"ErrorFeatureNeedJavascript"), null,
'errors');
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
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.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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 Calling this function terminate execution ...
print $_SERVER["PHP_SELF"]
Edit parameters.
img_edit_add($titlealt= 'default', $other= '')
Show logo +.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
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.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
img_delete($titlealt= 'default', $other= 'class="pictodelete"', $morecss= '')
Show delete logo.
tree_recur($tab, $pere, $rang, $iddivjstree= 'iddivjstree', $donoresetalreadyloaded=0, $showfk=0, $moreparam= '')
Recursive function to output a tree.