Changeset 873 for trunk/Modules/Finance/Finance.php
- Timestamp:
- Apr 6, 2020, 11:17:40 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Finance/Finance.php
r866 r873 44 44 { 45 45 $DbResult = $this->Database->query('SELECT * FROM `FinanceBillingPeriod`'); 46 while ($BillingPeriod = $DbResult->fetch_assoc())46 while ($BillingPeriod = $DbResult->fetch_assoc()) 47 47 $this->BillingPeriods[$BillingPeriod['Id']] = $BillingPeriod; 48 48 … … 80 80 function W2Kc($Spotreba) 81 81 { 82 return (round($Spotreba * 0.72 * $this->kWh));82 return (round($Spotreba * 0.72 * $this->kWh)); 83 83 } 84 84 … … 93 93 // Create DocumentLineSequence from previous 94 94 $DbResult = $this->Database->select('DocumentLine', 'Id', '`Yearly` = 1'); 95 while ($DbRow = $DbResult->fetch_assoc())95 while ($DbRow = $DbResult->fetch_assoc()) 96 96 { 97 97 $this->Database->insert('DocumentLineSequence', array('FinanceYear' => $YearId, … … 102 102 function GetFinanceYear($Year) 103 103 { 104 if ($Year == 0)104 if ($Year == 0) 105 105 { 106 106 // Get latest year 107 107 $DbResult = $this->Database->select('FinanceYear', '*', '1 ORDER BY `Year` DESC LIMIT 1'); 108 108 } else $DbResult = $this->Database->select('FinanceYear', '*', '`Year`='.$Year); 109 if ($DbResult->num_rows == 0) {110 if ($Year == date('Y'))109 if ($DbResult->num_rows == 0) { 110 if ($Year == date('Y')) 111 111 { 112 112 $this->CreateFinanceYear($Year); … … 115 115 } 116 116 $FinanceYear = $DbResult->fetch_assoc(); 117 if ($FinanceYear['Closed'] == 1)117 if ($FinanceYear['Closed'] == 1) 118 118 throw new Exception('Rok '.$FinanceYear['Year'].' je již uzavřen. Nelze do něj přidávat položky.'); 119 119 return $FinanceYear; … … 131 131 $Sequence = $DbResult->fetch_assoc(); 132 132 133 if ($Sequence['YearPrefix'] == 1)133 if ($Sequence['YearPrefix'] == 1) 134 134 { 135 135 $Result = $DocumentLine['Shortcut'].$Sequence['NextNumber'].'/'.$FinanceYear['Year']; … … 138 138 $this->Database->query('UPDATE `DocumentLineSequence` SET `NextNumber` = `NextNumber` + 1 '. 139 139 'WHERE (`DocumentLine`='.$Id.') AND (`FinanceYear`='.$FinanceYear['Id'].')'); 140 return ($Result);140 return ($Result); 141 141 } 142 142 … … 151 151 { 152 152 $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE `Id`= '.$Id); 153 if ($DbResult->num_rows == 1) {153 if ($DbResult->num_rows == 1) { 154 154 $Group = $DbResult->fetch_assoc(); 155 return ($Group);155 return ($Group); 156 156 } else die('Finance group id '.$Id.' not found in table '.$Table); 157 157 } … … 162 162 $this->Database->query('TRUNCATE TABLE `MemberPayment`'); 163 163 $DbResult = $this->Database->query('SELECT * FROM `Member`'); 164 while ($Member = $DbResult->fetch_assoc())164 while ($Member = $DbResult->fetch_assoc()) 165 165 { 166 166 $DbResult2 = $this->Database->query('SELECT ((SELECT COALESCE(SUM(`Value`), 0) FROM `FinanceOperation` '. … … 182 182 $DbRow = $DbResult2->fetch_assoc(); 183 183 $Monthly = 0; 184 if ($DbRow['Price'] != '') $MonthlyInet = $DbRow['Price'];184 if ($DbRow['Price'] != '') $MonthlyInet = $DbRow['Price']; 185 185 else $MonthlyInet = 0; 186 186 … … 189 189 $Monthly = round($Monthly); 190 190 191 if ($Member['BillingPeriod'] == 1)191 if ($Member['BillingPeriod'] == 1) 192 192 { 193 193 // Inactive payer … … 204 204 } 205 205 $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'RecalculateMemberPayment'); 206 return ($Output);206 return ($Output); 207 207 } 208 208 … … 214 214 TimeToMysqlDate($Time).'") OR (ValidTo IS NULL)) LIMIT 1'); 215 215 $Row = $DbResult->fetch_array(); 216 return ($Row[0]);216 return ($Row[0]); 217 217 } 218 218 } … … 665 665 function BeforeInsertFinanceOperation($Form) 666 666 { 667 if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);667 if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']); 668 668 else $Year = date("Y", $Form->Values['ValidFrom']); 669 669 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'FinanceOperationGroup'); 670 670 $Form->Values['BillCode'] = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($FinanceGroup['DocumentLine'], $Year); 671 return ($Form->Values);671 return ($Form->Values); 672 672 } 673 673 … … 677 677 $this->Database->query('UPDATE `'.$Form->Definition['Table'].'` SET `Value`= '. 678 678 ($Form->Values['ValueUser'] * $FinanceGroup['ValueSign']).' WHERE `Id`='.$Id); 679 return ($Form->Values);679 return ($Form->Values); 680 680 } 681 681 … … 685 685 $this->Database->query('UPDATE `'.$Form->Definition['Table'].'` SET `Value`= '. 686 686 ($Form->Values['ValueUser'] * $FinanceGroup['ValueSign']).' WHERE `Id`='.$Id); 687 return ($Form->Values);687 return ($Form->Values); 688 688 } 689 689 … … 691 691 { 692 692 // Get new DocumentLineCode by selected invoice Group 693 if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);693 if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']); 694 694 else $Year = date("Y", $Form->Values['ValidFrom']); 695 695 $Group = $this->System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'FinanceInvoiceGroup'); 696 696 $Form->Values['BillCode'] = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year); 697 return ($Form->Values);697 return ($Form->Values); 698 698 } 699 699 … … 707 707 $this->Database->query('UPDATE `'.$Form->Definition['Table'].'` SET `Value`= '. 708 708 ($Sum * $FinanceGroup['ValueSign']).' WHERE `Id`='.$Id); 709 return ($Form->Values);709 return ($Form->Values); 710 710 } 711 711 … … 718 718 $this->Database->query('UPDATE `'.$Form->Definition['Table'].'` SET `Value`= '. 719 719 ($Sum * $FinanceGroup['ValueSign']).' WHERE `Id`='.$Id); 720 return ($Form->Values);720 return ($Form->Values); 721 721 } 722 722 … … 727 727 $ParentForm->LoadValuesFromDatabase($Form->Values['FinanceInvoice']); 728 728 $this->AfterInsertFinanceInvoice($ParentForm, $Form->Values['FinanceInvoice']); 729 return ($Form->Values);729 return ($Form->Values); 730 730 } 731 731 … … 736 736 $ParentForm->LoadValuesFromDatabase($Form->Values['FinanceInvoice']); 737 737 $this->BeforeModifyFinanceInvoice($ParentForm, $Form->Values['FinanceInvoice']); 738 return ($Form->Values);738 return ($Form->Values); 739 739 } 740 740 741 741 function BeforeInsertContract($Form) 742 742 { 743 if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);743 if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']); 744 744 else $Year = date("Y", $Form->Values['ValidFrom']); 745 745 $Form->Values['BillCode'] = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($Form->Values['DocumentLine'], $Year); 746 return ($Form->Values);746 return ($Form->Values); 747 747 } 748 748 }
Note:
See TracChangeset
for help on using the changeset viewer.