Species Seen for the First Time
This commit is contained in:
@@ -5,6 +5,8 @@ error_reporting(E_ALL);
|
|||||||
|
|
||||||
$startdate = strtotime('last sunday') - (7*86400);
|
$startdate = strtotime('last sunday') - (7*86400);
|
||||||
$enddate = strtotime('last sunday') - (1*86400);
|
$enddate = strtotime('last sunday') - (1*86400);
|
||||||
|
|
||||||
|
$debug = false;
|
||||||
?>
|
?>
|
||||||
<div class="brbanner"> <?php
|
<div class="brbanner"> <?php
|
||||||
echo "<h1>Week ".date('W', $enddate)." Report</h1>".date('F jS, Y',$startdate)." — ".date('F jS, Y',$enddate)."<br>";
|
echo "<h1>Week ".date('W', $enddate)." Report</h1>".date('F jS, Y',$startdate)." — ".date('F jS, Y',$enddate)."<br>";
|
||||||
@@ -16,16 +18,34 @@ if($db == False){
|
|||||||
header("refresh: 0;");
|
header("refresh: 0;");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($debug == false){
|
||||||
$statement1 = $db->prepare('SELECT DISTINCT(Com_Name), COUNT(*) FROM detections WHERE Date BETWEEN "'.date("Y-m-d",$startdate).'" AND "'.date("Y-m-d",$enddate).'" GROUP By Com_Name ORDER BY COUNT(*) DESC LIMIT 10');
|
$statement1 = $db->prepare('SELECT DISTINCT(Com_Name), COUNT(*) FROM detections WHERE Date BETWEEN "'.date("Y-m-d",$startdate).'" AND "'.date("Y-m-d",$enddate).'" GROUP By Com_Name ORDER BY COUNT(*) DESC');
|
||||||
|
} else {
|
||||||
|
$statement1 = $db->prepare('SELECT DISTINCT(Com_Name), COUNT(*) FROM detections WHERE Date BETWEEN "'.date("Y-m-d",$startdate).'" AND "'.date("Y-m-d",$enddate).'" GROUP By Com_Name ORDER BY COUNT(*) ASC');
|
||||||
|
}
|
||||||
if($statement1 == False){
|
if($statement1 == False){
|
||||||
echo "Database is busy";
|
echo "Database is busy";
|
||||||
header("refresh: 0;");
|
header("refresh: 0;");
|
||||||
}
|
}
|
||||||
$result1 = $statement1->execute();
|
$result1 = $statement1->execute();
|
||||||
|
|
||||||
|
$detections = [];
|
||||||
|
$i = 0;
|
||||||
|
while($detection=$result1->fetchArray(SQLITE3_ASSOC))
|
||||||
|
{
|
||||||
|
if($debug == true){
|
||||||
|
if($i > 10) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$i++;
|
||||||
|
array_push($detections, $detection);
|
||||||
|
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<br>
|
<br>
|
||||||
|
<?php // TODO: fix the box shadows, maybe make them a bit smaller on the tr ?>
|
||||||
|
<table align="center" style="box-shadow:unset"><tr><td style="background-color:#77c487">
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -35,9 +55,12 @@ $result1 = $statement1->execute();
|
|||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
while($detection=$result1->fetchArray(SQLITE3_ASSOC))
|
$i = 0;
|
||||||
|
foreach($detections as $detection)
|
||||||
{
|
{
|
||||||
|
$i++;
|
||||||
|
|
||||||
|
if($i <= 10) {
|
||||||
$statement2 = $db->prepare('SELECT COUNT(*) FROM detections WHERE Com_Name == "'.$detection["Com_Name"].'" AND Date BETWEEN "'.date("Y-m-d",$startdate - (7*86400)).'" AND "'.date("Y-m-d",$enddate - (7*86400)).'"');
|
$statement2 = $db->prepare('SELECT COUNT(*) FROM detections WHERE Com_Name == "'.$detection["Com_Name"].'" AND Date BETWEEN "'.date("Y-m-d",$startdate - (7*86400)).'" AND "'.date("Y-m-d",$enddate - (7*86400)).'"');
|
||||||
if($statement2 == False){
|
if($statement2 == False){
|
||||||
echo "Database is busy";
|
echo "Database is busy";
|
||||||
@@ -57,9 +80,52 @@ if($percentagediff > 0) {
|
|||||||
|
|
||||||
echo "<tr><td>".$detection["Com_Name"]."<br><small style=\"font-size:small\">".$detection["COUNT(*)"]." (".$percentagediff.")</small><br></td></tr>";
|
echo "<tr><td>".$detection["Com_Name"]."<br><small style=\"font-size:small\">".$detection["COUNT(*)"]." (".$percentagediff.")</small><br></td></tr>";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
</td><td style="background-color:#77c487">
|
||||||
|
|
||||||
|
<table >
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th><?php echo "Species Seen for the First Time: <br>"; ?></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php
|
||||||
|
function searchForId($id, $array) {
|
||||||
|
foreach ($array as $key => $val) {
|
||||||
|
if ($val['Com_Name'] === $id) {
|
||||||
|
return $key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($detections as $detection)
|
||||||
|
{
|
||||||
|
$statement3 = $db->prepare('SELECT COUNT(*) FROM detections WHERE Com_Name == "'.$detection["Com_Name"].'" AND Date NOT BETWEEN "'.date("Y-m-d",$startdate).'" AND "'.date("Y-m-d",$enddate).'"');
|
||||||
|
if($statement3 == False){
|
||||||
|
echo "Database is busy";
|
||||||
|
header("refresh: 0;");
|
||||||
|
}
|
||||||
|
$result3 = $statement3->execute();
|
||||||
|
$totalcount = $result3->fetchArray(SQLITE3_ASSOC);
|
||||||
|
$nonthisweekcount = $totalcount['COUNT(*)'];
|
||||||
|
|
||||||
|
// TODO: add a "no species were seen for the first time this week", if applicable
|
||||||
|
|
||||||
|
if($nonthisweekcount == 0) {
|
||||||
|
$key = array_search($detection["Com_Name"], array_column($detections, 'Com_Name'));
|
||||||
|
echo "<tr><td>".$detection["Com_Name"]."<br><small style=\"font-size:small\">".$detections[$key]["COUNT(*)"]."</small><br></td></tr>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</td></tr></table>
|
||||||
|
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
<div style="text-align:center">
|
<div style="text-align:center">
|
||||||
|
|||||||
Reference in New Issue
Block a user