Changeset 275 for trunk/finance
- Timestamp:
- Jan 24, 2010, 8:05:10 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/finance/finance.php
r261 r275 23 23 var $ExternalSubject = 96; 24 24 var $MainSubject = 71; 25 25 var $BillingPeriods; 26 26 27 27 function LoadTariffs($Period = 1) … … 92 92 function LoadMonthParameters($Period = 1) // 0 - now, 1 - next month 93 93 { 94 95 96 97 94 $DbResult = $this->Database->query('SELECT * FROM FinanceBillingPeriod'); 95 while($BillingPeriod = $DbResult->fetch_assoc()) 96 $this->BillingPeriods[$BillingPeriod['Id']] = $BillingPeriod; 97 98 98 $DbResult = $this->Database->query('SELECT * FROM finance_charge WHERE period='.$Period); 99 99 $Row = $DbResult->fetch_array(); … … 130 130 } 131 131 132 function GetNextDocumentLineNumber($Id )132 function GetNextDocumentLineNumber($Id, $FinanceYear = 0) 133 133 { 134 $DbResult = $this->Database->query('SELECT Shortcut, NextNumber FROM DocumentLine WHERE Id='.$Id); 135 $DbRow = $DbResult->fetch_assoc(); 136 $Result = $DbRow['Shortcut'].$DbRow['NextNumber']; 137 $this->Database->query('UPDATE DocumentLine SET NextNumber = NextNumber + 1 WHERE Id='.$Id); 134 if($FinanceYear == 0) 135 { 136 // Get latest year 137 $DbResult = $this->Database->select('FinanceYear', '*', '1 ORDER BY Year DESC LIMIT 1'); 138 } else $DbResult = $this->Database->select('FinanceYear', '*', 'Id='.$FinanceYear); 139 $FinanceYear = $DbResult->fetch_assoc(); 140 141 $DbResult = $this->Database->query('SELECT Shortcut, Id FROM DocumentLine WHERE Id='.$Id); 142 $DocumentLine = $DbResult->fetch_assoc(); 143 144 $DbResult = $this->Database->query('SELECT Shortcut FROM DocumentLineSequence WHERE DocumentLine='.Id.' AND FinanceYear'.$FinanceYear['Id']); 145 $Sequence = $DbResult->fetch_assoc(); 146 147 if($Sequence['YearPrefix'] == 1) 148 { 149 $Result = $DbRow['Shortcut'].$Sequence['NextNumber'].'/'.$FinanceYear['Year']; 150 } else $Result = $DocumentLine['Shortcut'].$Sequence['NextNumber']; 151 152 $this->Database->query('UPDATE DocumentLineSequence SET NextNumber = NextNumber + 1 WHERE DocumentLine='.$Id.' AND FinanceYear='.$FinanceYear['Id']); 138 153 return($Result); 139 154 } … … 149 164 $Cash = $DbResult2->fetch_row(); 150 165 $Cash = $Cash[0]; 151 166 152 167 $DbResult2 = $this->Database->query('SELECT SUM(consumption) FROM network_devices WHERE (user='.$Member['Id'].') AND (used = 1)'); 153 168 $ConsumptionPlus = $DbResult2->fetch_row(); … … 166 181 $ID = $Device['parent']; 167 182 } 168 183 169 184 $Monthly = 0; 170 185 $MonthlyInet = $this->Tariffs[$Member['InternetTariffNextMonth']]['Price']; … … 177 192 $Monthly = round($Monthly); 178 193 //echo($Row['fullname'].' '.$Row['inet'].' '.$Monthly.'<br>'); 179 194 180 195 $this->Database->insert('MemberPayment', array('Member' => $Member['Id'], 'NetworkDevice' => $NetworkDevice, 'MonthlyInternet' => $MonthlyInet, 'MonthlyTotal' => $Monthly, 'MonthlyConsumption' => $this->W2Kc($Consumption), 'Cash' => $Cash, 'MonthlyPlus' => $this->W2Kc($ConsumptionPlus))); 181 196 } 182 $this->System->Modules['Log']->NewRecord('Finance', 'RecalculateMemberPayment'); 197 $this->System->Modules['Log']->NewRecord('Finance', 'RecalculateMemberPayment'); 183 198 $this->RecalculateTariffs(1); 184 199 $this->RecalculateTariffs(0); … … 189 204 { 190 205 $Output = 'Aktualizuji parametry segmentů...<br />'; 191 $this->Database->query('UPDATE network_segments SET users = 0, users_overheads = 0'); 206 $this->Database->query('UPDATE network_segments SET users = 0, users_overheads = 0'); // Vynulovat počty uživatelů 192 207 $DbResult = $this->Database->query('SELECT * FROM network_segments'); 193 208 while($NetworkSegment = $DbResult->fetch_array()) … … 219 234 $Row = $DbResult->fetch_array(); 220 235 $DbResult = $this->Database->update('network_segments','id='.$this->InternetSegmentId, array('users' => $Row[0], 'users_overheads' => $Row[0])); 221 236 $this->System->Modules['Log']->NewRecord('Finance', 'RecalculateSegmentParameters'); 222 237 return($Output); 223 238 }
Note:
See TracChangeset
for help on using the changeset viewer.