Changeset 916


Ignore:
Timestamp:
Dec 7, 2021, 11:08:42 PM (2 years ago)
Author:
chronos
Message:
  • Added: Allow to switch Mail class into test mode.
  • Modified: Type checking related changes.
  • Modified: Replace global $Config references with $this->System->Config is possible.
Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Contract/Contract.php

    r912 r916  
    2121  function DoStart(): void
    2222  {
    23     global $Config;
    24 
    25     $this->DirectoryId = $Config['Contract']['DirectoryId'];
     23    $this->DirectoryId = $this->System->Config['Contract']['DirectoryId'];
    2624    $this->System->RegisterPage(['smlouvy', 'generovat'], 'PageContractGenerate');
    2725    $this->System->FormManager->RegisterClass('Contract', array(
  • trunk/Modules/Finance/Bill.php

    r901 r916  
    1616      $Subject['AddressStreet'].'<br>'.
    1717      $Subject['AddressPSC'].' '.$Subject['AddressTown'].'<br>';
    18     if ($Subject['IC'] != 0) $Output .= 'IČ: '.$Subject['IC'].'<br>';
     18    if (($Subject['IC'] != '') and ($Subject['IC'] != 0)) $Output .= 'IČ: '.$Subject['IC'].'<br>';
    1919    if ($Subject['DIC'] != '') $Output .= 'DIČ: '.$Subject['DIC'].'<br>';
    2020    if ($Subject['Account'] != '') $Output .= 'Účet: '.$Subject['Account'].'<br>';
  • trunk/Modules/Finance/Finance.php

    r910 r916  
    3636  function DoStart(): void
    3737  {
    38     global $Config;
    39 
    4038    $this->System->RegisterPage(['finance', 'sprava'], 'PageFinanceManage');
    4139    $this->System->RegisterPage(['finance', 'platby'], 'PageFinanceUserState');
     
    162160        'Value' => array('Type' => 'Integer', 'Caption' => 'Částka absolutní', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true),
    163161        'ValueUser' => array('Type' => 'Integer', 'Caption' => 'Částka', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
    164           'SQL' => 'SELECT ROUND(SUM(`Price`*`Quantity`), '.$Config['Finance']['Rounding'].') FROM `FinanceInvoiceItem` WHERE `FinanceInvoiceItem`.`FinanceInvoice`=#Id'),
     162          'SQL' => 'SELECT ROUND(SUM(`Price`*`Quantity`), '.$this->System->Config['Finance']['Rounding'].') FROM `FinanceInvoiceItem` WHERE `FinanceInvoiceItem`.`FinanceInvoice`=#Id'),
    165163        'File' => array('Type' => 'TFile', 'Caption' => 'Doklad', 'Default' => '', 'Null' => true),
    166164        'Generate' => array('Type' => 'Boolean', 'Caption' => 'Generovat', 'Default' => ''),
     
    244242        'VAT' => array('Type' => 'Integer', 'Caption' => 'Daň', 'Default' => '21', 'Suffix' => '%'),
    245243        'Total' => array('Type' => 'Integer', 'Caption' => 'Celkem', 'Default' => '', 'Suffix' => 'Kč',
    246           'ReadOnly' => true, 'SQL' => 'ROUND(`Price` * `Quantity`, '.$Config['Finance']['Rounding'].')'),
     244          'ReadOnly' => true, 'SQL' => 'ROUND(`Price` * `Quantity`, '.$this->System->Config['Finance']['Rounding'].')'),
    247245      ),
    248246      'AfterInsert' => array($this, 'AfterInsertFinanceInvoiceItem'),
     
    259257        'State' => array('Type' => 'Float', 'Caption' => 'Stav', 'Default' => '',
    260258          'ReadOnly' => true, 'Suffix' => 'Kč', 'SQL' => 'IFNULL(ROUND((SELECT SUM(`FinanceOperation`.`Value`) FROM `FinanceOperation` '.
    261           'WHERE `FinanceOperation`.`Treasury`=#Id), '.$Config['Finance']['Rounding'].'), 0)'),
     259          'WHERE `FinanceOperation`.`Treasury`=#Id), '.$this->System->Config['Finance']['Rounding'].'), 0)'),
    262260        'Operations' => array('Type' => 'TFinanceOperationListTreasury', 'Caption' => 'Operace', 'Default' => ''),
    263261        'Check' => array('Type' => 'TFinanceTreasuryCheckListTreasury', 'Caption' => 'Kontrola', 'Default' => ''),
     
    568566    ));
    569567
    570     $this->Finance->MainSubject = $Config['Finance']['MainSubjectId'];
    571     $this->Finance->DirectoryId = $Config['Finance']['DirectoryId'];
     568    $this->Finance->MainSubject = $this->System->Config['Finance']['MainSubjectId'];
     569    $this->Finance->DirectoryId = $this->System->Config['Finance']['DirectoryId'];
    572570
    573571    ModuleIS::Cast($this->System->GetModule('IS'))->RegisterDashboardItem('Finance', array($this, 'ShowDashboardItem'));
  • trunk/Modules/Finance/Manage.php

    r912 r916  
    4949
    5050  /* Get first day and last day of given billing period. Periods are aligned with year start/end. */
    51   function GetBillingPeriod($Period)
     51  function GetBillingPeriod(int $Period): array
    5252  {
    5353    $Time = time();
     
    7373  }
    7474
    75   function ShowMonthlyPayment()
     75  function ShowMonthlyPayment(): string
    7676  {
    7777    if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'Manage')) return 'Nemáte oprávnění';
     
    126126  }
    127127
    128   function InsertInvoice($Subject, $TimeCreation, $TimeDue, $Items,
    129     $Group, $PeriodFrom, $PeriodTo)
     128  function InsertInvoice(string $Subject, string $TimeCreation, string $TimeDue, array $Items,
     129    array $Group, float $PeriodFrom, float $PeriodTo): string
    130130  {
    131131    global $LastInsertTime;
     
    156156  }
    157157
    158   function ProduceInvoices()
     158  function ProduceInvoices(): string
    159159  {
    160160    $Output = '';
     
    224224  }
    225225
    226   function TableUpdateChanges($Table)
     226  function TableUpdateChanges(string $Table): void
    227227  {
    228228    $Time = time();
     
    256256  }
    257257
    258   function ProcessTableUpdates()
     258  function ProcessTableUpdates(): string
    259259  {
    260260    // Update customers
     
    277277  }
    278278
    279   function ProcessMonthlyPayment()
     279  function ProcessMonthlyPayment(): string
    280280  {
    281281    if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'Manage')) return 'Nemáte oprávnění';
     
    344344  }
    345345
    346   function SendPaymentEmail($MemberId, $FileId = '')
     346  function SendPaymentEmail(string $MemberId, string $FileId = ''): string
    347347  {
    348348    global $Config;
     
    418418  }
    419419
    420   function GenerateInvoice($Where)
     420  function GenerateInvoice(string $Where): string
    421421  {
    422422    $DirectoryId = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->DirectoryId;
     
    447447  }
    448448
    449   function GenerateOperation($Where)
     449  function GenerateOperation(string $Where): string
    450450  {
    451451    $DirectoryId = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->DirectoryId;
     
    476476  }
    477477
    478   function GenerateBills()
     478  function GenerateBills(): string
    479479  {
    480480    $Output = '';
  • trunk/Modules/Network/UserHosts.php

    r912 r916  
    1212  function Show(): string
    1313  {
    14     global $Config;
    15 
    1614    if (ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'] == '') return $this->SystemMessage('Nepovolený přístup', 'Nemáte oprávnění pro tuto operaci');
    1715    $Output = '<div align="center" style="font-size: small;"><table class="WideTable">';
  • trunk/Modules/Stock/Stock.php

    r901 r916  
    2020  function DoStart(): void
    2121  {
    22     global $Config;
    23 
    2422    $this->System->FormManager->RegisterClass('Product', array(
    2523      'Title' => 'Produkty',
     
    114112        'Amount' => array('Type' => 'Integer', 'Caption' => 'Množství', 'Default' => '1'),
    115113        'Total' => array('Type' => 'Integer', 'Caption' => 'Celkem', 'Default' => '', 'Suffix' => 'Kč',
    116           'ReadOnly' => true, 'SQL' => 'ROUND(`UnitPrice` * `Amount`, '.$Config['Finance']['Rounding'].')'),
     114          'ReadOnly' => true, 'SQL' => 'ROUND(`UnitPrice` * `Amount`, '.$this->System->Config['Finance']['Rounding'].')'),
    117115        'Položky pohybů' => array('Type' => 'TStockMoveItemSerialListItem', 'Caption' => 'Vztahy sériových čísel', 'Default' => ''),
    118116        'Sériové čísla' => array('Type' => 'String', 'Caption' => 'Sériové čísla', 'ReadOnly' => true,
  • trunk/Modules/User/User.php

    r914 r916  
    2525  }
    2626
    27   function DoInstall(): void
    28   {
    29   }
    30 
    3127  function DoInsertSampleData(): void
    3228  {
  • trunk/Modules/User/UserModel.php

    r908 r916  
    4545}
    4646
    47 // TODO: Make User class more general without dependencies to System, Mail, Log
     47// TODO: Make User class more general without dependencies on System, Mail, Log
    4848
    4949class User extends Model
     
    418418        $Row['Id'].'&H='.$Row['Password'].'&P='.$NewPassword.'">tento odkaz</a>.'."\n<br />".
    419419        "Po přihlášení si prosím změňte heslo na nové.\n\n<br><br>Na tento email neodpovídejte.", 'text/html');
     420      print_r($Mail);
    420421      $Mail->Send();
    421422
  • trunk/Modules/WebCam/WebCam.php

    r912 r916  
    6969 function ShowImage(): string
    7070  {
    71     global $Config;
    7271    $Output = '';
    7372    $Output .= '<a href="//www.zdechov.net/kamery/?Id=5"><img alt="Koupaliště" width="140" height="79" src="//www.zdechov.net/images/webcam/webcam5.jpg" /></a>';
  • trunk/Packages/Common/Mail.php

    r887 r916  
    2020  private array $Priorities;
    2121  private string $Boundary;
     22  public bool $TestMode;
    2223
    2324  function __construct()
     
    2627    $this->Boundary = md5(date('r', time()));
    2728    $this->AgentIdent = 'PHP/Mail';
     29    $this->TestMode = false;
    2830    $this->Clear();
    2931  }
     
    145147    if ($this->Subject == '') throw new Exception(T('Mail message missing Subject'));
    146148
    147     $res = mail($To, $this->Subject, $Body, $Headers);
     149    if ($this->TestMode)
     150    {
     151      echo('to: '.$To.', subject: '.$this->Subject.', body: '.$Body.', headers: '.$Headers);
     152      $res = true;
     153    } else
     154    {
     155      $res = mail($To, $this->Subject, $Body, $Headers);
     156    }
    148157    return $res;
    149158  }
Note: See TracChangeset for help on using the changeset viewer.