include?'mysql.php';
include?"../charts.php";
//?Get?ad?id
if?(!isset($_GET['ad']))?{?no_chart();?}
$ad?=?intval($_GET['ad']);
//?Get?data?for?last?week
$days?=?$db->sql_query?("SELECT?year,?month,?day,?views,?week,?clicks,?ctr?FROM?stats?WHERE?ad?=?$ad?AND?type?=?'day'?ORDER?BY?week?DESC,?day?DESC?LIMIT?0,10");
if?(count($days)?==?0)?{
????no_chart();
}
$days?=?array_reverse($days);
//?Create?chart?data
$daynames?=?array('');
$clicks?=?array('Clicks');
$views?=?array('Impressions');
$week?=?false;
foreach?($days?as?$day)?{
????//?Correct?week?
????if?($week?!=?false?AND?$day['week']?!=?$week)?{
????????break;
????}
????$week?=?$day['week'];
????$daynames[]?=?date('l',?mktime(0,?0,?0,?$day['month'],?$day['day'],?$day['year']));
????$clicks[]?=?$day['clicks'];
????$views[]?=?$day['views'];
}
$chart['chart_data']?=?array($daynames,?$clicks,?$views);
$chart['axis_value']?=?array('color'?=>?'FFFFFF');
$chart['axis_category']?=?array('color'?=>?'FFFFFF',?'size'?=>?'10',?'skip'?=>?0);
$chart['axis_ticks']?=?array('value_ticks'?=>?true,?'minor_color'?=>?'FFFFFF');
$chart?[?'chart_value'?]?=?array?('position'?=>??"cursor",?'bold'?=>??true,?'size'?=>??11,?'color'?=>?"FFFFFF",?'alpha'?=>?190);?
$chart['chart_type']?=?'stacked?column';
SendChartData?($chart);
function?no_chart()?{
????$chart['chart_data']?=?array(array('',?'No?Data?Available'));
????$chart['axis_category']?=?array('color'?=>?'FFFFFF');
????SendChartData($chart);
}
?>