Ignore:
Timestamp:
Oct 4, 2012, 8:29:32 AM (12 years ago)
Author:
chronos
Message:
  • Upraveno: Přejmenována sql tabulka network_segments na NetworkSegment.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/finance/finance.php

    r407 r408  
    113113   
    114114    $this->SpravaUsers = $this->InternetUsers;
    115     $DbResult = $this->Database->query('SELECT SUM(consumption) FROM network_segments');
     115    $DbResult = $this->Database->query('SELECT SUM(Consumption) FROM NetworkSegment');
    116116    $TotalConsumption = $DbResult->fetch_array();
    117117    $this->TotalConsumption = $TotalConsumption[0];
     
    172172      $Consumption = 0;
    173173      $ID = $Member['NetworkSegment'];
    174       while($ID != 0)
    175       {
    176         $DbResult2 = $this->Database->query('SELECT * FROM `network_segments` WHERE `id`='.$ID);
     174      while($ID != 'NULL')
     175      {
     176        $DbResult2 = $this->Database->query('SELECT * FROM `NetworkSegment` WHERE `Id`='.$ID);
    177177        $Device = $DbResult2->fetch_assoc();
    178         $NetworkDevice += $Device['price'] / $Device['users'];
    179         $Consumption += $Device['consumption'] / $Device['users_overheads'];
     178        $NetworkDevice += $Device['Price'] / $Device['Users'];
     179        $Consumption += $Device['Consumption'] / $Device['UsersOverheads'];
    180180        //echo($ID.' '.$InternetSegment.' '.$InternetSegmentId.' '.$Row['inet_hw'].' '.$Price.'<br>');
    181         $ID = $Device['parent'];
     181        $ID = $Device['Parent'];
    182182      }
    183183   
     
    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 `NetworkSegment` SET `Users` = 0, `UsersOverheads` = 0');     // Vynulovat počty uživatelů
     215    $DbResult = $this->Database->query('SELECT * FROM `NetworkSegments`');
    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 `NetworkSegment` 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 `UsersOverheads` FROM `NetworkSegment` WHERE `Id`='.$NetworkSegment['Id']);
    222222      $RowP2 = $DbResult2->fetch_array();
    223223
    224       $DbResult2 = $this->Database->query('SELECT SUM(price) as Price, SUM(consumption) as Consumption FROM network_devices WHERE segment='.$NetworkSegment['id'].' AND used=1');
     224      $DbResult2 = $this->Database->query('SELECT SUM(Price) AS Price, SUM(Consumption) AS Consumption FROM NetworkDevice WHERE Segment='.$NetworkSegment['Id'].' AND Used=1');
    225225      $Row2 = $DbResult2->fetch_array();
    226226      $DbResult2 = $this->Database->query('SELECT COUNT(*) FROM Member WHERE NetworkSegment='.$NetworkSegment['id']);
     
    230230      {
    231231        //echo($ID.', ');
    232         $DbResult2 = $this->Database->query('SELECT * FROM network_segments WHERE id='.$ID);
     232        $DbResult2 = $this->Database->query('SELECT * FROM NetworkSegment WHERE Id='.$ID);
    233233        $Row4 = $DbResult2->fetch_array();
    234         $this->Database->update('network_segments', 'id='.$Row4['id'], array('users' => ($Row4['users'] + $Row3[0]), 'users_overheads' => ($Row4['users_overheads'] + $Row3[0])));
     234        $this->Database->update('NetworkSegment', 'Id='.$Row4['Id'], array('Users' => ($Row4['Users'] + $Row3[0]), 'UsersOverheads' => ($Row4['UsersOverheads'] + $Row3[0])));
    235235        $ID = $Row4['parent'];
    236236      }
    237       $this->Database->update('network_segments', 'id='.$NetworkSegment['id'], array('price' => $Row2['Price'], 'users' => ($Row3[0] + $RowP['users']), 'consumption' => $Row2['Consumption'], 'users_overheads' => ($Row3[0] + $RowP2['users_overheads'])));
     237      $this->Database->update('NetworkSegment', 'Id='.$NetworkSegment['Id'], array('Price' => $Row2['Price'], 'Users' => ($Row3[0] + $RowP['Users']), 'Consumption' => $Row2['Consumption'], 'UsersOverheads' => ($Row3[0] + $RowP2['UsersOverheads'])));
    238238    }
    239239
     
    241241    $DbResult = $this->Database->select('Member', 'COUNT(*)');
    242242    $Row = $DbResult->fetch_array();
    243     $DbResult = $this->Database->update('network_segments','id='.$this->InternetSegmentId, array('users' => $Row[0], 'users_overheads' => $Row[0]));
     243    $DbResult = $this->Database->update('NetworkSegments', 'Id='.$this->InternetSegmentId, array('Users' => $Row[0], 'UsersOverheads' => $Row[0]));
    244244    $this->System->Modules['Log']->NewRecord('Finance', 'RecalculateSegmentParameters');
    245245    return($Output);
Note: See TracChangeset for help on using the changeset viewer.