<?php
include_once "../../../../tools/inc.php";
$page = include("../../../common.php");
$n_id=intval($n_id);
$table='newsletters'.$config["table_prefix"];
$table_stat='stat'.$config["table_prefix"];
$br="\n";

$graph_list=array();
$graph_list['total_clicks']=array(
	'CLICK',
);
$graph_list['unique_clicks']=array(
	'CLICK.UNIQUE',
);
$graph_source=(isset($graph_list[$graph_source]) ? $graph_source : 'total_clicks');

$t0=$db->get_val($table, 'date_created', "where id='{$n_id}'");
$t0=mktime(0, 0, 0, date('m', $t0), date('d', $t0), date('Y', $t0));
$t1=mktime(0, 0, 0, date('m'), date('d')+1, date('Y'));
$dt=86400;

$t=$t0;
while ($t<$t1) {
	$st=date('Y-m-d', $t);
	foreach ($graph_list[$graph_source] as $key => $code) {
		$st.=';'.intval($db->get_val($table_stat, 'count', "where code='NEWSLETTER[{$n_id}].{$code}' and date_created='{$t}'"));
	}
	print $st.$br;
	$t=mktime(0, 0, 0, date('m', $t), date('d', $t)+1, date('Y', $t));
}
$db->close();
?>