Changeset 922 for trunk/Modules/IS/IS.php
- Timestamp:
- Feb 28, 2022, 8:53:22 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/IS/IS.php
r920 r922 163 163 if (defined('NEW_PERMISSION') and !ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission($this->TableToModule($Table), 'Write')) 164 164 return $this->SystemMessage('Oprávnění', 'Nemáte oprávnění'); 165 if (array_key_exists('o', $_GET)) 166 { 167 if ($_GET['o'] == 'save') 168 { 169 if (!array_key_exists('submit', $_POST)) 170 return $this->SystemMessage('Formulář', 'Formulář nebyl řádně odeslán. Vraťte se zpět a odešlete formulář znovu.'); 171 $Form = new Form($this->System->FormManager); 172 $Form->SetClass($Table); 173 $Form->LoadValuesFromForm(); 174 $this->Title .= ' - '.$Form->Definition['Title'].' úprava'; 175 try 176 { 177 $Form->Validate(); 178 if (array_key_exists('BeforeModify', $Form->Definition)) 179 { 180 $Class = $Form->Definition['BeforeModify'][0]; 181 $Method = $Form->Definition['BeforeModify'][1]; 182 $Form->Values = $Class->$Method($Form, $Id); 183 } 184 $this->LogChange($Form, 'Edit', $Id, $Id); 185 $Form->SaveValuesToDatabase($Id); 186 $Output .= $this->SystemMessage('Úprava položky', 'Položka upravena'); 187 $Output .= $this->ShowView($Table, $Id); 188 if (array_key_exists('AfterModify', $Form->Definition)) 189 { 190 $Class = $Form->Definition['AfterModify'][0]; 191 $Method = $Form->Definition['AfterModify'][1]; 192 $Form->Values = $Class->$Method($Form, $Id); 193 } 194 } catch (Exception $E) 195 { 196 $Output .= $this->SystemMessage('Úprava položky', 'Položku se nepodařilo uložit. Opravte problém a opakujte akci.<br/>'.$E->getMessage()); 197 $Form->OnSubmit = '?a=edit&t='.$Table.'&i='.$_GET['i'].'&o=save'; 198 $Output .= $Form->ShowEditForm(); 199 $Output .= '<ul class="ActionMenu">'; 200 $Output .= '<li>'.$this->ShowAction('Prohlížet', '?a=view&t='.$Table.'&i='.$Id, 201 $this->System->Link('/images/view.png')); 202 $Output .= '<li>'.$this->ShowAction('Duplikovat', '?a=clone&t='.$Table.'&i='.$Id, 203 $this->System->Link('/images/clone.png')); 204 $Output .= '<li>'.$this->ShowAction('Seznam', '?a=list&t='.$Table, 205 $this->System->Link('/images/list.png')); 206 $Output .= '<li>'.$this->ShowAction('Odstranit', '?a=delete&t='.$Table.'&i='.$Id, 207 $this->System->Link('/images/delete.png'), 'Opravdu smazat položku'); 208 $Output .= '</ul>'; 209 } 165 $Form = new Form($this->System->FormManager); 166 $Form->SetClass($Table); 167 if ($Form->HasAllPostVariables()) 168 { 169 $Form->LoadValuesFromForm(); 170 $this->Title .= ' - '.$Form->Definition['Title'].' úprava'; 171 try 172 { 173 $Form->Validate(); 174 if (array_key_exists('BeforeModify', $Form->Definition)) 175 { 176 $Class = $Form->Definition['BeforeModify'][0]; 177 $Method = $Form->Definition['BeforeModify'][1]; 178 $Form->Values = $Class->$Method($Form, $Id); 179 } 180 $this->LogChange($Form, 'Edit', $Id, $Id); 181 $Form->SaveValuesToDatabase($Id); 182 $Output .= $this->SystemMessage('Úprava položky', 'Položka upravena'); 183 $Output .= $this->ShowView($Table, $Id); 184 if (array_key_exists('AfterModify', $Form->Definition)) 185 { 186 $Class = $Form->Definition['AfterModify'][0]; 187 $Method = $Form->Definition['AfterModify'][1]; 188 $Form->Values = $Class->$Method($Form, $Id); 189 } 190 } catch (Exception $E) 191 { 192 $Output .= $this->SystemMessage('Úprava položky', 'Položku se nepodařilo uložit. Opravte problém a opakujte akci.<br/>'.$E->getMessage()); 193 $Form->OnSubmit = '?a=edit&t='.$Table.'&i='.$_GET['i']; 194 $Output .= $Form->ShowEditForm(); 195 $Output .= '<ul class="ActionMenu">'; 196 $Output .= '<li>'.$this->ShowAction('Prohlížet', '?a=view&t='.$Table.'&i='.$Id, 197 $this->System->Link('/images/view.png')); 198 $Output .= '<li>'.$this->ShowAction('Duplikovat', '?a=clone&t='.$Table.'&i='.$Id, 199 $this->System->Link('/images/clone.png')); 200 $Output .= '<li>'.$this->ShowAction('Seznam', '?a=list&t='.$Table, 201 $this->System->Link('/images/list.png')); 202 $Output .= '<li>'.$this->ShowAction('Odstranit', '?a=delete&t='.$Table.'&i='.$Id, 203 $this->System->Link('/images/delete.png'), 'Opravdu smazat položku'); 204 $Output .= '</ul>'; 210 205 } 211 206 } else 212 207 { 213 $Form = new Form($this->System->FormManager);214 $Form->SetClass($Table);215 208 $Form->LoadValuesFromDatabase($Id); 216 209 $this->Title .= ' - '.$Form->Definition['Title'].' úprava'; 217 $Form->OnSubmit = '?a=edit&t='.$Table.'&i='.$_GET['i'] .'&o=save';210 $Form->OnSubmit = '?a=edit&t='.$Table.'&i='.$_GET['i']; 218 211 $Output .= $Form->ShowEditForm(); 219 212 $Output .= '<ul class="ActionMenu">'; … … 238 231 if (defined('NEW_PERMISSION') and !ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission($this->TableToModule($Table), 'Write')) 239 232 return 'Nemáte oprávnění'; 240 if (array_key_exists('o', $_GET)) 241 { 242 if ($_GET['o'] == 'save') 243 { 244 $Form = new Form($this->System->FormManager); 245 $Form->SetClass($Table); 246 $Form->LoadValuesFromForm(); 247 $this->Title .= ' - '.$Form->Definition['Title'].' duplikování'; 248 try 249 { 250 $Form->Validate(); 251 if (array_key_exists('BeforeInsert', $Form->Definition)) 252 { 253 $Class = $Form->Definition['BeforeInsert'][0]; 254 $Method = $Form->Definition['BeforeInsert'][1]; 255 $Form->Values = $Class->$Method($Form); 256 } 257 $Form->Validate(); 258 $Form->SaveValuesToDatabase(0); 259 $Id = $this->Database->insert_id; 260 $this->LogChange($Form, 'Clone', $Id, 0); 261 $Output .= $this->SystemMessage('Duplikování položky', 'Nová kopie položky vytvořena'); 262 $Output .= $this->ShowView($Table, $Id, $_GET['a'] == 'addsub'); 263 if (array_key_exists('AfterInsert', $Form->Definition)) 264 { 265 $Class = $Form->Definition['AfterInsert'][0]; 266 $Method = $Form->Definition['AfterInsert'][1]; 267 $Form->Values = $Class->$Method($Form, $Id); 268 } 269 270 //$this->Database->update($Table, 'Id='.$Id, 271 // array('UserCreate' => ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'], 272 // 'TimeCreate' => 'NOW()')); 273 } catch (Exception $E) 274 { 275 $Output .= $this->SystemMessage('Duplikování položky', 'Položku se nepodařilo duplikovat. Opravte problém a opakujte akci.<br/>'.$E->getMessage()); 276 $Form->OnSubmit = '?a=clone&t='.$Table.'&o=save'; 277 $Output .= $Form->ShowEditForm(); 278 $Actions[] = '<a href="?a=list&t='.$Table.'"><img alt="Seznam" title="Seznam" src="'. 279 $this->System->Link('/images/list.png').'"/>Seznam</a>'; 280 } 281 } 282 } else 233 $Form = new Form($this->System->FormManager); 234 $Form->SetClass($Table); 235 if ($Form->HasAllPostVariables()) 283 236 { 284 237 $Form = new Form($this->System->FormManager); 285 238 $Form->SetClass($Table); 239 $Form->LoadValuesFromForm(); 240 $this->Title .= ' - '.$Form->Definition['Title'].' duplikování'; 241 try 242 { 243 $Form->Validate(); 244 if (array_key_exists('BeforeInsert', $Form->Definition)) 245 { 246 $Class = $Form->Definition['BeforeInsert'][0]; 247 $Method = $Form->Definition['BeforeInsert'][1]; 248 $Form->Values = $Class->$Method($Form); 249 } 250 $Form->Validate(); 251 $Form->SaveValuesToDatabase(0); 252 $Id = $this->Database->insert_id; 253 $this->LogChange($Form, 'Clone', $Id, 0); 254 $Output .= $this->SystemMessage('Duplikování položky', 'Nová kopie položky vytvořena'); 255 $Output .= $this->ShowView($Table, $Id, $_GET['a'] == 'addsub'); 256 if (array_key_exists('AfterInsert', $Form->Definition)) 257 { 258 $Class = $Form->Definition['AfterInsert'][0]; 259 $Method = $Form->Definition['AfterInsert'][1]; 260 $Form->Values = $Class->$Method($Form, $Id); 261 } 262 263 //$this->Database->update($Table, 'Id='.$Id, 264 // array('UserCreate' => ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'], 265 // 'TimeCreate' => 'NOW()')); 266 } catch (Exception $E) 267 { 268 $Output .= $this->SystemMessage('Duplikování položky', 'Položku se nepodařilo duplikovat. Opravte problém a opakujte akci.<br/>'.$E->getMessage()); 269 $Form->OnSubmit = '?a=clone&t='.$Table; 270 $Output .= $Form->ShowEditForm(); 271 $Actions[] = '<a href="?a=list&t='.$Table.'"><img alt="Seznam" title="Seznam" src="'. 272 $this->System->Link('/images/list.png').'"/>Seznam</a>'; 273 } 274 } else 275 { 286 276 $Form->LoadValuesFromDatabase($Id); 287 277 $this->Title .= ' - '.$Form->Definition['Title'].' duplikování'; 288 $Form->OnSubmit = '?a='.$_GET['a'].'&t='.$Table .'&o=save';278 $Form->OnSubmit = '?a='.$_GET['a'].'&t='.$Table; 289 279 $Output .= $Form->ShowEditForm(); 290 280 $Actions[] = $this->ShowAction('Seznam', '?a=list&t='.$Table, … … 347 337 if (defined('NEW_PERMISSION') and !ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission($this->TableToModule($Table), 'Write')) 348 338 return 'Nemáte oprávnění'; 349 if (array_key_exists('o', $_GET)) 350 { 351 if ($_GET['o'] == 'save') 352 { 353 $Form = new Form($this->System->FormManager); 354 $Form->SetClass($Table); 355 $Form->LoadValuesFromForm(); 356 $this->Title .= ' - '.$Form->Definition['Title'].' přidání'; 357 try 358 { 359 $Form->Validate(); 360 if (array_key_exists('BeforeInsert', $Form->Definition)) 361 { 362 $Class = $Form->Definition['BeforeInsert'][0]; 363 $Method = $Form->Definition['BeforeInsert'][1]; 364 $Form->Values = $Class->$Method($Form); 365 } 366 $Form->Validate(); 367 $Form->SaveValuesToDatabase(0); 368 $Id = $this->Database->insert_id; 369 $this->LogChange($Form, 'Add', $Id, 0); 370 $Output .= $this->SystemMessage('Přidání položky', 'Nová položka vytvořena'); 371 $Output .= $this->ShowView($Table, $Id, $_GET['a'] == 'addsub'); 372 if (array_key_exists('AfterInsert', $Form->Definition)) 373 { 374 $Class = $Form->Definition['AfterInsert'][0]; 375 $Method = $Form->Definition['AfterInsert'][1]; 376 $Form->Values = $Class->$Method($Form, $Id); 377 } 378 // Add action to update caller form 379 if ($_GET['a'] == 'addsub') 380 { 381 $Type = $this->System->FormManager->FormTypes[$_GET['rt']]; 382 $DbResult = $this->Database->select($Table, '('.$Type['Name'].') AS Name', 'Id='.$Id); 383 $DbRow = $DbResult->fetch_assoc(); 384 $Actions[] = '<a href="javascript:window.close();" onclick="add_select_item('.$Id.',"'.$DbRow['Name'].'","'. 385 $_GET['r'].'"); set_return ('.$Id.',"'. 386 $_GET['r'].'");"><img alt="Vybrat" title="Vybrat" src="'. 387 $this->System->Link('/images/select.png').'"/> Vybrat</a>'; 388 } 389 390 //$this->Database->update($Table, 'Id='.$Id, 391 // array('UserCreate' => ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'], 392 // 'TimeCreate' => 'NOW()')); 393 } catch (Exception $E) 394 { 395 $Output .= $this->SystemMessage('Přidání položky', 'Položku se nepodařilo přidat. Opravte problém a opakujte akci.<br/>'.$E->getMessage()); 396 $Form->OnSubmit = '?a=add&t='.$Table.'&o=save'; 397 $Output .= $Form->ShowEditForm(); 398 $Actions[] = '<a href="?a=list&t='.$Table.'"><img alt="Seznam" title="Seznam" src="'. 399 $this->System->Link('/images/list.png').'"/>Seznam</a>'; 400 } 339 $Form = new Form($this->System->FormManager); 340 $Form->SetClass($Table); 341 if ($Form->HasAllPostVariables()) 342 { 343 $Form->LoadValuesFromForm(); 344 $this->Title .= ' - '.$Form->Definition['Title'].' přidání'; 345 try 346 { 347 $Form->Validate(); 348 if (array_key_exists('BeforeInsert', $Form->Definition)) 349 { 350 $Class = $Form->Definition['BeforeInsert'][0]; 351 $Method = $Form->Definition['BeforeInsert'][1]; 352 $Form->Values = $Class->$Method($Form); 353 } 354 $Form->Validate(); 355 $Form->SaveValuesToDatabase(0); 356 $Id = $this->Database->insert_id; 357 $this->LogChange($Form, 'Add', $Id, 0); 358 $Output .= $this->SystemMessage('Přidání položky', 'Nová položka vytvořena'); 359 $Output .= $this->ShowView($Table, $Id, $_GET['a'] == 'addsub'); 360 if (array_key_exists('AfterInsert', $Form->Definition)) 361 { 362 $Class = $Form->Definition['AfterInsert'][0]; 363 $Method = $Form->Definition['AfterInsert'][1]; 364 $Form->Values = $Class->$Method($Form, $Id); 365 } 366 // Add action to update caller form 367 if ($_GET['a'] == 'addsub') 368 { 369 $Type = $this->System->FormManager->FormTypes[$_GET['rt']]; 370 $DbResult = $this->Database->select($Table, '('.$Type['Name'].') AS Name', 'Id='.$Id); 371 $DbRow = $DbResult->fetch_assoc(); 372 $Actions[] = '<a href="javascript:window.close();" onclick="add_select_item('.$Id.',"'.$DbRow['Name'].'","'. 373 $_GET['r'].'"); set_return ('.$Id.',"'. 374 $_GET['r'].'");"><img alt="Vybrat" title="Vybrat" src="'. 375 $this->System->Link('/images/select.png').'"/> Vybrat</a>'; 376 } 377 378 //$this->Database->update($Table, 'Id='.$Id, 379 // array('UserCreate' => ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'], 380 // 'TimeCreate' => 'NOW()')); 381 } catch (Exception $E) 382 { 383 $Output .= $this->SystemMessage('Přidání položky', 'Položku se nepodařilo přidat. Opravte problém a opakujte akci.<br/>'.$E->getMessage()); 384 $Form->OnSubmit = '?a=add&t='.$Table; 385 $Output .= $Form->ShowEditForm(); 386 $Actions[] = '<a href="?a=list&t='.$Table.'"><img alt="Seznam" title="Seznam" src="'. 387 $this->System->Link('/images/list.png').'"/>Seznam</a>'; 401 388 } 402 389 } else … … 417 404 if (array_key_exists('r', $_GET)) $URL = '&r='.$_GET['r'].'&rt='.$_GET['rt']; 418 405 else $URL = ''; 419 $Form->OnSubmit = '?a='.$_GET['a'].'&t='.$Table. '&o=save'.$URL;406 $Form->OnSubmit = '?a='.$_GET['a'].'&t='.$Table.$URL; 420 407 $Output .= $Form->ShowEditForm(); 421 408 $Actions[] = $this->ShowAction('Seznam', '?a=list&t='.$Table,
Note:
See TracChangeset
for help on using the changeset viewer.