KoolReport's Forum

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

Passing DateTimePicker to second level drill down #3284

Open Adolfo Alonso opened this topic on on May 1 - 2 comments

Adolfo Alonso commented on May 1

Hi guys, I'm able to use the selected date on the first level of drill down, but cant pass it to the second level...

MyReport.view.php

<div class= "col-md-4 form-group">
<?php
DrillDown::create(array(
	"name"=>"saleDrillDown",
	"title"=>"Kilometraje recorrido",
	"levels"=>array(
		array(
			"title"=>"ASTRA",
			"content"=>function($params,$scope)
			{
				ColumnChart::create(array(
					"dataSource"=>(
						$this->src("automaker")->query("
							SELECT localidad,
							sum(km_real) AS kms
							FROM tbl_linde_libroazul_productividad
							WHERE YEAR(fecha) = YEAR(:start)
							AND MONTH(fecha) = MONTH(:start)
							GROUP BY localidad;
						")
						->params(array(
							":start"=>$this->params["startDatePicker"],
						))
					),
					"columns"=>array(
						"localidad"=>array(
							"type"=>"string",
							"label"=>"Localidad",
						),
						"kms"=>array(
							"label"=>"Kms recorrido",
						)
					),
					"clientEvents"=>array(
						"itemSelect"=>"function(params){
							saleDrillDown.next({localidad:params.selectedRow[0],start:params["startDatePicker"]});
						}",
					)
				));
			}
		),
		array(
			"title"=>function($params,$scope)
			{
				return $params["localidad"];
			},
			"content"=>function($params,$scope)
			{
				ColumnChart::create(array(
					"dataSource"=>(
						$this->src("automaker")->query("
							SELECT tractor,
							sum(km_real) AS kms
							FROM tbl_linde_libroazul_productividad
							WHERE YEAR(fecha) = YEAR(:start)
							AND MONTH(fecha) = MONTH(:start)
							AND localidad = :localidad
							GROUP BY tractor
						")
						->params(array(
							":start"=>$this->params["start"],
							":localidad"=>$params["localidad"]
						))
					)
					,
					"columns"=>array(
						"tractor"=>array(
							"type"=>"string",							
						),
						"kms"=>array(
							"label"=>"Kms recorrido",
						)
					),
					"clientEvents"=>array(
						"itemSelect"=>"function(params){
							saleDrillDown.next({month:params.selectedRow[0]});
						}",
					)
				));
			}        
		),

Adolfo Alonso commented on May 1

Hello, I was able to move forward by using the scope. I validates the variable is passed to the second level, the problem now is that I cant get the :fecha to get the date value.

Please advise.

MyReport.view

<div class= "col-md-4 form-group">
<?php
DrillDown::create(array(
	"name"=>"saleDrillDown",
	"title"=>"Kilometraje recorrido",
	"scope"=>array(
		"fecha"=>$this->params["startDatePicker"],
	),
	
	"levels"=>array(
		array(
			"title"=>"ASTRA",
			"content"=>function($params,$scope)
			{
				$query= "SELECT localidad,
					sum(km_real) AS kms
					FROM tbl_linde_libroazul_productividad
					WHERE YEAR(fecha) = YEAR(:start)
					AND MONTH(fecha) = MONTH(:start)
					GROUP BY localidad;";
				ColumnChart::create(array(
					"dataSource"=>(
						$this->src("automaker")->query($query)
						->params(array(
							":start"=>$scope["fecha"],
						))
					),
					"columns"=>array(
						"localidad"=>array(
							"type"=>"string",
							"label"=>"Localidad",
						),
						"kms"=>array(
							"label"=>"Kms recorrido",
						)
					),
					"clientEvents"=>array(
						"itemSelect"=>"function(params){
							saleDrillDown.next({localidad:params.selectedRow[0]});
						}",
					)
				));
			}
		),
		array(
			"title"=>function($params,$scope)
			{
				return $params["localidad"];
			},
			"content"=>function($params,$scope)
			{
				$f = ($scope["fecha"]);
				echo 'f: ' . $f;
				ColumnChart::create(array(
					"dataSource"=>(
						$this->src("automaker")->query("
							SELECT tractor,
							sum(km_real) AS kms
							FROM tbl_linde_libroazul_productividad
							WHERE YEAR(fecha) = YEAR( :fecha )
							AND MONTH(fecha) = MONTH( :fecha )
							AND localidad = :localidad
							GROUP BY tractor
						")
						->params(array(
							":fecha"=> $f,
							":localidad"=>$params["localidad"]
						))
					)

KoolReport commented on May 7

Hi Adolfo,

We are sorry for our late reply.

The setup with $scope is a correct way.

So everything seems good for the first level, doesn't it? The issue is the second level when you could not catch the scope with fecha value.

Could you please use the inspector tool, watch the ajax request after you click to chart of first level. Does the request contains the scope sending to server? Or is there any error happens.

Please let me know.

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