1 | <?php
|
---|
2 | include('../style.php');
|
---|
3 | include('include.php');
|
---|
4 | include('bills.php');
|
---|
5 | RecalculateTariffs(1);
|
---|
6 |
|
---|
7 | if(array_key_exists('id',$_GET)) $UserID = $_GET['id'];
|
---|
8 | if(!array_key_exists('show',$_GET)) $_GET['show'] = '';
|
---|
9 | switch($_GET['show'])
|
---|
10 | {
|
---|
11 | case 'user':
|
---|
12 | ShowHeader('Seznam účastníků sítě', 'Seznam účastníků');
|
---|
13 | $DbResult = $Database->query("SELECT *,CONCAT(second_name, ' ', first_name) as fullname FROM users WHERE id=".$UserID);
|
---|
14 | $Row2 = $DbResult->fetch_array();
|
---|
15 | $TarifName = $Tarify[$Row2['inet_tarif_next']]['name'];
|
---|
16 | echo('<table width="100%" border="0" cellspacing="0" cellpadding="3"><tr><td valign="top">');
|
---|
17 |
|
---|
18 | // Tabulka operaci
|
---|
19 | 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>Popis</th><th>Částka [Kč]</th><th>Doklad</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 DESC');
|
---|
24 | while($DbRow = $DbResult->fetch_array())
|
---|
25 | $Operations[] = $DbRow;
|
---|
26 | foreach($Operations as $Row)
|
---|
27 | {
|
---|
28 | if($Row['Value'] > 0) $Row['Value'] = '+'.$Row['Value'];
|
---|
29 | if($Row['Bill'] > 0) $Invoice = '<a href="?show=bill&id='.$Row['Bill'].'">PDF</a>'; else $Invoice = ' ';
|
---|
30 | echo('<tr><td align="right">'.HumanDate($Row['Time']).'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].'</td><td>'.$Invoice.'</td></tr>');
|
---|
31 | }
|
---|
32 | //echo('<tr><td> </td><td>-'.$Row2['network_device'].'</td><td>Proměnná cena za zařízení</td></tr>
|
---|
33 | echo('</table>');
|
---|
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>');
|
---|
39 | echo('</td><td valign="top">');
|
---|
40 |
|
---|
41 | if($Row2['role'] == 2)
|
---|
42 | {
|
---|
43 | echo('Variabilní symbol pro platby: <strong>'.$Row2['id'].'</strong><br><br>');
|
---|
44 |
|
---|
45 | // Měsíční bilance
|
---|
46 | if($Row2['inet'] == 1) $InternetPrice = round($Row2['monthly_inet']); else $InternetPrice = 0;
|
---|
47 | if($Row2['overheads'] == 0)
|
---|
48 | {
|
---|
49 | $PoplatekSprava = 0;
|
---|
50 | $PoplatekSpotreba = 0;
|
---|
51 | $PrijemSpotreba = $Row2['plus'];
|
---|
52 | } else {
|
---|
53 | $PoplatekSprava = $Sprava;
|
---|
54 | $PoplatekSpotreba = $Row2['consumption'];
|
---|
55 | $PrijemSpotreba = $Row2['plus'];
|
---|
56 | }
|
---|
57 | echo('Rozpis měsíčního poplatku:<br><table border="1" cellspacing="0" cellpadding="3">'.
|
---|
58 | '<tr><th>Část</th><th>Cena [Kč]</th></tr>'.
|
---|
59 | '<tr><td>Internet - tarif '.$TarifName.'</td><td>'.$InternetPrice.'</td></tr>'.
|
---|
60 | //'<tr><td>Správa</td><td>'.$PoplatekSprava.'</td></tr>'.
|
---|
61 | //'<tr><td>Poplatek za spotřebu</td><td>'.$PoplatekSpotreba.'</td></tr>'.
|
---|
62 | '<tr><td>Příjem za spotřebu</td><td>'.(-1*$PrijemSpotreba) .'</td></tr>'.
|
---|
63 | '<tr><td><strong>Celkem</strong></td><td><strong>'.($InternetPrice // + $PoplatekSprava + $PoplatekSpotreba
|
---|
64 | - $PrijemSpotreba).'</strong></td></tr></table>');
|
---|
65 | //echo('Tarif pro příští měsíc: '.$Tarify[$Row2['inet_tarif_next']]['name'].'<br><br>');
|
---|
66 | echo('<br>');
|
---|
67 |
|
---|
68 | /*
|
---|
69 |
|
---|
70 | // Rozpis ceny za zařízení
|
---|
71 | echo('Výpis podílu na zařízení segmentů:');
|
---|
72 | 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>');
|
---|
73 | $ID = $Row2['network_segment'];
|
---|
74 | $Money = 0;
|
---|
75 | while($ID > 0)
|
---|
76 | {
|
---|
77 | $DbResult = $Database->query("SELECT * FROM network_segments WHERE id=".$ID);
|
---|
78 | $Row = $DbResult->fetch_array();
|
---|
79 | if(!(($Row2['inet_hw'] == 0) and ($ID == $InternetSegmentId)))
|
---|
80 | {
|
---|
81 | $Money += $Row['price']/$Row['users'];
|
---|
82 | echo('<tr><td>'.$Row['name'].'</td><td>'.$Row['price'].'</td><td>'.$Row['users'].' </td><td>'.round($Row['price']/$Row['users']).'</td></tr>');
|
---|
83 | }
|
---|
84 | $ID = $Row['parent'];
|
---|
85 | }
|
---|
86 | echo('<tr><td><strong>Celkem</strong></td><td> </td><td> </td><td><strong>'.round($Money).'</strong></td></tr>');
|
---|
87 | echo('</table><br>');
|
---|
88 |
|
---|
89 | // Rozpis platba spotřeby segmentů
|
---|
90 | echo('Výpis podílu na spotřebě segmentů:');
|
---|
91 | 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>');
|
---|
92 | $ID = $Row2['network_segment'];
|
---|
93 | $Money = 0;
|
---|
94 | while($ID>0)
|
---|
95 | {
|
---|
96 | $DbResult = $Database->query("SELECT * FROM network_segments WHERE id=".$ID);
|
---|
97 | $Row = $DbResult->fetch_array();
|
---|
98 | $Money += round(W2Kc($Row['consumption'])/$Row['users_overheads']);
|
---|
99 | echo('<tr><td>'.$Row['name'].'</td><td>'.W2Kc($Row['consumption']).'</td><td>'.$Row['users_overheads'].' </td><td>'.round(W2Kc($Row['consumption'])/$Row['users_overheads']).'</td></tr>');
|
---|
100 | $ID = $Row['parent'];
|
---|
101 | }
|
---|
102 | echo('<tr><td><strong>Celkem</strong></td><td> </td><td> </td><td><strong>'.round($Money).'</strong></td></tr>');
|
---|
103 | echo('</table><br>');
|
---|
104 | */
|
---|
105 |
|
---|
106 | echo('Měsíční příjem za spotřebu zařízení umístěných u uživatele:<br>');
|
---|
107 | echo('<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>');
|
---|
108 | $DbResult = $Database->query("SELECT * FROM network_devices WHERE user=".$UserID." AND used=1");
|
---|
109 | $TotalW = 0;
|
---|
110 | $TotalPrice = 0;
|
---|
111 | while($Row = $DbResult->fetch_array())
|
---|
112 | {
|
---|
113 | echo('<tr><td>'.$Row['name'].'</td><td>'.$Row['consumption'].'</td><td>'.W2Kc($Row['consumption']).'</td></tr>');
|
---|
114 | $TotalW += $Row['consumption'];
|
---|
115 | $TotalPrice += W2Kc($Row['consumption']);
|
---|
116 | }
|
---|
117 | echo('<tr><td><strong>Celkem</strong></td><td><strong>'.$TotalW.'</strong></td><td><strong>'.$TotalPrice.'</strong></td></tr>');
|
---|
118 | echo('</table>');
|
---|
119 | }
|
---|
120 | echo('</td></tr></table>');
|
---|
121 | ShowFooter();
|
---|
122 | break;
|
---|
123 | case 'bill':
|
---|
124 | $InvoiceGenerator->ShowStoredBill($_GET['id']);
|
---|
125 | break;
|
---|
126 | default:
|
---|
127 | ShowHeader('Seznam účastníků sítě', 'Seznam účastníků');
|
---|
128 | // Seznam členů
|
---|
129 | echo('Seznam účastníků:<br>'.
|
---|
130 | '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'.
|
---|
131 | '<tr><th>Jméno</th>');
|
---|
132 | //<th>Cena za zařízení [Kč]</th>
|
---|
133 | echo('<th>Měsíční poplatek [Kč]</th><th>Stav účtu [Kč]</th><th>Běžící tarif</th><th>Příští tarif</th><th>Poznámky</th></tr>');
|
---|
134 | $TotalDevice = 0;
|
---|
135 | $TotalMonth = 0;
|
---|
136 | $TotalCash = 0;
|
---|
137 | $DbResult = $Database->query('SELECT *, CONCAT(users.second_name, " ", users.first_name) as Fullname, ((SELECT COALESCE(SUM(Value), 0) FROM FinanceCashFlow WHERE Subject=users.id) + '.
|
---|
138 | '(SELECT COALESCE(SUM(-Value), 0) FROM FinanceClaimsLiabilities WHERE Subject=users.id)) as Cash FROM users WHERE role=2 ORDER BY fullname');
|
---|
139 |
|
---|
140 | //$DbResult = $Database->query("SELECT *,CONCAT(second_name, ' ', first_name) as fullname FROM users WHERE role=2 ORDER BY fullname");
|
---|
141 | while($Row = $DbResult->fetch_array())
|
---|
142 | {
|
---|
143 | $Monthly = $Row['monthly'] - $Row['plus'];
|
---|
144 | if($Row['hw'] == 0) $Monthly = '(trvale nepřipojen) '.(-$Row['plus']);
|
---|
145 | else {
|
---|
146 | if($Row['overheads'] == 0) $Monthly = '(dočasně nepřipojen) '.$Monthly;
|
---|
147 | else {
|
---|
148 | if($Row['inet'] == 0) $Monthly = '(bez internetu) '.$Monthly;
|
---|
149 | else $Monthly = $Monthly;
|
---|
150 | }
|
---|
151 | }
|
---|
152 | //$Row['cash'] = $Row['AdvancesIn'] - $Row['AdvancesOut'] + $Row['Liabilities'] - $Row['Claims'];
|
---|
153 | $TotalCash += $Row['Cash'];
|
---|
154 | if($Row['Cash'] < 0) $Row['Cash'] = '<span style="color: red;">'.$Row['Cash'].'</span>';
|
---|
155 | $Tarif = $Tarify[$Row['inet_tarif_now']]['name'];
|
---|
156 | $PristiTarif = $Tarify[$Row['inet_tarif_next']]['name'];
|
---|
157 | echo('<tr><td><a href="?show=user&id='.$Row['id'].'">'.$Row['Fullname'].'</a></td>');
|
---|
158 | //<td align="right">'.$Row['network_device'].'</td>
|
---|
159 | 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'].' </td></tr>');
|
---|
160 | $TotalDevice += $Row['network_device'];
|
---|
161 | $TotalMonth += ($Row['monthly'] - $Row['plus']);
|
---|
162 | }
|
---|
163 | echo('<tr><td><strong>Celkem</strong></td>');
|
---|
164 | //<td align="right"><strong>'.$TotalDevice.'</strong></td>
|
---|
165 | echo('<td align="right"><strong>'.$TotalMonth.'</strong></td><td align="right"><strong>'.$TotalCash.'</strong></td><td align="right"> </td><td align="right"> </td><td align="right"> </td></tr>');
|
---|
166 | echo('</table>');
|
---|
167 | ShowFooter();
|
---|
168 | }
|
---|
169 |
|
---|
170 | ?>
|
---|