Changeset 167 for www/finance


Ignore:
Timestamp:
Mar 24, 2009, 11:44:03 AM (16 years ago)
Author:
george
Message:
  • Přidáno: Stránka pro rozeslání emailů s počátečními hesly.
  • Upraveno: Konfigurační skripty pro nastavení síťových zařízení se systémem RouterOS doplněny o podporu zápisu konfigurace do více samostatných zařízení. Změna se týká konfigurace DHCP serveru a sledování net_watch.
  • Opraveno: Některé nefunkční odkazy na hlavní stránce.
  • Upraveno: Tabulka finance_operations nově převedena na tabulky FinanceOperation a FinanceClaimsLiabilities. Upraveny související stránky.
Location:
www/finance
Files:
3 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • www/finance/clenove.php

    r164 r167  
    1010  {
    1111    $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í');
    1414
    1515        // Seznam členů
    1616    $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>';
    1919    //<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>';
    2121    $TotalDevice = 0;
    2222    $TotalMonth = 0;
    2323    $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.Member JOIN 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');
    2525    while($Row = $DbResult->fetch_assoc())
    2626    {
     
    3838    $Output .= '<tr><td><strong>Celkem</strong></td><td>&nbsp;</td>';
    3939    //<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">&nbsp;</td><td align="right">&nbsp;</td><td align="right">&nbsp;</td></tr>';
     40    $Output .= '<td align="right"><strong>'.$TotalMonth.'</strong></td><td align="right"><strong>'.$TotalCash.'</strong></td><td align="right">&nbsp;</td><td align="right">&nbsp;</td></tr>';
    4141    $Output .= '</table>';
    4242    return($Output);
  • www/finance/index.php

    r163 r167  
    1010  {
    1111    $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 />';
    1514       
    1615    $Output .= '<a href="monthly_overall.php">Měsíční přehledy</a><br />';
     
    6362
    6463    $Output .= 'Měsíční vyúčtování:<br />
    65     <table border="1" cellspacing="0" cellpadding="3">
     64    <table class="WideTable">
    6665    <tr><th>Položka</th><th>Cena [Kč]</th></tr>
    6766    <tr><th colspan="2">Příjmy</th></tr>';
  • www/finance/manage.php

    r165 r167  
    381381  function ConvertData()
    382382  {
    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');
    385387
    386388    // Move time of device price transformation
     
    388390
    389391    // 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          }
    396418
    397419    // Transfer finance before era
     
    402424      $DbRow2 = $DbResult2->fetch_assoc();
    403425
    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 .= '#';
    418437    }
    419438
  • www/finance/prepocet.php

    r164 r167  
    1111    $Finance = &$this->System->Modules['Finance'];
    1212    $Output = 'Aktualizuju finance uživatelů...<br />';
    13         $this->Database->query('TRUNCATE TABLE MemberPayment');
     13          $this->Database->query('TRUNCATE TABLE MemberPayment');
    1414    $DbResult = $this->Database->query('SELECT * FROM Member');
    1515    while($Member = $DbResult->fetch_assoc())
    1616    {
    17       $DbResult2 = $this->Database->query('SELECT ((SELECT COALESCE(SUM(Value), 0) FROM FinanceCashFlow WHERE 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');
    1818      $Cash = $DbResult2->fetch_row();
    19           $Cash = $Cash[0];
     19            $Cash = $Cash[0];
    2020         
    2121      $DbResult2 = $this->Database->query('SELECT SUM(consumption) FROM network_devices WHERE user='.$Member['Id'].' AND used=1');
    2222      $ConsumptionPlus = $DbResult2->fetch_row();
    23           $ConsumptionPlus = $ConsumptionPlus[0];
     23            $ConsumptionPlus = $ConsumptionPlus[0];
    2424
    2525      $NetworkDevice = 0;
     
    3939      $MonthlyInet = $Finance->Tarify[$Member['InternetTariffNextMonth']]['price'];
    4040      //if($Row['inet'] == 1)
    41           $Monthly += $MonthlyInet;
     41            $Monthly += $MonthlyInet;
    4242      $Monthly -= $Finance->W2Kc($ConsumptionPlus);
    4343      //if($Row['overheads'] == 1) $Monthly += $Sprava; // + W2Kc($Consumption);
     
    196196          $BillCode = $Finance->GetNextDocumentLineNumber(6); // Faktury vydané
    197197          $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));
    199199        } else $Output .= ("<br />");
    200200      }
  • www/finance/spotreba.php

    r157 r167  
    99  function Show()
    1010  {
    11     global $kWh;
     11    $Finance = $this->System->Modules['Finance'];
    1212
    1313    // 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>';
    1515    $CelkovaSpotreba = 0;
    1616    $DbResult = $this->Database->query("SELECT * FROM network_segments");
     
    2323    }
    2424    $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 />';
    2727    return($Output);
    2828  }
  • www/finance/user_state.php

    r165 r167  
    2929    $DbResult = $this->Database->query('SELECT Id FROM Subject WHERE Id=(SELECT Subject FROM Member WHERE Id=(SELECT Member FROM User WHERE Id='.$UserId.'))');
    3030    $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.')');
    3232    $Member = $DbResult->fetch_assoc();
    3333    $TarifName = $Finance->Tarify[$Member['InternetTariffCurrentMonth']]['name'];
     
    4141    $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 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);
    4846    while($DbRow = $DbResult->fetch_array())
    4947      $Operations[] = $DbRow;
     
    5755    //echo('<tr><td>&nbsp;</td><td>-'.$Row2['network_device'].'</td><td>Proměnná cena za zařízení</td></tr>
    5856    $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);
    6458    $DbRow = $DbResult->fetch_array();
    6559    $Total = $DbRow['Total'];
  • www/finance/zarizeni.php

    r157 r167  
    1010  {
    1111    // 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>';
    1313    $DbResult = $this->Database->query("SELECT * FROM network_segments");   
    1414    while($Row = $DbResult->fetch_array())
    1515    {
    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>';
    1717      $DbResult2 = $this->Database->query("SELECT * FROM network_devices WHERE segment=".$Row['id']." AND used=1");
    1818      while($Row = $DbResult2->fetch_array())
    1919      {
    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>';
    2121      }
    2222    }
  • www/finance/zivnost.php

    r165 r167  
    3333  {
    3434    $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)');
    3636    $Row = $DbResult->fetch_array();
    3737    $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)');
    3939    //echo('SELECT SUM(Value) FROM FinanceCashFlow WHERE Time <= "'.TimeToMysqlDateTime($EndTime).'" AND Value > 0 AND Taxable = 1'.'<br />');
    4040    $Row = $DbResult->fetch_array();
    4141    $Balance['Income']['End'] = $Row[0] + 0;
    4242
    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)');
    4444    $Row = $DbResult->fetch_array();
    4545    $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)');
    4747          //echo('SELECT -SUM(Value) FROM FinanceCashFlow WHERE Time <= "'.TimeToMysqlDateTime($EndTime).'" AND Value < 0 AND Taxable = 1'.'<br />');
    4848    $Row = $DbResult->fetch_array();
    4949    $Balance['Spend']['End'] = $Row[0] + 0;
    5050
    51     $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceOperation 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)');
    5252    $Row = $DbResult->fetch_array();
    5353    $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.')');
     54    $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceClaimsLiabilities WHERE (TimeCreation <= "'.TimeToMysqlDateTime($EndTime).'") AND (TimeCreation >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Value > 0)');
    5555    $Row = $DbResult->fetch_array();
    5656    $Balance['Claims']['End'] = $Row[0] + 0;
    5757
    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)');
    5959    $Row = $DbResult->fetch_array();
    6060    $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)');
    6262    $Row = $DbResult->fetch_array();
    6363    $Balance['Liabilities']['End'] = $Row[0] + 0;
     
    7171    $Row = $DbResult->fetch_array();
    7272    $Balance['SmallAssets']['End'] = $Row[0] + 0;
    73         return($Balance);
     73          return($Balance);
    7474  }
    7575
    7676  function Show()
    7777  {
     78          if(!$this->System->Modules['User']->CheckPermission('Finance', 'TradingStatus')) return('Nemáte oprávnění');
    7879    $this->System->Modules['Finance']->RecalculateTariffs(1);
    7980    //TransformFinance();
     
    157158      case 'CashFlow':
    158159        $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">';
    160161        $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];
    164167          $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>';
    165168        }
     
    169172        $Output .= '<table width="100%"><tr><td valign="top">';
    170173        $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">';
    172175        $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>';
    173176        $DbResult = $this->Database->query('SELECT * FROM FinanceClaimsLiabilities JOIN Subject ON Subject.Id = FinanceClaimsLiabilities.Subject WHERE Value > 0 ORDER BY TimeCreation');
     
    180183
    181184        $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">';
    183186        $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>';
    184187        $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.