<?php
    class HOME_NETPERFDAILY extends HOME
    {
        public function home_netperfdaily_javainit()
        {

        }

        public function fn_netperfdaily_init()
        {
            if(isset($_REQUEST['task'])){$task=trim(strtolower($_REQUEST['task']));}
            if(isset($_POST['task'])){$task=trim(strtolower($_POST['task']));}
            if($_REQUEST||$_POST){if($_REQUEST['sec']||$_POST['sec']){$task=$this->dec($task);}}

            switch($task)
            {
                case "default":
                    $this->fn_default_sum();
                break;

                case $task:
                    $task="fn_".$task;
                    if(method_exists($this,$task)){$this->$task();}
                break;

                default:
                    $this->fn_default_sum();
                break;
            }
        }
        
        public function fn_default_sum()
        {
            echo $this->FN_CREATEHEADER();

            echo "<style>
                       .besidebtnsave {margin-left:80px;margin-top:-6px;position:absolute;}
                  </style>";
            echo "<script>
                       var myForm,myFormsearch,dgtra;
                       function initObject()
                       {";
                            $qry="select datasets,legend,series,startvalue,stepvalue,endvalue from ".DB_APORTIL.".tbl_chart_trendran
                                  where modules='netperf' and cast(chartname as date)=cast('2019-06-30' as date) 
                                  and isdeleted=0 order by id desc limit 1";
                            //echo $qry;
                            $spval=$this->fn_get_fieldsvalues("datasets,legend,series,startvalue,stepvalue,endvalue",$qry);
                            $datasets=$spval[0];$legend=$spval[1];$series=$spval[2];$startvalue=$spval[3];$stepvalue=$spval[4];$endvalue=$spval[5];
            echo "          var datasets=$datasets;
                            myLineChart =  new dhtmlXChart({
                                                view:\"line\",
                                                container:\"div_netperfdailyline\",
                                                offset:0,
                                                xAxis:{
                                                    template:\"'#times#\"
                                                },
                                                yAxis:{
                                                    start:$startvalue,
                                                    step: $stepvalue,
                                                    end: $endvalue,
                                                    title:'In Decimal'
                                                },
                                                padding:{
                                                    left:35,
                                                    bottom: 50
                                                },
                                                origin:0,
                                                legend:{
                                                    values: $legend,
                                                    align:\"bottom\",
                                                    valign:\"middle\",
                                                    layout:\"y\",
                                                    width: 800,
                                                    margin: 8,
                                                    marker:{
                                                        type: \"item\"
                                                    }
                                                }
                                            });
                                            myLineChart.addSeries($series);
                                            myLineChart.parse(datasets,\"json\");";
            echo "     };
                  </script>";
            echo $this->FN_CLOSEHEADER();
            echo $this->FN_CREATEBODY("white");
  //          echo "<table width=\"98%\" height=\"100%\" border=\"0\">";
//            echo "  <tr>
//                        <td valign=\"top\" width=\"100%\">
//                            <div style=\"width:100%;text-align:center;text-decoration:underline;font-size:24px;color:blue\">Network Performance Period ".date("d M Y",strtotime('2019-'))."</div>
//                            <div id=\"div_netperfdailyline\" style=\"width:100%;height:330px;\"></div>
//                        </td>                        
//                    </tr>";
//            echo "</table>";
            echo $this->FN_CREATEFOOTER();

        }
    }
?>