Changeset 726 for trunk/Modules/Finance/UserState.php
- Timestamp:
- Jan 5, 2015, 10:01:40 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Finance/UserState.php
r724 r726 9 9 function ShowFinanceOperation($Subject) 10 10 { 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'].')))';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 $DbResult = $this->Database->query('SELECT COUNT(*) FROM '.$UserOperationTableQuery.' AS T1');17 $DbResult = $this->Database->query('SELECT COUNT(*) FROM '.$UserOperationTableQuery.' AS `T1`'); 18 18 $DbRow = $DbResult->fetch_row(); 19 19 $PageList = GetPageList($DbRow[0]); … … 33 33 $Output .= $Order['Output']; 34 34 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'];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); … … 78 78 if(!$this->System->User->CheckPermission('Finance', 'DisplaySubjectState')) return('Nemáte oprávnění'); 79 79 $UserId = $this->System->User->User['Id']; 80 $DbResult = $this->Database->query('SELECT Customer FROM UserCustomerRel WHERE User='.$UserId.' LIMIT 1');80 $DbResult = $this->Database->query('SELECT `Customer` FROM `UserCustomerRel` WHERE `User`='.$UserId.' LIMIT 1'); 81 81 if($DbResult->num_rows > 0) 82 82 { … … 87 87 88 88 // Load customer info 89 $DbResult = $this->Database->query('SELECT * FROM Member WHERE Id='.$CustomerId);89 $DbResult = $this->Database->query('SELECT * FROM `Member` WHERE `Id`='.$CustomerId); 90 90 if($DbResult->num_rows == 1) 91 91 { … … 95 95 96 96 // Load subject info 97 $DbResult = $this->Database->query('SELECT * FROM Subject WHERE Id='.$Customer['Subject']);97 $DbResult = $this->Database->query('SELECT * FROM `Subject` WHERE `Id`='.$Customer['Subject']); 98 98 if($DbResult->num_rows == 1) 99 99 { … … 105 105 106 106 // Account state 107 $UserOperationTableQuery = '((SELECT Text, Time, (Value*Direction) AS Value, File, BillCode, NULL AS PeriodFrom, NULL AS PeriodTo'.108 'FROM FinanceOperation WHERE (Subject='.$Subject['Id'].')) UNION ALL '.109 '(SELECT (SELECT GROUP_CONCAT( Description SEPARATOR ",") FROM FinanceInvoiceItem WHERE FinanceInvoice=FinanceInvoice.Id) AS Text, '.110 ' Time, -(Value*Direction) as Value, File, BillCode, PeriodFrom, PeriodTo FROM FinanceInvoice WHERE (Subject='.$Subject['Id'].')) ORDER BY Time DESC) AS T1';111 $DbResult = $this->Database->query('SELECT SUM( T1.Value) AS TotalFROM '.$UserOperationTableQuery);107 $UserOperationTableQuery = '((SELECT `Text`, `Time`, (`Value`*`Direction`) AS `Value`, `File`, `BillCode`, NULL AS `PeriodFrom`, NULL AS `PeriodTo` '. 108 'FROM `FinanceOperation` WHERE (`Subject`='.$Subject['Id'].')) UNION ALL '. 109 '(SELECT (SELECT GROUP_CONCAT(`Description` SEPARATOR ",") FROM `FinanceInvoiceItem` WHERE `FinanceInvoice`=`FinanceInvoice`.`Id`) AS `Text`, '. 110 '`Time`, -(`Value`*`Direction`) AS `Value`, `File`, `BillCode`, `PeriodFrom`, `PeriodTo` FROM `FinanceInvoice` WHERE (`Subject`='.$Subject['Id'].')) ORDER BY `Time` DESC) AS `T1`'; 111 $DbResult = $this->Database->query('SELECT SUM(`T1`.`Value`) AS `Total` FROM '.$UserOperationTableQuery); 112 112 $DbRow = $DbResult->fetch_array(); 113 113 $Total = $DbRow['Total']; … … 133 133 $Output .= 'Rozpis měsíčního poplatku:<br><table class="WideTable">'. 134 134 '<tr><th>Služba</th><th>Cena [Kč]</th></tr>'; 135 $DbResult = $this->Database->query('SELECT Service.Name, Service.Price FROM ServiceCustomerRel'.136 'LEFT JOIN Service ON Service.Id=ServiceCustomerRel.Service'.137 'WHERE ( ServiceCustomerRel.Customer='.$Customer['Id'].') AND (ServiceCustomerRel.ActionIS NULL)');135 $DbResult = $this->Database->query('SELECT `Service`.`Name`, `Service`.`Price` FROM `ServiceCustomerRel` '. 136 'LEFT JOIN `Service` ON `Service`.`Id`=`ServiceCustomerRel`.`Service` '. 137 'WHERE (`ServiceCustomerRel`.`Customer`='.$Customer['Id'].') AND (`ServiceCustomerRel`.`ChangeAction` IS NULL)'); 138 138 while($DbRow = $DbResult->fetch_assoc()) 139 139 {
Note:
See TracChangeset
for help on using the changeset viewer.