Changeset 738 for trunk/Modules/FinanceBankAPI/FileImport.php
- Timestamp:
- Apr 14, 2015, 10:20:16 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/FinanceBankAPI/FileImport.php
r719 r738 8 8 var $Database; 9 9 var $BankAccount; 10 10 11 11 function __construct($System) 12 12 { … … 14 14 $this->System = &$System; 15 15 } 16 16 17 17 function Import() 18 18 { 19 19 } 20 20 21 21 function ImportFile($Content, $Ext) 22 { 22 { 23 23 } 24 24 25 25 function PairOperations() 26 26 { … … 32 32 $DbResult2 = $this->Database->select('Subject', 'Id', 'Id='.$DbRow['VariableSymbol']); 33 33 if($DbResult2->num_rows == 1) 34 { 34 { 35 35 $DbRow2 = $DbResult2->fetch_assoc(); 36 // TODO: Replace constants by links to real database numbers 36 // TODO: Replace constants by links to real database numbers 37 37 if($DbRow['Value'] >= 0) { 38 39 $Direction = 1;38 $DocumentLine = 3; // Receive money 39 $Direction = 1; 40 40 } else { 41 42 41 $DocumentLine = 4; // Send money 42 $Direction = -1; 43 43 } 44 44 $Year = date('Y', MysqlDateToTime($DbRow['Time'])); 45 45 $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumber($DocumentLine, $Year); 46 $DbResult3 = $this->Database->insert('FinanceOperation', array('Subject' => $DbRow2['Id'], 'Cash' => 0, 46 $DbResult3 = $this->Database->insert('FinanceOperation', array('Subject' => $DbRow2['Id'], 'Cash' => 0, 47 47 'Value' => Abs($DbRow['Value']), 'Direction' => $Direction, 'Taxable' => 1, 'BankAccount' => $DbRow['BankAccount'], 'Network' => 1, 48 48 'Time' => $DbRow['Time'], 'Text' => $DbRow['Description'], 'BillCode' => $BillCode, 'DocumentLine' => $DocumentLine)); … … 61 61 62 62 function Show() 63 { 63 { 64 64 $Output = ''; 65 65 if(!$this->System->User->CheckPermission('Finance', 'SubjectList')) return('Nemáte oprávnění'); 66 66 67 67 $DbResult = $this->Database->select('FinanceBankAccount', '*', 'Id='.$_GET['i']); 68 68 $BankAccount = $DbResult->fetch_assoc(); 69 69 70 70 $DbResult = $this->Database->select('FinanceBank', '*', 'Id='.$BankAccount['Bank']); 71 71 $Bank = $DbResult->fetch_assoc(); 72 72 $Output .= 'Účet: '.$BankAccount['Number'].'/'.$Bank['Code'].' ('.$Bank['Name'].')'; 73 73 74 74 if($Bank['Code'] == '2010') $Import = new ImportFio($this->System); 75 75 else if($Bank['Code'] == '0300') $Import = new ImportPS($this->System); … … 80 80 $Output .= $Import->Import(); 81 81 $Import->PairOperations(); 82 } 82 } 83 83 return($Output); 84 84 } 85 85 } 86 86 87 87 class PageImportFile extends Page 88 88 { … … 90 90 var $ShortTitle = 'Import plateb ze souboru'; 91 91 var $ParentClass = 'PageFinance'; 92 92 93 93 function Show() 94 94 { … … 103 103 return($Output); 104 104 } 105 105 106 106 function ShowForm() 107 107 { … … 113 113 return($Output); 114 114 } 115 115 116 116 function Prepare() 117 { 117 { 118 118 $Form = new Form($this->System->FormManager); 119 119 $Form->SetClass('ImportBankFile'); … … 125 125 $DbResult = $this->Database->select('FinanceBankAccount', '*', 'Id='.$Form->Values['BankAccount']); 126 126 $BankAccount = $DbResult->fetch_assoc(); 127 127 128 128 $DbResult = $this->Database->select('FinanceBank', '*', 'Id='.$BankAccount['Bank']); 129 129 $Bank = $DbResult->fetch_assoc(); 130 130 $Output .= 'Účet: '.$BankAccount['Number'].'/'.$Bank['Code'].' ('.$Bank['Name'].')'; 131 131 132 132 if($Bank['Code'] == '2010') $Import = new ImportFio($this->System); 133 133 else if($Bank['Code'] == '0300') $Import = new ImportPS($this->System); … … 135 135 $Import->BankAccount = $BankAccount; 136 136 $Output .= $Import->ImportFile($File->GetContent(), $File->GetExt()); 137 137 138 138 return($Output); 139 139 } 140 140 141 141 function InsertMoney($Subject, $Value, $Direction, $Cash, $Taxable, $Time, $Text, $DocumentLine) 142 142 { 143 $Year = date('Y', $Time); 143 $Year = date('Y', $Time); 144 144 $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumber($DocumentLine, $Year); 145 $this->Database->insert('FinanceOperation', array('Text' => $Text, 146 147 145 $this->Database->insert('FinanceOperation', array('Text' => $Text, 146 'Subject' => $Subject, 'Cash' => $Cash, 'Value' => $Value, 'Direction' => $Direction, 147 'Time' => TimeToMysqlDateTime($Time), 'Taxable' => $Taxable, 'BillCode' => $BillCode)); 148 148 } 149 149 … … 152 152 $Finance = $this->System->Modules['Finance']; 153 153 $Output = ''; 154 154 155 155 for($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--) 156 156 { 157 157 // TODO: Use links to database records instead of contants 158 158 if($_POST['Money'.$I] < 0) { 159 160 159 $DocumentLine = 4; 160 $Direction = -1; 161 161 } else { 162 163 162 $DocumentLine = 3; 163 $Direction = 1; 164 164 } 165 165 $Date = explode('-', $_POST['Date'.$I]); 166 166 $Date = mktime(0, 0, 0, $Date[1], $Date[2], $Date[0]); 167 167 $this->InsertMoney($_POST['Subject'.$I], Abs($_POST['Money'.$I]), $Direction, 0, $_POST['Taxable'.$I], $Date, $_POST['Text'.$I], $DocumentLine);
Note:
See TracChangeset
for help on using the changeset viewer.