Changeset 887 for trunk/Modules/Finance
- Timestamp:
- Nov 20, 2020, 12:08:12 AM (4 years ago)
- Location:
- trunk/Modules/Finance
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Finance/Bill.php
r874 r887 3 3 class Bill extends Model 4 4 { 5 var $SpecificSymbol = 1; // počítačová sít6 var $Checked;5 public int $SpecificSymbol = 1; // computer network number 6 public bool $Checked = false; 7 7 8 8 function GenerateHTML() … … 11 11 } 12 12 13 function SaveToFile($FileName) 14 { 15 global $Database; 16 13 function SaveToFile(string $FileName) 14 { 17 15 $PdfData = $this->HtmlToPdf($this->GenerateHTML()); 18 16 file_put_contents($FileName, $PdfData); 19 17 } 20 18 21 function HtmlToPdf( $HtmlCode)19 function HtmlToPdf(string $HtmlCode): string 22 20 { 23 21 $Encoding = new Encoding(); … … 35 33 class BillInvoice extends Bill 36 34 { 37 var$InvoiceId;38 39 function ShowSubjectInfo( $Subject)35 public string $InvoiceId; 36 37 function ShowSubjectInfo(array $Subject): string 40 38 { 41 39 $BooleanText = array('Ne', 'Ano'); … … 50 48 } 51 49 52 function GenerateHTML() 53 { 54 $Finance = & $this->System->Modules['Finance'];50 function GenerateHTML(): string 51 { 52 $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance; 55 53 $Finance->LoadMonthParameters(0); 56 54 … … 152 150 class BillOperation extends Bill 153 151 { 154 var$OperationId;155 156 function GenerateHTML() 152 public string $OperationId; 153 154 function GenerateHTML(): string 157 155 { 158 156 $DbResult = $this->Database->query('SELECT `FinanceOperation`.*, `FinanceOperationGroup`.`Direction`, `DocumentLineCode`.`Name` AS `BillName` FROM `FinanceOperation` '. -
trunk/Modules/Finance/Finance.php
r877 r887 41 41 var $Rounding; 42 42 43 function LoadMonthParameters( $Period = 1) // 0 - now, 1 - next month43 function LoadMonthParameters(int $Period = 1) // 0 - now, 1 - next month 44 44 { 45 45 $DbResult = $this->Database->query('SELECT * FROM `FinanceBillingPeriod`'); … … 78 78 } 79 79 80 function W2Kc($Spotreba) 80 function W2Kc($Spotreba): string 81 81 { 82 82 return round($Spotreba * 0.72 * $this->kWh); … … 88 88 $EndTime = mktime(0, 0, 0, 12, 31, $Year); 89 89 $this->Database->insert('FinanceYear', array('Year' => $Year, 90 'DateStart' => TimeToMysqlDate($StartTime), 'DateEnd' => TimeToMysqlDate($EndTime), 'Closed' => 0));91 $YearId = $this->Database->insert_id;90 'DateStart' => TimeToMysqlDate($StartTime), 'DateEnd' => TimeToMysqlDate($EndTime), 'Closed' => 0)); 91 $YearId = $this->Database->insert_id; 92 92 93 93 // Create DocumentLineSequence from previous … … 95 95 while ($DbRow = $DbResult->fetch_assoc()) 96 96 { 97 $this->Database->insert('DocumentLineSequence', array('FinanceYear' => $YearId,98 'NextNumber' => 1, 'YearPrefix' => 1, 'DocumentLine' => $DbRow['Id']));99 }100 } 101 102 function GetFinanceYear( $Year)97 $this->Database->insert('DocumentLineSequence', array('FinanceYear' => $YearId, 98 'NextNumber' => 1, 'YearPrefix' => 1, 'DocumentLine' => $DbRow['Id'])); 99 } 100 } 101 102 function GetFinanceYear(int $Year) 103 103 { 104 104 if ($Year == 0) … … 107 107 $DbResult = $this->Database->select('FinanceYear', '*', '1 ORDER BY `Year` DESC LIMIT 1'); 108 108 } else $DbResult = $this->Database->select('FinanceYear', '*', '`Year`='.$Year); 109 if ($DbResult->num_rows == 0) { 110 if ($Year == date('Y')) 111 { 112 $this->CreateFinanceYear($Year); 109 if ($DbResult->num_rows == 0) 110 { 111 if ($Year == date('Y')) 112 { 113 $this->CreateFinanceYear($Year); 113 114 $DbResult = $this->Database->select('FinanceYear', '*', '`Year`='.$Year); 114 } else throw new Exception('Rok '.$Year.' nenalezen');115 }115 } else throw new Exception('Rok '.$Year.' nenalezen'); 116 } 116 117 $FinanceYear = $DbResult->fetch_assoc(); 117 118 if ($FinanceYear['Closed'] == 1) … … 120 121 } 121 122 122 function GetNextDocumentLineNumber( $Id,$FinanceYear = 0)123 { 124 $FinanceYear = $this->GetFinanceYear($FinanceYear);123 function GetNextDocumentLineNumber(string $Id, int $FinanceYear = 0) 124 { 125 $FinanceYear = $this->GetFinanceYear($FinanceYear); 125 126 126 127 $DbResult = $this->Database->query('SELECT `Shortcut`, `Id` FROM `DocumentLine` WHERE `Id`='.$Id); … … 141 142 } 142 143 143 function GetNextDocumentLineNumberId( $Id, $FinanceYear = 0)144 function GetNextDocumentLineNumberId(string $Id, int $FinanceYear = 0): int 144 145 { 145 146 $Code = $this->GetNextDocumentLineNumber($Id, $FinanceYear); … … 148 149 } 149 150 150 function GetFinanceGroupById( $Id, $Table)151 function GetFinanceGroupById(string $Id, string $Table): ?array 151 152 { 152 153 $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE `Id`= '.$Id); … … 154 155 $Group = $DbResult->fetch_assoc(); 155 156 return $Group; 156 } else die('Finance group id '.$Id.' not found in table '.$Table); 157 } 158 159 function RecalculateMemberPayment() 157 } 158 echo('Finance group id '.$Id.' not found in table '.$Table); 159 return null; 160 } 161 162 function RecalculateMemberPayment(): string 160 163 { 161 164 $Output = 'Aktualizuji finance členů...<br />'; … … 199 202 $Consumption = 0; 200 203 $this->Database->insert('MemberPayment', array('Member' => $Member['Id'], 201 202 203 204 'MonthlyInternet' => $MonthlyInet, 205 'MonthlyTotal' => $Monthly, 'MonthlyConsumption' => $this->W2Kc($Consumption), 206 'Cash' => $Cash, 'MonthlyPlus' => $this->W2Kc($ConsumptionPlus))); 204 207 } 205 $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'RecalculateMemberPayment');208 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('Finance', 'RecalculateMemberPayment'); 206 209 return $Output; 207 210 } 208 211 209 function GetVATByType( $TypeId)212 function GetVATByType(string $TypeId): string 210 213 { 211 214 $Time = time(); … … 220 223 class ModuleFinance extends AppModule 221 224 { 222 function __construct($System) 225 public Finance $Finance; 226 public Bill $Bill; 227 228 function __construct(System $System) 223 229 { 224 230 parent::__construct($System); … … 229 235 $this->Description = 'Base module for finance management'; 230 236 $this->Dependencies = array('File', 'EmailQueue'); 231 } 232 233 function DoInstall() 234 { 235 } 236 237 function DoUninstall() 238 { 239 } 240 241 function DoStart() 237 238 $this->Bill = new Bill($this->System); 239 $this->Finance = new Finance($this->System); 240 } 241 242 function DoInstall(): void 243 { 244 } 245 246 function DoUninstall(): void 247 { 248 } 249 250 function DoStart(): void 242 251 { 243 252 global $Config; 244 253 245 $this->System->RegisterPage( array('finance', 'sprava'), 'PageFinanceManage');246 $this->System->RegisterPage( array('finance', 'platby'), 'PageFinanceUserState');247 $this->System->RegisterPage( array('finance', 'import'), 'PageFinanceImportPayment');248 $this->System->RegisterPage( array('finance', 'zivnost'), 'PageFinanceTaxFiling');254 $this->System->RegisterPage(['finance', 'sprava'], 'PageFinanceManage'); 255 $this->System->RegisterPage(['finance', 'platby'], 'PageFinanceUserState'); 256 $this->System->RegisterPage(['finance', 'import'], 'PageFinanceImportPayment'); 257 $this->System->RegisterPage(['finance', 'zivnost'], 'PageFinanceTaxFiling'); 249 258 250 259 $this->System->FormManager->RegisterClass('FinanceOperation', array( … … 644 653 )); 645 654 646 647 $this->System->AddModule(new Bill($this->System)); 648 $this->System->AddModule(new Finance($this->System)); 649 $this->System->Modules['Finance']->MainSubject = $Config['Finance']['MainSubjectId']; 650 $this->System->Modules['Finance']->DirectoryId = $Config['Finance']['DirectoryId']; 651 652 $this->System->ModuleManager->Modules['IS']->RegisterDashboardItem('Finance', 653 array('ModuleFinance', 'ShowDashboardItem')); 654 } 655 656 function ShowDashboardItem() 655 $this->Finance->MainSubject = $Config['Finance']['MainSubjectId']; 656 $this->Finance->DirectoryId = $Config['Finance']['DirectoryId']; 657 658 ModuleIS::Cast($this->System->GetModule('IS'))->RegisterDashboardItem('Finance', array($this, 'ShowDashboardItem')); 659 } 660 661 function ShowDashboardItem(): string 657 662 { 658 663 $DbResult = $this->Database->select('FinanceOperation', 'ROUND(SUM(`Value`))', '1'); … … 662 667 } 663 668 664 function DoStop() 665 { 666 } 667 668 function BeforeInsertFinanceOperation( $Form)669 function DoStop(): void 670 { 671 } 672 673 function BeforeInsertFinanceOperation(Form $Form): array 669 674 { 670 675 if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']); 671 676 else $Year = date("Y", $Form->Values['ValidFrom']); 672 $FinanceGroup = $this-> System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'FinanceOperationGroup');673 $Form->Values['BillCode'] = $this-> System->Modules['Finance']->GetNextDocumentLineNumberId($FinanceGroup['DocumentLine'], $Year);674 return $Form->Values; 675 } 676 677 function AfterInsertFinanceOperation( $Form, $Id)678 { 679 $FinanceGroup = $this-> System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'FinanceOperationGroup');677 $FinanceGroup = $this->Finance->GetFinanceGroupById($Form->Values['Group'], 'FinanceOperationGroup'); 678 $Form->Values['BillCode'] = $this->Finance->GetNextDocumentLineNumberId($FinanceGroup['DocumentLine'], $Year); 679 return $Form->Values; 680 } 681 682 function AfterInsertFinanceOperation(Form $Form, string $Id): array 683 { 684 $FinanceGroup = $this->Finance->GetFinanceGroupById($Form->Values['Group'], 'FinanceOperationGroup'); 680 685 $this->Database->query('UPDATE `'.$Form->Definition['Table'].'` SET `Value`= '. 681 686 ($Form->Values['ValueUser'] * $FinanceGroup['ValueSign']).' WHERE `Id`='.$Id); … … 683 688 } 684 689 685 function BeforeModifyFinanceOperation( $Form, $Id)686 { 687 $FinanceGroup = $this-> System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'FinanceOperationGroup');690 function BeforeModifyFinanceOperation(Form $Form, string $Id): array 691 { 692 $FinanceGroup = $this->Finance->GetFinanceGroupById($Form->Values['Group'], 'FinanceOperationGroup'); 688 693 $this->Database->query('UPDATE `'.$Form->Definition['Table'].'` SET `Value`= '. 689 694 ($Form->Values['ValueUser'] * $FinanceGroup['ValueSign']).' WHERE `Id`='.$Id); … … 691 696 } 692 697 693 function BeforeInsertFinanceInvoice( $Form)698 function BeforeInsertFinanceInvoice(Form $Form): array 694 699 { 695 700 // Get new DocumentLineCode by selected invoice Group 696 701 if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']); 697 702 else $Year = date("Y", $Form->Values['ValidFrom']); 698 $Group = $this-> System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'FinanceInvoiceGroup');699 $Form->Values['BillCode'] = $this-> System->Modules['Finance']->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year);700 return $Form->Values; 701 } 702 703 function AfterInsertFinanceInvoice( $Form, $Id)704 { 705 $FinanceGroup = $this-> System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'FinanceInvoiceGroup');703 $Group = $this->Finance->GetFinanceGroupById($Form->Values['Group'], 'FinanceInvoiceGroup'); 704 $Form->Values['BillCode'] = $this->Finance->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year); 705 return $Form->Values; 706 } 707 708 function AfterInsertFinanceInvoice(Form $Form, string $Id): array 709 { 710 $FinanceGroup = $this->Finance->GetFinanceGroupById($Form->Values['Group'], 'FinanceInvoiceGroup'); 706 711 $DbResult = $this->Database->query(str_replace('#Id', $Id, $Form->Definition['Items']['ValueUser']['SQL'])); 707 712 $DbRow = $DbResult->fetch_row(); … … 713 718 } 714 719 715 function BeforeModifyFinanceInvoice( $Form, $Id)716 { 717 $FinanceGroup = $this-> System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'FinanceInvoiceGroup');720 function BeforeModifyFinanceInvoice(Form $Form, string $Id): array 721 { 722 $FinanceGroup = $this->Finance->GetFinanceGroupById($Form->Values['Group'], 'FinanceInvoiceGroup'); 718 723 $DbResult = $this->Database->query(str_replace('#Id', $Id, $Form->Definition['Items']['ValueUser']['SQL'])); 719 724 $DbRow = $DbResult->fetch_row(); … … 724 729 } 725 730 726 function AfterInsertFinanceInvoiceItem( $Form, $Id)731 function AfterInsertFinanceInvoiceItem(Form $Form, string $Id): array 727 732 { 728 733 $ParentForm = new Form($this->System->FormManager); … … 733 738 } 734 739 735 function AfterModifyFinanceInvoiceItem( $Form, $Id)740 function AfterModifyFinanceInvoiceItem(Form $Form, string $Id): array 736 741 { 737 742 $ParentForm = new Form($this->System->FormManager); … … 742 747 } 743 748 744 function BeforeInsertContract( $Form)749 function BeforeInsertContract(Form $Form): array 745 750 { 746 751 if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']); 747 752 else $Year = date("Y", $Form->Values['ValidFrom']); 748 $Form->Values['BillCode'] = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($Form->Values['DocumentLine'], $Year); 749 return $Form->Values; 753 $Form->Values['BillCode'] = $this->Finance->GetNextDocumentLineNumberId($Form->Values['DocumentLine'], $Year); 754 return $Form->Values; 755 } 756 757 static function Cast(AppModule $AppModule): ModuleFinance 758 { 759 if ($AppModule instanceof ModuleFinance) 760 { 761 return $AppModule; 762 } 763 throw new Exception('Expected ModuleFinance type but '.gettype($AppModule)); 750 764 } 751 765 } -
trunk/Modules/Finance/Import.php
r874 r887 3 3 class PageFinanceImportPayment extends Page 4 4 { 5 var $FullTitle = 'Import plateb'; 6 var $ShortTitle = 'Import plateb'; 7 var $ParentClass = 'PageFinance'; 5 function __construct(System $System) 6 { 7 parent::__construct($System); 8 $this->FullTitle = 'Import plateb'; 9 $this->ShortTitle = 'Import plateb'; 10 $this->ParentClass = 'PageFinance'; 11 } 8 12 9 function Show() 13 function Show(): string 10 14 { 11 if (! $this->System->User->CheckPermission('Finance', 'SubjectList')) return 'Nemáte oprávnění';15 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'SubjectList')) return 'Nemáte oprávnění'; 12 16 if (array_key_exists('Operation', $_GET)) 13 17 { … … 26 30 } 27 31 28 function Prepare() 32 function Prepare(): string 29 33 { 30 $Finance = $this->System->Modules['Finance'];34 $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance; 31 35 $Finance->LoadMonthParameters(0); 32 36 $Data = explode("\n", $_POST['Source']); … … 124 128 } 125 129 126 function InsertMoney( $Subject, $Value, $Cash, $Taxable, $Time, $Text,$Group)130 function InsertMoney(string $Subject, string $Value, string $Cash, string $Taxable, string $Time, string $Text, array $Group) 127 131 { 128 132 $Year = date('Y', $Time); 129 $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year);133 $BillCode = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year); 130 134 // TODO: Fixed BankAccount=1, allow to select bank account for import 131 135 $this->Database->insert('FinanceOperation', array('Text' => $Text, … … 136 140 } 137 141 138 function Insert() 142 function Insert(): string 139 143 { 140 $Finance = $this->System->Modules['Finance'];144 $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance; 141 145 $Finance->LoadMonthParameters(0); 142 146 $Output = ''; … … 144 148 for ($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--) 145 149 { 146 if ($_POST['Money'.$I] < 0) { 147 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup'); 148 } else { 149 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup'); 150 if ($_POST['Money'.$I] < 0) 151 { 152 $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup'); 153 } else 154 { 155 $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup'); 150 156 } 151 157 $Date = explode('-', $_POST['Date'.$I]); … … 154 160 0, $_POST['Taxable'.$I], $Date, $_POST['Text'.$I], $FinanceGroup); 155 161 $Output .= $I.', '; 156 $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'NewPaymentInserted');162 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('Finance', 'NewPaymentInserted'); 157 163 } 158 164 return $Output; -
trunk/Modules/Finance/Manage.php
r886 r887 3 3 class PageFinanceManage extends Page 4 4 { 5 var $FullTitle = 'Správa financí'; 6 var $ShortTitle = 'Správa financí'; 7 var $ParentClass = 'PageFinance'; 8 9 function Show() 10 { 11 $Output = ''; 12 if (!$this->System->User->CheckPermission('Finance', 'Manage')) 5 function __construct(System $System) 6 { 7 parent::__construct($System); 8 $this->FullTitle = 'Správa financí'; 9 $this->ShortTitle = 'Správa financí'; 10 $this->ParentClass = 'PageFinance'; 11 } 12 13 function Show(): string 14 { 15 $Output = ''; 16 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'Manage')) 13 17 return 'Nemáte oprávnění'; 14 18 … … 18 22 { 19 23 case 'Recalculate': 20 $Output .= $this->System->Modules['Finance']->RecalculateMemberPayment();24 $Output .= ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->RecalculateMemberPayment(); 21 25 break; 22 26 case 'ShowMonthlyPayment': … … 51 55 $Year = date('Y', $Time); 52 56 53 $MonthCount = $this->System->Modules['Finance']->BillingPeriods[$Period]['MonthCount'];57 $MonthCount = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->BillingPeriods[$Period]['MonthCount']; 54 58 if ($MonthCount <= 0) return array('From' => NULL, 'To' => NULL, 'MonthCount' => 0); 55 59 $MonthCurrent = date('n', $Time); … … 72 76 function ShowMonthlyPayment() 73 77 { 74 if (! $this->System->User->CheckPermission('Finance', 'Manage')) return 'Nemáte oprávnění';78 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'Manage')) return 'Nemáte oprávnění'; 75 79 $SQL = 'SELECT `Member`.*, `MemberPayment`.`MonthlyTotal` AS `Monthly`, '. 76 80 '`MemberPayment`.`Cash` AS `Cash`, '. … … 128 132 global $LastInsertTime; 129 133 134 $Finance = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance; 135 130 136 $Year = date('Y', $TimeCreation); 131 $BillCode = $ this->System->Modules['Finance']->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year);137 $BillCode = $Finance->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year); 132 138 $SumValue = 0; 133 139 foreach ($Items as $Item) { 134 140 $SumValue = $SumValue + $Item['Price'] * $Item['Quantity']; 135 141 } 136 $Finance = &$this->System->Modules['Finance'];137 142 $SumValue = round($SumValue, $Finance->Rounding); 138 143 $this->Database->insert('FinanceInvoice', array( … … 181 186 { 182 187 $InvoiceItems[] = array('Description' => $Service['Name'], 'Price' => $Service['Price'], 183 'Quantity' => $Period['MonthCount'], 'VAT' => $this->System->Modules['Finance']->GetVATByType($Service['VAT']));188 'Quantity' => $Period['MonthCount'], 'VAT' => ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->GetVATByType($Service['VAT'])); 184 189 $MonthlyTotal += $Service['Price']; 185 190 } … … 196 201 197 202 // Load invoice group 198 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById($InvoiceGroupId, 'FinanceInvoiceGroup');203 $FinanceGroup = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->GetFinanceGroupById($InvoiceGroupId, 'FinanceInvoiceGroup'); 199 204 foreach ($InvoiceItems as $Index => $Item) 200 205 { … … 275 280 function ProcessMonthlyPayment() 276 281 { 277 if (! $this->System->User->CheckPermission('Finance', 'Manage')) return 'Nemáte oprávnění';282 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'Manage')) return 'Nemáte oprávnění'; 278 283 $Output = ''; 279 284 280 285 $Output .= $this->ProcessTableUpdates(); 281 286 282 $Finance = & $this->System->Modules['Finance'];287 $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance; 283 288 $Finance->LoadMonthParameters(0); 284 289 … … 334 339 //flush(); 335 340 //$this->GenerateBills(); 336 $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'ProcessMonthlyPayment', $Output);341 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('Finance', 'ProcessMonthlyPayment', $Output); 337 342 } 338 343 $Output = str_replace("\n", '<br/>', $Output); … … 379 384 $Service = $DbResult->fetch_assoc(); 380 385 $Content .= '<strong>'.$Service['Name'].'</strong><br />'."\n". 381 'Vaše platební období: <strong>'. $this->System->Modules['Finance']->BillingPeriods[$Member['BillingPeriod']]['Name'].'</strong><br />'."\n".386 'Vaše platební období: <strong>'.ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->BillingPeriods[$Member['BillingPeriod']]['Name'].'</strong><br />'."\n". 382 387 'Pravidelná platba za období: <strong>'.($MemberPayment['MonthlyTotal'] * $Period['MonthCount']).' Kč</strong><br />'."\n". 383 388 'Bankovní účet: <strong>'.$MainSubjectAccount['NumberFull'].'</strong><br/>'."\n". … … 407 412 408 413 $Content .= '<br />Tento email je generován automaticky. V případě zjištění nesrovnalostí napište zpět.'; 409 $this->System->ModuleManager->Modules['EmailQueue']->AddItem($User['Name'].' <'.$User['Email'].'>', $Title, $Content,414 ModuleEmailQueue::Cast($this->System->GetModule('EmailQueue'))->AddItem($User['Name'].' <'.$User['Email'].'>', $Title, $Content, 410 415 $Config['Web']['Admin'].' <'.$Config['Web']['AdminEmail'].'>'); 411 416 $Output = ''; … … 416 421 function GenerateInvoice($Where) 417 422 { 423 $DirectoryId = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->DirectoryId; 418 424 $Output = ''; 419 425 $DbResult = $this->Database->query('SELECT * FROM `FinanceInvoice` WHERE (`BillCode` <> "") '. … … 423 429 if ($Row['File'] == null) 424 430 { 425 $DbResult2 = $this->Database->insert('File', array('Name' => '', 'Size' => 0, 426 'Directory' => $this->System->Modules['Finance']->DirectoryId, 'Time' => 'NOW()')); 431 $this->Database->insert('File', array('Name' => '', 'Size' => 0, 'Directory' => $DirectoryId, 'Time' => 'NOW()')); 427 432 $FileId = $this->Database->insert_id; 428 433 } else $FileId = $Row['File']; … … 432 437 $Bill->System = &$this->System; 433 438 $Bill->InvoiceId = $Row['Id']; 434 $FullFileName = $this->System->Modules['File']->GetDir($this->System->Modules['Finance']->DirectoryId).$FileName;439 $FullFileName = ModuleFile::Cast($this->System->GetModule('File'))->File->GetDir($DirectoryId).$FileName; 435 440 $Bill->SaveToFile($FullFileName); 436 441 if (file_exists($FullFileName)) … … 446 451 function GenerateOperation($Where) 447 452 { 453 $DirectoryId = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->DirectoryId; 448 454 $Output = ''; 449 455 $DbResult = $this->Database->query('SELECT * FROM `FinanceOperation` WHERE (`BillCode` <> "") '. … … 454 460 { 455 461 $DbResult2 = $this->Database->insert('File', array('Name' => '', 'Size' => 0, 456 'Directory' => $ this->System->Modules['Finance']->DirectoryId, 'Time' => 'NOW()'));462 'Directory' => $DirectoryId, 'Time' => 'NOW()')); 457 463 $FileId = $this->Database->insert_id; 458 464 } else $FileId = $Row['File']; … … 462 468 $Bill->System = &$this->System; 463 469 $Bill->OperationId = $Row['Id']; 464 $FullFileName = $this->System->Modules['File']->GetDir($this->System->Modules['Finance']->DirectoryId).$FileName;470 $FullFileName = ModuleFile::Cast($this->System->GetModule('File'))->File->GetDir($DirectoryId).$FileName; 465 471 $Bill->SaveToFile($FullFileName); 466 472 if (file_exists($FullFileName)) -
trunk/Modules/Finance/Trade.php
r874 r887 3 3 class PageFinanceTaxFiling extends Page 4 4 { 5 var $FullTitle = 'Daňová evidence';6 var $ShortTitle = 'Daňová evidence';7 var $ParentClass = 'PageFinance';8 5 var $StartEvidence = 0; 6 7 function __construct(System $System) 8 { 9 parent::__construct($System); 10 $this->FullTitle = 'Daňová evidence'; 11 $this->ShortTitle = 'Daňová evidence'; 12 $this->ParentClass = 'PageFinance'; 13 } 9 14 10 15 function GetTimePeriodBalance($StartTime, $EndTime) … … 340 345 function ShowSubjectAccount() 341 346 { 347 $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance; 348 342 349 $Output = '<table style="width: 100%"><tr><td style="vertical-align: top;">'; 343 350 $Output .= '<strong>Výpis příjmů/výdajů</strong>'; … … 424 431 } 425 432 426 function Show() 427 { 428 if (! $this->System->User->CheckPermission('Finance', 'TradingStatus'))433 function Show(): string 434 { 435 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'TradingStatus')) 429 436 return 'Nemáte oprávnění'; 430 431 $Finance = &$this->System->Modules['Finance'];432 437 433 438 $Output = ''; -
trunk/Modules/Finance/UserState.php
r874 r887 3 3 class PageFinanceUserState extends Page 4 4 { 5 var $FullTitle = 'Stav financí účastníka'; 6 var $ShortTitle = 'Stav financí'; 7 var $ParentClass = 'PageUser'; 5 function __construct(System $System) 6 { 7 parent::__construct($System); 8 $this->FullTitle = 'Stav financí účastníka'; 9 $this->ShortTitle = 'Stav financí'; 10 $this->ParentClass = 'PageUser'; 11 } 8 12 9 13 function ShowFinanceOperation($Subject) … … 69 73 } 70 74 71 function Show() 75 function Show(): string 72 76 { 73 $Finance = & $this->System->Modules['Finance'];77 $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance; 74 78 $Finance->LoadMonthParameters(0); 75 79 … … 77 81 if (array_key_exists('i', $_GET)) 78 82 { 79 if (! $this->System->User->CheckPermission('Finance', 'Manage')) return 'Nemáte oprávnění';83 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'Manage')) return 'Nemáte oprávnění'; 80 84 $CustomerId = $_GET['i']; 81 85 } else 82 86 { 83 if (! $this->System->User->CheckPermission('Finance', 'DisplaySubjectState')) return 'Nemáte oprávnění';84 $UserId = $this->System->User->User['Id'];87 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'DisplaySubjectState')) return 'Nemáte oprávnění'; 88 $UserId = ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id']; 85 89 $DbResult = $this->Database->query('SELECT `Customer` FROM `UserCustomerRel` WHERE `User`='.$UserId.' LIMIT 1'); 86 90 if ($DbResult->num_rows > 0)
Note:
See TracChangeset
for help on using the changeset viewer.