Changeset 434
- Timestamp:
- Oct 12, 2012, 9:03:30 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/form_classes.php
r433 r434 84 84 'LastOnline' => array('Type' => 'DateTime', 'Caption' => 'Naposledy běželo', 'Default' => ''), 85 85 'PermanentOnline' => array('Type' => 'Boolean', 'Caption' => 'Běží stále', 'Default' => '0'), 86 'Interfaces' => array('Type' => 'TInterfaceList', 'Caption' => 'Rozhraní', 'Default' => ''), 86 87 ), 87 88 ), … … 439 440 'Filter' => '1', 440 441 ), 442 'TInterfaceList' => array( 443 'Type' => 'ManyToOne', 444 'Table' => 'NetworkInterface', 445 'Id' => 'Id', 446 'Ref' => 'Device', 447 'Filter' => '1', 448 ), 441 449 ); 442 450 -
trunk/forms.php
r433 r434 26 26 ); 27 27 foreach($this->Definition['Items'] as $Index => $Item) 28 if(!array_key_exists($Item['Type'], $FormTypes) or 29 (array_key_exists($Item['Type'], $FormTypes) and ($FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 28 30 { 29 31 if(!array_key_exists($Index, $this->Values) and isset($Item['Default'])) $this->Values[$Index] = $Item['Default']; … … 64 66 if($Context != '') $Context = $Context.'-'; 65 67 foreach($this->Definition['Items'] as $Index => $Item) 68 if(!array_key_exists($Item['Type'], $FormTypes) or 69 (array_key_exists($Item['Type'], $FormTypes) and ($FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 66 70 { 67 71 if(!array_key_exists($Index, $this->Values) and isset($Item['Default'])) $this->Values[$Index] = $Item['Default']; … … 154 158 function LoadValuesFromDatabase($Id) 155 159 { 156 global $Database ;160 global $Database, $FormTypes; 157 161 158 162 $DbResult = $Database->query('SELECT T.* FROM '.$this->Definition['Table'].' AS T WHERE T.Id='.$Id); 159 163 $DbRow = $DbResult->fetch_array(); 160 164 foreach($this->Definition['Items'] as $Index => $Item) 165 if(!array_key_exists($Item['Type'], $FormTypes) or 166 (array_key_exists($Item['Type'], $FormTypes) and ($FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 161 167 { 162 168 $this->Values[$Index] = $DbRow[$Index]; -
trunk/is/index.php
r433 r434 33 33 if(!array_key_exists('Action', $_SESSION)) $_SESSION['Action'] = 'list'; 34 34 35 if($_SESSION['Action'] == 'list') $Output .= $this->ShowList( );35 if($_SESSION['Action'] == 'list') $Output .= $this->ShowList($_SESSION['Table']); 36 36 else if($_SESSION['Action'] == 'edit') $Output .= $this->ShowEdit(); 37 37 else if($_SESSION['Action'] == 'add') $Output .= $this->ShowAdd(); … … 115 115 function ShowView() 116 116 { 117 global $FormTypes; 118 117 119 $Form = new Form($_SESSION['Table']); 118 120 $Form->LoadValuesFromDatabase($_SESSION['Id']); … … 126 128 $Output .= '<a href="?a=delete"><img alt="Odstranit" title="Odstranit" src="'. 127 129 $this->System->Link('/images/delete.png').'" onclick="return confirmAction(\'Opravdu smazat položku?\');"/></a>'; 128 $Output .= '</div>'; 129 return($Output); 130 } 131 132 function ShowList() 130 $Output .= '</div><br/>'; 131 132 // Show ManyToOne relations 133 foreach($Form->Definition['Items'] as $Index => $Item) 134 if((array_key_exists($Item['Type'], $FormTypes) and ($FormTypes[$Item['Type']]['Type'] == 'ManyToOne'))) 135 { 136 $Output .= '<div style="text-align: center;">'.$Form->Definition['Title'].'</div>'; 137 $Output .= $this->ShowList($FormTypes[$Item['Type']]['Table'], '`'.$FormTypes[$Item['Type']]['Ref'].'`='.$_SESSION['Id']).'<br/>'; 138 } 139 return($Output); 140 } 141 142 function ShowList($Table, $Filter = '') 133 143 { 134 144 global $Type, $FormTypes, $FormClasses; 135 145 136 if(array_key_exists('Table', $_SESSION)) 137 $FormClass = $FormClasses[$_SESSION['Table']]; 146 if($Table != '') $FormClass = $FormClasses[$Table]; 138 147 else return($this->SystemMessage('Chyba', 'Tabulka nenalezena')); 139 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `'.$FormClass['Table'].'`'); 148 if($Filter != '') $Filter = ' WHERE '.$Filter; 149 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `'.$FormClass['Table'].'`'.$Filter); 140 150 $DbRow = $DbResult->fetch_row(); 141 151 $PageList = GetPageList($DbRow[0]); … … 145 155 146 156 foreach($FormClass['Items'] as $ItemIndex => $FormItem) 157 if(!array_key_exists($FormItem['Type'], $FormTypes) or 158 (array_key_exists($FormItem['Type'], $FormTypes) and ($FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne'))) 147 159 $TableColumns[] = array('Name' => $ItemIndex, 'Title' => $FormItem['Caption']); 148 160 $TableColumns[] = array('Name' => '', 'Title' => 'Akce'); … … 152 164 $Output .= $Order['Output']; 153 165 154 $Query = 'SELECT * FROM `'.$FormClass['Table'].'` '.$Order['SQL'].$PageList['SQLLimit'];166 $Query = 'SELECT * FROM `'.$FormClass['Table'].'`'.$Filter.' '.$Order['SQL'].$PageList['SQLLimit']; 155 167 156 168 $DbResult = $this->Database->query($Query); … … 159 171 $Output .= '<tr>'; 160 172 foreach($FormClass['Items'] as $ItemIndex => $FormItem) 173 if(!array_key_exists($FormItem['Type'], $FormTypes) or 174 (array_key_exists($FormItem['Type'], $FormTypes) and ($FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne'))) 161 175 { 162 176 //$Output .= '<td>'.$Row[$ItemIndex].'</td>'; … … 166 180 $this->System->Type->RegisterType($FormItem['Type'], '', 167 181 $FormTypes[$FormItem['Type']]); 168 $ Output .= '<td>'.$this->System->Type->ExecuteTypeEvent('OneToMany', 'OnView',182 $Value = $this->System->Type->ExecuteTypeEvent('OneToMany', 'OnView', 169 183 array('Value' => $Row[$ItemIndex], 'Name' => $ItemIndex, 170 'Type' => $FormItem['Type'])).'</td>'; 171 } else $Output .= '<td>'.$this->System->Type->ExecuteTypeEvent($FormItem['Type'], 'OnView', 172 array('Value' => $Row[$ItemIndex], 'Name' => $ItemIndex)).'</td>'; 184 'Type' => $FormItem['Type'])); 185 } else $Value = $this->System->Type->ExecuteTypeEvent($FormItem['Type'], 'OnView', 186 array('Value' => $Row[$ItemIndex], 'Name' => $ItemIndex)); 187 if($Value == '') $Value = ' '; 188 $Output .= '<td>'.$Value.'</td>'; 173 189 } 174 $Output .= '<td><a href="?a=view& id='.$Row['Id'].'"><img alt="Ukázat" title="Ukázat" src="'.190 $Output .= '<td><a href="?a=view&t='.$Table.'&id='.$Row['Id'].'"><img alt="Ukázat" title="Ukázat" src="'. 175 191 $this->System->Link('/images/view.png').'"/></a>'. 176 '<a href="?a=edit& id='.$Row['Id'].'"><img alt="Upravit" title="Upravit" src="'.192 '<a href="?a=edit&t='.$Table.'&id='.$Row['Id'].'"><img alt="Upravit" title="Upravit" src="'. 177 193 $this->System->Link('/images/edit.png').'"/></a>'. 178 '<a href="?a=delete& id='.$Row['Id'].'"><img alt="Smazat" title="Smazat" src="'.194 '<a href="?a=delete&t='.$Table.'&id='.$Row['Id'].'"><img alt="Smazat" title="Smazat" src="'. 179 195 $this->System->Link('/images/delete.png').'" onclick="return confirmAction(\'Opravdu smazat položku?\');"/></a></td>'; 180 196 $Output .= '</tr>';
Note:
See TracChangeset
for help on using the changeset viewer.