Changeset 479 for trunk/finance/finance.php
- Timestamp:
- Feb 5, 2013, 9:45:44 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/finance/finance.php
r458 r479 2 2 3 3 define('TARIFF_FREE', 7); 4 define('INVOICE_DUE_DAYS', 15); 5 define('INVOICE_OUT_DOC_LINE', 6); 4 6 5 7 class Finance extends Module … … 30 32 { 31 33 $this->Tariffs = array(); 32 $DbResult = $this->Database->select(' FinanceTariff', '*', 'ReplaceId IS NULL ORDER BYSpeedMax');34 $DbResult = $this->Database->select('Service', '*', 'ReplaceId IS NULL ORDER BY InternetSpeedMax'); 33 35 while($Tariff = $DbResult->fetch_array()) 34 36 { 35 $Tariff[' SpeedMin'] = $Tariff['SpeedMin'] * 1024;36 $Tariff[' SpeedMax'] = $Tariff['SpeedMax'] * 1024;37 $Tariff['InternetSpeedMin'] = $Tariff['InternetSpeedMin'] * 1024; 38 $Tariff['InternetSpeedMax'] = $Tariff['InternetSpeedMax'] * 1024; 37 39 $this->Tariffs[$Tariff['Id']] = $Tariff; 38 40 } … … 50 52 foreach($this->Tariffs as $Index => $Tariff) 51 53 { 52 $DbResult = $this->Database->select('Member', 'COUNT(*)', '(InternetTariffCurrentMonth='.$Index.') AND (BillingPeriod > 1) AND (Blocked=0)'); 54 $DbResult = $this->Database->query('SELECT COUNT(*) FROM Member '. 55 'LEFT JOIN ServiceCustomerRel ON ServiceCustomerRel.Customer=Member.Id '. 56 '(ServiceCustomerRel.Service='.$Index.') AND (Member.BillingPeriod > 1) AND (Member.Blocked=0)'); 53 57 $Row = $DbResult->fetch_row(); 54 $this->Tariffs[$Index][' MemberCount'] = $Row[0];55 $Tariffs[' MemberCount'] = $Row[0];58 $this->Tariffs[$Index]['CustomerCount'] = $Row[0]; 59 $Tariffs['CustomerCount'] = $Row[0]; 56 60 57 61 //echo($Tariff['Name'].' '.$Tariff['MemberCount'].' '.$Tariff['SpeedMax'] * $Tariff['MemberCount'].' '.$ResidualSpeed.'<br />'); 58 switch($Tariff[' Group'])62 switch($Tariff['Category']) 59 63 { 60 64 case 1: 61 $TotalMemberCount += $Tariff[' MemberCount'];62 $TotalMaxSpeed += $Tariff[' SpeedMax'] * $Tariff['MemberCount'];65 $TotalMemberCount += $Tariff['CustomerCount']; 66 $TotalMaxSpeed += $Tariff['InternetSpeedMax'] * $Tariff['CustomerCount']; 63 67 break; 64 68 case 2: 65 $ResidualSpeed -= $Tariff[' SpeedMin'] * $Tariff['MemberCount'];69 $ResidualSpeed -= $Tariff['InternetSpeedMin'] * $Tariff['CustomerCount']; 66 70 break; 67 71 case 3: … … 75 79 foreach($this->Tariffs as $Index => $Tariff) 76 80 { 77 switch($Tariff[' Group'])81 switch($Tariff['Category']) 78 82 { 79 83 case 1: 80 84 // Přepočítávání rychlostí koliduje s rozdílovým zapisováním stromu front do mikrotiku. Vždy při změně počtu počítačů či domácností docházelo ke změně minima a přepočtu všeho. 81 //$Tariff[' SpeedMin'] = round($Tariff['SpeedMax'] * $Aggregation);85 //$Tariff['InternetSpeedMin'] = round($Tariff['InternetSpeedMax'] * $Aggregation); 82 86 break; 83 87 case 2: … … 86 90 break; 87 91 } 88 //echo('MinSpeed: '.$Tariff['SpeedMin'].'<br />'); 89 $this->Database->update('FinanceTariff', 'Id='.$Tariff['Id'], array('SpeedMin' => ($Tariff['SpeedMin'] / 1024), 'MemberCount' => $Tariff['MemberCount'])); 92 //echo('MinSpeed: '.$Tariff['InternetSpeedMin'].'<br />'); 93 $this->Database->update('Service', 'Id='.$Tariff['Id'], 94 array('InternetSpeedMin' => ($Tariff['InternetSpeedMin'] / 1024), 95 'CustomerCount' => $Tariff['CustomerCount'])); 90 96 } 91 97 $this->LoadTariffs();
Note:
See TracChangeset
for help on using the changeset viewer.