<?php 
   $qp="SELECT * FROM sv_master_produk";
   if(!empty($this->input->post('b'))){
       $qp.=" WHERE brand='".$this->input->post('b')."'";
   }
   if(!empty($this->input->post('j'))){
       $qp.=" AND jenis_produk='".$this->input->post('j')."'";
   }
   $produk=$this->db->query($qp)->result_array();
   $gdg=($this->input->post('g')?$this->input->post('g'):'');
?>

<script>
    
$(function () {
 

            // Create the chart
            $('#chart_exp_stok').highcharts({
    chart: {
        type: 'column'
    },
    title: {
        text: 'Expired Stok'
    },
    xAxis: {
        categories: [
            <?php foreach($produk as $pr){ ?>
                    '<?php echo $pr['title'] ?>',
            <?php }?>
                ]
    },yAxis: {
          type: 'datetime',labels: {
    format: '{value:%Y-%m-%d}'
  }
                },
    credits: {
        enabled: false
    },
    series: [{
        name: 'Current Date',
        data: [<?php foreach($produk as $pr){
            $qs=GetValue('tgl','sv_ref_exp',array('produk'=>'where/'.$pr['id']));
            //$qs=date_create($qs);
            ?>
                     '<?php //
                     echo $qs;
                     //echo ($qs==0?'':date_timestamp_get($qs)) ?>',
            <?php }?>]
    }/*, {
        name: 'Expired Date',
        data: [<?php foreach($produk as $pr){ ?>
                    <?php echo GetSumStok($pr['id'],$gdg);
                            
                            //lastq()?>,
            <?php }?>]
    }*/  ]
});
});
</script>
<div class="col-md-12">
<div id="chart_exp_stok" style=" min-width: 1000px; max-width: 100%; height: 400px; margin: 0 auto"></div>
</div>