<?php
/*
  www.oscGold.com (C) Kamelia-Net Jacek Krysiak
  modul oscGold wer 4.0
*/

	$year = (($HTTP_GET_VARS['year']) ? $HTTP_GET_VARS['year'] : date('Y'));

	$stats = array();
	for ($i=1; $i<13; $i++) {
	$stats[] = array(strftime('%b', mktime(0,0,0,$i)), '0', '0');
	}
	
	$dzien_wykresu = '';
	$liczba_wyswietlen = '';
	$liczba_klikniec = '';
	//	
	$banner_stats_query = tep_db_query("select month(banners_history_date) as banner_month, sum(banners_shown) as value, sum(banners_clicked) as dvalue from " . TABLE_BANNERS_HISTORY . " where banners_id = '" . $banner_id . "' and year(banners_history_date) = '" . $year . "' group by banner_month");
	while ($banner_stats = tep_db_fetch_array($banner_stats_query)) {
	$stats[($banner_stats['banner_month']-1)] = array(strftime('%b', mktime(0,0,0,$banner_stats['banner_month'])), (($banner_stats['value']) ? $banner_stats['value'] : '0'), (($banner_stats['dvalue']) ? $banner_stats['dvalue'] : '0'));
	}
	
	$wart_max_wyswietlen = 0;
	$wart_max_klikniec = 0;

	for ($i=0; $i < count($stats); $i++) {
	$dzien_wykresu .= $stats[$i][0].",";
	$liczba_wyswietlen .= $stats[$i][1].",";
	$liczba_klikniec .= $stats[$i][2].",";  
	if ((int)$stats[$i][1] > $wart_max_wyswietlen) {
		$wart_max_wyswietlen = (int)$stats[$i][1];
	}
	if ((int)$stats[$i][2] > $wart_max_klikniec) {
		$wart_max_klikniec = (int)$stats[$i][2];
	}	
	}

	$liczba_wyswietlen = substr($liczba_wyswietlen,0,strlen($liczba_wyswietlen)-1);
	$liczba_klikniec = substr($liczba_klikniec,0,strlen($liczba_klikniec)-1);
	$dzien_wykresu = substr($dzien_wykresu,0,strlen($dzien_wykresu)-1);
	
	?>

	<div id="wynik3" style="border:1px solid #474747;width:800px;text-align:center;"><span class="smallText">Brak zainstalowanej wtyczki flash</span></div>
	<script type="text/javascript">
	var so = new SWFObject("open-flash-chart.swf", "ofc", "800", "200", "9", "#FFFFFF");
	so.addVariable("variables","true");
	so.addVariable("title","Liczba wyświetleń w poszczególnych miesiącach.,{font-size: 16px;}");
	so.addVariable("x_label_style","8,#000000,0,1");
	so.addVariable("x_axis_steps","2");
	so.addVariable("y_legend","Ilosc wyswietlen,12,#C11B01");
	so.addVariable("y_ticks","5");
	so.addVariable("area_hollow","2,3,25,#C11B01,,12,#8E560F");
	so.addVariable("values","<?php echo $liczba_wyswietlen; ?>");
	so.addVariable("x_labels","<?php echo $dzien_wykresu; ?>");
	so.addVariable("y_min","0");
	so.addVariable("y_max","<?php echo ($wart_max_wyswietlen+3); ?>");
	so.addVariable("tool_tip","Liczba wyświetleń%23comma%23+%23val%23");
	so.addParam("wmode", "transparent");
	so.write("wynik3");
	</script><br>
	<div id="wynik2" style="border:1px solid #474747;width:800px;text-align:center;"><span class="smallText">Brak zainstalowanej wtyczki flash</span></div>
	<script type="text/javascript">
	var so = new SWFObject("open-flash-chart.swf", "ofc", "800", "200", "9", "#FFFFFF");
	so.addVariable("variables","true");
	so.addVariable("title","Liczba kliknięć w poszczególnych miesiącach.,{font-size: 16px;}");
	so.addVariable("x_label_style","8,#000000,0,1");
	so.addVariable("x_axis_steps","1");
	so.addVariable("y_legend","Ilosc klikniec,12,#C11B01");
	so.addVariable("y_ticks","5");
	so.addVariable("area_hollow","2,3,25,#C11B01,,12,#8E560F");
	so.addVariable("values","<?php echo $liczba_klikniec; ?>");
	so.addVariable("x_labels","<?php echo $dzien_wykresu; ?>");
	so.addVariable("y_min","0");
	so.addVariable("y_max","<?php echo ($wart_max_klikniec+2); ?>");
	so.addVariable("tool_tip","Liczba klikniec%23comma%23+%23val%23");
	so.addParam("wmode", "transparent");
	so.write("wynik2");
	</script>	
