source: devel/www/finance/user_state.php@ 87

Last change on this file since 87 was 87, checked in by george, 17 years ago

Přidáno: Nová vývojová větev webu sítě. Všechny stránky jsou předělávány na objektový přístup a stránky samotné nevypisují výstup přímo přes echo, ale vracejí zobrazovaná data přes návratovou hodnotu funkce.

File size: 6.5 KB
Line 
1<?php
2
3include_once('../global.php');
4include_once('include.php');
5RecalculateTariffs(1);
6
7class FinanceUserState extends Page
8{
9 var $FullTitle = 'Stav financí účastníka';
10 var $ShortTitle = 'Stav financí';
11
12 function Show()
13 {
14 global $Tarify, $Sprava;
15
16 if(!$this->System->Modules['User']->CheckPermission('Finance', 'UserState')) return('Nemáte oprávnění');
17
18 $UserId = $this->System->Modules['User']->User['Id'];
19 if(!array_key_exists('show',$_GET)) $_GET['show'] = '';
20 $DbResult = $this->Database->query("SELECT *,CONCAT(second_name, ' ', first_name) as fullname FROM users WHERE id=".$UserId);
21 $Row2 = $DbResult->fetch_array();
22 $TarifName = $Tarify[$Row2['inet_tarif_next']]['name'];
23 $Output = '<table width="100%" border="0" cellspacing="0" cellpadding="3"><tr><td valign="top">';
24
25 // Tabulka operaci
26 $Output .= 'Výpis operací pro účastníka '.$Row2['fullname'].':<br>';
27 $Output .= '<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>';
28 $Operations = array();
29 $DbResult = $this->Database->query('(SELECT Time, Value, Text, Bill FROM FinanceCashFlow WHERE Subject='.$UserId.') UNION ALL '.
30 '(SELECT TimeCreation as Time, (-Value) as Value, Text, Bill FROM FinanceClaimsLiabilities WHERE Subject='.$UserId.') ORDER BY Time DESC');
31 while($DbRow = $DbResult->fetch_array())
32 $Operations[] = $DbRow;
33 foreach($Operations as $Row)
34 {
35 if($Row['Value'] > 0) $Row['Value'] = '+'.$Row['Value'];
36 if($Row['Bill'] > 0) $Invoice = '<a href="?show=bill&amp;id='.$Row['Bill'].'">PDF</a>'; else $Invoice = '&nbsp;';
37 $Output .= '<tr><td align="right">'.HumanDate($Row['Time']).'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].'</td><td>'.$Invoice.'</td></tr>';
38 }
39 //echo('<tr><td>&nbsp;</td><td>-'.$Row2['network_device'].'</td><td>Proměnná cena za zařízení</td></tr>
40 $Output .= '</table>';
41 $DbResult = $this->Database->query('SELECT ((SELECT COALESCE(SUM(Value), 0) FROM FinanceCashFlow WHERE Subject='.$UserId.') + '.
42 '(SELECT COALESCE(SUM(-Value), 0) FROM FinanceClaimsLiabilities WHERE Subject='.$UserId.')) as Total');
43 $DbRow = $DbResult->fetch_array();
44 $Total = $DbRow['Total'];
45 $Output .= '<h3><strong>Stav účtu: </strong>'.$Total.' Kč</h3><br>';
46 $Output .= '</td><td valign="top">';
47
48 if($Row2['role'] == 2)
49 {
50 $Output .= 'Variabilní symbol pro platby: <strong>'.$Row2['id'].'</strong><br><br>';
51
52 // Měsíční bilance
53 if($Row2['inet'] == 1) $InternetPrice = round($Row2['monthly_inet']); else $InternetPrice = 0;
54 if($Row2['overheads'] == 0)
55 {
56 $PoplatekSprava = 0;
57 $PoplatekSpotreba = 0;
58 $PrijemSpotreba = $Row2['plus'];
59 } else {
60 $PoplatekSprava = $Sprava;
61 $PoplatekSpotreba = $Row2['consumption'];
62 $PrijemSpotreba = $Row2['plus'];
63 }
64 $Output .= 'Rozpis měsíčního poplatku:<br><table border="1" cellspacing="0" cellpadding="3">'.
65 '<tr><th>Část</th><th>Cena [Kč]</th></tr>'.
66 '<tr><td>Internet - tarif '.$TarifName.'</td><td>'.$InternetPrice.'</td></tr>'.
67 //'<tr><td>Správa</td><td>'.$PoplatekSprava.'</td></tr>'.
68 //'<tr><td>Poplatek za spotřebu</td><td>'.$PoplatekSpotreba.'</td></tr>'.
69 '<tr><td>Příjem za spotřebu</td><td>'.(-1*$PrijemSpotreba) .'</td></tr>'.
70 '<tr><td><strong>Celkem</strong></td><td><strong>'.($InternetPrice // + $PoplatekSprava + $PoplatekSpotreba
71 - $PrijemSpotreba).'</strong></td></tr></table>';
72 //echo('Tarif pro příští měsíc: '.$Tarify[$Row2['inet_tarif_next']]['name'].'<br><br>');
73 $Output .= '<br>';
74
75 /*
76
77 // Rozpis ceny za zařízení
78 echo('Výpis podílu na zařízení segmentů:');
79 echo('<table border="1" cellspacing="0" cellpadding="3"><tr><th>Název segmentu</th><th>Cena [Kč]</th><th>Uživatelů</th><th>Podíl [Kč]</th></tr>');
80 $ID = $Row2['network_segment'];
81 $Money = 0;
82 while($ID > 0)
83 {
84 $DbResult = $Database->query("SELECT * FROM network_segments WHERE id=".$ID);
85 $Row = $DbResult->fetch_array();
86 if(!(($Row2['inet_hw'] == 0) and ($ID == $InternetSegmentId)))
87 {
88 $Money += $Row['price']/$Row['users'];
89 echo('<tr><td>'.$Row['name'].'</td><td>'.$Row['price'].'</td><td>'.$Row['users'].'&nbsp;</td><td>'.round($Row['price']/$Row['users']).'</td></tr>');
90 }
91 $ID = $Row['parent'];
92 }
93 echo('<tr><td><strong>Celkem</strong></td><td>&nbsp;</td><td>&nbsp;</td><td><strong>'.round($Money).'</strong></td></tr>');
94 echo('</table><br>');
95
96 // Rozpis platba spotřeby segmentů
97 echo('Výpis podílu na spotřebě segmentů:');
98 echo('<table border="1" cellspacing="0" cellpadding="3"><tr><th>Název segmentu</th><th>Cena [Kč]</th><th>Uživatelů</th><th>Podíl [Kč]</th></tr>');
99 $ID = $Row2['network_segment'];
100 $Money = 0;
101 while($ID>0)
102 {
103 $DbResult = $Database->query("SELECT * FROM network_segments WHERE id=".$ID);
104 $Row = $DbResult->fetch_array();
105 $Money += round(W2Kc($Row['consumption'])/$Row['users_overheads']);
106 echo('<tr><td>'.$Row['name'].'</td><td>'.W2Kc($Row['consumption']).'</td><td>'.$Row['users_overheads'].'&nbsp;</td><td>'.round(W2Kc($Row['consumption'])/$Row['users_overheads']).'</td></tr>');
107 $ID = $Row['parent'];
108 }
109 echo('<tr><td><strong>Celkem</strong></td><td>&nbsp;</td><td>&nbsp;</td><td><strong>'.round($Money).'</strong></td></tr>');
110 echo('</table><br>');
111 */
112
113 $Output .= 'Měsíční příjem za spotřebu zařízení umístěných u uživatele:<br>';
114 $Output .= '<table border="1" cellspacing="0" cellpadding="3"><tr><th>Název zařízení</th><th>Spotřeba [W]</th><th>Příjem [Kč]</th></tr>';
115 $DbResult = $this->Database->query("SELECT * FROM network_devices WHERE user=".$UserId." AND used=1");
116 $TotalW = 0;
117 $TotalPrice = 0;
118 while($Row = $DbResult->fetch_array())
119 {
120 $Output .= '<tr><td>'.$Row['name'].'</td><td>'.$Row['consumption'].'</td><td>'.W2Kc($Row['consumption']).'</td></tr>';
121 $TotalW += $Row['consumption'];
122 $TotalPrice += W2Kc($Row['consumption']);
123 }
124 $Output .= '<tr><td><strong>Celkem</strong></td><td><strong>'.$TotalW.'</strong></td><td><strong>'.$TotalPrice.'</strong></td></tr>';
125 $Output .= '</table>';
126 }
127 $Output .= '</td></tr></table>';
128 return($Output);
129 }
130
131}
132
133$System->AddModule(new FinanceUserState());
134$System->Modules['FinanceUserState']->GetOutput();
135
136?>
Note: See TracBrowser for help on using the repository browser.