خرید بک لینک

Vote count: 1

I'm trying to create a chart using highcart.js. Please, take a look at my script :

public function index()
    {
            extract(populateform());
        if(isset($monthly)){
            $data['var'] = "Monthly";
            $data['tgl'] = $this->modelmodel->showdata("select MONTH(tanggal) Tanggal from transaksi 
                                                        where outlet = '".$this->session->userdata('useame')."' group by 
                                                        MONTH(tanggal)");
            $data['angka'] = $this->modelmodel->showdata("select Outlet, month(tanggal),
                                                        sum(cash + cc + dc + flash + piutang + reject + disc50) total 
                                                        from transaksi 
                                                        where outlet = '".$this->session->userdata('useame')."' 
                                                        group by Outlet, month(tanggal)");

            }else{
            $data['tgl'] = $this->modelmodel->showdata("SELECT TOP 12 Tanggal From transaksi where outlet = '".$this->session->userdata('useame')."' group by Tanggal order by tanggal desc");
            $data['angka'] = $this->modelmodel->showdata("select TOP 12 (cash + cc + dc + flash + piutang + reject + disc50) total from transaksi where outlet = '".$this->session->userdata('useame')."'");
            $data['var'] = "Daily";
            }

            $view = 'dummy';
            $this->go_to($view,$data);
    }

In else condition, everything working fine. But, when in if(isset($monthly)) condition there is an error Invalid argument supplied for foreach(). and here is my view

<div class="box-header">
        <form method="post" action="<?=base_url();?>home/"> 
        <button type="submit" class="btn" name="daily"> Daily  </button>
        <button type="submit" class="btn" name="monthly"> Monthly</button>
         </form>
        </div>
            <div class="box-body table-responsive">
            <script type="text/javascript">$(function () {
    $('#container').highcharts({
        title: {
            text: '<?=$var;?>',
            x: -20 //center
        },
        subtitle: {
            text: 'Omset Anda',
            x: -20
        },
        xAxis: {
            categories: [<?php foreach($tgl as $tgls) {echo "'".$tgls->Tanggal."',";} ?>]
        },
        yAxis: {
            title: {
                text: 'Rupiah (Rp.)'
            },
            plotLines: [{
                value: 0,
                width: 1,
                color: '#808080'
            }]
        },
        tooltip: {
            valueSuffix: ' Rupiah'
        },
        legend: {
            layout: 'vertical',
            align: 'right',
            verticalAlign: 'middle',
            borderWidth: 0
        },
        series: [{
            name: 'Outlet Anda',
            data: [<?php foreach($angka as $duit) {echo $duit->total.",";} ?>]

        }]
    });
});</script>

when i ruing query inside if(isset($monthly)) via sql server 2008, the results are show up, But when i try to print_r($data['angka']), there isn't any result showing up and when i try to print_r($data) only $data['tgl'] showing up.

asked 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: دوشنبه 14 تير 1395 ساعت: 14:10

صفحه بندی