Changeset 710


Ignore:
Timestamp:
Dec 29, 2014, 12:09:46 AM (10 years ago)
Author:
chronos
Message:
Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/FormClasses.php

    r708 r710  
    485485    'Filter' => '1',
    486486  ),
    487   'TStockItem' => array(
    488     'Type' => 'Reference',
    489     'Table' => 'StockItem',
     487  'TStockSerialNumber' => array(
     488    'Type' => 'Reference',
     489    'Table' => 'StockSerialNumber',
    490490    'Id' => 'Id',
    491491    'Name' => 'RegNumber',
     
    548548    'Filter' => '1',
    549549  ),
    550   'TStockItemListStock' => array(
    551     'Type' => 'ManyToOne',
    552     'Table' => 'StockItem',
     550  'TStockSerialNumberListStock' => array(
     551    'Type' => 'ManyToOne',
     552    'Table' => 'StockSerialNumber',
    553553    'Id' => 'Id',
    554554    'Ref' => 'Stock',
    555555    'Filter' => '1',
    556556  ),
    557   'TStockItemListProduct' => array(
    558     'Type' => 'ManyToOne',
    559     'Table' => 'StockItem',
     557  'TStockSerialNumberListProduct' => array(
     558    'Type' => 'ManyToOne',
     559    'Table' => 'StockSerialNumber',
    560560    'Id' => 'Id',
    561561    'Ref' => 'Product',
     
    723723    'Filter' => '1',
    724724  ),
    725   'TCustomerStockItem' => array(
    726     'Type' => 'ManyToOne',
    727     'Table' => 'StockItem',
     725  'TCustomerStockSerialNumber' => array(
     726    'Type' => 'ManyToOne',
     727    'Table' => 'StockSerialNumber',
    728728    'Id' => 'Id',
    729729    'Ref' => 'Location',
     
    863863    'Filter' => '1',
    864864  ),
    865   'TStockItemListStockItem' => array(
    866     'Type' => 'ManyToOne',
    867     'Table' => 'StockItem',
     865  'TStockSerialNumberListStockSerialNumber' => array(
     866    'Type' => 'ManyToOne',
     867    'Table' => 'StockSerialNumber',
    868868    'Id' => 'Id',
    869869    'Ref' => 'Esemble',
  • trunk/Application/Version.php

    r709 r710  
    11<?php
    22
    3 $Revision = 709; // Subversion revision
    4 $DatabaseRevision = 707; // SQL structure revision
     3$Revision = 710; // Subversion revision
     4$DatabaseRevision = 710; // SQL structure revision
    55$ReleaseTime = strtotime('2014-12-21');
  • trunk/Common/Setup/Updates.php

    r707 r710  
    914914function UpdateTo696($Manager)
    915915{
    916         $Manager->Execute('ALTER TABLE `NetworkInterfaceUpDown` ADD `Duration` INT NOT NULL ;');
    917         $Manager->Execute('UPDATE `NetworkInterfaceUpDown` AS `TM` SET `Duration` = IFNULL(TIMESTAMPDIFF(SECOND,
    918     (SELECT `Time` FROM (SELECT * FROM `NetworkInterfaceUpDown`) AS `TA` WHERE (`TA`.`Time` < `TM`.`Time`)
    919     AND (`TA`.`Interface`=`TM`.`Interface`) ORDER BY `TA`.`Time` DESC LIMIT 1), `TM`.`Time`), 0)');
     916  $Manager->Execute('ALTER TABLE `NetworkInterfaceUpDown` ADD `Duration` INT NOT NULL ;');
     917  $Manager->Execute('UPDATE `NetworkInterfaceUpDown` AS `TM` SET `Duration` = IFNULL(TIMESTAMPDIFF(SECOND,
     918  (SELECT `Time` FROM (SELECT * FROM `NetworkInterfaceUpDown`) AS `TA` WHERE (`TA`.`Time` < `TM`.`Time`)
     919  AND (`TA`.`Interface`=`TM`.`Interface`) ORDER BY `TA`.`Time` DESC LIMIT 1), `TM`.`Time`), 0)');
    920920}
    921921
    922922function UpdateTo697($Manager)
    923923{
    924         $Manager->Execute('ALTER TABLE `NetworkInterfaceUpDown` CHANGE `Duration` `Duration` INT( 11 ) NULL ;');
    925         $Manager->Execute('UPDATE `NetworkInterfaceUpDown` SET `Duration` = NULL');
    926         $Manager->Execute('UPDATE `NetworkInterfaceUpDown` AS `TM` SET `Duration` = TIMESTAMPDIFF(SECOND,
    927     `TM`.`Time`, (SELECT `Time` FROM (SELECT * FROM `NetworkInterfaceUpDown`) AS `TA` WHERE (`TA`.`Time` > `TM`.`Time`)
    928     AND (`TA`.`Interface`=`TM`.`Interface`) ORDER BY `TA`.`Time` ASC LIMIT 1))');
     924  $Manager->Execute('ALTER TABLE `NetworkInterfaceUpDown` CHANGE `Duration` `Duration` INT( 11 ) NULL ;');
     925  $Manager->Execute('UPDATE `NetworkInterfaceUpDown` SET `Duration` = NULL');
     926  $Manager->Execute('UPDATE `NetworkInterfaceUpDown` AS `TM` SET `Duration` = TIMESTAMPDIFF(SECOND,
     927  `TM`.`Time`, (SELECT `Time` FROM (SELECT * FROM `NetworkInterfaceUpDown`) AS `TA` WHERE (`TA`.`Time` > `TM`.`Time`)
     928  AND (`TA`.`Interface`=`TM`.`Interface`) ORDER BY `TA`.`Time` ASC LIMIT 1))');
    929929}
    930930
    931931function UpdateTo707($Manager)
    932932{
    933         $Manager->Execute('ALTER TABLE `NetworkDevice` CHANGE `Product` `Product` INT(11) NULL;');
     933  $Manager->Execute('ALTER TABLE `NetworkDevice` CHANGE `Product` `Product` INT(11) NULL;');
     934}
     935
     936function UpdateTo710($Manager)
     937{       
     938  $Manager->Execute('RENAME TABLE `StockItem` TO `StockSerialNumber`;');
     939  $Manager->Execute('UPDATE `Action` SET `URL`="/is/?t=StockSerialNumber&a=list",`Title`="Sériová čísla" WHERE `URL`="/is/?t=StockItem&a=list";');
     940 
     941  // StockMove
     942  $Manager->Execute('CREATE TABLE IF NOT EXISTS `StockMove` (
     943  `Id` int(11) NOT NULL,
     944  `Time` datetime NOT NULL,
     945  `StockFrom` int(11) DEFAULT NULL,
     946  `StockTo` int(11) DEFAULT NULL,
     947  `BillCode` varchar(255) NOT NULL,
     948  `DocumentLine` int(11) NOT NULL,
     949  `File` int(11) DEFAULT NULL
     950  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
     951   
     952  $Manager->Execute('ALTER TABLE `StockMove`
     953  ADD PRIMARY KEY (`Id`), ADD KEY `DocumentLine` (`DocumentLine`), ADD KEY `StockFrom` (`StockFrom`), ADD KEY `StockTo` (`StockTo`), ADD KEY `File` (`File`);');
     954   
     955  $Manager->Execute('ALTER TABLE `StockMove`
     956  MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT;');
     957 
     958  $Manager->Execute('ALTER TABLE `StockMove`
     959  ADD CONSTRAINT `StockMove_ibfk_1` FOREIGN KEY (`StockFrom`) REFERENCES `Stock` (`Id`),
     960  ADD CONSTRAINT `StockMove_ibfk_2` FOREIGN KEY (`StockTo`) REFERENCES `Stock` (`Id`),
     961  ADD CONSTRAINT `StockMove_ibfk_3` FOREIGN KEY (`DocumentLine`) REFERENCES `DocumentLine` (`Id`);');
     962 
     963  // StockMoveItem
     964  $Manager->Execute('CREATE TABLE IF NOT EXISTS `StockMoveItem` (
     965  `Id` int(11) NOT NULL,
     966  `StockMove` int(11) NOT NULL,
     967  `Product` int(11) NOT NULL,
     968  `Amount` int(11) NOT NULL,
     969  `Text` varchar(255) NOT NULL,
     970  `UnitPrice` int(11) NOT NULL
     971  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
     972 
     973  $Manager->Execute('ALTER TABLE `StockMoveItem`
     974  ADD PRIMARY KEY (`Id`), ADD KEY `Product` (`Product`), ADD KEY `StockMove` (`StockMove`);');
     975 
     976  $Manager->Execute('ALTER TABLE `StockMoveItem`
     977  MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT;');
     978
     979  $Manager->Execute('ALTER TABLE `StockMoveItem`
     980  ADD CONSTRAINT `StockMoveItem_ibfk_2` FOREIGN KEY (`Product`) REFERENCES `Product` (`Id`),
     981  ADD CONSTRAINT `StockMoveItem_ibfk_1` FOREIGN KEY (`StockMove`) REFERENCES `StockMove` (`Id`);'); 
     982
     983  // IS menu item
     984  $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,
     985`Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES (
     986NULL , "", "Skladové pohyby", "1", "/is/?t=StockMove&a=list", NULL , NULL , NULL , "1");');
     987  $ActionId = $Manager->Database->insert_id;
     988  $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Sklad"');
     989  if($DbResult->num_rows > 0)
     990  {
     991        $DbRow = $DbResult->fetch_assoc();
     992    $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
     993      "VALUES (NULL , 'Skladové pohyby', ".$DbRow['Id'].", '".$ActionId."', '1');");
     994  }
    934995}
    935996
     
    9871048      696 => array('Revision' => 697, 'Function' => 'UpdateTo697'),
    9881049      697 => array('Revision' => 707, 'Function' => 'UpdateTo707'),
     1050      707 => array('Revision' => 710, 'Function' => 'UpdateTo710'),
    9891051    ));
    9901052  }
  • trunk/Modules/Customer/Customer.php

    r645 r710  
    3535        'UserRel' => array('Type' => 'TUserCustomerRelListCustomer', 'Caption' => 'Přiřazení uživatelé', 'Default' => ''),
    3636        'ServiceRel' => array('Type' => 'TServiceCustomerRelListCustomer', 'Caption' => 'Placené služby', 'Default' => ''),
    37         'Consumption' => array('Type' => 'TCustomerStockItem', 'Caption' => 'Spotřeba zařízení', 'Default' => ''),
     37        'Consumption' => array('Type' => 'TCustomerStockSerialNumber', 'Caption' => 'Spotřeba zařízení', 'Default' => ''),
    3838      ),
    3939    ));   
  • trunk/Modules/Finance/Consumption.php

    r548 r710  
    1717    while($Segment = $DbResult->fetch_assoc())
    1818    {
    19       $DbResult2 = $this->Database->query('SELECT SUM(Product.Consumption) AS Consumption FROM StockItem JOIN Product ON Product.Id = StockItem.Product WHERE (StockItem.Segment='.$Segment['Id'].') AND (StockItem.TimeElimination IS NULL)');
     19      $DbResult2 = $this->Database->query('SELECT SUM(Product.Consumption) AS Consumption FROM StockSerialNumber '.
     20                'JOIN Product ON Product.Id = StockSerialNumber.Product WHERE (StockSerialNumber.Segment='.$Segment['Id'].') '.
     21                'AND (StockSerialNumber.TimeElimination IS NULL)');
    2022      $Row2 = $DbResult2->fetch_assoc();
    2123      $CelkovaSpotreba = $CelkovaSpotreba + $Row2['Consumption'];
  • trunk/Modules/Finance/Devices.php

    r548 r710  
    1717      $Output .= '<tr><td style="text-align: left" colspan="3"><strong>Segment: '.$Segment['Name'].' ('.$Segment['Users'].')</strong></td><td style="font-weight: Bold;" align="right">'.$Segment['Price'].'</td></tr>';
    1818      $DbResult2 = $this->Database->query('SELECT Product.Consumption AS Consumption, Product.Name AS Name, '.
    19          'StockItem.BuyPrice AS Price, StockItem.TimeEnlistment AS Date '.
    20          'FROM StockItem JOIN Product ON Product.Id = StockItem.Product WHERE (StockItem.Segment='.$Segment['Id'].') AND (StockItem.TimeElimination IS NULL)');
     19         'StockSerialNumber.BuyPrice AS Price, StockSerialNumber.TimeEnlistment AS Date '.
     20         'FROM StockSerialNumber JOIN Product ON Product.Id = StockSerialNumber.Product WHERE (StockSerialNumber.Segment='.$Segment['Id'].') AND (StockSerialNumber.TimeElimination IS NULL)');
    2121      while($Row = $DbResult2->fetch_assoc())
    2222      {
  • trunk/Modules/Finance/Finance.php

    r709 r710  
    203203      $Cash = $Cash[0];
    204204
    205       $DbResult2 = $this->Database->query('SELECT SUM(`Product`.`Consumption`) * `StockItem`.`Amount` '.
    206           'FROM `StockItem` JOIN `Product` ON `Product`.`Id` = `StockItem`.`Product` '.
    207           'WHERE (`StockItem`.`Location` = '.$Member['Id'].') AND (`StockItem`.`TimeElimination` IS NULL)');
     205      $DbResult2 = $this->Database->query('SELECT SUM(`Product`.`Consumption`) * `StockSerialNumber`.`Amount` '.
     206          'FROM `StockSerialNumber` JOIN `Product` ON `Product`.`Id` = `StockSerialNumber`.`Product` '.
     207          'WHERE (`StockSerialNumber`.`Location` = '.$Member['Id'].') AND (`StockSerialNumber`.`TimeElimination` IS NULL)');
    208208      $ConsumptionPlus = $DbResult2->fetch_row();
    209209      $ConsumptionPlus = $ConsumptionPlus[0];
     
    265265      $RowP2 = $DbResult2->fetch_array();
    266266
    267       $DbResult2 = $this->Database->query('SELECT SUM(`Product`.`BuyPrice`) * `StockItem`.`Amount` AS `Price`, '.
    268           'SUM(`Product`.`Consumption`) * `StockItem`.`Amount` AS `Consumption` '.
    269           'FROM `StockItem` JOIN `Product` ON `Product`.`Id` = `StockItem`.`Product` '.
    270           'WHERE (`StockItem`.`Segment`='.$NetworkSegment['Id'].') AND (`StockItem`.`TimeElimination` IS NULL)');
     267      $DbResult2 = $this->Database->query('SELECT SUM(`Product`.`BuyPrice`) * `StockSerialNumber`.`Amount` AS `Price`, '.
     268          'SUM(`Product`.`Consumption`) * `StockSerialNumber`.`Amount` AS `Consumption` '.
     269          'FROM `StockSerialNumber` JOIN `Product` ON `Product`.`Id` = `StockSerialNumber`.`Product` '.
     270          'WHERE (`StockSerialNumber`.`Segment`='.$NetworkSegment['Id'].') AND (`StockSerialNumber`.`TimeElimination` IS NULL)');
    271271      $Row2 = $DbResult2->fetch_array();
    272272      $DbResult2 = $this->Database->query('SELECT COUNT(*) FROM Member WHERE NetworkSegment='.$NetworkSegment['Id']);
  • trunk/Modules/Finance/Manage.php

    r692 r710  
    231231
    232232    // Celkovy prehled
    233     $DbResult = $this->Database->query('SELECT SUM(Product.SellPrice) AS Price FROM StockItem '.
    234       'JOIN Product ON StockItem.Product = Product.Id WHERE (StockItem.TimeElimination IS NULL) AND (StockItem.Segment IS NOT NULL)');
     233    $DbResult = $this->Database->query('SELECT SUM(Product.SellPrice) AS Price FROM StockSerialNumber '.
     234      'JOIN Product ON StockSerialNumber.Product = Product.Id WHERE (StockSerialNumber.TimeElimination IS NULL) AND (StockSerialNumber.Segment IS NOT NULL)');
    235235    $Row = $DbResult->fetch_row();
    236236    $TotalDeviceCost = $Row[0];
     
    252252    $Output .= 'Stav pokladny: Členové('.$TotalMemberCash.')';
    253253
    254     $DbResult = $this->Database->query('SELECT SUM(Product.Consumption) AS Consumption FROM StockItem '.
    255       'JOIN Product ON StockItem.Product = Product.Id WHERE (StockItem.TimeElimination IS NULL) AND (StockItem.Segment IS NOT NULL)');
     254    $DbResult = $this->Database->query('SELECT SUM(Product.Consumption) AS Consumption FROM StockSerialNumber '.
     255      'JOIN Product ON StockSerialNumber.Product = Product.Id WHERE (StockSerialNumber.TimeElimination IS NULL) '.
     256        'AND (StockSerialNumber.Segment IS NOT NULL)');
    256257    $Row = $DbResult->fetch_row();
    257258    $TotalConsumption = $Row[0];
  • trunk/Modules/Finance/Overview.php

    r548 r710  
    5656    $TotalGain = 0;
    5757    $TotalExpense = 0;
    58     $DbResult = $this->Database->query('SELECT SUM(Product.Consumption) * StockItem.Amount FROM StockItem '.
    59       'JOIN Product ON Product.Id=StockItem.Product WHERE (StockItem.TimeElimination IS NULL)');
     58    $DbResult = $this->Database->query('SELECT SUM(Product.Consumption) * StockSerialNumber.Amount FROM StockSerialNumber '.
     59      'JOIN Product ON Product.Id=StockSerialNumber.Product WHERE (StockSerialNumber.TimeElimination IS NULL)');
    6060    $Row = $DbResult->fetch_array();
    6161    $TotalConsumption = $this->System->Modules['Finance']->W2Kc($Row[0]);
  • trunk/Modules/Finance/Zivnost.php

    r627 r710  
    4343
    4444    // SmallAssets
    45     $DbResult = $this->Database->query('SELECT SUM(SellPrice) FROM StockItem WHERE (TimeEnlistment < "'.TimeToMysqlDateTime($StartTime).'") AND (TimeEnlistment != 0) AND ((TimeElimination > "'.TimeToMysqlDateTime($StartTime).'") OR (TimeElimination IS NULL))');
     45    $DbResult = $this->Database->query('SELECT SUM(SellPrice) FROM StockSerialNumber WHERE (TimeEnlistment < "'.TimeToMysqlDateTime($StartTime).'") AND (TimeEnlistment != 0) AND ((TimeElimination > "'.TimeToMysqlDateTime($StartTime).'") OR (TimeElimination IS NULL))');
    4646    //$Output .= $Database->error;
    4747    $Row = $DbResult->fetch_array();
    4848    $Balance['SmallAssets']['Start'] = $Row[0] + 0;
    49     $DbResult = $this->Database->query('SELECT SUM(SellPrice) FROM StockItem WHERE (TimeEnlistment < "'.TimeToMysqlDateTime($EndTime).'") AND (TimeEnlistment != 0) AND ((TimeElimination > "'.TimeToMysqlDateTime($EndTime).'") OR (TimeElimination IS NULL))');
     49    $DbResult = $this->Database->query('SELECT SUM(SellPrice) FROM StockSerialNumber WHERE (TimeEnlistment < "'.TimeToMysqlDateTime($EndTime).'") AND (TimeEnlistment != 0) AND ((TimeElimination > "'.TimeToMysqlDateTime($EndTime).'") OR (TimeElimination IS NULL))');
    5050    $Row = $DbResult->fetch_array();
    5151    $Balance['SmallAssets']['End'] = $Row[0] + 0;
     
    263263        $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">';
    264264        $Output .= '<tr><th>Název</th><th>Hodnota [Kč]</th><th>Datum zakoupení</th><th>Datum vyřezení</th></tr>';
    265         $DbResult = $this->Database->query('SELECT Product.Name AS Name, StockItem.SellPrice AS Price, StockItem.TimeEnlistment AS TimeEnlistment, StockItem.TimeElimination AS TimeElimination '.
    266           'FROM StockItem JOIN Product ON Product.Id = StockItem.Product '.
     265        $DbResult = $this->Database->query('SELECT Product.Name AS Name, StockSerialNumber.SellPrice AS Price, StockSerialNumber.TimeEnlistment AS TimeEnlistment, StockSerialNumber.TimeElimination AS TimeElimination '.
     266          'FROM StockSerialNumber JOIN Product ON Product.Id = StockSerialNumber.Product '.
    267267          'WHERE (TimeElimination IS NOT NULL)');
    268268        while($Row = $DbResult->fetch_array())
  • trunk/Modules/Stock/Stock.php

    r679 r710  
    3030        'Code' => array('Type' => 'String', 'Caption' => 'Kód', 'Default' => ''),
    3131        'UnitOfMeasure' => array('Type' => 'TUnitOfMeasure', 'Caption' => 'Měrná jednotka', 'Default' => '', 'Null' => true),
    32         'StockItems' => array('Type' => 'TStockItemListProduct', 'Caption' => 'Položky na skladě', 'Default' => '', 'Suffix' => 'ks'),
     32        'StockSerialNumbers' => array('Type' => 'TStockSerialNumberListProduct', 'Caption' => 'Položky na skladě', 'Default' => '', 'Suffix' => 'ks'),
    3333        'NetworkDevices' => array('Type' => 'TNetworkDeviceListProduct', 'Caption' => 'Síťová zařízení', 'Default' => ''),
    3434      ),
    3535    ));
    36     $this->System->FormManager->RegisterClass('StockItem', array(
     36    $this->System->FormManager->RegisterClass('StockSerialNumber', array(
    3737      'Title' => 'Skladové položky',
    38       'Table' => 'StockItem',
     38      'Table' => 'StockSerialNumber',
    3939      'DefaultSortColumn' => 'Id',
    4040      'Items' => array(
     
    5151        'Segment' => array('Type' => 'TNetworkSegment', 'Caption' => 'Úsek sítě', 'Default' => '', 'Null' => true),
    5252        'Info' => array('Type' => 'Text', 'Caption' => 'Informace', 'Default' => ''),
    53         'Esemble' => array('Type' => 'TStockItem', 'Caption' => 'Celek', 'Default' => ''),
    54         'Parts' => array('Type' => 'TStockItemListStockItem', 'Caption' => 'Části', 'Default' => ''),
     53        'Esemble' => array('Type' => 'TStockSerialNumber', 'Caption' => 'Celek', 'Default' => ''),
     54        'Parts' => array('Type' => 'TStockSerialNumberListStockSerialNumber', 'Caption' => 'Části', 'Default' => ''),
    5555      ),
    5656    ));
     
    6262        'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
    6363        'Location' => array('Type' => 'TMember', 'Caption' => 'Umístění', 'Default' => '', 'Null' => true),
    64         'Items' => array('Type' => 'TStockItemListStock', 'Caption' => 'Položky', 'Default' => ''),
     64        'Items' => array('Type' => 'TStockSerialNumberListStock', 'Caption' => 'Položky', 'Default' => ''),
    6565        'ItemsCount' => array('Type' => 'Integer', 'Caption' => 'Položek', 'Default' => '',
    66           'ReadOnly' => true, 'SQL' => '(SELECT COUNT(*) FROM `StockItem` WHERE '.
    67           '(`StockItem`.`Stock`=#Id) AND (`StockItem`.`TimeElimination` IS NULL))'),
     66          'ReadOnly' => true, 'SQL' => '(SELECT COUNT(*) FROM `StockSerialNumber` WHERE '.
     67          '(`StockSerialNumber`.`Stock`=#Id) AND (`StockSerialNumber`.`TimeElimination` IS NULL))'),
    6868        'TotalPrice' => array('Type' => 'Integer', 'Caption' => 'Celková cena', 'Default' => '',
    69           'ReadOnly' => true, 'SQL' => '(SELECT SUM(`SellPrice`) FROM `StockItem` WHERE '.
    70           '(`StockItem`.`Stock`=#Id) AND (`StockItem`.`TimeElimination` IS NULL))', 'Suffix' => 'Kč'),
     69          'ReadOnly' => true, 'SQL' => '(SELECT SUM(`SellPrice`) FROM `StockSerialNumber` WHERE '.
     70          '(`StockSerialNumber`.`Stock`=#Id) AND (`StockSerialNumber`.`TimeElimination` IS NULL))', 'Suffix' => 'Kč'),
    7171      ),
    7272    ));
     73    $this->System->FormManager->RegisterClass('StockMove', array(
     74      'Title' => 'Skladový pohyb',
     75      'Table' => 'StockMove',
     76      'DefaultSortColumn' => 'Time',
     77      'Items' => array(
     78        'DocumentLine' => array('Type' => 'TDocumentLine', 'Caption' => 'Dokladová řada', 'Default' => ''),
     79        'BillCode' => array('Type' => 'String', 'Caption' => 'Označení', 'Default' => ''),
     80        'Time' => array('Type' => 'DateTime', 'Caption' => 'Čas', 'Default' => ''),
     81        'StockFrom' => array('Type' => 'TStock', 'Caption' => 'Zdrojový sklad', 'Default' => '', 'Null' => true),
     82        'StockTo' => array('Type' => 'TStock', 'Caption' => 'Cílový sklad', 'Default' => '', 'Null' => true),
     83        'File' => array('Type' => 'TFile', 'Caption' => 'Doklad', 'Default' => '', 'Null' => true),
     84        'Price' => array('Type' => 'Float', 'Caption' => 'Cena', 'Default' => '',
     85          'ReadOnly' => true, 'Suffix' => 'Kč', 'SQL' => '(SELECT SUM(`StockMoveItem`.`UnitPrice` * `StockMoveItem`.`Amount`) FROM `StockMoveItem` '.
     86          'WHERE `StockMoveItem`.`StockMove`=#Id)'),
     87        'Items' => array('Type' => 'TStockMoveItemListStockMove', 'Caption' => 'Položky', 'Default' => ''),
     88      ),       
     89      'BeforeInsert' => array($this, 'BeforeInsertStockMove'),
     90    ));
     91    $this->System->FormManager->RegisterClass('StockMoveItem', array(
     92      'Title' => 'Položka skladového pohybu',
     93      'Table' => 'StockMoveItem',
     94      'DefaultSortColumn' => 'Text',
     95      'Items' => array(
     96        'StockMove' => array('Type' => 'TStockMove', 'Caption' => 'Skladový pohyb', 'Default' => ''),
     97        'Product' => array('Type' => 'TProduct', 'Caption' => 'Produkt', 'Default' => ''),
     98        'Amount' => array('Type' => 'Integer', 'Caption' => 'Množství', 'Default' => '1'),
     99        'Text' => array('Type' => 'String', 'Caption' => 'Text', 'Default' => ''),
     100        'UnitPrice' => array('Type' => 'Integer', 'Caption' => 'Jednotková cena', 'Default' => '0', 'Suffix' => 'Kč'),
     101      ),       
     102    ));
     103    $this->System->FormManager->RegisterFormType('TStockMoveItemListStockMove', array(
     104      'Type' => 'ManyToOne',
     105      'Table' => 'StockMoveItem',
     106      'Id' => 'Id',
     107      'Ref' => 'StockMove',
     108      'Filter' => '1',
     109    )); 
     110    $this->System->FormManager->RegisterFormType('TStockMove', array(
     111      'Type' => 'Reference',
     112      'Table' => 'StockMove',
     113      'Id' => 'Id',
     114      'Name' => 'BillCode',
     115      'Filter' => '1',
     116    ));
     117  }
     118
     119  function BeforeInsertStockMove($Form)
     120  {
     121        if(array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);
     122          else $Year = date("Y", $Form->Values['ValidFrom']);
     123    $DocumentLine = $Form->Values['DocumentLine'];
     124    $Form->Values['BillCode'] = $this->System->Modules['Finance']->GetNextDocumentLineNumber($DocumentLine, $Year);
     125    return($Form->Values);
    73126  }
    74127}
Note: See TracChangeset for help on using the changeset viewer.