Changeset 219 for trunk/finance/manage.php
- Timestamp:
- May 27, 2009, 1:17:11 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/finance/manage.php
r207 r219 517 517 // Generuj účetní položky 518 518 $DbResult = $this->Database->query('SELECT Member.*, MemberPayment.MonthlyTotal, UNIX_TIMESTAMP(Member.BillingPeriodLastDate), Subject.Name AS SubjectName FROM MemberPayment JOIN Member ON Member.Id=MemberPayment.Member JOIN Subject ON Subject.Id=Member.Subject'); 519 while($Member = $DbResult->fetch_a rray())519 while($Member = $DbResult->fetch_assoc()) 520 520 { 521 521 $Output .= $Member['SubjectName'].': '; 522 $Period = $this->GetBillingPeriod($Member['BillingPeriodNext']); 522 //$Member['UNIX_TIMESTAMP(Member.BillingPeriodLastDate)'] = MysqlDateTimeToTime('2009-04-01 1:1:1'); 523 $Period = $this->GetBillingPeriod($Member['BillingPeriodNext']); 523 524 if($Period['From'] > $Member['UNIX_TIMESTAMP(Member.BillingPeriodLastDate)']) 524 525 { 525 526 $this->Database->update('Member', 'Id='.$Member['Id'], array('BillingPeriod' => $Member['BillingPeriodNext'], 'InternetTariffCurrentMonth' => $Member['InternetTariffNextMonth'])); 526 527 $Member['BillingPeriod'] = $Member['BillingPeriodNext']; 528 $Member['InternetTariffCurrentMonth'] = $Member['InternetTariffNextMonth']; 527 529 } 528 530 $Period = $this->GetBillingPeriod($Member['BillingPeriod']); … … 536 538 $BillId = $this->System->Modules['Bill']->CreateBill($Member['Subject'], array(array('Description' => 'Připojení k síti', 'Price' => $PayPerPeriod, 'Quantity' => 1)), $Period['From'], $Period['To'], $BillCode); 537 539 $this->Database->insert('FinanceClaimsLiabilities', array('Value' => $PayPerPeriod, 'Subject' => $Member['Subject'], 'TimeCreation' => 'NOW()', 'Text' => 'Připojení k síti za období '.$TimePeriodText, 'Bill' => $BillId, 'BillCode' => $BillCode)); 540 $Output .= $this->SendPaymentEmail($Member['Id']); 538 541 $this->Database->update('Member', 'Id='.$Member['Id'], array('BillingPeriodLastDate' => TimeToMysqlDateTime($Period['To']))); 539 542 } else $Output .= '<br />'; … … 565 568 566 569 // Restart traffic shaping 567 //$this->Database->update('NetworkConfiguration', 'Id = 3', array('Changed' => 1)); 568 } 569 return($Output); 570 //$this->Database->update('NetworkConfiguration', 'Id = 3', array('Changed' => 1)); 571 } 572 return($Output); 573 } 574 575 function SendPaymentEmail($MemberId) 576 { 577 global $Config; 578 579 $DbResult = $this->Database->select('Member', '*', 'Id='.$MemberId); 580 $Member = $DbResult->fetch_assoc(); 581 582 $DbResult = $this->Database->select('MemberPayment', '*', 'Member='.$MemberId); 583 $MemberPayment = $DbResult->fetch_assoc(); 584 585 $DbResult = $this->Database->select('Subject', 'Name', 'Id='.$Member['Subject']); 586 $Subject = $DbResult->fetch_assoc(); 587 588 $DbResult = $this->Database->select('User', '*', 'Id='.$Member['ResponsibleUser']); 589 $User = $DbResult->fetch_assoc(); 590 591 if($User['Email'] != '') 592 { 593 $Title = 'Pravidelné vyúčtování internetu'; 594 $Content = 'Vyúčtovaní subjektu <strong>'.$Subject['Name'].'</strong> zastoupeného uživatelem <strong>'.$User['Name'].'</strong>.<br /><br />'. 595 'Váš aktuální tarif: <strong>'.$this->System->Modules['Finance']->Tariffs[$Member['InternetTariffCurrentMonth']]['Name'].'</strong><br />'. 596 'Vaše platební období: <strong>'.$this->System->Modules['Finance']->BillingPeriods[$Member['BillingPeriod']]['Name'].'</strong><br />'. 597 'Pravidelná platba za období: <strong>'.$MemberPayment['MonthlyTotal'].' Kč</strong><br />'. 598 'Stav vašeho účtu: <strong>'.$MemberPayment['Cash'].' Kč</strong><br /><br />'; 599 $Content .= 'Nové finanční operace:<br/>'. 600 '<table border="1"><tr><th>Čas</th><th>Popis</th><th>Částka [Kč]</th></tr>'; 601 //$Member['BillingPeriodLastDate'] = '2009-04-01'; 602 $DbResult = $this->Database->query('SELECT T1.* FROM ((SELECT Text, Time, Value AS Value, Bill FROM FinanceOperation WHERE (Subject='.$Member['Subject'].')) UNION ALL '. 603 '(SELECT Text, TimeCreation as Time, -Value as Value, Bill FROM FinanceClaimsLiabilities WHERE (Subject='.$Member['Subject'].')) ORDER BY Time DESC) AS T1 WHERE (T1.Time > "'.$Member['BillingPeriodLastDate'].'")'); 604 while($DbRow = $DbResult->fetch_assoc()) 605 { 606 $Content .= '<tr><td>'.HumanDate($DbRow['Time']).'</td><td>'.$DbRow['Text'].'</td><td>'.$DbRow['Value'].'</td></tr>'; 607 } 608 $Content .= '</table>'. 609 'Pro více informací a možnost změny údajů se prosím přihlašte na stránkách <a href="http://'.$Config['Web']['Host'].$Config['Web']['RootFolder'].'">http://'.$Config['Web']['Host'].$Config['Web']['RootFolder'].'</a>.<br /><br />'; 610 611 $Content .= '<br />Tento email je generován automaticky. V případě zjištění nesrovnalostí pište zpět.'; 612 $AdditionalHeaders = 'To: =?UTF-8?B?'.base64_encode($User['Name']).'?= <'.$User['Email'].">\n".'From: =?UTF-8?B?'.base64_encode($Config['Web']['Title']).'?='." <".$Config['Web']['AdminEmail'].">\n"; 613 $this->System->AddEmailToQueue($User['Email'], $Title, $Content, $AdditionalHeaders); 614 $Output = ''; 615 } else $Output = 'Uživatel '.$User['Name'].' nemá email.'; 570 616 } 571 617 }
Note:
See TracChangeset
for help on using the changeset viewer.