Changeset 451


Ignore:
Timestamp:
Oct 24, 2012, 10:42:58 PM (12 years ago)
Author:
chronos
Message:
  • Upraveno: Korekce tabulek Product a StockItem.
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/finance/finance.php

    r444 r451  
    170170      $Cash = $Cash[0];
    171171   
    172       $DbResult2 = $this->Database->query('SELECT SUM(Consumption) FROM Product WHERE (User='.$Member['Id'].') AND (Used = 1)');
     172      $DbResult2 = $this->Database->query('SELECT SUM(`Product`.`Consumption`) * `StockItem`.`Amount` '.
     173        'FROM `StockItem` JOIN `Product` ON `Product`.`Id` = `StockItem`.`Product` '.
     174        'WHERE (`StockItem`.`Location` = '.$Member['Id'].') AND (`StockItem`.`TimeElimination` IS NULL)');
    173175      $ConsumptionPlus = $DbResult2->fetch_row();
    174176      $ConsumptionPlus = $ConsumptionPlus[0];
     
    232234      $RowP2 = $DbResult2->fetch_array();
    233235
    234       $DbResult2 = $this->Database->query('SELECT SUM(Price) AS Price, SUM(Consumption) AS Consumption FROM Product WHERE Segment='.$NetworkSegment['Id'].' AND Used=1');
     236      $DbResult2 = $this->Database->query('SELECT SUM(`Product`.`BuyPrice`) * `StockItem`.`Amount` AS `Price`, '.
     237        'SUM(`Product`.`Consumption`) * `StockItem`.`Amount` AS `Consumption` '.
     238        'FROM `StockItem` JOIN `Product` ON `Product`.`Id` = `StockItem`.`Product` '.
     239        'WHERE (`StockItem`.`Segment`='.$NetworkSegment['Id'].') AND (`StockItem`.`TimeElimination` IS NULL)');
    235240      $Row2 = $DbResult2->fetch_array();
    236241      $DbResult2 = $this->Database->query('SELECT COUNT(*) FROM Member WHERE NetworkSegment='.$NetworkSegment['Id']);
  • trunk/finance/index.php

    r438 r451  
    5757    $TotalGain = 0;
    5858    $TotalExpense = 0;
    59     $DbResult = $this->Database->query('SELECT SUM(Consumption) FROM Product WHERE Used=1');
     59    $DbResult = $this->Database->query('SELECT SUM(Product.Consumption) * StockItem.Amount FROM StockItem '.
     60      'JOIN Product ON Product.Id=StockItem.Product WHERE (StockItem.TimeElimination IS NULL)');
    6061    $Row = $DbResult->fetch_array();
    6162    $TotalConsumption = $this->System->Modules['Finance']->W2Kc($Row[0]);
  • trunk/form_classes.php

    r449 r451  
    110110    'Items' => array(
    111111      'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
    112       'SellPrice' => array('Type' => 'Integer', 'Caption' => 'Cena', 'Default' => '0'),
     112      'SellPrice' => array('Type' => 'Integer', 'Caption' => 'Prodejní cena', 'Default' => '0'),
     113      'BuyPrice' => array('Type' => 'Integer', 'Caption' => 'Kupní cena', 'Default' => '0'),
    113114      'VAT' => array('Type' => 'Integer', 'Caption' => 'DPH', 'Default' => '0'),
    114115      'Consumption' => array('Type' => 'Integer', 'Caption' => 'Spotřeba', 'Default' => ''),
     
    133134      'Location' => array('Type' => 'TMember', 'Caption' => 'Umístění', 'Default' => '', 'Null' => true),
    134135      'Segment' => array('Type' => 'TNetworkSegment', 'Caption' => 'Úsek sítě', 'Default' => '', 'Null' => true),
     136      'Info' => array('Type' => 'Text', 'Caption' => 'Informace', 'Default' => ''),
    135137    ),
    136138  ),
  • trunk/sql/updates/446.sql

    r450 r451  
    44RENAME TABLE `StockCard` TO `Product` ;
    55ALTER TABLE `Product` CHANGE `Code` `Code` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_czech_ci NULL ;
     6ALTER TABLE `Product` ADD `BuyPrice` FLOAT NOT NULL AFTER `SellPrice`;
    67
    78DROP TABLE IF EXISTS `StockItem`;
     
    3132ALTER TABLE `StockItem` CHANGE `Segment` `Segment` INT( 11 ) NULL;
    3233ALTER TABLE `StockItem` ADD `Info` TEXT NOT NULL ;
     34ALTER TABLE `StockItem` CHANGE `TimeElimination` `TimeElimination` DATE NULL;
    3335
    3436ALTER TABLE `Stock` ADD `Location` INT NULL , ADD INDEX ( `Location` );
  • trunk/temp/product.php

    r450 r451  
    1313 
    1414  $System->Database->insert('Product', array('Name' => $DbRow['Name'], 'SellPrice' => $DbRow['Price'],
    15      'Consumption' => $DbRow['Consumption'], 'UnitOfMeasure' => 1, 'VAT' => 20));
     15    'BuyPrice' => $DbRow['Price'],
     16    'Consumption' => $DbRow['Consumption'], 'UnitOfMeasure' => 1, 'VAT' => 20));
    1617  $ProductId = $System->Database->insert_id;
    1718  $Database->insert('StockItem', array('Stock' => 1, 'Product' => $ProductId, 'Amount' => $DbRow['Count'],
    1819    'Segment' => $DbRow['Segment'], 'TimeEnlistment' => $DbRow['Date'], 'SerialNumber' => $DbRow['DeviceId'],
    19       'Location' => $DbRow['User'], 'Info' => $DbRow['Info']));
     20    'Location' => $DbRow['User'], 'Info' => $DbRow['Info']));
    2021}
    2122
Note: See TracChangeset for help on using the changeset viewer.