Changeset 436 for trunk/is/index.php


Ignore:
Timestamp:
Oct 12, 2012, 11:37:49 AM (12 years ago)
Author:
chronos
Message:
  • P5idáno: Tabulky Zboží a sklady v Správě dat.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/is/index.php

    r435 r436  
    3434   
    3535    if($_SESSION['Action'] == 'list') $Output .= $this->ShowList($_SESSION['Table']);
    36     else if($_SESSION['Action'] == 'edit') $Output .= $this->ShowEdit();
    37     else if($_SESSION['Action'] == 'add') $Output .= $this->ShowAdd();
    38     else if($_SESSION['Action'] == 'view') $Output .= $this->ShowView();
    39     else if($_SESSION['Action'] == 'delete') $Output .= $this->ShowDelete();
     36    else if($_SESSION['Action'] == 'edit') $Output .= $this->ShowEdit($_SESSION['Table'], $_SESSION['Id']);
     37    else if($_SESSION['Action'] == 'add') $Output .= $this->ShowAdd($_SESSION['Table']);
     38    else if($_SESSION['Action'] == 'view') $Output .= $this->ShowView($_SESSION['Table'], $_SESSION['Id']);
     39    else if($_SESSION['Action'] == 'delete') $Output .= $this->ShowDelete($_SESSION['Table'], $_SESSION['Id']);
    4040    $Output .= '</td></tr></table>';
    4141   
     
    4343  }
    4444 
    45   function ShowEdit()
     45  function ShowEdit($Table, $Id)
    4646  {
    4747    $Output = '';
     
    5050      if($_GET['o'] == 'save')
    5151      {
    52         $Form = new Form($_SESSION['Table']);
     52        $Form = new Form($Table);
    5353        $Form->LoadValuesFromForm();
    54         $Form->SaveValuesToDatabase($_SESSION['Id']);
     54        $Form->SaveValuesToDatabase($Id);
    5555        $Output .= $this->SystemMessage('Úprava položky', 'Položka upravena');
    5656        $_SESSION['Action'] = 'view';
    57         $Output .= $this->ShowView();   
     57        $Output .= $this->ShowView($Table, $Id);   
    5858      }
    5959    } else
    6060    {
    61       $Form = new Form($_SESSION['Table']);
    62       $Form->LoadValuesFromDatabase($_SESSION['Id']);
     61      $Form = new Form($Table);
     62      $Form->LoadValuesFromDatabase($Id);
    6363      $Form->OnSubmit = '?a=edit&amp;o=save';
    6464      $Output .= $Form->ShowEditForm();
     
    7575  }
    7676 
    77   function ShowDelete()
     77  function ShowDelete($Table, $Id)
    7878  {
    7979    $Output = '';
    80     $this->Database->delete($_SESSION['Table'], 'Id='.$_SESSION['Id']);
     80    $this->Database->delete($Table, 'Id='.$Id);
    8181    $Output .= $this->SystemMessage('Odstranění položky', 'Položka odstraněna');
    8282    $_SESSION['Action'] = 'list';
    83     $Output .= $this->ShowList();   
    84     return($Output);
    85   }
    86  
    87   function ShowAdd()
     83    $Output .= $this->ShowList($Table);   
     84    return($Output);
     85  }
     86 
     87  function ShowAdd($Table)
    8888  {
    8989    $Output = '';
     
    9292      if($_GET['o'] == 'save')
    9393      {
    94         $Form = new Form($_SESSION['Table']);
     94        $Form = new Form($Table);
    9595        $Form->LoadValuesFromForm();
    9696        $Form->SaveValuesToDatabase(0);
    9797        $Output .= $this->SystemMessage('Přidání položky', 'Nová položka vytvořena');
    9898        $_SESSION['Action'] = 'view';
    99         $_SESSION['Id'] = $this->Database->insert_id;
    100         $Output .= $this->ShowView();   
     99        $Id = $this->Database->insert_id;
     100        $_SESSION['Id'] = $Id;
     101        $this->Database->update($Table, 'Id='.$Id,
     102          array('UserCreate' => $this->System->Modules['User']->User['Id'],
     103          'TimeCreate' => 'NOW()'));
     104        $Output .= $this->ShowView($Table, $Id);   
    101105      }
    102106    } else
    103107    {
    104       $Form = new Form($_SESSION['Table']);
     108      $Form = new Form($Table);
    105109      $Form->OnSubmit = '?a=add&amp;o=save';
    106110      $Output .= $Form->ShowEditForm();
     
    113117  }
    114118 
    115   function ShowView()
     119  function ShowView($Table, $Id)
    116120  {
    117121    global $FormTypes;
    118122   
    119     $Form = new Form($_SESSION['Table']);
    120     $Form->LoadValuesFromDatabase($_SESSION['Id']);
     123    $Form = new Form($Table);
     124    $Form->LoadValuesFromDatabase($Id);
    121125    $Form->OnSubmit = '?a=view';
    122126    $Output = $Form->ShowViewForm();
     
    135139    {
    136140      $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/>';
     141      $Output .= $this->ShowList($FormTypes[$Item['Type']]['Table'], '`'.$FormTypes[$Item['Type']]['Ref'].'`='.$Id).'<br/>';
    138142    }   
    139143    return($Output);
Note: See TracChangeset for help on using the changeset viewer.