1 | 2 | simandl | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
2 | | | <html> |
3 | | | <head> |
4 | | | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2"> |
5 | | | <style type="text/css" media="screen"> @import "style.css"; </style> |
6 | | | <title>db.jablonka.cz - Elektrika</title> |
7 | | | </head> |
8 | | | <link rel="stylesheet" type="text/css" href="style.css"> |
9 | | | </head> |
10 | | | <body topmargin=0 leftmargin=10> |
11 | | | <? |
12 | | | include ("header.htm"); |
13 | | | require('grab_globals.lib.php'); |
14 | | | include ("fce.php"); |
15 | | | $spojeni = MySQL_Connect($db_host, $db_user, $db_pass); |
16 | | | MySQL_Select_DB($db_name); |
17 | | | |
18 | | | |
19 | | | echo ' |
20 | | | <center>'; |
21 | | | |
22 | | | if(!@$show) $show="all"; |
23 | | | if(!@$order) $order="uk.datum"; |
24 | | | if(!@$elektromer) $elektromer="vsechno"; |
25 | | | if(!@$rok) $rok="vsechno"; |
26 | | | |
27 | | | if($rok=="vsechno") { |
28 | | | $condition = ""; |
29 | | | } else { |
30 | | | $condition = " AND YEAR(uk.datum)=$rok"; |
31 | | | } |
32 | | | |
33 | | | |
34 | | | if($show!="all") |
35 | | | { |
36 | | | echo '<b>Seznam úkonů aktivních uživatelů:</b> <a href="elektrika.php?show=all&elektromer='.$elektromer.'&rok='.$rok.'&order='.$order.'" class=odkaz>zobrazit vše</a>'; |
37 | | | $where="WHERE active IN (1) $condition "; |
38 | | | } |
39 | | | else |
40 | | | { |
41 | | | echo '<b>Seznam úkonů všech uživatelů:</b> <a href="elektrika.php?show=active&elektromer='.$elektromer.'&rok='.$rok.'&order='.$order.'" class=odkaz>zobrazit pouze aktivní</a>'; |
42 | | | $where="WHERE active IN (0,1) $condition "; |
43 | | | } |
44 | | | |
45 | | | echo "<br>"; |
46 | | | #tisk datumu plateb |
47 | | | echo "Rok : "; |
48 | | | $dotaz=MySQL_Query("SELECT DISTINCT YEAR(datum) from ukony ORDER BY datum"); |
49 | | | $count=MySQL_Num_Rows($dotaz); |
50 | | | $count++; |
51 | | | for ($i=1;$i<$count;$i++) |
52 | | | { |
53 | | | $radek=MySQL_Fetch_Array($dotaz); |
54 | | | echo "<a href=\"elektrika.php?show=$show&elektromer=$elektromer&rok=".$radek["YEAR(datum)"]."&order=$order\">".$radek["YEAR(datum)"].'</a> * '; |
55 | | | echo ' |
56 | | | '; |
57 | | | } |
58 | | | #dotisk posledni volby pro vsechny roky |
59 | | | echo "<a href=\"elektrika.php?show=$show&elektromer=$elektromer&rok=vsechno&order=$order\">všechno</a>"; |
60 | | | echo ' |
61 | | | '; |
62 | | | |
63 | | | echo "<br>"; |
64 | | | #tisk vsech moznosti elektromeru |
65 | | | echo "Elektroměry : "; |
66 | | | $dbelektromery=MySQL_Query("SELECT * from majetek WHERE zarizeni=7 ORDER BY id"); |
67 | | | $count=MySQL_Num_Rows($dbelektromery); |
68 | | | $count++; |
69 | | | for ($i=1;$i<$count;$i++) |
70 | | | { |
71 | | | $radek=MySQL_Fetch_Array($dbelektromery); |
72 | | | echo "<a href=\"elektrika.php?show=$show&rok=$rok&elektromer=".$radek["id"]."&order=$order\">".id_to_majetek($radek["id"]).'</a> * '; |
73 | | | echo ' |
74 | | | '; |
75 | | | } |
76 | | | #dotisk posledni volby pro vsechny elektromery |
77 | | | echo "<a href=\"elektrika.php?show=$show&rok=$rok&elektromer=vsechno&order=$order\">všechno</a><br><br>"; |
78 | | | echo ' |
79 | | | '; |
80 | | | #nastaveni databaze znovu na zacatek |
81 | | | mysql_data_seek($dbelektromery, 0); |
82 | | | |
83 | | | #finalni dotaz |
84 | | | #$string=MySQL_Query("SELECT c.id as cid, c.*, uk.id as ukid, uk.adresa as ukadresa, uk.finance as ukfinance, uk.*, u.id as uid, u.*, i.id as iid, i.* |
85 | | | # FROM ((cleni c LEFT JOIN ukony uk ON c.id = uk.clen) |
86 | | | # LEFT JOIN elektromeri u ON uk.elektromer = u.id) |
87 | | | # LEFT JOIN ipecka i ON uk.predmet = i.id AND uk.udalost IN (17,18) $where ORDER BY $order"); |
88 | | | |
89 | | | echo ' |
90 | | | |
91 | | | <table width=100% cellspacing=1> |
92 | | | <tr> |
93 | | | <td bgcolor=#73BE1E> |
94 | | | |
95 | | | <table cellspacing=0 cellpadding=0 width=100%> |
96 | | | <tr> |
97 | | | <td bgcolor=#FFFFFF class=text> |
98 | | | <a title="seřadit podle ID" class=odkaz href="elektrika.php?show='.$show.'&elektromer='.$elektromer.'&rok='.$rok.'&order=cid">Elektroměr</a> |
99 | | | </td> |
100 | | | <td bgcolor=#FFFFFF class=text> |
101 | | | <a title="seřadit podle ID" class=odkaz href="elektrika.php?show='.$show.'&elektromer='.$elektromer.'&rok='.$rok.'&order=cid">Místo odběru</a> |
102 | | | </td> |
103 | | | <td bgcolor=#FFFFFF class=text> |
104 | | | <a title="seřadit podle ID" class=odkaz href="elektrika.php?show='.$show.'&elektromer='.$elektromer.'&rok='.$rok.'&order=cid">Spotřebič</a> |
105 | | | </td> |
106 | | | <td bgcolor=#FFFFFF class=text> |
107 | | | <a title="seřadit podle ID" class=odkaz href="elektrika.php?show='.$show.'&elektromer='.$elektromer.'&rok='.$rok.'&order=cid">Spotřeba [W]</a> |
108 | | | </td> |
109 | | | <td bgcolor=#FFFFFF class=text> |
110 | | | <a title="seřadit podle ID" class=odkaz href="elektrika.php?show='.$show.'&elektromer='.$elektromer.'&rok='.$rok.'&order=cid">Doba provozu</a> |
111 | | | </td> |
112 | | | <td bgcolor=#FFFFFF class=text> |
113 | | | <a title="seřadit podle ID" class=odkaz href="elektrika.php?show='.$show.'&elektromer='.$elektromer.'&rok='.$rok.'&order=cid">Náklady</a> |
114 | | | </td> |
115 | | | <td bgcolor=#FFFFFF class=text> |
116 | | | <a title="seřadit podle ID" class=odkaz href="elektrika.php?show='.$show.'&elektromer='.$elektromer.'&rok='.$rok.'&order=cid">Náklady celkem</a> |
117 | | | </td> |
118 | | | </tr> |
119 | | | '; |
120 | | | |
121 | | | $color=1; |
122 | | | $celkem=0; |
123 | | | $nakladycelkem=0; |
124 | | | |
125 | | | while($vysledek=MySQL_Fetch_Array($dbelektromery)) |
126 | | | { |
127 | | | $celkem++; |
128 | | | if($color==0) |
129 | | | { |
130 | | | $color=1; |
131 | | | $barva="#E6E4E4"; |
132 | | | } |
133 | | | else |
134 | | | { |
135 | | | $color=0; |
136 | | | $barva="#FFFFFF"; |
137 | | | } |
138 | | | |
139 | | | $dot="apj.bmp"; |
140 | | | $alt="AP Jablonecká"; |
141 | | | |
142 | | | $elektromer=$vysledek["id"]; |
143 | | | #dotaz na adresy kde se meri nebo merilo danym elektromerem - neni to omezeno |
144 | | | $dbadresy=MySQL_Query("SELECT adresa FROM ukony WHERE udalost IN (17) AND majetek=$elektromer ORDER BY id"); |
145 | | | |
146 | | | #posbirame vsechny id adres pro dotaz na spotrebice |
147 | | | $pocetadres=MySQL_Num_Rows($dbadresy); |
148 | | | $adresyid=""; |
149 | | | while($adresaid=MySQL_Fetch_Array($dbadresy)) |
150 | | | { |
151 | | | if($adresyid=="") |
152 | | | { $adresyid.=$adresaid["adresa"]; |
153 | | | } else { |
154 | | | $adresyid.=",".$adresaid["adresa"]; |
155 | | | } |
156 | | | } |
157 | | | mysql_data_seek($dbadresy, 0); |
158 | | | |
159 | | | #dotaz na jednotlive spotrebice povesene na dany elektromer |
160 | | | $dbspotrebice=MySQL_Query("SELECT * FROM ukony WHERE udalost IN (17) AND adresa IN ($adresyid) AND majetek<>$elektromer ORDER BY id"); |
161 | | | |
162 | | | $pocetspotrebicu=MySQL_Num_Rows($dbspotrebice); |
163 | | | $spotrebice=""; |
164 | | | |
165 | | | |
166 | | | while($spotrebic=MySQL_Fetch_Array($dbspotrebice)) |
167 | | | { |
168 | | | $spotrebice.=id_to_majetek($spotrebic["majetek"]).","; |
169 | | | } |
170 | | | mysql_data_seek($dbspotrebice, 0); |
171 | | | |
172 | | | ######################################################## |
173 | | | $nakladyelektromer=0; |
174 | | | |
175 | | | for ($i=0;$i<$pocetadres;$i++) |
176 | | | { |
177 | | | |
178 | | | $dbadresaid=MySQL_Fetch_Array($dbadresy); |
179 | | | $adresaid=$dbadresaid["adresa"]; |
180 | | | |
181 | | | #dotaz na jednotlive spotrebice povesene na dany elektromer na dane adrese |
182 | | | $dbspotrebice=MySQL_Query("SELECT * FROM ukony WHERE udalost IN (17) AND adresa IN ($adresaid) AND majetek<>$elektromer ORDER BY id"); |
183 | | | $pocetspotrebicu=MySQL_Num_Rows($dbspotrebice); |
184 | | | |
185 | | | for ($j=0;$j<$pocetspotrebicu;$j++) |
186 | | | { |
187 | | | $dbspotrebic=MySQL_Fetch_Array($dbspotrebice); |
188 | | | |
189 | | | $spotreba=id_to_spotreba($dbspotrebic["majetek"]); |
190 | | | $dobaprovozu=round(id_to_delkaspotreby($dbspotrebic["majetek"],$rok)/(60*60*24*15))/2; |
191 | | | $naklady=(3.6/1000)*$spotreba*$dobaprovozu*30*24; |
192 | | | $nakladyelektromer+=$naklady; |
193 | | | |
194 | | | echo ' |
195 | | | <tr> |
196 | | | <td bgcolor='.$barva.' class=text> |
197 | | | '.id_to_majetek($vysledek["id"]).' |
198 | | | </td> |
199 | | | <td bgcolor='.$barva.' class=text> |
200 | | | '.id_to_adresa($adresaid).' |
201 | | | </td> |
202 | | | <td bgcolor='.$barva.' class=text> |
203 | | | '.id_to_majetek($dbspotrebic["majetek"]).' |
204 | | | </td> |
205 | | | <td bgcolor='.$barva.' class=text> |
206 | | | '.$spotreba.' |
207 | | | </td> |
208 | | | <td bgcolor='.$barva.' class=text> |
209 | | | '.$dobaprovozu.' |
210 | | | </td> |
211 | | | <td bgcolor='.$barva.' class=text> |
212 | | | '.$naklady.' |
213 | | | </td> |
214 | | | <td bgcolor='.$barva.' class=text> |
215 | | | '.$nakladyelektromer.' |
216 | | | </td> |
217 | | | </tr> |
218 | | | |
219 | | | '; |
220 | | | |
221 | | | } # for spotrebice |
222 | | | } # for adresy |
223 | | | |
224 | | | $nakladycelkem+=$nakladyelektromer; |
225 | | | |
226 | | | } # while elektromery |
227 | | | |
228 | | | |
229 | | | echo ' |
230 | | | </table> |
231 | | | </tr></td> |
232 | | | </table> |
233 | | | </center> |
234 | | | <br> |
235 | | | Celkem zobrazeno '.$celkem.' záznamů. Celkové náklady jsou '.$nakladycelkem.'Kč. |
236 | | | '; |
237 | | | ?> |
238 | | | </body> |
239 | | | </html> |