I am trying to get the statsdata to show a count of how many flights have been completed by my custom kacars program. But it is not working and need help, maybe someone here has the answer. Here is the code I got:
/**
* Get the number of flights flown with macars
*/
public static function AcarsCount($airline_code = '')
{
$key = 'acars_count';
if($airline_code != '')
{
$key .= '_'.$airline_code;
}
$acars = "mACARS";
$total = CodonCache::read($key);
if($total === false)
{
$sql = 'SELECT COUNT(*) AS `total`
FROM `'.TABLE_PREFIX.'pireps`
WHERE `source`='.$acars;
if($airline_code != '')
{
$sql .= " AND `code`='{$airline_code}' GROUP BY `code`";
}
$result = DB::get_row($sql);
if(!$result)
{
return 0;
}
$total = $result->total;
CodonCache::write($key, $total, '15minute');
}
return $total;
}
That is from the StatsData.class.php file.
If I have done something wrong please point it out to me.
<tr>
<td><strong>mACARS count:</strong> </td>
<td><span class="label label-info"><?php echo StatsData::AcarsCount();?></span></td>
</tr>
There is the code from the frontpage_main.tpl file.
No error is showing, so I have not made any php error that is critical for the site to work.