-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathold_index.php
469 lines (433 loc) · 13.1 KB
/
old_index.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
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
<?PHP
// preprocess data using zip.php (reviews all zip codes over known time)
$page_description = "Reopen Status - Phase One";
include_once('menu.php');
global $date;
$date = $global_date;
// move inside function?
$q = "SELECT distinct zip_code FROM coronavirus_zip where state_name = 'Maryland'";
$r = $covid_db->query($q);
$total_zip = $r->num_rows;
$flat = 23;
$down = 0;
// pull date from last update, not assume today.
$date = $global_date;
?>
<?PHP
ob_start();
$total_up=0;
$total_flat=0;
$total_down=0;
$new_up=0;
$new_flat=0;
$new_down=0;
?>
<div class="row">
<div class="col-sm-12">
<div id="chartContainer5" style="height: 400px; width: 100%;"></div>
</div>
</div>
<?PHP
/*
<div class="row">
<div class="col-sm-12">
<h3>We are setting up this page to track zipcodes across the curve. As they trend higher we count the days,
as they flatten off we count the days, as they drop we count the days. Every time the trend changes the
duration resets.</h3>
</div>
</div>
<?PHP
*/
function make_reopen($state){
global $covid_db;
$return1 = '';
$return2 = '';
$range = '30';
$q = "SELECT * FROM coronavirus_reopen where state = '$state' ";
$r = $covid_db->query($q);
$rows = mysqli_num_rows($r);
$start = $rows - $range;
$test1 = $start;
$range2= $range - 1;
$start = max($start, 0);
$q = "SELECT * FROM coronavirus_reopen where state = '$state' limit $start, $range";
$r = $covid_db->query($q);
$test1 = $test1 + 1;
if ($test1 < 0){
foreach(range($test1,0) as $days){
$date = date('Y-m-d',strtotime($days.' days'));
$return1 .= '{ label: "'.$date.'", y: 0 }, ';
$return2 .= '{ label: "'.$date.'", y: 0 }, ';
}
}
while ($d = mysqli_fetch_array($r)){
$return1 .= '{ label: "'.$d['the_date'].'", y: '.$d['zip_open'].' }, ';
$return2 .= '{ label: "'.$d['the_date'].'", y: '.$d['zip_closed'].' }, ';
}
$return[] = rtrim(trim($return1), ",");
$return[] = rtrim(trim($return2), ",");
return $return;
}
?>
<script src="canvasjs.min.js"></script>
<script>
window.onload = function () {
var chart = new CanvasJS.Chart("chartContainer", {
animationEnabled: true,
exportEnabled: true,
title: {
text: "<?PHP echo $state;?> Zipcode Curve Position <?PHP echo $date;?> covid19math.net"
},
data: [{
type: "pie",
startAngle: 240,
yValueFormatString: "#####",
indexLabel: "{label} {y}",
dataPoints: [
{y: <?PHP echo intval($total_up);?>, label: "UP"},
{y: <?PHP echo intval($total_flat);?>, label: "FLAT"},
{y: <?PHP echo intval($total_down);?>, label: "DOWN"}
]
}]
});
chart.render();
var chart2 = new CanvasJS.Chart("chartContainer2", {
animationEnabled: true,
exportEnabled: true,
title: {
text: "<?PHP echo $state;?> Zipcode New Curve Position <?PHP echo $date;?> covid19math.net"
},
data: [{
type: "pie",
startAngle: 240,
yValueFormatString: "#####",
indexLabel: "{label} {y}",
dataPoints: [
{y: <?PHP echo intval($new_up);?>, label: "UP"},
{y: <?PHP echo intval($new_flat);?>, label: "FLAT"},
{y: <?PHP echo intval($new_down);?>, label: "DOWN"}
]
}]
});
chart2.render();
var chart5 = new CanvasJS.Chart("chartContainer5", {
theme:"light2",
animationEnabled: true,
exportEnabled: true,
title:{
text: "14 Days Flat <?PHP echo $date;?> covid19math.net"
},
axisY :{
includeZero: false,
title: "Number of ZIP Codes",
suffix: ""
},
toolTip: {
shared: "true"
},
legend:{
cursor:"pointer",
itemclick : toggleDataSeries
},
data: [{
type: "line",
visible: true,
showInLegend: true,
yValueFormatString: "#####",
name: "Maryland Open",
dataPoints: [
<?PHP echo make_reopen('Maryland')[0]; ?>
]
},{
type: "line",
visible: true,
showInLegend: true,
yValueFormatString: "#####",
name: "Maryland Closed",
dataPoints: [
<?PHP echo make_reopen('Maryland')[1]; ?>
]
},{
type: "line",
visible: true,
showInLegend: true,
yValueFormatString: "#####",
name: "Florida Open",
dataPoints: [
<?PHP echo make_reopen('Florida')[0]; ?>
]
},{
type: "line",
visible: true,
showInLegend: true,
yValueFormatString: "#####",
name: "Florida Closed",
dataPoints: [
<?PHP echo make_reopen('Florida')[1]; ?>
]
},{
type: "line",
visible: true,
showInLegend: true,
yValueFormatString: "#####",
name: "Virginia Open",
dataPoints: [
<?PHP echo make_reopen('Virginia')[0]; ?>
]
},{
type: "line",
visible: true,
showInLegend: true,
yValueFormatString: "#####",
name: "Virginia Closed",
dataPoints: [
<?PHP echo make_reopen('Virginia')[1]; ?>
]
},{
type: "line",
visible: true,
showInLegend: true,
yValueFormatString: "#####",
name: "New York Open",
dataPoints: [
<?PHP echo make_reopen('New York')[0]; ?>
]
},{
type: "line",
visible: true,
showInLegend: true,
yValueFormatString: "#####",
name: "New York Closed",
dataPoints: [
<?PHP echo make_reopen('New York')[1]; ?>
]
}]
}
);
chart5.render();
function toggleDataSeries(e) {
if (typeof (e.dataSeries.visible) === "undefined" || e.dataSeries.visible) {
e.dataSeries.visible = false;
} else {
e.dataSeries.visible = true;
}
e.chart.render();
}
}
</script>
<?PHP
function state_data($state){
global $covid_db;
ob_start();
$total_up=0;
$total_flat=0;
$total_down=0;
$new_up=0;
$new_flat=0;
$new_down=0;
?>
<div class="row">
<div class="col-sm-6">
<h3>14+ Day Trends Flat / Down</h3>
<ol>
<?PHP
$q = "SELECT * FROM coronavirus_zip where report_date = '$date' and trend_duration > '13' and state_name = '$state' and report_count <> 0 and trend_direction <> 'up' order by trend_duration DESC";
$r = $covid_db->query($q);
while($d = mysqli_fetch_array($r)){
$color='orange';
if ($d['trend_direction'] == 'FLAT'){
$color = 'lightgreen';
}
echo "<li style='background-color:$color;'><a href='zipcode.php?zip=$d[zip_code]'>For $d[trend_duration] days, $d[town_name] ( $d[zip_code] ) has been going $d[trend_direction] and is now $d[report_count]</a></li>";
}
?>
</ol>
</div>
<div class="col-sm-6">
<h3>14+ Day Trends Up</h3>
<ol>
<?PHP
$q = "SELECT * FROM coronavirus_zip where report_date = '$date' and trend_duration > '13' and state_name = '$state' and report_count <> 0 and trend_direction = 'up' order by trend_duration DESC";
$r = $covid_db->query($q);
while($d = mysqli_fetch_array($r)){
$color='orange';
if ($d['trend_direction'] == 'FLAT'){
$color = 'lightgreen';
}
echo "<li style='background-color:$color;'><a href='zipcode.php?zip=$d[zip_code]'>For $d[trend_duration] days, $d[town_name] ( $d[zip_code] ) has been going $d[trend_direction] and is now $d[report_count]</a></li>";
}
?>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm-4">
<h3>Up Trend</h3>
<ol>
<?PHP
$q = "SELECT * FROM coronavirus_zip where report_date = '$date' and trend_direction = 'UP' and trend_duration <> '0' and state_name = '$state' order by trend_duration DESC";
$r = $covid_db->query($q);
while($d = mysqli_fetch_array($r)){
echo "<li><a href='zipcode.php?zip=$d[zip_code]'>$d[town_name] $d[zip_code] $d[trend_direction] at $d[report_count] for $d[trend_duration] days</a></li>";
$total_up++;
}
?>
</ol>
</div>
<div class="col-sm-4">
<h3>Flat Trend</h3>
<ol>
<?PHP
$q = "SELECT * FROM coronavirus_zip where report_date = '$date' and trend_direction = 'FLAT' and report_count <> '0' and trend_duration <> 0 and state_name = '$state' order by trend_duration DESC";
$r = $covid_db->query($q);
while($d = mysqli_fetch_array($r)){
echo "<li><a href='zipcode.php?zip=$d[zip_code]'>$d[town_name] $d[zip_code] $d[trend_direction] at $d[report_count] for $d[trend_duration] days</a></li>";
$total_flat++;
}
?>
</ol>
</div>
<div class="col-sm-4">
<h3>Down Trend</h3>
<ol>
<?PHP
$q = "SELECT * FROM coronavirus_zip where report_date = '$date' and trend_direction = 'DOWN' and trend_duration <> '0' and state_name = '$state' order by trend_duration DESC";
$r = $covid_db->query($q);
while($d = mysqli_fetch_array($r)){
echo "<li><a href='zipcode.php?zip=$d[zip_code]'>$d[town_name] $d[zip_code] $d[trend_direction] at $d[report_count] for $d[trend_duration] days</a></li>";
$total_down++;
}
?>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm-4">
<h3>New Direction Up</h3>
<ol>
<?PHP
$q = "SELECT * FROM coronavirus_zip where report_date = '$date' and trend_direction = 'UP' and trend_duration = '0' and state_name = '$state' order by trend_duration DESC";
$r = $covid_db->query($q);
while($d = mysqli_fetch_array($r)){
echo "<li><a href='zipcode.php?zip=$d[zip_code]'>$d[town_name] $d[zip_code] $d[trend_direction] at $d[report_count]</a></li>";
$new_up++;
}
?>
</ol>
</div>
<div class="col-sm-4">
<h3>New Direction Flat</h3>
<ol>
<?PHP
$q = "SELECT * FROM coronavirus_zip where report_date = '$date' and trend_direction = 'FLAT' and report_count <> 0 and trend_duration = '0' and state_name = '$state' order by trend_duration DESC";
$r = $covid_db->query($q);
while($d = mysqli_fetch_array($r)){
echo "<li><a href='zipcode.php?zip=$d[zip_code]'>$d[town_name] $d[zip_code] $d[trend_direction] at $d[report_count]</a></li>";
$new_flat++;
}
?>
</ol>
</div>
<div class="col-sm-4">
<h3>New Direction Down</h3>
<ol>
<?PHP
$q = "SELECT * FROM coronavirus_zip where report_date = '$date' and trend_direction = 'DOWN' and trend_duration = '0' and state_name = '$state' order by trend_duration DESC";
$r = $covid_db->query($q);
while($d = mysqli_fetch_array($r)){
echo "<li><a href='zipcode.php?zip=$d[zip_code]'>$d[town_name] $d[zip_code] $d[trend_direction] at $d[report_count]</a></li>";
$new_down++;
}
?>
</ol>
</div>
</div>
<?PHP
$buffer = ob_get_clean();
$return = array();
$return['buffer'] = $buffer;
$return['new_down'] = intval($new_down);
$return['new_flat'] = intval($new_flat);
$return['new_up'] = intval($new_up);
$return['total_down'] = intval($total_down);
$return['total_flat'] = intval($total_flat);
$return['total_up'] = intval($total_up);
return $return;
}
$array = state_data('Maryland');
$buffer = $array['buffer'];
$new_down = $return['new_down'];
$new_flat = $return['new_flat'];
$new_up = $return['new_up'];
$total_down = $return['total_down'];
$total_flat = $return['total_flat'];
$total_up = $return['total_up'];
echo $buffer;
function count_open_zips($state){
global $covid_db;
global $global_date;
$date = $global_date;
$zip_open=0;
$zip_closed=0;
?>
<div class="row">
<div class="col-sm-12">
<h1>Phase One Reopen <?PHP echo $date.' '.$state;?></h1><p>The following zip codes are flat or down for over 2 weeks and ready to look at how to begin phase one.</p>
<?PHP
$q = "SELECT * FROM coronavirus_zip where report_date = '$date' and trend_duration > '13' and state_name = '$state' and (trend_direction = 'DOWN' or trend_direction = 'FLAT' ) order by report_count desc";
$r = $covid_db->query($q);
while($d = mysqli_fetch_array($r)){
$zip_open++;
echo "[ <a href='zipcode.php?zip=$d[zip_code]'>$d[zip_code] at $d[report_count]</a> ]";
}
?>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<h1>Not Phase One <?PHP echo $date.' '.$state;?></h1>
<?PHP
$q = "SELECT * FROM coronavirus_zip where report_date = '$date' and trend_duration > '13' and state_name = '$state' and trend_direction = 'UP' order by report_count desc ";
$r = $covid_db->query($q);
while($d = mysqli_fetch_array($r)){
$zip_closed++;
echo "[ <a href='zipcode.php?zip=$d[zip_code]'>$d[zip_code] at $d[report_count]</a> ]";
}
$q = "SELECT * FROM coronavirus_zip where report_date = '$date' and trend_duration < '13' and state_name = '$state' order by report_count desc";
$r = $covid_db->query($q);
while($d = mysqli_fetch_array($r)){
$zip_closed++;
echo "[ <a href='zipcode.php?zip=$d[zip_code]'>$d[zip_code] at $d[report_count]</a> ]";
}
?>
</div>
</div>
<?PHP
$q = "select * from coronavirus_reopen where the_date = '$date' and state = '$state'";
$r = $covid_db->query($q);
$d = mysqli_fetch_array($r);
if ($d['id'] == ''){
$q = "insert into coronavirus_reopen (zip_closed,zip_open,the_date,state) values ('$zip_closed','$zip_open','$date','$state') ";
}else{
$q = "update coronavirus_reopen set zip_closed = '$zip_closed', zip_open = '$zip_open' where the_date = '$date' and state = '$state' ";
}
$covid_db->query($q);
slack_general("$q",'covid19-sql');
}
// This makes the data in the top graphs
count_open_zips('Maryland');
count_open_zips('Florida');
count_open_zips('Virginia');
count_open_zips('New York');
?>
<div class="row">
<div class="col-sm-6">
<div id="chartContainer" style="height: 400px; width: 100%;"></div>
</div>
<div class="col-sm-6">
<div id="chartContainer2" style="height: 400px; width: 100%;"></div>
</div>
</div>
<?PHP
include_once('footer.php');
?>