Ignore:
Timestamp:
Dec 17, 2011, 3:10:03 PM (13 years ago)
Author:
chronos
Message:
  • Upraveno: Tabulka FinanceTariff přetvořena tak, aby se bylo možné odkazovat z jiných tabulek přes standardní primární klíč. Doposud se odkazovalo na sloupec Tariff což dělalo paseku. Překlápění nových tarifů se nyní provádní namísto sloupce Period pomocí sloupece ReplaceId, kde u nových položek se nastaví Id tarifu, který bude v novém měsící aktualizován. Id tarifů nyní musí začínat od jedničky.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/finance/finance.php

    r301 r327  
    2525  var $BillingPeriods;
    2626 
    27   function LoadTariffs($Period = 1)
     27  function LoadTariffs()
    2828  {
    2929    $this->Tariffs = array();
    30     $DbResult = $this->Database->select('FinanceTariff', '*', 'Period='.$Period.' ORDER BY Tariff, SpeedMax');
     30    $DbResult = $this->Database->select('FinanceTariff', '*', 'ReplaceId IS NULL ORDER BY SpeedMax');
    3131    while($Tariff = $DbResult->fetch_array())
    3232    {
    3333      $Tariff['SpeedMin'] = $Tariff['SpeedMin'] * 1024;
    3434      $Tariff['SpeedMax'] = $Tariff['SpeedMax'] * 1024;
    35       $this->Tariffs[$Tariff['Tariff']] = $Tariff;
     35      $this->Tariffs[$Tariff['Id']] = $Tariff;
    3636    } 
    3737  }
    3838 
    39   function RecalculateTariffs($Period = 1)
     39  function RecalculateTariffs()
    4040  {
    4141    $ResidualSpeed = $this->MaxSpeed * 1024;
    4242 
    43     $this->LoadTariffs($Period);
     43    $this->LoadTariffs();
    4444   
    4545    $Column = array('Current', 'Next');
     
    4848    foreach($this->Tariffs as $Index => $Tariff)
    4949    {
    50       $DbResult = $this->Database->select('Member', 'COUNT(*)', 'InternetTariff'.$Column[$Period].'Month='.$Index.' AND (BillingPeriod > 1)');
     50      $DbResult = $this->Database->select('Member', 'COUNT(*)', 'InternetTariffCurrentMonth='.$Index.' AND (BillingPeriod > 1)');
    5151      $Row = $DbResult->fetch_row();
    5252      $this->Tariffs[$Index]['MemberCount'] = $Row[0];
     
    8585      }
    8686      //echo('MinSpeed: '.$Tariff['SpeedMin'].'<br />');
    87       $this->Database->update('FinanceTariff', 'Tariff='.$Tariff['Tariff'], array('SpeedMin' => ($Tariff['SpeedMin'] / 1024), 'MemberCount' => $Tariff['MemberCount']));
    88     }
    89     $this->LoadTariffs($Period);
     87      $this->Database->update('FinanceTariff', 'Id='.$Tariff['Id'], array('SpeedMin' => ($Tariff['SpeedMin'] / 1024), 'MemberCount' => $Tariff['MemberCount']));
     88    }
     89    $this->LoadTariffs();
    9090  }
    9191
     
    174174      while($ID != 0)
    175175      {
    176         $DbResult2 = $this->Database->query('SELECT * FROM network_segments WHERE id='.$ID);
     176        $DbResult2 = $this->Database->query('SELECT * FROM `network_segments` WHERE `id`='.$ID);
    177177        $Device = $DbResult2->fetch_assoc();
    178178        $NetworkDevice += $Device['price'] / $Device['users'];
     
    212212  {
    213213    $Output = 'Aktualizuji parametry segmentů...<br />';
    214     $this->Database->query('UPDATE network_segments SET users = 0, users_overheads = 0');     // Vynulovat počty uživatelů
    215     $DbResult = $this->Database->query('SELECT * FROM network_segments');
     214    $this->Database->query('UPDATE `network_segments` SET `users` = 0, `users_overheads` = 0');     // Vynulovat počty uživatelů
     215    $DbResult = $this->Database->query('SELECT * FROM `network_segments`');
    216216    while($NetworkSegment = $DbResult->fetch_array())
    217217    {
    218218      //echo('Segment '.$Row['name'].'<br>');
    219       $DbResult2 = $this->Database->query('SELECT users FROM network_segments WHERE id='.$NetworkSegment['id']);
     219      $DbResult2 = $this->Database->query('SELECT `users` FROM `network_segments` WHERE `id`='.$NetworkSegment['id']);
    220220      $RowP = $DbResult2->fetch_array();
    221       $DbResult2 = $this->Database->query('SELECT users_overheads FROM network_segments WHERE id='.$NetworkSegment['id']);
     221      $DbResult2 = $this->Database->query('SELECT `users_overheads` FROM `network_segments` WHERE `id`='.$NetworkSegment['id']);
    222222      $RowP2 = $DbResult2->fetch_array();
    223223
Note: See TracChangeset for help on using the changeset viewer.