Changeset 873 for trunk/Modules/Finance/Import.php
- Timestamp:
- Apr 6, 2020, 11:17:40 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Finance/Import.php
r812 r873 9 9 function Show() 10 10 { 11 if (!$this->System->User->CheckPermission('Finance', 'SubjectList')) return('Nemáte oprávnění');12 if (array_key_exists('Operation', $_GET))11 if (!$this->System->User->CheckPermission('Finance', 'SubjectList')) return ('Nemáte oprávnění'); 12 if (array_key_exists('Operation', $_GET)) 13 13 { 14 if ($_GET['Operation'] == 'prepare') return($this->Prepare());15 else if ($_GET['Operation'] == 'insert') return($this->Insert());14 if ($_GET['Operation'] == 'prepare') return ($this->Prepare()); 15 else if ($_GET['Operation'] == 'insert') return ($this->Insert()); 16 16 else echo('Neplatná akce'); 17 17 } else … … 22 22 $Output .= '<input type="submit" value="Analyzovat"/>'; 23 23 $Output .= '</form>'; 24 return ($Output);24 return ($Output); 25 25 } 26 26 } … … 31 31 $Finance->LoadMonthParameters(0); 32 32 $Data = explode("\n", $_POST['Source']); 33 foreach ($Data as $Key => $Value)33 foreach ($Data as $Key => $Value) 34 34 { 35 35 $Value = str_replace('\"', '"', $Value); 36 36 $Data[$Key] = str_getcsv($Value, ',', '"', "\\"); 37 37 //print_r($Data[$Key]); 38 foreach ($Data[$Key] as $Key2 => $Value2)38 foreach ($Data[$Key] as $Key2 => $Value2) 39 39 { 40 if (substr($Data[$Key][$Key2], 0, 2) == '\"')40 if (substr($Data[$Key][$Key2], 0, 2) == '\"') 41 41 $Data[$Key][$Key2] = substr($Data[$Key][$Key2], 2, -2); 42 42 } … … 61 61 //print_r($Data); 62 62 63 if ($Header != $Data[0]) {63 if ($Header != $Data[0]) { 64 64 $Output = 'Nekompatibilní struktura CSV'; 65 65 print_r($Header); … … 73 73 $Output = '<form action="?Operation=insert" method="post">'; 74 74 $I = 0; 75 foreach ($Data as $Key => $Value)75 foreach ($Data as $Key => $Value) 76 76 { 77 if (count($Value) <= 1) continue;78 if ($Value[9] == '') $Value[5] = 128; // Žádný účet => Poštovní spořitelna77 if (count($Value) <= 1) continue; 78 if ($Value[9] == '') $Value[5] = 128; // Žádný účet => Poštovní spořitelna 79 79 $Time = explode('.', $Value[0]); 80 80 $Time = $Time[2].'-'.$Time[1].'-'.$Time[0]; 81 81 $Money = $Value[1]; 82 if (is_numeric($Value[5]))82 if (is_numeric($Value[5])) 83 83 { 84 84 $Subject = $Value[5] * 1; 85 85 $DbResult = $this->Database->query('SELECT Id FROM Subject WHERE Id='.$this->Database->real_escape_string($Subject)); 86 if ($DbResult->num_rows == 0) $Subject = '? ('.($Value[5] * 1).')';86 if ($DbResult->num_rows == 0) $Subject = '? ('.($Value[5] * 1).')'; 87 87 } else 88 88 { 89 89 $Subject = '? ('.$Value[5].')'; 90 90 } 91 if (!is_numeric($Subject))91 if (!is_numeric($Subject)) 92 92 { 93 93 $Mode = 'Ručně'; … … 99 99 } 100 100 101 if ($Money < 0) $Text = 'Platba převodem';101 if ($Money < 0) $Text = 'Platba převodem'; 102 102 else $Text = 'Přijatá platba'; 103 103 $Automatic .= '<tr>'. … … 121 121 $Output .= '<input type="submit" value="Zpracovat"/></form>'; 122 122 } 123 return ($Output);123 return ($Output); 124 124 } 125 125 … … 142 142 $Output = ''; 143 143 144 for ($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--)144 for ($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--) 145 145 { 146 if ($_POST['Money'.$I] < 0) {146 if ($_POST['Money'.$I] < 0) { 147 147 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup'); 148 148 } else { … … 156 156 $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'NewPaymentInserted'); 157 157 } 158 return ($Output);158 return ($Output); 159 159 } 160 160 }
Note:
See TracChangeset
for help on using the changeset viewer.