ZenCart_Documentation  1.5.0
http://www.collinsharper.com
C:/xampp/htdocs/zen-cart/admin/includes/graphs/banner_daily.php
Go to the documentation of this file.
00001 <?php
00009 if (!defined('IS_ADMIN_FLAG')) {
00010   die('Illegal Access');
00011 }
00012 
00013   include(DIR_WS_CLASSES . 'phplot.php');
00014 
00015   $year = (($_GET['year']) ? zen_db_input($_GET['year']) : date('Y'));
00016   $month = (($_GET['month']) ? zen_db_input($_GET['month']) : date('n'));
00017 
00018   $days = (date('t', mktime(0,0,0,$month))+1);
00019   $stats = array();
00020   for ($i=1; $i<$days; $i++) {
00021     $stats[] = array($i, '0', '0');
00022   }
00023 
00024   $banner_stats = $db->Execute("select dayofmonth(banners_history_date) as banner_day, banners_shown as value, banners_clicked as dvalue from " . TABLE_BANNERS_HISTORY . " where banners_id = '" . (int)$banner_id . "' and month(banners_history_date) = '" . $month . "' and year(banners_history_date) = '" . $year . "'");
00025   while (!$banner_stats->EOF) {
00026     $stats[($banner_stats->fields['banner_day']-1)] = array($banner_stats->fields['banner_day'], (($banner_stats->fields['value']) ? $banner_stats->fields['value'] : '0'), (($banner_stats->fields['dvalue']) ? $banner_stats->fields['dvalue'] : '0'));
00027     $banner_stats->MoveNext();
00028   }
00029 
00030   $graph = new PHPlot(600, 350, 'images/graphs/banner_daily-' . $banner_id . '.' . $banner_extension);
00031 
00032   $graph->SetFileFormat($banner_extension);
00033   $graph->SetIsInline(1);
00034   $graph->SetPrintImage(0);
00035 
00036   $graph->SetSkipBottomTick(1);
00037   $graph->SetDrawYGrid(1);
00038   $graph->SetPrecisionY(0);
00039   $graph->SetPlotType('lines');
00040 
00041   $graph->SetPlotBorderType('left');
00042   $graph->SetTitleFontSize('4');
00043   $graph->SetTitle(sprintf(TEXT_BANNERS_DAILY_STATISTICS, $banner->fields['banners_title'], strftime('%B', mktime(0,0,0,$month)), $year));
00044 
00045   $graph->SetBackgroundColor('white');
00046 
00047   $graph->SetVertTickPosition('plotleft');
00048   $graph->SetDataValues($stats);
00049   $graph->SetDataColors(array('blue','red'),array('blue', 'red'));
00050 
00051   $graph->DrawGraph();
00052 
00053   $graph->PrintImage();
 All Data Structures Namespaces Files Functions Variables Enumerations