Changeset 550 for trunk/Modules/FinanceBankAPI/ImportFio.php
- Timestamp:
- Jul 7, 2013, 7:37:48 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/FinanceBankAPI/ImportFio.php
r548 r550 3 3 include('FioAPI.php'); 4 4 5 class ImportFio extends FileImport5 class ImportFio extends BankImport 6 6 { 7 7 function Import() 8 { 9 $DbResult = $this->Database->select('FinanceBankAccount', '*', 'Id='.$this->BankAccountId); 10 $BankAccount = $DbResult->fetch_assoc(); 11 8 { 12 9 $Fio = new FioAPI(); 13 $Fio->Token = $BankAccount['LoginName']; 14 $Records = $Fio->Import(time() - 3600 * 24 * 31 * 2, time()); 15 foreach($Records as $Record) 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 print_r($Records); 16 //die(); 17 $Output = '<table>'; 18 //$Output .= '<tr>'; 19 //$Output .= '<td>Jméno účtu: '.$Records['AccountName'].'</td>'; 20 //$Output .= '<td>Číslo účtu: '.$Records['AccountNumber'].'</td>'; 21 //$Output .= '<td>Ke dni '.date('j.n.Y', $Records['DateStart']).' je stav účtu '.$Records['OpeningBalance'].' Kč</td>'; 22 //$Output .= '<td>Ke dni '.date('j.n.Y', $Records['DateEnd']).' je stav účtu '.$Records['ClosingBalance'].' Kč</td>'; 23 //$Output .= '<td>Suma příjmů: '.$Records['CreditValue'].' Kč</td>'; 24 //$Output .= '<td>Suma výdajů: '.$Records['DebitValue'].' Kč</td>'; 25 //$Output .= '</tr>'; 26 foreach($Records['Items'] as $Record) 16 27 { 17 echo('<tr>'); 18 if($Record['Type'] == GPC_TYPE_REPORT) 19 { 20 echo('<td>Jméno účtu: '.$Record['AccountName'].'</td>'); 21 echo('<td>Číslo účtu: '.$Record['AccountNumber'].'</td>'); 22 echo('<td>Ke dni '.date('j.n.Y', $Record['OldBalanceDate']).' je stav účtu '.$Record['OldBalanceValue'].' Kč</td>'); 23 echo('<td>Ke dni '.date('j.n.Y', $Record['Date']).' je stav účtu '.$Record['NewBalanceValue'].' Kč</td>'); 24 echo('<td>Suma příjmů: '.$Record['CreditValue'].' Kč</td>'); 25 echo('<td>Suma výdajů: '.$Record['DebitValue'].' Kč</td>'); 26 } else 27 if($Record['Type'] == GPC_TYPE_ITEM) 28 { 29 $this->Database->insert('FinanceBankImport', array('Time' => TimeToMysqlDate($Record['DueDate']), 30 'BankAccount' => $this->BankAccount, 'Value' => $Record['Value'], 28 $DbResult = $this->Database->select('FinanceBankImport', 'ID', 'Identification='.$Record['ID']); 29 if($DbResult->num_rows == 0) 30 { 31 $Output .= '<tr>'; 32 $this->Database->insert('FinanceBankImport', array('Time' => TimeToMysqlDate($Record['Date']), 33 'BankAccount' => $this->BankAccount['Id'], 'Value' => $Record['Value'], 31 34 'SpecificSymbol' => $Record['SpecificSymbol'], 'VariableSymbol' => $Record['VariableSymbol'], 32 'ConstantSymbol' => $Record['ConstantSymbol'], 'Currency' => $this->Currency, 33 )); 34 echo('<td>'.$Record['OffsetAccount'].'</td>'); 35 echo('<td>'.$Record['BankCode'].'</td>'); 36 echo('<td>'.$Record['ClientName'].'</td>'); 35 'ConstantSymbol' => $Record['ConstantSymbol'], 'Currency' => $this->BankAccount['Currency'], 36 'Identification' => $Record['ID'], 'AccountNumber' => $Record['OffsetAccount'], 37 'BankCode' => $Record['BankCode'], 'Description' => $Record['Type'], 'OffsetAccountName' => $Record['UserIdent'])); 38 $Output .= '<td>'.$Record['OffsetAccount'].'</td>'; 39 $Output .= '<td>'.$Record['BankCode'].'</td>'; 40 $Output .= '<td>'.$Record['UserIdent'].'</td>'; 41 $Output .= '</tr>'; 37 42 } 38 43 } 44 $Output .= '</table>'; 45 $this->Database->Update('FinanceBankAccount', 'Id='.$this->BankAccount['Id'], array('LastImportDate' => TimeToMysqlDate($PeriodEnd))); 46 return($Output); 39 47 } 40 48 }
Note:
See TracChangeset
for help on using the changeset viewer.