Ignore:
Timestamp:
Sep 30, 2015, 11:55:11 PM (9 years ago)
Author:
chronos
Message:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Finance/Zivnost.php

    r740 r748  
    1111  {
    1212    $Balance = array();
    13     $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceOperation WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (ValueSign = 1)');
     13    $DbResult = $this->Database->query('SELECT SUM(`Value`) FROM `FinanceOperation` '.
     14      'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `FinanceOperation`.`Group` '.
     15      'WHERE (`Time` < "'.TimeToMysqlDateTime($StartTime).'") AND (`Time` >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (`Taxable` = 1) AND (`FinanceOperationGroup`.`ValueSign` = 1)');
    1416    $Row = $DbResult->fetch_array();
    1517    $Balance['Income']['Start'] = $Row[0] + 0;
    16     $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceOperation WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (ValueSign = 1)');
     18    $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceOperation '.
     19      'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `FinanceOperation`.`Group` '.
     20      'WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (`FinanceOperationGroup`.`ValueSign` = 1)');
    1721    //echo('SELECT SUM(Value) FROM FinanceCashFlow WHERE Time <= "'.TimeToMysqlDateTime($EndTime).'" AND Value > 0 AND Taxable = 1'.'<br />');
    1822    $Row = $DbResult->fetch_array();
    1923    $Balance['Income']['End'] = $Row[0] + 0;
    2024
    21     $DbResult = $this->Database->query('SELECT -SUM(Value*ValueSign) FROM FinanceOperation WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (ValueSign = -1)');
     25    $DbResult = $this->Database->query('SELECT SUM(Value*ValueSign) FROM FinanceOperation '.
     26      'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `FinanceOperation`.`Group` '.
     27      'WHERE (`Time` < "'.TimeToMysqlDateTime($StartTime).'") AND (`Time` >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (`Taxable` = 1) AND (`FinanceOperationGroup`.`ValueSign` = -1)');
    2228    $Row = $DbResult->fetch_array();
    2329    $Balance['Spend']['Start'] = $Row[0] + 0;
    24     $DbResult = $this->Database->query('SELECT -SUM(Value*ValueSign) FROM FinanceOperation WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (ValueSign = -1)');
     30    $DbResult = $this->Database->query('SELECT SUM(Value*ValueSign) FROM FinanceOperation '.
     31      'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `FinanceOperation`.`Group` '.
     32      'WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (`FinanceOperationGroup`.`ValueSign` = -1)');
    2533          //echo('SELECT -SUM(Value) FROM FinanceCashFlow WHERE Time <= "'.TimeToMysqlDateTime($EndTime).'" AND Value < 0 AND Taxable = 1'.'<br />');
    2634    $Row = $DbResult->fetch_array();
    2735    $Balance['Spend']['End'] = $Row[0] + 0;
    2836
    29     $DbResult = $this->Database->query('SELECT SUM(Value*ValueSign) FROM FinanceInvoice WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (ValueSign = 1)');
     37    $DbResult = $this->Database->query('SELECT SUM(Value*ValueSign) FROM FinanceInvoice '.
     38      'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `FinanceInvoice`.`Group` '.
     39      'WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (`FinanceInvoiceGroup`.`ValueSign` = 1)');
    3040    $Row = $DbResult->fetch_array();
    3141    $Balance['Claims']['Start'] = $Row[0] + 0;
    32     $DbResult = $this->Database->query('SELECT SUM(Value*ValueSign) FROM FinanceInvoice WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (ValueSign = 1)');
     42    $DbResult = $this->Database->query('SELECT SUM(Value*ValueSign) FROM FinanceInvoice '.
     43      'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `FinanceInvoice`.`Group` '.
     44      'WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (`FinanceInvoiceGroup`.`ValueSign` = 1)');
    3345    $Row = $DbResult->fetch_array();
    3446    $Balance['Claims']['End'] = $Row[0] + 0;
    3547
    36     $DbResult = $this->Database->query('SELECT -SUM(Value*ValueSign) FROM FinanceInvoice WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (ValueSign = -1)');
     48    $DbResult = $this->Database->query('SELECT SUM(Value*ValueSign) FROM FinanceInvoice '.
     49      'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `FinanceInvoice`.`Group` '.
     50      'WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (`FinanceInvoiceGroup`.`ValueSign` = -1)');
    3751    $Row = $DbResult->fetch_array();
    3852    $Balance['Liabilities']['Start'] = $Row[0] + 0;
    39     $DbResult = $this->Database->query('SELECT -SUM(Value*ValueSign) FROM FinanceInvoice WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (ValueSign = -1)');
     53    $DbResult = $this->Database->query('SELECT SUM(Value*ValueSign) FROM FinanceInvoice '.
     54      'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `FinanceInvoice`.`Group` '.
     55      'WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (`FinanceInvoiceGroup`.`ValueSign` = -1)');
    4056    $Row = $DbResult->fetch_array();
    4157    $Balance['Liabilities']['End'] = $Row[0] + 0;
     
    5470  function Show()
    5571  {
    56     if(!$this->System->User->CheckPermission('Finance', 'TradingStatus')) return('Nemáte oprávnění');
     72    if(!$this->System->User->CheckPermission('Finance', 'TradingStatus'))
     73      return('Nemáte oprávnění');
     74
     75    $Finance = &$this->System->Modules['Finance'];
    5776
    5877    $Output = '';
     
    143162        $Output .= '<table style="font-size: smaller;" class="WideTable">';
    144163        $Output .= '<tr><th>Čas</th><th>Kód</th><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th><th>Daňový</th><th>Hotovost</th></tr>';
    145         $DbResult = $this->Database->query('SELECT * FROM FinanceOperation LEFT JOIN Subject ON Subject.Id = FinanceOperation.Subject '.
    146           'WHERE (ValueSign = 1) AND (FinanceOperation.Time >= "'.$Year['DateStart'].'") AND (FinanceOperation.Time <= "'.$Year['DateEnd'].'") ORDER BY Time');
     164        $DbResult = $this->Database->query('SELECT `FinanceOperation`.*, `DocumentLineCode`.`Name` AS `BillName`, `Subject`.`Name` AS `Name` FROM `FinanceOperation` '.
     165          'LEFT JOIN `Subject` ON `Subject`.`Id` = `FinanceOperation`.`Subject` '.
     166          'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `FinanceOperation`.`Group` '.
     167          'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id` = `FinanceOperation`.`BillCode` '.
     168          'WHERE (`ValueSign` = 1) AND (`FinanceOperation`.`Time` >= "'.$Year['DateStart'].'") '.
     169          'AND (`FinanceOperation`.`Time` <= "'.$Year['DateEnd'].'") ORDER BY `Time`');
    147170        while($Row = $DbResult->fetch_array())
    148171        {
    149172          $Row['Time'] = explode(' ', $Row['Time']);
    150173          $Row['Time'] = $Row['Time'][0];
    151           $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillCode'].'</td><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].'</td><td>'.$Table[$Row['Taxable']].'</td><td>'.$Table[$Row['Cash']].'</td></tr>';
     174          $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillName'].
     175            '</td><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].
     176            '</td><td>'.$Table[$Row['Taxable']].'</td><td>'.$Table[$Row['Cash']].'</td></tr>';
    152177          $Total += $Row['Value'];
    153178          $TotalTax[$Row['Taxable']] += $Row['Value'];
     
    173198        $Output .= '<table style="font-size: smaller;" class="WideTable">';
    174199        $Output .= '<tr><th>Čas</th><th>Kód</th><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th><th>Daňový</th><th>Hotovost</th></tr>';
    175         $DbResult = $this->Database->query('SELECT * FROM FinanceOperation LEFT JOIN Subject ON Subject.Id = FinanceOperation.Subject '.
    176           'WHERE (ValueSign = -1) AND (FinanceOperation.Time >= "'.$Year['DateStart'].'") AND (FinanceOperation.Time <= "'.$Year['DateEnd'].'") ORDER BY Time');
     200        $DbResult = $this->Database->query('SELECT `FinanceOperation`.*, `DocumentLineCode`.`Name` AS `BillName`, `Subject`.`Name` AS `Name` FROM `FinanceOperation` '.
     201          'LEFT JOIN `Subject` ON `Subject`.`Id` = `FinanceOperation`.`Subject` '.
     202          'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `FinanceOperation`.`Group` '.
     203          'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id` = `FinanceOperation`.`BillCode` '.
     204          'WHERE (`FinanceOperationGroup`.`ValueSign` = -1) AND (`FinanceOperation`.`Time` >= "'.$Year['DateStart'].'") '.
     205          'AND (`FinanceOperation`.`Time` <= "'.$Year['DateEnd'].'") ORDER BY `Time`');
    177206        while($Row = $DbResult->fetch_array())
    178207        {
     
    180209          $Row['Time'] = $Row['Time'][0];
    181210          $Row['Value'] = $Row['Value'];
    182           $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillCode'].'</td><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].'</td><td>'.$Table[$Row['Taxable']].'</td><td>'.$Table[$Row['Cash']].'</td></tr>';
     211          $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillName'].
     212            '</td><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].
     213            '</td><td>'.$Table[$Row['Taxable']].'</td><td>'.$Table[$Row['Cash']].'</td></tr>';
    183214          $Total += $Row['Value'];
    184215          $TotalTax[$Row['Taxable']] += $Row['Value'];
     
    202233        $Output .= '<table style="font-size: smaller;" class="WideTable">';
    203234        $Output .= '<tr><th>Čas vystavení</th><th>Kód</th><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th></tr>';
    204         $DbResult = $this->Database->query('SELECT *, (SELECT GROUP_CONCAT(Description SEPARATOR ",") FROM FinanceInvoiceItem WHERE FinanceInvoiceItem.FinanceInvoice = FinanceInvoice.Id) AS Text '.
     235        $DbResult = $this->Database->query('SELECT `FinanceInvoice`.*, (SELECT GROUP_CONCAT(Description SEPARATOR ",") '.
     236          'FROM FinanceInvoiceItem WHERE FinanceInvoiceItem.FinanceInvoice = FinanceInvoice.Id) AS Text, `DocumentLineCode`.`Name` AS `BillName`, `Subject`.`Name` AS `Name` '.
    205237          'FROM FinanceInvoice JOIN Subject ON Subject.Id = FinanceInvoice.Subject '.
    206           'WHERE (ValueSign = 1) AND (FinanceInvoice.Time >= "'.$Year['DateStart'].
     238          'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `FinanceInvoice`.`Group` '.
     239          'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id` = `FinanceInvoice`.`BillCode` '.
     240          'WHERE (`FinanceInvoiceGroup`.`ValueSign` = 1) AND (FinanceInvoice.Time >= "'.$Year['DateStart'].
    207241          '") AND (FinanceInvoice.Time <= "'.$Year['DateEnd'].'") ORDER BY Time');
    208242        while($Row = $DbResult->fetch_array())
    209243        {
    210244          if($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = '&nbsp;';
    211           $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillCode'].
    212             '</td><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.($Row['Value'] * $Row['ValueSign']).'</td></tr>';
     245          $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillName'].
     246            '</td><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].'</td></tr>';
    213247          $Total += $Row['Value'];
    214248        }
     
    225259        $Output .= '<table style="font-size: smaller;" class="WideTable">';
    226260        $Output .= '<tr><th>Čas vystavení</th><th>Kód</th><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th></tr>';
    227         $DbResult = $this->Database->query('SELECT *, (SELECT GROUP_CONCAT(Description SEPARATOR ",") FROM FinanceInvoiceItem WHERE FinanceInvoiceItem.FinanceInvoice = FinanceInvoice.Id) AS Text '.
     261        $DbResult = $this->Database->query('SELECT *, (SELECT GROUP_CONCAT(Description SEPARATOR ",") '.
     262          'FROM FinanceInvoiceItem WHERE FinanceInvoiceItem.FinanceInvoice = FinanceInvoice.Id) AS `Text`, `DocumentLineCode`.`Name` AS `BillName` '.
    228263          'FROM FinanceInvoice JOIN Subject ON Subject.Id = FinanceInvoice.Subject '.
    229           'WHERE (ValueSign = -1) AND (FinanceInvoice.Time >= "'.$Year['DateStart'].
     264          'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `FinanceInvoice`.`Group` '.
     265          'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id` = `FinanceInvoice`.`BillCode` '.
     266          'WHERE (`FinanceInvoiceGroup`.`ValueSign` = -1) AND (`FinanceInvoice`.`Time` >= "'.$Year['DateStart'].
    230267          '") AND (FinanceInvoice.Time <= "'.$Year['DateEnd'].'") ORDER BY Time');
    231268        while($Row = $DbResult->fetch_array())
     
    233270          if($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = '&nbsp;';
    234271          $Row['Value'] = $Row['Value'] * -1;
    235           $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillCode'].
     272          $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillName'].
    236273            '</td><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.($Row['Value'] * $Row['ValueSign']).'</td></tr>';
    237274          $Total += $Row['Value'];
     
    245282        $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>';
    246283        $DbResult = $this->Database->query('SELECT Id, Name, 0 AS Cash, '.
    247         '(SELECT SUM(T1.Value*T1.ValueSign) FROM FinanceInvoice AS T1 WHERE (T1.Subject = Subject.Id) AND (T1.ValueSign = 1)) as Claims, '.
    248         '(SELECT SUM(T2.Value*T2.ValueSign) FROM FinanceInvoice AS T2 WHERE (T2.Subject = Subject.Id) AND (T2.ValueSign = 1) AND (TimePayment IS NULL)) as OpenedClaims, '.
    249         '(SELECT -SUM(T3.Value*T3.ValueSign) FROM FinanceInvoice AS T3 WHERE (T3.Subject = Subject.Id) AND (T3.ValueSign = -1)) as Liabilities, '.
    250         '(SELECT -SUM(T4.Value*T4.ValueSign) FROM FinanceInvoice AS T4 WHERE (T4.Subject = Subject.Id) AND (T4.ValueSign = -1) AND (TimePayment IS NULL)) AS OpenedLiabilities, '.
    251         '(SELECT SUM(T5.Value*T5.ValueSign) FROM FinanceOperation AS T5 WHERE (T5.Subject = Subject.Id) AND (T5.ValueSign = 1)) AS Gains, '.
    252         '(SELECT SUM(T6.Value*T6.ValueSign) FROM FinanceOperation AS T6 WHERE (T6.Subject = Subject.Id) AND (T6.ValueSign = -1)) AS Spends '.
     284        '(SELECT SUM(T1.Value) FROM FinanceInvoice AS T1 '.
     285         'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `T1`.`Group` '.
     286         'WHERE (T1.Subject = Subject.Id) AND (`FinanceInvoiceGroup`.ValueSign = 1)) AS `Claims`, '.
     287        '(SELECT SUM(T2.Value) FROM FinanceInvoice AS T2 '.
     288         'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `T2`.`Group` '.
     289         'WHERE (T2.Subject = Subject.Id) AND (`FinanceInvoiceGroup`.`ValueSign` = 1) AND (TimePayment IS NULL)) AS `OpenedClaims`, '.
     290        '(SELECT -SUM(T3.Value) FROM FinanceInvoice AS T3 '.
     291        'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `T3`.`Group` '.
     292        'WHERE (T3.Subject = Subject.Id) AND (`FinanceInvoiceGroup`.`ValueSign` = -1)) AS `Liabilities`, '.
     293        '(SELECT -SUM(T4.Value) FROM FinanceInvoice AS T4 '.
     294        'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `T4`.`Group` '.
     295        'WHERE (T4.Subject = Subject.Id) AND (`FinanceInvoiceGroup`.`ValueSign` = -1) AND (`TimePayment` IS NULL)) AS `OpenedLiabilities`, '.
     296        '(SELECT SUM(T5.Value) FROM FinanceOperation AS T5 '.
     297        'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `T5`.`Group` '.
     298        'WHERE (T5.Subject = Subject.Id) AND (`FinanceOperationGroup`.`ValueSign` = 1)) AS `Gains`, '.
     299        '(SELECT SUM(T6.Value) FROM FinanceOperation AS T6 '.
     300        'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `T6`.`Group` '.
     301        'WHERE (T6.Subject = Subject.Id) AND (`FinanceOperationGroup`.`ValueSign` = -1)) AS `Spends` '.
    253302        'FROM Subject ORDER BY Name');
    254303        while($Row = $DbResult->fetch_assoc())
     
    276325        $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">';
    277326        $Output .= '<tr><th>Datum</th><th>Název</th><th>Hodnota [Kč]</th><th>Doklad</th></tr>';
    278         $DbResult = $this->Database->select('FinanceOperation', '*', 'Subject='.$_GET['Id'].' ORDER BY Time');
     327        $DbResult = $this->Database->query('SELECT `FinanceOperation`.*, `DocumentLineCode`.`Name` AS `BillName` FROM `FinanceOperation` '.
     328          'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id` = `FinanceOperation`.`BillCode` '.
     329          'WHERE `Subject=`'.$_GET['Id'].' ORDER BY `Time`');
    279330        while($Row = $DbResult->fetch_array())
    280331        {
    281332          $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['Text'].
    282             '</td><td>'.($Row['Value']*$Row['ValueSign']).'</td><td>'.$Row['BillCode'].'</td></tr>';
     333            '</td><td>'.($Row['Value']*$Row['ValueSign']).'</td><td>'.$Row['BillName'].'</td></tr>';
    283334        }
    284335        $Output .= '</table></td><td style="vertical-align: top;">';
     
    287338        $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">';
    288339        $Output .= '<tr><th>Datum vytvoření</th><th>Datum zaplacení</th><th>Název</th><th>Hodnota [Kč]</th><th>Doklad</th></tr>';
    289         $DbResult = $this->Database->select('FinanceInvoice', '*, (SELECT GROUP_CONCAT(Description SEPARATOR ",") '.
    290           'FROM FinanceInvoiceItem WHERE FinanceInvoiceItem.FinanceInvoice = FinanceInvoice.Id) AS Text',
    291           'Subject='.$_GET['Id'].' ORDER BY Time');
     340        $DbResult = $this->Database->query('SELECT `FinanceInvoice`.*, (SELECT GROUP_CONCAT(Description SEPARATOR ",") '.
     341          'FROM FinanceInvoiceItem WHERE `FinanceInvoiceItem`.`FinanceInvoice` = `FinanceInvoice`.`Id`) AS `Text`, `DocumentLineCode`.`Name` AS `BillName` '.
     342          'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id` = `FinanceOperation`.`BillCode` '.
     343          'WHERE `Subject`='.$_GET['Id'].' ORDER BY `Time`');
    292344        while($Row = $DbResult->fetch_array())
    293345        {
    294346          $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.HumanDate($Row['TimePayment']).
    295             '</td><td>'.$Row['Text'].'</td><td>'.ceil($Row['Value'] * $Row['ValueSign']).'</td><td>'.$Row['BillCode'].'</td></tr>';
     347            '</td><td>'.$Row['Text'].'</td><td>'.round($Row['Value'] * $Row['ValueSign'], $Finance->Rounding).'</td><td>'.$Row['BillName'].'</td></tr>';
    296348        }
    297349        $Output .= '</table></td></tr></table>';
Note: See TracChangeset for help on using the changeset viewer.