Changeset 691 for trunk/Modules/Finance/UserState.php
- Timestamp:
- Sep 7, 2014, 10:50:01 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Finance/UserState.php
r688 r691 12 12 'FROM FinanceOperation WHERE (Subject='.$Subject['Id'].')) UNION ALL '. 13 13 '(SELECT (SELECT GROUP_CONCAT(Description SEPARATOR ",") FROM FinanceInvoiceItem WHERE FinanceInvoice=FinanceInvoice.Id) AS Text, '. 14 'Time, -Value as Value, File, BillCode, PeriodFrom, PeriodTo FROM FinanceInvoice WHERE (Subject='.$Subject['Id'].')) ORDER BY Time DESC) AS T1';14 'Time, -Value 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.' ');17 $DbResult = $this->Database->query('SELECT COUNT(*) FROM '.$UserOperationTableQuery.' AS T1'); 18 18 $DbRow = $DbResult->fetch_row(); 19 19 $PageList = GetPageList($DbRow[0]); … … 25 25 array('Name' => 'Time', 'Title' => 'Datum'), 26 26 array('Name' => 'Description', 'Title' => 'Popis'), 27 array('Name' => 'Value', 'Title' => 'Částka [Kč]'), 27 array('Name' => 'Value', 'Title' => 'Změna [Kč]'), 28 array('Name' => 'State', 'Title' => 'Zůstatek [Kč]'), 28 29 array('Name' => 'Period', 'Title' => 'Období'), 29 30 array('Name' => 'Bill', 'Title' => 'Doklad'), … … 32 33 $Output .= $Order['Output']; 33 34 34 $Query = 'SELECT * FROM '.$UserOperationTableQuery.' '.$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']; 35 38 36 39 $DbResult = $this->Database->query($Query); … … 38 41 while($Row = $DbResult->fetch_assoc()) 39 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>'; 40 46 if($Row['Value'] == -0) $Row['Value'] = 0; 41 47 if($Row['Value'] > 0) $Row['Value'] = '+'.$Row['Value']; … … 48 54 '<td style="text-align: left;">'.$Row['Text'].'</td>'. 49 55 '<td style="text-align: right;">'.round($Row['Value'], 2).'</td>'. 56 '<td style="text-align: right;">'.$Row['State'].'</td>'. 50 57 '<td>'.$Period.'</td>'. 51 58 '<td>'.$Invoice.'</td></tr>'; … … 67 74 if(!$this->System->User->CheckPermission('Finance', 'Manage')) return('Nemáte oprávnění'); 68 75 $DbResult = $this->Database->query('SELECT * FROM Subject WHERE Id='.$_GET['Subject']); 69 $Subject = $DbResult->fetch_assoc(); 76 if($DbResult->num_rows > 0) 77 $Subject = $DbResult->fetch_assoc(); 78 else return($this->SystemMessage('Chyba', 'Subjekt nenalezen')); 70 79 } else 71 80 {
Note:
See TracChangeset
for help on using the changeset viewer.