1 | <?php
|
---|
2 |
|
---|
3 | include_once(dirname(__FILE__).'/../../Common/Global.php');
|
---|
4 |
|
---|
5 | class PageIS extends Page
|
---|
6 | {
|
---|
7 | var $FullTitle = 'Správa dat';
|
---|
8 | var $ShortTitle = 'Správa dat';
|
---|
9 | var $ParentClass = 'PagePortal';
|
---|
10 | var $MenuItems;
|
---|
11 | var $HideMenu;
|
---|
12 | var $ShowActionName;
|
---|
13 |
|
---|
14 | function __construct($System)
|
---|
15 | {
|
---|
16 | parent::__construct($System);
|
---|
17 | $this->MenuItems = array();
|
---|
18 | $this->HideMenu = false;
|
---|
19 | $this->ShowActionName = false;
|
---|
20 | }
|
---|
21 |
|
---|
22 | function Show()
|
---|
23 | {
|
---|
24 | if(!$this->System->User->CheckPermission('IS', 'Manage'))
|
---|
25 | return('Nemáte oprávnění');
|
---|
26 | $this->System->FormManager->ShowRelation = true;
|
---|
27 |
|
---|
28 | // a - action
|
---|
29 | if(array_key_exists('a', $_GET)) $Action = $_GET['a'];
|
---|
30 | else $Action = '';
|
---|
31 | // t - table
|
---|
32 | if(array_key_exists('t', $_GET)) $Table = $_GET['t'];
|
---|
33 | else $Table = '';
|
---|
34 | // i - index of item
|
---|
35 | if(array_key_exists('i', $_GET)) $ItemId = $_GET['i'];
|
---|
36 | else $ItemId = 0;
|
---|
37 | // fc - preset colum
|
---|
38 | if(array_key_exists('fn', $_GET)) $FilterName = $_GET['fn'];
|
---|
39 | else $FilterName = '';
|
---|
40 | if(array_key_exists('fv', $_GET)) $FilterValue = $_GET['fv'];
|
---|
41 | else $FilterValue = '';
|
---|
42 | if(array_key_exists('menutype', $_COOKIE)) $MenuType = $_COOKIE['menutype'];
|
---|
43 | else $MenuType = 0;
|
---|
44 | if(array_key_exists('menutype', $_GET)) $MenuType = $_GET['menutype'] * 1;
|
---|
45 | setcookie('menutype', $MenuType, time() + 60 * 60 * 24 * 365);
|
---|
46 |
|
---|
47 | if($Action == 'list') {
|
---|
48 | if($FilterName == '') $Content = $this->ShowList($Table);
|
---|
49 | else $Content = $this->ShowList($Table, '', '', $FilterName, $FilterValue);
|
---|
50 | }
|
---|
51 | else if($Action == 'select') $Content = $this->ShowSelect($Table);
|
---|
52 | else if($Action == 'mapselect') $Content = $this->ShowMapSelect($Table);
|
---|
53 | else if($Action == 'edit') $Content = $this->ShowEdit($Table, $ItemId);
|
---|
54 | else if($Action == 'add') $Content = $this->ShowAdd($Table);
|
---|
55 | else if($Action == 'addsub') $Content = $this->ShowAddSub($Table);
|
---|
56 | else if($Action == 'view') $Content = $this->ShowView($Table, $ItemId);
|
---|
57 | else if($Action == 'delete') $Content = $this->ShowDelete($Table, $ItemId);
|
---|
58 | else if($Action == 'fav_add') $Content = $this->ShowFavoriteAdd($Table, $ItemId);
|
---|
59 | else if($Action == 'fav_del') $Content = $this->ShowFavoriteDel($Table, $ItemId);
|
---|
60 | else $Content = $this->Dashboard();
|
---|
61 | if($this->HideMenu == false)
|
---|
62 | {
|
---|
63 | $Output = '<table style="width: 100%"><tr><td style="width: 20%; vertical-align: top;">';
|
---|
64 | $MenuTypeText = '<a href="?menutype=0">Nabídka</a>';
|
---|
65 | if($MenuType == 0) $MenuTypeText = '<strong>'.$MenuTypeText.'</strong>';
|
---|
66 | $Output .= $MenuTypeText.' ';
|
---|
67 | $MenuTypeText = '<a href="?menutype=1">Oblíbené</a>';
|
---|
68 | if($MenuType == 1) $MenuTypeText = '<strong>'.$MenuTypeText.'</strong>';
|
---|
69 | $Output .= $MenuTypeText.' ';
|
---|
70 | if($MenuType == 0) $Output .= $this->ShowMenu();
|
---|
71 | if($MenuType == 1) $Output .= $this->ShowFavorites();
|
---|
72 | $Output .= '</td><td style="width: 80%; vertical-align: top;">';
|
---|
73 | $Output .= $Content;
|
---|
74 | $Output .= '</td></tr></table>';
|
---|
75 | } else $Output = $Content;
|
---|
76 |
|
---|
77 | return($Output);
|
---|
78 | }
|
---|
79 |
|
---|
80 | function Dashboard()
|
---|
81 | {
|
---|
82 | $Output = '<strong>Nástěnka:</strong><br/>';
|
---|
83 | $DbResult = $this->Database->select('Task', 'COUNT(*)', '`Progress` < 100');
|
---|
84 | $DbRow = $DbResult->fetch_row();
|
---|
85 | $Output .= 'Nedokončených úkolů: '.$DbRow['0'].'<br/>';
|
---|
86 |
|
---|
87 | $DbResult = $this->Database->select('Member', 'COUNT(*)', '1');
|
---|
88 | $DbRow = $DbResult->fetch_row();
|
---|
89 | $Output .= 'Zákazníků: '.$DbRow['0'].'<br/>';
|
---|
90 |
|
---|
91 | $DbResult = $this->Database->select('Subject', 'COUNT(*)', '1');
|
---|
92 | $DbRow = $DbResult->fetch_row();
|
---|
93 | $Output .= 'Subjektů: '.$DbRow['0'].'<br/>';
|
---|
94 |
|
---|
95 | $DbResult = $this->Database->select('User', 'COUNT(*)', '1');
|
---|
96 | $DbRow = $DbResult->fetch_row();
|
---|
97 | $Output .= 'Uživatelů: '.$DbRow['0'].'<br/>';
|
---|
98 |
|
---|
99 | $DbResult = $this->Database->select('NetworkDevice', 'COUNT(*)', '1');
|
---|
100 | $DbRow = $DbResult->fetch_row();
|
---|
101 | $Output .= 'Registrovaných zařízení: '.$DbRow['0'].'<br/>';
|
---|
102 |
|
---|
103 | $DbResult = $this->Database->select('FinanceOperation', 'SUM(`Value` * `Direction`)', '1');
|
---|
104 | $DbRow = $DbResult->fetch_row();
|
---|
105 | $Output .= 'Stav placení: '.$DbRow['0'].'<br/>';
|
---|
106 |
|
---|
107 | $DbResult = $this->Database->select('FinanceBankImport', 'COUNT(*)', '`FinanceOperation` IS NULL');
|
---|
108 | $DbRow = $DbResult->fetch_row();
|
---|
109 | $Output .= 'Nezpárovaných plateb: '.$DbRow['0'].'<br/>';
|
---|
110 | return($Output);
|
---|
111 | }
|
---|
112 |
|
---|
113 | function ShowFavoriteAdd($Table, $ItemId)
|
---|
114 | {
|
---|
115 | $DbResult = $this->Database->select('MenuItemFavorite', 'Id', '(`MenuItem`='.($_GET['i'] * 1).') AND (`User`='.$this->System->User->User['Id'].')');
|
---|
116 | if($DbResult->num_rows > 0)
|
---|
117 | {
|
---|
118 | $Output = $this->SystemMessage('Oblíbené', 'Již existuje v oblíbených');
|
---|
119 | } else {
|
---|
120 | $this->Database->insert('MenuItemFavorite', array('MenuItem' => ($_GET['i'] * 1), 'User' => $this->System->User->User['Id']));
|
---|
121 | $Output = $this->SystemMessage('Oblíbené', 'Přidáno do oblíbených');
|
---|
122 | }
|
---|
123 | $Output .= $this->ShowList($Table);
|
---|
124 | return($Output);
|
---|
125 | }
|
---|
126 |
|
---|
127 | function ShowFavoriteDel($Table, $ItemId)
|
---|
128 | {
|
---|
129 | $DbResult = $this->Database->select('MenuItemFavorite', 'Id', '(`MenuItem`='.($_GET['i'] * 1).') AND (`User`='.$this->System->User->User['Id'].')');
|
---|
130 | if($DbResult->num_rows > 0)
|
---|
131 | {
|
---|
132 | $DbRow = $DbResult->fetch_assoc();
|
---|
133 | $this->Database->delete('MenuItemFavorite', '`Id`= '.$DbRow['Id']);
|
---|
134 | $Output = $this->SystemMessage('Oblíbené', 'Odstraněno z oblíbených');
|
---|
135 | } else {
|
---|
136 | $Output = $this->SystemMessage('Oblíbené', 'Nenalezeno v oblíbených');
|
---|
137 | }
|
---|
138 | $Output .= $this->ShowList($Table);
|
---|
139 | return($Output);
|
---|
140 | }
|
---|
141 |
|
---|
142 | function LogChange($Form, $Action, $NewId, $OldId)
|
---|
143 | {
|
---|
144 | $Values = $Form->Definition['Table'].' (Id: '.$OldId.' => '.$NewId.'):'."\n";
|
---|
145 | // Compare old values loaded from database with new values in Form variable
|
---|
146 | $NewValues = $Form->Values;
|
---|
147 | if($OldId != 0)
|
---|
148 | {
|
---|
149 | $FormOld = new Form($this->System->FormManager);
|
---|
150 | $FormOld->SetClass($Form->Definition['Table']);
|
---|
151 | $FormOld->LoadValuesFromDatabase($OldId);
|
---|
152 | $OldValues = $FormOld->Values;
|
---|
153 | // Keep only changes values
|
---|
154 | foreach($NewValues as $Index => $Value)
|
---|
155 | {
|
---|
156 | if($OldValues[$Index] != $NewValues[$Index])
|
---|
157 | {
|
---|
158 | $Values .= $Index.': '.$FormOld->GetValue($Index);
|
---|
159 | if($NewId != 0) $Values .= ' => '.$Form->GetValue($Index);
|
---|
160 | $Values .= "\n";
|
---|
161 | }
|
---|
162 | }
|
---|
163 | } else {
|
---|
164 | foreach($NewValues as $Index => $Value)
|
---|
165 | {
|
---|
166 | $Values .= $Index.': '.$Form->GetValue($Index)."\n";
|
---|
167 | }
|
---|
168 | }
|
---|
169 | $this->System->ModuleManager->Modules['Log']->NewRecord('IS', $Action, $Values);
|
---|
170 | }
|
---|
171 |
|
---|
172 | function ShowEdit($Table, $Id)
|
---|
173 | {
|
---|
174 | $this->ShortTitle .= ' - Úprava '.$Table;
|
---|
175 | $Output = '';
|
---|
176 | if(defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Write'))
|
---|
177 | return($this->SystemMessage('Oprávnění', 'Nemáte oprávnění'));
|
---|
178 | if(array_key_exists('o', $_GET))
|
---|
179 | {
|
---|
180 | if($_GET['o'] == 'save')
|
---|
181 | {
|
---|
182 | if(!array_key_exists('submit', $_POST))
|
---|
183 | return($this->SystemMessage('Formulář', 'Formulář nebyl řádně odeslán. Vraťte se zpět a odešlete formulář znovu.'));
|
---|
184 | $Form = new Form($this->System->FormManager);
|
---|
185 | $Form->SetClass($Table);
|
---|
186 | $Form->LoadValuesFromForm();
|
---|
187 | $this->ShortTitle .= ' - úprava '.$Form->Definition['Title'];
|
---|
188 | try {
|
---|
189 | $Form->Validate();
|
---|
190 | $this->LogChange($Form, 'Edit', $Id, $Id);
|
---|
191 | $Form->SaveValuesToDatabase($Id);
|
---|
192 | $Output .= $this->SystemMessage('Úprava položky', 'Položka upravena');
|
---|
193 | $Output .= $this->ShowView($Table, $Id);
|
---|
194 | } catch (Exception $E)
|
---|
195 | {
|
---|
196 | $Output .= $this->SystemMessage('Úprava položky', 'Položku se nepodařilo uložit. Opravte problém a opakujte akci.<br/>'.$E->getMessage());
|
---|
197 | $Form->OnSubmit = '?a=edit&t='.$Table.'&i='.$_GET['i'].'&o=save';
|
---|
198 | $Output .= $Form->ShowEditForm();
|
---|
199 | $Output .= '<ul class="ActionMenu">';
|
---|
200 | $Output .= '<li>'.$this->ShowAction('Prohlížet', '?a=view&t='.$Table.'&i='.$Id,
|
---|
201 | $this->System->Link('/images/view.png'));
|
---|
202 | $Output .= '<li>'.$this->ShowAction('Seznam', '?a=list&t='.$Table,
|
---|
203 | $this->System->Link('/images/list.png'));
|
---|
204 | $Output .= '<li>'.$this->ShowAction('Odstranit', '?a=delete&t='.$Table.'&i='.$Id,
|
---|
205 | $this->System->Link('/images/delete.png'), 'Opravdu smazat položku');
|
---|
206 | $Output .= '</ul>';
|
---|
207 | }
|
---|
208 | }
|
---|
209 | } else
|
---|
210 | {
|
---|
211 | $Form = new Form($this->System->FormManager);
|
---|
212 | $Form->SetClass($Table);
|
---|
213 | $Form->LoadValuesFromDatabase($Id);
|
---|
214 | $this->ShortTitle .= ' - úprava '.$Form->Definition['Title'];
|
---|
215 | $Form->OnSubmit = '?a=edit&t='.$Table.'&i='.$_GET['i'].'&o=save';
|
---|
216 | $Output .= $Form->ShowEditForm();
|
---|
217 | $Output .= '<ul class="ActionMenu">';
|
---|
218 | $Output .= '<li>'.$this->ShowAction('Prohlížet', '?a=view&t='.$Table.'&i='.$Id,
|
---|
219 | $this->System->Link('/images/view.png'));
|
---|
220 | $Output .= '<li>'.$this->ShowAction('Seznam', '?a=list&t='.$Table,
|
---|
221 | $this->System->Link('/images/list.png'));
|
---|
222 | $Output .= '<li>'.$this->ShowAction('Odstranit', '?a=delete&t='.$Table.'&i='.$Id,
|
---|
223 | $this->System->Link('/images/delete.png'), 'Opravdu smazat položku?');
|
---|
224 | $Output .= '</ul>';
|
---|
225 | }
|
---|
226 | return($Output);
|
---|
227 | }
|
---|
228 |
|
---|
229 | function ShowDelete($Table, $Id)
|
---|
230 | {
|
---|
231 | $Output = '';
|
---|
232 | if(defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Write'))
|
---|
233 | return('Nemáte oprávnění');
|
---|
234 | $this->ShortTitle .= ' - odstranění '.$Table;
|
---|
235 | $DbResult = $this->Database->select($Table, '*', '`Id`='.$Id);
|
---|
236 | if($DbResult->num_rows > 0)
|
---|
237 | {
|
---|
238 | $DbRow = $DbResult->fetch_assoc();
|
---|
239 | try {
|
---|
240 | $Form = new Form($this->System->FormManager);
|
---|
241 | $Form->SetClass($Table);
|
---|
242 | $this->LogChange($Form, 'Delete', 0, $Id);
|
---|
243 | $this->Database->delete($Table, '`Id`='.$Id);
|
---|
244 | $Output .= $this->SystemMessage('Smazání položky', 'Položka odstraněna');
|
---|
245 | } catch (Exception $E)
|
---|
246 | {
|
---|
247 | $Output .= $this->SystemMessage('Smazání položky', 'Položku se nepodařilo smazat. Pravděpodobně na ni závisejí další položky.');
|
---|
248 | }
|
---|
249 | } else $Output .= $this->SystemMessage('Smazání položky', 'Položka nenalezena');
|
---|
250 | $Output .= $this->ShowList($Table);
|
---|
251 | return($Output);
|
---|
252 | }
|
---|
253 |
|
---|
254 | function ShowAdd($Table, $Actions = array())
|
---|
255 | {
|
---|
256 | $Output = '';
|
---|
257 | if(defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Write'))
|
---|
258 | return('Nemáte oprávnění');
|
---|
259 | if(array_key_exists('o', $_GET))
|
---|
260 | {
|
---|
261 | if($_GET['o'] == 'save')
|
---|
262 | {
|
---|
263 | $Form = new Form($this->System->FormManager);
|
---|
264 | $Form->SetClass($Table);
|
---|
265 | $Form->LoadValuesFromForm();
|
---|
266 | $this->ShortTitle .= ' - přidání '.$Form->Definition['Title'];
|
---|
267 | try {
|
---|
268 | $Form->Validate();
|
---|
269 | if(array_key_exists('BeforeInsert', $Form->Definition))
|
---|
270 | {
|
---|
271 | $Class = $Form->Definition['BeforeInsert'][0];
|
---|
272 | $Method = $Form->Definition['BeforeInsert'][1];
|
---|
273 | $this->Values = $Class->$Method($Form);
|
---|
274 | }
|
---|
275 | $Form->Validate();
|
---|
276 | $Form->SaveValuesToDatabase(0);
|
---|
277 | $Id = $this->Database->insert_id;
|
---|
278 | $this->LogChange($Form, 'Add', $Id, 0);
|
---|
279 | $Output .= $this->SystemMessage('Přidání položky', 'Nová položka vytvořena');
|
---|
280 | $Output .= $this->ShowView($Table, $Id, $_GET['a'] == 'addsub');
|
---|
281 | if(array_key_exists('AfterInsert', $Form->Definition))
|
---|
282 | {
|
---|
283 | $Class = $Form->Definition['AfterInsert'][0];
|
---|
284 | $Method = $Form->Definition['AfterInsert'][1];
|
---|
285 | $this->Values = $Class->$Method($Form);
|
---|
286 | }
|
---|
287 | // Add action to update caller form
|
---|
288 | if($_GET['a'] == 'addsub')
|
---|
289 | {
|
---|
290 | $Type = $this->System->FormManager->FormTypes[$_GET['rt']];
|
---|
291 | $DbResult = $this->Database->select($Table, '('.$Type['Name'].') AS Name', 'Id='.$Id);
|
---|
292 | $DbRow = $DbResult->fetch_assoc();
|
---|
293 | $Actions[] = '<a href="javascript:window.close();" onclick="add_select_item('.$Id.',"'.$DbRow['Name'].'","'.
|
---|
294 | $_GET['r'].'"); set_return('.$Id.',"'.
|
---|
295 | $_GET['r'].'");"><img alt="Vybrat" title="Vybrat" src="'.
|
---|
296 | $this->System->Link('/images/select.png').'"/> Vybrat</a>';
|
---|
297 | }
|
---|
298 |
|
---|
299 | //$this->Database->update($Table, 'Id='.$Id,
|
---|
300 | // array('UserCreate' => $this->System->User->User['Id'],
|
---|
301 | // 'TimeCreate' => 'NOW()'));
|
---|
302 | } catch (Exception $E)
|
---|
303 | {
|
---|
304 | $Output .= $this->SystemMessage('Přidání položky', 'Položku se nepodařilo přidat. Opravte problém a opakujte akci.<br/>'.$E->getMessage());
|
---|
305 | $Form->OnSubmit = '?a=add&t='.$Table.'&o=save';
|
---|
306 | $Output .= $Form->ShowEditForm();
|
---|
307 | $Actions[] = '<a href="?a=list&t='.$Table.'"><img alt="Seznam" title="Seznam" src="'.
|
---|
308 | $this->System->Link('/images/list.png').'"/>Seznam</a>';
|
---|
309 | }
|
---|
310 | }
|
---|
311 | } else
|
---|
312 | {
|
---|
313 | $Form = new Form($this->System->FormManager);
|
---|
314 | $Form->SetClass($Table);
|
---|
315 | $this->ShortTitle .= ' - přidání '.$Form->Definition['Title'];
|
---|
316 | // Load presets from URL
|
---|
317 | foreach($_GET as $Key => $Value)
|
---|
318 | if(substr($Key, 0, 6) == 'preset')
|
---|
319 | {
|
---|
320 | $Key = substr($Key, 6);
|
---|
321 | if(($Key != '') and array_key_exists($Key, $Form->Values))
|
---|
322 | $Form->Values[$Key] = $Value;
|
---|
323 | }
|
---|
324 | if(array_key_exists('r', $_GET)) $URL = '&r='.$_GET['r'].'&rt='.$_GET['rt'];
|
---|
325 | else $URL = '';
|
---|
326 | $Form->OnSubmit = '?a='.$_GET['a'].'&t='.$Table.'&o=save'.$URL;
|
---|
327 | $Output .= $Form->ShowEditForm();
|
---|
328 | $Actions[] = $this->ShowAction('Seznam', '?a=list&t='.$Table,
|
---|
329 | $this->System->Link('/images/list.png'));
|
---|
330 | }
|
---|
331 | $Output .= '<ul class="ActionMenu">';
|
---|
332 | foreach($Actions as $Action)
|
---|
333 | {
|
---|
334 | $Output .= '<li>'.$Action.'</li>';
|
---|
335 | }
|
---|
336 | $Output .= '</ul>';
|
---|
337 | return($Output);
|
---|
338 | }
|
---|
339 |
|
---|
340 | function ShowAddSub($Table, $Filter = '', $Title = '')
|
---|
341 | {
|
---|
342 | if(defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Write'))
|
---|
343 | return('Nemáte oprávnění');
|
---|
344 | $this->BasicHTML = true;
|
---|
345 | $this->HideMenu = true;
|
---|
346 | $Output = $this->ShowAdd($Table);
|
---|
347 | return($Output);
|
---|
348 | }
|
---|
349 |
|
---|
350 | function ShowView($Table, $Id, $WithoutActions = false)
|
---|
351 | {
|
---|
352 | if($Table != '') $FormClass = $this->System->FormManager->Classes[$Table];
|
---|
353 | else return($this->SystemMessage('Chyba', 'Tabulka nenalezena'));
|
---|
354 | if(defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Read'))
|
---|
355 | return('Nemáte oprávnění');
|
---|
356 |
|
---|
357 | $Form = new Form($this->System->FormManager);
|
---|
358 | $Form->SetClass($Table);
|
---|
359 | $this->ShortTitle .= ' - položka '.$Form->Definition['Title'];
|
---|
360 | $Form->LoadValuesFromDatabase($Id);
|
---|
361 | $Form->OnSubmit = '?a=view';
|
---|
362 | $Output = $Form->ShowViewForm();
|
---|
363 | if($WithoutActions == false)
|
---|
364 | {
|
---|
365 | $Actions = array(
|
---|
366 | $this->ShowAction('Upravit', '?a=edit&t='.$Table.'&i='.$Id,
|
---|
367 | $this->System->Link('/images/edit.png')),
|
---|
368 | $this->ShowAction('Seznam', '?a=list&t='.$Table,
|
---|
369 | $this->System->Link('/images/list.png')),
|
---|
370 | $this->ShowAction('Odstranit', '?a=delete&t='.$Table.'&i='.$Id,
|
---|
371 | $this->System->Link('/images/delete.png'), 'Opravdu smazat položku?'),
|
---|
372 | $this->ShowAction('Přidat', '?a=add&t='.$Table,
|
---|
373 | $this->System->Link('/images/add.png'))
|
---|
374 | );
|
---|
375 | if(array_key_exists('ItemActions', $FormClass))
|
---|
376 | {
|
---|
377 | foreach($FormClass['ItemActions'] as $Action)
|
---|
378 | {
|
---|
379 | $URL = str_replace('#RowId', $Id, $this->System->Link($Action['URL']));
|
---|
380 | $Actions[] = $this->ShowAction($Action['Caption'], $URL,
|
---|
381 | $this->System->Link('/images/action.png'));
|
---|
382 | }
|
---|
383 | }
|
---|
384 | $Output .= '<ul class="ActionMenu">';
|
---|
385 | foreach($Actions as $Action)
|
---|
386 | {
|
---|
387 | $Output .= '<li>'.$Action.'</li>';
|
---|
388 | }
|
---|
389 | $Output .= '</ul><br/>';
|
---|
390 |
|
---|
391 | // Show ManyToOne relations
|
---|
392 | foreach($Form->Definition['Items'] as $Index => $Item)
|
---|
393 | if((array_key_exists($Item['Type'], $this->System->FormManager->FormTypes) and
|
---|
394 | ($this->System->FormManager->FormTypes[$Item['Type']]['Type'] == 'ManyToOne')))
|
---|
395 | {
|
---|
396 | $Output .= $this->ShowList($this->System->FormManager->FormTypes[$Item['Type']]['Table'], '`'.
|
---|
397 | $this->System->FormManager->FormTypes[$Item['Type']]['Ref'].'`='.$Id, $Item['Caption'],
|
---|
398 | $this->System->FormManager->FormTypes[$Item['Type']]['Ref'], $Id).'<br/>';
|
---|
399 | }
|
---|
400 | }
|
---|
401 | return($Output);
|
---|
402 | }
|
---|
403 |
|
---|
404 | function ShowTable($Table, $Filter = '', $Title = '', $RowActions = array(), $ExcludeColumn = '')
|
---|
405 | {
|
---|
406 | if($Table != '') $FormClass = $this->System->FormManager->Classes[$Table];
|
---|
407 | else return($this->SystemMessage('Chyba', 'Tabulka nenalezena'));
|
---|
408 |
|
---|
409 | if(array_key_exists('SQL', $FormClass))
|
---|
410 | $SourceTable = '('.$FormClass['SQL'].') AS `TX`';
|
---|
411 | else $SourceTable = '`'.$FormClass['Table'].'` AS `TX`';
|
---|
412 |
|
---|
413 | // Build form type filter
|
---|
414 | $TypeFilter = '';
|
---|
415 | foreach($FormClass['Items'] as $ItemIndex => $FormItem)
|
---|
416 | if(!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or
|
---|
417 | (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) and
|
---|
418 | ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne')))
|
---|
419 | if(array_key_exists('Filter', $FormItem) and ($FormItem['Filter'] == true))
|
---|
420 | {
|
---|
421 | if($TypeFilter != '') $TypeFilter .= ' AND ';
|
---|
422 | $TypeFilter .= '('.$ItemIndex.' = "'.$FormItem['Default'].'")';
|
---|
423 | }
|
---|
424 | if($TypeFilter != '')
|
---|
425 | {
|
---|
426 | if($Filter != '') $Filter = ' AND';
|
---|
427 | $Filter .= ' '.$TypeFilter;
|
---|
428 | }
|
---|
429 |
|
---|
430 | // Build user filter
|
---|
431 | $UserFilter = '';
|
---|
432 | $Columns = array('Id' => '`Id`');
|
---|
433 | if(array_key_exists('filter', $_GET) and ($_GET['filter'] == 1))
|
---|
434 | {
|
---|
435 | foreach($FormClass['Items'] as $ItemIndex => $FormItem)
|
---|
436 | if(!array_key_exists('Hidden', $FormItem) or ($FormItem['Hidden'] == false))
|
---|
437 | if(!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or
|
---|
438 | (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) and
|
---|
439 | ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne')))
|
---|
440 | {
|
---|
441 | $UseType = $UseType = $FormItem['Type'];
|
---|
442 | if(array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes))
|
---|
443 | {
|
---|
444 | if(!array_key_exists($FormItem['Type'], $this->System->FormManager->Type->TypeDefinitionList))
|
---|
445 | $this->System->FormManager->Type->RegisterType($FormItem['Type'], '',
|
---|
446 | $this->System->FormManager->FormTypes[$FormItem['Type']]);
|
---|
447 | if($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] == 'Reference')
|
---|
448 | $UseType = 'OneToMany';
|
---|
449 | else
|
---|
450 | if($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] == 'Enumeration')
|
---|
451 | $UseType = 'Enumeration';
|
---|
452 | }
|
---|
453 | $FilterName = $this->System->FormManager->Type->ExecuteTypeEvent($UseType, 'OnFilterName',
|
---|
454 | array('Name' => $ItemIndex, 'Type' => $FormItem['Type']));
|
---|
455 | if(array_key_exists('Filter'.$ItemIndex, $_POST) and ($_POST['Filter'.$ItemIndex] != ''))
|
---|
456 | {
|
---|
457 | if($UserFilter != '') $UserFilter .= ' AND ';
|
---|
458 | $UserFilter .= '('.$FilterName.' LIKE "%'.$_POST['Filter'.$ItemIndex].'%")';
|
---|
459 | }
|
---|
460 | }
|
---|
461 | }
|
---|
462 | if($UserFilter != '')
|
---|
463 | {
|
---|
464 | if($Filter != '') $Filter = ' AND';
|
---|
465 | $Filter .= ' '.$UserFilter;
|
---|
466 | }
|
---|
467 | if($Filter != '') $Filter = ' HAVING '.$Filter;
|
---|
468 |
|
---|
469 | foreach($FormClass['Items'] as $ItemIndex => $FormItem)
|
---|
470 | if(!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or
|
---|
471 | (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) and
|
---|
472 | ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne')))
|
---|
473 | {
|
---|
474 | if($ExcludeColumn != $ItemIndex)
|
---|
475 | if(!array_key_exists('Hidden', $FormItem) or ($FormItem['Hidden'] == false))
|
---|
476 | $TableColumns[] = array('Name' => $ItemIndex, 'Title' => $FormItem['Caption']);
|
---|
477 | $UseType = $UseType = $FormItem['Type'];
|
---|
478 | if(array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes))
|
---|
479 | {
|
---|
480 | if(!array_key_exists($FormItem['Type'], $this->System->FormManager->Type->TypeDefinitionList))
|
---|
481 | $this->System->FormManager->Type->RegisterType($FormItem['Type'], '',
|
---|
482 | $this->System->FormManager->FormTypes[$FormItem['Type']]);
|
---|
483 | if($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] == 'Reference')
|
---|
484 | $UseType = 'OneToMany';
|
---|
485 | else
|
---|
486 | if($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] == 'Enumeration')
|
---|
487 | $UseType = 'Enumeration';
|
---|
488 | }
|
---|
489 | if(array_key_exists('Filter'.$ItemIndex, $_POST) and ($_POST['Filter'.$ItemIndex] != ''))
|
---|
490 | $Value = $_POST['Filter'.$ItemIndex];
|
---|
491 | else $Value = '';
|
---|
492 | if($ItemIndex == 'Id') unset($Columns['Id']);
|
---|
493 |
|
---|
494 | if(!array_key_exists('SQL', $FormItem)) $FormItem['SQL'] = '';
|
---|
495 | else $FormItem['SQL'] = str_replace('#Id', '`TX`.`Id`', $FormItem['SQL']);
|
---|
496 | $Columns[] = $this->System->FormManager->Type->ExecuteTypeEvent($UseType, 'OnFilterNameQuery',
|
---|
497 | array('Value' => $Value, 'Name' => $ItemIndex,
|
---|
498 | 'Type' => $FormItem['Type'], 'SQL' => $FormItem['SQL']));
|
---|
499 | }
|
---|
500 |
|
---|
501 | // Get total item count in database
|
---|
502 | $Query = 'SELECT COUNT(*) FROM '.$SourceTable;
|
---|
503 | $DbResult = $this->Database->query($Query);
|
---|
504 | $DbRow = $DbResult->fetch_assoc();
|
---|
505 | $TotalCount = $DbRow['COUNT(*)'];
|
---|
506 |
|
---|
507 | // Get total filtered item count in database
|
---|
508 | $Columns = implode(',', $Columns);
|
---|
509 | if($Filter != '')
|
---|
510 | {
|
---|
511 | $Query = 'SELECT COUNT(*) FROM (SELECT '.$Columns.' FROM '.$SourceTable.' '.$Filter.') AS `TS`';
|
---|
512 | $DbResult = $this->Database->query($Query);
|
---|
513 | $DbRow = $DbResult->fetch_row();
|
---|
514 | $TotalFilteredCount = $DbRow[0];
|
---|
515 | } else $TotalFilteredCount = $TotalCount;
|
---|
516 | $PageList = GetPageList($TotalFilteredCount);
|
---|
517 |
|
---|
518 | $Output = $PageList['Output'];
|
---|
519 | $Output .= '<table class="WideTable" style="font-size: small;">';
|
---|
520 |
|
---|
521 | $TableColumns[] = array('Name' => '', 'Title' => 'Akce');
|
---|
522 | if(!array_key_exists('DefaultSortColumn', $FormClass))
|
---|
523 | $FormClass['DefaultSortColumn'] = 'Id';
|
---|
524 | if(!array_key_exists('DefaultSortOrder', $FormClass))
|
---|
525 | $FormClass['DefaultSortOrder'] = 0;
|
---|
526 | $Order = GetOrderTableHeader($TableColumns, $FormClass['DefaultSortColumn'], $FormClass['DefaultSortOrder']);
|
---|
527 | $Output .= $Order['Output'];
|
---|
528 |
|
---|
529 | // Show search fields
|
---|
530 | if(array_key_exists('r', $_GET)) $Addition = '&r='.$_GET['r'];
|
---|
531 | else $Addition = '';
|
---|
532 | $Output .= '<tr><form action="?a='.$_GET['a'].'&t='.$Table.'&filter=1'.$Addition.'" method="post">';
|
---|
533 | foreach($FormClass['Items'] as $ItemIndex => $FormItem)
|
---|
534 | if(!array_key_exists('Hidden', $FormItem) or ($FormItem['Hidden'] == false))
|
---|
535 | if((!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or
|
---|
536 | (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) and
|
---|
537 | ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne'))) and
|
---|
538 | ($ExcludeColumn != $ItemIndex))
|
---|
539 | {
|
---|
540 | if(array_key_exists('Filter'.$ItemIndex, $_POST) and ($_POST['Filter'.$ItemIndex] != ''))
|
---|
541 | $Value = $_POST['Filter'.$ItemIndex];
|
---|
542 | else $Value = '';
|
---|
543 | $Output .= '<td><input type="text" name="Filter'.$ItemIndex.'" value="'.$Value.'" style="width: 100%"/></td>';
|
---|
544 | }
|
---|
545 | $Output .= '<td><input type="Submit" value="Hledat"/></td></form></tr>';
|
---|
546 |
|
---|
547 | // Load and show items
|
---|
548 | $Query = 'SELECT '.$Columns.' FROM '.$SourceTable.' '.
|
---|
549 | $Filter.' '.$Order['SQL'].$PageList['SQLLimit'];
|
---|
550 | $VisibleItemCount = 0;
|
---|
551 | $DbResult = $this->Database->query($Query);
|
---|
552 | while($Row = $DbResult->fetch_assoc())
|
---|
553 | {
|
---|
554 | $Output .= '<tr>';
|
---|
555 | foreach($FormClass['Items'] as $ItemIndex => $FormItem)
|
---|
556 | if(!array_key_exists('Hidden', $FormItem) or ($FormItem['Hidden'] == false))
|
---|
557 | if((!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or
|
---|
558 | (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) and
|
---|
559 | ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne'))) and
|
---|
560 | ($ExcludeColumn != $ItemIndex))
|
---|
561 | {
|
---|
562 | //$Output .= '<td>'.$Row[$ItemIndex].'</td>';
|
---|
563 | $UseType = $UseType = $FormItem['Type'];
|
---|
564 | if(array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes))
|
---|
565 | {
|
---|
566 | if(!array_key_exists($FormItem['Type'], $this->System->FormManager->Type->TypeDefinitionList))
|
---|
567 | $this->System->FormManager->Type->RegisterType($FormItem['Type'], '',
|
---|
568 | $this->System->FormManager->FormTypes[$FormItem['Type']]);
|
---|
569 | if($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] == 'Reference')
|
---|
570 | $UseType = 'OneToMany';
|
---|
571 | else
|
---|
572 | if($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] == 'Enumeration')
|
---|
573 | $UseType = 'Enumeration';
|
---|
574 | }
|
---|
575 | $Row[$ItemIndex] = $this->System->FormManager->Type->ExecuteTypeEvent($UseType, 'OnLoadDb',
|
---|
576 | array('Value' => $Row[$ItemIndex], 'Name' => $ItemIndex,
|
---|
577 | 'Type' => $FormItem['Type']));
|
---|
578 | $Value = $this->System->FormManager->Type->ExecuteTypeEvent($UseType, 'OnView',
|
---|
579 | array('Value' => $Row[$ItemIndex], 'Name' => $ItemIndex,
|
---|
580 | 'Type' => $FormItem['Type'], 'Filter' => $Row[$ItemIndex.'_Filter']));
|
---|
581 | if($Value == '') $Value = ' ';
|
---|
582 | $Output .= '<td>'.$Value.'</td>';
|
---|
583 | }
|
---|
584 | $Output .= '<td>'.str_replace('#RowId', $Row['Id'], $RowActions).'</td></tr>';
|
---|
585 | $VisibleItemCount = $VisibleItemCount + 1;
|
---|
586 | }
|
---|
587 | $Output .= '<tr><td colspan="'.count($TableColumns).'" style="text-align: right;">Zobrazeno <strong>'.$VisibleItemCount.'</strong>';
|
---|
588 | if($UserFilter != '') $Output .= ' z filtrovaných <strong>'.$TotalFilteredCount.'</strong>';
|
---|
589 | $Output .= ' z celkem <strong>'.$TotalCount.'</strong></td></tr>';
|
---|
590 | $Output .= '</table>';
|
---|
591 | $Output .= $PageList['Output'];
|
---|
592 | return($Output);
|
---|
593 | }
|
---|
594 |
|
---|
595 | function ShowSelect($Table, $Filter = '', $Title = '')
|
---|
596 | {
|
---|
597 | if(defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Read'))
|
---|
598 | return('Nemáte oprávnění');
|
---|
599 | $this->BasicHTML = true;
|
---|
600 | $this->HideMenu = true;
|
---|
601 | $RowActions = '<a href="javascript:window.close();" onclick="set_return(#RowId,"'.
|
---|
602 | $_GET['r'].'");"><img alt="Vybrat" title="Vybrat" src="'.
|
---|
603 | $this->System->Link('/images/select.png').'"/></a>';
|
---|
604 | $Output = $this->ShowTable($Table, $Filter, $Title, $RowActions);
|
---|
605 | return($Output);
|
---|
606 | }
|
---|
607 |
|
---|
608 | function ShowMapSelect($Table, $Filter = '', $Title = '')
|
---|
609 | {
|
---|
610 | if(defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Write'))
|
---|
611 | return('Nemáte oprávnění');
|
---|
612 | $MapApi = new MapApiGoogle($this->System);
|
---|
613 | $MapApi->Position = array('Lat' => $this->System->Config['Map']['DefaultLatitude'],
|
---|
614 | 'Lng' => $this->System->Config['Map']['DefaultLongitude']);
|
---|
615 | $MapApi->Zoom = $this->System->Config['Map']['DefaultZoom'];
|
---|
616 | $MapApi->Key = $this->System->Config['Map']['GoogleMapsApiKey'];
|
---|
617 | $MapApi->OnClickObject = $_GET['r'];
|
---|
618 | //$MapApi->ShowMarker = true;
|
---|
619 | $Output = $MapApi->ShowPage($this);
|
---|
620 | return($Output);
|
---|
621 | }
|
---|
622 |
|
---|
623 | function ShowList($Table, $Filter = '', $Title = '', $ExcludeColumn = '', $ExcludeValue = '')
|
---|
624 | {
|
---|
625 | $Output = '';
|
---|
626 | if(defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Read'))
|
---|
627 | return('Nemáte oprávnění');
|
---|
628 | $RowActions = '<a href="?a=view&t='.$Table.'&i=#RowId"><img alt="Ukázat" title="Ukázat" src="'.
|
---|
629 | $this->System->Link('/images/view.png').'"/></a>'.
|
---|
630 | '<a href="?a=edit&t='.$Table.'&i=#RowId"><img alt="Upravit" title="Upravit" src="'.
|
---|
631 | $this->System->Link('/images/edit.png').'"/></a>'.
|
---|
632 | '<a href="?a=delete&t='.$Table.'&i=#RowId"><img alt="Smazat" title="Smazat" src="'.
|
---|
633 | $this->System->Link('/images/delete.png').'" onclick="return confirmAction(\'Opravdu smazat položku?\');"/></a>';
|
---|
634 | if(($Table != '') and (array_key_exists($Table, $this->System->FormManager->Classes)))
|
---|
635 | $FormClass = $this->System->FormManager->Classes[$Table];
|
---|
636 | else return($this->SystemMessage('Chyba', 'Tabulka '.$Table.' nenalezena'));
|
---|
637 | if(array_key_exists('ItemActions', $FormClass))
|
---|
638 | {
|
---|
639 | foreach($FormClass['ItemActions'] as $Action)
|
---|
640 | {
|
---|
641 | $URL = $this->System->Link($Action['URL']);
|
---|
642 | $RowActions .= '<a href="'.$URL.'"><img alt="'.$Action['Caption'].'" title="'.$Action['Caption'].'" src="'.
|
---|
643 | $this->System->Link('/images/action.png').'"/></a>';
|
---|
644 | }
|
---|
645 | }
|
---|
646 | $Output .= '<div style="text-align: center;">'.$FormClass['Title'].'</div>';
|
---|
647 | $Output .= '<ul class="ActionMenu">';
|
---|
648 | $Output .= '<li>'.$this->ShowAction('Přidat', '?a=add&t='.$Table.'&preset'.$ExcludeColumn.'='.$ExcludeValue, $this->System->Link('/images/add.png')).'</li>';
|
---|
649 | $Output .= '<li>'.$this->ShowAction('Seznam', '?a=list&t='.$Table, $this->System->Link('/images/list.png')).'</li>';
|
---|
650 | $MI = 0;
|
---|
651 | if(array_key_exists('mi', $_GET))
|
---|
652 | {
|
---|
653 | $DbResult = $this->Database->select('MenuItemFavorite', 'Id', '(`MenuItem`='.($_GET['mi'] * 1).') AND (`User`='.$this->System->User->User['Id'].')');
|
---|
654 | if($DbResult->num_rows > 0)
|
---|
655 | {
|
---|
656 | $DbRow = $DbResult->fetch_assoc();
|
---|
657 | $Fav = $DbRow['Id'];
|
---|
658 | $Output .= '<li>'.$this->ShowAction('Odebrat z oblíbených', '?a=fav_del&t='.$Table.'&i='.$_GET['mi'].'&mi='.$_GET['mi'],
|
---|
659 | $this->System->Link('/images/Favorite-Del.png')).'</li>';
|
---|
660 | } else $Output .= '<li>'.$this->ShowAction('Přidat do oblíbených', '?a=fav_add&t='.$Table.'&i='.$_GET['mi'].'&mi='.$_GET['mi'],
|
---|
661 | $this->System->Link('/images/Favorite-Add.png')).'</li>';
|
---|
662 | }
|
---|
663 | if(array_key_exists('Actions', $FormClass))
|
---|
664 | {
|
---|
665 | foreach($FormClass['Actions'] as $Action)
|
---|
666 | $Output .= '<li>'.$this->ShowAction($Action['Caption'], $this->System->Link($Action['URL']),
|
---|
667 | $this->System->Link('/images/action.png')).'</li>';
|
---|
668 | }
|
---|
669 | $Output .= '</ul>';
|
---|
670 | $Output .= $this->ShowTable($Table, $Filter, $Title, $RowActions, $ExcludeColumn);
|
---|
671 | return($Output);
|
---|
672 | }
|
---|
673 |
|
---|
674 | function ShowFavorites()
|
---|
675 | {
|
---|
676 | $this->MenuItems = array();
|
---|
677 | $DbResult = $this->Database->query('SELECT `MenuItem`.`Id`, `MenuItem`.`Name`, `MenuItem`.`Parent`, `Action`.`URL` AS `URL`, `ActionIcon`.`Name` AS `IconName`, `Action`.`PermissionOperation` AS `Permission` FROM `MenuItemFavorite` ' .
|
---|
678 | 'LEFT JOIN `MenuItem` ON `MenuItem`.`Id` = `MenuItemFavorite`.`MenuItem` '.
|
---|
679 | 'LEFT JOIN `Action` ON `Action`.`Id` = `MenuItem`.`Action` '.
|
---|
680 | 'LEFT JOIN `ActionIcon` ON `ActionIcon`.`Id` = `Action`.`Icon` '.
|
---|
681 | 'WHERE `MenuItemFavorite`.`User`='.$this->System->User->User['Id'].' '.
|
---|
682 | 'ORDER BY `MenuItem`.`Parent`,`MenuItem`.`Name`');
|
---|
683 | while($DbRow = $DbResult->fetch_assoc())
|
---|
684 | {
|
---|
685 | //if($DbRow['Permission'] != '')
|
---|
686 | $this->MenuItems[$DbRow['Id']] = $DbRow;
|
---|
687 | }
|
---|
688 | return($this->ShowMenuItem('', true));
|
---|
689 | }
|
---|
690 |
|
---|
691 | function ShowMenu()
|
---|
692 | {
|
---|
693 | $this->MenuItems = array();
|
---|
694 | $DbResult = $this->Database->query('SELECT `MenuItem`.`Id`, `MenuItem`.`Name`, `MenuItem`.`Parent`, `Action`.`URL` AS `URL`, `ActionIcon`.`Name` AS `IconName`, `Action`.`PermissionOperation` AS `Permission` FROM `MenuItem` '.
|
---|
695 | 'LEFT JOIN `Action` ON `Action`.`Id` = `MenuItem`.`Action` '.
|
---|
696 | 'LEFT JOIN `ActionIcon` ON `ActionIcon`.`Id` = `Action`.`Icon` '.
|
---|
697 | 'WHERE `MenuItem`.`Menu`=1 '.
|
---|
698 | 'ORDER BY `MenuItem`.`Parent`,`MenuItem`.`Name`');
|
---|
699 | while($DbRow = $DbResult->fetch_assoc())
|
---|
700 | {
|
---|
701 | //if($DbRow['Permission'] != '')
|
---|
702 | $this->MenuItems[$DbRow['Id']] = $DbRow;
|
---|
703 | }
|
---|
704 | return($this->ShowMenuItem(''));
|
---|
705 | }
|
---|
706 |
|
---|
707 | function ShowMenuItem($Parent, $All = false)
|
---|
708 | {
|
---|
709 | $Output = '<ul style="list-style: none; margin-left:1em; padding-left:0em;">';
|
---|
710 | foreach($this->MenuItems as $MenuItem)
|
---|
711 | if(($MenuItem['Parent'] == $Parent) or $All)
|
---|
712 | {
|
---|
713 | $LinkTitle = $MenuItem['Name'];
|
---|
714 | if($MenuItem['URL'] != '')
|
---|
715 | {
|
---|
716 | $Icon = 'Device.png';
|
---|
717 | if(substr($MenuItem['URL'], 0, 4) != 'http') $MenuItem['URL'] = $this->System->Link($MenuItem['URL']);
|
---|
718 | $LinkTitle = MakeLink($MenuItem['URL'].'&mi='.$MenuItem['Id'], $LinkTitle);
|
---|
719 | } else $Icon = 'Folder.png';
|
---|
720 | if($MenuItem['IconName'] != '') $Image = '<img src="'.$this->System->Link('/images/favicons/'.$MenuItem['IconName']).'"/> ';
|
---|
721 | else $Image = '<img src="'.$this->System->Link('/images/favicons/'.$Icon).'"/> ';
|
---|
722 | //if($this->System->User->CheckPermission($this->TableToModule($Table), 'Write') or !defined('NEW_PERMISSION'))
|
---|
723 | $Output .= '<li>'.$Image.$LinkTitle.'</li>';
|
---|
724 | if($All == false) $Output .= $this->ShowMenuItem($MenuItem['Id']);
|
---|
725 | }
|
---|
726 | $Output .= '</ul>';
|
---|
727 | return($Output);
|
---|
728 | }
|
---|
729 |
|
---|
730 | function TableToModule($Table)
|
---|
731 | {
|
---|
732 | $DbResult = $this->Database->query('SELECT (SELECT `Name` FROM `Module` '.
|
---|
733 | 'WHERE `Module`.`Id`=`Model`.`Module`) AS `Name` FROM `Model` WHERE `Name`="'.$Table.'"');
|
---|
734 | if($DbResult->num_rows == 1)
|
---|
735 | {
|
---|
736 | $DbRow = $DbResult->fetch_assoc();
|
---|
737 | return($DbRow['Name']);
|
---|
738 | } else return('');
|
---|
739 | }
|
---|
740 |
|
---|
741 | function ShowAction($Name, $Target, $Icon, $Confirm = '')
|
---|
742 | {
|
---|
743 | $Output = '<img alt="'.$Name.'" title="'.$Name.'" src="'.
|
---|
744 | $Icon.'"/>';
|
---|
745 | if($this->ShowActionName) $Output .= $Name;
|
---|
746 | if($Confirm != '')
|
---|
747 | $Confirm = ' onclick="return confirmAction(\''.$Confirm.'\');"';
|
---|
748 | $Output = '<a href="'.$Target.'"'.$Confirm.'>'.$Output.'</a>';
|
---|
749 | return($Output);
|
---|
750 | }
|
---|
751 | }
|
---|
752 |
|
---|
753 | class ModuleIS extends AppModule
|
---|
754 | {
|
---|
755 | function __construct($System)
|
---|
756 | {
|
---|
757 | parent::__construct($System);
|
---|
758 | $this->Name = 'IS';
|
---|
759 | $this->Title = 'Information system';
|
---|
760 | $this->Version = '1.0';
|
---|
761 | $this->Creator = 'Chronos';
|
---|
762 | $this->License = 'GNU/GPLv3';
|
---|
763 | $this->Description = 'User interface for generic information system';
|
---|
764 | $this->Dependencies = array();
|
---|
765 | }
|
---|
766 |
|
---|
767 | function DoInstall()
|
---|
768 | {
|
---|
769 | }
|
---|
770 |
|
---|
771 | function DoUninstall()
|
---|
772 | {
|
---|
773 | }
|
---|
774 |
|
---|
775 | function DoStart()
|
---|
776 | {
|
---|
777 | $this->System->RegisterPage('is', 'PageIS');
|
---|
778 | $this->System->FormManager->RegisterClass('MenuItem', array(
|
---|
779 | 'Title' => 'Položky nabídky',
|
---|
780 | 'Table' => 'MenuItem',
|
---|
781 | 'Items' => array(
|
---|
782 | 'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''),
|
---|
783 | 'Parent' => array('Type' => 'TMenuItem', 'Caption' => 'Rodič', 'Default' => '', 'Null' => true),
|
---|
784 | 'Action' => array('Type' => 'TAction', 'Caption' => 'Akce', 'Default' => ''),
|
---|
785 | 'Menu' => array('Type' => 'TMenu', 'Caption' => 'Nabídka', 'Default' => ''),
|
---|
786 | 'Items' => array('Type' => 'TMenuItemListParent', 'Caption' => 'Položky'),
|
---|
787 | ),
|
---|
788 | ));
|
---|
789 | $this->System->FormManager->RegisterClass('MenuItemFavorite', array(
|
---|
790 | 'Title' => 'Oblíbené položky nabídky',
|
---|
791 | 'Table' => 'MenuItemFavorite',
|
---|
792 | 'Items' => array(
|
---|
793 | 'User' => array('Type' => 'TUser', 'Caption' => 'Uživatele', 'Default' => '0'),
|
---|
794 | 'MenuItem' => array('Type' => 'TMenuItem', 'Caption' => 'Položka nabídky', 'Default' => '0'),
|
---|
795 | ),
|
---|
796 | ));
|
---|
797 | $this->System->FormManager->RegisterClass('Menu', array(
|
---|
798 | 'Title' => 'Nabídky',
|
---|
799 | 'Table' => 'Menu',
|
---|
800 | 'Items' => array(
|
---|
801 | 'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''),
|
---|
802 | 'Items' => array('Type' => 'TMenuItemListMenu', 'Caption' => 'Položky'),
|
---|
803 | ),
|
---|
804 | ));
|
---|
805 | $this->System->FormManager->RegisterFormType('TMenuItem', array(
|
---|
806 | 'Type' => 'Reference',
|
---|
807 | 'Table' => 'MenuItem',
|
---|
808 | 'Id' => 'Id',
|
---|
809 | 'Name' => 'Name',
|
---|
810 | 'Filter' => '1',
|
---|
811 | ));
|
---|
812 | $this->System->FormManager->RegisterFormType('TMenu', array(
|
---|
813 | 'Type' => 'Reference',
|
---|
814 | 'Table' => 'Menu',
|
---|
815 | 'Id' => 'Id',
|
---|
816 | 'Name' => 'Name',
|
---|
817 | 'Filter' => '1',
|
---|
818 | ));
|
---|
819 | }
|
---|
820 |
|
---|
821 | function DoStop()
|
---|
822 | {
|
---|
823 | }
|
---|
824 | }
|
---|