source: trunk/Modules/FinanceBankAPI/ImportFio.php

Last change on this file was 887, checked in by chronos, 4 years ago
  • Added: Static types added to almost all classes, methods and function. Supported by PHP 7.4.
  • Fixed: Various found code issues.
File size: 2.4 KB
Line 
1<?php
2
3include('FioAPI.php');
4
5class ImportFio extends BankImport
6{
7 function Import(): string
8 {
9 $Fio = new FioAPI();
10 $Fio->Token = $this->BankAccount['LoginName'];
11 if ($this->BankAccount['LastImportDate'] == '') $PeriodStart = time();
12 else $PeriodStart = MysqlDateToTime($this->BankAccount['LastImportDate']);
13 $PeriodEnd = time();
14 $Records = $Fio->Import($PeriodStart, $PeriodEnd);
15 $Output = '<table>';
16 //$Output .= '<tr>';
17 //$Output .= '<td>Jméno účtu: '.$Records['AccountName'].'</td>';
18 //$Output .= '<td>Číslo účtu: '.$Records['AccountNumber'].'</td>';
19 //$Output .= '<td>Ke dni '.date('j.n.Y', $Records['DateStart']).' je stav účtu '.$Records['OpeningBalance'].' Kč</td>';
20 //$Output .= '<td>Ke dni '.date('j.n.Y', $Records['DateEnd']).' je stav účtu '.$Records['ClosingBalance'].' Kč</td>';
21 //$Output .= '<td>Suma příjmů: '.$Records['CreditValue'].' Kč</td>';
22 //$Output .= '<td>Suma výdajů: '.$Records['DebitValue'].' Kč</td>';
23 //$Output .= '</tr>';
24 foreach ($Records['Items'] as $Record)
25 {
26 $DbResult = $this->Database->select('FinanceBankImport', 'ID', 'Identification='.$Record['ID']);
27 if ($DbResult->num_rows == 0)
28 {
29 $Record['Value'] = str_replace(",", ".", $Record['Value']);
30 $Output .= '<tr>';
31 $this->Database->insert('FinanceBankImport', array('Time' => TimeToMysqlDate($Record['Date']),
32 'BankAccount' => $this->BankAccount['Id'], 'Value' => $Record['Value'],
33 'SpecificSymbol' => $Record['SpecificSymbol'], 'VariableSymbol' => $Record['VariableSymbol'],
34 'ConstantSymbol' => $Record['ConstantSymbol'], 'Currency' => $this->BankAccount['Currency'],
35 'Identification' => $Record['ID'], 'AccountNumber' => $Record['OffsetAccount'],
36 'BankCode' => $Record['BankCode'], 'Description' => $Record['Type'], 'OffsetAccountName' => $Record['UserIdent']));
37 $Output .= '<td>'.$Record['OffsetAccount'].'</td>';
38 $Output .= '<td>'.$Record['BankCode'].'</td>';
39 $Output .= '<td>'.$Record['UserIdent'].'</td>';
40 $Output .= '<td>'.$Record['Value'].'</td>';
41 $Output .= '</tr>'."\n";
42 }
43 }
44 $Output .= '</table>';
45 $this->Database->update('FinanceBankAccount', 'Id='.$this->BankAccount['Id'],
46 array('LastImportDate' => TimeToMysqlDate($PeriodEnd)));
47 return $Output;
48 }
49}
Note: See TracBrowser for help on using the repository browser.