Changeset 486 for trunk/finance/zivnost.php
- Timestamp:
- Feb 10, 2013, 9:20:06 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/finance/zivnost.php
r479 r486 11 11 var $StartEvidence = 0; 12 12 13 /*function TransformFinance()14 {15 //$Database->Query('SELECT user as Subject, date as TimeCreation, date as TimeDue, date as TimePayment, -money as Value, bill_id as Bill, comment as Text FROM `finance_operations` WHERE Comment LIKE "Poplatek za měsíc%" AND date >= "2007-12-01"');16 //'TRUNCATE TABLE FinanceCashFlow; INSERT INTO FinanceCashFlow (SELECT '' as Id, user as Subject, comment as Text, date as Time, 1 as Taxable, 0 as Cash, money as Value, bill_id as Bill FROM `finance_operations` WHERE comment NOT LIKE "Poplatek za měsíc%" AND date >= "2007-12-01")'17 // 'UPDATE finance_operations SET date="2007-11-24" WHERE comment="Jednorázový poplatek za společné zařízení"'18 19 $DbResult = $this->Database->query('SELECT * FROM users WHERE role=2');20 while($User = $DbResult->fetch_array())21 {22 $DbResult2 = $this->Database->query('SELECT SUM(money) FROM finance_operations WHERE user='.$User['id'].' AND date < "2007-12-01"');23 $Row = $DbResult2->fetch_array();24 echo($User['second_name'].' '.$User['first_name'].' '.$Row[0].'<br />');25 // if($Row[0] > 0) $Database->insert('FinanceCashFlow', array('Text' => 'Přijatá záloha (z období před účetnictvím)', 'Subject' => $User['id'], 'Time' => '2007-01-01', 'Taxable' => 1, 'Cash' => 0, 'Value' => $Row[0], 'Bill' => 0));26 if($Row[0] < 0)27 {28 $this->Database->insert('FinanceClaimsLiabilities', array('Text' => 'Připojení k síti (z období před účetnictvím)', 'Subject' => $User['id'], 'TimeCreation' => '2007-12-01', 'TimeDue' => '2007-12-14', 'TimePayment' => '', 'Value' => (-$Row[0]), 'Bill' => 0));29 //echo($Database->LastQuery.'<br />');30 }31 }32 }*/33 13 function GetTimePeriodBalance($StartTime, $EndTime) 34 14 { … … 50 30 $Balance['Spend']['End'] = $Row[0] + 0; 51 31 52 $DbResult = $this->Database->query('SELECT SUM(Value) FROM Finance ClaimsLiabilitiesWHERE (TimeCreation < "'.TimeToMysqlDateTime($StartTime).'") AND (TimeCreation >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Value > 0)');32 $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceInvoice WHERE (TimeCreation < "'.TimeToMysqlDateTime($StartTime).'") AND (TimeCreation >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Value > 0)'); 53 33 $Row = $DbResult->fetch_array(); 54 34 $Balance['Claims']['Start'] = $Row[0] + 0; 55 $DbResult = $this->Database->query('SELECT SUM(Value) FROM Finance ClaimsLiabilitiesWHERE (TimeCreation <= "'.TimeToMysqlDateTime($EndTime).'") AND (TimeCreation >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Value > 0)');35 $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceInvoice WHERE (TimeCreation <= "'.TimeToMysqlDateTime($EndTime).'") AND (TimeCreation >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Value > 0)'); 56 36 $Row = $DbResult->fetch_array(); 57 37 $Balance['Claims']['End'] = $Row[0] + 0; 58 38 59 $DbResult = $this->Database->query('SELECT SUM(-Value) FROM Finance ClaimsLiabilitiesWHERE (TimeCreation < "'.TimeToMysqlDateTime($StartTime).'") AND (TimeCreation >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Value < 0)');39 $DbResult = $this->Database->query('SELECT SUM(-Value) FROM FinanceInvoice WHERE (TimeCreation < "'.TimeToMysqlDateTime($StartTime).'") AND (TimeCreation >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Value < 0)'); 60 40 $Row = $DbResult->fetch_array(); 61 41 $Balance['Liabilities']['Start'] = $Row[0] + 0; 62 $DbResult = $this->Database->query('SELECT SUM(-Value) FROM Finance ClaimsLiabilitiesWHERE (TimeCreation <= "'.TimeToMysqlDateTime($EndTime).'") AND (TimeCreation >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Value < 0)');42 $DbResult = $this->Database->query('SELECT SUM(-Value) FROM FinanceInvoice WHERE (TimeCreation <= "'.TimeToMysqlDateTime($EndTime).'") AND (TimeCreation >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Value < 0)'); 63 43 $Row = $DbResult->fetch_array(); 64 44 $Balance['Liabilities']['End'] = $Row[0] + 0; … … 227 207 $Output .= '<table style="font-size: smaller;" class="WideTable">'; 228 208 $Output .= '<tr><th>Čas vystavení</th><th>Kód</th><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th></tr>'; 229 $DbResult = $this->Database->query('SELECT * FROM FinanceClaimsLiabilities JOIN Subject ON Subject.Id = FinanceClaimsLiabilities.Subject '. 230 'WHERE (Value > 0) AND (FinanceClaimsLiabilities.TimeCreation >= "'.$Year['DateStart'].'") AND (FinanceClaimsLiabilities.TimeCreation <= "'.$Year['DateEnd'].'") ORDER BY TimeCreation'); 209 $DbResult = $this->Database->query('SELECT *, (SELECT GROUP_CONCAT(Description SEPARATOR ",") FROM FinanceInvoiceItem WHERE FinanceInvoiceItem.FinanceInvoice = FinanceInvoice.Id) AS Text '. 210 'FROM FinanceInvoice JOIN Subject ON Subject.Id = FinanceInvoice.Subject '. 211 'WHERE (Value > 0) AND (FinanceInvoice.TimeCreation >= "'.$Year['DateStart']. 212 '") AND (FinanceInvoice.TimeCreation <= "'.$Year['DateEnd'].'") ORDER BY TimeCreation'); 231 213 while($Row = $DbResult->fetch_array()) 232 214 { … … 247 229 $Output .= '<table style="font-size: smaller;" class="WideTable">'; 248 230 $Output .= '<tr><th>Čas vystavení</th><th>Kód</th><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th></tr>'; 249 $DbResult = $this->Database->query('SELECT * FROM FinanceClaimsLiabilities JOIN Subject ON Subject.Id = FinanceClaimsLiabilities.Subject '. 250 'WHERE (Value < 0) AND (FinanceClaimsLiabilities.TimeCreation >= "'.$Year['DateStart'].'") AND (FinanceClaimsLiabilities.TimeCreation <= "'.$Year['DateEnd'].'") ORDER BY TimeCreation'); 231 $DbResult = $this->Database->query('SELECT *, (SELECT GROUP_CONCAT(Description SEPARATOR ",") FROM FinanceInvoiceItem WHERE FinanceInvoiceItem.FinanceInvoice = FinanceInvoice.Id) AS Text '. 232 'FROM FinanceInvoice JOIN Subject ON Subject.Id = FinanceInvoice.Subject '. 233 'WHERE (Value < 0) AND (FinanceInvoice.TimeCreation >= "'.$Year['DateStart']. 234 '") AND (FinanceInvoice.TimeCreation <= "'.$Year['DateEnd'].'") ORDER BY TimeCreation'); 251 235 while($Row = $DbResult->fetch_array()) 252 236 { … … 264 248 $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>'; 265 249 $DbResult = $this->Database->query('SELECT Id, Name, 0 AS Cash, '. 266 '(SELECT SUM(T1.Value) FROM Finance ClaimsLiabilitiesAS T1 WHERE (T1.Subject = Subject.Id) AND (T1.Value > 0)) as Claims, '.267 '(SELECT SUM(T2.Value) FROM Finance ClaimsLiabilitiesAS T2 WHERE (T2.Subject = Subject.Id) AND (T2.Value > 0) AND (TimePayment IS NULL)) as OpenedClaims, '.268 '(SELECT -SUM(T3.Value) FROM Finance ClaimsLiabilitiesAS T3 WHERE (T3.Subject = Subject.Id) AND (T3.Value < 0)) as Liabilities, '.269 '(SELECT -SUM(T4.Value) FROM Finance ClaimsLiabilitiesAS T4 WHERE (T4.Subject = Subject.Id) AND (T4.Value < 0) AND (TimePayment IS NULL)) AS OpenedLiabilities, '.250 '(SELECT SUM(T1.Value) FROM FinanceInvoice AS T1 WHERE (T1.Subject = Subject.Id) AND (T1.Value > 0)) as Claims, '. 251 '(SELECT SUM(T2.Value) FROM FinanceInvoice AS T2 WHERE (T2.Subject = Subject.Id) AND (T2.Value > 0) AND (TimePayment IS NULL)) as OpenedClaims, '. 252 '(SELECT -SUM(T3.Value) FROM FinanceInvoice AS T3 WHERE (T3.Subject = Subject.Id) AND (T3.Value < 0)) as Liabilities, '. 253 '(SELECT -SUM(T4.Value) FROM FinanceInvoice AS T4 WHERE (T4.Subject = Subject.Id) AND (T4.Value < 0) AND (TimePayment IS NULL)) AS OpenedLiabilities, '. 270 254 '(SELECT SUM(T5.Value) FROM FinanceOperation AS T5 WHERE (T5.Subject = Subject.Id) AND (T5.Value > 0)) AS Gains, '. 271 255 '(SELECT -SUM(T6.Value) FROM FinanceOperation AS T6 WHERE (T6.Subject = Subject.Id) AND (T6.Value < 0)) AS Spends '. … … 306 290 $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'; 307 291 $Output .= '<tr><th>Datum vytvoření</th><th>Datum zaplacení</th><th>Název</th><th>Hodnota [Kč]</th><th>Doklad</th></tr>'; 308 $DbResult = $this->Database->select('Finance ClaimsLiabilities', '*', 'Subject='.$_GET['Id'].' ORDER BY TimeCreation');292 $DbResult = $this->Database->select('FinanceInvoice', '*, (SELECT GROUP_CONCAT(Description SEPARATOR ",") FROM FinanceInvoiceItem WHERE FinanceInvoiceItem.FinanceInvoice = FinanceInvoice.Id) AS Text', 'Subject='.$_GET['Id'].' ORDER BY TimeCreation'); 309 293 while($Row = $DbResult->fetch_array()) 310 294 { … … 324 308 $Output .= '</table>';*/ 325 309 326 $DbResult = $this->Database->query('SELECT Id, 0 AS Cash, (SELECT SUM(Finance ClaimsLiabilities.Value) '.327 'FROM Finance ClaimsLiabilities WHERE FinanceClaimsLiabilities.Subject = Subject.Id AND '.328 'Finance ClaimsLiabilities.Value > 0) as Claims, (SELECT SUM(FinanceClaimsLiabilities.Value) '.329 'FROM Finance ClaimsLiabilities WHERE FinanceClaimsLiabilities.Subject = Subject.Id AND '.330 'Finance ClaimsLiabilities.Value > 0 AND TimePayment IS NULL) as OpenedClaims, '.331 '(SELECT SUM(Finance ClaimsLiabilities.Value) FROM FinanceClaimsLiabilities'.332 'WHERE Finance ClaimsLiabilities.Subject = Subject.Id AND FinanceClaimsLiabilities.Value < 0) AS '.333 'Liabilities, (SELECT SUM(Finance ClaimsLiabilities.Value) FROM FinanceClaimsLiabilities'.334 'WHERE Finance ClaimsLiabilities.Subject = Subject.Id AND FinanceClaimsLiabilities.Value < 0 '.310 $DbResult = $this->Database->query('SELECT Id, 0 AS Cash, (SELECT SUM(FinanceInvoice.Value) '. 311 'FROM FinanceInvoice WHERE FinanceInvoice.Subject = Subject.Id AND '. 312 'FinanceInvoice.Value > 0) as Claims, (SELECT SUM(FinanceInvoice.Value) '. 313 'FROM FinanceInvoice WHERE FinanceInvoice.Subject = Subject.Id AND '. 314 'FinanceInvoice.Value > 0 AND TimePayment IS NULL) as OpenedClaims, '. 315 '(SELECT SUM(FinanceInvoice.Value) FROM FinanceInvoice '. 316 'WHERE FinanceInvoice.Subject = Subject.Id AND FinanceInvoice.Value < 0) AS '. 317 'Liabilities, (SELECT SUM(FinanceInvoice.Value) FROM FinanceInvoice '. 318 'WHERE FinanceInvoice.Subject = Subject.Id AND FinanceInvoice.Value < 0 '. 335 319 'AND TimePayment IS NULL) as OpenedLiabilities, (SELECT SUM(FinanceOperation.Value) '. 336 320 'FROM FinanceOperation WHERE FinanceOperation.Subject = Subject.Id AND FinanceOperation.Value > 0) '.
Note:
See TracChangeset
for help on using the changeset viewer.