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 = array();
|
---|
11 | var $MenuItemsLoaded = false;
|
---|
12 | var $HideMenu = false;
|
---|
13 |
|
---|
14 | function Show()
|
---|
15 | {
|
---|
16 | if(!$this->System->User->CheckPermission('IS', 'Manage'))
|
---|
17 | return('Nemáte oprávnění');
|
---|
18 |
|
---|
19 | if(array_key_exists('a', $_GET)) $Action = $_GET['a'];
|
---|
20 | else $Action = '';
|
---|
21 | if(array_key_exists('t', $_GET)) $Table = $_GET['t'];
|
---|
22 | else $Table = '';
|
---|
23 | if(array_key_exists('i', $_GET)) $ItemId = $_GET['i'];
|
---|
24 | else $ItemId = 0;
|
---|
25 |
|
---|
26 | if($Action == 'list') $Content = $this->ShowList($Table);
|
---|
27 | else if($Action == 'select') $Content = $this->ShowSelect($Table);
|
---|
28 | else if($Action == 'edit') $Content = $this->ShowEdit($Table, $ItemId);
|
---|
29 | else if($Action == 'add') $Content = $this->ShowAdd($Table);
|
---|
30 | else if($Action == 'view') $Content = $this->ShowView($Table, $ItemId);
|
---|
31 | else if($Action == 'delete') $Content = $this->ShowDelete($Table, $ItemId);
|
---|
32 | else $Content = $this->Dashboard();
|
---|
33 | if($this->HideMenu == false)
|
---|
34 | {
|
---|
35 | $Output = '<table style="width: 100%"><tr><td style="width: 20%; vertical-align: top;">';
|
---|
36 | $Output .= '<strong>Nabídka:</strong>'.$this->ShowMenuItem('');
|
---|
37 | $Output .= '</td><td style="width: 80%; vertical-align: top;">';
|
---|
38 | $Output .= $Content;
|
---|
39 | $Output .= '</td></tr></table>';
|
---|
40 | } else $Output = $Content;
|
---|
41 |
|
---|
42 | return($Output);
|
---|
43 | }
|
---|
44 |
|
---|
45 | function Dashboard()
|
---|
46 | {
|
---|
47 | $Output = '<strong>Nástěnka:</strong><br/>';
|
---|
48 | $DbResult = $this->Database->select('Task', 'COUNT(*)', 'Progress < 100');
|
---|
49 | $DbRow = $DbResult->fetch_row();
|
---|
50 | $Output .= 'Nedokončených úkolů: '.$DbRow['0'].'<br/>';
|
---|
51 | $DbResult = $this->Database->select('Member', 'COUNT(*)', '1');
|
---|
52 | $DbRow = $DbResult->fetch_row();
|
---|
53 | $Output .= 'Zákazníků: '.$DbRow['0'].'<br/>';
|
---|
54 | $DbResult = $this->Database->select('Subject', 'COUNT(*)', '1');
|
---|
55 | $DbRow = $DbResult->fetch_row();
|
---|
56 | $Output .= 'Subjektů: '.$DbRow['0'].'<br/>';
|
---|
57 | $DbResult = $this->Database->select('User', 'COUNT(*)', '1');
|
---|
58 | $DbRow = $DbResult->fetch_row();
|
---|
59 | $Output .= 'Uživatelů: '.$DbRow['0'].'<br/>';
|
---|
60 | $DbResult = $this->Database->select('NetworkDevice', 'COUNT(*)', '1');
|
---|
61 | $DbRow = $DbResult->fetch_row();
|
---|
62 | $Output .= 'Registrovaných zařízení: '.$DbRow['0'].'<br/>';
|
---|
63 | $DbResult = $this->Database->select('FinanceOperation', 'SUM(Value)', '1');
|
---|
64 | $DbRow = $DbResult->fetch_row();
|
---|
65 | $Output .= 'Stav placení: '.$DbRow['0'].'<br/>';
|
---|
66 | return($Output);
|
---|
67 | }
|
---|
68 |
|
---|
69 | function ShowEdit($Table, $Id)
|
---|
70 | {
|
---|
71 | $Output = '';
|
---|
72 | if(array_key_exists('o', $_GET))
|
---|
73 | {
|
---|
74 | if($_GET['o'] == 'save')
|
---|
75 | {
|
---|
76 | $Form = new Form($this->System->FormManager);
|
---|
77 | $Form->SetClass($Table);
|
---|
78 | $Form->LoadValuesFromForm();
|
---|
79 | $Form->SaveValuesToDatabase($Id);
|
---|
80 | $Output .= $this->SystemMessage('Úprava položky', 'Položka upravena');
|
---|
81 | $Output .= $this->ShowView($Table, $Id);
|
---|
82 | }
|
---|
83 | } else
|
---|
84 | {
|
---|
85 | $Form = new Form($this->System->FormManager);
|
---|
86 | $Form->SetClass($Table);
|
---|
87 | $Form->LoadValuesFromDatabase($Id);
|
---|
88 | $Form->OnSubmit = '?a=edit&t='.$Table.'&i='.$_GET['i'].'&o=save';
|
---|
89 | $Output .= $Form->ShowEditForm();
|
---|
90 | $Output .= '<ul class="ActionMenu">';
|
---|
91 | $Output .= '<li><a href="?a=view&t='.$Table.'&i='.$Id.'"><img alt="Prohlížet" title="Prohlížet" src="'.
|
---|
92 | $this->System->Link('/images/view.png').'"/>Prohlížet</a></li>';
|
---|
93 | $Output .= '<li><a href="?a=list&t='.$Table.'"><img alt="Seznam" title="Seznam" src="'.
|
---|
94 | $this->System->Link('/images/list.png').'"/>Seznam</a></li>';
|
---|
95 | $Output .= '<li><a href="?a=delete&t='.$Table.'&i='.$Id.'" onclick="return confirmAction(\'Opravdu smazat položku?\');"><img alt="Odstranit" title="Odstranit" src="'.
|
---|
96 | $this->System->Link('/images/delete.png').'"/>Odstranit</a></li>';
|
---|
97 | $Output .= '</ul>';
|
---|
98 | }
|
---|
99 | return($Output);
|
---|
100 | }
|
---|
101 |
|
---|
102 | function ShowDelete($Table, $Id)
|
---|
103 | {
|
---|
104 | $Output = '';
|
---|
105 | $this->Database->delete($Table, 'Id='.$Id);
|
---|
106 | $Output .= $this->SystemMessage('Odstranění položky', 'Položka odstraněna');
|
---|
107 | $Output .= $this->ShowList($Table);
|
---|
108 | return($Output);
|
---|
109 | }
|
---|
110 |
|
---|
111 | function ShowAdd($Table)
|
---|
112 | {
|
---|
113 | $Output = '';
|
---|
114 | if(array_key_exists('o', $_GET))
|
---|
115 | {
|
---|
116 | if($_GET['o'] == 'save')
|
---|
117 | {
|
---|
118 | $Form = new Form($this->System->FormManager);
|
---|
119 | $Form->SetClass($Table);
|
---|
120 | $Form->LoadValuesFromForm();
|
---|
121 | $Form->SaveValuesToDatabase(0);
|
---|
122 | $Output .= $this->SystemMessage('Přidání položky', 'Nová položka vytvořena');
|
---|
123 | $Id = $this->Database->insert_id;
|
---|
124 | //$this->Database->update($Table, 'Id='.$Id,
|
---|
125 | // array('UserCreate' => $this->System->User->User['Id'],
|
---|
126 | // 'TimeCreate' => 'NOW()'));
|
---|
127 | $Output .= $this->ShowView($Table, $Id);
|
---|
128 | }
|
---|
129 | } else
|
---|
130 | {
|
---|
131 | $Form = new Form($this->System->FormManager);
|
---|
132 | $Form->SetClass($Table);
|
---|
133 | $Form->OnSubmit = '?a=add&t='.$Table.'&o=save';
|
---|
134 | $Output .= $Form->ShowEditForm();
|
---|
135 | $Output .= '<ul class="ActionMenu">';
|
---|
136 | $Output .= '<li><a href="?a=list&t='.$Table.'"><img alt="Seznam" title="Seznam" src="'.
|
---|
137 | $this->System->Link('/images/list.png').'"/>Seznam</a></li>';
|
---|
138 | $Output .= '</ul>';
|
---|
139 | }
|
---|
140 | return($Output);
|
---|
141 | }
|
---|
142 |
|
---|
143 | function ShowView($Table, $Id)
|
---|
144 | {
|
---|
145 | if($Table != '') $FormClass = $this->System->FormManager->Classes[$Table];
|
---|
146 | else return($this->SystemMessage('Chyba', 'Tabulka nenalezena'));
|
---|
147 |
|
---|
148 | $Form = new Form($this->System->FormManager);
|
---|
149 | $Form->SetClass($Table);
|
---|
150 | $Form->LoadValuesFromDatabase($Id);
|
---|
151 | $Form->OnSubmit = '?a=view';
|
---|
152 | $Output = $Form->ShowViewForm();
|
---|
153 | $Output .= '<ul class="ActionMenu">';
|
---|
154 | $Output .= '<li><a href="?a=edit&t='.$Table.'&i='.$Id.'"><img alt="Upravit" title="Upravit" src="'.
|
---|
155 | $this->System->Link('/images/edit.png').'"/>Upravit</a></li>';
|
---|
156 | $Output .= '<li><a href="?a=list&t='.$Table.'"><img alt="Seznam" title="Seznam" src="'.
|
---|
157 | $this->System->Link('/images/list.png').'"/>Seznam</a></li>';
|
---|
158 | $Output .= '<li><a href="?a=delete&t='.$Table.'&i='.$Id.'" onclick="return confirmAction(\'Opravdu smazat položku?\');"><img alt="Odstranit" title="Odstranit" src="'.
|
---|
159 | $this->System->Link('/images/delete.png').'" />Odstranit</a></li>';
|
---|
160 | $Output .= '<li><a href="?a=add&t='.$Table.'"><img alt="Přidat" title="Přidat" src="'.
|
---|
161 | $this->System->Link('/images/add.png').'"/>Přidat</a></li>';
|
---|
162 | if(array_key_exists('ItemActions', $FormClass))
|
---|
163 | {
|
---|
164 | foreach($FormClass['ItemActions'] as $Action)
|
---|
165 | $Output .= '<li><a href="'.$this->System->Link($Action['URL']).'&i='.$Id.'"><img alt="'.$Action['Caption'].'" title="'.$Action['Caption'].'" src="'.
|
---|
166 | $this->System->Link('/images/action.png').'"/>'.$Action['Caption'].'</a></li>';
|
---|
167 | }
|
---|
168 | $Output .= '</ul><br/>';
|
---|
169 |
|
---|
170 | // Show ManyToOne relations
|
---|
171 | foreach($Form->Definition['Items'] as $Index => $Item)
|
---|
172 | if((array_key_exists($Item['Type'], $this->System->FormManager->FormTypes) and
|
---|
173 | ($this->System->FormManager->FormTypes[$Item['Type']]['Type'] == 'ManyToOne')))
|
---|
174 | {
|
---|
175 | $Output .= $this->ShowList($this->System->FormManager->FormTypes[$Item['Type']]['Table'], '`'.
|
---|
176 | $this->System->FormManager->FormTypes[$Item['Type']]['Ref'].'`='.$Id, $Item['Caption']).'<br/>';
|
---|
177 | }
|
---|
178 | return($Output);
|
---|
179 | }
|
---|
180 |
|
---|
181 | function ShowTable($Table, $Filter = '', $Title = '', $RowActions = array())
|
---|
182 | {
|
---|
183 | if($Table != '') $FormClass = $this->System->FormManager->Classes[$Table];
|
---|
184 | else return($this->SystemMessage('Chyba', 'Tabulka nenalezena'));
|
---|
185 |
|
---|
186 | // Build user filter
|
---|
187 | $UserFilter = '';
|
---|
188 | $Columns = array('Id' => '`Id`');
|
---|
189 | if(array_key_exists('filter', $_GET) and ($_GET['filter'] == 1))
|
---|
190 | {
|
---|
191 | foreach($FormClass['Items'] as $ItemIndex => $FormItem)
|
---|
192 | if(!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or
|
---|
193 | (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) and
|
---|
194 | ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne')))
|
---|
195 | {
|
---|
196 | $UseType = $UseType = $FormItem['Type'];
|
---|
197 | if(array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes))
|
---|
198 | {
|
---|
199 | if(!array_key_exists($FormItem['Type'], $this->System->FormManager->Type->TypeDefinitionList))
|
---|
200 | $this->System->FormManager->Type->RegisterType($FormItem['Type'], '',
|
---|
201 | $this->System->FormManager->FormTypes[$FormItem['Type']]);
|
---|
202 | if($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] == 'Reference')
|
---|
203 | $UseType = 'OneToMany';
|
---|
204 | else
|
---|
205 | if($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] == 'Enumeration')
|
---|
206 | $UseType = 'Enumeration';
|
---|
207 | }
|
---|
208 | $FilterName = $this->System->FormManager->Type->ExecuteTypeEvent($UseType, 'OnFilterName',
|
---|
209 | array('Name' => $ItemIndex, 'Type' => $FormItem['Type']));
|
---|
210 | if(array_key_exists('Filter'.$ItemIndex, $_POST) and ($_POST['Filter'.$ItemIndex] != ''))
|
---|
211 | $UserFilter .= ' AND ('.$FilterName.' LIKE "%'.$_POST['Filter'.$ItemIndex].'%")';
|
---|
212 | }
|
---|
213 | }
|
---|
214 | if(($Filter == '') and ($UserFilter != '')) $Filter = '1 '.$UserFilter;
|
---|
215 | if($Filter != '') $Filter = ' WHERE '.$Filter;
|
---|
216 |
|
---|
217 | foreach($FormClass['Items'] as $ItemIndex => $FormItem)
|
---|
218 | if(!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or
|
---|
219 | (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) and
|
---|
220 | ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne')))
|
---|
221 | {
|
---|
222 | $TableColumns[] = array('Name' => $ItemIndex, 'Title' => $FormItem['Caption']);
|
---|
223 | $UseType = $UseType = $FormItem['Type'];
|
---|
224 | if(array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes))
|
---|
225 | {
|
---|
226 | if(!array_key_exists($FormItem['Type'], $this->System->FormManager->Type->TypeDefinitionList))
|
---|
227 | $this->System->FormManager->Type->RegisterType($FormItem['Type'], '',
|
---|
228 | $this->System->FormManager->FormTypes[$FormItem['Type']]);
|
---|
229 | if($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] == 'Reference')
|
---|
230 | $UseType = 'OneToMany';
|
---|
231 | else
|
---|
232 | if($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] == 'Enumeration')
|
---|
233 | $UseType = 'Enumeration';
|
---|
234 | }
|
---|
235 | if(array_key_exists('Filter'.$ItemIndex, $_POST) and ($_POST['Filter'.$ItemIndex] != ''))
|
---|
236 | $Value = $_POST['Filter'.$ItemIndex];
|
---|
237 | else $Value = '';
|
---|
238 | if($ItemIndex == 'Id') unset($Columns['Id']);
|
---|
239 | $Columns[] = $this->System->FormManager->Type->ExecuteTypeEvent($UseType, 'OnFilterNameQuery',
|
---|
240 | array('Value' => $Value, 'Name' => $ItemIndex,
|
---|
241 | 'Type' => $FormItem['Type']));
|
---|
242 | }
|
---|
243 |
|
---|
244 | // Get total item count in database
|
---|
245 | $Query = 'SELECT COUNT(*) FROM `'.$FormClass['Table'].'`';
|
---|
246 | $DbResult = $this->Database->query($Query);
|
---|
247 | $DbRow = $DbResult->fetch_assoc();
|
---|
248 | $TotalCount = $DbRow['COUNT(*)'];
|
---|
249 |
|
---|
250 | // Get total filtered item count in database
|
---|
251 | $Columns = implode(',', $Columns);
|
---|
252 | if($UserFilter != '')
|
---|
253 | {
|
---|
254 | $Query = 'SELECT COUNT(*) FROM (SELECT '.$Columns.' FROM `'.$FormClass['Table'].'`) AS `TS` '.$Filter;
|
---|
255 | $DbResult = $this->Database->query($Query);
|
---|
256 | $DbRow = $DbResult->fetch_row();
|
---|
257 | $TotalFilteredCount = $DbRow[0];
|
---|
258 | } else $TotalFilteredCount = $TotalCount;
|
---|
259 | $PageList = GetPageList($TotalFilteredCount);
|
---|
260 |
|
---|
261 | $Output = '<div style="text-align: center;">'.$FormClass['Title'].'</div>';
|
---|
262 | $Output .= $PageList['Output'];
|
---|
263 | $Output .= '<table class="WideTable" style="font-size: small;">';
|
---|
264 |
|
---|
265 | $TableColumns[] = array('Name' => '', 'Title' => 'Akce');
|
---|
266 | if(!array_key_exists('DefaultSortColumn', $FormClass))
|
---|
267 | $FormClass['DefaultSortColumn'] = 'Id';
|
---|
268 | $Order = GetOrderTableHeader($TableColumns, $FormClass['DefaultSortColumn'], 0);
|
---|
269 | $Output .= $Order['Output'];
|
---|
270 |
|
---|
271 | // Show search fields
|
---|
272 | $Output .= '<tr><form action="?a=list&t='.$Table.'&filter=1" method="post">';
|
---|
273 | foreach($FormClass['Items'] as $ItemIndex => $FormItem)
|
---|
274 | if(!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or
|
---|
275 | (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) and
|
---|
276 | ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne')))
|
---|
277 | {
|
---|
278 | if(array_key_exists('Filter'.$ItemIndex, $_POST) and ($_POST['Filter'.$ItemIndex] != ''))
|
---|
279 | $Value = $_POST['Filter'.$ItemIndex];
|
---|
280 | else $Value = '';
|
---|
281 | $Output .= '<td><input type="text" name="Filter'.$ItemIndex.'" value="'.$Value.'" style="width: 100%"/></td>';
|
---|
282 | }
|
---|
283 | $Output .= '<td><input type="Submit" value="Hledat"/></td></form></tr>';
|
---|
284 |
|
---|
285 | // Load and show items
|
---|
286 | $Query = 'SELECT * FROM (SELECT '.$Columns.' FROM `'.$FormClass['Table'].'`) AS `TS` '.$Filter.' '.$Order['SQL'].$PageList['SQLLimit'];
|
---|
287 | $VisibleItemCount = 0;
|
---|
288 | $DbResult = $this->Database->query($Query);
|
---|
289 | while($Row = $DbResult->fetch_assoc())
|
---|
290 | {
|
---|
291 | $Output .= '<tr>';
|
---|
292 | foreach($FormClass['Items'] as $ItemIndex => $FormItem)
|
---|
293 | if(!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or
|
---|
294 | (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) and
|
---|
295 | ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne')))
|
---|
296 | {
|
---|
297 | //$Output .= '<td>'.$Row[$ItemIndex].'</td>';
|
---|
298 | $UseType = $UseType = $FormItem['Type'];
|
---|
299 | if(array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes))
|
---|
300 | {
|
---|
301 | if(!array_key_exists($FormItem['Type'], $this->System->FormManager->Type->TypeDefinitionList))
|
---|
302 | $this->System->FormManager->Type->RegisterType($FormItem['Type'], '',
|
---|
303 | $this->System->FormManager->FormTypes[$FormItem['Type']]);
|
---|
304 | if($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] == 'Reference')
|
---|
305 | $UseType = 'OneToMany';
|
---|
306 | else
|
---|
307 | if($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] == 'Enumeration')
|
---|
308 | $UseType = 'Enumeration';
|
---|
309 | }
|
---|
310 | $Row[$ItemIndex] = $this->System->FormManager->Type->ExecuteTypeEvent($UseType, 'OnLoadDb',
|
---|
311 | array('Value' => $Row[$ItemIndex], 'Name' => $ItemIndex,
|
---|
312 | 'Type' => $FormItem['Type']));
|
---|
313 | $Value = $this->System->FormManager->Type->ExecuteTypeEvent($UseType, 'OnView',
|
---|
314 | array('Value' => $Row[$ItemIndex], 'Name' => $ItemIndex,
|
---|
315 | 'Type' => $FormItem['Type'], 'Filter' => $Row[$ItemIndex.'_Filter']));
|
---|
316 | if($Value == '') $Value = ' ';
|
---|
317 | $Output .= '<td>'.$Value.'</td>';
|
---|
318 | }
|
---|
319 | $Output .= '<td>'.str_replace('#RowId', $Row['Id'], $RowActions).'</td></tr>';
|
---|
320 | $VisibleItemCount = $VisibleItemCount + 1;
|
---|
321 | }
|
---|
322 | $Output .= '<tr><td colspan="'.count($TableColumns).'" style="text-align: right;">Zobrazeno <strong>'.$VisibleItemCount.'</strong>';
|
---|
323 | if($UserFilter != '') $Output .= ' z filtrovaných <strong>'.$TotalFilteredCount.'</strong>';
|
---|
324 | $Output .= ' z celkem <strong>'.$TotalCount.'</strong></td></tr>';
|
---|
325 | $Output .= '</table>';
|
---|
326 | $Output .= $PageList['Output'];
|
---|
327 | return($Output);
|
---|
328 | }
|
---|
329 |
|
---|
330 | function ShowSelect($Table, $Filter = '', $Title = '')
|
---|
331 | {
|
---|
332 | $this->BasicHTML = true;
|
---|
333 | $this->HideMenu = true;
|
---|
334 | $RowActions = '<a href="javascript:window.close();" onclick="set_return(#RowId,"'.$_GET['r'].'");"><img alt="Vybrat" title="Vybrat" src="'.
|
---|
335 | $this->System->Link('/images/select.png').'"/></a>';
|
---|
336 | $Output = $this->ShowTable($Table, $Filter, $Title, $RowActions);
|
---|
337 | return($Output);
|
---|
338 | }
|
---|
339 |
|
---|
340 | function ShowList($Table, $Filter = '', $Title = '')
|
---|
341 | {
|
---|
342 | $RowActions = '<a href="?a=view&t='.$Table.'&i=#RowId"><img alt="Ukázat" title="Ukázat" src="'.
|
---|
343 | $this->System->Link('/images/view.png').'"/></a>'.
|
---|
344 | '<a href="?a=edit&t='.$Table.'&i=#RowId"><img alt="Upravit" title="Upravit" src="'.
|
---|
345 | $this->System->Link('/images/edit.png').'"/></a>'.
|
---|
346 | '<a href="?a=delete&t='.$Table.'&i=#RowId"><img alt="Smazat" title="Smazat" src="'.
|
---|
347 | $this->System->Link('/images/delete.png').'" onclick="return confirmAction(\'Opravdu smazat položku?\');"/></a>';
|
---|
348 | if($Table != '') $FormClass = $this->System->FormManager->Classes[$Table];
|
---|
349 | else return($this->SystemMessage('Chyba', 'Tabulka nenalezena'));
|
---|
350 | if(array_key_exists('ItemActions', $FormClass))
|
---|
351 | {
|
---|
352 | foreach($FormClass['ItemActions'] as $Action)
|
---|
353 | $RowActions .= '<a href="'.$this->System->Link($Action['URL']).'&i=#RowId"><img alt="'.$Action['Caption'].'" title="'.$Action['Caption'].'" src="'.
|
---|
354 | $this->System->Link('/images/action.png').'"/></a>';
|
---|
355 | }
|
---|
356 | $Output = $this->ShowTable($Table, $Filter, $Title, $RowActions);
|
---|
357 | $Output .= '<ul class="ActionMenu">';
|
---|
358 | $Output .= '<li><a href="?a=add&t='.$Table.'"><img alt="Přidat" title="Přidat" src="'.
|
---|
359 | $this->System->Link('/images/add.png').'"/>Přidat</a></li>';
|
---|
360 | $Output .= '<li><a href="?a=list&t='.$Table.'"><img alt="Seznam" title="Seznam" src="'.
|
---|
361 | $this->System->Link('/images/list.png').'"/>Seznam</a></li>';
|
---|
362 | if(array_key_exists('Actions', $FormClass))
|
---|
363 | {
|
---|
364 | foreach($FormClass['Actions'] as $Action)
|
---|
365 | $Output .= '<li><a href="'.$this->System->Link($Action['URL']).'"><img alt="'.$Action['Caption'].'" title="'.$Action['Caption'].'" src="'.
|
---|
366 | $this->System->Link('/images/action.png').'"/>'.$Action['Caption'].'</a></li>';
|
---|
367 | }
|
---|
368 | $Output .= '</ul>';
|
---|
369 | return($Output);
|
---|
370 | }
|
---|
371 |
|
---|
372 | function ShowMenuItem($Parent)
|
---|
373 | {
|
---|
374 | if($this->MenuItemsLoaded == false)
|
---|
375 | {
|
---|
376 | $DbResult = $this->Database->query('SELECT `MenuItem`.`Id`, `MenuItem`.`Name`, `MenuItem`.`Parent`, `Action`.`URL` AS `URL`, `ActionIcon`.`Name` AS `IconName` FROM `MenuItem` '.
|
---|
377 | 'LEFT JOIN `Action` ON `Action`.`Id` = `MenuItem`.`Action` '.
|
---|
378 | 'LEFT JOIN `ActionIcon` ON `ActionIcon`.`Id` = `Action`.`Icon` '.
|
---|
379 | 'ORDER BY `MenuItem`.`Parent`,`MenuItem`.`Name`');
|
---|
380 | while($DbRow = $DbResult->fetch_assoc())
|
---|
381 | {
|
---|
382 | $this->MenuItems[$DbRow['Id']] = $DbRow;
|
---|
383 | }
|
---|
384 | $this->MenuItemsLoaded = true;
|
---|
385 | }
|
---|
386 |
|
---|
387 | $Output = '<ul style="list-style: none; margin-left:1em; padding-left:0em;">';
|
---|
388 | foreach($this->MenuItems as $MenuItem)
|
---|
389 | if($MenuItem['Parent'] == $Parent)
|
---|
390 | {
|
---|
391 | $LinkTitle = $MenuItem['Name'];
|
---|
392 | if($MenuItem['URL'] != '')
|
---|
393 | {
|
---|
394 | if(substr($MenuItem['URL'], 0, 4) != 'http') $MenuItem['URL'] = $this->System->Link($MenuItem['URL']);
|
---|
395 | $LinkTitle = MakeLink($MenuItem['URL'], $LinkTitle);
|
---|
396 | }
|
---|
397 | if($MenuItem['IconName'] != '') $Image = '<img src="../images/favicons/'.$MenuItem['IconName'].'"/> ';
|
---|
398 | else $Image = '';
|
---|
399 | $Output .= '<li>'.$Image.$LinkTitle.'</li>';
|
---|
400 | $Output .= $this->ShowMenuItem($MenuItem['Id']);
|
---|
401 | }
|
---|
402 | $Output .= '</ul>';
|
---|
403 | return($Output);
|
---|
404 | }
|
---|
405 | }
|
---|
406 |
|
---|
407 | class ModuleIS extends AppModule
|
---|
408 | {
|
---|
409 | function __construct($System)
|
---|
410 | {
|
---|
411 | parent::__construct($System);
|
---|
412 | $this->Name = 'Information system';
|
---|
413 | $this->Version = '1.0';
|
---|
414 | $this->Creator = 'Chronos';
|
---|
415 | $this->License = 'GNU/GPLv3';
|
---|
416 | $this->Description = 'User interface for generic information system';
|
---|
417 | $this->Dependencies = array();
|
---|
418 | }
|
---|
419 |
|
---|
420 | function Install()
|
---|
421 | {
|
---|
422 | }
|
---|
423 |
|
---|
424 | function Uninstall()
|
---|
425 | {
|
---|
426 | }
|
---|
427 |
|
---|
428 | function Start()
|
---|
429 | {
|
---|
430 | parent::Start();
|
---|
431 | $this->System->RegisterPage('is', 'PageIS');
|
---|
432 | $this->System->FormManager->RegisterClass('MenuItem', array(
|
---|
433 | 'Title' => 'Položky nabídky',
|
---|
434 | 'Table' => 'MenuItem',
|
---|
435 | 'Items' => array(
|
---|
436 | 'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''),
|
---|
437 | 'Parent' => array('Type' => 'TMenuItem', 'Caption' => 'Rodič', 'Default' => '', 'Null' => true),
|
---|
438 | 'Action' => array('Type' => 'TAction', 'Caption' => 'Akce', 'Default' => ''),
|
---|
439 | 'Menu' => array('Type' => 'TMenu', 'Caption' => 'Nabídka', 'Default' => ''),
|
---|
440 | 'Items' => array('Type' => 'TMenuItemListParent', 'Caption' => 'Položky'),
|
---|
441 | ),
|
---|
442 | ));
|
---|
443 | $this->System->FormManager->RegisterClass('Menu', array(
|
---|
444 | 'Title' => 'Nabídky',
|
---|
445 | 'Table' => 'Menu',
|
---|
446 | 'Items' => array(
|
---|
447 | 'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''),
|
---|
448 | 'Items' => array('Type' => 'TMenuItemListMenu', 'Caption' => 'Položky'),
|
---|
449 | ),
|
---|
450 | ));
|
---|
451 |
|
---|
452 | }
|
---|
453 |
|
---|
454 | function Stop()
|
---|
455 | {
|
---|
456 | }
|
---|
457 | }
|
---|
458 |
|
---|
459 | ?>
|
---|