<?php
$cs = Yii::app()->getClientScript();
$cs->registerScript("loadGraphdetail", '
    $(document).ready(function() {
     var data_plot="";
        var table_id ="#tbl_graph_order_details_yearwise";  
        var fromdate  = $("#start_date_10").val();
        var todate  = $("#end_date_10").val();
        var table = $(table_id).DataTable({
            //scrollY         : "380px",
           // scrollX         : "true",
           // scrollCollapse  : true,
            //pageLength      : 50,
            paging:   false,
            ordering: false,
            info:     false,
            processing: true,
            ajax: {
                url: "' . Yii::app()->createUrl('dashboard/GetOrderDetailYearwise') . '",
                type: "POST",
                cache : false,
                data : {fromdate:fromdate,todate:todate},
                complete:function(response){
                    data_plot=JSON.parse(response.responseText).plot;                
               }                            
            },
            columns: [
                {className: ""},
                  {className: ""},
                {className: ""},
                {className: "text-right"},
                {className: ""},
                {className: ""},
            ],
            "columnDefs": [            
            {
                "targets": [ 4 ],
                "visible": false
            },
            {
                "targets": [ 5 ],
                "visible": false
            }
            ],
            
            serverSide:     true,
            bFilter: false,
            fixedColumns:   true,
			processing: true,
            fixedHeader: {
                headerOffset: $("header.main").outerHeight()
            },
//            rowCallback: function ( row, data){          
//                $("td", row).css("background-color",""+data[3]+"");
//              
//            },        
        });
        
      $("#tbl_graph_order_details_yearwise tbody").on("click", "tr", function () {
            var data = table.row( this ).data();
            var month  = data[4];
            var year  = data[5];
            jQuery.ajax({
              "type"  : "post",
              "data"  : "month="+month+"&year="+year,
              "url"  : $("#liveSite").val()+"index.php?r=dashboard/OrderYearWise",
              "cache": false,
              "success":function(data){
                    $("#loader").hide();
                    $("#lead_info").html(data);
               }
            });
        } );
                       
        $(".dataTables_scrollFoot").hide(); 
    });', CClientScript::POS_HEAD);

$cs->registerScript("loadgraph", "    
    $(document).ready(function() {
    setTimeout(function() {
            var canvas1 =document.getElementById('current_year_invoice_yearwise');
        Chart.defaults.global.responsive = true;
        var ctx = canvas1.getContext('2d');
        var pieChart = new Chart(ctx).Pie(".$plot.");
          }, 300);  
});", CClientScript::POS_HEAD); 

//print_r($plot);
?>
<div class="clearfix"></div>
<br>
<div class="clearfix">
    <div class="col-lg-4" data-initial-class="col-lg-4" id="pieChartParentyear">
        <section class="panel">
<!--            <header class="panel-heading">
                  Lead- Lead Owner
            </header>-->
            <div class="panel-body text-center">
                <div class="clearfix canvas-holder" id="lead_container_1">
                    <canvas id="current_year_invoice_yearwise" width="400" height="400"></canvas>
                </div>
            </div>
        </section>
    </div>
    <div class="col-lg-8">
        <input type="hidden" id="start_date_10" value="<?php echo $from_date; ?>">
        <input type="hidden" id="end_date_10" value="<?php echo $end_date; ?>">
        <table class="table table-hover table-bordered personal-task" id="tbl_graph_order_details_yearwise">
            <thead>
                <tr>
                    <th>No</th>
                    <th>Year</th>
                    <th>Order Count</th>
                    <th>Amount</th>
                    <th></th>
                    <th></th>
                    <!--<th></th>-->
                    
                </tr>
            </thead>
            
        </table>
    </div>
    <div class="col-lg-12" id="lead_info"></div>
   