Changeset 167 for www/finance
- Timestamp:
- Mar 24, 2009, 11:44:03 AM (16 years ago)
- Location:
- www/finance
- Files:
-
- 3 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
www/finance/clenove.php
r164 r167 10 10 { 11 11 $Finance = $this->System->Modules['Finance']; 12 $this->System->Modules['Finance']->RecalculateTariffs(1);13 if(!$this->System->Modules['User']->CheckPermission('Finance', 'SubjectList')) return('Nemáte oprávnění');12 $this->System->Modules['Finance']->RecalculateTariffs(1); 13 if(!$this->System->Modules['User']->CheckPermission('Finance', 'SubjectList')) return('Nemáte oprávnění'); 14 14 15 15 // Seznam členů 16 16 $Output = 'Seznam účastníků:<br>'. 17 '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'.18 '<tr><th> JZástupce</th><th>Subjekt</th>';17 '<table class="WideTable">'. 18 '<tr><th>Zástupce</th><th>Subjekt</th>'; 19 19 //<th>Cena za zařízení [Kč]</th> 20 $Output .= '<th>Měsíční poplatek [Kč]</th><th>Stav účtu [Kč]</th><th>Běžící tarif</th><th>Příští tarif</th>< th>Poznámky</th></tr>';20 $Output .= '<th>Měsíční poplatek [Kč]</th><th>Stav účtu [Kč]</th><th>Běžící tarif</th><th>Příští tarif</th></tr>'; 21 21 $TotalDevice = 0; 22 22 $TotalMonth = 0; 23 23 $TotalCash = 0; 24 $DbResult = $this->Database->query('SELECT MonthlyTotal, Cash, Subject.Id, Subject.Name, NetworkDevice, InternetTariffCurrentMonth, InternetTariffNextMonth, CONCAT(User.SecondName, " ", User.FirstName) AS FullName FROM MemberPayment JOIN Member ON Member.Id=MemberPayment.MemberJOIN Subject ON Subject.Id=Member.Subject JOIN User ON User.Id=Member.ResponsibleUser ORDER BY FullName');24 $DbResult = $this->Database->query('SELECT MonthlyTotal, Cash, Subject.Id, Subject.Name, NetworkDevice, InternetTariffCurrentMonth, InternetTariffNextMonth, CONCAT(User.SecondName, " ", User.FirstName) AS FullName FROM MemberPayment LEFT JOIN Member ON Member.Id=MemberPayment.Member LEFT JOIN Subject ON Subject.Id=Member.Subject JOIN User ON User.Id=Member.ResponsibleUser ORDER BY FullName'); 25 25 while($Row = $DbResult->fetch_assoc()) 26 26 { … … 38 38 $Output .= '<tr><td><strong>Celkem</strong></td><td> </td>'; 39 39 //<td align="right"><strong>'.$TotalDevice.'</strong></td> 40 $Output .= '<td align="right"><strong>'.$TotalMonth.'</strong></td><td align="right"><strong>'.$TotalCash.'</strong></td><td align="right"> </td><td align="right"> </td>< td align="right"> </td></tr>';40 $Output .= '<td align="right"><strong>'.$TotalMonth.'</strong></td><td align="right"><strong>'.$TotalCash.'</strong></td><td align="right"> </td><td align="right"> </td></tr>'; 41 41 $Output .= '</table>'; 42 42 return($Output); -
www/finance/index.php
r163 r167 10 10 { 11 11 $Finance = $this->System->Modules['Finance']; 12 $Output = '<table><tr><td valign="top">'; 13 14 if(GetMemberByIP(GetRemoteAddress()) > 0) $Output .= '<a href="user_state_ip.php?old">Vaše finanční operace</a> (Tato volba je také přístupná po přihlášení do systému v uživatelském menu).<br /><br /><br />'; 12 $Output = '<table><tr><td valign="top">'; 13 if(GetMemberByIP(GetRemoteAddress()) > 0) $Output .= '<a href="user_state.php?old">Vaše finanční operace</a> (Tato volba je také přístupná po přihlášení do systému v uživatelském menu).<br /><br /><br />'; 15 14 16 15 $Output .= '<a href="monthly_overall.php">Měsíční přehledy</a><br />'; … … 63 62 64 63 $Output .= 'Měsíční vyúčtování:<br /> 65 <table border="1" cellspacing="0" cellpadding="3">64 <table class="WideTable"> 66 65 <tr><th>Položka</th><th>Cena [Kč]</th></tr> 67 66 <tr><th colspan="2">Příjmy</th></tr>'; -
www/finance/manage.php
r165 r167 381 381 function ConvertData() 382 382 { 383 $Output = ''; 384 $this->Database->query('TRUNCATE TABLE FinanceOperation'); 383 $Finance = $this->System->Modules['Finance']; 384 $Output = ''; 385 $this->Database->query('TRUNCATE TABLE FinanceOperation'); 386 $this->Database->query('TRUNCATE TABLE FinanceClaimsLiabilities'); 385 387 386 388 // Move time of device price transformation … … 388 390 389 391 // Transform old operations 390 $DbResult = $this->Database->query('SELECT * FROM finance_operations WHERE finance_operations.date >= "2007-12-01"'); 391 while($DbRow = $DbResult->fetch_assoc()) 392 { 393 $this->Database->insert('FinanceOperation', array('Id' => $DbRow['id'], 'SourceSubject' => $DbRow['Source'], 'DestinationSubject' => $DbRow['Destination'], 'Value' => abs($DbRow['money']), 'Time' => $DbRow['date'], 'BillCode' => $DbRow['BillCode'], 'Taxable' => $DbRow['Taxable'], 'Text' => $DbRow['comment'], 'Bill' => $DbRow['bill_id'])); 394 $Output .= '.'; 395 } 392 $DbResult = $this->Database->query('SELECT * FROM finance_operations WHERE finance_operations.date >= "2007-12-01" AND (Source = '.$Finance->ExternalSubject.')'); 393 while($DbRow = $DbResult->fetch_assoc()) 394 { 395 $this->Database->insert('FinanceOperation', array('Id' => $DbRow['id'], 'Subject' => $DbRow['Destination'], 'Cash' => $DbRow['cash'], 'Value' => abs($DbRow['money']), 'Time' => $DbRow['date'], 'BillCode' => $DbRow['BillCode'], 'Taxable' => $DbRow['Taxable'], 'Text' => $DbRow['comment'], 'Bill' => $DbRow['bill_id'])); 396 $Output .= '.'; 397 } 398 $DbResult = $this->Database->query('SELECT * FROM finance_operations WHERE finance_operations.date >= "2007-12-01" AND (Destination = '.$Finance->ExternalSubject.')'); 399 while($DbRow = $DbResult->fetch_assoc()) 400 { 401 $this->Database->insert('FinanceOperation', array('Id' => $DbRow['id'], 'Subject' => $DbRow['Source'], 'Cash' => $DbRow['cash'], 'Value' => -abs($DbRow['money']), 'Time' => $DbRow['date'], 'BillCode' => $DbRow['BillCode'], 'Taxable' => $DbRow['Taxable'], 'Text' => $DbRow['comment'], 'Bill' => $DbRow['bill_id'])); 402 $Output .= '.'; 403 } 404 405 // Transform old invoices 406 $DbResult = $this->Database->query('SELECT * FROM finance_operations WHERE finance_operations.date >= "2007-12-01" AND (Source = '.$Finance->MainSubject.')'); 407 while($DbRow = $DbResult->fetch_assoc()) 408 { 409 $this->Database->insert('FinanceClaimsLiabilities', array('Id' => $DbRow['id'], 'Subject' => $DbRow['Destination'], 'Value' => -abs($DbRow['money']), 'TimeCreation' => $DbRow['date'], 'BillCode' => $DbRow['BillCode'], 'Text' => $DbRow['comment'], 'Bill' => $DbRow['bill_id'])); 410 $Output .= 'FV '.$DbRow['comment'].'<br />'; 411 } 412 $DbResult = $this->Database->query('SELECT * FROM finance_operations WHERE finance_operations.date >= "2007-12-01" AND (Destination = '.$Finance->MainSubject.')'); 413 while($DbRow = $DbResult->fetch_assoc()) 414 { 415 $this->Database->insert('FinanceClaimsLiabilities', array('Id' => $DbRow['id'], 'Subject' => $DbRow['Source'], 'Value' => abs($DbRow['money']), 'TimeCreation' => $DbRow['date'], 'BillCode' => $DbRow['BillCode'], 'Text' => $DbRow['comment'], 'Bill' => $DbRow['bill_id'])); 416 $Output .= 'FP '.$DbRow['comment'].'<br />'; 417 } 396 418 397 419 // Transfer finance before era … … 402 424 $DbRow2 = $DbResult2->fetch_assoc(); 403 425 404 if($DbRow2['money'] > 0) 405 { 406 $DestinationSubject = $Subject['Id']; 407 $SourceSubject = 96; 408 $Comment = 'Přijatá záloha (z období před daňovou evidencí)'; 409 } else 410 { 411 $DestinationSubject = 71; 412 $SourceSubject = $Subject['Id']; 413 $Comment = 'Připojení k síti (z období před daňovou evidencí)'; 414 } 415 $DbRow2['date'] = TimeToMysqlDateTime(mktime(0, 0, 0, 12, 1, 2007)); 416 $this->Database->insert('FinanceOperation', array('SourceSubject' => $SourceSubject, 'DestinationSubject' => $DestinationSubject, 'Value' => abs($DbRow2['money']), 'Time' => $DbRow2['date'], 'Taxable' => 1, 'Text' => $Comment)); 417 $Output .= '#'; 426 $DbRow2['date'] = TimeToMysqlDateTime(mktime(0, 0, 0, 12, 1, 2007)); 427 if($DbRow2['money'] > 0) 428 { 429 $Comment = 'Přijatá záloha (z období před daňovou evidencí)'; 430 $this->Database->insert('FinanceOperation', array('Subject' => $Subject['Id'], 'Cash' => 0, 'Value' => abs($DbRow2['money']), 'Time' => $DbRow2['date'], 'Taxable' => 1, 'Text' => $Comment)); 431 } else 432 { 433 $Comment = 'Připojení k síti (z období před daňovou evidencí)'; 434 $this->Database->insert('FinanceClaimsLiabilities', array('Subject' => $Subject['Id'], 'Value' => abs($DbRow2['money']), 'TimeCreation' => $DbRow2['date'], 'Text' => $Comment)); 435 } 436 $Output .= '#'; 418 437 } 419 438 -
www/finance/prepocet.php
r164 r167 11 11 $Finance = &$this->System->Modules['Finance']; 12 12 $Output = 'Aktualizuju finance uživatelů...<br />'; 13 $this->Database->query('TRUNCATE TABLE MemberPayment');13 $this->Database->query('TRUNCATE TABLE MemberPayment'); 14 14 $DbResult = $this->Database->query('SELECT * FROM Member'); 15 15 while($Member = $DbResult->fetch_assoc()) 16 16 { 17 $DbResult2 = $this->Database->query('SELECT ((SELECT COALESCE(SUM(Value), 0) FROM Finance CashFlowWHERE Subject='.$Member['Subject'].') + (SELECT COALESCE(SUM(-Value), 0) FROM FinanceClaimsLiabilities WHERE Subject='.$Member['Subject'].')) as Cash');17 $DbResult2 = $this->Database->query('SELECT ((SELECT COALESCE(SUM(Value), 0) FROM FinanceOperation WHERE Subject='.$Member['Subject'].') + (SELECT COALESCE(SUM(-Value), 0) FROM FinanceClaimsLiabilities WHERE Subject='.$Member['Subject'].')) as Cash'); 18 18 $Cash = $DbResult2->fetch_row(); 19 $Cash = $Cash[0];19 $Cash = $Cash[0]; 20 20 21 21 $DbResult2 = $this->Database->query('SELECT SUM(consumption) FROM network_devices WHERE user='.$Member['Id'].' AND used=1'); 22 22 $ConsumptionPlus = $DbResult2->fetch_row(); 23 $ConsumptionPlus = $ConsumptionPlus[0];23 $ConsumptionPlus = $ConsumptionPlus[0]; 24 24 25 25 $NetworkDevice = 0; … … 39 39 $MonthlyInet = $Finance->Tarify[$Member['InternetTariffNextMonth']]['price']; 40 40 //if($Row['inet'] == 1) 41 $Monthly += $MonthlyInet;41 $Monthly += $MonthlyInet; 42 42 $Monthly -= $Finance->W2Kc($ConsumptionPlus); 43 43 //if($Row['overheads'] == 1) $Monthly += $Sprava; // + W2Kc($Consumption); … … 196 196 $BillCode = $Finance->GetNextDocumentLineNumber(6); // Faktury vydané 197 197 $BillId = $this->System->Modules['Bill']->CreateBill($User['Id'], array(array('Description' => 'Připojení k síti', 'Price' => $PayPerPeriod, 'Quantity' => 1)), $PeriodFrom, $PeriodTo, $BillCode); 198 $this->Database->insert(' finance_operations', array('money' => -$PayPerPeriod, 'user' => $User['Id'], 'type' => 2, 'date' => 'NOW()', 'comment' => 'Připojení k síti za období '.$TimePeriodText, 'group' => 1, 'bill_id' => $BillId, 'BillCode' => $BillCode));198 $this->Database->insert('FinanceClaimsLiabilities', array('Value' => $PayPerPeriod, 'Subject' => $User['Id'], 'TimeCreation' => 'NOW()', 'Text' => 'Připojení k síti za období '.$TimePeriodText, 'Bill' => $BillId, 'BillCode' => $BillCode)); 199 199 } else $Output .= ("<br />"); 200 200 } -
www/finance/spotreba.php
r157 r167 9 9 function Show() 10 10 { 11 global $kWh;11 $Finance = $this->System->Modules['Finance']; 12 12 13 13 // Seznam segmentů a zařízení 14 $Output = 'Spotřeba zařízení jednotlivých segmentů:< br /><table border="1" cellspacing="0" cellpadding="3"><tr><th>Jméno segmentu</th><th>Spotřeba [W]</th><th>Cena [Kč/měsíc]</th></tr>';14 $Output = 'Spotřeba zařízení jednotlivých segmentů:<div align="center"><table class="WideTable"><tr><th>Jméno segmentu</th><th>Spotřeba [W]</th><th>Cena [Kč/měsíc]</th></tr>'; 15 15 $CelkovaSpotreba = 0; 16 16 $DbResult = $this->Database->query("SELECT * FROM network_segments"); … … 23 23 } 24 24 $Output .= '<tr style="font-weight: Bold;"><td><strong>Celkem</strong></td><td align="right">'.$CelkovaSpotreba.'</td><td align="right">'.$this->System->Modules['Finance']->W2Kc($CelkovaSpotreba).'</td></tr>'; 25 $Output .= '</table>< br />';26 $Output .= 'Dohodnutá cena za jednu kWh: <strong>'.$ kWh.' Kč</strong><br />';25 $Output .= '</table></div>'; 26 $Output .= 'Dohodnutá cena za jednu kWh: <strong>'.$Finance->kWh.' Kč</strong><br />'; 27 27 return($Output); 28 28 } -
www/finance/user_state.php
r165 r167 29 29 $DbResult = $this->Database->query('SELECT Id FROM Subject WHERE Id=(SELECT Subject FROM Member WHERE Id=(SELECT Member FROM User WHERE Id='.$UserId.'))'); 30 30 $Subject = $DbResult->fetch_assoc(); 31 $DbResult = $this->Database->query('SELECT * FROM Member JOIN MemberPayment ON MemberPayment.Member=Member.Id WHERE Member.Id=(SELECT Member FROM User WHERE User.Id='.$UserId.')');31 $DbResult = $this->Database->query('SELECT * FROM Member LEFT JOIN MemberPayment ON MemberPayment.Member=Member.Id WHERE Member.Id=(SELECT Member FROM User WHERE User.Id='.$UserId.')'); 32 32 $Member = $DbResult->fetch_assoc(); 33 33 $TarifName = $Finance->Tarify[$Member['InternetTariffCurrentMonth']]['name']; … … 41 41 $Output .= '<table style="font-size: smaller;" class="WideTable"><tr><th>Datum</th><th>Popis</th><th>Částka</th><th>Doklad</th></tr>'; 42 42 $Operations = array(); 43 $DbResult = $this->Database->query('(SELECT Time, Value, Text, Bill FROM FinanceOperation WHERE (DestinationSubject='.$Subject['Id'].') AND (SourceSubject = '.$Finance->ExternalSubject.')) UNION ALL '. 44 '(SELECT Time, -Value as Value, Text, Bill FROM FinanceOperation WHERE (SourceSubject='.$Subject['Id'].') AND (DestinationSubject='.$Finance->MainSubject.')) UNION ALL '. 45 '(SELECT Time, -Value as Value, Text, Bill FROM FinanceOperation WHERE (SourceSubject='.$Subject['Id'].') AND (DestinationSubject='.$Finance->ExternalSubject.')) UNION ALL '. 46 '(SELECT Time, Value, Text, Bill FROM FinanceOperation WHERE (DestinationSubject='.$Subject['Id'].') AND (SourceSubject = '.$Finance->MainSubject.')) '. 47 'ORDER BY Time DESC'); 43 $UserOperationTableQuery = '((SELECT Text, Time, Value AS Value, Bill FROM FinanceOperation WHERE (Subject='.$Subject['Id'].')) UNION ALL '. 44 '(SELECT Text, TimeCreation as Time, -Value as Value, Bill FROM FinanceClaimsLiabilities WHERE (Subject='.$Subject['Id'].')) ORDER BY Time DESC) AS T1'; 45 $DbResult = $this->Database->query('SELECT T1.* FROM '.$UserOperationTableQuery); 48 46 while($DbRow = $DbResult->fetch_array()) 49 47 $Operations[] = $DbRow; … … 57 55 //echo('<tr><td> </td><td>-'.$Row2['network_device'].'</td><td>Proměnná cena za zařízení</td></tr> 58 56 $Output .= '</table>'; 59 $DbResult = $this->Database->query('SELECT ('. 60 '(SELECT COALESCE(SUM(Value), 0) FROM FinanceOperation WHERE (DestinationSubject='.$Subject['Id'].') AND (SourceSubject = '.$Finance->ExternalSubject.')) - '. 61 '(SELECT COALESCE(SUM(Value), 0) FROM FinanceOperation WHERE (SourceSubject='.$Subject['Id'].') AND (DestinationSubject='.$Finance->MainSubject.')) - '. 62 '(SELECT COALESCE(SUM(Value), 0) FROM FinanceOperation WHERE (SourceSubject='.$Subject['Id'].') AND (DestinationSubject = '.$Finance->ExternalSubject.')) + '. 63 '(SELECT COALESCE(SUM(Value), 0) FROM FinanceOperation WHERE (DestinationSubject='.$Subject['Id'].') AND (SourceSubject='.$Finance->MainSubject.'))) as Total'); 57 $DbResult = $this->Database->query('SELECT SUM(T1.Value) AS Total FROM '.$UserOperationTableQuery); 64 58 $DbRow = $DbResult->fetch_array(); 65 59 $Total = $DbRow['Total']; -
www/finance/zarizeni.php
r157 r167 10 10 { 11 11 // Seznam segmentů a zařízení 12 $Output = 'Seznam segmentů a zařízení:<br><table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3"><tr><th>Název</th><th>Spotřeba<br>[W]</th><th>Datum<br>zakoupení</th><th>Cena [Kč]</th></tr>';12 $Output = 'Seznam segmentů a zařízení:<br><table style="font-size: smaller;" class="WideTable"><tr><th>Název</th><th>Spotřeba<br>[W]</th><th>Datum<br>zakoupení</th><th>Cena [Kč]</th></tr>'; 13 13 $DbResult = $this->Database->query("SELECT * FROM network_segments"); 14 14 while($Row = $DbResult->fetch_array()) 15 15 { 16 $Output .= '<tr><td colspan="3"><strong>Segment: '.$Row['name'].' ('.$Row['users'].')</strong></td><td style="font-weight: Bold;" align="right">'.$Row['price'].'</td></tr>';16 $Output .= '<tr><td style="text-align: left" colspan="3"><strong>Segment: '.$Row['name'].' ('.$Row['users'].')</strong></td><td style="font-weight: Bold;" align="right">'.$Row['price'].'</td></tr>'; 17 17 $DbResult2 = $this->Database->query("SELECT * FROM network_devices WHERE segment=".$Row['id']." AND used=1"); 18 18 while($Row = $DbResult2->fetch_array()) 19 19 { 20 $Output .= '<tr><td >'.$Row['name'].'</td><td align="right">'.$Row['consumption'].'</td><td align="right">'.HumanDate($Row['date']).'</td><td align="right">'.$Row['price'].'</td></tr>';20 $Output .= '<tr><td style="text-align: left; padding-left: 20px;">'.$Row['name'].'</td><td align="right">'.$Row['consumption'].'</td><td align="right">'.HumanDate($Row['date']).'</td><td align="right">'.$Row['price'].'</td></tr>'; 21 21 } 22 22 } -
www/finance/zivnost.php
r165 r167 33 33 { 34 34 $Balance = array(); 35 $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceOperation WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND ( SourceSubject = '.$this->ExternalSubject.')');35 $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceOperation WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (Value > 0)'); 36 36 $Row = $DbResult->fetch_array(); 37 37 $Balance['Income']['Start'] = $Row[0] + 0; 38 $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceOperation WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND ( SourceSubject = '.$this->ExternalSubject.')');38 $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceOperation WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (Value > 0)'); 39 39 //echo('SELECT SUM(Value) FROM FinanceCashFlow WHERE Time <= "'.TimeToMysqlDateTime($EndTime).'" AND Value > 0 AND Taxable = 1'.'<br />'); 40 40 $Row = $DbResult->fetch_array(); 41 41 $Balance['Income']['End'] = $Row[0] + 0; 42 42 43 $DbResult = $this->Database->query('SELECT SUM( Value) FROM FinanceOperation WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (DestinationSubject = '.$this->ExternalSubject.')');43 $DbResult = $this->Database->query('SELECT SUM(-Value) FROM FinanceOperation WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (Value < 0)'); 44 44 $Row = $DbResult->fetch_array(); 45 45 $Balance['Spend']['Start'] = $Row[0] + 0; 46 $DbResult = $this->Database->query('SELECT SUM( Value) FROM FinanceOperation WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (DestinationSubject = '.$this->ExternalSubject.')');46 $DbResult = $this->Database->query('SELECT SUM(-Value) FROM FinanceOperation WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (Value < 0)'); 47 47 //echo('SELECT -SUM(Value) FROM FinanceCashFlow WHERE Time <= "'.TimeToMysqlDateTime($EndTime).'" AND Value < 0 AND Taxable = 1'.'<br />'); 48 48 $Row = $DbResult->fetch_array(); 49 49 $Balance['Spend']['End'] = $Row[0] + 0; 50 50 51 $DbResult = $this->Database->query('SELECT SUM(Value) FROM Finance Operation WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (DestinationSubject = '.$this->MainSubject.')');51 $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceClaimsLiabilities WHERE (TimeCreation < "'.TimeToMysqlDateTime($StartTime).'") AND (TimeCreation >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Value > 0)'); 52 52 $Row = $DbResult->fetch_array(); 53 53 $Balance['Claims']['Start'] = $Row[0] + 0; 54 $DbResult = $this->Database->query('SELECT SUM(Value) FROM Finance Operation WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (DestinationSubject = '.$this->MainSubject.')');54 $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceClaimsLiabilities WHERE (TimeCreation <= "'.TimeToMysqlDateTime($EndTime).'") AND (TimeCreation >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Value > 0)'); 55 55 $Row = $DbResult->fetch_array(); 56 56 $Balance['Claims']['End'] = $Row[0] + 0; 57 57 58 $DbResult = $this->Database->query('SELECT SUM( Value) FROM FinanceOperation WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (SourceSubject = '.$this->MainSubject.')');58 $DbResult = $this->Database->query('SELECT SUM(-Value) FROM FinanceClaimsLiabilities WHERE (TimeCreation < "'.TimeToMysqlDateTime($StartTime).'") AND (TimeCreation >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Value < 0)'); 59 59 $Row = $DbResult->fetch_array(); 60 60 $Balance['Liabilities']['Start'] = $Row[0] + 0; 61 $DbResult = $this->Database->query('SELECT SUM( Value) FROM FinanceOperation WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (SourceSubject = '.$this->MainSubject.')');61 $DbResult = $this->Database->query('SELECT SUM(-Value) FROM FinanceClaimsLiabilities WHERE (TimeCreation <= "'.TimeToMysqlDateTime($EndTime).'") AND (TimeCreation >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Value < 0)'); 62 62 $Row = $DbResult->fetch_array(); 63 63 $Balance['Liabilities']['End'] = $Row[0] + 0; … … 71 71 $Row = $DbResult->fetch_array(); 72 72 $Balance['SmallAssets']['End'] = $Row[0] + 0; 73 return($Balance);73 return($Balance); 74 74 } 75 75 76 76 function Show() 77 77 { 78 if(!$this->System->Modules['User']->CheckPermission('Finance', 'TradingStatus')) return('Nemáte oprávnění'); 78 79 $this->System->Modules['Finance']->RecalculateTariffs(1); 79 80 //TransformFinance(); … … 157 158 case 'CashFlow': 158 159 $Table = array('Ne', 'Ano'); 159 $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">';160 $Output .= '<table style="font-size: smaller;" class="WideTable">'; 160 161 $Output .= '<tr><th>Čas</th><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th><th>Daňový</th><th>Hotovost</th></tr>'; 161 $DbResult = $this->Database->query('SELECT * FROM FinanceCashFlow JOIN Subject ON Subject.Id = FinanceCashFlow.Subject ORDER BY Time'); 162 while($Row = $DbResult->fetch_array()) 163 { 162 $DbResult = $this->Database->query('SELECT * FROM FinanceOperation LEFT JOIN Subject ON Subject.Id = FinanceOperation.Subject ORDER BY Time'); 163 while($Row = $DbResult->fetch_array()) 164 { 165 $Row['Time'] = explode(' ', $Row['Time']); 166 $Row['Time'] = $Row['Time'][0]; 164 167 $Output .= '<tr><td>'.$Row['Time'].'</td><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].'</td><td>'.$Table[$Row['Taxable']].'</td><td>'.$Table[$Row['Cash']].'</td></tr>'; 165 168 } … … 169 172 $Output .= '<table width="100%"><tr><td valign="top">'; 170 173 $Output .= '<strong>Pohledávky</strong>'; 171 $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">';174 $Output .= '<table style="font-size: smaller;" class="WideTable">'; 172 175 $Output .= '<tr><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th><th>Čas vystavení</th><th>Čas splatnosti</th><th>Čas uhrazení</th></tr>'; 173 176 $DbResult = $this->Database->query('SELECT * FROM FinanceClaimsLiabilities JOIN Subject ON Subject.Id = FinanceClaimsLiabilities.Subject WHERE Value > 0 ORDER BY TimeCreation'); … … 180 183 181 184 $Output .= '<strong>Závazky</strong>'; 182 $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">';185 $Output .= '<table style="font-size: smaller;" class="WideTable">'; 183 186 $Output .= '<tr><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th><th>Čas vystavení</th><th>Čas splatnosti</th><th>Čas uhrazení</th></tr>'; 184 187 $DbResult = $this->Database->query('SELECT * FROM FinanceClaimsLiabilities JOIN Subject ON Subject.Id = FinanceClaimsLiabilities.Subject WHERE Value < 0 ORDER BY TimeCreation');
Note:
See TracChangeset
for help on using the changeset viewer.