Changeset 436 for trunk


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.
Location:
trunk
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/form_classes.php

    r435 r436  
    22
    33$FormClasses = array(
     4  'Product' => array(
     5    'Title' => 'Zboží',
     6    'Table' => 'Product',
     7    'DefaultSortColumn' => 'Name',
     8    'Items' => array(
     9      'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
     10      'Price' => array('Type' => 'Integer', 'Caption' => 'Cena', 'Default' => '0'),
     11      'Count' => array('Type' => 'Integer', 'Caption' => 'Počet', 'Default' => ''),
     12      'Date' => array('Type' => 'Date', 'Caption' => 'Datum', 'Default' => ''),
     13      'Segment' => array('Type' => 'TNetworkSegment', 'Caption' => 'Úsek', 'Default' => ''),
     14      'Used' => array('Type' => 'Boolean', 'Caption' => 'Použito', 'Default' => '0'),
     15      'Info' => array('Type' => 'Text', 'Caption' => 'Informace', 'Default' => ''),
     16      'User' => array('Type' => 'TMember', 'Caption' => 'Uživatel', 'Default' => ''),
     17      'Consumption' => array('Type' => 'Integer', 'Caption' => 'Spotřeba', 'Default' => ''),
     18      'DeviceId' => array('Type' => 'String', 'Caption' => 'Označení', 'Default' => ''),
     19      'DeprecatedPrice' => array('Type' => 'Float', 'Caption' => 'Odpisová cena', 'Default' => ''),
     20      'StockCard' => array('Type' => 'TStockCard', 'Caption' => 'Zboží', 'Default' => ''),
     21    ),
     22  ),
     23  'Stock' => array(
     24    'Title' => 'Sklady',
     25    'Table' => 'Stock',
     26    'DefaultSortColumn' => 'Name',
     27    'Items' => array(
     28      'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
     29    ),
     30  ),
    431  'FinanceBillingPeriod' => array(
    532    'Title' => 'Platební období',
     
    504531    'Filter' => '1',
    505532  ),
     533  'TStockCard' => array(
     534    'Type' => 'Reference',
     535    'Table' => 'StockCard',
     536    'Id' => 'Id',
     537    'Name' => 'Name',
     538    'Filter' => '1',
     539  ),
    506540);
    507541
  • 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.