Changeset 691


Ignore:
Timestamp:
Sep 7, 2014, 10:50:01 PM (10 years ago)
Author:
chronos
Message:
  • Přidáno: Zobrazení průběžného zůstatku ve zobrazení financí zákazníků.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/Version.php

    r690 r691  
    11<?php
    22
    3 $Revision = 690; // Subversion revision
     3$Revision = 691; // Subversion revision
    44$DatabaseRevision = 688; // SQL structure revision
    55$ReleaseTime = strtotime('2014-09-07');
  • trunk/Modules/Finance/UserState.php

    r688 r691  
    1212          'FROM FinanceOperation WHERE (Subject='.$Subject['Id'].')) UNION ALL '.
    1313                '(SELECT (SELECT GROUP_CONCAT(Description SEPARATOR ",") FROM FinanceInvoiceItem WHERE FinanceInvoice=FinanceInvoice.Id) AS Text, '.
    14                 'Time, -Value as Value, File, BillCode, PeriodFrom, PeriodTo FROM FinanceInvoice WHERE (Subject='.$Subject['Id'].')) ORDER BY Time DESC) AS T1';
     14                'Time, -Value as Value, File, BillCode, PeriodFrom, PeriodTo FROM FinanceInvoice WHERE (Subject='.$Subject['Id'].')))';
    1515
    1616    $Output = '<div style="text-align:center">Výpis finančních operací</div>';
    17         $DbResult = $this->Database->query('SELECT COUNT(*) FROM '.$UserOperationTableQuery.'');
     17        $DbResult = $this->Database->query('SELECT COUNT(*) FROM '.$UserOperationTableQuery.' AS T1');
    1818        $DbRow = $DbResult->fetch_row();
    1919        $PageList = GetPageList($DbRow[0]);
     
    2525                        array('Name' => 'Time', 'Title' => 'Datum'),
    2626                        array('Name' => 'Description', 'Title' => 'Popis'),
    27                         array('Name' => 'Value', 'Title' => 'Částka [Kč]'),
     27                        array('Name' => 'Value', 'Title' => 'Změna [Kč]'),
     28                        array('Name' => 'State', 'Title' => 'Zůstatek [Kč]'),
    2829                        array('Name' => 'Period', 'Title' => 'Období'),
    2930                        array('Name' => 'Bill', 'Title' => 'Doklad'),
     
    3233        $Output .= $Order['Output'];
    3334
    34         $Query = 'SELECT * FROM '.$UserOperationTableQuery.' '.$Order['SQL'].$PageList['SQLLimit'];
     35        $StateQuery = 'SELECT SUM(T2.Value) FROM '.$UserOperationTableQuery.
     36          ' AS T2 WHERE T2.Time <= T1.Time ';
     37        $Query = 'SELECT *, ('.$StateQuery.') AS State FROM '.$UserOperationTableQuery.' AS T1 '.$Order['SQL'].$PageList['SQLLimit'];
    3538
    3639        $DbResult = $this->Database->query($Query);
     
    3841        while($Row = $DbResult->fetch_assoc())
    3942        {
     43                $Row['State'] = round($Row['State'], 2);
     44                if($Row['State'] > 0) $Row['State'] = '<span style="color:green;">'.$Row['State'].'</span>';
     45                if($Row['State'] < 0) $Row['State'] = '<span style="color:red;">'.$Row['State'].'</span>';
    4046                if($Row['Value'] == -0) $Row['Value'] = 0;
    4147                if($Row['Value'] > 0) $Row['Value'] = '+'.$Row['Value'];
     
    4854                                '<td style="text-align: left;">'.$Row['Text'].'</td>'.
    4955                                '<td style="text-align: right;">'.round($Row['Value'], 2).'</td>'.
     56                                '<td style="text-align: right;">'.$Row['State'].'</td>'.
    5057                                '<td>'.$Period.'</td>'.
    5158                                '<td>'.$Invoice.'</td></tr>';
     
    6774      if(!$this->System->User->CheckPermission('Finance', 'Manage')) return('Nemáte oprávnění');
    6875      $DbResult = $this->Database->query('SELECT * FROM Subject WHERE Id='.$_GET['Subject']);
    69       $Subject = $DbResult->fetch_assoc();
     76      if($DbResult->num_rows > 0)
     77        $Subject = $DbResult->fetch_assoc();
     78      else return($this->SystemMessage('Chyba', 'Subjekt nenalezen'));
    7079    } else
    7180    {
Note: See TracChangeset for help on using the changeset viewer.