<?php
require APPPATH."libraries/koolreport/autoload.php";
require APPPATH."reports/front/ChildReport.php";
class ParentReport extends \koolreport\KoolReport
{
use \koolreport\clients\jquery;
use \koolreport\core\SubReport;
function settings()
{
return array(
"assets"=>array(
"path"=>"../../../assets",
"url"=>UPLOAD_PATH."assets",
),
"subReports"=>array(
"childreport"=>"Childreport",
),
);
}
}
?>
ParentReport.view.php
<div class="col-sm-12 col-lg-12 col-md-12 col-xs-12 status-mb pd0 mobi-pad0">
<div class="common-border-all "><!--height-equal-->
<h3 class="common-dash-heading" >Page status</h3>
<div class="col-sm-12 col-lg-12 col-md-12 col-xs-12 pd0 mobi-pad0" >
<div class="col-sm-3 col-lg-3 col-md-3 col-xs-12 pd0 mobi-pad0" ></div>
<div class="col-sm-6 col-lg-6 col-md-6 col-xs-12 pd0 mobi-pad0" >
<?php $this->subReport("childreport"); ?>
</div>
<div class="col-sm-3 col-lg-3 col-md-3 col-xs-12 pd0 mobi-pad0" >
</div>
</div>
childreport.php-
<?php
use \koolreport\processes\ColumnMeta;
use \koolreport\processes\CalculatedColumn;
use \koolreport\processes\Sort;
use \koolreport\processes\Join;
use \koolreport\processes\DateTimeFormat;
use \koolreport\processes\RemoveColumn;
use \koolreport\cube\processes\Cube;
require APPPATH."libraries/koolreport/autoload.php";
class Childreport extends \koolreport\KoolReport
{
use \koolreport\clients\jquery;
use \koolreport\inputs\Bindable;
use \koolreport\inputs\POSTBinding;
protected function defaultParamValues()
{
return array(
"dateRange_page"=>array(
'2017-05-09' , '2018-09-30'
),
);
}
protected function bindParamsToInputs()
{
return array(
"dateRange_page"=>"dateRange_page",
);
}
function settings()
{
return array(
"assets"=>array(
"path"=>"../../../assets",
"url"=>UPLOAD_PATH."assets",
),
"dataSources"=>array(
"database"=>array(
"connectionString"=>"mysql:host=localhost;dbname=newlive",
"username"=>"root",
"password"=>"",
"charset"=>"utf8"
),
),
);
}
function setup()
{
$this->src("database")->query("SELECT STR_TO_DATE(page_visit_date,'%Y-%m-%d') AS DATE, page_visit FROM event_page_visits WHERE event_id = '6672'
AND DATE(page_visit_date) BETWEEN :start AND :end GROUP BY DAY(page_visit_date) ;")
->params(array(
":start"=>$this->params["dateRange_page"][0],
":end"=>$this->params["dateRange_page"][1],
))->pipe(new Sort(array(
"DATE"=>"asc",
)))
->pipe(new DateTimeFormat(array(
"DATE"=>array(
"from"=>"Y-m-d",
"to"=>"d M"
),
)))
->pipe($this->dataStore("report_pagevisit"));
}
}
Childreport.view.php
<?php
use \koolreport\widgets\koolphp\Table;
use \koolreport\inputs\DateRangePicker;
use \koolreport\widgets\google\DonutChart;
use \koolreport\widgets\google\PieChart;
use \koolreport\widgets\google\AreaChart;
use \koolreport\widgets\google\LineChart;
use \koolreport\widgets\google\BarChart;
use \koolreport\widgets\google\ColumnChart;
//use \koolreport\chartjs\LineChart;
?>
<div class="col-sm-12 col-lg-12 col-md-12 col-xs-12 pd0 mobi-pad0" >
<div class="col-sm-3 col-lg-3 col-md-3 col-xs-12 pd0 mobi-pad0" ></div>
<div class="col-sm-6 col-lg-6 col-md-6 col-xs-12 pd0 mobi-pad0" >
<div class="form-group date_div" style="text-align:center;">
<?php
DateRangePicker::create(array(
"name"=>"dateRange_page",
/* "clientEvents"=>array(
"change"=>"function(){
subReport.update('eventPageViewSub',{
'dateRange_page':[$('#dateRange_page_start').val(),$('#dateRange_page_end').val()],
});
}",
),*/
))
?>
</div>
<script type="text/javascript">
$(document).ready(function(){
var date_html = $('#dateRange_page span').html()
setInterval(function(){ if($('#dateRange_page span').html() != date_html){
var date_s=$('#dateRange_page_start').val();
var date_e=$('#dateRange_page_end').val();
subReport.update("childreport",{
"dateRange_page":[date_s,date_e],
});
//return false;
date_html = $('#dateRange_page span').html() } }, 500)
});
</script>
</div>
<div class="col-sm-3 col-lg-3 col-md-3 col-xs-12 pd0 mobi-pad0" >
</div>
</div>
<div class="col-sm-12 col-lg-12 col-md-12 col-xs-12 pd0 mobi-pad0" >
<?php
$count=$this->dataStore('report_pagevisit')->countData();
if($count){
LineChart::create(array(
"dataStore"=>isset($this->params["dateRange_page"])?$this->dataStore("report_pagevisit"):null,
"data"=>isset($this->params["dateRange_page"])?null:array(),
"width"=>"100%",
"height"=>"100%",
"options"=>array(
"responsive"=>true,
"legend"=>array(
"position"=> 'bottom',
"labeledValueText"=> 'both',
),
"annotations"=>true,
'hAxis' => array(
'textStyle' => array(
'fontSize' => 11 ,
),
//'showTextEvery' => ($numLabels-1),
'showTextEvery' => ($this->dataStore("report_pagevisit")->countData()-1),
),
'pointShape' => 'circle',
'pointSize' => 3,
'chartArea' => array(
'height' => '50%',
'width' => '80%'
),
),
"clientEvents"=>array(
"itemSelect"=>"function(){}"
),
));
}else{ echo "No Records";
} ?>
</div>
</div>
</div>