Changeset 740 for trunk/Modules/Finance/Zivnost.php
- Timestamp:
- Jul 3, 2015, 11:36:07 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Finance/Zivnost.php
r738 r740 11 11 { 12 12 $Balance = array(); 13 $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceOperation WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND ( Direction = 1)');13 $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceOperation WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (ValueSign = 1)'); 14 14 $Row = $DbResult->fetch_array(); 15 15 $Balance['Income']['Start'] = $Row[0] + 0; 16 $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceOperation WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND ( Direction = 1)');16 $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceOperation WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (ValueSign = 1)'); 17 17 //echo('SELECT SUM(Value) FROM FinanceCashFlow WHERE Time <= "'.TimeToMysqlDateTime($EndTime).'" AND Value > 0 AND Taxable = 1'.'<br />'); 18 18 $Row = $DbResult->fetch_array(); 19 19 $Balance['Income']['End'] = $Row[0] + 0; 20 20 21 $DbResult = $this->Database->query('SELECT -SUM(Value* Direction) FROM FinanceOperation WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (Direction = -1)');21 $DbResult = $this->Database->query('SELECT -SUM(Value*ValueSign) FROM FinanceOperation WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (ValueSign = -1)'); 22 22 $Row = $DbResult->fetch_array(); 23 23 $Balance['Spend']['Start'] = $Row[0] + 0; 24 $DbResult = $this->Database->query('SELECT -SUM(Value* Direction) FROM FinanceOperation WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (Direction = -1)');24 $DbResult = $this->Database->query('SELECT -SUM(Value*ValueSign) FROM FinanceOperation WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (ValueSign = -1)'); 25 25 //echo('SELECT -SUM(Value) FROM FinanceCashFlow WHERE Time <= "'.TimeToMysqlDateTime($EndTime).'" AND Value < 0 AND Taxable = 1'.'<br />'); 26 26 $Row = $DbResult->fetch_array(); 27 27 $Balance['Spend']['End'] = $Row[0] + 0; 28 28 29 $DbResult = $this->Database->query('SELECT SUM(Value* Direction) FROM FinanceInvoice WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Direction = 1)');29 $DbResult = $this->Database->query('SELECT SUM(Value*ValueSign) FROM FinanceInvoice WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (ValueSign = 1)'); 30 30 $Row = $DbResult->fetch_array(); 31 31 $Balance['Claims']['Start'] = $Row[0] + 0; 32 $DbResult = $this->Database->query('SELECT SUM(Value* Direction) FROM FinanceInvoice WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Direction = 1)');32 $DbResult = $this->Database->query('SELECT SUM(Value*ValueSign) FROM FinanceInvoice WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (ValueSign = 1)'); 33 33 $Row = $DbResult->fetch_array(); 34 34 $Balance['Claims']['End'] = $Row[0] + 0; 35 35 36 $DbResult = $this->Database->query('SELECT -SUM(Value* Direction) FROM FinanceInvoice WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Direction = -1)');36 $DbResult = $this->Database->query('SELECT -SUM(Value*ValueSign) FROM FinanceInvoice WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (ValueSign = -1)'); 37 37 $Row = $DbResult->fetch_array(); 38 38 $Balance['Liabilities']['Start'] = $Row[0] + 0; 39 $DbResult = $this->Database->query('SELECT -SUM(Value* Direction) FROM FinanceInvoice WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Direction = -1)');39 $DbResult = $this->Database->query('SELECT -SUM(Value*ValueSign) FROM FinanceInvoice WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (ValueSign = -1)'); 40 40 $Row = $DbResult->fetch_array(); 41 41 $Balance['Liabilities']['End'] = $Row[0] + 0; … … 144 144 $Output .= '<tr><th>Čas</th><th>Kód</th><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th><th>Daňový</th><th>Hotovost</th></tr>'; 145 145 $DbResult = $this->Database->query('SELECT * FROM FinanceOperation LEFT JOIN Subject ON Subject.Id = FinanceOperation.Subject '. 146 'WHERE ( Direction = 1) AND (FinanceOperation.Time >= "'.$Year['DateStart'].'") AND (FinanceOperation.Time <= "'.$Year['DateEnd'].'") ORDER BY Time');146 'WHERE (ValueSign = 1) AND (FinanceOperation.Time >= "'.$Year['DateStart'].'") AND (FinanceOperation.Time <= "'.$Year['DateEnd'].'") ORDER BY Time'); 147 147 while($Row = $DbResult->fetch_array()) 148 148 { … … 174 174 $Output .= '<tr><th>Čas</th><th>Kód</th><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th><th>Daňový</th><th>Hotovost</th></tr>'; 175 175 $DbResult = $this->Database->query('SELECT * FROM FinanceOperation LEFT JOIN Subject ON Subject.Id = FinanceOperation.Subject '. 176 'WHERE ( Direction = -1) AND (FinanceOperation.Time >= "'.$Year['DateStart'].'") AND (FinanceOperation.Time <= "'.$Year['DateEnd'].'") ORDER BY Time');176 'WHERE (ValueSign = -1) AND (FinanceOperation.Time >= "'.$Year['DateStart'].'") AND (FinanceOperation.Time <= "'.$Year['DateEnd'].'") ORDER BY Time'); 177 177 while($Row = $DbResult->fetch_array()) 178 178 { … … 204 204 $DbResult = $this->Database->query('SELECT *, (SELECT GROUP_CONCAT(Description SEPARATOR ",") FROM FinanceInvoiceItem WHERE FinanceInvoiceItem.FinanceInvoice = FinanceInvoice.Id) AS Text '. 205 205 'FROM FinanceInvoice JOIN Subject ON Subject.Id = FinanceInvoice.Subject '. 206 'WHERE ( Direction = 1) AND (FinanceInvoice.Time >= "'.$Year['DateStart'].206 'WHERE (ValueSign = 1) AND (FinanceInvoice.Time >= "'.$Year['DateStart']. 207 207 '") AND (FinanceInvoice.Time <= "'.$Year['DateEnd'].'") ORDER BY Time'); 208 208 while($Row = $DbResult->fetch_array()) … … 210 210 if($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = ' '; 211 211 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillCode']. 212 '</td><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.($Row['Value'] * $Row[' Direction']).'</td></tr>';212 '</td><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.($Row['Value'] * $Row['ValueSign']).'</td></tr>'; 213 213 $Total += $Row['Value']; 214 214 } … … 227 227 $DbResult = $this->Database->query('SELECT *, (SELECT GROUP_CONCAT(Description SEPARATOR ",") FROM FinanceInvoiceItem WHERE FinanceInvoiceItem.FinanceInvoice = FinanceInvoice.Id) AS Text '. 228 228 'FROM FinanceInvoice JOIN Subject ON Subject.Id = FinanceInvoice.Subject '. 229 'WHERE ( Direction = -1) AND (FinanceInvoice.Time >= "'.$Year['DateStart'].229 'WHERE (ValueSign = -1) AND (FinanceInvoice.Time >= "'.$Year['DateStart']. 230 230 '") AND (FinanceInvoice.Time <= "'.$Year['DateEnd'].'") ORDER BY Time'); 231 231 while($Row = $DbResult->fetch_array()) … … 234 234 $Row['Value'] = $Row['Value'] * -1; 235 235 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillCode']. 236 '</td><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.($Row['Value'] * $Row[' Direction']).'</td></tr>';236 '</td><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.($Row['Value'] * $Row['ValueSign']).'</td></tr>'; 237 237 $Total += $Row['Value']; 238 238 } … … 245 245 $Output .= '<tr><th>Jméno</th><th>Závazky [Kč]</th><th>Pohledávky [Kč]</th><th>Příjmy [Kč]</th><th>Výdaje [Kč]</th><th>Stav účtu</th><th>Starý systém</th></tr>'; 246 246 $DbResult = $this->Database->query('SELECT Id, Name, 0 AS Cash, '. 247 '(SELECT SUM(T1.Value*T1. Direction) FROM FinanceInvoice AS T1 WHERE (T1.Subject = Subject.Id) AND (T1.Direction = 1)) as Claims, '.248 '(SELECT SUM(T2.Value*T2. Direction) FROM FinanceInvoice AS T2 WHERE (T2.Subject = Subject.Id) AND (T2.Direction = 1) AND (TimePayment IS NULL)) as OpenedClaims, '.249 '(SELECT -SUM(T3.Value*T3. Direction) FROM FinanceInvoice AS T3 WHERE (T3.Subject = Subject.Id) AND (T3.Direction = -1)) as Liabilities, '.250 '(SELECT -SUM(T4.Value*T4. Direction) FROM FinanceInvoice AS T4 WHERE (T4.Subject = Subject.Id) AND (T4.Direction = -1) AND (TimePayment IS NULL)) AS OpenedLiabilities, '.251 '(SELECT SUM(T5.Value*T5. Direction) FROM FinanceOperation AS T5 WHERE (T5.Subject = Subject.Id) AND (T5.Direction = 1)) AS Gains, '.252 '(SELECT SUM(T6.Value*T6. Direction) FROM FinanceOperation AS T6 WHERE (T6.Subject = Subject.Id) AND (T6.Direction = -1)) AS Spends '.247 '(SELECT SUM(T1.Value*T1.ValueSign) FROM FinanceInvoice AS T1 WHERE (T1.Subject = Subject.Id) AND (T1.ValueSign = 1)) as Claims, '. 248 '(SELECT SUM(T2.Value*T2.ValueSign) FROM FinanceInvoice AS T2 WHERE (T2.Subject = Subject.Id) AND (T2.ValueSign = 1) AND (TimePayment IS NULL)) as OpenedClaims, '. 249 '(SELECT -SUM(T3.Value*T3.ValueSign) FROM FinanceInvoice AS T3 WHERE (T3.Subject = Subject.Id) AND (T3.ValueSign = -1)) as Liabilities, '. 250 '(SELECT -SUM(T4.Value*T4.ValueSign) FROM FinanceInvoice AS T4 WHERE (T4.Subject = Subject.Id) AND (T4.ValueSign = -1) AND (TimePayment IS NULL)) AS OpenedLiabilities, '. 251 '(SELECT SUM(T5.Value*T5.ValueSign) FROM FinanceOperation AS T5 WHERE (T5.Subject = Subject.Id) AND (T5.ValueSign = 1)) AS Gains, '. 252 '(SELECT SUM(T6.Value*T6.ValueSign) FROM FinanceOperation AS T6 WHERE (T6.Subject = Subject.Id) AND (T6.ValueSign = -1)) AS Spends '. 253 253 'FROM Subject ORDER BY Name'); 254 254 while($Row = $DbResult->fetch_assoc()) … … 280 280 { 281 281 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['Text']. 282 '</td><td>'.($Row['Value']*$Row[' Direction']).'</td><td>'.$Row['BillCode'].'</td></tr>';282 '</td><td>'.($Row['Value']*$Row['ValueSign']).'</td><td>'.$Row['BillCode'].'</td></tr>'; 283 283 } 284 284 $Output .= '</table></td><td style="vertical-align: top;">'; … … 293 293 { 294 294 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.HumanDate($Row['TimePayment']). 295 '</td><td>'.$Row['Text'].'</td><td>'.ceil($Row['Value'] * $Row[' Direction']).'</td><td>'.$Row['BillCode'].'</td></tr>';295 '</td><td>'.$Row['Text'].'</td><td>'.ceil($Row['Value'] * $Row['ValueSign']).'</td><td>'.$Row['BillCode'].'</td></tr>'; 296 296 } 297 297 $Output .= '</table></td></tr></table>'; … … 303 303 while($Row = $DbResult->fetch_array()) 304 304 { 305 $Output .= '<tr><td>'.$Row['Time'].'</td><td>'.$Row['TimePass'].'</td><td>'.$Row[' Direction'].'</td><td>'.($Row['Value']).'</td><td>'.$Row['CashFlowId'].'</td></tr>';305 $Output .= '<tr><td>'.$Row['Time'].'</td><td>'.$Row['TimePass'].'</td><td>'.$Row['ValueSign'].'</td><td>'.($Row['Value']).'</td><td>'.$Row['CashFlowId'].'</td></tr>'; 306 306 } 307 307 $Output .= '</table>';*/ 308 308 309 $DbResult = $this->Database->query('SELECT Id, 0 AS Cash, (SELECT SUM(FinanceInvoice.Value * FinanceInvoice. Direction) '.309 $DbResult = $this->Database->query('SELECT Id, 0 AS Cash, (SELECT SUM(FinanceInvoice.Value * FinanceInvoice.ValueSign) '. 310 310 'FROM FinanceInvoice WHERE (FinanceInvoice.Subject = Subject.Id) AND '. 311 '(FinanceInvoice. Direction = 1)) as Claims, (SELECT SUM(FinanceInvoice.Value * FinanceInvoice.Direction) '.311 '(FinanceInvoice.ValueSign = 1)) as Claims, (SELECT SUM(FinanceInvoice.Value * FinanceInvoice.ValueSign) '. 312 312 'FROM FinanceInvoice WHERE (FinanceInvoice.Subject = Subject.Id) AND ('. 313 'FinanceInvoice. Direction = 1) AND (TimePayment IS NULL)) as OpenedClaims, '.314 '(SELECT SUM(FinanceInvoice.Value * FinanceInvoice. Direction) FROM FinanceInvoice '.315 'WHERE (FinanceInvoice.Subject = Subject.Id) AND (FinanceInvoice. Direction = -1)) AS '.313 'FinanceInvoice.ValueSign = 1) AND (TimePayment IS NULL)) as OpenedClaims, '. 314 '(SELECT SUM(FinanceInvoice.Value * FinanceInvoice.ValueSign) FROM FinanceInvoice '. 315 'WHERE (FinanceInvoice.Subject = Subject.Id) AND (FinanceInvoice.ValueSign = -1)) AS '. 316 316 'Liabilities, (SELECT SUM(FinanceInvoice.Value) FROM FinanceInvoice '. 317 'WHERE (FinanceInvoice.Subject = Subject.Id) AND (FinanceInvoice. Direction = -1) '.317 'WHERE (FinanceInvoice.Subject = Subject.Id) AND (FinanceInvoice.ValueSign = -1) '. 318 318 'AND (TimePayment IS NULL)) AS OpenedLiabilities, '. 319 '(SELECT SUM(FinanceOperation.Value*FinanceOperation. Direction) '.320 'FROM FinanceOperation WHERE FinanceOperation.Subject = Subject.Id AND FinanceOperation. Direction = 1) '.321 'AS Gains, (SELECT SUM(FinanceOperation.Value*FinanceOperation. Direction) FROM FinanceOperation WHERE '.322 'FinanceOperation.Subject = Subject.Id AND FinanceOperation. Direction = -1) as Spends '.319 '(SELECT SUM(FinanceOperation.Value*FinanceOperation.ValueSign) '. 320 'FROM FinanceOperation WHERE FinanceOperation.Subject = Subject.Id AND FinanceOperation.ValueSign = 1) '. 321 'AS Gains, (SELECT SUM(FinanceOperation.Value*FinanceOperation.ValueSign) FROM FinanceOperation WHERE '. 322 'FinanceOperation.Subject = Subject.Id AND FinanceOperation.ValueSign = -1) as Spends '. 323 323 'FROM Subject WHERE Id='.$_GET['Id']); 324 324 $Row = $DbResult->fetch_array();
Note:
See TracChangeset
for help on using the changeset viewer.