KoolReport's Forum

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

Get data from constructor into report class .... #380

Open sneha narnaware opened this topic on on Jul 18, 2018 - 13 comments

sneha narnaware commented on Jul 18, 2018

Hi,

I want to use data from constructor file into report class ...

while fetching sql query i need data which is in constructor file.

$data['event_detail' ]= $chk; $data['render'] = new TicketsReport(); need to use $chk in sql query of TicketsReport.....

please look into matter ....

KoolReport commented on Jul 18, 2018

Sure things, you can input any parameters into KoolReport and use it in your sql query:

class TicketsReport
{
    ...
    function setup()
    {
        $this->src("mysource")
        ->query("select * from tickets where ticket_price > :price")
        ->params(array(
            ":price"=>$this->params["price"]
        ))
        ->pipe(...)
        ...
        ->pipe($this->dataStore("results"))
    }
}

index.php

    $report = new TicketsReport(array(
        "price"=>12
    ));
    $report->run()->render();

Reference: How to insert parameters to KoolReport?

Let me know if you need further assistance.

sneha narnaware commented on Jul 18, 2018

Thanks for quick response its working as I expected...

I have put some date range

    protected function defaultParamValues()
    {   
        return array(
		"dateRange"=>array(
		         $this->params['event_start_date_time'],
				 $this->params['event_end_date_time']
				
            ),
            );
    }

here i want don't want to get select date range beyond $this->params['event_end_date_time'] ....

can we do this

KoolReport commented on Jul 18, 2018

Currently, it is not possible yet, but it is in our plan to add this feature of minDate and maxDate. The ETA is 1 month.

sneha narnaware commented on Jul 18, 2018

Thanks for your help , I have given default date from my database

protected function defaultParamValues()

{   
    return array(
	"dateRange"=>array(
	         $this->params['event_start_date_time'],
			 $this->params['event_end_date_time']
			
        ),
        );
}

$this->params['event_start_date_time'] -----this date format is shows '2012-11-12 00:00:00'
but I want to give only '2012-11-12'

how to do this ...

And while showing result date column not come in order from selected start date to selected end date .....in chart its not shows proper ....

Please help with this...

sneha narnaware commented on Jul 18, 2018

please look into view

KoolReport commented on Jul 19, 2018

You need to use Sort process to sort by generated date. Also, please specify the column type as date

"type"=>"date"

You can specify this inside the "columns" of chart/table or you can use ColumnMeta process to set it.

sneha narnaware commented on Jul 19, 2018

I have given default date from my database

protected function defaultParamValues()

{

return array(
"dateRange"=>array(
         $this->params['created_at'],
		 $this->params['event_end_date_time']
		
    ),
    );

} $this->params['event_start_date_time'] -----this date format is shows '2018-02-28 06:59:37' but I want to give only '2018-02-28'

how to do this ...

sneha narnaware commented on Jul 19, 2018

"dateRange"=>array(

	         DATE_FORMAT($this->params['created_at'],'%Y-%m-%d'),
			 $this->params['event_end_date_time']
    ),
        );

I tried with this but it doesn't work

$this->params['created_at'] ='2018-02-28 06:59:37' but I want only '2018-02-28'

KoolReport commented on Jul 19, 2018

You may use date("Y-m-d,"strtotime($this->params['created_at']))

sneha narnaware commented on Jul 19, 2018

thanks for the help ... but its through an error Array ( [type] => 4 [message] => syntax error, unexpected 'strtotime' (T_STRING) [file] .....

KoolReport commented on Jul 19, 2018

I suggest that you just leave th default format as Y-m-d H:i:s, when you need to use it in your query then you use the date("Y-m-d",strtotime("your date string here in form of Y-m-d H:i:s")) to convert date to "Y-m-d"

sneha narnaware commented on Jul 19, 2018

Its word ...

I have two query which gives results ..

...I tried with joins but its gives only matching data with query1.date and query2.date .. Trying to get result which showed in above result table ...

sneha narnaware commented on Aug 3, 2018

Hi , I have associate array and i want to get that value in tabledata to show .... array( [tickets_name] => Array

    (
        [0] => Early birds
        [1] => Access ticket
        [2] => Attendees Sale
        [3] => GROSS_SALES
    )

[tickets_total] => Array
    (
        [0] => $110.00 
        [1] => $0.00 
        [2] => $100.00 
        [3] => $110.00 
    )

)

$render1 = new EventTotalReport($totalReport);

				        $render1-> run()->render();

class file---

function settings()
{
    return array(
       "assets"=>array(
           "path"=>"../../../assets",
            "url"=>UPLOAD_PATH."assets",
        ),
        "dataSources"=>array(
           "Total_datasource"=>array(
                "class"=>'\koolreport\datasources\ArrayDataSource',
                "dataFormat"=>"associate",
                "data"=>array(
	 array("Tickets_name"=>$this->params['values1'],      "Total"=>$this->params['totalvalue1']),
             array("Tickets_name"=>$this->params['values2'],      "Total"=>$this->params['totalvalue2']),
             array("Tickets_name"=>$this->params['values3'],      "Total"=>$this->params['totalvalue2']),
						
						
					),    ),)    )

}

how to get this value

"TotalTickets_datasource"=>array(

                "class"=>'\koolreport\datasources\ArrayDataSource',
                "dataFormat"=>"associate",
                "data"=>array( 
	        	array( for(int i=0;i<(count($this->params['tickets_name']));i++){
				 "TicketsName"=>,$this->params['tickets_name'][i]
				   }, 
			    for(int i=0;i<(count($this->params['tickets_total']));i++){
			  "Total"=>,$this->params['tickets_total'][i]
						   }
						   ),
						   ),
            ),

I tried with this buts its not working .....

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