Changeset 873 for trunk/Modules/Finance/Manage.php
- Timestamp:
- Apr 6, 2020, 11:17:40 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Finance/Manage.php
r866 r873 10 10 { 11 11 $Output = ''; 12 if (!$this->System->User->CheckPermission('Finance', 'Manage'))13 return ('Nemáte oprávnění');14 15 if (array_key_exists('Operation', $_GET)) $Operation = $_GET['Operation'];12 if (!$this->System->User->CheckPermission('Finance', 'Manage')) 13 return ('Nemáte oprávnění'); 14 15 if (array_key_exists('Operation', $_GET)) $Operation = $_GET['Operation']; 16 16 else $Operation = ''; 17 switch ($Operation)17 switch ($Operation) 18 18 { 19 19 case 'Recalculate': … … 42 42 $Output .= '<a href="'.$this->System->Link('/finance/import/').'">Import plateb</a><br />'; 43 43 } 44 return ($Output);44 return ($Output); 45 45 } 46 46 … … 52 52 53 53 $MonthCount = $this->System->Modules['Finance']->BillingPeriods[$Period]['MonthCount']; 54 if ($MonthCount <= 0) return(array('From' => NULL, 'To' => NULL, 'MonthCount' => 0));54 if ($MonthCount <= 0) return (array('From' => NULL, 'To' => NULL, 'MonthCount' => 0)); 55 55 $MonthCurrent = date('n', $Time); 56 56 … … 67 67 $PeriodTo = mktime(0, 0, 0, $MonthTo, date('t', mktime(0, 0, 0, $MonthTo, 1, $Year)), $Year); 68 68 69 return (array('From' => $PeriodFrom, 'To' => $PeriodTo, 'MonthCount' => $MonthCount));69 return (array('From' => $PeriodFrom, 'To' => $PeriodTo, 'MonthCount' => $MonthCount)); 70 70 } 71 71 72 72 function ShowMonthlyPayment() 73 73 { 74 if (!$this->System->User->CheckPermission('Finance', 'Manage')) return('Nemáte oprávnění');74 if (!$this->System->User->CheckPermission('Finance', 'Manage')) return ('Nemáte oprávnění'); 75 75 $SQL = 'SELECT `Member`.*, `MemberPayment`.`MonthlyTotal` AS `Monthly`, '. 76 76 '`MemberPayment`.`Cash` AS `Cash`, '. … … 106 106 107 107 $DbResult = $this->Database->query($Query); 108 while ($Row = $DbResult->fetch_assoc())108 while ($Row = $DbResult->fetch_assoc()) 109 109 { 110 110 $Output .= '<tr>'. … … 120 120 $Output .= $PageList['Output']; 121 121 $Output .= '<a href="?Operation=ProcessMonthlyPayment">Generovat faktury</a>'; 122 return ($Output);122 return ($Output); 123 123 } 124 124 … … 131 131 $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year); 132 132 $SumValue = 0; 133 foreach ($Items as $Item) {133 foreach ($Items as $Item) { 134 134 $SumValue = $SumValue + $Item['Price'] * $Item['Quantity']; 135 135 } … … 143 143 'Generate' => 1, 'Group' => $Group['Id'])); 144 144 $InvoiceId = $this->Database->insert_id; 145 foreach ($Items as $Item)145 foreach ($Items as $Item) 146 146 $this->Database->insert('FinanceInvoiceItem', array('FinanceInvoice' => $InvoiceId, 147 147 'Description' => $Item['Description'], 'Price' => $Item['Price'], … … 149 149 //$LastInsertTime = $Time; 150 150 //$this->CheckAdvancesAndLiabilities($Subject); 151 return ($InvoiceId);151 return ($InvoiceId); 152 152 } 153 153 … … 162 162 'FROM `MemberPayment` JOIN `Member` ON `Member`.`Id`=`MemberPayment`.`Member` '. 163 163 'JOIN `Subject` ON `Subject`.`Id`=`Member`.`Subject`'); 164 while ($Member = $DbResult->fetch_assoc())164 while ($Member = $DbResult->fetch_assoc()) 165 165 { 166 166 $Output .= $Member['SubjectName'].': '; … … 168 168 169 169 /* Check if need to produce new invoice for customer */ 170 if (($Period['MonthCount'] > 0) and ($Member['Blocked'] == 0) and170 if (($Period['MonthCount'] > 0) and ($Member['Blocked'] == 0) and 171 171 ($Period['From'] > $Member['BillingPeriodLastUnixTime'])) 172 172 { … … 178 178 'WHERE (`ServiceCustomerRel`.`Customer`='. 179 179 $Member['Id'].') AND (`ServiceCustomerRel`.`ChangeAction` IS NULL) '); 180 while ($Service = $DbResult2->fetch_assoc())180 while ($Service = $DbResult2->fetch_assoc()) 181 181 { 182 182 $InvoiceItems[] = array('Description' => $Service['Name'], 'Price' => $Service['Price'], … … 188 188 // TODO: In case of negative invoice it is not sufficient to reverse invoicing direction 189 189 // Other subject should invoice only positive items. Negative items should be somehow removed. 190 if ($MonthlyTotal >= 0)190 if ($MonthlyTotal >= 0) 191 191 { 192 192 $InvoiceGroupId = INVOICE_GROUP_OUT; … … 197 197 // Load invoice group 198 198 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById($InvoiceGroupId, 'FinanceInvoiceGroup'); 199 foreach ($InvoiceItems as $Index => $Item)199 foreach ($InvoiceItems as $Index => $Item) 200 200 { 201 201 $InvoiceItems[$Index]['Price'] = $Item['Price'] * $FinanceGroup['ValueSign']; 202 202 } 203 203 204 if ($PayPerPeriod != 0)204 if ($PayPerPeriod != 0) 205 205 { 206 206 $TimePeriodText = date('j.n.Y', $Period['From']).' - '.date('j.n.Y', $Period['To']); … … 217 217 $Output .= "\n"; 218 218 } 219 return ($Output);219 return ($Output); 220 220 } 221 221 … … 225 225 $DbResult = $this->Database->select($Table, '*', '(`ChangeAction` IS NOT NULL) AND '. 226 226 '(`ChangeTime` <= "'.TimeToMysqlDateTime($Time).'") ORDER BY `ChangeTime` ASC'); 227 while ($Service = $DbResult->fetch_assoc())228 { 229 if ($Service['ChangeAction'] == 'add')227 while ($Service = $DbResult->fetch_assoc()) 228 { 229 if ($Service['ChangeAction'] == 'add') 230 230 { 231 231 unset($Service['Id']); … … 235 235 $this->Database->insert($Table, $Service); 236 236 } else 237 if ($Service['ChangeAction'] == 'modify')237 if ($Service['ChangeAction'] == 'modify') 238 238 { 239 239 unset($Service['Id']); … … 244 244 $this->Database->update($Table, '`Id`='.$ReplaceId, $Service); 245 245 } else 246 if ($Service['ChangeAction'] == 'delete')246 if ($Service['ChangeAction'] == 'delete') 247 247 { 248 248 $this->Database->delete($Table, '`Id`='.$Service['ReplaceId']); … … 270 270 $this->TableUpdateChanges('ServiceCustomerRel'); 271 271 272 return ($Output);272 return ($Output); 273 273 } 274 274 275 275 function ProcessMonthlyPayment() 276 276 { 277 if (!$this->System->User->CheckPermission('Finance', 'Manage')) return('Nemáte oprávnění');277 if (!$this->System->User->CheckPermission('Finance', 'Manage')) return ('Nemáte oprávnění'); 278 278 $Output = ''; 279 279 … … 311 311 // Zkontrolovat odečtení měsíčního poplatku 312 312 $Output .= 'Kontrola odečtení poplatků: Poslední měsíc-'.$MonthLast.' Aktuální měsíc-'.$MonthCurrent."\n"; 313 if ($MonthCurrent != $MonthLast)313 if ($MonthCurrent != $MonthLast) 314 314 { 315 315 $Output .= 'Odečítám pravidelný poplatek...'."\n"; … … 335 335 } 336 336 $Output = str_replace("\n", '<br/>', $Output); 337 return ($Output);337 return ($Output); 338 338 } 339 339 … … 366 366 $MainSubjectAccount = $DbResult->fetch_assoc(); 367 367 368 if ($User['Email'] != '')368 if ($User['Email'] != '') 369 369 { 370 370 $Title = 'Pravidelné vyúčtování služeb'; … … 392 392 '`Time`, -`Value`, `File` FROM `FinanceInvoice` WHERE (`Subject`='. 393 393 $Member['Subject'].')) ORDER BY `Time` DESC) AS `T1` WHERE (`T1`.`Time` > "'.$Member['BillingPeriodLastDate'].'")'); 394 while ($DbRow = $DbResult->fetch_assoc())394 while ($DbRow = $DbResult->fetch_assoc()) 395 395 { 396 396 $Text = $DbRow['Text']; … … 417 417 $DbResult = $this->Database->query('SELECT * FROM `FinanceInvoice` WHERE (`BillCode` <> "") '. 418 418 'AND (`Value` != 0) AND (`Generate` = 1)'.$Where); 419 while ($Row = $DbResult->fetch_assoc())419 while ($Row = $DbResult->fetch_assoc()) 420 420 { 421 421 if ($Row['File'] == null) … … 447 447 $DbResult = $this->Database->query('SELECT * FROM `FinanceOperation` WHERE (`BillCode` <> "") '. 448 448 'AND (`Value` != 0) AND (`Generate` = 1)'.$Where); 449 while ($Row = $DbResult->fetch_assoc())449 while ($Row = $DbResult->fetch_assoc()) 450 450 { 451 451 if ($Row['File'] == null) … … 462 462 $FullFileName = $this->System->Modules['File']->GetDir($this->System->Modules['Finance']->DirectoryId).$FileName; 463 463 $Bill->SaveToFile($FullFileName); 464 if (file_exists($FullFileName))464 if (file_exists($FullFileName)) 465 465 { 466 466 $this->Database->update('File', 'Id='.$FileId, array('Name' => $FileName, 'Size' => filesize($FullFileName))); … … 478 478 $Output .= $this->GenerateInvoice(' AND (`File` IS NULL)'); 479 479 $Output .= $this->GenerateOperation(' AND (`File` IS NULL)'); 480 return ($Output);480 return ($Output); 481 481 } 482 482 }
Note:
See TracChangeset
for help on using the changeset viewer.