source: www/web/finance/clenove.php@ 1

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

Prvotní import všeho

  • Property svn:executable set to *
File size: 6.3 KB
Line 
1<?
2
3$DirectoryList = array('Seznam èlenù', 'Seznam èlenù sítì',
4);
5
6function Finance_Clenove_Show()
7{
8 global $PathRemain, $Internet, $InternetUsers, $kWh, $Sprava, $SpravaUsers, $PathRemain, $InternetSegmentId;
9
10 if(count($PathRemain) > 0)
11 {
12 $UserId = addslashes($PathRemain[0]);
13 DB_Query("SELECT * FROM users WHERE id=".$UserId);
14 $Row2 = DB_Row();
15 $Result = '<table width="100%" border="0" cellspacing="0" cellpadding="3"><tr><td valign="top">';
16
17 // Tabulka operaci
18 $Result .= 'Výpis operací pro èlena '.$Row2['fullname'].':<br>';
19 $Result .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3"><tr><th>Datum</th><th>Zmìna</th><th>Komentáø</th></tr>';
20 DB_Query("SELECT * FROM finance_operations WHERE user=".$UserId.' ORDER BY date DESC');
21 while($Row = DB_Row())
22 {
23 if($Row['money']>0) $Row['money'] = '+'.$Row['money'];
24 $Result .= '<tr><td align="right">'.HumanDate($Row['date']).'</td><td>'.$Row['money'].'</td><td>'.$Row['comment'].'&nbsp;</td></tr>';
25 }
26 $Result .= '<tr><td>&nbsp;</td><td>-'.$Row2['network_device'].'</td><td>Promìnná cena za zaøízení</td></tr></table>';
27 $Result .= '<h3><strong>Stav úètu: </strong>'.$Row2['cash'].' Kè</h3><br>';
28 $Result .= '</td><td valign="top">';
29
30 // Mìsíèní bilance
31 if($Row2['inet'] == 1) $InternetPrice = round($Internet/$InternetUsers); else $InternetPrice = 0;
32 if($Row2['overheads'] == 0)
33 {
34 $PoplatekSprava = 0;
35 $PoplatekSpotreba = 0;
36 $PrijemSpotreba = $Row2['plus'];
37 } else {
38 $PoplatekSprava = $Sprava;
39 $PoplatekSpotreba = $Row2['consumption'];
40 $PrijemSpotreba = $Row2['plus'];
41 }
42 $Result .= 'Rozpis mìsíèního poplatku:<br><table border="1" cellspacing="0" cellpadding="3">'.
43 '<tr><th>Èást</th><th>Cena [Kè]</th></tr>'.
44 '<tr><td>Internet</td><td>'.$InternetPrice.'</td></tr>'.
45 '<tr><td>Správa</td><td>'.$PoplatekSprava.'</td></tr>'.
46 '<tr><td>Poplatek za spotøebu</td><td>'.$PoplatekSpotreba.'</td></tr>'.
47 '<tr><td>Pøíjem za spotøebu</td><td>'.(-1*$PrijemSpotreba) .'</td></tr>'.
48 '<tr><td><strong>Celkem</strong></td><td><strong>'.($InternetPrice + $PoplatekSprava + $PoplatekSpotreba - $PrijemSpotreba).'</strong></td></tr></table><br>';
49
50 // Rozpis ceny za zaøízení
51 $Result .= 'Výpis podílu na zaøízení segmentù:';
52 $Result .= '<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>';
53 $ID = $Row2['network_segment'];
54 $Money = 0;
55 while($ID>0)
56 {
57 DB_Query("SELECT * FROM network_segments WHERE id=".$ID);
58 $Row = DB_Row();
59 if(!(($Row2['inet_hw'] == 0) and ($ID == $InternetSegmentId)))
60 {
61 $Money += $Row['price']/$Row['users'];
62 $Result .= '<tr><td>'.$Row['name'].'</td><td>'.$Row['price'].'</td><td>'.$Row['users'].'&nbsp;</td><td>'.round($Row['price']/$Row['users']).'</td></tr>';
63 }
64 $ID = $Row['parent'];
65 }
66 $Result .= '<tr><td><strong>Celkem</strong></td><td>&nbsp;</td><td>&nbsp;</td><td><strong>'.round($Money).'</strong></td></tr>';
67 $Result .= '</table><br>';
68
69 // Rozpis platba spotøeby segmentù
70 $Result .= 'Výpis podílu na spotøebì segmentù:';
71 $Result .= '<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>';
72 $ID = $Row2['network_segment'];
73 $Money = 0;
74 while($ID>0)
75 {
76 DB_Query("SELECT * FROM network_segments WHERE id=".$ID);
77 $Row = DB_Row();
78 $Money += round(W2Kc($Row['consumption'])/$Row['users_overheads']);
79 $Result .= '<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>';
80 $ID = $Row['parent'];
81 }
82 $Result .= '<tr><td><strong>Celkem</strong></td><td>&nbsp;</td><td>&nbsp;</td><td><strong>'.round($Money).'</strong></td></tr>';
83 $Result .= '</table><br>';
84
85 $Result .= 'Mìsíèní pøíjem za spotøebu zaøízení umístìných u u¾ivatele:<br>';
86 $Result .= '<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>';
87 DB_Query("SELECT * FROM network_devices WHERE user=".$UserId." AND used=1");
88 $TotalW = 0;
89 $TotalPrice = 0;
90 while($Row = DB_Row())
91 {
92 $Result .= '<tr><td>'.$Row['name'].'</td><td>'.$Row['consumption'].'</td><td>'.W2Kc($Row['consumption']).'</td></tr>';
93 $TotalW += $Row['consumption'];
94 $TotalPrice += W2Kc($Row['consumption']);
95 }
96 $Result .= '<tr><td><strong>Celkem</strong></td><td><strong>'.$TotalW.'</strong></td><td><strong>'.$TotalPrice.'</strong></td></tr>';
97 $Result .= '</table>';
98
99 $Result .= '</td></tr></table>';
100 } else {
101 // Seznam èlenù
102 $Result = 'Seznam èlenù:<br>'.
103 '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'.
104 '<tr><th>Jméno</th><th>Cena za zaøízení [Kè]</th><th>Mìsíèní poplatek [Kè]</th><th>Stav úètu [Kè]</th><th>Poznámky</th></tr>';
105 $TotalDevice = 0;
106 $TotalMonth = 0;
107 $TotalCash = 0;
108 DB_Query("SELECT * FROM users WHERE role=0 ORDER BY fullname");
109 while($Row = DB_Row())
110 {
111 $Monthly = $Row['monthly'] - $Row['plus'];
112 if($Row['hw'] == 0) $Monthly = '(trvale nepøipojen) '.(-$Row['plus']);
113 else {
114 if($Row['overheads'] == 0) $Monthly = '(doèasnì nepøipojen) '.$Monthly;
115 else {
116 if($Row['inet'] == 0) $Monthly = '(bez internetu) '.$Monthly;
117 else $Monthly = $Monthly;
118 }
119 }
120 $TotalCash += $Row['cash'];
121 if($Row['cash']<0) $Row['cash'] = '<span style="color: red;">'.$Row['cash'].'</span>';
122 $Result .= '<tr><td><a href="'.$Row['id'].'/">'.$Row['fullname'].'</a></td><td align="right">'.$Row['network_device'].'</td><td align="right">'.$Monthly.'</td><td align="right">'.$Row['cash'].'</td><td>'.$Row['notice'].'&nbsp;</td></tr>';
123 $TotalDevice += $Row['network_device'];
124 $TotalMonth += ($Row['monthly']-$Row['plus']);
125 }
126 $Result .= '<tr><td><strong>Celkem</strong></td><td align="right"><strong>'.$TotalDevice.'</strong></td><td align="right"><strong>'.$TotalMonth.'</strong></td><td align="right"><strong>'.$TotalCash.'</strong></td><td align="right">&nbsp;</td></tr>';
127 $Result .= '</table>';
128 }
129 return($Result);
130}
131
132?>
Note: See TracBrowser for help on using the repository browser.