Changeset 434 for trunk/is/index.php
- Timestamp:
- Oct 12, 2012, 9:03:30 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.