Ignore:
Timestamp:
Mar 5, 2009, 10:16:12 PM (16 years ago)
Author:
george
Message:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • www/finance/zivnost.php

    r164 r165  
    66  var $FullTitle = 'Daňová evidence';
    77  var $ShortTitle = 'Daňová evidence';
     8  var $ExternalSubject = 96;
     9  var $MainSubject = 71;
     10  var $StartEvidence = 0;
    811
    912  /*function TransformFinance()
     
    2730    }
    2831  }*/
     32  function GetTimePeriodBalance($StartTime, $EndTime)
     33  {
     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.')');
     36    $Row = $DbResult->fetch_array();
     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.')');
     39    //echo('SELECT SUM(Value) FROM FinanceCashFlow WHERE Time <= "'.TimeToMysqlDateTime($EndTime).'" AND Value > 0 AND Taxable = 1'.'<br />');
     40    $Row = $DbResult->fetch_array();
     41    $Balance['Income']['End'] = $Row[0] + 0;
     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.')');
     44    $Row = $DbResult->fetch_array();
     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.')');
     47          //echo('SELECT -SUM(Value) FROM FinanceCashFlow WHERE Time <= "'.TimeToMysqlDateTime($EndTime).'" AND Value < 0 AND Taxable = 1'.'<br />');
     48    $Row = $DbResult->fetch_array();
     49    $Balance['Spend']['End'] = $Row[0] + 0;
     50
     51    $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceOperation WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (DestinationSubject = '.$this->MainSubject.')');
     52    $Row = $DbResult->fetch_array();
     53    $Balance['Claims']['Start'] = $Row[0] + 0;
     54    $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceOperation WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (DestinationSubject = '.$this->MainSubject.')');
     55    $Row = $DbResult->fetch_array();
     56    $Balance['Claims']['End'] = $Row[0] + 0;
     57
     58    $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceOperation WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (SourceSubject = '.$this->MainSubject.')');
     59    $Row = $DbResult->fetch_array();
     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.')');
     62    $Row = $DbResult->fetch_array();
     63    $Balance['Liabilities']['End'] = $Row[0] + 0;
     64
     65    // SmallAssets
     66    $DbResult = $this->Database->query('SELECT SUM(price) FROM network_devices WHERE (TimeEnlistment < "'.TimeToMysqlDateTime($StartTime).'") AND (TimeEnlistment != 0) AND ((TimeElimination > "'.TimeToMysqlDateTime($StartTime).'") OR (TimeElimination = 0))');
     67    //$Output .= $Database->error;
     68    $Row = $DbResult->fetch_array();
     69    $Balance['SmallAssets']['Start'] = $Row[0] + 0;
     70    $DbResult = $this->Database->query('SELECT SUM(price) FROM network_devices WHERE (TimeEnlistment < "'.TimeToMysqlDateTime($EndTime).'") AND (TimeEnlistment != 0) AND ((TimeElimination > "'.TimeToMysqlDateTime($EndTime).'") OR (TimeElimination = 0))');
     71    $Row = $DbResult->fetch_array();
     72    $Balance['SmallAssets']['End'] = $Row[0] + 0;
     73        return($Balance);
     74  }
    2975
    3076  function Show()
     
    3884    {
    3985      case 'AnnualBalance':
    40         $Output = '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">';
    41         $Output .= '<tr><th colspan="3">Účetní období</th><th colspan="5">Na konci</th><th colspan="6">Během</th></tr>';
    42         $Output .= '<tr><th>Rok</th><th>Od</th><th>Do</th><th>Příjmy</th><th>Výdaje</th><th>Pohledávky</th><th>Závazky</th><th>Drobný majetek</th><th>Příjmy</th><th>Výdaje</th><th>Pohledávky</th><th>Závazky</th><th>Drobný majetek</th><th>Základ daně</th></tr>';
    43 
    44         $StartEvidence = mktime(0, 0, 0, 12, 1, 2007);
    45         $StartYear = date('Y', $StartEvidence);
     86        $Output = '<table style="font-size: smaller;" class="WideTable">';
     87        $Output .= '<tr><th colspan="3">Účetní období</th><th colspan="5">Na konci</th><th colspan="6">Během</th></tr>'.
     88                  '<tr><th>Rok</th><th>Od</th><th>Do</th><th>Příjmy</th><th>Výdaje</th><th>Pohledávky</th><th>Závazky</th><th>Drobný majetek</th><th>Příjmy</th><th>Výdaje</th><th>Pohledávky</th><th>Závazky</th><th>Drobný majetek</th><th>Základ daně</th></tr>';
     89
     90        $this->StartEvidence = mktime(0, 0, 0, 12, 1, 2007);
     91        $StartYear = date('Y', $this->StartEvidence);
    4692        $EndYear = date('Y', time());
    4793        for($Year = $StartYear; $Year <= $EndYear; $Year++)
    4894        {
    4995          $EndTime = mktime(0, 0, 0, 12, 31, $Year);
    50           $Year = date('Y', $EndTime);
     96          //$Year = date('Y', $EndTime);
    5197          $StartTime = mktime(0, 0, 0, 1, 1, $Year);
    52           if($StartTime < $StartEvidence) $StartTime = $StartEvidence;
    53 
    54           $Balance = array();
    55 
    56           $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceCashFlow WHERE Time < "'.TimeToMysqlDateTime($StartTime).'" AND Value > 0 AND Taxable = 1');
    57           $Row = $DbResult->fetch_array();
    58           $Balance['Income']['Start'] = $Row[0] + 0;
    59           $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceCashFlow WHERE Time <= "'.TimeToMysqlDateTime($EndTime).'" AND Value > 0 AND Taxable = 1');
    60           //echo('SELECT SUM(Value) FROM FinanceCashFlow WHERE Time <= "'.TimeToMysqlDateTime($EndTime).'" AND Value > 0 AND Taxable = 1'.'<br />');
    61           $Row = $DbResult->fetch_array();
    62           $Balance['Income']['End'] = $Row[0] + 0;
    63 
    64           $DbResult = $this->Database->query('SELECT -SUM(Value) FROM FinanceCashFlow WHERE Time < "'.TimeToMysqlDateTime($StartTime).'" AND Value < 0 AND Taxable = 1');
    65           $Row = $DbResult->fetch_array();
    66           $Balance['Spend']['Start'] = $Row[0] + 0;
    67           $DbResult = $this->Database->query('SELECT -SUM(Value) FROM FinanceCashFlow WHERE Time <= "'.TimeToMysqlDateTime($EndTime).'" AND Value < 0 AND Taxable = 1');
    68           //echo('SELECT -SUM(Value) FROM FinanceCashFlow WHERE Time <= "'.TimeToMysqlDateTime($EndTime).'" AND Value < 0 AND Taxable = 1'.'<br />');
    69           $Row = $DbResult->fetch_array();
    70           $Balance['Spend']['End'] = $Row[0] + 0;
    71 
    72           $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceClaimsLiabilities WHERE TimeCreation < "'.TimeToMysqlDateTime($StartTime).'" AND TimePayment = "0000-00-00 00:00:00" AND Value > 0');
    73           $Row = $DbResult->fetch_array();
    74           $Balance['Claims']['Start'] = $Row[0] + 0;
    75           $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceClaimsLiabilities WHERE TimeCreation <= "'.TimeToMysqlDateTime($EndTime).'" AND TimePayment = "0000-00-00 00:00:00" AND Value > 0');
    76           $Row = $DbResult->fetch_array();
    77           $Balance['Claims']['End'] = $Row[0] + 0;
    78 
    79           $DbResult = $this->Database->query('SELECT -SUM(Value) FROM FinanceClaimsLiabilities WHERE TimeCreation < "'.TimeToMysqlDateTime($StartTime).'" AND TimePayment = "0000-00-00 00:00:00" AND Value < 0');
    80           $Row = $DbResult->fetch_array();
    81           $Balance['Liabilities']['Start'] = $Row[0] + 0;
    82           $DbResult = $this->Database->query('SELECT -SUM(Value) FROM FinanceClaimsLiabilities WHERE TimeCreation <= "'.TimeToMysqlDateTime($EndTime).'" AND TimePayment = "0000-00-00 00:00:00" AND Value < 0');
    83           $Row = $DbResult->fetch_array();
    84           $Balance['Liabilities']['End'] = $Row[0] + 0;
    85 
    86           // SmallAssets
    87           $DbResult = $this->Database->query('SELECT SUM(price) FROM network_devices WHERE (TimeEnlistment < "'.TimeToMysqlDateTime($StartTime).'") AND (TimeEnlistment != 0) AND ((TimeElimination > "'.TimeToMysqlDateTime($StartTime).'") OR (TimeElimination = 0))');
    88           //$Output .= $Database->error;
    89           $Row = $DbResult->fetch_array();
    90           $Balance['SmallAssets']['Start'] = $Row[0] + 0;
    91           $DbResult = $this->Database->query('SELECT SUM(price) FROM network_devices WHERE (TimeEnlistment < "'.TimeToMysqlDateTime($EndTime).'") AND (TimeEnlistment != 0) AND ((TimeElimination > "'.TimeToMysqlDateTime($EndTime).'") OR (TimeElimination = 0))');
    92           $Row = $DbResult->fetch_array();
    93           $Balance['SmallAssets']['End'] = $Row[0] + 0;
     98          if($StartTime < $this->StartEvidence) $StartTime = $this->StartEvidence;
     99
     100                  $Balance = $this->GetTimePeriodBalance($StartTime, $EndTime);
    94101
    95102          $Output .= '<tr><td>'.$Year.'</td><td>'.date(HumanDate(TimeToMysqlDateTime($StartTime))).'</td><td>'.date(HumanDate(TimeToMysqlDateTime($EndTime))).'</td>';
     
    108115        }
    109116        $Output .= '</table>';
    110 
    111         //    echo('<tr><td colspan="2">Výkaz o majetku a závazcích</td><td>Ing. Jiří Hajda</td></tr>');
    112    /*
    113     echo('<tr><td>Dlouhodobý hmotný majetek</td><td>&nbsp;</td><td>&nbsp;</td></tr>');
    114     echo('<tr><td>Dlouhodobý nehmotný majetek</td><td>&nbsp;</td><td>&nbsp;</td></tr>');
    115     echo('<tr><td>Peněžní prostředky v hotovosti</td><td>&nbsp;</td><td>&nbsp;</td></tr>');
    116     echo('<tr><td>Peněžní prostředky na bankovních účtech</td><td>&nbsp;</td><td>&nbsp;</td></tr>');
    117     echo('<tr><td>Cenné papíry a peněžní vklady</td><td>&nbsp;</td><td>&nbsp;</td></tr>');
    118     echo('<tr><td>Zásoby</td><td>&nbsp;</td><td>&nbsp;</td></tr>');
    119     echo('<tr><td>Úvěry a půjčky (poskytnuté)</td><td>&nbsp;</td><td>&nbsp;</td></tr>');
    120     echo('<tr><td>Aktivní opravná položka</td><td>&nbsp;</td><td>&nbsp;</td></tr>');
    121     echo('<tr><th>Závazky</th><th>&nbsp;</th><th>&nbsp;</th></tr>');
    122     echo('<tr><td>Závazky (bez úvěrů a půjček)</td><td>'.$Liabilities.'</td><td>&nbsp;</td></tr>');
    123     echo('<tr><td>Úvěry a půjčky</td><td>&nbsp;</td><td>&nbsp;</td></tr>');
    124     echo('<tr><td>Pasivní opravná položka</td><td>&nbsp;</td><td>&nbsp;</td></tr>');
    125     echo('<tr><td>Rezervy</td><td>&nbsp;</td><td>&nbsp;</td></tr>');
    126     echo('<tr><td>Závazky celkem</td><td>&nbsp;</td><td>&nbsp;</td></tr>');
    127     echo('<tr><th>Rozdíl (jmění)</th><th>&nbsp;</th><th>&nbsp;</th></tr>');
    128     echo('<tr><td colspan="3"></td></tr>');
    129 
    130     echo('<tr><td colspan="3">Výkaz příjmů a výdajů</td></tr>');
    131     echo('<tr><th>Příjmy</th><th>&nbsp;</th><th>&nbsp;</th></tr>');
    132     echo('<tr><td>Prodej zboží</td><td>&nbsp;</td><td>&nbsp;</td></tr>');
    133     echo('<tr><td>Prodej výrobků a služeb</td><td>&nbsp;</td><td>&nbsp;</td></tr>');
    134     echo('<tr><td>Ostatní</td><td>&nbsp;</td><td>&nbsp;</td></tr>');
    135     echo('<tr><td>z toho úroky</td><td>&nbsp;</td><td>&nbsp;</td></tr>');
    136     echo('<tr><td>Cenné papíry a peněžní vklady</td><td>&nbsp;</td><td>&nbsp;</td></tr>');
    137     echo('<tr><td>Úzávěrková oprava příjmů</td><td>&nbsp;</td><td>&nbsp;</td></tr>');
    138     echo('<tr><td>Příjmy celkem</td><td>&nbsp;</td><td>'.$Income.'</td></tr>');
    139     echo('<tr><th>Výdaje</th><th>&nbsp;</th><th>&nbsp;</th></tr>');
    140     echo('<tr><td>Nákup materiálu</td><td>&nbsp;</td><td>&nbsp;</td></tr>');
    141     echo('<tr><td>Nákup zboží</td><td>&nbsp;</td><td>&nbsp;</td></tr>');
    142     echo('<tr><td>Mzdy</td><td>&nbsp;</td><td>&nbsp;</td></tr>');
    143     echo('<tr><td>Pojistné</td><td>&nbsp;</td><td>&nbsp;</td></tr>');
    144     echo('<tr><td>Provozní režie</td><td>&nbsp;</td><td>&nbsp;</td></tr>');
    145     echo('<tr><td>Uzávěrková oprava příjmů</td><td>&nbsp;</td><td>&nbsp;</td></tr>');
    146     echo('<tr><td>z toho: odpisy dlouhodobého majetku</td><td>&nbsp;</td><td>&nbsp;</td></tr>');
    147     echo('<tr><td>z toho: zůstatková cena dlouhodobého majetku</td><td>&nbsp;</td><td>&nbsp;</td></tr>');
    148     echo('<tr><td>z toho: poměrná splátka leasingové akontace</td><td>&nbsp;</td><td>&nbsp;</td></tr>');
    149     echo('<tr><td>Výdaje celkem</td><td>&nbsp;</td><td>'.$Spend.'</td></tr>');
    150     echo('<tr><th>Rozdíl mezi příjmy a výdaji</th><th>&nbsp;</th><th>&nbsp;</th></tr>');
    151     echo('</table>');
    152 */
     117        break;
     118      case 'MonthlyBalance':
     119        $Output = '<table class="WideTable" style="font-size: smaller;">';
     120        $Output .= '<tr><th colspan="4">Účetní období</th><th colspan="5">Na konci</th><th colspan="6">Během</th></tr>'.
     121                  '<tr><th>Rok</th><th>Měsíc</th></th><th>Od</th><th>Do</th><th>Příjmy</th><th>Výdaje</th><th>Pohledávky</th><th>Závazky</th><th>Drobný majetek</th><th>Příjmy</th><th>Výdaje</th><th>Pohledávky</th><th>Závazky</th><th>Drobný majetek</th><th>Základ daně</th></tr>';
     122
     123        $this->StartEvidence = mktime(0, 0, 0, 12, 1, 2007);
     124        $StartYear = date('Y', $this->StartEvidence);
     125        $EndYear = date('Y', time());
     126        for($Year = $StartYear; $Year <= $EndYear; $Year++)
     127        {
     128          for($Month = 1; $Month <= 12; $Month++)
     129          {
     130            $EndTime = mktime(0, 0, 0, $Month, 31, $Year);
     131            //$Year = date('Y', $EndTime);
     132            $StartTime = mktime(0, 0, 0, $Month, 1, $Year);
     133            if(($StartTime < time()) and ($EndTime > $this->StartEvidence))
     134                        {
     135                          if($StartTime < $this->StartEvidence) $StartTime = $this->StartEvidence;
     136
     137                      $Balance = $this->GetTimePeriodBalance($StartTime, $EndTime);
     138
     139              $Output .= '<tr><td>'.$Year.'</td><td>'.$Month.'</td><td>'.date(HumanDate(TimeToMysqlDateTime($StartTime))).'</td><td>'.date(HumanDate(TimeToMysqlDateTime($EndTime))).'</td>';
     140              $Output .= '<td>'.$Balance['Income']['End'].'</td>';
     141              $Output .= '<td>'.$Balance['Spend']['End'].'</td>';
     142              $Output .= '<td>'.$Balance['Claims']['End'].'</td>';
     143              $Output .= '<td>'.$Balance['Liabilities']['End'].'</td>';
     144              $Output .= '<td>'.$Balance['SmallAssets']['End'].'</td>';
     145
     146              $Output .= '<td>'.($Balance['Income']['End'] - $Balance['Income']['Start']).'</td>';
     147              $Output .= '<td>'.($Balance['Spend']['End'] - $Balance['Spend']['Start']).'</td>';
     148              $Output .= '<td>'.($Balance['Claims']['End'] - $Balance['Claims']['Start']).'</td>';
     149              $Output .= '<td>'.($Balance['Liabilities']['End'] - $Balance['Liabilities']['Start']).'</td>';
     150              $Output .= '<td>'.($Balance['SmallAssets']['End'] - $Balance['SmallAssets']['Start']).'</td>';
     151              $Output .= '<td>'.(($Balance['Income']['End'] - $Balance['Income']['Start']) - ($Balance['Spend']['End'] - $Balance['Spend']['Start'])).'</td></tr>';
     152                    }
     153                  }
     154        }
     155        $Output .= '</table>';
    153156        break;
    154157      case 'CashFlow':
     
    187190        $Output .= '</table></td></tr></table>';
    188191        break;
    189       case 'Advantages':
    190         $Output .= '<table width="100%"><tr><td valign="top">';
    191         $Output .= 'Přijaté zálohy';
    192         $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">';
    193         $Output .= '<tr><th>Subjekt</th><th>Hodnota [Kč]</th><th>Čas vystavení</th><th>Čas uzavření</th></tr>';
    194         $DbResult = $this->Database->query('SELECT * FROM FinanceAdvances JOIN Subject ON Subject.Id = FinanceAdvances.Subject WHERE Direction = "In" ORDER BY TimeCreation');
    195         while($Row = $DbResult->fetch_array())
    196         {
    197           if($Row['TimePass'] == '0000-00-00 00:00:00') $Row['TimePass'] = '&nbsp;';
    198           $Output .= '<tr><td>'.$Row['Name'].'</td><td>'.$Row['Value'].'</td><td>'.$Row['TimeCreation'].'</td><td>'.$Row['TimePass'].'</td></tr>';
    199         }
    200         $Output .= '</table></td><td valign="top">';
    201 
    202         $Output .= 'Vydané zálohy';
    203         $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">';
    204         $Output .= '<tr><th>Subjekt</th><th>Hodnota [Kč]</th><th>Čas vystavení</th><th>Čas uzavření</th></tr>';
    205         $DbResult = $this->Database->query('SELECT * FROM FinanceAdvances JOIN Subject ON Subject.Id = FinanceAdvances.Subject WHERE Direction = "Out" ORDER BY TimeCreation');
    206         while($Row = $DbResult->fetch_array())
    207         {
    208           if($Row['TimePass'] == '0000-00-00 00:00:00') $Row['TimePass'] = '&nbsp;';
    209           $Output .= '<tr><td>'.$Row['Name'].'</td><td>'.$Row['Value'].'</td><td>'.$Row['TimeCreation'].'</td><td>'.$Row['TimePass'].'</td></tr>';
    210         }
    211         $Output .= '</table></td></tr></table>';
    212         break;
    213192      case 'SubjectList':
    214193        $Output .= '<strong>Seznam subjektů</strong>';
    215         $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">';
    216         $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>Zálohy [Kč]</th><th>Stav účtu</th><th>Starý systém</th></tr>';
    217         $DbResult = $this->Database->query('SELECT Id, Name, 0 AS Cash, (SELECT SUM(FinanceClaimsLiabilities.Value) FROM FinanceClaimsLiabilities WHERE FinanceClaimsLiabilities.Subject = Subject.Id AND FinanceClaimsLiabilities.Value > 0) as Claims, (SELECT SUM(FinanceClaimsLiabilities.Value) FROM FinanceClaimsLiabilities WHERE FinanceClaimsLiabilities.Subject = Subject.Id AND FinanceClaimsLiabilities.Value > 0 AND TimePayment IS NULL) as OpenedClaims, (SELECT SUM(FinanceClaimsLiabilities.Value) FROM FinanceClaimsLiabilities WHERE FinanceClaimsLiabilities.Subject = Subject.Id AND FinanceClaimsLiabilities.Value < 0) as Liabilities, (SELECT SUM(FinanceClaimsLiabilities.Value) FROM FinanceClaimsLiabilities WHERE FinanceClaimsLiabilities.Subject = Subject.Id AND FinanceClaimsLiabilities.Value < 0 AND TimePayment IS NULL) as OpenedLiabilities, (SELECT SUM(FinanceCashFlow.Value) FROM FinanceCashFlow WHERE FinanceCashFlow.Subject = Subject.Id AND FinanceCashFlow.Value > 0) as Gains, (SELECT SUM(FinanceCashFlow.Value) FROM FinanceCashFlow WHERE FinanceCashFlow.Subject = Subject.Id AND FinanceCashFlow.Value < 0) as Spends, (SELECT SUM(FinanceAdvances.Value) FROM FinanceAdvances WHERE FinanceAdvances.Subject = Subject.Id AND FinanceAdvances.Direction="In") as AdvancesIn, (SELECT SUM(FinanceAdvances.Value) FROM FinanceAdvances WHERE FinanceAdvances.Subject = Subject.Id AND FinanceAdvances.Direction="Out") as AdvancesOut FROM Subject ORDER BY Name');
    218         while($Row = $DbResult->fetch_array())
    219         {
    220           $Advances = ($Row['AdvancesIn'] - $Row['AdvancesOut']);
    221           $Output .= '<tr><td><a href="?table=SubjectAccount&Id='.$Row['Id'].'">'.$Row['Name'].'</a></td><td>'.$Row['Liabilities'].'/'.$Row['OpenedLiabilities'].'</td><td>'.$Row['Claims'].'/'.$Row['OpenedClaims'].'</td><td>'.$Row['Gains'].'</td><td>'.$Row['Spends'].'</td><td>'.$Advances.'</td><td>'.($Advances - $Row['OpenedClaims'] + Abs($Row['OpenedLiabilities'])).'</td><td>'.$Row['Cash'].'</td></tr>';
     194        $Output .= '<table style="font-size: smaller;" class="WideTable">';
     195        $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>';
     196        $DbResult = $this->Database->query('SELECT Id, Name, 0 AS Cash, (SELECT SUM(T1.Value) FROM FinanceOperation AS T1 WHERE T1.SourceSubject = Subject.Id AND T1.DestinationSubject = 71) as Claims, (SELECT SUM(T2.Value) FROM FinanceOperation AS T2 WHERE T2.SourceSubject = Subject.Id AND T2.DestinationSubject = 71 AND Time IS NULL) as OpenedClaims, (SELECT SUM(T3.Value) FROM FinanceOperation AS T3 WHERE T3.DestinationSubject = Subject.Id AND T3.SourceSubject = 71) as Liabilities, (SELECT SUM(T4.Value) FROM FinanceOperation AS T4 WHERE T4.DestinationSubject = Subject.Id AND T4.SourceSubject = 71 AND Time IS NULL) as OpenedLiabilities, (SELECT SUM(T5.Value) FROM FinanceOperation AS T5 WHERE T5.DestinationSubject = Subject.Id AND T5.SourceSubject = 96) as Gains, (SELECT SUM(T6.Value) FROM FinanceOperation AS T6 WHERE T6.SourceSubject = Subject.Id AND T6.DestinationSubject = 96) as Spends FROM Subject ORDER BY Name');
     197        while($Row = $DbResult->fetch_assoc())
     198        {
     199          $Output .= '<tr><td><a href="?table=SubjectAccount&Id='.$Row['Id'].'">'.$Row['Name'].'</a></td><td>'.$Row['Liabilities'].'/'.$Row['OpenedLiabilities'].'</td><td>'.$Row['Claims'].'/'.$Row['OpenedClaims'].'</td><td>'.$Row['Gains'].'</td><td>'.$Row['Spends'].'</td><td>'.($Row['Gains'] - $Row['Spends'] - $Row['Claims'] + $Row['Liabilities']).'</td><td>'.$Row['Cash'].'</td></tr>';
    222200        }
    223201        $Output .= '</table>';
     
    271249      default:
    272250        $Output .= '<a href="?table=AnnualBalance">Účetní závěrka</a><br />';
     251        $Output .= '<a href="?table=MonthlyBalance">Měsíční přehledy</a><br />';
    273252        $Output .= '<a href="?table=CashFlow">Příjmy a výdaje</a><br />';
    274253        $Output .= '<a href="?table=ClaimsLiabilities">Závazky a pohledávky</a><br />';
Note: See TracChangeset for help on using the changeset viewer.