amaya Gimhani 0 Newbie Poster

model

controller
function viewdashboard(){
        $this->load->model('AgentPerformance/agentPerformance_model');
       $value = $this->agentPerformance_model->dashboard(); 
       //echo $value;
       return $value;



view
<html>
    <head>
    <script src="http://code.highcharts.com/highcharts.js"></script>
    <script src="http://code.highcharts.com/modules/exporting.js"></script>   
    <script>
    $(function () {

       $('#container').highcharts({
        chart: {
            plotBackgroundColor: null,
            plotBorderWidth: null,
            plotShadow: false
        },
        title: {
            //alert('ttttt');
            text: 'Browser market shares at a specific website, 2014'
        },
        tooltip: {
            pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
        },
        plotOptions: {
            pie: {
                allowPointSelect: true,
                cursor: 'pointer',
                dataLabels: {
                    enabled: true,
                    format: '<b>{point.name}</b>: {point.percentage:.1f} %',
                    style: {
                        color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
                    }
                }
            }
        },
        //alert('tttttt');
        series: [{
//                $.ajax({
//                    type: 'post',
//                    url: 'viewdashboard',
//                    data: {},
//                    success: function (data) {
                        type: 'pie',
                        name: 'Call ',
                        data: [
                            ['Firefox',   45.0],
                           ['IE',       26.8],
                            {
                                name: 'Chrome',
                                y: 12.8,
                                sliced: true,
                                selected: true
                            },
                            ['Safari',    8.5],
                            ['Opera',     6.2],
                            ['Others',   0.7],
                            ['vegitable',  60.9]
                        ]
//                    }
//                });

        }]
    });
});


    </script>
    </head>
    <body>
      <div id="container" style="min-width: 310px; height: 400px; max-width: 600px; margin: 0 auto"></div>
    </body>
</html>


function dashboard(){

      $query = "select count(`idCall`) as val from `call` where `idEmployee` = 20 and`C_date` = '2015-04-22' and `C_ansornot` = 'Answer' group by `C_ansornot`";
      $result = mysql_query($query) or die ("SQL Error 1:".mysql_error());
      while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
          $orders[] = array('value' => $row['val']);
      }
      echo json_encode($orders);