Changeset 6 for www/finance


Ignore:
Timestamp:
Jan 16, 2008, 8:40:08 PM (17 years ago)
Author:
george
Message:

Upraveno: Aktualizace výpočtů tarifů ve financích.

Location:
www/finance
Files:
16 added
6 edited

Legend:

Unmodified
Added
Removed
  • www/finance/clenove.php

    r4 r6  
    5050    '<tr><td><strong>Celkem</strong></td><td><strong>'.($InternetPrice + $PoplatekSprava + $PoplatekSpotreba - $PrijemSpotreba).'</strong></td></tr></table>');
    5151    //echo('Tarif pro příští měsíc: '.$Tarify[$Row2['inet_tarif_next']]['name'].'<br><br>');
     52    echo('<br>');
    5253   
    5354    // Rozpis ceny za zařízení
  • www/finance/faktury/index.php

    r4 r6  
    11<?php
    2 include('../../global.php');
    32include('../../style.php');
    43ShowHeader('Faktury za internet','Faktury');
    54
    65echo('<table width="100%"><tr><td width="20%" valign="top">');
     6echo('<a href="?date=internext_smlouva_10Mbit">Internext - smlouva 10 Mbit/s</a><br>');
     7echo('<a href="?date=faktura_internext_2007-12">Internext Prosinec 2007</a><br>');
     8echo('<a href="?date=faktura_internext_2007-11">Internext Listopad 2007</a><br>');
     9echo('<a href="?date=faktura_internext_2007-10">Internext Říjen 2007</a><br>');
     10echo('<a href="?date=faktura_internext_2007-09">Internext Září 2007</a><br>');
     11echo('<a href="?date=faktura_internext_2007-08">Internext Srpen 2007</a><br>');
     12echo('<a href="?date=faktura_internext_2007-07">Internext Červenec 2007</a><br>');
     13echo('<a href="?date=faktura_internext_2007-06">Internext Červen 2007</a><br>');
    714echo('<a href="?date=faktura_internext_2007-05">Internext Květen 2007</a><br>');
    815echo('<a href="?date=faktura_internext_2007-04">Internext Duben 2007</a><br>');
  • www/finance/include.php

    r4 r6  
    44function RecalculateTariffs($Period = 1)
    55{
    6   global $Tarify, $MaxSpeed, $Internet, $SpeedElement, $Database;
     6  global $Tarify, $MaxSpeed, $Internet, $SpeedElement, $BaseSpeedElement, $Database;
    77   
     8  $ResidualPrice = $Internet;
     9  $ResidualSpeed = $MaxSpeed;
     10 
    811  $Tarify = array();
    912  $DbResult = $Database->select('finance_tariffs', '*', 'period='.$Period.' ORDER BY speed_factor');
     
    2326    $Row = $DbResult->fetch_array();
    2427    $Tarify[$Index]['user_count'] = $Row[0];   
    25     $TotalUserCount = $TotalUserCount + $Tarify[$Index]['user_count'];
    26     $Tarify[$Index]['total_units'] = $Tarify[$Index]['price_units'] * $Tarify[$Index]['user_count'];
    27     $TotalTarifUnits = $TotalTarifUnits + $Tarify[$Index]['total_units'];
     28    switch($Tarif['group_id'])
     29    {
     30      case 1:
     31        $TotalUserCount = $TotalUserCount + $Tarify[$Index]['user_count'];
     32        $Tarify[$Index]['total_units'] = $Tarify[$Index]['price_units'] * $Tarify[$Index]['user_count'];
     33        $TotalTarifUnits = $TotalTarifUnits + $Tarify[$Index]['total_units'];
    2834   
    29     if($Index == 3) // Zarizeni site v tarifu 3 neplati penize, ale ma internet
    30       $Tarify[$Index]['total_speed_factor'] = $Tarify[$Index]['speed_factor'] * ($Tarify[$Index]['user_count']+1);
    31       else $Tarify[$Index]['total_speed_factor'] = $Tarify[$Index]['speed_factor'] * $Tarify[$Index]['user_count'];
    32     $TotalTarifSpeedUnits = $TotalTarifSpeedUnits + $Tarify[$Index]['total_speed_factor'];
     35        if($Index == 3) // Zarizeni site v tarifu 3 neplati penize, ale ma internet
     36          $Tarify[$Index]['total_speed_factor'] = $Tarify[$Index]['speed_factor'] * ($Tarify[$Index]['user_count']+1);
     37          else $Tarify[$Index]['total_speed_factor'] = $Tarify[$Index]['speed_factor'] * $Tarify[$Index]['user_count'];
     38        $TotalTarifSpeedUnits = $TotalTarifSpeedUnits + $Tarify[$Index]['total_speed_factor'];
     39        break;
     40      case 2:
     41        $ResidualPrice -= $Tarif['price'] * $Tarify[$Index]['user_count'];
     42        $ResidualSpeed -= $Tarif['min_speed'] * $Tarify[$Index]['user_count'];
     43        $Tarify[$Index]['total_units'] = $Tarify[$Index]['price_units'] * $Tarify[$Index]['user_count'];
     44        break;
     45      case 3:
     46        $Tarify[$Index]['total_units'] = $Tarify[$Index]['price_units'] * $Tarify[$Index]['user_count'];
     47        break;
     48    }
    3349  }
    34   $PricePerUnit = $Internet / $TotalTarifUnits;
    35   $SpeedPerUnit = $MaxSpeed * 1024 / $TotalTarifSpeedUnits;
     50  $PricePerUnit = $ResidualPrice / $TotalTarifUnits;
     51  $SpeedPerUnit = $ResidualSpeed * 1024 / $TotalTarifSpeedUnits;
     52 
    3653  // Recalculate price
    37   $SpeedElement = 256*1024;
    3854  foreach($Tarify as $Index => $Tarif)
    3955  {
    40     $Tarify[$Index]['price'] = round($Tarif['price_units'] * $PricePerUnit);
    41     $Tarify[$Index]['min_speed'] = round($Tarif['speed_factor'] * $SpeedPerUnit);
    42     $Tarify[$Index]['max_speed'] = round($Tarify[$Index]['speed_factor'] * $SpeedElement);
     56    switch($Tarif['group_id'])
     57    {
     58      case 1:
     59        $Tarify[$Index]['price'] = round($Tarif['price_units'] * $PricePerUnit);
     60        $Tarify[$Index]['min_speed'] = round($Tarif['speed_factor'] * $SpeedPerUnit);
     61        $Tarify[$Index]['max_speed'] = round($Tarify[$Index]['speed_factor'] * $BaseSpeedElement * 1024);
     62        break;
     63      case 2:
     64        $Tarify[$Index]['min_speed'] = $Tarify[$Index]['min_speed'] * 1024;
     65        $Tarify[$Index]['max_speed'] = $Tarify[$Index]['max_speed'] * 1024;
     66        break;
     67      case 3:
     68        $Tarify[$Index]['min_speed'] = $Tarify[$Index]['min_speed'] * 1024;
     69        $Tarify[$Index]['max_speed'] = $Tarify[$Index]['max_speed'] * 1024;
     70        break;
     71    }
    4372    $Tarify[$Index]['aggregation'] = '1:'.round($Tarify[$Index]['max_speed'] / $Tarify[$Index]['min_speed']);
    44     //echo($Tarify[$Index]['price'].'<br>');
    4573  }               
    4674}
     
    4977{
    5078  global $kWh, $Internet, $Sprava, $DatumOdecteni, $InternetUsers, $SpravaUsers, $InternetSegmentId,
    51     $MaxSpeed, $RealMaxSpeed, $SpeedReserve, $Database;
     79    $MaxSpeed, $RealMaxSpeed, $SpeedReserve, $BaseSpeedElement, $Database;
    5280   
    5381  $DbResult = $Database->query("SELECT * FROM finance_charge WHERE period=".$Period);
     
    5886  $RealMaxSpeed = $Row['internet_speed'];
    5987  $SpeedReserve = $Row['internet_speed_reserve'];
     88  $BaseSpeedElement = $Row['base_speed_element'];
    6089  $MaxSpeed = $RealMaxSpeed - $SpeedReserve;
    6190
  • www/finance/index.php

    r4 r6  
    5858$DbResult = $Database->query("SELECT SUM(family) FROM users WHERE role=0");
    5959$Row5 = $DbResult->fetch_array();
    60 $TotalFamily = 650;
     60$TotalFamily = 600;
    6161echo('V připojených domácnostech celkem <strong>'.$Row5[0].'</strong> občanů ze všech <strong>'.$TotalFamily.'</strong> ('.round($Row5[0]/$TotalFamily*100).' %)<br>');
    6262echo('Provizorní bankovní účet kam lze posílát peníze: <strong>86-7755240207/0100</strong><br>');
  • www/finance/prepocet.php

    r4 r6  
    152152  //print_r($Charge);
    153153  $DbResult = $Database->insert('finance_charge', array('period' => 0, 'internet' => $Charge['internet'],
    154     'internet_speed' => $Charge['internet_speed'], 'internet_speed_reserve' => $Charge['internet_speed_reserve'],
    155     'administration_per_user' => $Charge['administration_per_user'], 'kWh' => $Charge['kWh']));
     154    'internet_speed' => $Charge['internet_speed'], 'internet_speed_reserve' => $Charge['internet_speed_reserve'], 'administration_per_user' => $Charge['administration_per_user'], 'kWh' => $Charge['kWh'], 'base_speed_element' => $Charge['base_speed_element']));
    156155 
    157156 
     
    164163  {
    165164    $Database->insert('finance_tariffs', array('period' => 0, 'name' => $Tariff['name'], 'id' => $Tariff['id'],
    166       'speed_factor' => $Tariff['speed_factor'], 'price_units' => $Tariff['price_units']));
     165      'speed_factor' => $Tariff['speed_factor'], 'price_units' => $Tariff['price_units'], 'group_id' => $Tariff['group_id'], 'min_speed' => $Tariff['min_speed'], 'max_speed' => $Tariff['max_speed'], 'price' => $Tariff['price']));
    167166  }
    168167 
  • www/finance/tarify.php

    r4 r6  
    11<?php
    2 include('../global.php');
    32include('../style.php');
    43include('include.php');
Note: See TracChangeset for help on using the changeset viewer.