<?php $this->render(WPSG_PATH_VIEW.'/mods/mod_statistics/simplefilter.phtml'); ?>

<?php if (wpsg_isSizedArray($this->view['chart']['data']['records'])) { ?>

<div id="chartsalestopaymentmethod-bar" style="height:<?php echo $this->get_option('wpsg_mod_statistics_bar_chart_height'); ?>px; width:<?php echo $this->get_option('wpsg_mod_statistics_bar_chart_width'); ?>px;"></div>

<br/>
<h3><?php echo __('Anteile (prozentual)', 'wpsg'); ?></h3>
<div id="chartsalestopaymentmethod-pie" style="height:<?php echo $this->get_option('wpsg_mod_statistics_pie_chart_height'); ?>px; width:<?php echo $this->get_option('wpsg_mod_statistics_bar_chart_width'); ?>px;"></div>

<br/>

<div id="table-data">
	<?php $this->render(WPSG_PATH_VIEW.'/mods/mod_statistics/chartsalestopaymentmethod/data.phtml'); ?>	
</div>

<div class="wpsg_clearer"></div>
	
<?php 

	foreach ($this->view['chart']['data']['records'] as $data) 
	{ 
		$barChartJS['payment'] .= "'".wpsg_hspc($data['name'])."', "; 
		$barChartJS['total'] .= wpsg_hspc($data['total']).", "; 
		$pieChartJS .= "['".wpsg_hspc($data['name'])."', ".wpsg_hspc($data['percent'])."], ";
	} 
	
	$barChartJS['payment'] = substr($barChartJS['payment'], 0, -2); 
	$barChartJS['total'] = substr($barChartJS['total'], 0, -2); 
	$pieChartJS = substr($pieChartJS, 0, -2);

?>

<script type="text/javascript">
	jQuery(document).ready(function()
	{

		jQuery.jqplot.config.enablePlugins = true;
	    var totals = [<?php echo $barChartJS['total']; ?>];
	    var payment = [<?php echo $barChartJS['payment']; ?>];
	     
	    var chartsalestopaymentmethodBar = jQuery.jqplot('chartsalestopaymentmethod-bar', [totals], {
	        animate: !jQuery.jqplot.use_excanvas,
	        seriesDefaults:{
	            renderer:jQuery.jqplot.BarRenderer,
	            rendererOptions: {
                	varyBarColor: true
              	},          
	            pointLabels: { show: true }
	        },
	        axesDefaults: {
	            labelRenderer: jQuery.jqplot.CanvasAxisLabelRenderer
	        },
	        axes: {
	            xaxis: {
	                renderer: jQuery.jqplot.CategoryAxisRenderer,
	                ticks: payment,
	                label:'<?php echo wpsg_hspc($this->view['chart']['info']['xaxis']['label']); ?>'
	            },
	            yaxis:{
	                label:'<?php echo wpsg_hspc($this->view['chart']['info']['yaxis']['label']); ?>',
	                tickOptions: {
	            		formatter: wpsg_statistics_number_format
                	},
    				min:0
	            }
	        },
	        highlighter: { show: false }
	    });

	    var data = [<?php echo $pieChartJS; ?>];
		  
	  	var chartsalestopaymentmethodPie = jQuery.jqplot ('chartsalestopaymentmethod-pie', [data],
	    {
	      seriesDefaults: {
	        renderer: jQuery.jqplot.PieRenderer,
	        rendererOptions: { padding: 50, sliceMargin: 4, showDataLabels: true } 
	      },
	      legend: { show:true, location: 'e' }
	    }
	  	);

	  	wpsg_statistic_addExportButton();
	    
	});
</script>


<?php } else { ?>
<?php echo __('Keine Daten zur Auswertung vorhanden.', 'wpsg'); ?>
<?php } ?>