<?php
	$CI =& get_instance();
	$CI->load->model('Saleschart_model');
	$customerSale = $CI->Saleschart_model->dashboardSaleByCustomer(date('Y'));
?>
<!--Account Balance -->     
<div class="row-fluid">              
	<div class="span12 scCol">
		<div class="block">
			<div class="head">                                        
				<h2><?php echo $this->lang->line('salesByCust')?></h2>
				<ul class="buttons">
					<li><a href="#" class="block_loading"><span class="i-cycle"></span></a></li>
					<li><a href="#" class="block_toggle"><span class="i-arrow-down-3"></span></a></li>
				</ul>
			</div>
			<div class="content">
				<div id="columnchart_values" style=" margin: 0px auto;"></div>
	        </div>
	        <script type="text/javascript">
	        	google.load("visualization", "1", {packages:["corechart"]});
			    google.setOnLoadCallback(drawChart2);
			    function drawChart2() {
			      var data = google.visualization.arrayToDataTable([
			          ['Year', 'Sales'],
			          <?php
					  	if(!empty($customerSale)){
					  		foreach($customerSale as $v){
								echo "['".$v->customerName."', ".$v->totalAmountByCust."],";
							}
						}
						else{
							echo "[test,0]";
						}
					  ?>
			        ]);

			        var options = {
			          chart: {
						width: 400,
			        	height: 300,
			          }
			        };


			      var view = new google.visualization.DataView(data);
			      view.setColumns([0, 1,
			                       { calc: "stringify",
			                         sourceColumn: 1,
			                         type: "string",
			                         role: "annotation" }]);

			      
			      var chart = new google.visualization.ColumnChart(document.getElementById("columnchart_values"));
			      chart.draw(view, options);
			  }

				$(window).resize(function(){
					drawChart2();
				});
	        </script>
	    </div>
	</div>
</div>