Merge pull request #766 from bogey3/patch-1
Resolved division by 0 error that occurs in a weekly report for the first week of use where no previous data exists.
This commit is contained in:
@@ -100,15 +100,19 @@ if(isset($_GET['ascii'])) {
|
|||||||
$priorweekcount = $totalcount['COUNT(*)'];
|
$priorweekcount = $totalcount['COUNT(*)'];
|
||||||
|
|
||||||
// really percent changed
|
// really percent changed
|
||||||
$percentagediff = round( (($scount - $priorweekcount) / $priorweekcount) * 100 );
|
if($priorweekcount > 0){
|
||||||
|
$percentagediff = round( (($scount - $priorweekcount) / $priorweekcount) * 100 );
|
||||||
|
|
||||||
if($percentagediff > 0) {
|
if($percentagediff > 0) {
|
||||||
$percentagediff = "<span style='color:green;font-size:small'>+".$percentagediff."%</span>";
|
$percentagediff = "<span style='color:green;font-size:small'>+".$percentagediff."%</span>";
|
||||||
} else {
|
} else {
|
||||||
$percentagediff = "<span style='color:red;font-size:small'>-".abs($percentagediff)."%</span>";
|
$percentagediff = "<span style='color:red;font-size:small'>-".abs($percentagediff)."%</span>";
|
||||||
}
|
}
|
||||||
|
|
||||||
echo $com_name." - ".$scount." (".$percentagediff.")<br>";
|
echo $com_name." - ".$scount." (".$percentagediff.")<br>";
|
||||||
|
} else {
|
||||||
|
echo $com_name." - ".$scount ."<br>";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user