Changeset 272 for trunk/finance


Ignore:
Timestamp:
Jan 10, 2010, 5:02:00 PM (15 years ago)
Author:
george
Message:
  • Upraveno: Zobrazení výpisů finančních operací klientů dle roků.
  • Přidáno: Skript pro periodickou kontrolu adres DHCP serverů a zajištění přenositelnosti IP adres klientů.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/finance/user_state.php

    r227 r272  
    1010  function Show()
    1111  {
    12           $Finance = &$this->System->Modules['Finance'];
    13           $this->System->Modules['Finance']->LoadTariffs(1);
     12    $Finance = &$this->System->Modules['Finance'];
     13    $this->System->Modules['Finance']->LoadTariffs(1);
    1414
    1515    if(array_key_exists('old', $_GET))
    16           {
    17             $MemberId = GetMemberByIP(GetRemoteAddress());
     16    {
     17      $MemberId = GetMemberByIP(GetRemoteAddress());
    1818      if($MemberId != '')
    1919      {
     
    2121        $Subject = $DbResult->fetch_assoc();
    2222      } else die('Nemáte oprávnění');
    23           } else
     23    } else
    2424    if(array_key_exists('Subject', $_GET))
    25           {
    26             if(!$this->System->Modules['User']->CheckPermission('Finance', 'Manage')) return('Nemáte oprávnění');
     25    {
     26      if(!$this->System->Modules['User']->CheckPermission('Finance', 'Manage')) return('Nemáte oprávnění');
    2727      $DbResult = $this->Database->query('SELECT * FROM Subject WHERE Id='.$_GET['Subject']);
    2828      $Subject = $DbResult->fetch_assoc();
    2929    } else
    30           {
    31             if(!$this->System->Modules['User']->CheckPermission('Finance', 'DisplaySubjectState')) return('Nemáte oprávnění');
     30    {
     31      if(!$this->System->Modules['User']->CheckPermission('Finance', 'DisplaySubjectState')) return('Nemáte oprávnění');
    3232      $UserId = $this->System->Modules['User']->User['Id'];
    3333      $DbResult = $this->Database->query('SELECT * FROM Subject WHERE Id=(SELECT Subject FROM Member WHERE Id=(SELECT Member FROM User WHERE Id='.$UserId.'))');
    3434      $Subject = $DbResult->fetch_assoc();
    35           }
     35    }
    3636   
    3737    if(!array_key_exists('show', $_GET)) $_GET['show'] = '';
     
    3939    $Member = $DbResult->fetch_assoc();
    4040    $TarifName = $Finance->Tariffs[$Member['InternetTariffCurrentMonth']]['Name'];
    41           $TarifPrice = $Finance->Tariffs[$Member['InternetTariffCurrentMonth']]['Price'];
     41    $TarifPrice = $Finance->Tariffs[$Member['InternetTariffCurrentMonth']]['Price'];
    4242    $Output = '<table width="100%" border="0" cellspacing="0" cellpadding="3"><tr><td valign="top">';
    4343
     44    if(array_key_exists('year', $_GET))
     45    {
     46      $DbResult = $this->Database->query('SELECT * FROM FinanceYear WHERE Id='.$_GET['year']);
     47    } else
     48    {
     49      $DbResult = $this->Database->query('SELECT * FROM FinanceYear ORDER BY Year DESC LIMIT 1');
     50    }
     51    $FinanceYearSelected = $DbResult->fetch_assoc();
     52    $YearWhere = ' WHERE (Time >= "'.$FinanceYearSelected['DateStart'].'") AND (Time <= "'.$FinanceYearSelected['DateEnd'].'")';
     53
     54    $Output .= 'Roky: ';
     55    $DbResult = $this->Database->query('SELECT * FROM FinanceYear');
     56    while($FinanceYear = $DbResult->fetch_assoc())
     57    {
     58      $Year = '<a href="?year='.$FinanceYear['Id'].'">'.$FinanceYear['Year'].'</a> ';
     59      if($FinanceYear['Id'] == $FinanceYearSelected['Id']) $Output .= '<strong>'.$Year.'</strong>';
     60        else $Output .= $Year;
     61    }
     62    $Output .= '<br/><br/>';   
     63   
    4464    $UserOperationTableQuery = '((SELECT Text, Time, Value AS Value, Bill FROM FinanceOperation WHERE (Subject='.$Subject['Id'].')) UNION ALL '.
    4565      '(SELECT Text, TimeCreation as Time, -Value as Value, Bill FROM FinanceClaimsLiabilities WHERE (Subject='.$Subject['Id'].')) ORDER BY Time DESC) AS T1';
    46     $DbResult = $this->Database->query('SELECT SUM(T1.Value) AS Total FROM '.$UserOperationTableQuery);
     66    $DbResult = $this->Database->query('SELECT SUM(T1.Value) AS Total FROM '.$UserOperationTableQuery.$YearWhere);
    4767    $DbRow = $DbResult->fetch_array();
    4868    $Total = $DbRow['Total'];
    4969    $Output .= 'Stav účtu: <strong>'.$Total.' Kč</strong<br /><br />';
    5070
     71   
    5172    // Tabulka operaci
    5273    $Output .= 'Výpis operací pro subjekt '.$Subject['Name'].':<br />';
    5374    $Output .= '<table style="font-size: smaller;" class="WideTable"><tr><th>Datum</th><th>Popis</th><th>Částka</th><th>Doklad</th></tr>';
    5475    $Operations = array();
    55     $DbResult = $this->Database->query('SELECT T1.* FROM '.$UserOperationTableQuery);
     76    $DbResult = $this->Database->query('SELECT T1.* FROM '.$UserOperationTableQuery.$YearWhere);
    5677    while($DbRow = $DbResult->fetch_array())
    5778      $Operations[] = $DbRow;
     
    6990    $Output .= 'Variabilní symbol pro platby: <strong>'.$Subject['Id'].'</strong><br><br>';
    7091
    71           $Total = 0;
     92    $Total = 0;
    7293    $Output .= 'Rozpis měsíčního poplatku:<br><table class="WideTable">'.
    7394      '<tr><th>Část</th><th>Cena [Kč]</th></tr>'.
    7495      '<tr><td>Internet - tarif '.$TarifName.'</td><td>'.$TarifPrice.'</td></tr>';
    7596    $Total += $TarifPrice;
    76           if($Member['Hire'] != 0)
     97    if($Member['Hire'] != 0)
    7798    {
    7899      $Output .= '<tr><td>Nájem</td><td>'.(-$Member['Hire']).'</td></tr>';
    79             $Total -= $Member['Hire'];
     100      $Total -= $Member['Hire'];
    80101    }
    81           if($Member['MonthlyPlus'] != 0)
     102    if($Member['MonthlyPlus'] != 0)
    82103    {
    83104      $Output .= '<tr><td>Příjem za spotřebu</td><td>'.(-$Member['MonthlyPlus']).'</td></tr>';
    84             $Total -= $Member['MonthlyPlus'];
     105      $Total -= $Member['MonthlyPlus'];
    85106    }
    86107    $Output .= '<tr><td><strong>Celkem</strong></td><td><strong>'.$Total.'</strong></td></tr></table>';
     
    103124      $Output .= '<tr><td><strong>Celkem</strong></td><td><strong>'.$TotalW.'</strong></td><td><strong>'.$TotalPrice.'</strong></td></tr>';
    104125      $Output .= '</table>';
    105         }
     126  }
    106127    $Output .= '</td></tr></table>';
    107128    return($Output);
Note: See TracChangeset for help on using the changeset viewer.