Changeset 408 for trunk/finance/finance.php
- Timestamp:
- Oct 4, 2012, 8:29:32 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/finance/finance.php
r407 r408 113 113 114 114 $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'); 116 116 $TotalConsumption = $DbResult->fetch_array(); 117 117 $this->TotalConsumption = $TotalConsumption[0]; … … 172 172 $Consumption = 0; 173 173 $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); 177 177 $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']; 180 180 //echo($ID.' '.$InternetSegment.' '.$InternetSegmentId.' '.$Row['inet_hw'].' '.$Price.'<br>'); 181 $ID = $Device[' parent'];181 $ID = $Device['Parent']; 182 182 } 183 183 … … 212 212 { 213 213 $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`'); 216 216 while($NetworkSegment = $DbResult->fetch_array()) 217 217 { 218 218 //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']); 220 220 $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']); 222 222 $RowP2 = $DbResult2->fetch_array(); 223 223 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'); 225 225 $Row2 = $DbResult2->fetch_array(); 226 226 $DbResult2 = $this->Database->query('SELECT COUNT(*) FROM Member WHERE NetworkSegment='.$NetworkSegment['id']); … … 230 230 { 231 231 //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); 233 233 $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]))); 235 235 $ID = $Row4['parent']; 236 236 } 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']))); 238 238 } 239 239 … … 241 241 $DbResult = $this->Database->select('Member', 'COUNT(*)'); 242 242 $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])); 244 244 $this->System->Modules['Log']->NewRecord('Finance', 'RecalculateSegmentParameters'); 245 245 return($Output);
Note:
See TracChangeset
for help on using the changeset viewer.