Skip to content

Commit

Permalink
Updated admin controller
Browse files Browse the repository at this point in the history
Added hits chart
  • Loading branch information
alkawamara committed Apr 7, 2017
1 parent b6b89a7 commit ec41480
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions admin/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -847,5 +847,33 @@
$item->exportTransactionsPDF();

endif;

/* == Latest Leader Stats == */
if (isset($_GET['getLeaderStats'])):

$data = array();
$data['hits'] = array();
$data['xaxis'] = array();
$data['hits']['label'] = Lang::$word->ADM_PVIEWS;
$data['uhits']['label'] = Lang::$word->ADM_UVIEWS;

$and = (Filter::$id) ? "AND lid = " . Filter::$id : null;

for ($i = 1; $i <= 12; $i++):
$row = $db->first("SELECT SUM(hits) AS hits,"
. "\n SUM(uhits) as uhits"
. "\n FROM stats"
. "\n WHERE YEAR(day) = '" . date('Y') . "'"
. "\n AND MONTH(day) = '" . $i . "'"
. "\n $and"
. "\n GROUP BY MONTH(day)");

$data['hits']['data'][] = ($row) ? array($i, (int)$row->hits) : array($i, 0);
$data['uhits']['data'][] = ($row) ? array($i, (int)$row->uhits) : array($i, 0);
$data['xaxis'][] = array($i, date('M', mktime(0, 0, 0, $i, 1, date('Y'))));
endfor;

print json_encode($data);
endif;

?>

0 comments on commit ec41480

Please sign in to comment.