Changeset 50 for www/finance/include.php
- Timestamp:
- Feb 24, 2008, 2:07:52 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
www/finance/include.php
r34 r50 4 4 function RecalculateTariffs($Period = 1) 5 5 { 6 global $Tarify, $MaxSpeed, $Internet, $SpeedElement, $BaseSpeedElement, $Database ;6 global $Tarify, $MaxSpeed, $Internet, $SpeedElement, $BaseSpeedElement, $Database, $BaseTariffPrice, $TopTariffPrice; 7 7 8 8 $ResidualPrice = $Internet; … … 10 10 11 11 $Tarify = array(); 12 $DbResult = $Database->select('finance_tariffs', '*', 'period='.$Period.' ORDER BY speed_factor');12 $DbResult = $Database->select('finance_tariffs', '*', 'period='.$Period.' ORDER BY id,speed_factor'); 13 13 while($Tariff = $DbResult->fetch_array()) 14 14 { … … 23 23 foreach($Tarify as $Index => $Tarif) 24 24 { 25 $DbResult = $Database->select('users', 'COUNT(*)', 'inet_tarif_'.$Column.'='.$Index.' AND inet=1 AND role= 0');25 $DbResult = $Database->select('users', 'COUNT(*)', 'inet_tarif_'.$Column.'='.$Index.' AND inet=1 AND role=2'); 26 26 $Row = $DbResult->fetch_array(); 27 27 $Tarify[$Index]['user_count'] = $Row[0]; … … 48 48 } 49 49 } 50 $PricePerUnit =$ResidualPrice / $TotalTarifUnits;50 //$PricePerUnit = $TopTariffPrice / ; // $ResidualPrice / $TotalTarifUnits; 51 51 $SpeedPerUnit = $ResidualSpeed * 1024 / $TotalTarifSpeedUnits; 52 52 … … 57 57 { 58 58 case 1: 59 $Tarify[$Index]['price'] = round($Tarif['price_units'] * $PricePerUnit);59 $Tarify[$Index]['price'] = $BaseTariffPrice + round($TopTariffPrice * $Tarif['price_units'] / 10) * 10; 60 60 $Tarify[$Index]['min_speed'] = round($Tarif['speed_factor'] * $SpeedPerUnit); 61 61 $Tarify[$Index]['max_speed'] = round($Tarify[$Index]['speed_factor'] * $BaseSpeedElement * 1024); … … 66 66 break; 67 67 case 3: 68 $Tarify[$Index]['price'] = $BaseTariffPrice + round($TopTariffPrice * $Tarif['price_units']); 68 69 $Tarify[$Index]['min_speed'] = $Tarify[$Index]['min_speed'] * 1024; 69 70 $Tarify[$Index]['max_speed'] = $Tarify[$Index]['max_speed'] * 1024; … … 77 78 { 78 79 global $kWh, $Internet, $Sprava, $DatumOdecteni, $InternetUsers, $SpravaUsers, $InternetSegmentId, 79 $MaxSpeed, $RealMaxSpeed, $SpeedReserve, $BaseSpeedElement, $Database; 80 $MaxSpeed, $RealMaxSpeed, $SpeedReserve, $BaseSpeedElement, $Database, $TotalConsumption, $UserIdNetwork, 81 $BaseTariffPrice, $TopTariffPrice, $TotalPaid, $TotalInternetPaid; 80 82 81 83 $DbResult = $Database->query("SELECT * FROM finance_charge WHERE period=".$Period); … … 88 90 $BaseSpeedElement = $Row['base_speed_element']; 89 91 $MaxSpeed = $RealMaxSpeed - $SpeedReserve; 92 $TopTariffPrice = $Row['TopTariffPrice']; 93 $BaseTariffPrice = $Row['BaseTariffPrice']; 90 94 91 $DbResult = $Database->query("SELECT COUNT(*) FROM users WHERE inet=1 AND role= 0");95 $DbResult = $Database->query("SELECT COUNT(*) FROM users WHERE inet=1 AND role=2"); 92 96 $Row = $DbResult->fetch_array(); 93 97 $InternetUsers = $Row[0]; 94 98 95 $DbResult = $Database->query("SELECT COUNT(*) FROM users WHERE overheads=1 AND role= 0");99 $DbResult = $Database->query("SELECT COUNT(*) FROM users WHERE overheads=1 AND role=2"); 96 100 $SpravaUsers = $DbResult->fetch_array(); 97 101 $SpravaUsers = $SpravaUsers[0]; 98 102 $InternetSegmentId = 21; 103 $DbResult = $Database->query("SELECT SUM(consumption) FROM network_segments"); 104 $TotalConsumption = $DbResult->fetch_array(); 105 $TotalConsumption = $TotalConsumption[0]; 106 $UserIdNetwork = 46; 99 107 108 $DbResult = $Database->query("SELECT SUM(`monthly`) as `internet`, SUM(`monthly` - `plus`) as `real` FROM users WHERE role=2"); 109 $Row = $DbResult->fetch_array(); 110 $TotalInternetPaid = $Row['internet']; 111 $TotalPaid = $Row['real']; 100 112 101 113 RecalculateTariffs($Period);
Note:
See TracChangeset
for help on using the changeset viewer.