Ignore:
Timestamp:
Jan 20, 2012, 3:32:02 PM (13 years ago)
Author:
chronos
Message:
  • Přidáno: Model pro NetworkSegment.
  • Upraveno: Přepracován model systém pro načítání modelů modulů.
File:
1 edited

Legend:

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

    r377 r378  
    287287    $this->Description = 'Accounting processing';
    288288    $this->Dependencies = array('User', 'Subject');
    289     $this->Models = array('FinanceYear', 'DocumentLine', 'DocumentLineSequence',
     289    $this->SupportedModels = array('FinanceYear', 'DocumentLine', 'DocumentLineSequence',
    290290      'FinanceTariff', 'FinanceOperation', 'FinanceClaimsLiabilities',
    291291      'FinanceBills', 'FinanceBillsItems', 'FinanceBillingPeriod', 'FinanceCharge',
     
    398398   
    399399    $this->SpravaUsers = $this->InternetUsers;
    400     $DbResult = $this->Database->query('SELECT SUM(`Consumption`) FROM `network_segments`');
     400    $DbResult = $this->Database->query('SELECT SUM(`Consumption`) FROM `NetworkSegments`');
    401401    $TotalConsumption = $DbResult->fetch_array();
    402402    $this->TotalConsumption = $TotalConsumption[0];
     
    459459      while($ID != 0)
    460460      {
    461         $DbResult2 = $this->Database->query('SELECT * FROM `network_segments` WHERE `id`='.$ID);
     461        $DbResult2 = $this->Database->query('SELECT * FROM `NetworkSegments` WHERE `Id`='.$ID);
    462462        $Device = $DbResult2->fetch_assoc();
    463         $NetworkDevice += $Device['price'] / $Device['users'];
    464         $Consumption += $Device['consumption'] / $Device['users_overheads'];
     463        $NetworkDevice += $Device['Price'] / $Device['Users'];
     464        $Consumption += $Device['Consumption'] / $Device['UsersOverheads'];
    465465        //echo($ID.' '.$InternetSegment.' '.$InternetSegmentId.' '.$Row['inet_hw'].' '.$Price.'<br>');
    466         $ID = $Device['parent'];
     466        $ID = $Device['Parent'];
    467467      }
    468468   
     
    497497  {
    498498    $Output = 'Aktualizuji parametry segmentů...<br />';
    499     $this->Database->query('UPDATE `network_segments` SET `users` = 0, `users_overheads` = 0');     // Vynulovat počty uživatelů
    500     $DbResult = $this->Database->query('SELECT * FROM `network_segments`');
     499    $this->Database->query('UPDATE `NetworkSegments` SET `Users` = 0, `UsersOverheads` = 0');     // Vynulovat počty uživatelů
     500    $DbResult = $this->Database->query('SELECT * FROM `NetworkSegments`');
    501501    while($NetworkSegment = $DbResult->fetch_array())
    502502    {
    503503      //echo('Segment '.$Row['name'].'<br>');
    504       $DbResult2 = $this->Database->query('SELECT `users` FROM `network_segments` WHERE `id`='.$NetworkSegment['id']);
     504      $DbResult2 = $this->Database->query('SELECT `Users` FROM `NetworkSegments` WHERE `Id`='.$NetworkSegment['Id']);
    505505      $RowP = $DbResult2->fetch_array();
    506       $DbResult2 = $this->Database->query('SELECT `users_overheads` FROM `network_segments` WHERE `id`='.$NetworkSegment['id']);
     506      $DbResult2 = $this->Database->query('SELECT `UsersOverheads` FROM `NetworkSegments` WHERE `Id`='.$NetworkSegment['Id']);
    507507      $RowP2 = $DbResult2->fetch_array();
    508508
    509       $DbResult2 = $this->Database->query('SELECT SUM(price) as Price, SUM(consumption) as Consumption FROM network_devices WHERE segment='.$NetworkSegment['id'].' AND used=1');
     509      $DbResult2 = $this->Database->query('SELECT SUM(Price) as Price, SUM(Consumption) as Consumption FROM NetworkDevices WHERE Segment='.$NetworkSegment['id'].' AND Used=1');
    510510      $Row2 = $DbResult2->fetch_array();
    511511      $DbResult2 = $this->Database->query('SELECT COUNT(*) FROM Member WHERE NetworkSegment='.$NetworkSegment['id']);
    512512      $Row3 = $DbResult2->fetch_array();
    513       $ID = $NetworkSegment['parent'];
     513      $ID = $NetworkSegment['Parent'];
    514514      while($ID != 0)
    515515      {
    516516        //echo($ID.', ');
    517         $DbResult2 = $this->Database->query('SELECT * FROM network_segments WHERE id='.$ID);
     517        $DbResult2 = $this->Database->query('SELECT * FROM NetworkSegments WHERE Id='.$ID);
    518518        $Row4 = $DbResult2->fetch_array();
    519         $this->Database->update('network_segments', 'id='.$Row4['id'], array('users' => ($Row4['users'] + $Row3[0]), 'users_overheads' => ($Row4['users_overheads'] + $Row3[0])));
    520         $ID = $Row4['parent'];
     519        $this->Database->update('NetworkSegments', 'Id='.$Row4['Id'], array('Users' => ($Row4['Users'] + $Row3[0]), 'UsersOverheads' => ($Row4['UsersOverheads'] + $Row3[0])));
     520        $ID = $Row4['Parent'];
    521521      }
    522       $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'])));
     522      $this->Database->update('NetworkSegments', 'Id='.$NetworkSegment['Id'], array('Price' => $Row2['Price'], 'Users' => ($Row3[0] + $RowP['Users']), 'Consumption' => $Row2['Consumption'], 'UsersOverheads' => ($Row3[0] + $RowP2['UsersOverheads'])));
    523523    }
    524524
     
    526526    $DbResult = $this->Database->select('Member', 'COUNT(*)');
    527527    $Row = $DbResult->fetch_array();
    528     $DbResult = $this->Database->update('network_segments','id='.$this->InternetSegmentId, array('users' => $Row[0], 'users_overheads' => $Row[0]));
     528    $DbResult = $this->Database->update('NetworkSegments', 'Id='.$this->InternetSegmentId, array('Users' => $Row[0], 'UsersOverheads' => $Row[0]));
    529529    $this->System->Modules['Log']->NewRecord('Finance', 'RecalculateSegmentParameters');
    530530    return($Output);
Note: See TracChangeset for help on using the changeset viewer.