This topic is locked

Don't filter on search

8/8/2010 7:28:08 AM
PHPRunner General questions
H
hornet author

HI!
I added (thx to another thread) $strWhereClause = whereAdd($strWhereClause, 'acct_status="Enabled"'); in the "Before SQL Query" and this is working correctly. I'd like to only apply on default list view, if I do a search for "Disabled" I get no records back (as expected due to the filter). Is there a way to not apply the filter on searches? I was thinking of writing a php if statement to look for "ctlSearchFor" in the URL. Can this be done?
-Erik-

H
hornet author 8/8/2010



HI!
I added (thx to another thread) $strWhereClause = whereAdd($strWhereClause, 'acct_status="Enabled"'); in the "Before SQL Query" and this is working correctly. I'd like to only apply on default list view, if I do a search for "Disabled" I get no records back (as expected due to the filter). Is there a way to not apply the filter on searches? I was thinking of writing a php if statement to look for "ctlSearchFor" in the URL. Can this be done?
-Erik-


So I came up with this,



$string=$_SERVER["QUERY_STRING"];
$issearch=strpos($string, 'value11=Disabled');

$isadvsrch=strpos($string, 'not1=on');
if( $issearch === FALSE && $isadvsrch === FALSE) {

echo "Applying default filter
";

$strWhereClause = whereAdd($strWhereClause, 'acct_status="Enabled"');

}


This seems to work but is very ugly. I looked that the $_SESSION["customers_advsearch"] but I cant seem to figure out how to parse it correctly. That seems like a better way to go. Can someone point me in the right direction please?
-Erik-

H
hornet author 8/8/2010



So I came up with this,



$string=$_SERVER["QUERY_STRING"];
$issearch=strpos($string, 'value11=Disabled');

$isadvsrch=strpos($string, 'not1=on');
if( $issearch === FALSE && $isadvsrch === FALSE) {

echo "Applying default filter
";

$strWhereClause = whereAdd($strWhereClause, 'acct_status="Enabled"');

}


This seems to work but is very ugly. I looked that the $_SESSION["customers_advsearch"] but I cant seem to figure out how to parse it correctly. That seems like a better way to go. Can someone point me in the right direction please?
-Erik-


Also added a dropdown to quickly change between the two states



$str = "";

$str.= "<select onchange=\"window.location.href=this.options[this.selectedIndex]. value;\"><option value=\"\">Account Status</option>";
//select values from database

global $conn;

$strSQL = "select distinct acct_status from customers";

$rs = db_query($strSQL,$conn);

while ($data = db_fetch_array($rs))

$str.="<option value=\"customers_list.php?ctlSearchFor=".$data["acct_status"].

"&srchOptShowStatus=1&ctrlTypeComboStatus=0&srchWinShowStatus=0&a=integrated&id=1&criteria=and&type1=&value11=".

$data["acct_status"]."&field1=acct_status&option1=Contains&not1=a=search&value=1\">".$data["acct_status"]."</option>";

$str.="</select>";

echo $str;
J
Jane 8/9/2010

Hi,
You can check search valuesin the List page: Before SQL query event and add or remove custom WHERE statement dynamically. Here is a sample how to check search parameters:

http://www.asprunner.com/forums/topic/14570-how-to-print-search-parameters-on-the-list-page/