<?php 
            error_reporting(0);
            $sales=$_POST['marketing'];
            $year=$_POST['year']==NULL? date('Y'):$_POST['year'];
            if($sales!=NULL){
                $cust="AND sales='$sales'";
            }else{
                $cust='';
            }
            ?>
<script type="text/javascript">

    
    $(function () {
    $('#yearly').highcharts({
        title: {
            text: 'Monthly Activity Solution Force <?php echo date("Y");?>',
            x: -20 //center
        },
        subtitle: {
            text: '',
            x: -20
        },
        xAxis: {
            categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
                'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
        },
        yAxis: {
            title: {
                text: 'Total Activity'
            },
            plotLines: [{
                value: 0,
                width: 1,
                color: '#808080'
            }]
        },
        tooltip: {
            valueSuffix: 'kali'
        },
        legend: {
            layout: 'vertical',
            align: 'right',
            verticalAlign: 'middle',
            borderWidth: 0
        },
        series: [
        <?php
            $aktf=" AND c.status='Aktif'";
            $aktfb=" AND b.status='Aktif'";
        $wherez['status']='where/Aktif';
       if($this->session->userdata('divisi')) $wherez['type']='where/'.$this->session->userdata('divisi');
       $wherez['notes']='order/asc';
             $act=GetAll('sv_ref_activity',$wherez)->result_array();
             //lastq();
                    foreach($act as $ct){
                        
		$div=divisinya();
                $anaknya=  anaknya(); 
                        
             $q="SELECT COUNT(id) as tot";
                        for($a=1;$a<=12;$a++){
                            $b=sprintf('%02d',$a);
                            $q.=",(SELECT COUNT(a.id) as `$b` FROM sv_activity_sales a LEFT JOIN sv_master_sales b ON a.sales=b.id WHERE a.`jenis_aktivitas`='".$ct['id']."' AND MONTH(a.tanggal)='$b' AND YEAR(a.tanggal)='".$year."' $aktfb $cust";
            if(!diaadmin()){$q.=" AND (b.leader IN (".implode(',',$anaknya).") OR a.created_by ='".$this->session->userdata('webmaster_id')."')";}
            if($this->session->userdata('divisi')){
                $q.=" AND b.divisi='".$this->session->userdata('divisi')."'";
            }
            if($this->session->userdata('groups')){
                $q.=" AND b.groups='".$this->session->userdata('groups')."'";
            }
           // if(diasales()){$q.=" OR a.created_by ='".$this->session->userdata('webmaster_id')."')";}else{
           //     if(!diaadmin()) $q.=')';
          //  }
                            $q.=") as `$b`";
                        }
                        $q.=" FROM sv_activity_sales WHERE pelanggan='10' AND MONTH(tanggal)='07' AND YEAR(tanggal)='2016'";
                        //echo $q;
                        $has=$this->db->query($q)->row_array();
                        ?>
                       
        {
            name: '<?php echo $ct['notes']?>',
            data: [
        <?php 
                        for($a=1;$a<=12;$a++){
                        $b=sprintf('%02d',$a);
                        echo $has[$b].',';
                        
                        }?>
        
                ]
        },   
               <?php     }
        ?>]
    });
});


		</script>
<div id="yearly" style="min-width: 310px; height: 400px; margin: 0 " class="col-md-12"></div>