Changeset 433 for trunk/is/index.php
- Timestamp:
- Oct 12, 2012, 8:27:30 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/is/index.php
r431 r433 30 30 if(array_key_exists('a', $_GET)) $_SESSION['Action'] = $_GET['a']; 31 31 if(array_key_exists('id', $_GET)) $_SESSION['Id'] = $_GET['id']; 32 33 if($_SESSION['Action'] == 'list') 34 { 35 if(array_key_exists('Table', $_SESSION)) 36 $Output .= $this->ShowList($FormClasses[$_SESSION['Table']]); 37 } else 38 if($_SESSION['Action'] == 'edit') $Output .= $this->ShowEdit(); 32 33 if(!array_key_exists('Action', $_SESSION)) $_SESSION['Action'] = 'list'; 34 35 if($_SESSION['Action'] == 'list') $Output .= $this->ShowList(); 36 else if($_SESSION['Action'] == 'edit') $Output .= $this->ShowEdit(); 39 37 else if($_SESSION['Action'] == 'add') $Output .= $this->ShowAdd(); 40 38 else if($_SESSION['Action'] == 'view') $Output .= $this->ShowView(); … … 47 45 function ShowEdit() 48 46 { 49 $Form = new Form($_SESSION['Table']); 50 $Form->LoadValuesFromDatabase($_SESSION['Id']); 51 $Form->OnSubmit = '?a=view'; 52 $Output = $Form->ShowEditForm(); 47 $Output = ''; 48 if(array_key_exists('o', $_GET)) 49 { 50 if($_GET['o'] == 'save') 51 { 52 $Form = new Form($_SESSION['Table']); 53 $Form->LoadValuesFromForm(); 54 $Form->SaveValuesToDatabase($_SESSION['Id']); 55 $Output .= $this->SystemMessage('Úprava položky', 'Položka upravena'); 56 $_SESSION['Action'] = 'view'; 57 $Output .= $this->ShowView(); 58 } 59 } else 60 { 61 $Form = new Form($_SESSION['Table']); 62 $Form->LoadValuesFromDatabase($_SESSION['Id']); 63 $Form->OnSubmit = '?a=edit&o=save'; 64 $Output .= $Form->ShowEditForm(); 65 $Output .= '<br/><div style="text-align: center;">'; 66 $Output .= '<a href="?a=view"><img alt="Prohlížet" title="Prohlížet" src="'. 67 $this->System->Link('/images/view.png').'"/></a>'; 68 $Output .= '<a href="?a=list"><img alt="Seznam" title="Seznam" src="'. 69 $this->System->Link('/images/list.png').'"/></a>'; 70 $Output .= '<a href="?a=delete" ><img alt="Odstranit" title="Odstranit" src="'. 71 $this->System->Link('/images/delete.png').'" onclick="return confirmAction(\'Opravdu smazat položku?\');"/></a>'; 72 $Output .= '</div>'; 73 } 53 74 return($Output); 54 75 } … … 57 78 { 58 79 $Output = ''; 80 $this->Database->delete($_SESSION['Table'], 'Id='.$_SESSION['Id']); 81 $Output .= $this->SystemMessage('Odstranění položky', 'Položka odstraněna'); 82 $_SESSION['Action'] = 'list'; 83 $Output .= $this->ShowList(); 59 84 return($Output); 60 85 } … … 62 87 function ShowAdd() 63 88 { 64 $Form = new Form($_SESSION['Table']); 65 $Form->OnSubmit = '?a=view'; 66 $Output = $Form->ShowEditForm(); 89 $Output = ''; 90 if(array_key_exists('o', $_GET)) 91 { 92 if($_GET['o'] == 'save') 93 { 94 $Form = new Form($_SESSION['Table']); 95 $Form->LoadValuesFromForm(); 96 $Form->SaveValuesToDatabase(0); 97 $Output .= $this->SystemMessage('Přidání položky', 'Nová položka vytvořena'); 98 $_SESSION['Action'] = 'view'; 99 $_SESSION['Id'] = $this->Database->insert_id; 100 $Output .= $this->ShowView(); 101 } 102 } else 103 { 104 $Form = new Form($_SESSION['Table']); 105 $Form->OnSubmit = '?a=add&o=save'; 106 $Output .= $Form->ShowEditForm(); 107 $Output .= '<br/><div style="text-align: center;">'; 108 $Output .= '<a href="?a=list"><img alt="Seznam" title="Seznam" src="'. 109 $this->System->Link('/images/list.png').'"/></a>'; 110 $Output .= '</div>'; 111 } 67 112 return($Output); 68 113 } … … 74 119 $Form->OnSubmit = '?a=view'; 75 120 $Output = $Form->ShowViewForm(); 76 $Output .= '<br/><div style="text-align: center;"><a href="?a=edit"><img alt="Upravit" title="Upravit" src="'. 77 $this->System->Link('/images/edit.png').'"/></a></div>'; 78 return($Output); 79 } 80 81 function ShowList($FormClass) 121 $Output .= '<br/><div style="text-align: center;">'; 122 $Output .= '<a href="?a=edit"><img alt="Upravit" title="Upravit" src="'. 123 $this->System->Link('/images/edit.png').'"/></a>'; 124 $Output .= '<a href="?a=list"><img alt="Seznam" title="Seznam" src="'. 125 $this->System->Link('/images/list.png').'"/></a>'; 126 $Output .= '<a href="?a=delete"><img alt="Odstranit" title="Odstranit" src="'. 127 $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() 82 133 { 83 global $Type, $FormTypes; 84 134 global $Type, $FormTypes, $FormClasses; 135 136 if(array_key_exists('Table', $_SESSION)) 137 $FormClass = $FormClasses[$_SESSION['Table']]; 138 else return($this->SystemMessage('Chyba', 'Tabulka nenalezena')); 85 139 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `'.$FormClass['Table'].'`'); 86 140 $DbRow = $DbResult->fetch_row(); … … 123 177 $this->System->Link('/images/edit.png').'"/></a>'. 124 178 '<a href="?a=delete&id='.$Row['Id'].'"><img alt="Smazat" title="Smazat" src="'. 125 $this->System->Link('/images/delete.png').'" /></a></td>';179 $this->System->Link('/images/delete.png').'" onclick="return confirmAction(\'Opravdu smazat položku?\');"/></a></td>'; 126 180 $Output .= '</tr>'; 127 181 } 128 182 $Output .= '</table>'; 129 183 $Output .= $PageList['Output']; 130 $Output .= '<br/><div style="text-align: center;"><a href="?a=add"><img alt="Přidat" title="Přidat" src="'. 131 $this->System->Link('/images/add.png').'"/></a></div>'; 184 $Output .= '<br/><div style="text-align: center;">'; 185 $Output .= '<a href="?a=add"><img alt="Přidat" title="Přidat" src="'. 186 $this->System->Link('/images/add.png').'"/></a>'; 187 $Output .= '</div>'; 132 188 return($Output); 133 189 }
Note:
See TracChangeset
for help on using the changeset viewer.