1 | <?php
|
---|
2 |
|
---|
3 | include('FioAPI.php');
|
---|
4 |
|
---|
5 | class 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 | }
|
---|