Changeset 50 for www/finance/include.php


Ignore:
Timestamp:
Feb 24, 2008, 2:07:52 PM (17 years ago)
Author:
george
Message:

Změněno: Odebrán proměnný podíl na zařízení sítě.
Změněno: Ceny tarifů změněny na pevné.
Změněno: Měsíční přehled nákladů a výnosů sítě.
Odebráno: Účtování spotřeby.
Upraveno: Systém zobrazení navigačního řádku.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • www/finance/include.php

    r34 r50  
    44function RecalculateTariffs($Period = 1)
    55{
    6   global $Tarify, $MaxSpeed, $Internet, $SpeedElement, $BaseSpeedElement, $Database;
     6  global $Tarify, $MaxSpeed, $Internet, $SpeedElement, $BaseSpeedElement, $Database, $BaseTariffPrice, $TopTariffPrice;
    77   
    88  $ResidualPrice = $Internet;
     
    1010 
    1111  $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');
    1313  while($Tariff = $DbResult->fetch_array())
    1414  {
     
    2323  foreach($Tarify as $Index => $Tarif)
    2424  {
    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');
    2626    $Row = $DbResult->fetch_array();
    2727    $Tarify[$Index]['user_count'] = $Row[0];   
     
    4848    }
    4949  }
    50   $PricePerUnit = $ResidualPrice / $TotalTarifUnits;
     50  //$PricePerUnit = $TopTariffPrice / ;  // $ResidualPrice / $TotalTarifUnits;
    5151  $SpeedPerUnit = $ResidualSpeed * 1024 / $TotalTarifSpeedUnits;
    5252 
     
    5757    {
    5858      case 1:
    59         $Tarify[$Index]['price'] = round($Tarif['price_units'] * $PricePerUnit);
     59        $Tarify[$Index]['price'] = $BaseTariffPrice + round($TopTariffPrice * $Tarif['price_units'] / 10) * 10;
    6060        $Tarify[$Index]['min_speed'] = round($Tarif['speed_factor'] * $SpeedPerUnit);
    6161        $Tarify[$Index]['max_speed'] = round($Tarify[$Index]['speed_factor'] * $BaseSpeedElement * 1024);
     
    6666        break;
    6767      case 3:
     68        $Tarify[$Index]['price'] = $BaseTariffPrice + round($TopTariffPrice * $Tarif['price_units']);
    6869        $Tarify[$Index]['min_speed'] = $Tarify[$Index]['min_speed'] * 1024;
    6970        $Tarify[$Index]['max_speed'] = $Tarify[$Index]['max_speed'] * 1024;
     
    7778{
    7879  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;
    8082   
    8183  $DbResult = $Database->query("SELECT * FROM finance_charge WHERE period=".$Period);
     
    8890  $BaseSpeedElement = $Row['base_speed_element'];
    8991  $MaxSpeed = $RealMaxSpeed - $SpeedReserve;
     92  $TopTariffPrice = $Row['TopTariffPrice'];
     93  $BaseTariffPrice = $Row['BaseTariffPrice'];
    9094
    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");
    9296  $Row = $DbResult->fetch_array();
    9397  $InternetUsers = $Row[0];
    9498
    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");
    96100  $SpravaUsers = $DbResult->fetch_array();
    97101  $SpravaUsers = $SpravaUsers[0];
    98102  $InternetSegmentId = 21;
     103  $DbResult = $Database->query("SELECT SUM(consumption) FROM network_segments");
     104  $TotalConsumption = $DbResult->fetch_array();
     105  $TotalConsumption = $TotalConsumption[0];
     106  $UserIdNetwork = 46;
    99107
     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'];
    100112 
    101113  RecalculateTariffs($Period);
Note: See TracChangeset for help on using the changeset viewer.