Rev 15607 | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?php$brands = array();$map = array();$dates = array();foreach ($brand_preferences as $key => $value) {$brands[$value['brand_preferences']['brand']] = $value['brand_preferences']['brand'];$dates[$value[0]['date']] = $value[0]['date'];$map[$value[0]['date']][$value['brand_preferences']['brand']] = $value[0]['count'];}?><!-- <script type="text/javascript" src="https://www.google.com/jsapi"></script> --><script type="text/javascript">/*google.load('visualization', '1', {packages: ['corechart', 'line']});google.setOnLoadCallback(drawAxisTickColors);function drawAxisTickColors() {var data = new google.visualization.DataTable();data.addColumn('date', 'Date');<?php foreach ($brands as $key => $value):?>data.addColumn('number', '<?php echo $value;?>');<?php endforeach;?>data.addRows([<?php foreach ($dates as $key => $date):?>[new Date('<?php echo $date;?>'),<?php foreach ($brands as $key => $brand) :?><?php if(isset($map[$date][$brand])):?><?php echo $map[$date][$brand];?>,<?php else:?>0,<?php endif;?><?php endforeach;?>],<?php endforeach;?>]);var options = {hAxis: {title: 'Date',textStyle: {color: '#01579b',fontSize: 20,fontName: 'Arial',bold: true,italic: true},titleTextStyle: {color: '#01579b',fontSize: 16,fontName: 'Arial',bold: false,italic: true}},vAxis: {title: 'Count',textStyle: {color: '#1a237e',fontSize: 24,bold: true},titleTextStyle: {color: '#1a237e',fontSize: 24,bold: true}},colors: ['#a52714', '#097138']};var chart = new google.visualization.LineChart(document.getElementById('chart_div'));chart.draw(data, options);}*/</script><div class="table-responsive"><table id="example" class="display table table-striped" cellspacing="0" width="100%"><thead><tr><th>Brand</th><th>Total</th><?php foreach ($dates as $key => $date):?><th><?php echo ($date);?></th><?php endforeach;?></tr></thead><tfoot><tr><th>Brand</th><th>Total</th><?php foreach ($dates as $key => $date):?><th><?php echo ($date);?></th><?php endforeach;?></tr></tfoot><tbody><?php foreach ($count as $key => $row):?><tr><td><?php echo $row['brand_preferences']['brand'];?></td><td><?php echo $row[0]['count'];?></td><?php foreach ($dates as $key => $date) :?><td><?php if(isset($map[$date][$row['brand_preferences']['brand']])):?><?php echo $map[$date][$row['brand_preferences']['brand']];?><?php else:?>0<?php endif;?></td><?php endforeach;?></tr><?php endforeach;?></tbody></table></div><!-- <div id="chart_div" style="width: 1200px; height: 900px"><div> --><script type="text/javascript" src="//cdn.datatables.net/1.10.7/js/jquery.dataTables.min.js"></script><link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.7/css/jquery.dataTables.css"></link><script type="text/javascript">$(document).ready(function() {var table = $('#example').DataTable();table.order( [ 1, 'desc' ] ).draw();} );</script>