Changeset 887 for trunk/Modules/FinanceBankAPI/FileImport.php
- Timestamp:
- Nov 20, 2020, 12:08:12 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/FinanceBankAPI/FileImport.php
r884 r887 5 5 class BankImport 6 6 { 7 var$System;8 var$Database;9 var$BankAccount;10 11 function __construct( $System)7 public System $System; 8 public Database $Database; 9 public int $BankAccount; 10 11 function __construct(System $System) 12 12 { 13 13 $this->Database = &$System->Database; … … 15 15 } 16 16 17 function Import() 18 { 17 function Import(): string 18 { 19 return ''; 19 20 } 20 21 … … 23 24 } 24 25 25 function PairOperations() 26 { 26 function PairOperations(): void 27 { 28 $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance; 27 29 $DbResult = $this->Database->select('FinanceBankImport', '*', 'FinanceOperation IS NULL'); 28 30 while ($DbRow = $DbResult->fetch_assoc()) … … 34 36 { 35 37 $DbRow2 = $DbResult2->fetch_assoc(); 36 if ($DbRow['Value'] >= 0) { 37 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_IN, 'FinanceOperationGroup'); 38 } else { 39 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup'); 38 if ($DbRow['Value'] >= 0) 39 { 40 $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_IN, 'FinanceOperationGroup'); 41 } else 42 { 43 $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup'); 40 44 } 41 45 $Year = date('Y', MysqlDateToTime($DbRow['Time'])); 42 $BillCode = $ this->System->Modules['Finance']->GetNextDocumentLineNumberId($FinanceGroup['DocumentLine'], $Year);43 $ DbResult3 = $this->Database->insert('FinanceOperation', array('Subject' => $DbRow2['Id'], 'Cash' => 0,46 $BillCode = $Finance->GetNextDocumentLineNumberId($FinanceGroup['DocumentLine'], $Year); 47 $this->Database->insert('FinanceOperation', array('Subject' => $DbRow2['Id'], 'Cash' => 0, 44 48 'ValueUser' => Abs($DbRow['Value']), 'Value' => 0, 'Taxable' => 1, 'BankAccount' => $DbRow['BankAccount'], 'Network' => 1, 45 49 'Time' => $DbRow['Time'], 'Text' => $DbRow['Description'], 'BillCode' => $BillCode, 'Group' => $FinanceGroup['Id'])); … … 65 69 class PageImportAPI extends Page 66 70 { 67 var $FullTitle = 'Import plateb přes API'; 68 var $ShortTitle = 'Import plateb přes API'; 69 var $ParentClass = 'PageFinance'; 70 71 function Import($Id) 71 function __construct(System $System) 72 { 73 parent::__construct($System); 74 $this->FullTitle = 'Import plateb přes API'; 75 $this->ShortTitle = 'Import plateb přes API'; 76 $this->ParentClass = 'PageFinance'; 77 } 78 79 function Import(int $Id): string 72 80 { 73 81 $Output = ''; … … 92 100 } 93 101 94 function Show() 95 { 96 if (! $this->System->User->CheckPermission('Finance', 'SubjectList'))102 function Show(): string 103 { 104 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'SubjectList')) 97 105 return 'Nemáte oprávnění'; 98 106 … … 104 112 class PageImportFile extends Page 105 113 { 106 var $FullTitle = 'Import plateb ze souboru'; 107 var $ShortTitle = 'Import plateb ze souboru'; 108 var $ParentClass = 'PageFinance'; 109 110 function Show() 114 function __construct(System $System) 115 { 116 parent::__construct($System); 117 $this->FullTitle = 'Import plateb ze souboru'; 118 $this->ShortTitle = 'Import plateb ze souboru'; 119 $this->ParentClass = 'PageFinance'; 120 } 121 122 function Show(): string 111 123 { 112 124 $Output = ''; 113 if (! $this->System->User->CheckPermission('Finance', 'SubjectList')) return 'Nemáte oprávnění';125 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'SubjectList')) return 'Nemáte oprávnění'; 114 126 if (array_key_exists('Operation', $_GET)) 115 127 { … … 121 133 } 122 134 123 function ShowForm() 135 function ShowForm(): string 124 136 { 125 137 $Form = new Form($this->System->FormManager); … … 156 168 } 157 169 158 function InsertMoney($Subject, $Value, $Cash, $Taxable, $Time, $Text, $Group) 170 function InsertMoney($Subject, $Value, $Cash, $Taxable, $Time, $Text, $Group): void 159 171 { 160 172 $Year = date('Y', $Time); 161 $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumberId(173 $BillCode = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->GetNextDocumentLineNumberId( 162 174 $Group['DocumentLine'], $Year); 163 175 $this->Database->insert('FinanceOperation', array('Text' => $Text, … … 166 178 } 167 179 168 function Insert() 169 { 170 $Finance = $ this->System->Modules['Finance'];180 function Insert(): string 181 { 182 $Finance = $ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance; 171 183 $Output = ''; 172 184 173 185 for ($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--) 174 186 { 175 if ($_POST['Money'.$I] >= 0) { 187 if ($_POST['Money'.$I] >= 0) 188 { 176 189 $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_IN, 177 190 'FinanceOperationGroup'); 178 } else { 191 } else 192 { 179 193 $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 180 194 'FinanceOperationGroup'); … … 185 199 0, $_POST['Taxable'.$I], $Date, $_POST['Text'.$I], $FinanceGroup); 186 200 $Output .= $I.', '; 187 $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'NewPaymentInserted');201 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('Finance', 'NewPaymentInserted'); 188 202 } 189 203 return $Output;
Note:
See TracChangeset
for help on using the changeset viewer.