Changeset 715


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.
Location:
trunk
Files:
2 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/Version.php

    r711 r715  
    11<?php
    22
    3 $Revision = 711; // Subversion revision
    4 $DatabaseRevision = 710; // SQL structure revision
    5 $ReleaseTime = strtotime('2014-12-29');
     3$Revision = 715; // Subversion revision
     4$DatabaseRevision = 715; // SQL structure revision
     5$ReleaseTime = strtotime('2015-01-01');
  • trunk/Common/Setup/Updates.php

    r710 r715  
    993993      "VALUES (NULL , 'Skladové pohyby', ".$DbRow['Id'].", '".$ActionId."', '1');");
    994994  }
     995}
     996
     997function UpdateTo715($Manager)
     998{
     999        $Manager->Execute('ALTER TABLE `StockSerialNumber` DROP FOREIGN KEY `StockSerialNumber_ibfk_6`;');
     1000        $Manager->Execute('ALTER TABLE `StockSerialNumber` DROP `Segment`');
     1001        $Manager->Execute('ALTER TABLE `Member` DROP `NetworkSegment`');
     1002        $Manager->Execute('DROP TABLE `NetworkSegment`');
    9951003}
    9961004
     
    10481056      696 => array('Revision' => 697, 'Function' => 'UpdateTo697'),
    10491057      697 => array('Revision' => 707, 'Function' => 'UpdateTo707'),
    1050       707 => array('Revision' => 710, 'Function' => 'UpdateTo710'),
     1058      710 => array('Revision' => 715, 'Function' => 'UpdateTo715'),
    10511059    ));
    10521060  }
  • trunk/Modules/Customer/Customer.php

    r711 r715  
    2929        'BillingPeriodNext' => array('Type' => 'TFinanceBillingPeriod', 'Caption' => 'Fakturační období příští', 'Default' => ''),
    3030        'BillingPeriodLastDate' => array('Type' => 'Date', 'Caption' => 'Datum poslední fakturace', 'Default' => ''),
    31         'NetworkSegment' => array('Type' => 'TNetworkSegment', 'Caption' => 'Úsek sítě', 'Default' => '', 'Null' => true),
    3231        'Blocked' => array('Type' => 'Boolean', 'Caption' => 'Blokování', 'Default' => '0'),
    3332        'PayDay' => array('Type' => 'Integer', 'Caption' => 'Den placení', 'Default' => '0', 'Suffix' => 'den'),
  • 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' => ''),
  • trunk/Modules/Finance/Manage.php

    r710 r715  
    1818    {
    1919      case 'Recalculate':
    20         $Output = $this->System->Modules['Finance']->RecalculateSegmentParameters();
    2120        $Output .= $this->System->Modules['Finance']->RecalculateMemberPayment();
    2221        break;
     
    226225    $MonthCurrent = date('m') + 0;
    227226
    228     $Output .= $Finance->RecalculateSegmentParameters();
    229227    $Output .= $Finance->LoadTariffs();
    230228    $Output .= $Finance->RecalculateMemberPayment();
     
    236234    $TotalDeviceCost = $Row[0];
    237235    $Output .= 'Celková cena zařízení: Zařízení('.$TotalDeviceCost;
    238 
    239     $DbResult = $this->Database->query('SELECT SUM(Price) FROM NetworkSegment');
    240     $Row = $DbResult->fetch_row();
    241     $TotalSegmentDeviceCost = $Row[0];
    242     $Output .= '), Segmenty('.$TotalSegmentDeviceCost;
    243236
    244237    $DbResult = $this->Database->query('SELECT SUM(NetworkDevice) FROM MemberPayment');
  • trunk/Modules/Finance/Overview.php

    r710 r715  
    1515    $Output .= '<a href="'.$this->System->Link('/finance/mesicni-prehledy/').'">Měsíční přehledy</a><br />';
    1616    $Output .= '<a href="'.$this->System->Link('/finance/sluzby/').'">Přehled nabízených služeb</a><br />';
    17     $Output .= '<a href="'.$this->System->Link('/finance/zarizeni/').'">Výpis zařízení</a><br />';
    1817    if($this->System->User->CheckPermission('Finance', 'SubjectList'))
    1918      $Output .= '<a href="'.$this->System->Link('/finance/zakaznici/').'">Seznam zákazníků</a><br />';
    20     $Output .= '<a href="'.$this->System->Link('/finance/spotreba/').'">Spotřeba energie</a><br />';
    2119    //$Output .= '<a href="'.$this->System->Config['Web']['RootFolder'].'/aktuality/index.php?category=9">Investice v síti</a><br />';
    2220   
  • trunk/Modules/FinanceBankAPI/ImportFio.php

    r628 r715  
    2727      if($DbResult->num_rows == 0)
    2828      {     
    29       $Output .= '<tr>';
     29        $Output .= '<tr>';
    3030        $this->Database->insert('FinanceBankImport', array('Time' => TimeToMysqlDate($Record['Date']),
    3131          'BankAccount' => $this->BankAccount['Id'], 'Value' => $Record['Value'],
     
    3434          'Identification' => $Record['ID'], 'AccountNumber' => $Record['OffsetAccount'],
    3535          'BankCode' => $Record['BankCode'], 'Description' => $Record['Type'], 'OffsetAccountName' => $Record['UserIdent']));
    36       $Output .= '<td>'.$Record['OffsetAccount'].'</td>';
    37       $Output .= '<td>'.$Record['BankCode'].'</td>';
    38       $Output .= '<td>'.$Record['UserIdent'].'</td>';
    39       $Output .= '</tr>';
     36        $Output .= '<td>'.$Record['OffsetAccount'].'</td>';
     37        $Output .= '<td>'.$Record['BankCode'].'</td>';
     38        $Output .= '<td>'.$Record['UserIdent'].'</td>';
     39        $Output .= '<td>'.$Record['Value'].'</td>';
     40        $Output .= '</tr>';
    4041      }
    4142    }
    4243    $Output .= '</table>';   
    43     $this->Database->update('FinanceBankAccount', 'Id='.$this->BankAccount['Id'], array('LastImportDate' => TimeToMysqlDate($PeriodEnd)));
     44    $this->Database->update('FinanceBankAccount', 'Id='.$this->BankAccount['Id'],
     45        array('LastImportDate' => TimeToMysqlDate($PeriodEnd)));
    4446    return($Output);
    4547  }
  • trunk/Modules/Network/Network.php

    r712 r715  
    262262      ),
    263263    ));
    264     $this->System->FormManager->RegisterClass('NetworkSegment', array(
    265       'Title' => 'Úsek sítě',
    266       'Table' => 'NetworkSegment',
    267       'Items' => array(
    268         'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
    269         'Price' => array('Type' => 'Integer', 'Caption' => 'Cena', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true),
    270         'Parent' => array('Type' => 'TNetworkSegment', 'Caption' => 'Nadřazený', 'Default' => '', 'Null' => true),
    271         'Users' => array('Type' => 'Integer', 'Caption' => 'Uživatelů', 'Default' => '0', 'ReadOnly' => true),
    272         'Consumption' => array('Type' => 'Integer', 'Caption' => 'Spotřeba', 'Default' => '0', 'ReadOnly' => true, 'Suffix' => 'Wattů'),
    273         'UsersOverheads' => array('Type' => 'Integer', 'Caption' => 'Podílníků', 'Default' => '0', 'ReadOnly' => true),
    274       ),
    275     ));
    276264    $this->System->FormManager->RegisterClass('DeviceAPIType', array(
    277265      'Title' => 'Typ API zařízení',
     
    406394      'Filter' => '1',
    407395    ));
    408     $this->System->FormManager->RegisterFormType('TNetworkSegment', array(
    409         'Type' => 'Reference',
    410         'Table' => 'NetworkSegment',
    411         'Id' => 'Id',
    412         'Name' => 'Name',
    413         'Filter' => '1',
    414     ));
    415    
    416396  }
    417397
  • trunk/Modules/Stock/Stock.php

    r711 r715  
    4949        'RegNumber' => array('Type' => 'String', 'Caption' => 'Evidenční číslo', 'Default' => '', 'Null' => true),
    5050        'Location' => array('Type' => 'TMember', 'Caption' => 'Umístění', 'Default' => '', 'Null' => true),
    51         'Segment' => array('Type' => 'TNetworkSegment', 'Caption' => 'Úsek sítě', 'Default' => '', 'Null' => true),
    5251        'Info' => array('Type' => 'Text', 'Caption' => 'Informace', 'Default' => ''),
    5352        'Esemble' => array('Type' => 'TStockSerialNumber', 'Caption' => 'Celek', 'Default' => ''),
Note: See TracChangeset for help on using the changeset viewer.