Changeset 204
- Timestamp:
- May 1, 2009, 12:13:50 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/finance/clenove.php
r189 r204 28 28 $TotalCash += $Row['Cash']; 29 29 if($Row['Cash'] < 0) $Row['Cash'] = '<span style="color: red;">'.$Row['Cash'].'</span>'; 30 $Tarif = $Finance->Tarif y[$Row['InternetTariffCurrentMonth']]['name'];31 $PristiTarif = $Finance->Tarif y[$Row['InternetTariffNextMonth']]['name'];30 $Tarif = $Finance->Tariffs[$Row['InternetTariffCurrentMonth']]['Name']; 31 $PristiTarif = $Finance->Tariffs[$Row['InternetTariffNextMonth']]['Name']; 32 32 $Output .= '<tr><td>'.$Row['FullName'].'</td><td><a href="user_state.php?Subject='.$Row['Id'].'">'.$Row['Name'].'</a></td>'; 33 33 //<td align="right">'.$Row['network_device'].'</td> -
trunk/finance/finance.php
r195 r204 20 20 var $TotalPaid; 21 21 var $TotalInternetPaid; 22 var $Tarif y;22 var $Tariffs; 23 23 var $ExternalSubject = 96; 24 24 var $MainSubject = 71; 25 25 var $BillingPeriods; 26 26 27 function LoadTariffs($Period = 1) 28 { 29 $this->Tariffs = array(); 30 $DbResult = $this->Database->select('FinanceTariff', '*', 'Period='.$Period.' ORDER BY Tariff, SpeedMax'); 31 while($Tariff = $DbResult->fetch_array()) 32 { 33 $Tariff['SpeedMin'] = $Tariff['SpeedMin'] * 1024; 34 $Tariff['SpeedMax'] = $Tariff['SpeedMax'] * 1024; 35 $this->Tariffs[$Tariff['Tariff']] = $Tariff; 36 } 37 } 38 27 39 function RecalculateTariffs($Period = 1) 28 40 { 29 $ResidualPrice = $this->Internet; 30 $ResidualSpeed = $this->MaxSpeed; 31 32 $Tarify = array(); 33 $DbResult = $this->Database->select('finance_tariffs', '*', 'period='.$Period.' ORDER BY id,speed_factor'); 34 while($Tariff = $DbResult->fetch_array()) 35 { 36 $Tarify[$Tariff['id']] = $Tariff; 37 } 38 39 if($Period == 0) $Column = 'Current'; else $Column = 'Next'; 40 $TotalUserCount = 0; 41 $TotalUnits = 0; 42 $TotalTarifUnits = 0; 43 $TotalTarifSpeedUnits = 0; 44 foreach($Tarify as $Index => $Tarif) 45 { 46 $DbResult = $this->Database->select('Member', 'COUNT(*)', 'InternetTariff'.$Column.'Month='.$Index); 41 $ResidualSpeed = $this->MaxSpeed * 1024; 42 43 $this->LoadTariffs($Period); 44 45 $Column = array('Current', 'Next'); 46 $TotalMemberCount = 0; 47 $TotalMaxSpeed = 0; 48 foreach($this->Tariffs as $Index => $Tariff) 49 { 50 $DbResult = $this->Database->select('Member', 'COUNT(*)', 'InternetTariff'.$Column[$Period].'Month='.$Index); 47 51 $Row = $DbResult->fetch_row(); 48 $Tarify[$Index]['user_count'] = $Row[0]; 49 switch($Tarif['group_id']) 52 $this->Tariffs[$Index]['MemberCount'] = $Row[0]; 53 $Tariffs['MemberCount'] = $Row[0]; 54 55 //echo($Tariff['Name'].' '.$Tariff['MemberCount'].' '.$Tariff['SpeedMax'] * $Tariff['MemberCount'].' '.$ResidualSpeed.'<br />'); 56 switch($Tariff['Group']) 50 57 { 51 58 case 1: 52 $TotalUserCount = $TotalUserCount + $Tarify[$Index]['user_count']; 53 $Tarify[$Index]['total_units'] = $Tarify[$Index]['price_units'] * $Tarify[$Index]['user_count']; 54 $TotalTarifUnits = $TotalTarifUnits + $Tarify[$Index]['total_units']; 55 56 if($Index == 3) // Zarizeni site v tarifu 3 neplati penize, ale ma internet 57 $Tarify[$Index]['total_speed_factor'] = $Tarify[$Index]['speed_factor'] * ($Tarify[$Index]['user_count']+1); 58 else $Tarify[$Index]['total_speed_factor'] = $Tarify[$Index]['speed_factor'] * $Tarify[$Index]['user_count']; 59 $TotalTarifSpeedUnits = $TotalTarifSpeedUnits + $Tarify[$Index]['total_speed_factor']; 59 $TotalMemberCount += $Tariff['MemberCount']; 60 $TotalMaxSpeed += $Tariff['SpeedMax'] * $Tariff['MemberCount']; 60 61 break; 61 62 case 2: 62 $ResidualPrice -= $Tarif['price'] * $Tarify[$Index]['user_count']; 63 $ResidualSpeed -= $Tarif['min_speed'] * $Tarify[$Index]['user_count']; 64 $Tarify[$Index]['total_units'] = $Tarify[$Index]['price_units'] * $Tarify[$Index]['user_count']; 63 $ResidualSpeed -= $Tariff['SpeedMin'] * $Tariff['MemberCount']; 65 64 break; 66 65 case 3: 67 $Tarify[$Index]['total_units'] = $Tarify[$Index]['price_units'] * $Tarify[$Index]['user_count']; 68 break; 69 } 70 } 71 //$PricePerUnit = $TopTariffPrice / ; // $ResidualPrice / $TotalTarifUnits; 72 $SpeedPerUnit = $ResidualSpeed * 1024 / $TotalTarifSpeedUnits; 66 break; 67 } 68 } 69 $Aggregation = $ResidualSpeed / $TotalMaxSpeed; 70 //echo($TotalMaxSpeed.' '.$Aggregation.'<br />'); 73 71 74 72 // Recalculate price 75 foreach($ Tarify as $Index => $Tarif)76 { 77 switch($Tarif ['group_id'])73 foreach($this->Tariffs as $Index => $Tariff) 74 { 75 switch($Tariff['Group']) 78 76 { 79 77 case 1: 80 $Tarify[$Index]['price'] = $this->BaseTariffPrice + round($this->TopTariffPrice * $Tarif['price_units'] / 10) * 10; 81 $Tarify[$Index]['min_speed'] = round($Tarif['speed_factor'] * $SpeedPerUnit); 82 $Tarify[$Index]['max_speed'] = round($Tarify[$Index]['speed_factor'] * $this->BaseSpeedElement * 1024); 78 $Tariff['SpeedMin'] = round($Tariff['SpeedMax'] * $Aggregation); 83 79 break; 84 80 case 2: 85 $Tarify[$Index]['min_speed'] = $Tarify[$Index]['min_speed'] * 1024;86 $Tarify[$Index]['max_speed'] = $Tarify[$Index]['max_speed'] * 1024;87 81 break; 88 82 case 3: 89 $Tarify[$Index]['price'] = $this->BaseTariffPrice + round($this->TopTariffPrice * $Tarif['price_units']); 90 $Tarify[$Index]['min_speed'] = $Tarify[$Index]['min_speed'] * 1024; 91 $Tarify[$Index]['max_speed'] = $Tarify[$Index]['max_speed'] * 1024; 92 break; 93 } 94 $Tarify[$Index]['aggregation'] = '1:'.round($Tarify[$Index]['max_speed'] / $Tarify[$Index]['min_speed']); 95 } 96 $this->Tarify = $Tarify; 83 break; 84 } 85 //echo('MinSpeed: '.$Tariff['SpeedMin'].'<br />'); 86 $this->Database->update('FinanceTariff', 'Tariff='.$Tariff['Tariff'], array('SpeedMin' => ($Tariff['SpeedMin'] / 1024), 'MemberCount' => $Tariff['MemberCount'])); 87 } 88 $this->LoadTariffs($Period); 97 89 } 98 90 … … 130 122 131 123 $this->RecalculateTariffs($Period); 124 $this->LoadTariffs($Period); 132 125 } 133 126 … … 175 168 176 169 $Monthly = 0; 177 $MonthlyInet = $this->Tarif y[$Member['InternetTariffNextMonth']]['price'];170 $MonthlyInet = $this->Tariffs[$Member['InternetTariffNextMonth']]['Price']; 178 171 //if($Row['inet'] == 1) 179 172 $Monthly += $MonthlyInet; 180 173 $Monthly -= $this->W2Kc($ConsumptionPlus); 174 $Monthly -= $Member['Hire']; 181 175 //if($Row['overheads'] == 1) $Monthly += $Sprava; // + W2Kc($Consumption); 182 176 //echo($Row['fullname'].' '.$Row['inet'].' '.$Monthly.'<br>'); -
trunk/finance/index.php
r167 r204 24 24 $Output .= '<br /><strong>Souhrn:</strong><br />'; 25 25 26 $DbResult = $this->Database->query( "SELECT * FROM finance_monthly_overall ORDER BY date DESC LIMIT 0,1");26 $DbResult = $this->Database->query('SELECT * FROM finance_monthly_overall ORDER BY date DESC LIMIT 0,1'); 27 27 $Row = $DbResult->fetch_array(); 28 28 $Output .= 'Platba za internetovou linku ('.$Finance->RealMaxSpeed.'/'.$Finance->RealMaxSpeed.' kbit/s): <strong>'.$Finance->Internet.' Kč</strong><br />'; … … 57 57 $TotalGain = 0; 58 58 $TotalExpense = 0; 59 $DbResult = $this->Database->query( "SELECT SUM(consumption) FROM network_devices WHERE used=1");59 $DbResult = $this->Database->query('SELECT SUM(consumption) FROM network_devices WHERE used=1'); 60 60 $Row = $DbResult->fetch_array(); 61 61 $TotalConsumption = $this->System->Modules['Finance']->W2Kc($Row[0]); -
trunk/finance/manage.php
r186 r204 553 553 $Output .= 'Měním aktuální tarify....<br>'; 554 554 // Update tarrifs 555 $this->Database->delete(' finance_tariffs', 'period=0');556 $DbResult = $this->Database->select(' finance_tariffs', '*', 'period = 1');555 $this->Database->delete('FinanceTariffs', 'Period=0'); 556 $DbResult = $this->Database->select('FinanceTariff', '*', 'Period = 1'); 557 557 while($Tariff = $DbResult->fetch_array()) 558 558 { 559 $this->Database->insert(' finance_tariffs', array('period' => 0, 'name' => $Tariff['name'], 'id' => $Tariff['id'],'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']));559 $this->Database->insert('FinanceTariff', array('Period' => 0, 'Name' => $Tariff['Name'], 'Tariff' => $Tariff['Tariff'], 'UploadAsymmetry' => $Tariff['UploadAsymmetry'], 'MemberCount' => $Tariff['MemberCount'], 'Group' => $Tariff['Group'], 'SpeedMin' => $Tariff['SpeedMin'], 'SpeedMax' => $Tariff['SpeedMax'], 'Price' => $Tariff['Price'])); 560 560 } 561 561 … … 566 566 567 567 // Restart traffic shaping 568 $this->Database->update('services_restart', 'id = 3', array('changed' => 1));568 //$this->Database->update('NetworkConfiguration', 'Id = 3', array('Changed' => 1)); 569 569 } 570 570 return($Output); -
trunk/finance/tarify.php
r179 r204 18 18 19 19 $Output .= '<table width="50%" class="WideTable" style="font-size: small;">'; 20 $Output .= '<tr><th>Název tarifu</th><th>Min. rychlost [kbit/s]</th><th>Max. rychlost [kbit/s]</th><th>Agregační poměr</th><th> Cenových jednotek</th><th>Počet podílníků</th><th>Celkem cenových jednotek</th><th>Cena [Kč]</th><th>Vybráno celkem[Kč]</th></tr>';20 $Output .= '<tr><th>Název tarifu</th><th>Min. rychlost [kbit/s]</th><th>Max. rychlost [kbit/s]</th><th>Agregační poměr</th><th>Počet podílníků</th><th>Cena [Kč]</th><th>Součet ceny [Kč]</th></tr>'; 21 21 $TotalPrice = 0; 22 $TotalUnits = 0; 23 foreach($Finance->Tarify as $Index => $Tarif) 22 foreach($Finance->Tariffs as $Index => $Tariff) 24 23 { 25 $Output .= '<tr><td style="color: blue;">'.$Tarif['name'].'</td><td align="center">'.round($Tarif['min_speed'] / 1024).'</td><td align="center" style="color: blue;">'.round($Tarif['max_speed'] / 1024).'</td><td align="center">'.$Tarif['aggregation'].'</td><td align="center">'.$Tarif['price_units'].'</td><td align="center">'.$Tarif['user_count'].'</td><td align="center">'. 26 $Tarif['total_units'].'</td><td align="center" style="color: blue;">'.$Tarif['price'].'</td><td align="center">'.$Tarif['user_count'] * $Tarif['price'].'</td></tr>'; 27 $TotalPrice = $TotalPrice + $Tarif['price'] * $Tarif['user_count']; 28 $TotalUnits = $TotalUnits + $Tarif['total_units']; 24 $Tariff['Aggregation'] = '1:'.round($Tariff['SpeedMax'] / $Tariff['SpeedMin']); 25 $Output .= '<tr><td style="color: blue;">'.$Tariff['Name'].'</td><td align="center">'.round($Tariff['SpeedMin'] / 1024).'</td><td align="center" style="color: blue;">'.round($Tariff['SpeedMax'] / 1024).'</td><td align="center">'.$Tariff['Aggregation'].'</td><td align="center">'.$Tariff['MemberCount'].'</td><td align="center" style="color: blue;">'.$Tariff['Price'].'</td><td align="center">'.$Tariff['MemberCount'] * $Tariff['Price'].'</td></tr>'; 26 $TotalPrice = $TotalPrice + $Tariff['Price'] * $Tariff['MemberCount']; 29 27 } 30 $Output .= '<tr><td>Součty</td><td colspan=" 4"> </td><td align="center">'.$Finance->InternetUsers.'</td><td align="center">'.$TotalUnits.'</td><td> </td><td align="center">'.$TotalPrice.'</td></tr>';28 $Output .= '<tr><td>Součty</td><td colspan="3"> </td><td align="center">'.$Finance->InternetUsers.'</td><td> </td><td align="center">'.$TotalPrice.'</td></tr>'; 31 29 $Output .= '</table>'; 32 30 return($Output); -
trunk/finance/user_state.php
r179 r204 38 38 $DbResult = $this->Database->query('SELECT * FROM Member LEFT JOIN MemberPayment ON MemberPayment.Member=Member.Id WHERE Member.Subject='.$Subject['Id']); 39 39 $Member = $DbResult->fetch_assoc(); 40 $TarifName = $Finance->Tarif y[$Member['InternetTariffCurrentMonth']]['name'];41 $TarifPrice = $Finance->Tarif y[$Member['InternetTariffCurrentMonth']]['price'];40 $TarifName = $Finance->Tariffs[$Member['InternetTariffCurrentMonth']]['Name']; 41 $TarifPrice = $Finance->Tariffs[$Member['InternetTariffCurrentMonth']]['Price']; 42 42 $Output = '<table width="100%" border="0" cellspacing="0" cellpadding="3"><tr><td valign="top">'; 43 43 … … 68 68 $Output .= 'Variabilní symbol pro platby: <strong>'.$Subject['Id'].'</strong><br><br>'; 69 69 70 $Total = 0;70 $Total = 0; 71 71 $Output .= 'Rozpis měsíčního poplatku:<br><table class="WideTable">'. 72 72 '<tr><th>Část</th><th>Cena [Kč]</th></tr>'. 73 73 '<tr><td>Internet - tarif '.$TarifName.'</td><td>'.$TarifPrice.'</td></tr>'; 74 $Total += $TarifPrice; 75 if($Member['MonthlyPlus'] != 0) 76 $Output .= '<tr><td>Příjem za spotřebu</td><td>'.(-$Member['MonthlyPlus']) .'</td></tr>'; 77 $Total += -$Member['MonthlyPlus']; 74 $Total += $TarifPrice; 75 if($Member['Hire'] != 0) 76 { 77 $Output .= '<tr><td>Nájem</td><td>'.(-$Member['Hire']).'</td></tr>'; 78 $Total -= $Member['Hire']; 79 } 80 if($Member['MonthlyPlus'] != 0) 81 { 82 $Output .= '<tr><td>Příjem za spotřebu</td><td>'.(-$Member['MonthlyPlus']).'</td></tr>'; 83 $Total -= $Member['MonthlyPlus']; 84 } 78 85 $Output .= '<tr><td><strong>Celkem</strong></td><td><strong>'.$Total.'</strong></td></tr></table>'; 79 86 //echo('Tarif pro příští měsíc: '.$Tarify[$Row2['inet_tarif_next']]['name'].'<br><br>'); … … 82 89 if($Member['MonthlyPlus'] != 0) 83 90 { 84 91 $Output .= 'Měsíční příjem za spotřebu zařízení umístěných u uživatele:<br>'; 85 92 $Output .= '<table class="WideTable"><tr><th>Název zařízení</th><th>Spotřeba [W]</th><th>Příjem [Kč]</th></tr>'; 86 93 $DbResult = $this->Database->query('SELECT * FROM network_devices WHERE user='.$Member['Id'].' AND used=1'); -
trunk/form_classes.php
r202 r204 136 136 ), 137 137 ), 138 'News' => array( 139 'Title' => 'Nová aktualita', 140 'Table' => '', 141 'SubmitText' => 'Vložit', 142 'Items' => array( 143 'Category' => array('Type' => 'TNewsCategory', 'Caption' => 'Kategorie', 'Default' => 0), 144 'Title' => array('Type' => 'String', 'Caption' => 'Nadpis', 'Default' => ''), 145 'Content' => array('Type' => 'Text', 'Caption' => 'Obsah', 'Default' => ''), 146 'Enclosure1' => array('Type' => 'File', 'Caption' => 'Přílohy (Max. velikost souboru 1 MB)', 'Default' => ''), 147 'Enclosure2' => array('Type' => 'File', 'Caption' => '', 'Default' => ''), 148 'Enclosure3' => array('Type' => 'File', 'Caption' => '', 'Default' => ''), 149 ), 150 ), 138 151 ); 139 152 … … 176 189 'Filter' => '1', 177 190 ), 191 'TNewsCategory' => array( 192 'Type' => 'Reference', 193 'Table' => 'NewsCategory', 194 'Id' => 'Id', 195 'Name' => 'Caption', 196 'Filter' => '1', 197 ), 178 198 ); 179 199 -
trunk/network/user_hosts.php
r195 r204 12 12 13 13 $Output = '<br /><table class="WideTable"> 14 <tr><th>Jméno počítače</th><th>Typ</th>< /th><th>Místní IP adresa</th><th>Veřejná IP adresa</th><th>CZFree IP adresa</th><th>Naposledy online</th><th>Fyzická adresa</th></tr>';14 <tr><th>Jméno počítače</th><th>Typ</th><th>Místní IP adresa</th><th>Veřejná IP adresa</th><th>CZFree IP adresa</th><th>Naposledy online</th><th>Fyzická adresa</th></tr>'; 15 15 16 16 $DbResult = $this->Database->query('SELECT hosts.*, HostType.Name AS HostType FROM hosts LEFT JOIN HostType ON HostType.Id = hosts.type WHERE (hosts.used = 1) AND (hosts.user = '.$this->System->Modules['User']->User['Member'].') ORDER BY hosts.name'); … … 25 25 $Output .= '<tr><td style="text-align: left; '.$Style.'">'.$Host['name'].'</td><td>'.$Host['HostType'].'</td><td>'.$Host['IP'].'</td><td>'.$Host['external_ip'].'</td><td>'.$Host['czfree_ip'].'</td><td >'.HumanDate($Host['last_online']).'</td><td>'.$Host['MAC'].'</td></tr>'; 26 26 } 27 $Output .= '</table> <br />';27 $Output .= '</table>'; 28 28 return($Output); 29 29 } -
trunk/system/generators/traffic_shaping.php
r197 r204 128 128 $UserClassId = $ClassId; 129 129 $ClassId = $ClassId + 1; 130 $SpeedIn = round($Tarify[$User['inet_tarif_now']][' min_speed'] / $InDivider);131 $SpeedOut = round($Tarify[$User['inet_tarif_now']][' min_speed'] / $OutDivider);132 $UserMaxSpeedIn = round($Tarify[$User['inet_tarif_now']][' max_speed'] / $InDivider);133 $UserMaxSpeedOut = round($Tarify[$User['inet_tarif_now']][' max_speed'] / $OutDivider);130 $SpeedIn = round($Tarify[$User['inet_tarif_now']]['SpeedMin'] / $InDivider); 131 $SpeedOut = round($Tarify[$User['inet_tarif_now']]['SpeedMin'] / $OutDivider); 132 $UserMaxSpeedIn = round($Tarify[$User['inet_tarif_now']]['SpeedMax'] / $InDivider); 133 $UserMaxSpeedOut = round($Tarify[$User['inet_tarif_now']]['SpeedMax'] / $OutDivider); 134 134 $Quantum = $Tarify[$User['inet_tarif_now']]['speed_factor'] * 1500; 135 135 -
trunk/system/generators/traffic_shaping_routerboard.php
r197 r204 67 67 68 68 echo('Uživatel '.$Member['Name'].': '); 69 $Tariff = $Finance->Tarify[$Member['InternetTariffCurrentMonth']]; 70 $SpeedIn = round($Tariff['min_speed'] / $InDivider); 71 $SpeedOut = round($Tariff['min_speed'] / $OutDivider); 72 $UserMaxSpeedIn = round($Tariff['max_speed'] / $InDivider); 73 $UserMaxSpeedOut = round($Tariff['max_speed'] / $OutDivider); 74 $Quantum = $Tariff['speed_factor'] * 1500; 69 $Tariff = $Finance->Tariffs[$Member['InternetTariffCurrentMonth']]; 70 $SpeedIn = round($Tariff['SpeedMin'] / $InDivider); 71 $SpeedOut = round($Tariff['SpeedMin'] / $OutDivider); 72 $UserMaxSpeedIn = round($Tariff['SpeedMax'] / $InDivider); 73 $UserMaxSpeedOut = round($Tariff['SpeedMax'] / $OutDivider); 75 74 $Commands[] = ' /queue tree add name='.$Member['Name'].'-out limit-at='.$SpeedIn.' max-limit='.$UserMaxSpeedIn.' parent=main-out queue=wireless-default'; 76 75 $Commands[] = ' /queue tree add name='.$Member['Name'].'-in limit-at='.$SpeedOut.' max-limit='.$UserMaxSpeedOut.' parent=main-in queue=wireless-default';
Note:
See TracChangeset
for help on using the changeset viewer.