-
Notifications
You must be signed in to change notification settings - Fork 14
/
menu.php
149 lines (111 loc) · 3.67 KB
/
menu.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
require 'config.php';
dol_include_once('/query/class/query.class.php');
dol_include_once('/query/class/dashboard.class.php');
$PDOdb = new TPDOdb;
$langs->load('query@query');
$action = GETPOST('action','alpha');
// HOTFIX: l'action "add" nécessite un jeton CSRF (car dans les modules standard, c'est une action impactante)
// mais pour query, "add" correspond au "create" du standard.
if ($action === 'create') $action = 'add';
$object=new TQueryMenu;
switch ($action) {
case 'save':
$object->load($PDOdb, GETPOST('id','int'));
if(GETPOST('bt_delete','alpha')!='') {
$object->delete($PDOdb);
setEventMessage('MenuDeleted');
}
else{
$object->set_values($_POST);
$object->save($PDOdb);
setEventMessage('MenuSaved');
}
_list($PDOdb);
break;
case 'edit':
$object->load($PDOdb, GETPOST('id','int'));
_card($PDOdb, $object);
break;
case 'add':
_card($PDOdb, $object);
break;
default:
_list($PDOdb);
break;
}
function _card(&$PDOdb, &$object) {
global $langs, $conf,$user,$db;
llxHeader();
dol_fiche_head(array(),'menu','Menu');
$formCore=new TFormCore('auto','formMenu','post');
echo $formCore->hidden('action', 'save');
echo $formCore->hidden('id', $object->getId());
$TQuery = array('0' => '----') + TQuery::getQueries($PDOdb);
$TDashBoard = array('0' => '----') + TQDashBoard::getDashboard($PDOdb, '', null, true);
$buttons = '';
if (!empty($object->getId())) $buttons.= $formCore->btsubmit($langs->trans('Delete'), 'bt_delete','','buttonDelete');
$buttons.= ' '. $formCore->btsubmit($langs->trans('Save'), 'bt_save');
$tbs=new TTemplateTBS;
echo $tbs->render('tpl/menu.html',array(),array(
'menu'=>array(
'type_menu'=>$formCore->combo('', 'type_menu', $object->TTypeMenu, $object->type_menu)
,'tab_object'=>$formCore->combo('', 'tab_object', $object->TTabObject, $object->tab_object)
,'mainmenu'=>$formCore->combo('', 'mainmenu', TQueryMenu::getMenu($PDOdb, 'main'), $object->mainmenu)
,'leftmenu'=>$formCore->combo('', 'leftmenu', TQueryMenu::getMenu($PDOdb, 'left'), $object->leftmenu)
,'fk_query'=>$formCore->combo('', 'fk_query', $TQuery, $object->fk_query)
,'fk_dashboard'=>$formCore->combo('', 'fk_dashboard', $TDashBoard, $object->fk_dashboard)
,'title'=>$formCore->texte('','title', $object->title,80,255)
,'perms'=>$formCore->texte('','perms', $object->perms,80,255)
)
,'view'=>array(
'langs'=>$langs
,'buttons'=>$buttons
)
,'conf'=>$conf
));
$formCore->end();
dol_fiche_end();
llxFooter();
}
function _list(&$PDOdb) {
global $langs, $conf,$user,$db;
llxHeader();
dol_fiche_head(array(),'menu','Menu', -1);
$l=new Listview($db, 'lMenu');
$sql = "SELECT rowid,title, type_menu, tab_object, mainmenu,leftmenu,date_cre
FROM ".MAIN_DB_PREFIX."query_menu
WHERE entity IN (0,".$conf->entity.")";
$menu_static = new TQueryMenu;
echo $l->render($sql,array(
'title'=>array(
'title'=>$langs->trans('Title')
,'leftmenu'=>$langs->trans('LeftMenu')
,'mainmenu'=>$langs->trans('MainMenu')
,'date_cre'=>$langs->trans('Date')
,'tab_object'=>$langs->trans('TabsObject')
,'type_menu'=>$langs->trans('TypeMenu')
)
,'translate'=>array(
'tab_object'=>$menu_static->TTabObject
,'type_menu'=>$menu_static->TTypeMenu
)
,'link'=>array(
'title'=>'<a href="?id=@rowid@&action=edit">@val@</a>'
)
,'hide'=>array('rowid')
,'type'=>array(
'date_cre'=>'date'
) ,'sortorder'=>''
,'sortfield'=>''
,'list' =>array('param_url'=>'','morehtmlrighttitle'=>'')
));
/*$kiwi = new TKiwi;
$kiwi->fk_soc = $object->id;
$kiwi->fk_product = 1;
$kiwi->save($PDOdb);
*/
// pied de page
dol_fiche_end(-1);
llxFooter();
}