This topic is locked
[SOLVED]

 Apply a filter opening chart page.

12/2/2011 6:12:52 AM
PHPRunner General questions
B
b.emanuele author

Hi all, is there a way to filter records on the chart-page's open event?

I would to set a filter like Advanced search page does, but before chart is displayed.

These filters should be displayed also in the Adv.search page when I open it.

Any ideas?

Thanks

C
cgphp 12/2/2011

Post a screenshot of what you want to achieve.

B
b.emanuele author 12/2/2011



Post a screenshot of what you want to achieve.



My pie-chart is build over a view containing the amount of material extruded by each production line of our company per week.
Example view:

Week | Production line | Qty

--------------------------------

47 | Prod. Line 1 | 100 kg

47 | Prod. Line 2 | 80 kg

48 | Prod. Line 1 | 120 kg

48 | Prod. Line 2 | 90 kg
Data series -> Qty

Label field -> Production line
Now, assuming I have 4 records in this view, opening the pie-chart page the first time i get 4 slices shown.

The desired behaviour is that the first time I open the chart's page, chart will display amounts of the current week only (for eg. week=48).

But I would also have the possibility to change that filter by calling the Advanced search page, for eg. to recall extruded qty of the previous week.
Thanks

C
cgphp 12/2/2011

Check this article: http://xlinesoft.com/phprunner/docs/before_sql_query.htm

You can modify the where clause of the SQL query:

$strWhereClause = whereAdd("week=48",$strWhereClause);
B
b.emanuele author 12/5/2011



Check this article: http://xlinesoft.com/phprunner/docs/before_sql_query.htm

You can modify the where clause of the SQL query:

$strWhereClause = whereAdd("week=48",$strWhereClause);



Ok...I've put this code in my project on BeforeQueryChart event:

global $strTableName;

if (isset($_SESSION[$strTableName.'_advsearch']))

{

$searchClauseObj = unserialize($_SESSION[$strTableName.'_advsearch']);

$fieldSearchData = $searchClauseObj->_where[$strTableName."_srchFields"];

if (isset($fieldSearchData)) {

$i = count($fieldSearchData);

if ($i = 0) {

$strWhereClause = whereAdd(" Year=2011 AND Week=48 ",$strWhereClause);

}

} else {

$strWhereClause = whereAdd(" Year=2011 AND Week=48 ",$strWhereClause);

}

}


If "Advanced search page" is not initialized I apply the filter.

Otherwise user defined filter is applied.