Changeset 481
- Timestamp:
- Feb 5, 2013, 10:47:05 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/finance/finance.php
r479 r481 32 32 { 33 33 $this->Tariffs = array(); 34 $DbResult = $this->Database->select('Service', '*', ' ReplaceId IS NULL ORDER BY InternetSpeedMax');34 $DbResult = $this->Database->select('Service', '*', '`ReplaceId` IS NULL ORDER BY `InternetSpeedMax`'); 35 35 while($Tariff = $DbResult->fetch_array()) 36 36 { … … 52 52 foreach($this->Tariffs as $Index => $Tariff) 53 53 { 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)');54 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Member` '. 55 'LEFT JOIN `ServiceCustomerRel` ON `ServiceCustomerRel`.`Customer`=`Member`.`Id` '. 56 'WHERE (`ServiceCustomerRel`.`Service`='.$Index.') AND (`Member`.`BillingPeriod` > 1) AND (`Member`.`Blocked`=0)'); 57 57 $Row = $DbResult->fetch_row(); 58 58 $this->Tariffs[$Index]['CustomerCount'] = $Row[0]; … … 100 100 function LoadMonthParameters($Period = 1) // 0 - now, 1 - next month 101 101 { 102 $DbResult = $this->Database->query('SELECT * FROM FinanceBillingPeriod');102 $DbResult = $this->Database->query('SELECT * FROM `FinanceBillingPeriod`'); 103 103 while($BillingPeriod = $DbResult->fetch_assoc()) 104 104 $this->BillingPeriods[$BillingPeriod['Id']] = $BillingPeriod; 105 105 106 $DbResult = $this->Database->query('SELECT * FROM FinanceCharge WHERE Period='.$Period);106 $DbResult = $this->Database->query('SELECT * FROM `FinanceCharge` WHERE `Period`='.$Period); 107 107 $Row = $DbResult->fetch_array(); 108 108 $this->kWh = $Row['kWh']; … … 116 116 $this->BaseTariffPrice = $Row['BaseTariffPrice']; 117 117 118 $DbResult = $this->Database->query('SELECT COUNT(*) FROM Member');118 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Member`'); 119 119 $Row = $DbResult->fetch_row(); 120 120 $this->InternetUsers = $Row[0]; 121 $DbResult = $this->Database->query('SELECT COUNT(*) FROM Member WHERE (Blocked=0) AND (BillingPeriod> 1)');121 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Member` WHERE (`Blocked`=0) AND (`BillingPeriod` > 1)'); 122 122 $Row = $DbResult->fetch_row(); 123 123 $this->PayingUsers = $Row[0]; … … 125 125 $this->SpravaUsers = $this->PayingUsers; 126 126 127 $DbResult = $this->Database->query('SELECT SUM( Consumption) FROM NetworkSegment');127 $DbResult = $this->Database->query('SELECT SUM(`Consumption`) FROM `NetworkSegment`'); 128 128 $TotalConsumption = $DbResult->fetch_array(); 129 129 $this->TotalConsumption = $TotalConsumption[0]; 130 130 131 $DbResult = $this->Database->query('SELECT SUM(`MemberPayment`.`MonthlyInternet`) AS `MonthlyInternet`, SUM(`MemberPayment`.`MonthlyTotal`) AS `MonthlyTotal` '. 132 'FROM MemberPayment JOIN Member ON Member.Id=MemberPayment.Member WHERE Member.Blocked=0'); 131 $DbResult = $this->Database->query('SELECT SUM(`MemberPayment`.`MonthlyInternet`) AS `MonthlyInternet`, '. 132 'SUM(`MemberPayment`.`MonthlyTotal`) AS `MonthlyTotal` '. 133 'FROM `MemberPayment` JOIN `Member` ON `Member`.`Id`=`MemberPayment`.`Member` WHERE `Member`.`Blocked`=0'); 133 134 $Row = $DbResult->fetch_assoc(); 134 135 $this->TotalInternetPaid = $Row['MonthlyInternet']; … … 148 149 { 149 150 // Get latest year 150 $DbResult = $this->Database->select('FinanceYear', '*', '1 ORDER BY YearDESC LIMIT 1');151 $DbResult = $this->Database->select('FinanceYear', '*', '1 ORDER BY `Year` DESC LIMIT 1'); 151 152 } else $DbResult = $this->Database->select('FinanceYear', '*', 'Id='.$FinanceYear); 152 153 $FinanceYear = $DbResult->fetch_assoc(); 153 154 154 $DbResult = $this->Database->query('SELECT Shortcut, Id FROM DocumentLine WHERE Id='.$Id);155 $DbResult = $this->Database->query('SELECT `Shortcut`, `Id` FROM `DocumentLine` WHERE `Id`='.$Id); 155 156 $DocumentLine = $DbResult->fetch_assoc(); 156 157 157 $DbResult = $this->Database->query('SELECT * FROM DocumentLineSequence WHERE DocumentLine='.$Id.' AND FinanceYear='.$FinanceYear['Id']); 158 $DbResult = $this->Database->query('SELECT * FROM `DocumentLineSequence` WHERE '. 159 '`DocumentLine`='.$Id.' AND `FinanceYear`='.$FinanceYear['Id']); 158 160 $Sequence = $DbResult->fetch_assoc(); 159 161 … … 163 165 } else $Result = $DocumentLine['Shortcut'].$Sequence['NextNumber']; 164 166 165 $this->Database->query('UPDATE DocumentLineSequence SET NextNumber = NextNumber + 1 WHERE DocumentLine='.$Id.' AND FinanceYear='.$FinanceYear['Id']); 167 $this->Database->query('UPDATE `DocumentLineSequence` SET `NextNumber` = `NextNumber` + 1 '. 168 'WHERE `DocumentLine`='.$Id.' AND `FinanceYear`='.$FinanceYear['Id']); 166 169 return($Result); 167 170 } … … 170 173 { 171 174 $Output = 'Aktualizuji finance členů...<br />'; 172 $this->Database->query('TRUNCATE TABLE MemberPayment');173 $DbResult = $this->Database->query('SELECT * FROM Member');175 $this->Database->query('TRUNCATE TABLE `MemberPayment`'); 176 $DbResult = $this->Database->query('SELECT * FROM `Member`'); 174 177 while($Member = $DbResult->fetch_assoc()) 175 178 { … … 199 202 } 200 203 204 $DbResult2 = $this->Database->query('SELECT SUM(`Service`.`Price`) AS `Price` '. 205 'FROM `ServiceCustomerRel` LEFT JOIN '. 206 '`Service` ON `Service`.`Id` = `ServiceCustomerRel`.`Service` WHERE `ServiceCustomerRel`.`Customer`='. 207 $Member['Id'].' AND `ServiceCustomerRel`.`Period`=1'); 208 $DbRow = $DbResult2->fetch_assoc(); 201 209 $Monthly = 0; 202 $MonthlyInet = $ this->Tariffs[$Member['InternetTariffNextMonth']]['Price'];210 $MonthlyInet = $DbRow['Price']; 203 211 //if($Row['inet'] == 1) 204 212 $Monthly += $MonthlyInet;
Note:
See TracChangeset
for help on using the changeset viewer.