Ignore:
Timestamp:
Feb 10, 2013, 9:20:06 PM (12 years ago)
Author:
chronos
Message:
  • Upraveno: Příprava na zrušení tabulek dokladů a jejich převedení na tabulky File a FinanceInvoice.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/finance/user_state.php

    r479 r486  
    5252      else $SubjectParam = '';
    5353    $Output .= 'Roky: ';
    54     $DbResult = $this->Database->query('SELECT * FROM FinanceYear');
     54    $DbResult = $this->Database->query('SELECT * FROM FinanceYear WHERE Year >= '.
     55      substr($Member['MembershipDate'], 0, strpos($Member['MembershipDate'], '-')));
    5556    while($FinanceYear = $DbResult->fetch_assoc())
    5657    {
     
    6263   
    6364    // Account state   
    64     $UserOperationTableQuery = '((SELECT Text, Time, Value AS Value, Bill, BillCode FROM FinanceOperation WHERE (Subject='.$Subject['Id'].')) UNION ALL '.
    65       '(SELECT Text, TimeCreation as Time, -Value as Value, Bill, BillCode FROM FinanceClaimsLiabilities WHERE (Subject='.$Subject['Id'].')) ORDER BY Time DESC) AS T1';
     65    $UserOperationTableQuery = '((SELECT Text, Time, Value AS Value, Bill, BillCode, NULL AS PeriodFrom, NULL AS PeriodTo '.
     66      'FROM FinanceOperation WHERE (Subject='.$Subject['Id'].')) UNION ALL '.
     67      '(SELECT (SELECT GROUP_CONCAT(Description SEPARATOR ",") FROM FinanceInvoiceItem WHERE FinanceInvoice=FinanceInvoice.Id) AS Text, '.
     68      'TimeCreation as Time, -Value as Value, Bill, BillCode, PeriodFrom, PeriodTo FROM FinanceInvoice WHERE (Subject='.$Subject['Id'].')) ORDER BY Time DESC) AS T1';
    6669    $DbResult = $this->Database->query('SELECT SUM(T1.Value) AS Total FROM '.$UserOperationTableQuery);
    6770    $DbRow = $DbResult->fetch_array();
     
    7275    // Tabulka operaci
    7376    $Output .= 'Výpis operací pro subjekt '.$Subject['Name'].':<br />';
    74     $Output .= '<table style="font-size: smaller;" class="WideTable"><tr><th>Datum</th><th>Popis</th><th>Částka</th><th>Doklad</th></tr>';
     77    $Output .= '<table style="font-size: smaller;" class="WideTable"><tr>'.
     78    '<th>Datum</th><th>Popis</th><th>Částka</th><th>Období</th><th>Doklad</th></tr>';
    7579    $Operations = array();
    7680    $DbResult = $this->Database->query('SELECT T1.* FROM '.$UserOperationTableQuery.$YearWhere);
     
    8387      if($Row['Value'] > 0) $Row['Value'] = '+'.$Row['Value'];
    8488      if($Row['BillCode'] == '') $Row['BillCode'] = 'PDF';
    85       if($Row['Bill'] > 0) $Invoice = '<a href="bill.php?Id='.$Row['Bill'].'">'.$Row['BillCode'].'</a>'; else $Invoice = '&nbsp;';
    86       $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>';
     89      if($Row['Bill'] > 0) $Invoice = '<a href="bill.php?Id='.$Row['Bill'].'">'.$Row['BillCode'].'</a>';
     90        else $Invoice = '&nbsp;';
     91      if($Row['PeriodFrom'] != '') $Period = HumanDate($Row['PeriodFrom']).' - '.HumanDate($Row['PeriodTo']);
     92        else $Period = '&nbsp;';
     93      $Output .= '<tr><td style="text-align: right;">'.HumanDate($Row['Time']).'</td>'.
     94      '<td style="text-align: left;">'.$Row['Text'].'</td>'.
     95      '<td style="text-align: right;">'.$Row['Value'].'</td>'.
     96      '<td style="text-align: center;">'.$Period.'</td>'.
     97      '<td style="text-align: center;">'.$Invoice.'</td></tr>';
    8798      $SumValue = $SumValue + $Row['Value'];
    8899    }
    89     $Output .= '<tr><td style="text-align: right;" colspan="2"><strong>Celkem za rok</strong></td><td style="text-align: right;"><strong>'.$SumValue.'</strong></td><td style="text-align: center;">&nbsp;</td></tr>';
     100    $Output .= '<tr><td style="text-align: right;" colspan="2"><strong>Celkem za rok</strong></td>'.
     101    '<td style="text-align: right;"><strong>'.$SumValue.'</strong></td>'.
     102    '<td style="text-align: center;">&nbsp;</td>'.
     103    '<td style="text-align: center;">&nbsp;</td></tr>';
    90104   
    91105   
Note: See TracChangeset for help on using the changeset viewer.