Subversion Repositories SmartDukaan

Rev

Rev 15607 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
15607 anikendra 1
<?php 
2
	$brands = array();
3
	$map = array();
4
	$dates = array();
5
	foreach ($brand_preferences as $key => $value) {
6
		$brands[$value['brand_preferences']['brand']] = $value['brand_preferences']['brand'];
7
		$dates[$value[0]['date']] = $value[0]['date'];
8
		$map[$value[0]['date']][$value['brand_preferences']['brand']] = $value[0]['count'];
9
	}
10
?>
11
 
15621 anikendra 12
<!-- <script type="text/javascript" src="https://www.google.com/jsapi"></script> -->
15607 anikendra 13
 
14
<script type="text/javascript">
15621 anikendra 15
/*
15607 anikendra 16
google.load('visualization', '1', {packages: ['corechart', 'line']});
17
google.setOnLoadCallback(drawAxisTickColors);
18
 
19
function drawAxisTickColors() {
20
      var data = new google.visualization.DataTable();
21
      data.addColumn('date', 'Date');
22
      <?php foreach ($brands as $key => $value):?>
23
      	data.addColumn('number', '<?php echo $value;?>');
24
      <?php endforeach;?>
25
 
26
      data.addRows([
27
      <?php foreach ($dates as $key => $date):?>
28
      	[new Date('<?php echo $date;?>'),
29
      	<?php foreach ($brands as $key => $brand) :?>
30
      		<?php if(isset($map[$date][$brand])):?>
31
      			<?php echo $map[$date][$brand];?>,
32
  			<?php else:?>
33
  				0,
34
			<?php endif;?>
35
      	<?php endforeach;?>
36
      	],
37
      <?php endforeach;?>      
38
      ]);
39
 
40
      var options = {
41
        hAxis: {
42
          title: 'Date',
43
          textStyle: {
44
            color: '#01579b',
45
            fontSize: 20,
46
            fontName: 'Arial',
47
            bold: true,
48
            italic: true
49
          },
50
          titleTextStyle: {
51
            color: '#01579b',
52
            fontSize: 16,
53
            fontName: 'Arial',
54
            bold: false,
55
            italic: true
56
          }
57
        },
58
        vAxis: {
59
          title: 'Count',
60
          textStyle: {
61
            color: '#1a237e',
62
            fontSize: 24,
63
            bold: true
64
          },
65
          titleTextStyle: {
66
            color: '#1a237e',
67
            fontSize: 24,
68
            bold: true
69
          }
70
        },
71
        colors: ['#a52714', '#097138']
72
      };
73
      var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
74
      chart.draw(data, options);
75
    }
15621 anikendra 76
    */
15607 anikendra 77
</script>
78
 
79
<div class="table-responsive">
80
	<table id="example" class="display table table-striped" cellspacing="0" width="100%">
81
	    <thead>
82
	        <tr>
15621 anikendra 83
	            <th>Brand</th>
84
              <th>Total</th>
85
	            <?php foreach ($dates as $key => $date):?>
86
	            <th><?php echo ($date);?></th>	
15607 anikendra 87
	            <?php endforeach;?>
88
	        </tr>
89
	    </thead>
90
	    <tfoot>
91
	        <tr>
15621 anikendra 92
	            <th>Brand</th>
93
              <th>Total</th>
94
	            <?php foreach ($dates as $key => $date):?>
95
	            <th><?php echo ($date);?></th>	
15607 anikendra 96
	            <?php endforeach;?>
97
	        </tr>
98
	    </tfoot>
99
	    <tbody>
15621 anikendra 100
	    	<?php foreach ($count as $key => $row):?>
15607 anikendra 101
	      	<tr>
15621 anikendra 102
            <td><?php echo $row['brand_preferences']['brand'];?></td>
103
	      		<td><?php echo $row[0]['count'];?></td>
104
	      		<?php foreach ($dates as $key => $date) :?>
15607 anikendra 105
	      			<td>
15621 anikendra 106
		      		<?php if(isset($map[$date][$row['brand_preferences']['brand']])):?>
107
		      			<?php echo $map[$date][$row['brand_preferences']['brand']];?>
15607 anikendra 108
		  			<?php else:?>
109
 
110
					<?php endif;?>
111
					</td>
112
	      		<?php endforeach;?>
113
	      	</tr>
114
	      <?php endforeach;?>      
115
		</tbody>
116
	</table>            
117
</div>
118
 
15621 anikendra 119
<!-- <div id="chart_div" style="width: 1200px; height: 900px"><div> -->
15607 anikendra 120
 
121
<script type="text/javascript" src="//cdn.datatables.net/1.10.7/js/jquery.dataTables.min.js"></script>
122
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.7/css/jquery.dataTables.css"></link>
123
<script type="text/javascript">
124
$(document).ready(function() {
15621 anikendra 125
    var table = $('#example').DataTable();
126
    table.order( [ 1, 'desc' ] ).draw();
15607 anikendra 127
} );
128
</script>