KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Sub report error #438

Open mike opened this topic on on Aug 30, 2018 - 12 comments

mike commented on Aug 30, 2018

when I import child class in parent class

"subReports"=>array(

			  "childReport"=>childReport::class
               ),

its give an error

Array ( [type] => 4 [message] => syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' [file]

KoolReport commented on Aug 30, 2018

I guess your PHP version does not support the ClassName::class, so you can use directly:

"childReport"=>"ChildReport"

The "ChildReport" is the class name in string

mike commented on Aug 30, 2018

Thanks... I need to send array in report index.php

    $render_page = new PageViewMain(array(
									"data_e"=>$details_report,
										));
				        $render_page-> run()->render();

how to get data_e values in childclass ......

mike commented on Aug 30, 2018

Here I am using daterange selector.... but child report not getting updated after hit submit button

    subReport.update("ChildReport",{
	"dateRange_page":$('#dateRange_page').val(),
       });
KoolReport commented on Aug 30, 2018

it should be "childReport"

mike commented on Aug 30, 2018

still I m getting same error....

how pass parameter in childreport ...

    "subReports"=>array(
			  "childreport "=>"Childreport ",
			  "scope"=>array(
                    "beginDate"=>$this->params["dateRange_page"][0],
                    "endDate"=>$this->params["dateRange_page"][1],
			
                )
               ),

BUT QUERY NOT GETTING VALUES ...

mike commented on Aug 30, 2018

Provide some example for subreport with date range selector .. without refreshing page form should submit .....

And we can pass parameter from parentReport class to childReport..
we appreciate your help ...
KoolReport commented on Aug 30, 2018

May be with example is better. Please have a look at SubReport demo.

mike commented on Aug 30, 2018

I tried with this but daterange values not getting updated ....

1)  subReport.update("childReport",{
        "dateRange_page":$('#dateRange_page').val(),
			 });
 Query code
   ":start"=>$this->params["dateRange_page"][0],
        ":end"=>$this->params["dateRange_page"][1],

   

 2)   subReport.update("childReport",{
       	"dateRange_page_s":$('#dateRange_page_start').val(),
	"dateRange_page_e":$('#dateRange_page_end').val(),
            });

Query code

   ":start"=>$this->params["dateRange_page_s"],
        ":end"=>$this->params["dateRange_page_e"],

I tried with both way but query is not getting values .....

KoolReport commented on Aug 31, 2018

It should be like this:

subReport.update("childReport",{
       	"dateRange_page":[$('#dateRange_page_start').val(),$('#dateRange_page_end').val()],
});
mike commented on Sep 1, 2018

Thanks ... but still child report not getting values after updatiing child report ...... same error

Disallowed Key Charac

Could you please let us know how to pass parameter from parentReport to Child Report....

KoolReport commented on Sep 2, 2018

Is this possible that you can setup a sample page with this error that we can access. I would like to see the error as I can not guess what went wrong. I have not seen this error before.

mike commented on Sep 3, 2018

<?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>

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
None yet

None