Changeset 70 for www/finance/clenove.php


Ignore:
Timestamp:
Apr 16, 2008, 6:17:48 PM (17 years ago)
Author:
george
Message:

Přidáno: Skripty pro podporu vedení daňové evidence.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • www/finance/clenove.php

    r60 r70  
    1010{
    1111  case 'user':
    12     ShowHeader('Seznam členů sítě', 'Seznam členů');
     12    ShowHeader('Seznam účastníků sítě', 'Seznam účastníků');
    1313    $DbResult = $Database->query("SELECT *,CONCAT(second_name, ' ', first_name) as fullname FROM users WHERE id=".$UserID);
    1414    $Row2 = $DbResult->fetch_array();
     
    1818    // Tabulka operaci
    1919    echo('Výpis operací pro účastníka '.$Row2['fullname'].':<br>');
    20     echo('<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3"><tr><th>Datum</th><th>Změna</th><th>Doklad</th><th>Komentář</th></tr>');
    21     $DbResult = $Database->query("SELECT * FROM finance_operations WHERE user=".$_GET['id'].' ORDER BY date DESC');
    22     while($Row = $DbResult->fetch_array())
     20    echo('<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3"><tr><th>Datum</th><th>Popis</th><th>Doklad</th><th>Komentář</th></tr>');
     21    $Operations = array();
     22    $DbResult = $Database->query('(SELECT Time, Value, Text, Bill FROM FinanceCashFlow WHERE Subject='.$_GET['id'].') UNION ALL '.
     23      '(SELECT TimeCreation as Time, (-Value) as Value, Text, Bill FROM FinanceClaimsLiabilities WHERE Subject='.$_GET['id'].') ORDER BY Time');
     24    while($DbRow = $DbResult->fetch_array())
     25      $Operations[] = $DbRow;
     26    foreach($Operations as $Row)
    2327    {
    24       if($Row['money'] > 0) $Row['money'] = '+'.$Row['money'];
    25       if($Row['bill_id'] > 0) $Invoice = '<a href="?show=bill&amp;id='.$Row['bill_id'].'">PDF</a>'; else $Invoice = '&nbsp;';
    26       echo('<tr><td align="right">'.HumanDate($Row['date']).'</td><td>'.$Row['money'].'</td><td>'.$Invoice.'</td><td>'.$Row['comment'].'&nbsp;</td></tr>');
     28      if($Row['Value'] > 0) $Row['Value'] = '+'.$Row['Value'];
     29      if($Row['Bill'] > 0) $Invoice = '<a href="?show=bill&amp;id='.$Row['Bill'].'">PDF</a>'; else $Invoice = '&nbsp;';
     30      echo('<tr><td align="right">'.HumanDate($Row['Time']).'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].'</td><td>'.$Invoice.'</td></tr>');
    2731    }
    2832    //echo('<tr><td>&nbsp;</td><td>-'.$Row2['network_device'].'</td><td>Proměnná cena za zařízení</td></tr>
    2933    echo('</table>');
    30     echo('<h3><strong>Stav účtu: </strong>'.$Row2['cash'].' Kč</h3><br>');
     34    $DbResult = $Database->query('SELECT ((SELECT COALESCE(SUM(Value), 0) FROM FinanceCashFlow WHERE Subject='.$_GET['id'].') + '.
     35      '(SELECT COALESCE(SUM(-Value), 0) FROM FinanceClaimsLiabilities WHERE Subject='.$_GET['id'].')) as Total');
     36    $DbRow = $DbResult->fetch_array();
     37    $Total = $DbRow['Total'];
     38    echo('<h3><strong>Stav účtu: </strong>'.$Total.' Kč</h3><br>');
    3139    echo('</td><td valign="top">');
    3240
     
    117125    break;
    118126  default:
    119     ShowHeader('Seznam členů sítě', 'Seznam členů');
     127    ShowHeader('Seznam účastníků sítě', 'Seznam účastníků');
    120128    // Seznam členů
    121     echo('Seznam členů:<br>'.
     129    echo('Seznam účastníků:<br>'.
    122130    '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'.
    123131    '<tr><th>Jméno</th>');
     
    127135    $TotalMonth = 0;
    128136    $TotalCash = 0;
    129     $DbResult = $Database->query("SELECT *,CONCAT(second_name, ' ', first_name) as fullname FROM users WHERE role=2 ORDER BY fullname");
     137    $DbResult = $Database->query('SELECT *, CONCAT(users.second_name, " ", users.first_name) as Fullname, (SELECT SUM(FinanceClaimsLiabilities.Value) FROM FinanceClaimsLiabilities WHERE FinanceClaimsLiabilities.Subject = users.id AND FinanceClaimsLiabilities.Value > 0 AND TimePayment IS NULL) as OpenedClaims, (SELECT SUM(FinanceClaimsLiabilities.Value) FROM FinanceClaimsLiabilities WHERE FinanceClaimsLiabilities.Subject = users.id AND FinanceClaimsLiabilities.Value < 0 AND TimePayment IS NULL) as OpenedLiabilities, (SELECT SUM(FinanceCashFlow.Value) FROM FinanceCashFlow WHERE FinanceCashFlow.Subject = users.id AND FinanceCashFlow.Value > 0) as Gains, (SELECT SUM(FinanceCashFlow.Value) FROM FinanceCashFlow WHERE FinanceCashFlow.Subject = users.id AND FinanceCashFlow.Value < 0) as Spends, (SELECT SUM(FinanceAdvances.Value) FROM FinanceAdvances WHERE FinanceAdvances.Subject = users.id AND FinanceAdvances.Direction="In") as AdvancesIn, (SELECT SUM(FinanceAdvances.Value) FROM FinanceAdvances WHERE FinanceAdvances.Subject = users.id AND FinanceAdvances.Direction="Out") as AdvancesOut FROM users WHERE role=2 ORDER BY fullname');
     138
     139    //$DbResult = $Database->query("SELECT *,CONCAT(second_name, ' ', first_name) as fullname FROM users WHERE role=2 ORDER BY fullname");
    130140    while($Row = $DbResult->fetch_array())
    131141    {
     
    139149        }
    140150      }
     151      $Row['cash'] = $Row['AdvancesIn'] - $Row['AdvancesOut'] + $Row['OpenedLiabilities'] - $Row['OpenedClaims'];
    141152      $TotalCash += $Row['cash'];
    142153      if($Row['cash'] < 0) $Row['cash'] = '<span style="color: red;">'.$Row['cash'].'</span>';
    143154      $Tarif = $Tarify[$Row['inet_tarif_now']]['name'];
    144155      $PristiTarif = $Tarify[$Row['inet_tarif_next']]['name'];
    145       echo('<tr><td><a href="?show=user&amp;id='.$Row['id'].'">'.$Row['fullname'].'</a></td>');
     156      echo('<tr><td><a href="?show=user&amp;id='.$Row['id'].'">'.$Row['Fullname'].'</a></td>');
    146157//<td align="right">'.$Row['network_device'].'</td>
    147158      echo('<td align="right">'.$Monthly.'</td><td align="right">'.$Row['cash'].'</td><td align="center">'.$Tarif.'</td><td align="center">'.$PristiTarif.'</td><td>'.$Row['notice'].'&nbsp;</td></tr>');
Note: See TracChangeset for help on using the changeset viewer.