This topic is locked

multiple search buttons for multiple chart/report list page?

2/12/2009 2:40:05 PM
PHPRunner General questions
hichem author

Hi Jane/Admin, following up a previous post, I was wondering if you could provide your expert opinion about the following?
Is it possible to have multiple search buttons (copy/paste in the visual editor) and label these differently on a multiples chart list page so that users can search the chart they like?

This might be the perfect workaround for the limitation of having the search apply to only one table/report/chart and could be enhanced by providing a radio button or drop down list to select which chart a user would like to search.
If possible, what is the best way to do this?
Many Thanks
Hich

J
Jane 2/13/2009

Hi,
you can edit generated..._chart.php file.

Find this code:

if(@$_REQUEST["a"]=="advsearch")

{

...

$_SESSION[$strTableName."_pagenumber"]=1;

}



and replace it with this one:

if(@$_REQUEST["a"]=="advsearch")

{

...

$_SESSION[$strTableName."_pagenumber"]=1;

$oldtable=$strTableName;

$strTableName="chart2";

...

$strTableName=$oldtable;

}



Copy all code between { and } and paste it just after $strTableName="chart2";

hichem author 2/15/2009

Thanks Jane,

I have tried your suggestion but didn't work.

I have tried using $strTableName="chart2"; and also

$strTableName="<mychartpagename>";

My page contains 6 charts and I assume I will have to copy/paste the suggested code 6 times. Does the name "chart2" need to correspond to each of the php chart files included in page containing all 6 charts? or does it need to correspong to an actual table/view name? (I use the same table and show different charts each displaying data for today, last 12 hours, last 3 days, last 7 days and last 30 days).

Note that I use a subquery to get my date (works fine to display the chart but not sure if it affects the search in here)
[codebox]if(@$_REQUEST["a"]=="advsearch")

{

$_SESSION[$strTableName."_asearchnot"]=array();

$_SESSION[$strTableName."_asearchopt"]=array();

$_SESSION[$strTableName."_asearchfor"]=array();

$_SESSION[$strTableName."_asearchfor2"]=array();

$tosearch=0;

$asearchfield = postvalue("asearchfield");

$_SESSION[$strTableName."_asearchtype"] = postvalue("type");

if(!$_SESSION[$strTableName."_asearchtype"])

$_SESSION[$strTableName."asearchtype"]="and";

foreach($asearchfield as $field)

{

$gfield=GoodFieldName($field);

$asopt=postvalue("asearchopt
".$gfield);

$value1=postvalue("value".$gfield);

$type=postvalue("type
".$gfield);

$value2=postvalue("value1".$gfield);

$not=postvalue("not
".$gfield);

if($value1 || $asopt=='Empty')

{

$tosearch=1;

$_SESSION[$strTableName."_asearchopt"][$field]=$asopt;

if(!is_array($value1))

$_SESSION[$strTableName."_asearchfor"][$field]=$value1;

else

$_SESSION[$strTableName."_asearchfor"][$field]=combinevalues($value1);

$_SESSION[$strTableName."_asearchfortype"][$field]=$type;

if($value2)

$_SESSION[$strTableName."_asearchfor2"][$field]=$value2;

$_SESSION[$strTableName."_asearchnot"][$field]=($not=="on");

}

}

if($tosearch)

$_SESSION[$strTableName."_search"]=2;

else

$_SESSION[$strTableName."_search"]=0;

$_SESSION[$strTableName."_pagenumber"]=1;
//start additions

$oldtable=$strTableName;

$strTableName="activity_audit_today_chart";
$_SESSION[$strTableName."_asearchnot"]=array();

$_SESSION[$strTableName."_asearchopt"]=array();

$_SESSION[$strTableName."_asearchfor"]=array();

$_SESSION[$strTableName."_asearchfor2"]=array();

$tosearch=0;

$asearchfield = postvalue("asearchfield");

$_SESSION[$strTableName."_asearchtype"] = postvalue("type");

if(!$_SESSION[$strTableName."_asearchtype"])

$_SESSION[$strTableName."asearchtype"]="and";

foreach($asearchfield as $field)

{

$gfield=GoodFieldName($field);

$asopt=postvalue("asearchopt
".$gfield);

$value1=postvalue("value".$gfield);

$type=postvalue("type
".$gfield);

$value2=postvalue("value1".$gfield);

$not=postvalue("not
".$gfield);

if($value1 || $asopt=='Empty')

{

$tosearch=1;

$_SESSION[$strTableName."_asearchopt"][$field]=$asopt;

if(!is_array($value1))

$_SESSION[$strTableName."_asearchfor"][$field]=$value1;

else

$_SESSION[$strTableName."_asearchfor"][$field]=combinevalues($value1);

$_SESSION[$strTableName."_asearchfortype"][$field]=$type;

if($value2)

$_SESSION[$strTableName."_asearchfor2"][$field]=$value2;

$_SESSION[$strTableName."_asearchnot"][$field]=($not=="on");

}

}

if($tosearch)

$_SESSION[$strTableName."_search"]=2;

else

$_SESSION[$strTableName."_search"]=0;

$_SESSION[$strTableName."_pagenumber"]=1;
$strTableName=$oldtable;

//end additions
}[/codebox]

J
Jane 2/16/2009

Hi,
you need to replace chart2 with your actual chart name which you've added to the page.