Ignore:
Timestamp:
Jan 1, 2015, 2:18:20 PM (10 years ago)
Author:
chronos
Message:
  • Removed: Unused table NetworkSegment which was previously used to compute exact member participation on device and consumption payment. Now consumption is handled with customer Service table.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Finance/Finance.php

    r713 r715  
    22
    33include_once(dirname(__FILE__).'/Overview.php');
    4 include_once(dirname(__FILE__).'/Consumption.php');
    5 include_once(dirname(__FILE__).'/Devices.php');
    64include_once(dirname(__FILE__).'/Bill.php');
    75include_once(dirname(__FILE__).'/Services.php');
     
    3432  var $SpeedReserve;
    3533  var $BaseSpeedElement;
    36   var $TotalConsumption;
    3734  var $UserIdNetwork = 46;
    3835  var $BaseTariffPrice;
     
    143140    $this->SpravaUsers = $this->PayingUsers;
    144141
    145     $DbResult = $this->Database->query('SELECT SUM(`Consumption`) FROM `NetworkSegment`');
    146     $TotalConsumption = $DbResult->fetch_array();
    147     $this->TotalConsumption = $TotalConsumption[0];
    148 
    149142    $DbResult = $this->Database->query('SELECT SUM(`MemberPayment`.`MonthlyInternet`) AS `MonthlyInternet`, '.
    150143        'SUM(`MemberPayment`.`MonthlyTotal`) AS `MonthlyTotal` '.
     
    208201      $ConsumptionPlus = $DbResult2->fetch_row();
    209202      $ConsumptionPlus = $ConsumptionPlus[0];
    210 
    211       $NetworkDevice = 0;
    212       $Consumption = 0;
    213       $Id = $Member['NetworkSegment'];
    214       while(($Id != '') and ($Id != 0))
    215       {
    216         $DbResult2 = $this->Database->query('SELECT * FROM `NetworkSegment` WHERE `Id`='.$Id);
    217         $Device = $DbResult2->fetch_assoc();
    218         if($Device['Users'] > 0) $NetworkDevice += $Device['Price'] / $Device['Users'];
    219         if($Device['UsersOverheads'] > 0) $Consumption += $Device['Consumption'] / $Device['UsersOverheads'];
    220         $Id = $Device['Parent'];
    221       }
    222203
    223204      $DbResult2 = $this->Database->query('SELECT SUM(`Service`.`Price`) AS `Price` '.
     
    253234  }
    254235
    255   function RecalculateSegmentParameters()
    256   {
    257     $Output = 'Aktualizuji parametry segmentů...<br />';
    258     $this->Database->query('UPDATE `NetworkSegment` SET `Users` = 0, `UsersOverheads` = 0');     // Vynulovat počty uživatelů
    259     $DbResult = $this->Database->query('SELECT * FROM `NetworkSegment`');
    260     while($NetworkSegment = $DbResult->fetch_array())
    261     {
    262       $DbResult2 = $this->Database->query('SELECT `Users` FROM `NetworkSegment` WHERE `Id`='.$NetworkSegment['Id']);
    263       $RowP = $DbResult2->fetch_array();
    264       $DbResult2 = $this->Database->query('SELECT `UsersOverheads` FROM `NetworkSegment` WHERE `Id`='.$NetworkSegment['Id']);
    265       $RowP2 = $DbResult2->fetch_array();
    266 
    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)');
    271       $Row2 = $DbResult2->fetch_array();
    272       $DbResult2 = $this->Database->query('SELECT COUNT(*) FROM Member WHERE NetworkSegment='.$NetworkSegment['Id']);
    273       $Row3 = $DbResult2->fetch_array();
    274       $ID = $NetworkSegment['Parent'];
    275       while($ID != 0)
    276       {
    277         $DbResult2 = $this->Database->query('SELECT * FROM NetworkSegment WHERE Id='.$ID);
    278         $Row4 = $DbResult2->fetch_array();
    279         $this->Database->update('NetworkSegment', 'Id='.$Row4['Id'],
    280             array('Users' => ($Row4['Users'] + $Row3[0]), 'UsersOverheads' => ($Row4['UsersOverheads'] + $Row3[0])));
    281         $ID = $Row4['Parent'];
    282       }
    283       $this->Database->update('NetworkSegment', 'Id='.$NetworkSegment['Id'],
    284           array('Price' => $Row2['Price'], 'Users' => ($Row3[0] + $RowP['Users']), 'Consumption' => $Row2['Consumption'], 'UsersOverheads' => ($Row3[0] + $RowP2['UsersOverheads'])));
    285     }
    286 
    287     // Zkorigovat segment Internet
    288     $DbResult = $this->Database->select('Member', 'COUNT(*)');
    289     $Row = $DbResult->fetch_array();
    290     $DbResult = $this->Database->update('NetworkSegment', 'Id='.$this->InternetSegmentId,
    291         array('Users' => $Row[0], 'UsersOverheads' => $Row[0]));
    292     $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'RecalculateSegmentParameters');
    293     return($Output);
    294   }
    295 
    296236  function GetVATByType($TypeId)
    297237  {
     
    331271
    332272    $this->System->RegisterPage('finance', 'PageFinance');
    333     $this->System->RegisterPage(array('finance', 'spotreba'), 'PageFinanceConsumption');
    334     $this->System->RegisterPage(array('finance', 'zarizeni'), 'PageFinanceDeviceList');
    335273    $this->System->RegisterPage(array('finance', 'sluzby'), 'PageFinanceServices');
    336274    $this->System->RegisterPage(array('finance', 'mesicni-prehledy'), 'PageFinanceMonthlyOverall');
     
    433371        'Bank' => array('Type' => 'TFinanceBank', 'Caption' => 'Banka', 'Default' => ''),
    434372        'TimeCreate' => array('Type' => 'Date', 'Caption' => 'Čas vytvoření', 'Default' => ''),
    435         'TimeEnd' => array('Type' => 'Date', 'Caption' => 'Čas zrušení', 'Default' => ''),
     373        'TimeEnd' => array('Type' => 'Date', 'Caption' => 'Čas zrušení', 'Default' => '', 'Null' => true),
    436374        'Currency' => array('Type' => 'TCurrency', 'Caption' => 'Měna', 'Default' => ''),
    437375        'LoginName' => array('Type' => 'String', 'Caption' => 'Přihlašovací jméno / token', 'Default' => ''),
Note: See TracChangeset for help on using the changeset viewer.