Changeset 873 for trunk/Modules/Finance
- Timestamp:
- Apr 6, 2020, 11:17:40 PM (5 years ago)
- Location:
- trunk/Modules/Finance
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Finance/Bill.php
r748 r873 8 8 function GenerateHTML() 9 9 { 10 return ('');10 return (''); 11 11 } 12 12 … … 22 22 { 23 23 $Encoding = new Encoding(); 24 if ($this->Checked == false) {25 if (CommandExist('htmldoc')) {24 if ($this->Checked == false) { 25 if (CommandExist('htmldoc')) { 26 26 $this->Checked = true; 27 27 } else throw new Exception('htmldoc is not installed.'); … … 29 29 $Output = shell_exec('echo "'.addslashes($Encoding->FromUTF8($HtmlCode)). 30 30 '"|htmldoc --no-numbered --webpage --no-embedfonts --charset 8859-2 -t pdf -'); 31 return ($Output);31 return ($Output); 32 32 } 33 33 } … … 43 43 $Subject['AddressStreet'].'<br>'. 44 44 $Subject['AddressPSC'].' '.$Subject['AddressTown'].'<br>'; 45 if ($Subject['IC'] != 0) $Output .= 'IČ: '.$Subject['IC'].'<br>';46 if ($Subject['DIC'] != '') $Output .= 'DIČ: '.$Subject['DIC'].'<br>';47 if ($Subject['Account'] != '') $Output .= 'Účet: '.$Subject['Account'].'<br>';48 if ($Subject['PayVAT'] != '') $Output .= 'Plátce DPH: '.$BooleanText[$Subject['PayVAT']].'<br>';49 return ($Output);45 if ($Subject['IC'] != 0) $Output .= 'IČ: '.$Subject['IC'].'<br>'; 46 if ($Subject['DIC'] != '') $Output .= 'DIČ: '.$Subject['DIC'].'<br>'; 47 if ($Subject['Account'] != '') $Output .= 'Účet: '.$Subject['Account'].'<br>'; 48 if ($Subject['PayVAT'] != '') $Output .= 'Plátce DPH: '.$BooleanText[$Subject['PayVAT']].'<br>'; 49 return ($Output); 50 50 } 51 51 … … 78 78 $InvoiceItems = array(); 79 79 $DbResult = $this->Database->select('FinanceInvoiceItem', '*, ROUND(`Price` * `Quantity`, '.$Finance->Rounding.') AS `Total`', '`FinanceInvoice`='.$this->InvoiceId); 80 while ($Item = $DbResult->fetch_assoc())80 while ($Item = $DbResult->fetch_assoc()) 81 81 { 82 82 $InvoiceItems[$Item['Id']] = $Item; … … 84 84 85 85 // If direction is in => switch sides 86 if ($Invoice['Direction'] == FINANCE_DIRECTION_OUT)87 { 88 } 89 else if ($Invoice['Direction'] == FINANCE_DIRECTION_IN)86 if ($Invoice['Direction'] == FINANCE_DIRECTION_OUT) 87 { 88 } 89 else if ($Invoice['Direction'] == FINANCE_DIRECTION_IN) 90 90 { 91 91 $Subject = $SubjectTo; … … 121 121 'Datum zdanitel. plnění: '.HumanDate($Invoice['Time']).'<br>'. 122 122 'Datum splatnosti: '.HumanDate($Invoice['TimeDue']).'<br>'; 123 if (($Invoice['PeriodFrom'] != '') and ($Invoice['PeriodTo'] != ''))123 if (($Invoice['PeriodFrom'] != '') and ($Invoice['PeriodTo'] != '')) 124 124 $Output .= 'Fakturované období: '.HumanDate($Invoice['PeriodFrom']).' - '. 125 125 HumanDate($Invoice['PeriodTo']).'<br>'; … … 133 133 134 134 $Total = 0; 135 foreach ($InvoiceItems as $Item)135 foreach ($InvoiceItems as $Item) 136 136 { 137 137 $Output .= '<tr><td>'.$Item['Description'].'</td><td align="right">'. … … 146 146 '</table>'; 147 147 148 return ($Output);148 return ($Output); 149 149 } 150 150 } … … 174 174 175 175 $BooleanText = array('Ne', 'Ano'); 176 if ($Operation['Direction'] == FINANCE_DIRECTION_OUT)176 if ($Operation['Direction'] == FINANCE_DIRECTION_OUT) 177 177 $Desc = array( 178 178 'Type' => 'VÝDAJOVÝ', … … 180 180 'Target' => 'Vydáno komu', 181 181 ); 182 else if ($Operation['Direction'] == FINANCE_DIRECTION_IN)182 else if ($Operation['Direction'] == FINANCE_DIRECTION_IN) 183 183 $Desc = array( 184 184 'Type' => 'PŘÍJMOVÝ', … … 206 206 $Subject['AddressStreet'].'<br>'. 207 207 $Subject['AddressPSC'].' '.$Subject['AddressTown'].'<br>'; 208 if ($Subject['IC'] != 0) $Output .= 'IČ: '.$Subject['IC'].'<br>';209 if ($Subject['DIC'] != '') $Output .= 'DIČ: '.$Subject['DIC'].'<br>';208 if ($Subject['IC'] != 0) $Output .= 'IČ: '.$Subject['IC'].'<br>'; 209 if ($Subject['DIC'] != '') $Output .= 'DIČ: '.$Subject['DIC'].'<br>'; 210 210 $Description = $Operation['Text']; 211 211 $Output .= '</td></tr>'. … … 215 215 '<tr><td> </td><td><br><br>'.$Desc['Signature'].':</td></tr>'; 216 216 $Output .= '</table>'; 217 return ($Output);217 return ($Output); 218 218 } 219 219 } -
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 } -
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 } -
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 } -
trunk/Modules/Finance/Trade.php
r847 r873 65 65 $Row = $DbResult->fetch_array(); 66 66 $Balance['SmallAssets']['End'] = $Row[0] + 0; 67 return ($Balance);67 return ($Balance); 68 68 } 69 69 … … 77 77 $StartYear = date('Y', $this->StartEvidence); 78 78 $EndYear = date('Y', time()); 79 for ($Year = $StartYear; $Year <= $EndYear; $Year++)79 for ($Year = $StartYear; $Year <= $EndYear; $Year++) 80 80 { 81 81 $EndTime = mktime(0, 0, 0, 12, 31, $Year); 82 82 //$Year = date('Y', $EndTime); 83 83 $StartTime = mktime(0, 0, 0, 1, 1, $Year); 84 if ($StartTime < $this->StartEvidence) $StartTime = $this->StartEvidence;84 if ($StartTime < $this->StartEvidence) $StartTime = $this->StartEvidence; 85 85 86 86 $Balance = $this->GetTimePeriodBalance($StartTime, $EndTime); … … 113 113 $StartYear = date('Y', $this->StartEvidence); 114 114 $EndYear = date('Y', time()); 115 for ($Year = $StartYear; $Year <= $EndYear; $Year++)116 { 117 for ($Month = 1; $Month <= 12; $Month++)115 for ($Year = $StartYear; $Year <= $EndYear; $Year++) 116 { 117 for ($Month = 1; $Month <= 12; $Month++) 118 118 { 119 119 $EndTime = mktime(0, 0, 0, $Month, 31, $Year); 120 120 //$Year = date('Y', $EndTime); 121 121 $StartTime = mktime(0, 0, 0, $Month, 1, $Year); 122 if (($StartTime < time()) and ($EndTime > $this->StartEvidence))122 if (($StartTime < time()) and ($EndTime > $this->StartEvidence)) 123 123 { 124 if ($StartTime < $this->StartEvidence) $StartTime = $this->StartEvidence;124 if ($StartTime < $this->StartEvidence) $StartTime = $this->StartEvidence; 125 125 126 126 $Balance = $this->GetTimePeriodBalance($StartTime, $EndTime); … … 164 164 'WHERE (`ValueSign` = 1) AND (`FinanceOperation`.`Time` >= "'.$Year['DateStart'].'") '. 165 165 'AND (`FinanceOperation`.`Time` <= "'.$Year['DateEnd'].'") ORDER BY `Time`'); 166 while ($Row = $DbResult->fetch_array())166 while ($Row = $DbResult->fetch_array()) 167 167 { 168 168 $Row['Time'] = explode(' ', $Row['Time']); … … 204 204 'WHERE (`FinanceOperationGroup`.`ValueSign` = -1) AND (`FinanceOperation`.`Time` >= "'.$Year['DateStart'].'") '. 205 205 'AND (`FinanceOperation`.`Time` <= "'.$Year['DateEnd'].'") ORDER BY `Time`'); 206 while ($Row = $DbResult->fetch_array())206 while ($Row = $DbResult->fetch_array()) 207 207 { 208 208 $Row['Time'] = explode(' ', $Row['Time']); … … 245 245 'WHERE (`FinanceInvoiceGroup`.`ValueSign` = 1) AND (`FinanceInvoice`.`Time` >= "'.$Year['DateStart']. 246 246 '") AND (`FinanceInvoice`.`Time` <= "'.$Year['DateEnd'].'") ORDER BY `Time`'); 247 while ($Row = $DbResult->fetch_array())248 { 249 if ($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = ' ';247 while ($Row = $DbResult->fetch_array()) 248 { 249 if ($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = ' '; 250 250 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillName']. 251 251 '</td><td>'.$Row['SubjectName'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].'</td></tr>'; … … 276 276 'WHERE (`FinanceInvoiceGroup`.`ValueSign` = -1) AND (`FinanceInvoice`.`Time` >= "'.$Year['DateStart']. 277 277 '") AND (FinanceInvoice.Time <= "'.$Year['DateEnd'].'") ORDER BY Time'); 278 while ($Row = $DbResult->fetch_array())279 { 280 if ($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = ' ';278 while ($Row = $DbResult->fetch_array()) 279 { 280 if ($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = ' '; 281 281 $Row['Value'] = $Row['Value'] * $Row['ValueSign']; 282 282 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillName']. … … 314 314 'WHERE (T6.Subject = Subject.Id) AND (`FinanceOperationGroup`.`ValueSign` = -1)) AS `Spends` '. 315 315 'FROM Subject ORDER BY Name'); 316 while ($Row = $DbResult->fetch_assoc())316 while ($Row = $DbResult->fetch_assoc()) 317 317 { 318 318 $Output .= '<tr><td style="text-align: left;"><a href="?table=SubjectAccount&Id='.$Row['Id'].'">'.$Row['Name'].'</a></td><td>'.$Row['Liabilities'].' / '.$Row['OpenedLiabilities'].'</td><td>'.$Row['Claims'].' / '.$Row['OpenedClaims'].'</td><td>'.$Row['Gains'].'</td><td>'.$Row['Spends'].'</td><td>'.($Row['Gains'] - $Row['Spends'] - $Row['Claims'] + $Row['Liabilities']).'</td><td>'.$Row['Cash'].'</td></tr>'; … … 330 330 'FROM StockSerialNumber JOIN Product ON Product.Id = StockSerialNumber.Product '. 331 331 'WHERE (TimeElimination IS NOT NULL)'); 332 while ($Row = $DbResult->fetch_array())332 while ($Row = $DbResult->fetch_array()) 333 333 { 334 334 $Output .= '<tr><td>'.$Row['Name'].'</td><td>'.$Row['Price'].'</td><td>'.$Row['TimeEnlistment'].'</td><td>'.$Row['TimeElimination'].'</td></tr>'; … … 349 349 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `FinanceOperation`.`Group` '. 350 350 'WHERE `Subject`='.$_GET['Id'].' ORDER BY `Time`'); 351 while ($Row = $DbResult->fetch_array())351 while ($Row = $DbResult->fetch_array()) 352 352 { 353 353 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['Text']. … … 364 364 'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id` = `FinanceInvoice`.`BillCode` '. 365 365 'WHERE `Subject`='.$_GET['Id'].' ORDER BY `Time`'); 366 while ($Row = $DbResult->fetch_array())366 while ($Row = $DbResult->fetch_array()) 367 367 { 368 368 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.HumanDate($Row['TimePayment']). … … 375 375 $Output .= '<tr><th>Datum vytvoření</th><th>Datum zaplacení</th><th>Název</th><th>Hodnota [Kč]</th></tr>'; 376 376 $DbResult = $this->Database->select('FinanceAdvances', '*', 'Subject='.$_GET['Id']); 377 while ($Row = $DbResult->fetch_array())377 while ($Row = $DbResult->fetch_array()) 378 378 { 379 379 $Output .= '<tr><td>'.$Row['Time'].'</td><td>'.$Row['TimePass'].'</td><td>'.$Row['ValueSign'].'</td><td>'.($Row['Value']).'</td><td>'.$Row['CashFlowId'].'</td></tr>'; … … 411 411 $Output .= '<strong>Roční přehledy</strong><br/>'; 412 412 $Output .= $this->ShowFinanceYears(); 413 if (array_key_exists('year', $_GET))413 if (array_key_exists('year', $_GET)) 414 414 { 415 415 $Year = $_GET['year'] * 1; … … 426 426 function Show() 427 427 { 428 if (!$this->System->User->CheckPermission('Finance', 'TradingStatus'))429 return ('Nemáte oprávnění');428 if (!$this->System->User->CheckPermission('Finance', 'TradingStatus')) 429 return ('Nemáte oprávnění'); 430 430 431 431 $Finance = &$this->System->Modules['Finance']; 432 432 433 433 $Output = ''; 434 if (!array_key_exists('table', $_GET)) $_GET['table'] = '';435 switch ($_GET['table'])434 if (!array_key_exists('table', $_GET)) $_GET['table'] = ''; 435 switch ($_GET['table']) 436 436 { 437 437 case 'AnnualBalance': … … 478 478 $Output = $this->ShowDefault(); 479 479 } 480 return ($Output);480 return ($Output); 481 481 } 482 482 … … 485 485 $Output = 'Roky: '; 486 486 $DbRows = $this->Database->select('FinanceYear', '*'); 487 while ($DbRow = $DbRows->fetch_assoc())487 while ($DbRow = $DbRows->fetch_assoc()) 488 488 $Output .= '<a href="?year='.$DbRow['Id'].'">'.$DbRow['Year'].'</a> '; 489 489 $Output .= '<br/>'; 490 return ($Output);490 return ($Output); 491 491 } 492 492 -
trunk/Modules/Finance/UserState.php
r825 r873 44 44 $DbResult = $this->Database->query($Query); 45 45 $SumValue = 0; 46 while ($Row = $DbResult->fetch_assoc())46 while ($Row = $DbResult->fetch_assoc()) 47 47 { 48 48 $Row['State'] = round($Row['State'], 2); 49 if ($Row['State'] > 0) $Row['State'] = '<span style="color:green;">'.$Row['State'].'</span>';50 if ($Row['State'] < 0) $Row['State'] = '<span style="color:red;">'.$Row['State'].'</span>';51 if ($Row['Value'] == -0) $Row['Value'] = 0;52 if ($Row['Value'] > 0) $Row['Value'] = '+'.$Row['Value'];53 if ($Row['BillName'] == '') $Row['BillName'] = 'PDF';54 if ($Row['File'] > 0) $Invoice = '<a href="'.$this->System->Link('/file?id='.$Row['File']).'">'.$Row['BillName'].'</a>';49 if ($Row['State'] > 0) $Row['State'] = '<span style="color:green;">'.$Row['State'].'</span>'; 50 if ($Row['State'] < 0) $Row['State'] = '<span style="color:red;">'.$Row['State'].'</span>'; 51 if ($Row['Value'] == -0) $Row['Value'] = 0; 52 if ($Row['Value'] > 0) $Row['Value'] = '+'.$Row['Value']; 53 if ($Row['BillName'] == '') $Row['BillName'] = 'PDF'; 54 if ($Row['File'] > 0) $Invoice = '<a href="'.$this->System->Link('/file?id='.$Row['File']).'">'.$Row['BillName'].'</a>'; 55 55 else $Invoice = NotBlank($Row['BillName']); 56 if ($Row['PeriodFrom'] != '') $Period = HumanDate($Row['PeriodFrom']).' - '.HumanDate($Row['PeriodTo']);56 if ($Row['PeriodFrom'] != '') $Period = HumanDate($Row['PeriodFrom']).' - '.HumanDate($Row['PeriodTo']); 57 57 else $Period = ' '; 58 58 $Output .= '<tr><td style="text-align: right;">'.HumanDate($Row['Time']).'</td>'. … … 66 66 $Output .= '</table>'; 67 67 $Output .= $PageList['Output']; 68 return ($Output);68 return ($Output); 69 69 } 70 70 … … 75 75 76 76 // Determine which customer should be displayed 77 if (array_key_exists('i', $_GET))77 if (array_key_exists('i', $_GET)) 78 78 { 79 if (!$this->System->User->CheckPermission('Finance', 'Manage')) return('Nemáte oprávnění');79 if (!$this->System->User->CheckPermission('Finance', 'Manage')) return ('Nemáte oprávnění'); 80 80 $CustomerId = $_GET['i']; 81 81 } else 82 82 { 83 if (!$this->System->User->CheckPermission('Finance', 'DisplaySubjectState')) return('Nemáte oprávnění');83 if (!$this->System->User->CheckPermission('Finance', 'DisplaySubjectState')) return ('Nemáte oprávnění'); 84 84 $UserId = $this->System->User->User['Id']; 85 85 $DbResult = $this->Database->query('SELECT `Customer` FROM `UserCustomerRel` WHERE `User`='.$UserId.' LIMIT 1'); 86 if ($DbResult->num_rows > 0)86 if ($DbResult->num_rows > 0) 87 87 { 88 88 $CustomerUserRel = $DbResult->fetch_assoc(); 89 89 $CustomerId = $CustomerUserRel['Customer']; 90 } else return ($this->SystemMessage('Chyba', 'Nejste zákazníkem'));90 } else return ($this->SystemMessage('Chyba', 'Nejste zákazníkem')); 91 91 } 92 92 93 93 // Load customer info 94 94 $DbResult = $this->Database->query('SELECT * FROM `Member` WHERE `Id`='.$CustomerId); 95 if ($DbResult->num_rows == 1)95 if ($DbResult->num_rows == 1) 96 96 { 97 97 $Customer = $DbResult->fetch_assoc(); 98 } else return ($this->SystemMessage('Položka nenalezena', 'Zákazník nenalezen'));98 } else return ($this->SystemMessage('Položka nenalezena', 'Zákazník nenalezen')); 99 99 100 100 101 101 // Load subject info 102 102 $DbResult = $this->Database->query('SELECT * FROM `Subject` WHERE `Id`='.$Customer['Subject']); 103 if ($DbResult->num_rows == 1)103 if ($DbResult->num_rows == 1) 104 104 { 105 105 $Subject = $DbResult->fetch_assoc(); 106 } else return ($this->SystemMessage('Položka nenalezena', 'Subjekt nenalezen'));106 } else return ($this->SystemMessage('Položka nenalezena', 'Subjekt nenalezen')); 107 107 108 108 … … 141 141 'LEFT JOIN `Service` ON `Service`.`Id`=`ServiceCustomerRel`.`Service` '. 142 142 'WHERE (`ServiceCustomerRel`.`Customer`='.$Customer['Id'].') AND (`ServiceCustomerRel`.`ChangeAction` IS NULL)'); 143 while ($DbRow = $DbResult->fetch_assoc())143 while ($DbRow = $DbResult->fetch_assoc()) 144 144 { 145 145 $Output .= '<tr><td>'.$DbRow['Name'].'</td><td>'.$DbRow['Price'].'</td></tr>'; … … 152 152 153 153 $Output .= '</td></tr></table>'; 154 return ($Output);154 return ($Output); 155 155 } 156 156 }
Note:
See TracChangeset
for help on using the changeset viewer.