function bsa_stats_chart_callback() { if (isset($_POST) && isset($_POST['ad_id'])) { $model = new BSA_PRO_Model(); $ad_id = $_POST['ad_id']; $days = $_POST['days']; echo json_encode(array("labels" => array(date('m.d', time() - ($days - 1) * 24 * 60 * 60), date('m.d', time() - ($days - 2) * 24 * 60 * 60), date('m.d', time() - ($days - 3) * 24 * 60 * 60), date('m.d', time() - ($days - 4) * 24 * 60 * 60), date('m.d', time() - ($days - 5) * 24 * 60 * 60), date('m.d', time() - ($days - 6) * 24 * 60 * 60), date('m.d', time() - ($days - 7) * 24 * 60 * 60)), "clicks" => array($model->bsaChartClicks($ad_id, $days), $model->bsaChartClicks($ad_id, $days - 1), $model->bsaChartClicks($ad_id, $days - 2), $model->bsaChartClicks($ad_id, $days - 3), $model->bsaChartClicks($ad_id, $days - 4), $model->bsaChartClicks($ad_id, $days - 5), $model->bsaChartClicks($ad_id, $days - 6)), "views" => array($model->bsaChartViews($ad_id, $days), $model->bsaChartViews($ad_id, $days - 1), $model->bsaChartViews($ad_id, $days - 2), $model->bsaChartViews($ad_id, $days - 3), $model->bsaChartViews($ad_id, $days - 4), $model->bsaChartViews($ad_id, $days - 5), $model->bsaChartViews($ad_id, $days - 6)))); } else { echo 'Stats can not be download.'; } die; }