Changeset 710 for trunk/Modules/Finance


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

Legend:

Unmodified
Added
Removed
  • 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())
Note: See TracChangeset for help on using the changeset viewer.