Changeset 479 for trunk/finance/manage.php
- Timestamp:
- Feb 5, 2013, 9:45:44 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/finance/manage.php
r477 r479 355 355 if($Period['From'] > $Member['UNIX_TIMESTAMP(Member.BillingPeriodLastDate)']) 356 356 { 357 $this->Database->update('Member', 'Id='.$Member['Id'], array('BillingPeriod' => $Member['BillingPeriodNext'], 'InternetTariffCurrentMonth' => $Member['InternetTariffNextMonth'])); 357 $this->Database->update('Member', 'Id='.$Member['Id'], 358 array('BillingPeriod' => $Member['BillingPeriodNext'])); 358 359 $Member['BillingPeriod'] = $Member['BillingPeriodNext']; 359 $Member['InternetTariffCurrentMonth'] = $Member['InternetTariffNextMonth'];360 360 } 361 361 $Period = $this->GetBillingPeriod($Member['BillingPeriod']); 362 $PayPerPeriod = $Member['MonthlyTotal'] * $Period['MonthCount'];363 362 if(($Period['From'] > $Member['UNIX_TIMESTAMP(Member.BillingPeriodLastDate)']) and ($Member['InternetTariffCurrentMonth'] != TARIFF_FREE) and ($PayPerPeriod > 0) and 364 363 ($Member['Blocked'] == 0)) 365 364 { 366 //echo($Mesic.'%'.$MonthCount.'='.($Mesic % $MonthCount).' '); 365 $BillItems = array(); 366 $MonthlyTotal = 0; 367 $DbResult2 = $this->Database->query('(SELECT Service.* FROM ServiceCustomerRel LEFT JOIN Service '. 368 'ON Service.Id=ServiceCustomerRel.Service WHERE ServiceCustomerRel.Customer='.$Member['Id'].') AND (ServiceCustomerRel.Period=0)'); 369 while($Service = $DbResult2->fetch_assoc()) 370 { 371 $BillItems[] = array('Description' => $Service['Name'], 'Price' => $Service['Price'], 372 'Quantity' => $Period['MonthCount']); 373 $MonthlyTotal += $ServicePrice['Price']; 374 $this->Database->update('ServiceCustomerRel', 'Id='); 375 } 376 if($Member['Hire'] != 0) 377 { 378 $Output .= '<tr><td>Nájem</td><td>'.(-$Member['Hire']).'</td></tr>'; 379 $MonthlyTotal -= $Member['Hire']; 380 } 381 if($Member['MonthlyPlus'] != 0) 382 { 383 $MonthlyTotal -= $Member['MonthlyPlus']; 384 } 385 $PayPerPeriod = $MonthlyTotal * $Period['MonthCount']; 386 387 //echo($Mesic.'%'.$MonthCount.'='.($Mesic % $MonthCount).' '); 367 388 $TimePeriodText = date('j.n.Y', $Period['From']).' - '.date('j.n.Y', $Period['To']); 368 $Output .= $TimePeriodText.': '.$M ember['MonthlyTotal'].' * '.$Period['MonthCount'].' = '.$PayPerPeriod.'<br />';369 $BillCode = $Finance->GetNextDocumentLineNumber( 6); // Faktury vydané389 $Output .= $TimePeriodText.': '.$MonthlyTotal.' * '.$Period['MonthCount'].' = '.$PayPerPeriod.'<br />'; 390 $BillCode = $Finance->GetNextDocumentLineNumber(INVOICE_OUT_DOC_LINE); 370 391 $BillId = $this->System->Modules['Bill']->CreateBill($Member['Subject'], 371 array(array('Description' => 'Připojení k Internetu', 'Price' => $PayPerPeriod, 372 'Quantity' => 1)), time(), time() + 3600 * 24 * 15, $BillCode, $Period['From'], $Period['To']); 392 $BillItems, time(), time() + 3600 * 24 * INVOICE_DUE_DAYS, $BillCode, $Period['From'], $Period['To']); 373 393 $this->Database->insert('FinanceClaimsLiabilities', array('Value' => $PayPerPeriod, 374 394 'Subject' => $Member['Subject'], 'TimeCreation' => 'NOW()', 375 'TimeDue' => 'DATE_ADD(NOW(), INTERVAL 15DAY)',376 'Text' => ' Připojení k Internetuza období '.$TimePeriodText,395 'TimeDue' => 'DATE_ADD(NOW(), INTERVAL '.INVOICE_DUE_DAYS.' DAY)', 396 'Text' => 'Vyúčtování služeb za období '.$TimePeriodText, 377 397 'Bill' => $BillId, 'BillCode' => $BillCode)); 378 398 $Output .= $this->SendPaymentEmail($Member['Id']); … … 392 412 $this->Database->insert('FinanceMonthlyOverall', array('Date' => 'NOW()', 'Money' => $Finance->Internet, 'kWh' => $Finance->kWh, 'Administration' => $Finance->Sprava, 'AdministrationTotal' => $SpravaCelkem, 'ConsumptionTotal' => $TotalConsumptionCost, 'TotalPaid' => $Finance->TotalPaid, 'BaseTariffPrice' => $Charge['BaseTariffPrice'], 'TopTariffPrice' => $Charge['TopTariffPrice'], 'MemberCount' => $Finance->InternetUsers)); 393 413 394 // Update tarrifs414 // Update services 395 415 $Output .= 'Měním aktuální tarify....<br>'; 396 $DbResult = $this->Database->select(' FinanceTariff', '*', '`ReplaceId` IS NOT NULL');397 while($ Tariff= $DbResult->fetch_array())416 $DbResult = $this->Database->select('Service', '*', '`ReplaceId` IS NOT NULL'); 417 while($Service = $DbResult->fetch_array()) 398 418 { 399 $this->Database->update('FinanceTariff', 'Id='.$Tariff['ReplaceId'], array('Name' => $Tariff['Name'], 400 'UploadAsymmetry' => $Tariff['UploadAsymmetry'], 'MemberCount' => $Tariff['MemberCount'], 401 'Group' => $Tariff['Group'], 'SpeedMin' => $Tariff['SpeedMin'], 402 'SpeedMax' => $Tariff['SpeedMax'], 'Price' => $Tariff['Price'])); 419 $Service['Id'] = $Service['ReplaceId']; 420 $Service['ReplaceId'] = ''; 421 $this->Database->update('Service', 'Id='.$Service['ReplaceId'], $Service); 403 422 } 404 $this->Database->delete(' FinanceTariff', '`ReplaceId` IS NOT NULL');423 $this->Database->delete('Service', '`ReplaceId` IS NOT NULL'); 405 424 406 425 $Finance->RecalculateMemberPayment(); … … 429 448 $DbResult = $this->Database->select('User', '*', 'Id='.$Member['ResponsibleUser']); 430 449 $User = $DbResult->fetch_assoc(); 450 451 $DbResult = $this->Database->select('Subject', '*', '`Id`='.$Config['Finance']['MainSubjectId']); 452 $MainSubject = $DbResult->fetch_assoc(); 453 454 $DbResult = $this->Database->select('FinanceBankAccount', '*', '(`Subject`='. 455 $Config['Finance']['MainSubjectId'].') AND (`Use`=1)'); 456 $MainSubjectAccount = $DbResult->fetch_assoc(); 431 457 432 458 if($User['Email'] != '') 433 459 { 434 460 $Title = 'Pravidelné vyúčtování služeb'; 435 $Content = 'Vyúčtovaní subjektu <strong>'.$Subject['Name'].'</strong> zastoupeného uživatelem <strong>'.$User['Name'].'</strong> ke dni <strong>'.$this->System->HumanDate(time()).'</strong>.<br /><br />'."\n". 436 'Váš aktuální tarif: <strong>'.$this->System->Modules['Finance']->Tariffs[$Member['InternetTariffCurrentMonth']]['Name'].' '.$this->System->AddPrefixMultipliers($this->System->Modules['Finance']->Tariffs[$Member['InternetTariffCurrentMonth']]['SpeedMax'], 'bit/s', 3, 'Binary').'</strong><br />'."\n". 461 $Content = 'Vyúčtovaní zákazníka <strong>'.$Subject['Name'].'</strong> zastoupeného uživatelem <strong>'.$User['Name'].'</strong> ke dni <strong>'.$this->System->HumanDate(time()).'</strong>.<br /><br />'."\n". 462 'Váše aktuální služby: '; 463 $DbResult = $this->Database->query('SELECT GROUP_CONCAT(Service.Name) AS Name FROM ServiceCustomerRel LEFT JOIN Service '. 464 'ON Service.Id=ServiceCustomerRel.Service WHERE ServiceCustomerRel.Customer='.$Member['Id'].' AND ServiceCustomerRel.Period=0'); 465 $Service = $DbRow->fetch_assoc(); 466 $Content .= '<strong>'.$Service['Name'].'</strong><br />'."\n". 437 467 'Vaše platební období: <strong>'.$this->System->Modules['Finance']->BillingPeriods[$Member['BillingPeriod']]['Name'].'</strong><br />'."\n". 438 468 'Pravidelná platba za období: <strong>'.$MemberPayment['MonthlyTotal'].' Kč</strong><br />'."\n". 439 'Bankovní účet: <strong> 2600134781 / 2010</strong> (EUR Slovensko 2600134781 / 8330, Fio banka)<br/>'."\n".469 'Bankovní účet: <strong>'.$MainSubjectAccount['Number'].'<br/>'."\n". 440 470 'Variabilní symbol: <strong>'.$Member['Subject'].'</strong><br/>'."\n". 441 471 'Stav vašeho účtu: <strong>'.($MemberPayment['Cash'] - $MemberPayment['MonthlyTotal']).' Kč</strong><br /><br />'."\n";
Note:
See TracChangeset
for help on using the changeset viewer.