/
monthly-report-2.php
321 lines (276 loc) · 9.04 KB
/
monthly-report-2.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
<?php
// index.php
// $Revision: 1.1 $ - $Date: 2007-11-11 20:06:00-05 $
//
// index is the opening page of the mi-nts website. It displays the
// standard menu, and then only some text introducing the site.
//
include('includes/session.inc');
$title=_('Michigan Section FSD-212');
include('includes/functions.inc');
// Remember the launch time
$starttime = strftime("%A, %B %d %Y, %H:%M");
// Open the database
$db = mysql_connect($host , $dbuser, $dbpassword);
mysql_select_db($DatabaseName,$db);
$period=92;
// Get the requested period, if blank choose the latest
$period = $_GET['period'];
if ( $period < 1 )
{
$SQL="SELECT MAX(`period`) FROM `arpsc_ecrept`";
$period = singleResult($SQL,$db);;
}
// Display the month name for this report
$SQL = 'SELECT lastday FROM `periods` WHERE `periodno`=' . $period;
$usedate=singleResult($SQL,$db);
if ( $keywords == "" )
$keywords="ARPSC ARES Michigan 'Amateur Radio Public Service Corps' 'Michigan Section' MI";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<?php
echo ' <title>' . $title . '</title>' . "\n";
echo ' <meta name="KEYWORDS" content="' . $keywords . '" />' . "\n";
?>
<style type="text/css" media="all">@import "css/arrl3c.css";</style>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://www.arrl-mi.org/?q=rss.xml" />
<link rel="shortcut icon" href="/misc/favicon.ico" type="image/x-icon" />
<!--<style type="text/css" media="all">@import "css/bluemarine.css";</style>-->
<script type="text/javascript"> </script>
</head>
<body>
<div id="container">
<?php
echo ' <div id="nonavbar">' . "\n";
echo " \n";
echo ' </div>' . "\n";
echo ' <div id="main">' . "\n";
echo ' <p>"Michigan Section ARPSC Report for ' . convertDate($usedate) . "\"</p>\n";
?>
<p>
District,Juris,"Monthly Man Hours","Contrib Dollar Value","Total # ARES mbrs",Chg,Net,,"Public Service",,Emergency<br />
,,,,,,Num,"Man Hours",Num,"Man Hours",Num,"Man Hours"<br />
<?php
//==================================================================================================
// S u m m a r y L i n e s
//==================================================================================================
// Initialize maxdate to most recent county update
$q0='SELECT MAX(`updated`) FROM `arpsc_counties`';
$r0=getResult($q0,$db);
$row0=getRow($r0,$db);
$maxdate=$row0[0];
// Loop through districts
$q1='SELECT `districtkey`, `district_code` from `arpsc_districts` ORDER BY `district_code`';
$r1=getResult($q1,$db);
$garesmem=0;
$gareschg=0;
$gnetsess=0;
$gnethrs =0;
$gpsnum =0;
$gpshrs =0;
$gemnum =0;
$gemhrs =0;
$gmanhrs =0;
$gvalue =0;
while ( $row1 = getRow($r1,$db) )
{
$district=$row1[1];
$manhrs=0;
$aresmem=0;
$areschg=0;
$netsess=0;
$nethrs=0;
$psnum = 0;
$pshrs = 0;
$emnum = 0;
$emhrs = 0;
$adhrs = 0;
$q2="SELECT `countyname`, `countycode` FROM `arpsc_counties` WHERE `district`='" .
$row1[0] . "' ORDER BY `countyname`";
$r2=getResult($q2,$db);
while ( $row2 = getRow($r2,$db) )
{
$q3='SELECT `aresmem`,`drillsnum`,`drillshrs`,`psesnum`,`pseshrs`,`eopsnum`,`eopshrs`,`aresopsnum`,`aresops`, `updated` ' .
"FROM `arpsc_ecrept` WHERE `county`='" . $row2[1] . "' AND `period`=" . $period;
$r3=getResult($q3,$db);
if ( $row3 = getRow($r3,$db) )
{
$hours = $row3[2]+$row3[4]+$row3[6]+$row3[8];
$value = $hours * 18.11;
$lastperiod = $period-1;
$q4="SELECT `aresmem` FROM `arpsc_ecrept` WHERE `county`='" . $row2[1] .
"' AND `period`=" . $lastperiod;
$r4=getResult($q4,$db);
if ( $row4 = getRow($r4,$db) )
{
$change = $row3[0]-$row4[0];
}
else
{
$q4="SELECT `aresmem` FROM `arpsc_ecrept` WHERE `county`='" . $row2[1] .
"' AND `period`=0";
$r4=getResult($q4,$db);
if ( $row4 = getRow($r4,$db) )
{
$change = $row3[0]-$row4[0];
}
else
{
$change = 0;
}
}
$aresmem=$aresmem+$row3[0];
$areschg=$areschg+$change;
$netsess=$netsess+$row3[1];
$nethrs=$nethrs+$row3[2];
$psnum = $psnum+$row3[3];
$pshrs = $pshrs+$row3[4];
$emnum = $emnum+$row3[5];
$emhrs = $emhrs+$row3[6];
$adhrs = $adhrs+$row3[8];
if ( $row3[9] > $maxdate )
{
$maxdate = $row3[9];
}
}
else
{
$q3='SELECT `aresmem` ' .
"FROM `arpsc_ecrept` WHERE `county`='" . $row2[1] . "' AND `period`=0";
$r3=getResult($q3,$db);
if ( $row3 = getRow($r3,$db) )
{
$aresmem=$aresmem+$row3[0];
}
}
}
$manhrs = $nethrs + $pshrs + $emhrs + $adhrs;
$value = $manhrs * 18.11;
echo $district . ',' . ',' . round($manhrs) . ',' . round($value) . ',' .
$aresmem . ',' . $areschg . ',' . $netsess . ',' . round($nethrs). ',' .
$psnum . ',' . round($pshrs) . ',' . $emnum . ',' . round($emhrs) . " <br />\n";
$garesmem=$garesmem+$aresmem;
$gareschg=$gareschg+$areschg;
$gnetsess=$gnetsess+$netsess;
$gnethrs =$gnethrs +$nethrs ;
$gpsnum =$gpsnum +$psnum ;
$gpshrs =$gpshrs +$pshrs ;
$gemnum =$gemnum +$emnum ;
$gemhrs =$gemhrs +$emhrs ;
$gmanhrs =$gmanhrs +$manhrs ;
$gvalue =$gvalue +$value ;
}
echo "Total all districts" . ",," . round($gmanhrs) . ',' . round($gvalue) . ',' .
$garesmem . ',' . $gareschg . ',' . $gnetsess . ',' . round($gnethrs) .',' .
$gpsnum . ',' . round($gpshrs) .',' . $gemnum . ',' . round($gemhrs) . "<br />\n";
//==================================================================================================
// D e t a i l L i n e s
//==================================================================================================
$q1='SELECT `districtkey`, `district_code` from `arpsc_districts` ORDER BY `district_code`';
$r1=getResult($q1,$db);
$olddistrict=0;
while ( $row1 = getRow($r1,$db) )
{
$district=$row1[1];
$q2="SELECT `countyname`, `countycode` FROM `arpsc_counties` WHERE `district`='" .
$district . "' ORDER BY `countyname`";
$r2=getResult($q2,$db);
if ( $district < ":" )
{
echo "<tr></tr>\n";
$sqlc='SELECT COUNT(*) FROM `arpsc_counties` WHERE `district`='
. $district;
$lc=singleResult($sqlc,$db);
while ( $row2 = getRow($r2,$db) )
{
//echo $district . ',' . $row2[0] . "<br>\n";
$q3='SELECT `aresmem`,`drillsnum`,`drillshrs`,`psesnum`,`pseshrs`,`eopsnum`,`eopshrs`,`aresopsnum`,`aresops` ' .
"FROM `arpsc_ecrept` WHERE `county`='" . $row2[1] . "' AND `period`=" . $period;
$r3=getResult($q3,$db);
if ( $row3 = getRow($r3,$db) )
{
$hours = $row3[2]+$row3[4]+$row3[6]+$row3[8];
$value = $hours * 18.11;
$lastperiod = $period-1;
$q4="SELECT `aresmem` FROM `arpsc_ecrept` WHERE `county`='" . $row2[1] .
"' AND `period`=" . $lastperiod;
$r4=getResult($q4,$db);
if ( $row4 = getRow($r4,$db) )
{
$change = $row3[0]-$row4[0];
}
else
{
$q4="SELECT `aresmem` FROM `arpsc_ecrept` WHERE `county`='" . $row2[1] .
"' AND `period`=0";
$r4=getResult($q4,$db);
if ( $row4 = getRow($r4,$db) )
{
$change = $row3[0]-$row4[0];
}
else
{
$change = " ";
}
}
echo "\t<tr>\n";
if ( $district != $olddistrict )
{
echo $district;
$olddistrict = $district;
}
echo ',' . $row2[0] . ',' . round($hours) . ',' . round($value) . ',' .
$row3[0] . ',' . $change . ',' . $row3[1] . ',' . $row3[2] . ',' . $row3[3] . ',' .
$row3[4] . ',' . $row3[5] . ',' . $row3[6] . "<br .>\n";
}
else
{
if ( $row2[0]=='Arenac' )
{
if ( $district != $olddistrict )
{
echo $district;
$olddistrict = $district;
}
echo "," . $row2[0] . ",";
echo "w/Ogemaw" . "<br />\n" ;
}
else if ( $row2[0]=='Clare' )
{
if ( $district != $olddistrict )
{
echo $district;
$olddistrict = $district;
}
echo "," . $row2[0] . ",";
echo "w/Isabella" . "<br />\n" ;
}
else
{
if ( $district != $olddistrict )
{
echo $district;
$olddistrict = $district;
}
echo "," . $row2[0] . ",";
echo '"- - - - N o R e p o r t - - - -"' . "<br/>\n";
}
}
}
}
}
echo "<p></p>\n";
echo "\" Requested: " . $starttime . "Z\"<br />\n";
echo "\" Most recent data: " . $maxdate . "E\"<br />\n";
echo "\" copyright © 2007, Michigan Section, American Radio Relay League\"\n";
echo " </div>\n";
echo " <div id=\"footer\">\n";
echo " </div>\n";
//footer($starttime,$maxdate,
// "\$Revision: 1.1 $ - \$Date: 2007-11-11 20:06:00-05 $");
?>
</div>
</body>
</html>