Changeset 887 for trunk/Modules/Finance


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.
Location:
trunk/Modules/Finance
Files:
6 edited

Legend:

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

    r874 r887  
    33class Bill extends Model
    44{
    5   var $SpecificSymbol = 1; // počítačová sít
    6   var $Checked;
     5  public int $SpecificSymbol = 1; // computer network number
     6  public bool $Checked = false;
    77
    88  function GenerateHTML()
     
    1111  }
    1212
    13   function SaveToFile($FileName)
    14   {
    15     global $Database;
    16 
     13  function SaveToFile(string $FileName)
     14  {
    1715    $PdfData = $this->HtmlToPdf($this->GenerateHTML());
    1816    file_put_contents($FileName, $PdfData);
    1917  }
    2018
    21   function HtmlToPdf($HtmlCode)
     19  function HtmlToPdf(string $HtmlCode): string
    2220  {
    2321    $Encoding = new Encoding();
     
    3533class BillInvoice extends Bill
    3634{
    37   var $InvoiceId;
    38 
    39   function ShowSubjectInfo($Subject)
     35  public string $InvoiceId;
     36
     37  function ShowSubjectInfo(array $Subject): string
    4038  {
    4139    $BooleanText = array('Ne', 'Ano');
     
    5048  }
    5149
    52   function GenerateHTML()
    53   {
    54     $Finance = &$this->System->Modules['Finance'];
     50  function GenerateHTML(): string
     51  {
     52    $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance;
    5553    $Finance->LoadMonthParameters(0);
    5654
     
    152150class BillOperation extends Bill
    153151{
    154   var $OperationId;
    155 
    156   function GenerateHTML()
     152  public string $OperationId;
     153
     154  function GenerateHTML(): string
    157155  {
    158156    $DbResult = $this->Database->query('SELECT `FinanceOperation`.*, `FinanceOperationGroup`.`Direction`, `DocumentLineCode`.`Name` AS `BillName` FROM `FinanceOperation` '.
  • trunk/Modules/Finance/Finance.php

    r877 r887  
    4141  var $Rounding;
    4242
    43   function LoadMonthParameters($Period = 1) // 0 - now, 1 - next month
     43  function LoadMonthParameters(int $Period = 1) // 0 - now, 1 - next month
    4444  {
    4545    $DbResult = $this->Database->query('SELECT * FROM `FinanceBillingPeriod`');
     
    7878  }
    7979
    80   function W2Kc($Spotreba)
     80  function W2Kc($Spotreba): string
    8181  {
    8282    return round($Spotreba * 0.72 * $this->kWh);
     
    8888    $EndTime = mktime(0, 0, 0, 12, 31, $Year);
    8989    $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;
    9292
    9393    // Create DocumentLineSequence from previous
     
    9595    while ($DbRow = $DbResult->fetch_assoc())
    9696    {
    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)
    103103  {
    104104    if ($Year == 0)
     
    107107      $DbResult = $this->Database->select('FinanceYear', '*', '1 ORDER BY `Year` DESC LIMIT 1');
    108108    } 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);
    113114        $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          }
    116117    $FinanceYear = $DbResult->fetch_assoc();
    117118    if ($FinanceYear['Closed'] == 1)
     
    120121  }
    121122
    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);
    125126
    126127    $DbResult = $this->Database->query('SELECT `Shortcut`, `Id` FROM `DocumentLine` WHERE `Id`='.$Id);
     
    141142  }
    142143
    143   function GetNextDocumentLineNumberId($Id, $FinanceYear = 0)
     144  function GetNextDocumentLineNumberId(string $Id, int $FinanceYear = 0): int
    144145  {
    145146    $Code = $this->GetNextDocumentLineNumber($Id, $FinanceYear);
     
    148149  }
    149150
    150   function GetFinanceGroupById($Id, $Table)
     151  function GetFinanceGroupById(string $Id, string $Table): ?array
    151152  {
    152153    $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE `Id`= '.$Id);
     
    154155      $Group = $DbResult->fetch_assoc();
    155156      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
    160163  {
    161164    $Output = 'Aktualizuji finance členů...<br />';
     
    199202      $Consumption = 0;
    200203      $this->Database->insert('MemberPayment', array('Member' => $Member['Id'],
    201           'MonthlyInternet' => $MonthlyInet,
    202           'MonthlyTotal' => $Monthly, 'MonthlyConsumption' => $this->W2Kc($Consumption),
    203           'Cash' => $Cash, 'MonthlyPlus' => $this->W2Kc($ConsumptionPlus)));
     204        'MonthlyInternet' => $MonthlyInet,
     205        'MonthlyTotal' => $Monthly, 'MonthlyConsumption' => $this->W2Kc($Consumption),
     206        'Cash' => $Cash, 'MonthlyPlus' => $this->W2Kc($ConsumptionPlus)));
    204207    }
    205     $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'RecalculateMemberPayment');
     208    ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('Finance', 'RecalculateMemberPayment');
    206209    return $Output;
    207210  }
    208211
    209   function GetVATByType($TypeId)
     212  function GetVATByType(string $TypeId): string
    210213  {
    211214    $Time = time();
     
    220223class ModuleFinance extends AppModule
    221224{
    222   function __construct($System)
     225  public Finance $Finance;
     226  public Bill $Bill;
     227
     228  function __construct(System $System)
    223229  {
    224230    parent::__construct($System);
     
    229235    $this->Description = 'Base module for finance management';
    230236    $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
    242251  {
    243252    global $Config;
    244253
    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');
    249258
    250259    $this->System->FormManager->RegisterClass('FinanceOperation', array(
     
    644653    ));
    645654
    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
    657662  {
    658663    $DbResult = $this->Database->select('FinanceOperation', 'ROUND(SUM(`Value`))', '1');
     
    662667  }
    663668
    664   function DoStop()
    665   {
    666   }
    667 
    668   function BeforeInsertFinanceOperation($Form)
     669  function DoStop(): void
     670  {
     671  }
     672
     673  function BeforeInsertFinanceOperation(Form $Form): array
    669674  {
    670675    if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);
    671676      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');
    680685    $this->Database->query('UPDATE `'.$Form->Definition['Table'].'` SET `Value`= '.
    681686      ($Form->Values['ValueUser'] * $FinanceGroup['ValueSign']).' WHERE `Id`='.$Id);
     
    683688  }
    684689
    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');
    688693    $this->Database->query('UPDATE `'.$Form->Definition['Table'].'` SET `Value`= '.
    689694      ($Form->Values['ValueUser'] * $FinanceGroup['ValueSign']).' WHERE `Id`='.$Id);
     
    691696  }
    692697
    693   function BeforeInsertFinanceInvoice($Form)
     698  function BeforeInsertFinanceInvoice(Form $Form): array
    694699  {
    695700    // Get new DocumentLineCode by selected invoice Group
    696701    if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);
    697702      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');
    706711    $DbResult = $this->Database->query(str_replace('#Id', $Id, $Form->Definition['Items']['ValueUser']['SQL']));
    707712    $DbRow = $DbResult->fetch_row();
     
    713718  }
    714719
    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');
    718723    $DbResult = $this->Database->query(str_replace('#Id', $Id, $Form->Definition['Items']['ValueUser']['SQL']));
    719724    $DbRow = $DbResult->fetch_row();
     
    724729  }
    725730
    726   function AfterInsertFinanceInvoiceItem($Form, $Id)
     731  function AfterInsertFinanceInvoiceItem(Form $Form, string $Id): array
    727732  {
    728733    $ParentForm = new Form($this->System->FormManager);
     
    733738  }
    734739
    735   function AfterModifyFinanceInvoiceItem($Form, $Id)
     740  function AfterModifyFinanceInvoiceItem(Form $Form, string $Id): array
    736741  {
    737742    $ParentForm = new Form($this->System->FormManager);
     
    742747  }
    743748
    744   function BeforeInsertContract($Form)
     749  function BeforeInsertContract(Form $Form): array
    745750  {
    746751    if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);
    747752      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));
    750764  }
    751765}
  • trunk/Modules/Finance/Import.php

    r874 r887  
    33class PageFinanceImportPayment extends Page
    44{
    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  }
    812
    9   function Show()
     13  function Show(): string
    1014  {
    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í';
    1216    if (array_key_exists('Operation', $_GET))
    1317    {
     
    2630  }
    2731
    28   function Prepare()
     32  function Prepare(): string
    2933  {
    30     $Finance = $this->System->Modules['Finance'];
     34    $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance;
    3135    $Finance->LoadMonthParameters(0);
    3236    $Data = explode("\n", $_POST['Source']);
     
    124128  }
    125129
    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)
    127131  {
    128132    $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);
    130134    // TODO: Fixed BankAccount=1, allow to select bank account for import
    131135    $this->Database->insert('FinanceOperation', array('Text' => $Text,
     
    136140  }
    137141
    138   function Insert()
     142  function Insert(): string
    139143  {
    140     $Finance = $this->System->Modules['Finance'];
     144    $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance;
    141145    $Finance->LoadMonthParameters(0);
    142146    $Output = '';
     
    144148    for ($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--)
    145149    {
    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');
    150156      }
    151157      $Date = explode('-', $_POST['Date'.$I]);
     
    154160        0, $_POST['Taxable'.$I], $Date, $_POST['Text'.$I], $FinanceGroup);
    155161      $Output .= $I.', ';
    156       $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'NewPaymentInserted');
     162      ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('Finance', 'NewPaymentInserted');
    157163    }
    158164    return $Output;
  • 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))
  • trunk/Modules/Finance/Trade.php

    r874 r887  
    33class PageFinanceTaxFiling extends Page
    44{
    5   var $FullTitle = 'Daňová evidence';
    6   var $ShortTitle = 'Daňová evidence';
    7   var $ParentClass = 'PageFinance';
    85  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  }
    914
    1015  function GetTimePeriodBalance($StartTime, $EndTime)
     
    340345  function ShowSubjectAccount()
    341346  {
     347    $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance;
     348
    342349    $Output = '<table style="width: 100%"><tr><td style="vertical-align: top;">';
    343350    $Output .= '<strong>Výpis příjmů/výdajů</strong>';
     
    424431  }
    425432
    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'))
    429436      return 'Nemáte oprávnění';
    430 
    431     $Finance = &$this->System->Modules['Finance'];
    432437
    433438    $Output = '';
  • trunk/Modules/Finance/UserState.php

    r874 r887  
    33class PageFinanceUserState extends Page
    44{
    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  }
    812
    913  function ShowFinanceOperation($Subject)
     
    6973  }
    7074
    71   function Show()
     75  function Show(): string
    7276  {
    73     $Finance = &$this->System->Modules['Finance'];
     77    $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance;
    7478    $Finance->LoadMonthParameters(0);
    7579
     
    7781    if (array_key_exists('i', $_GET))
    7882    {
    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í';
    8084      $CustomerId = $_GET['i'];
    8185    } else
    8286    {
    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'];
    8589      $DbResult = $this->Database->query('SELECT `Customer` FROM `UserCustomerRel` WHERE `User`='.$UserId.' LIMIT 1');
    8690      if ($DbResult->num_rows > 0)
Note: See TracChangeset for help on using the changeset viewer.