Changeset 165 for www


Ignore:
Timestamp:
Mar 5, 2009, 10:16:12 PM (16 years ago)
Author:
george
Message:
Location:
www
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • www/finance/finance.php

    r164 r165  
    2121  var $TotalInternetPaid;
    2222  var $Tarify;
     23  var $ExternalSubject = 96;
     24  var $MainSubject = 71;
    2325 
    2426  function RecalculateTariffs($Period = 1)
  • www/finance/manage.php

    r164 r165  
    4747      case 'NewInvoiceForm':
    4848        $Output = $this->ShowNewInvoiceForm();
     49        break;
     50      case 'ConvertData':
     51        $Output = $this->ConvertData();
    4952        break;
    5053      default:
     
    5659        $Output .= '<a href="?Operation=ConvertPDFToFile">Převést data z databáze do souborů</a><br />';
    5760        $Output .= '<a href="?Operation=Bills">Správa dokladů</a><br />';
     61        $Output .= '<a href="?Operation=ConvertData">Převést tabulky</a><br />';
    5862                $Output .= '<a href="prepocet.php">Přepočet financí</a><br />';
    5963                $Output .= '<a href="clenove.php">Seznam subjektů</a><br />';
     
    356360  {
    357361    $DbResult = $this->Database->query('SELECT * FROM FinanceBills');
    358     while($Bill = $DbResult->fetch_array())
     362    while($Bill = $DbResult->fetch_assoc())
    359363    {
    360364      file_put_contents('doklady/doklad_'.$Bill['id'].'.pdf', $Bill['pdf']);
     
    365369  function CheckPDFFiles()
    366370  {
    367     global $Database, $InvoiceGenerator;
     371    global $InvoiceGenerator;
    368372
    369373    $DbResult = $this->Database->query('SELECT * FROM FinanceBills');
    370     while($Bill = $DbResult->fetch_array())
     374    while($Bill = $DbResult->fetch_assoc())
    371375    {
    372376      file_put_contents('doklady2/doklad-'.$Bill['id'].'.pdf', file_get_contents('doklady/doklad-'.$Bill['id'].'.pdf'));
     
    375379  }
    376380
     381  function ConvertData()
     382  {
     383        $Output = '';
     384        $this->Database->query('TRUNCATE TABLE FinanceOperation');
     385
     386    // Move time of device price transformation
     387    $this->Database->query('UPDATE finance_operations SET date="2007-11-30" WHERE comment = "Jednorázový poplatek za společné zařízení"');
     388
     389    // 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        }
     396
     397    // Transfer finance before era
     398    $DbResult = $this->Database->query('SELECT * FROM Subject');
     399    while($Subject = $DbResult->fetch_assoc())
     400    {
     401      $DbResult2 = $this->Database->query('SELECT SUM(money) as money FROM finance_operations WHERE user='.$Subject['Id'].' AND date < "2007-12-01"');
     402      $DbRow2 = $DbResult2->fetch_assoc();
     403
     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 .= '#';
     418    }
     419
     420        return($Output);
     421  }
    377422}
    378423
  • www/finance/user_state.php

    r163 r165  
    3939    $User = $DbResult->fetch_assoc();
    4040    $Output .= 'Výpis operací pro účastníka '.$User['Name'].':<br>';
    41     $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3"><tr><th>Datum</th><th>Popis</th><th>Částka</th><th>Doklad</th></tr>';
     41    $Output .= '<table style="font-size: smaller;" class="WideTable"><tr><th>Datum</th><th>Popis</th><th>Částka</th><th>Doklad</th></tr>';
    4242    $Operations = array();
    43     $DbResult = $this->Database->query('(SELECT Time, Value, Text, Bill FROM FinanceCashFlow WHERE Subject='.$Subject['Id'].') UNION ALL '.
    44       '(SELECT TimeCreation as Time, -Value as Value, Text, Bill FROM FinanceClaimsLiabilities WHERE Subject='.$Subject['Id'].') ORDER BY Time DESC');
     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');
    4548    while($DbRow = $DbResult->fetch_array())
    4649      $Operations[] = $DbRow;
     
    5053      if($Row['Value'] > 0) $Row['Value'] = '+'.$Row['Value'];
    5154      if($Row['Bill'] > 0) $Invoice = '<a href="bill.php?Id='.$Row['Bill'].'">PDF</a>'; else $Invoice = '&nbsp;';
    52       $Output .= '<tr><td align="right">'.HumanDate($Row['Time']).'</td><td>'.$Row['Text'].'</td><td style="text-align: right;">'.$Row['Value'].'</td><td style="text-align: center;">'.$Invoice.'</td></tr>';
     55      $Output .= '<tr><td style="text-align: right;">'.HumanDate($Row['Time']).'</td><td style="text-align: left;">'.$Row['Text'].'</td><td style="text-align: right;">'.$Row['Value'].'</td><td style="text-align: center;">'.$Invoice.'</td></tr>';
    5356    }
    5457    //echo('<tr><td>&nbsp;</td><td>-'.$Row2['network_device'].'</td><td>Proměnná cena za zařízení</td></tr>
    5558    $Output .= '</table>';
    56     $DbResult = $this->Database->query('SELECT ((SELECT COALESCE(SUM(Value), 0) FROM FinanceCashFlow WHERE Subject='.$Subject['Id'].') + '.
    57       '(SELECT COALESCE(SUM(-Value), 0) FROM FinanceClaimsLiabilities WHERE Subject='.$Subject['Id'].')) as Total');
     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');
    5864    $DbRow = $DbResult->fetch_array();
    5965    $Total = $DbRow['Total'];
     
    6470
    6571        $Total = 0;
    66     $Output .= 'Rozpis měsíčního poplatku:<br><table border="1" cellspacing="0" cellpadding="3">'.
     72    $Output .= 'Rozpis měsíčního poplatku:<br><table class="WideTable">'.
    6773      '<tr><th>Část</th><th>Cena [Kč]</th></tr>'.
    6874      '<tr><td>Internet - tarif '.$TarifName.'</td><td>'.$TarifPrice.'</td></tr>';
     
    7884    {
    7985          $Output .= 'Měsíční příjem za spotřebu zařízení umístěných u uživatele:<br>';
    80       $Output .= '<table border="1" cellspacing="0" cellpadding="3"><tr><th>Název zařízení</th><th>Spotřeba [W]</th><th>Příjem [Kč]</th></tr>';
     86      $Output .= '<table class="WideTable"><tr><th>Název zařízení</th><th>Spotřeba [W]</th><th>Příjem [Kč]</th></tr>';
    8187      $DbResult = $this->Database->query('SELECT * FROM network_devices WHERE user='.$UserId.' AND used=1');
    8288      $TotalW = 0;
  • 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 />';
  • www/sql/updates/163.sql

    r163 r165  
    11RENAME TABLE `is`.`users`  TO `is`.`users_old` ;
    2 
    3 ALTER TABLE `Member` ADD `MonthlyPayment` FLOAT NOT NULL DEFAULT '0' COMMENT 'cache';
    42
    53CREATE TABLE IF NOT EXISTS `MemberPayment` (
  • www/style.css

    r153 r165  
    179179}
    180180
    181 
    182181.BasicTable
    183182{
     
    254253  border-style: solid;
    255254  border-width: 0px 0px 1px 1px;
    256   padding: 1px 10px 1px 10px;
     255  padding: 1px 5px 1px 5px;
     256  background-color: #F0F0FF
    257257}
    258258
     
    262262  border-style: solid;
    263263  border-width: 0px 0px 1px 1px;
    264   padding: 1px 10px 1px 10px;
     264  padding: 1px 5px 1px 5px;
    265265  text-align: center;
    266266}
Note: See TracChangeset for help on using the changeset viewer.