Changeset 738 for trunk/Modules/Finance/UserState.php
- Timestamp:
- Apr 14, 2015, 10:20:16 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Finance/UserState.php
r728 r738 9 9 function ShowFinanceOperation($Subject) 10 10 { 11 12 13 14 11 $UserOperationTableQuery = '((SELECT `Text`, `Time`, (`Value`*`Direction`) AS `Value`, `File`, `BillCode`, NULL AS `PeriodFrom`, NULL AS `PeriodTo` '. 12 'FROM `FinanceOperation` WHERE (`Subject`='.$Subject['Id'].')) UNION ALL '. 13 '(SELECT (SELECT GROUP_CONCAT(`Description` SEPARATOR ",") FROM `FinanceInvoiceItem` WHERE `FinanceInvoice`=`FinanceInvoice`.`Id`) AS `Text`, '. 14 '`Time`, -(`Value`*`Direction`) AS `Value`, `File`, `BillCode`, `PeriodFrom`, `PeriodTo` FROM `FinanceInvoice` WHERE (`Subject`='.$Subject['Id'].')))'; 15 15 16 16 $Output = '<div style="text-align:center">Výpis finančních operací</div>'; 17 18 19 17 $DbResult = $this->Database->query('SELECT COUNT(*) FROM '.$UserOperationTableQuery.' AS `T1`'); 18 $DbRow = $DbResult->fetch_row(); 19 $PageList = GetPageList($DbRow[0]); 20 20 21 22 21 $Output .= $PageList['Output']; 22 $Output .= '<table class="WideTable" style="font-size: small;">'; 23 23 24 25 26 27 28 29 30 31 32 33 24 $TableColumns = array( 25 array('Name' => 'Time', 'Title' => 'Datum'), 26 array('Name' => 'Text', 'Title' => 'Popis'), 27 array('Name' => 'Value', 'Title' => 'Změna [Kč]'), 28 array('Name' => 'State', 'Title' => 'Zůstatek [Kč]'), 29 array('Name' => 'PeriodFrom', 'Title' => 'Období'), 30 array('Name' => 'BillCode', 'Title' => 'Doklad'), 31 ); 32 $Order = GetOrderTableHeader($TableColumns, 'Time', 1); 33 $Output .= $Order['Output']; 34 34 35 36 37 35 $StateQuery = 'SELECT SUM(`T2`.`Value`) FROM '.$UserOperationTableQuery. 36 ' AS `T2` WHERE `T2`.`Time` <= `T1`.`Time` '; 37 $Query = 'SELECT *, ('.$StateQuery.') AS `State` FROM '.$UserOperationTableQuery.' AS `T1` '.$Order['SQL'].$PageList['SQLLimit']; 38 38 39 39 $DbResult = $this->Database->query($Query); 40 40 $SumValue = 0; 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 41 while($Row = $DbResult->fetch_assoc()) 42 { 43 $Row['State'] = round($Row['State'], 2); 44 if($Row['State'] > 0) $Row['State'] = '<span style="color:green;">'.$Row['State'].'</span>'; 45 if($Row['State'] < 0) $Row['State'] = '<span style="color:red;">'.$Row['State'].'</span>'; 46 if($Row['Value'] == -0) $Row['Value'] = 0; 47 if($Row['Value'] > 0) $Row['Value'] = '+'.$Row['Value']; 48 if($Row['BillCode'] == '') $Row['BillCode'] = 'PDF'; 49 if($Row['File'] > 0) $Invoice = '<a href="'.$this->System->Link('/file?id='.$Row['File']).'">'.$Row['BillCode'].'</a>'; 50 else $Invoice = NotBlank($Row['BillCode']); 51 if($Row['PeriodFrom'] != '') $Period = HumanDate($Row['PeriodFrom']).' - '.HumanDate($Row['PeriodTo']); 52 else $Period = ' '; 53 $Output .= '<tr><td style="text-align: right;">'.HumanDate($Row['Time']).'</td>'. 54 '<td style="text-align: left;">'.$Row['Text'].'</td>'. 55 '<td style="text-align: right;">'.round($Row['Value'], 2).'</td>'. 56 '<td style="text-align: right;">'.$Row['State'].'</td>'. 57 '<td>'.$Period.'</td>'. 58 '<td>'.$Invoice.'</td></tr>'; 59 $SumValue = $SumValue + $Row['Value']; 60 } 61 $Output .= '</table>'; 62 $Output .= $PageList['Output']; 63 return($Output); 64 64 } 65 65 … … 85 85 } else return($this->SystemMessage('Chyba', 'Nejste zákazníkem')); 86 86 } 87 87 88 88 // Load customer info 89 89 $DbResult = $this->Database->query('SELECT * FROM `Member` WHERE `Id`='.$CustomerId); 90 90 if($DbResult->num_rows == 1) 91 91 { 92 $Customer = $DbResult->fetch_assoc();92 $Customer = $DbResult->fetch_assoc(); 93 93 } else return($this->SystemMessage('Položka nenalezena', 'Zákazník nenalezen')); 94 95 94 95 96 96 // Load subject info 97 97 $DbResult = $this->Database->query('SELECT * FROM `Subject` WHERE `Id`='.$Customer['Subject']); 98 98 if($DbResult->num_rows == 1) 99 { 100 $Subject = $DbResult->fetch_assoc(); 99 { 100 $Subject = $DbResult->fetch_assoc(); 101 101 } else return($this->SystemMessage('Položka nenalezena', 'Subjekt nenalezen')); 102 103 104 $Output = '<table width="100%" border="0" cellspacing="0" cellpadding="3"><tr><td valign="top">'; 102 103 104 $Output = '<table width="100%" border="0" cellspacing="0" cellpadding="3"><tr><td valign="top">'; 105 105 106 106 // Account state … … 120 120 121 121 $DbResult = $this->Database->query('SELECT FinanceBankAccount.*, CONCAT(FinanceBankAccount.Number, "/", FinanceBank.Code) AS NumberFull FROM FinanceBankAccount '. 122 123 122 'JOIN FinanceBank ON FinanceBank.Id=FinanceBankAccount.Bank '. 123 'WHERE (FinanceBankAccount.`Subject`='.$this->System->Config['Finance']['MainSubjectId'].') AND (FinanceBankAccount.`Use`=1)'); 124 124 $SubjectFromAccount = $DbResult->fetch_assoc(); 125 125 $Account = $SubjectFromAccount['NumberFull']; … … 138 138 while($DbRow = $DbResult->fetch_assoc()) 139 139 { 140 140 $Output .= '<tr><td>'.$DbRow['Name'].'</td><td>'.$DbRow['Price'].'</td></tr>'; 141 141 $Total += $DbRow['Price']; 142 142 }
Note:
See TracChangeset
for help on using the changeset viewer.