Changeset 272 for trunk/finance/user_state.php
- Timestamp:
- Jan 10, 2010, 5:02:00 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/finance/user_state.php
r227 r272 10 10 function Show() 11 11 { 12 13 12 $Finance = &$this->System->Modules['Finance']; 13 $this->System->Modules['Finance']->LoadTariffs(1); 14 14 15 15 if(array_key_exists('old', $_GET)) 16 17 16 { 17 $MemberId = GetMemberByIP(GetRemoteAddress()); 18 18 if($MemberId != '') 19 19 { … … 21 21 $Subject = $DbResult->fetch_assoc(); 22 22 } else die('Nemáte oprávnění'); 23 23 } else 24 24 if(array_key_exists('Subject', $_GET)) 25 26 25 { 26 if(!$this->System->Modules['User']->CheckPermission('Finance', 'Manage')) return('Nemáte oprávnění'); 27 27 $DbResult = $this->Database->query('SELECT * FROM Subject WHERE Id='.$_GET['Subject']); 28 28 $Subject = $DbResult->fetch_assoc(); 29 29 } else 30 31 30 { 31 if(!$this->System->Modules['User']->CheckPermission('Finance', 'DisplaySubjectState')) return('Nemáte oprávnění'); 32 32 $UserId = $this->System->Modules['User']->User['Id']; 33 33 $DbResult = $this->Database->query('SELECT * FROM Subject WHERE Id=(SELECT Subject FROM Member WHERE Id=(SELECT Member FROM User WHERE Id='.$UserId.'))'); 34 34 $Subject = $DbResult->fetch_assoc(); 35 35 } 36 36 37 37 if(!array_key_exists('show', $_GET)) $_GET['show'] = ''; … … 39 39 $Member = $DbResult->fetch_assoc(); 40 40 $TarifName = $Finance->Tariffs[$Member['InternetTariffCurrentMonth']]['Name']; 41 41 $TarifPrice = $Finance->Tariffs[$Member['InternetTariffCurrentMonth']]['Price']; 42 42 $Output = '<table width="100%" border="0" cellspacing="0" cellpadding="3"><tr><td valign="top">'; 43 43 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 44 64 $UserOperationTableQuery = '((SELECT Text, Time, Value AS Value, Bill FROM FinanceOperation WHERE (Subject='.$Subject['Id'].')) UNION ALL '. 45 65 '(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); 47 67 $DbRow = $DbResult->fetch_array(); 48 68 $Total = $DbRow['Total']; 49 69 $Output .= 'Stav účtu: <strong>'.$Total.' Kč</strong<br /><br />'; 50 70 71 51 72 // Tabulka operaci 52 73 $Output .= 'Výpis operací pro subjekt '.$Subject['Name'].':<br />'; 53 74 $Output .= '<table style="font-size: smaller;" class="WideTable"><tr><th>Datum</th><th>Popis</th><th>Částka</th><th>Doklad</th></tr>'; 54 75 $Operations = array(); 55 $DbResult = $this->Database->query('SELECT T1.* FROM '.$UserOperationTableQuery );76 $DbResult = $this->Database->query('SELECT T1.* FROM '.$UserOperationTableQuery.$YearWhere); 56 77 while($DbRow = $DbResult->fetch_array()) 57 78 $Operations[] = $DbRow; … … 69 90 $Output .= 'Variabilní symbol pro platby: <strong>'.$Subject['Id'].'</strong><br><br>'; 70 91 71 92 $Total = 0; 72 93 $Output .= 'Rozpis měsíčního poplatku:<br><table class="WideTable">'. 73 94 '<tr><th>Část</th><th>Cena [Kč]</th></tr>'. 74 95 '<tr><td>Internet - tarif '.$TarifName.'</td><td>'.$TarifPrice.'</td></tr>'; 75 96 $Total += $TarifPrice; 76 97 if($Member['Hire'] != 0) 77 98 { 78 99 $Output .= '<tr><td>Nájem</td><td>'.(-$Member['Hire']).'</td></tr>'; 79 100 $Total -= $Member['Hire']; 80 101 } 81 102 if($Member['MonthlyPlus'] != 0) 82 103 { 83 104 $Output .= '<tr><td>Příjem za spotřebu</td><td>'.(-$Member['MonthlyPlus']).'</td></tr>'; 84 105 $Total -= $Member['MonthlyPlus']; 85 106 } 86 107 $Output .= '<tr><td><strong>Celkem</strong></td><td><strong>'.$Total.'</strong></td></tr></table>'; … … 103 124 $Output .= '<tr><td><strong>Celkem</strong></td><td><strong>'.$TotalW.'</strong></td><td><strong>'.$TotalPrice.'</strong></td></tr>'; 104 125 $Output .= '</table>'; 105 126 } 106 127 $Output .= '</td></tr></table>'; 107 128 return($Output);
Note:
See TracChangeset
for help on using the changeset viewer.