Changeset 529 for trunk/Modules/IS/IS.php
- Timestamp:
- Apr 23, 2013, 7:12:53 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/IS/IS.php
r528 r529 9 9 var $ParentClass = 'PagePortal'; 10 10 var $MenuItems = array(); 11 var $HideMenu = false; 11 12 12 13 function Show() … … 22 23 { 23 24 $this->MenuItems[$DbRow['Id']] = $DbRow; 24 } 25 26 $Output = '<table style="width: 100%"><tr><td style="width: 20%; vertical-align: top;">'; 27 $Output .= '<strong>Nabídka:</strong><br/>'.$this->ShowMenuItem(''); 28 $Output .= '</td><td style="width: 80%; vertical-align: top;">'; 25 } 29 26 30 27 if(array_key_exists('t', $_GET)) $_SESSION['Table'] = $_GET['t']; 31 28 if(array_key_exists('a', $_GET)) $_SESSION['Action'] = $_GET['a']; 32 29 if(array_key_exists('id', $_GET)) $_SESSION['Id'] = $_GET['id']; 33 30 if(array_key_exists('r', $_GET)) $_SESSION['Ref'] = $_GET['r']; 31 34 32 if(!array_key_exists('Action', $_SESSION)) $_SESSION['Action'] = 'list'; 35 33 if(!array_key_exists('Id', $_SESSION) or !array_key_exists('Table', $_SESSION) or … … 38 36 $_SESSION['Action'] = ''; 39 37 $_SESSION['Table'] = ''; 40 } 41 42 if($_SESSION['Action'] == 'list') $Output .= $this->ShowList($_SESSION['Table']); 43 else if($_SESSION['Action'] == 'edit') $Output .= $this->ShowEdit($_SESSION['Table'], $_SESSION['Id']); 44 else if($_SESSION['Action'] == 'add') $Output .= $this->ShowAdd($_SESSION['Table']); 45 else if($_SESSION['Action'] == 'view') $Output .= $this->ShowView($_SESSION['Table'], $_SESSION['Id']); 46 else if($_SESSION['Action'] == 'delete') $Output .= $this->ShowDelete($_SESSION['Table'], $_SESSION['Id']); 47 $Output .= '</td></tr></table>'; 38 $_SESSION['Ref'] = ''; 39 } 40 41 if($_SESSION['Action'] == 'list') $Content = $this->ShowList($_SESSION['Table']); 42 else if($_SESSION['Action'] == 'select') $Content = $this->ShowSelect($_SESSION['Table']); 43 else if($_SESSION['Action'] == 'edit') $Content = $this->ShowEdit($_SESSION['Table'], $_SESSION['Id']); 44 else if($_SESSION['Action'] == 'add') $Content = $this->ShowAdd($_SESSION['Table']); 45 else if($_SESSION['Action'] == 'view') $Content = $this->ShowView($_SESSION['Table'], $_SESSION['Id']); 46 else if($_SESSION['Action'] == 'delete') $Content = $this->ShowDelete($_SESSION['Table'], $_SESSION['Id']); 47 else $Content = ''; 48 if($this->HideMenu == false) 49 { 50 $Output = '<table style="width: 100%"><tr><td style="width: 20%; vertical-align: top;">'; 51 $Output .= '<strong>Nabídka:</strong><br/>'.$this->ShowMenuItem(''); 52 $Output .= '</td><td style="width: 80%; vertical-align: top;">'; 53 $Output .= $Content; 54 $Output .= '</td></tr></table>'; 55 } else $Output = $Content; 48 56 49 57 return($Output); … … 70 78 $Form->SetClass($Table); 71 79 $Form->LoadValuesFromDatabase($Id); 72 $Form->OnSubmit = '?a=edit& o=save';80 $Form->OnSubmit = '?a=edit&t='.$Table.'&o=save'; 73 81 $Output .= $Form->ShowEditForm(); 74 82 $Output .= '<ul class="ActionMenu">'; 75 $Output .= '<li><a href="?a=view "><img alt="Prohlížet" title="Prohlížet" src="'.83 $Output .= '<li><a href="?a=view&t='.$Table.'"><img alt="Prohlížet" title="Prohlížet" src="'. 76 84 $this->System->Link('/images/view.png').'"/>Prohlížet</a></li>'; 77 $Output .= '<li><a href="?a=list "><img alt="Seznam" title="Seznam" src="'.85 $Output .= '<li><a href="?a=list&t='.$Table.'"><img alt="Seznam" title="Seznam" src="'. 78 86 $this->System->Link('/images/list.png').'"/>Seznam</a></li>'; 79 $Output .= '<li><a href="?a=delete " onclick="return confirmAction(\'Opravdu smazat položku?\');"><img alt="Odstranit" title="Odstranit" src="'.87 $Output .= '<li><a href="?a=delete&t='.$Table.'" onclick="return confirmAction(\'Opravdu smazat položku?\');"><img alt="Odstranit" title="Odstranit" src="'. 80 88 $this->System->Link('/images/delete.png').'"/>Odstranit</a></li>'; 81 89 $Output .= '</ul>'; … … 118 126 $Form = new Form($this->System->FormManager); 119 127 $Form->SetClass($Table); 120 $Form->OnSubmit = '?a=add& o=save';128 $Form->OnSubmit = '?a=add&t='.$Table.'&o=save'; 121 129 $Output .= $Form->ShowEditForm(); 122 130 $Output .= '<ul class="ActionMenu">'; 123 $Output .= '<li><a href="?a=list "><img alt="Seznam" title="Seznam" src="'.131 $Output .= '<li><a href="?a=list&t='.$Table.'"><img alt="Seznam" title="Seznam" src="'. 124 132 $this->System->Link('/images/list.png').'"/>Seznam</a></li>'; 125 133 $Output .= '</ul>'; … … 166 174 } 167 175 168 function ShowList($Table, $Filter = '', $Title = '') 169 { 176 function ShowSelect($Table, $Filter = '', $Title = '') 177 { 178 $this->BasicHTML = true; 179 $this->HideMenu = true; 170 180 if($Table != '') $FormClass = $this->System->FormManager->Classes[$Table]; 171 181 else return($this->SystemMessage('Chyba', 'Tabulka nenalezena')); … … 174 184 $PageList = GetPageList($DbRow[0]); 175 185 176 $Output = '<div style="text-align: center;">'.$FormClass['Title'].'</div>'; 186 $Output = '<script type="text/javascript"> 187 function set_return(id, obj) 188 { 189 window.opener.document.getElementById(obj).value = id; 190 } 191 </script>'; 192 $Output .= '<div style="text-align: center;">'.$FormClass['Title'].'</div>'; 177 193 $Output .= $PageList['Output']; 178 194 $Output .= '<table class="WideTable" style="font-size: small;">'; … … 204 220 } 205 221 } 206 $Output .= '<tr><form action="?a= list&filter=1" method="post">';222 $Output .= '<tr><form action="?a=select&filter=1" method="post">'; 207 223 foreach($FormClass['Items'] as $ItemIndex => $FormItem) 208 224 if(!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or … … 252 268 $Output .= '<td>'.$Value.'</td>'; 253 269 } 270 $Output .= '<td><a href="javascript:window.close();" onclick="set_return('.$Row['Id'].',"'.$_SESSION['Ref'].'");"><img alt="Vybrat" title="Vybrat" src="'. 271 $this->System->Link('/images/select.png').'"/></a>'; 272 $Output .= '</td></tr>'; 273 } 274 $Output .= '</table>'; 275 $Output .= $PageList['Output']; 276 return($Output); 277 } 278 279 function ShowList($Table, $Filter = '', $Title = '') 280 { 281 if($Table != '') $FormClass = $this->System->FormManager->Classes[$Table]; 282 else return($this->SystemMessage('Chyba', 'Tabulka nenalezena')); 283 284 // Build user filter 285 $UserFilter = ''; 286 if(array_key_exists('filter', $_GET) and ($_GET['filter'] == 1)) 287 { 288 foreach($FormClass['Items'] as $ItemIndex => $FormItem) 289 if(!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or 290 (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) and 291 ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne'))) 292 { 293 if(array_key_exists('Filter'.$ItemIndex, $_POST) and ($_POST['Filter'.$ItemIndex] != '')) 294 $UserFilter .= ' AND (`'.$ItemIndex.'` LIKE "%'.$_POST['Filter'.$ItemIndex].'%")'; 295 } 296 } 297 if(($Filter == '') and ($UserFilter != '')) $Filter = '1 '.$UserFilter; 298 if($Filter != '') $Filter = ' WHERE '.$Filter; 299 300 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `'.$FormClass['Table'].'`'.$Filter); 301 $DbRow = $DbResult->fetch_row(); 302 $PageList = GetPageList($DbRow[0]); 303 304 $Output = '<div style="text-align: center;">'.$FormClass['Title'].'</div>'; 305 $Output .= $PageList['Output']; 306 $Output .= '<table class="WideTable" style="font-size: small;">'; 307 308 foreach($FormClass['Items'] as $ItemIndex => $FormItem) 309 if(!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or 310 (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) and 311 ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne'))) 312 { 313 $TableColumns[] = array('Name' => $ItemIndex, 'Title' => $FormItem['Caption']); 314 } 315 $TableColumns[] = array('Name' => '', 'Title' => 'Akce'); 316 if(!array_key_exists('DefaultSortColumn', $FormClass)) 317 $FormClass['DefaultSortColumn'] = 'Id'; 318 $Order = GetOrderTableHeader($TableColumns, $FormClass['DefaultSortColumn'], 0); 319 $Output .= $Order['Output']; 320 321 // Show search fields 322 $Output .= '<tr><form action="?a=list&filter=1" method="post">'; 323 foreach($FormClass['Items'] as $ItemIndex => $FormItem) 324 if(!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or 325 (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) and 326 ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne'))) 327 { 328 if(array_key_exists('Filter'.$ItemIndex, $_POST) and ($_POST['Filter'.$ItemIndex] != '')) 329 $Value = $_POST['Filter'.$ItemIndex]; 330 else $Value = ''; 331 $Output .= '<td><input type="text" name="Filter'.$ItemIndex.'" value="'.$Value.'" style="width: 100%"/></td>'; 332 } 333 $Output .= '<td><input type="Submit" value="Hledat"/></td></form></tr>'; 334 335 $Query = 'SELECT * FROM `'.$FormClass['Table'].'`'.$Filter.' '.$Order['SQL'].$PageList['SQLLimit']; 336 337 $DbResult = $this->Database->query($Query); 338 while($Row = $DbResult->fetch_assoc()) 339 { 340 $Output .= '<tr>'; 341 foreach($FormClass['Items'] as $ItemIndex => $FormItem) 342 if(!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or 343 (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) and 344 ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne'))) 345 { 346 //$Output .= '<td>'.$Row[$ItemIndex].'</td>'; 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, 364 'Type' => $FormItem['Type'])); 365 if($Value == '') $Value = ' '; 366 $Output .= '<td>'.$Value.'</td>'; 367 } 254 368 $Output .= '<td><a href="?a=view&t='.$Table.'&id='.$Row['Id'].'"><img alt="Ukázat" title="Ukázat" src="'. 255 369 $this->System->Link('/images/view.png').'"/></a>'.
Note:
See TracChangeset
for help on using the changeset viewer.