Ignore:
Timestamp:
Nov 20, 2020, 12:08:12 AM (4 years ago)
Author:
chronos
Message:
  • Added: Static types added to almost all classes, methods and function. Supported by PHP 7.4.
  • Fixed: Various found code issues.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Finance/Manage.php

    r886 r887  
    33class PageFinanceManage extends Page
    44{
    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'))
    1317      return 'Nemáte oprávnění';
    1418
     
    1822    {
    1923      case 'Recalculate':
    20         $Output .= $this->System->Modules['Finance']->RecalculateMemberPayment();
     24        $Output .= ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->RecalculateMemberPayment();
    2125        break;
    2226      case 'ShowMonthlyPayment':
     
    5155    $Year = date('Y', $Time);
    5256
    53     $MonthCount = $this->System->Modules['Finance']->BillingPeriods[$Period]['MonthCount'];
     57    $MonthCount = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->BillingPeriods[$Period]['MonthCount'];
    5458    if ($MonthCount <= 0) return array('From' => NULL, 'To' => NULL, 'MonthCount' => 0);
    5559    $MonthCurrent = date('n', $Time);
     
    7276  function ShowMonthlyPayment()
    7377  {
    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í';
    7579    $SQL = 'SELECT `Member`.*, `MemberPayment`.`MonthlyTotal` AS `Monthly`, '.
    7680      '`MemberPayment`.`Cash` AS `Cash`, '.
     
    128132    global $LastInsertTime;
    129133
     134    $Finance = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance;
     135
    130136    $Year = date('Y', $TimeCreation);
    131     $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year);
     137    $BillCode = $Finance->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year);
    132138    $SumValue = 0;
    133139    foreach ($Items as $Item) {
    134140      $SumValue = $SumValue + $Item['Price'] * $Item['Quantity'];
    135141    }
    136     $Finance = &$this->System->Modules['Finance'];
    137142    $SumValue = round($SumValue, $Finance->Rounding);
    138143    $this->Database->insert('FinanceInvoice', array(
     
    181186        {
    182187          $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']));
    184189          $MonthlyTotal += $Service['Price'];
    185190        }
     
    196201
    197202        // Load invoice group
    198         $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById($InvoiceGroupId, 'FinanceInvoiceGroup');
     203        $FinanceGroup = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->GetFinanceGroupById($InvoiceGroupId, 'FinanceInvoiceGroup');
    199204        foreach ($InvoiceItems as $Index => $Item)
    200205        {
     
    275280  function ProcessMonthlyPayment()
    276281  {
    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í';
    278283    $Output = '';
    279284
    280285    $Output .= $this->ProcessTableUpdates();
    281286
    282     $Finance = &$this->System->Modules['Finance'];
     287    $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance;
    283288    $Finance->LoadMonthParameters(0);
    284289
     
    334339      //flush();
    335340      //$this->GenerateBills();
    336       $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'ProcessMonthlyPayment', $Output);
     341      ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('Finance', 'ProcessMonthlyPayment', $Output);
    337342    }
    338343    $Output = str_replace("\n", '<br/>', $Output);
     
    379384      $Service = $DbResult->fetch_assoc();
    380385      $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".
    382387        'Pravidelná platba za období: <strong>'.($MemberPayment['MonthlyTotal'] * $Period['MonthCount']).' Kč</strong><br />'."\n".
    383388        'Bankovní účet: <strong>'.$MainSubjectAccount['NumberFull'].'</strong><br/>'."\n".
     
    407412
    408413      $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,
    410415         $Config['Web']['Admin'].' <'.$Config['Web']['AdminEmail'].'>');
    411416      $Output = '';
     
    416421  function GenerateInvoice($Where)
    417422  {
     423    $DirectoryId = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->DirectoryId;
    418424    $Output = '';
    419425    $DbResult = $this->Database->query('SELECT * FROM `FinanceInvoice` WHERE (`BillCode` <> "") '.
     
    423429      if ($Row['File'] == null)
    424430      {
    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()'));
    427432        $FileId = $this->Database->insert_id;
    428433      } else $FileId = $Row['File'];
     
    432437      $Bill->System = &$this->System;
    433438      $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;
    435440      $Bill->SaveToFile($FullFileName);
    436441      if (file_exists($FullFileName))
     
    446451  function GenerateOperation($Where)
    447452  {
     453    $DirectoryId = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->DirectoryId;
    448454    $Output = '';
    449455    $DbResult = $this->Database->query('SELECT * FROM `FinanceOperation` WHERE (`BillCode` <> "") '.
     
    454460      {
    455461        $DbResult2 = $this->Database->insert('File', array('Name' => '', 'Size' => 0,
    456           'Directory' => $this->System->Modules['Finance']->DirectoryId, 'Time' => 'NOW()'));
     462          'Directory' => $DirectoryId, 'Time' => 'NOW()'));
    457463        $FileId = $this->Database->insert_id;
    458464      } else $FileId = $Row['File'];
     
    462468      $Bill->System = &$this->System;
    463469      $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;
    465471      $Bill->SaveToFile($FullFileName);
    466472      if (file_exists($FullFileName))
Note: See TracChangeset for help on using the changeset viewer.