Changeset 887 for trunk/Modules/Finance/Manage.php
- Timestamp:
- Nov 20, 2020, 12:08:12 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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))
Note:
See TracChangeset
for help on using the changeset viewer.