Ignore:
Timestamp:
Nov 20, 2020, 12:08:12 AM (3 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/FinanceBankAPI/FileImport.php

    r884 r887  
    55class BankImport
    66{
    7   var $System;
    8   var $Database;
    9   var $BankAccount;
    10 
    11   function __construct($System)
     7  public System $System;
     8  public Database $Database;
     9  public int $BankAccount;
     10
     11  function __construct(System $System)
    1212  {
    1313    $this->Database = &$System->Database;
     
    1515  }
    1616
    17   function Import()
    18   {
     17  function Import(): string
     18  {
     19    return '';
    1920  }
    2021
     
    2324  }
    2425
    25   function PairOperations()
    26   {
     26  function PairOperations(): void
     27  {
     28    $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance;
    2729    $DbResult = $this->Database->select('FinanceBankImport', '*', 'FinanceOperation IS NULL');
    2830    while ($DbRow = $DbResult->fetch_assoc())
     
    3436        {
    3537          $DbRow2 = $DbResult2->fetch_assoc();
    36           if ($DbRow['Value'] >= 0) {
    37             $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_IN, 'FinanceOperationGroup');
    38           } else {
    39             $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup');
     38          if ($DbRow['Value'] >= 0)
     39          {
     40            $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_IN, 'FinanceOperationGroup');
     41          } else
     42          {
     43            $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup');
    4044          }
    4145          $Year = date('Y', MysqlDateToTime($DbRow['Time']));
    42           $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($FinanceGroup['DocumentLine'], $Year);
    43           $DbResult3 = $this->Database->insert('FinanceOperation', array('Subject' => $DbRow2['Id'], 'Cash' => 0,
     46          $BillCode = $Finance->GetNextDocumentLineNumberId($FinanceGroup['DocumentLine'], $Year);
     47          $this->Database->insert('FinanceOperation', array('Subject' => $DbRow2['Id'], 'Cash' => 0,
    4448            'ValueUser' => Abs($DbRow['Value']), 'Value' => 0, 'Taxable' => 1, 'BankAccount' => $DbRow['BankAccount'], 'Network' => 1,
    4549            'Time' => $DbRow['Time'], 'Text' => $DbRow['Description'], 'BillCode' => $BillCode, 'Group' => $FinanceGroup['Id']));
     
    6569class PageImportAPI extends Page
    6670{
    67   var $FullTitle = 'Import plateb přes API';
    68   var $ShortTitle = 'Import plateb přes API';
    69   var $ParentClass = 'PageFinance';
    70 
    71   function Import($Id)
     71  function __construct(System $System)
     72  {
     73    parent::__construct($System);
     74    $this->FullTitle = 'Import plateb přes API';
     75    $this->ShortTitle = 'Import plateb přes API';
     76    $this->ParentClass = 'PageFinance';
     77  }
     78
     79  function Import(int $Id): string
    7280  {
    7381    $Output = '';
     
    92100  }
    93101
    94   function Show()
    95   {
    96     if (!$this->System->User->CheckPermission('Finance', 'SubjectList'))
     102  function Show(): string
     103  {
     104    if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'SubjectList'))
    97105      return 'Nemáte oprávnění';
    98106
     
    104112class PageImportFile extends Page
    105113{
    106   var $FullTitle = 'Import plateb ze souboru';
    107   var $ShortTitle = 'Import plateb ze souboru';
    108   var $ParentClass = 'PageFinance';
    109 
    110   function Show()
     114  function __construct(System $System)
     115  {
     116    parent::__construct($System);
     117    $this->FullTitle = 'Import plateb ze souboru';
     118    $this->ShortTitle = 'Import plateb ze souboru';
     119    $this->ParentClass = 'PageFinance';
     120  }
     121
     122  function Show(): string
    111123  {
    112124    $Output = '';
    113     if (!$this->System->User->CheckPermission('Finance', 'SubjectList')) return 'Nemáte oprávnění';
     125    if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'SubjectList')) return 'Nemáte oprávnění';
    114126    if (array_key_exists('Operation', $_GET))
    115127    {
     
    121133  }
    122134
    123   function ShowForm()
     135  function ShowForm(): string
    124136  {
    125137    $Form = new Form($this->System->FormManager);
     
    156168  }
    157169
    158   function InsertMoney($Subject, $Value, $Cash, $Taxable, $Time, $Text, $Group)
     170  function InsertMoney($Subject, $Value, $Cash, $Taxable, $Time, $Text, $Group): void
    159171  {
    160172    $Year = date('Y', $Time);
    161     $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumberId(
     173    $BillCode = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->GetNextDocumentLineNumberId(
    162174      $Group['DocumentLine'], $Year);
    163175    $this->Database->insert('FinanceOperation', array('Text' => $Text,
     
    166178  }
    167179
    168   function Insert()
    169   {
    170     $Finance = $this->System->Modules['Finance'];
     180  function Insert(): string
     181  {
     182    $Finance = $ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance;
    171183    $Output = '';
    172184
    173185    for ($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--)
    174186    {
    175       if ($_POST['Money'.$I] >= 0) {
     187      if ($_POST['Money'.$I] >= 0)
     188      {
    176189        $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_IN,
    177190          'FinanceOperationGroup');
    178       } else {
     191      } else
     192      {
    179193        $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT,
    180194          'FinanceOperationGroup');
     
    185199        0, $_POST['Taxable'.$I], $Date, $_POST['Text'.$I], $FinanceGroup);
    186200      $Output .= $I.', ';
    187       $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'NewPaymentInserted');
     201      ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('Finance', 'NewPaymentInserted');
    188202    }
    189203    return $Output;
Note: See TracChangeset for help on using the changeset viewer.