0) { $percentagedifftotal = "+".$percentagedifftotal."%"; } else { $percentagedifftotal = "-".abs($percentagedifftotal)."%"; } $percentagedifftotaldistinctspecies = round( (($totalspeciestally - $priortotalspeciestally) / $priortotalspeciestally) * 100 ); if($percentagedifftotaldistinctspecies > 0) { $percentagedifftotaldistinctspecies = "+".$percentagedifftotaldistinctspecies."%"; } else { $percentagedifftotaldistinctspecies = "-".abs($percentagedifftotaldistinctspecies)."%"; } $detections = []; $i = 0; foreach ($result1 as $detection) { $detections[$detection["Com_Name"]] = $detection["COUNT(*)"]; } echo "# BirdNET-Pi: Week ".date('W', $enddate)." Report\n"; echo "Total Detections: ".$totalcount." (".$percentagedifftotal.")
"; echo "Unique Species Detected: ".$totalspeciestally." (".$percentagedifftotaldistinctspecies.")

"; echo "= Top 10 Species =
"; $i = 0; foreach($detections as $com_name=>$scount) { $i++; if($i <= 10) { $statement2 = getWeeklyReportSpeciesDetection($com_name); if($statement2['success'] == False){ echo $statement2['message']; header("refresh: 0;"); } $priorweekcount = $statement2['data']['COUNT(*)']; // really percent changed if($priorweekcount > 0){ $percentagediff = round( (($scount - $priorweekcount) / $priorweekcount) * 100 ); if($percentagediff > 0) { $percentagediff = "+".$percentagediff."%"; } else { $percentagediff = "-".abs($percentagediff)."%"; } echo $com_name." - ".$scount." (".$percentagediff.")
"; } else { echo $com_name." - ".$scount ."
"; } } } echo "
= Species Detected for the First Time =
"; $newspeciescount=0; foreach($detections as $com_name=>$scount) { $statement3 = getWeeklyReportSpeciesDetection($com_name,false); if($statement3['success'] == False){ echo $statement3['message']; header("refresh: 0;"); } $nonthisweekcount = $statement3['data']['COUNT(*)']; if($nonthisweekcount == 0) { $newspeciescount++; echo $com_name." - ".$scount."
"; } } if($newspeciescount == 0) { echo "No new species were seen this week."; } $prevweek = date('W', $enddate) - 1; if($prevweek < 1) { $prevweek = 52; } echo "
* data from ".date('Y-m-d', $startdate)." — ".date('Y-m-d',$enddate).".
"; echo '* percentages are calculated relative to week '.($prevweek).'.'; die(); } ?>
Week ".date('W', $enddate)." Report".date('F jS, Y',$startdate)." — ".date('F jS, Y',$enddate)."
"; ?>
10) { break; } } $i++; $detections[$detection["Com_Name"]] = $detection["COUNT(*)"]; } ?>
$scount) { $i++; if($i <= 10) { $statement2 = getWeeklyReportSpeciesDetection($com_name); if($statement2['success'] == False){ echo $statement2['message']; header("refresh: 0;"); } $priorweekcount = $statement2['data']['COUNT(*)']; if ($priorweekcount > 0) { $percentagediff = round( (($scount - $priorweekcount) / $priorweekcount) * 100 ); } else { $percentagediff = 0; } if($percentagediff > 0) { $percentagediff = "+".$percentagediff."%"; } else { $percentagediff = "-".abs($percentagediff)."%"; } echo ""; } } ?>
"; ?>
".$com_name."
".$scount." (".$percentagediff.")
$scount) { $statement3 = getWeeklyReportSpeciesDetection($com_name,false); if($statement3['success'] == False){ echo $statement3['message']; header("refresh: 0;"); } $nonthisweekcount = $statement3['data']['COUNT(*)']; if($nonthisweekcount == 0) { $newspeciescount++; echo ""; } } if($newspeciescount == 0) { echo ""; } ?>
"; ?>
".$com_name."
".$scount."
No new species were seen this week.


* percentages are calculated relative to week