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