Changeset 377 for trunk/Modules/Finance
- Timestamp:
- Jan 20, 2012, 3:05:24 PM (13 years ago)
- Location:
- trunk/Modules/Finance
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Finance/Finance.php
r373 r377 83 83 } 84 84 85 class FinanceBillingPeriod extends Model 86 { 87 function __construct($Database, $System) 88 { 89 parent::__construct($Database, $System); 90 $this->Name = 'FinanceBillingPeriod'; 91 $this->AddPropertyString('Name'); 92 $this->AddPropertyInteger('MonthCount'); 93 } 94 } 95 85 96 class FinanceTariff extends Model 86 97 { … … 127 138 $this->AddPropertyString('BillCode'); 128 139 $this->AddPropertyOneToMany('Subject', 'Subject'); 129 $this->AddPropertyDateTime('TimeCreat e');140 $this->AddPropertyDateTime('TimeCreation'); 130 141 $this->AddPropertyDateTime('TimeDue'); 131 142 $this->AddPropertyDateTime('TimePayment'); … … 163 174 $this->AddPropertyFloat('Price'); 164 175 $this->AddPropertyFloat('Quantity'); 176 } 177 } 178 179 class FinanceCharge extends Model 180 { 181 function __construct($Database, $System) 182 { 183 parent::__construct($Database, $System); 184 $this->Name = 'FinanceCharge'; 185 $this->AddPropertyInteger('Period'); 186 $this->AddPropertyInteger('Internet'); 187 $this->AddPropertyInteger('InternetSpeed'); 188 $this->AddPropertyInteger('InternetSpeedReserve'); 189 $this->AddPropertyInteger('AdministrationPerUser'); 190 $this->AddPropertyInteger('kWh'); 191 $this->AddPropertyInteger('BaseSpeedElement'); 192 $this->AddPropertyInteger('BaseTariffPrice'); 193 $this->AddPropertyInteger('TopTariffPrice'); 194 } 195 } 196 197 class FinanceMonthlyOverall extends Model 198 { 199 function __construct($Database, $System) 200 { 201 parent::__construct($Database, $System); 202 $this->Name = 'FinanceMonthlyOverall'; 203 $this->AddPropertyInteger('Money'); 204 $this->AddPropertyDate('Date'); 205 $this->AddPropertyInteger('Administration'); 206 $this->AddPropertyInteger('kWh'); 207 $this->AddPropertyInteger('AdministrationTotal'); 208 $this->AddPropertyInteger('ConsumptionTotal'); 209 $this->AddPropertyInteger('TotalPaid'); 210 $this->AddPropertyInteger('BaseTariffPrice'); 211 $this->AddPropertyInteger('TopTariffPrice'); 212 $this->AddPropertyInteger('MemberCount'); 213 $this->AddPropertyInteger('Investment'); 165 214 } 166 215 } … … 237 286 $this->License = 'GNU/GPL'; 238 287 $this->Description = 'Accounting processing'; 239 $this->Dependencies = array('User' );288 $this->Dependencies = array('User', 'Subject'); 240 289 $this->Models = array('FinanceYear', 'DocumentLine', 'DocumentLineSequence', 241 290 'FinanceTariff', 'FinanceOperation', 'FinanceClaimsLiabilities', 242 'FinanceBills', 'FinanceBillsItems'); 291 'FinanceBills', 'FinanceBillsItems', 'FinanceBillingPeriod', 'FinanceCharge', 292 'FinanceMonthlyOverall'); 243 293 $this->Views = array('FinanceOperation', 'FinanceClaimsLiabilities'); 244 294 } … … 331 381 $this->BillingPeriods[$BillingPeriod['Id']] = $BillingPeriod; 332 382 333 $DbResult = $this->Database->query('SELECT * FROM finance_charge WHERE period='.$Period);383 $DbResult = $this->Database->query('SELECT * FROM FinanceCharge WHERE period='.$Period); 334 384 $Row = $DbResult->fetch_array(); 335 385 $this->kWh = $Row['kWh']; 336 $this->Internet = $Row[' internet'];337 $this->Sprava = $Row[' administration_per_user'];338 $this->RealMaxSpeed = $Row[' internet_speed'];339 $this->SpeedReserve = $Row[' internet_speed_reserve'];340 $this->BaseSpeedElement = $Row[' base_speed_element'];386 $this->Internet = $Row['Internet']; 387 $this->Sprava = $Row['AdministrationPerUser']; 388 $this->RealMaxSpeed = $Row['InternetSpeed']; 389 $this->SpeedReserve = $Row['InternetSpeedReserve']; 390 $this->BaseSpeedElement = $Row['BaseSpeedElement']; 341 391 $this->MaxSpeed = $this->RealMaxSpeed - $this->SpeedReserve; 342 392 $this->TopTariffPrice = $Row['TopTariffPrice']; … … 348 398 349 399 $this->SpravaUsers = $this->InternetUsers; 350 $DbResult = $this->Database->query('SELECT SUM(` consumption`) FROM `network_segments`');400 $DbResult = $this->Database->query('SELECT SUM(`Consumption`) FROM `network_segments`'); 351 401 $TotalConsumption = $DbResult->fetch_array(); 352 402 $this->TotalConsumption = $TotalConsumption[0]; -
trunk/Modules/Finance/FinanceOverview.php
r366 r377 23 23 $Output .= '<br /><strong>Souhrn:</strong><br />'; 24 24 25 $DbResult = $this->Database->query('SELECT * FROM finance_monthly_overall ORDER BY date DESC LIMIT 0,1');25 $DbResult = $this->Database->query('SELECT * FROM FinanceMonthlyOverall ORDER BY Date DESC LIMIT 0,1'); 26 26 $Row = $DbResult->fetch_array(); 27 27 $Output .= 'Platba za internetovou linku ('.$Finance->RealMaxSpeed.'/'.$Finance->RealMaxSpeed.' kbit/s): <strong>'.$Finance->Internet.' Kč</strong><br />'; … … 60 60 $TotalGain = 0; 61 61 $TotalExpense = 0; 62 $DbResult = $this->Database->query('SELECT SUM( consumption) FROM network_devices WHERE used=1');62 $DbResult = $this->Database->query('SELECT SUM(Consumption) FROM network_devices WHERE used=1'); 63 63 $Row = $DbResult->fetch_array(); 64 64 $TotalConsumption = $this->System->Modules['Finance']->W2Kc($Row[0]); -
trunk/Modules/Finance/Manage.php
r375 r377 279 279 280 280 // Načti poslední měsíční přehled a nastavení 281 $DbResult = $this->Database->select(' finance_monthly_overall', '*', '1 ORDER BY date DESC LIMIT 1');281 $DbResult = $this->Database->select('FinanceMonthlyOverall', '*', '1 ORDER BY Date DESC LIMIT 1'); 282 282 $Overall = $DbResult->fetch_array(); 283 283 284 284 $Output -= 'Datum: '.date('j.n.Y').'<br />'; 285 285 286 $Datum = explode('-', $Overall[' date']);286 $Datum = explode('-', $Overall['Date']); 287 287 $Mesic = date('m') + 0; 288 288 … … 359 359 // Update finance charge 360 360 $Output .= 'Měním aktuální parametry sítě...<br>'; 361 $this->Database->delete(' finance_charge', 'period = 0');362 $DbResult = $this->Database->select(' finance_charge', '*', 'period = 1');361 $this->Database->delete('FinanceCharge', 'Period = 0'); 362 $DbResult = $this->Database->select('FinanceCharge', '*', 'Period = 1'); 363 363 $Charge = $DbResult->fetch_assoc(); 364 364 //print_r($Charge); 365 $DbResult = $this->Database->insert('finance_charge', array('period' => 0, 'internet' => $Charge['internet'], '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'], 'BaseTariffPrice' => $Charge['BaseTariffPrice'], 'TopTariffPrice' => $Charge['TopTariffPrice'])); 365 $DbResult = $this->Database->insert('FinanceCharge', array('Period' => 0, 366 'Internet' => $Charge['Internet'], 'InternetSpeed' => $Charge['InternetSpeed'], 367 'InternetSpeedReserve' => $Charge['InternetSpeedReserve'], 368 'AdministrationPerUser' => $Charge['AdministrationPerUser'], 369 'kWh' => $Charge['kWh'], 'BaseSpeedElement' => $Charge['BaseSpeedElement'], 370 'BaseTariffPrice' => $Charge['BaseTariffPrice'], 'TopTariffPrice' => $Charge['TopTariffPrice'])); 366 371 367 372 $Output .= 'Přidávám měsíční přehled...<br />'; 368 $this->Database->insert('finance_monthly_overall', array('date' => 'NOW()', 'money' => $Finance->Internet, 'kWh' => $Finance->kWh, 'administration' => $Finance->Sprava, 'administration_total' => $SpravaCelkem, 'consumption_total' => $TotalConsumptionCost, 'total_paid' => $Finance->TotalPaid, 'BaseTariffPrice' => $Charge['BaseTariffPrice'], 'TopTariffPrice' => $Charge['TopTariffPrice'], 'member_count' => $Finance->InternetUsers)); 373 $this->Database->insert('FinanceMonthlyOverall', array('Date' => 'NOW()', 374 'Money' => $Finance->Internet, 'kWh' => $Finance->kWh, 375 'Administration' => $Finance->Sprava, 'AdministrationTotal' => $SpravaCelkem, 376 'ConsumptionTotal' => $TotalConsumptionCost, 'TotalPaid' => $Finance->TotalPaid, 377 'BaseTariffPrice' => $Charge['BaseTariffPrice'], 'TopTariffPrice' => $Charge['TopTariffPrice'], 'MemberCount' => $Finance->InternetUsers)); 369 378 370 379 // Update tarrifs -
trunk/Modules/Finance/MonthlyOverall.php
r370 r377 11 11 12 12 $Output = '<table class="WideTable"><tr><th>Rok</th><th>Měsíc</th><th>Internet [Kč]</th><th>Účastníků</th><th>Správa [Kč/účastníka]</th><th>Správa [Kč]</th><th>Spotřeba [Kč/kWh]</th><th>Spotřeba [Kč]</th><th>Obrat [Kč]</th><th>Průměrná cena [Kč/účastníka]</th><th align="center">Investice [Kč]</th></tr>'; 13 $Total = array(' money' => 0, 'administration_total' => 0, 'consumption_total' => 0, 'total_paid' => 0, 'investment' => 0);14 $DbResult = $this->Database->select(' finance_monthly_overall', '*', '1 ORDER BY date DESC');13 $Total = array('Money' => 0, 'AdministrationTotal' => 0, 'ConsumptionTotal' => 0, 'TotalPaid' => 0, 'Investment' => 0); 14 $DbResult = $this->Database->select('FinanceMonthlyOverall', '*', '1 ORDER BY Date DESC'); 15 15 while($Month = $DbResult->fetch_array()) 16 16 { 17 $DateParts = explode('-', $Month['date']); 18 $Output .= '<tr><td>'.$DateParts[0].'</td><td align="center">'.$MonthNames[$DateParts[1] * 1].'</td><td align="center">'.$Month['money'].'</td><td align="center">'.$Month['member_count'].'</td><td align="center">'.$Month['administration'].'</td><td align="center">'.$Month['administration_total'].'</td><td align="center">'.$Month['kWh'].'</td><td align="center">'.$Month['consumption_total'].'</td><td align="center">'.$Month['total_paid'].'</td><td align="center">'.round($Month['total_paid'] / $Month['member_count']).'</td><td align="center">'.$Month['investment'].'</td></tr>'; 17 $DateParts = explode('-', $Month['Date']); 18 $Output .= '<tr><td>'.$DateParts[0].'</td><td align="center">'. 19 $MonthNames[$DateParts[1] * 1].'</td><td align="center">'.$Month['Money']. 20 '</td><td align="center">'.$Month['MemberCount'].'</td><td align="center">'. 21 $Month['Administration'].'</td><td align="center">'.$Month['AdministrationTotal']. 22 '</td><td align="center">'.$Month['kWh'].'</td><td align="center">'. 23 $Month['Consumption_Total'].'</td><td align="center">'.$Month['TotalPaid']. 24 '</td><td align="center">'.round($Month['TotalPaid'] / $Month['MemberCount']). 25 '</td><td align="center">'.$Month['Investment'].'</td></tr>'; 19 26 20 $Total[' money'] += $Month['money'];21 $Total[' administration_total'] += $Month['administration_total'];22 $Total[' consumption_total'] += $Month['consumption_total'];23 $Total[' total_paid'] += $Month['total_paid'];24 $Total['investment'] += $Month['investment'];27 $Total['Money'] += $Month['Money']; 28 $Total['AdministrationTotal'] += $Month['AdministrationTotal']; 29 $Total['ConsumptionTotal'] += $Month['ConsumptionTotal']; 30 $Total['TotalPaid'] += $Month['TotalPaid']; 31 $Total['Investment'] += $Month['Investment']; 25 32 //if($DateParts[1] == '01') echo('<tr><td style="font-size: 4;" colspan="10"> </td></tr>'); 26 33 } 27 $Output .= '<tr><th colspan="2">Celkem</th><th>'.$Total[' money'].'</th><th> </th><th> </th><th>'.$Total['administration_total'].'</th><th> </th><th>'.$Total['consumption_total'].'</th><th>'.$Total['total_paid'].'</th><th> </th><th>'.$Total['investment'].'</th>';34 $Output .= '<tr><th colspan="2">Celkem</th><th>'.$Total['Money'].'</th><th> </th><th> </th><th>'.$Total['AdministrationTotal'].'</th><th> </th><th>'.$Total['ConsumptionTotal'].'</th><th>'.$Total['TotalPaid'].'</th><th> </th><th>'.$Total['Investment'].'</th>'; 28 35 $Output .= '</table>'; 29 36 return($Output);
Note:
See TracChangeset
for help on using the changeset viewer.