I think I have all the info you need below.
A big NOTE: This is done using PHPRunner 3.0 not the newer version.
First I copied the bit below from my construction_data_search.php and pasted it into a new file
as below. I found I only needed to copy the function WriteSearchOptions($field,$fmt) also as it
stopped the errors I was getting. I only have one field I wanted in this case, if I need more, I can
just copy them from the search page and paste them into this file.
Save it with the orginal ..._list.php and just add _select to the name as below for my file.
Start of construction_data_list_select.php file
<?php
echo "<form method=\"POST\" action=\"construction_data_list.php\" name=\"by_select\">";
echo "<input type=\"hidden\" id=\"a\" name=\"a\" value=\"advsearch\">";
echo "<input type=\"hidden\" name=\"type\" value=\"and\" checked>";
echo "<tr bgcolor=\"lightgray\" height=\"30px\">";
echo "<td align=\"right\" valign=\"middle\">Select by Component ";
$secondid=1;
// component
if(!IsBinaryType(@$_SESSION[$strTableName."_fieldinfo"]["component"]["type"]))
{
$opt="";
$for="";
$for2="";
$not=false;
$i=array_search("component",$fieldlist);
if(@$_SESSION[$strTableName."_search"]==2)
{
if(@$_SESSION[$strTableName."_asearchopt"] && array_key_exists($i,@$_SESSION[$strTableName."_asearchopt"]))
$opt=$_SESSION[$strTableName."_asearchopt"][$i];
if(@$_SESSION[$strTableName."_asearchfor"] && array_key_exists($i,@$_SESSION[$strTableName."_asearchfor"]))
$for=$_SESSION[$strTableName."_asearchfor"][$i];
if(@$_SESSION[$strTableName."_asearchfor2"] && array_key_exists($i,@$_SESSION[$strTableName."_asearchfor2"]))
$for2=$_SESSION[$strTableName."_asearchfor2"][$i];
if(@$_SESSION[$strTableName."_asearchnot"] && array_key_exists($i,@$_SESSION[$strTableName."_asearchnot"]))
$not=$_SESSION[$strTableName."_asearchnot"][$i];
}
$fmt=GetEditFormat("component");
if(!$fmt)
$fmt=EDIT_FORMAT_TEXT_FIELD;
if(!$fmt || $fmt==EDIT_FORMAT_TEXT_AREA
|| $fmt==EDIT_FORMAT_PASSWORD || $fmt==EDIT_FORMAT_HIDDEN
|| $fmt==EDIT_FORMAT_READONLY)
$fmt=EDIT_FORMAT_TEXT_FIELD;
?>
<input type="hidden" name="asearchfield[]" value="<?php echo $i;?>">
<input type="hidden" name="not<?php echo $i;?>" <?php if($not) echo "checked" ?>>
<span style="display:none"><?php $havesecond=WriteSearchOptions("component",$fmt); ?></span>
<?php echo BuildEditControl("component",$for,$fmt,MODE_SEARCH); ?>
<span id="second<?php echo $secondid++;?>"><?php if($havesecond) echo BuildEditControl("component",$for2,$fmt,MODE_SEARCH,$i+10000); ?></span>
<?php
}
echo "</td></tr></form>";
function WriteSearchOptions($field,$fmt)
{
global $opt,$strSize;
$ret=0;
if($fmt==EDIT_FORMAT_TEXT_FIELD)
{
$a=array("Contains","Equals","Starts with ...","More than ...","Less than ...","Equal or more than ...","Equal or less than ...","Between","Empty");
$b=array(mlang_message("CONTAINS"),mlang_message("EQUALS"),mlang_message("STARTS_WITH"),mlang_message("MORE_THAN"),mlang_message("LESS_THAN"),mlang_message("EQUAL_OR_MORE"),mlang_message("EQUAL_OR_LESS"),mlang_message("BETWEEN"),mlang_message("EMPTY"));
$ret=1;
}
else if($fmt==EDIT_FORMAT_DATE)
{
$a=array("Equals","More than ...","Less than ...","Equal or more than ...","Equal or less than ...","Between","Empty");
$b=array(mlang_message("EQUALS"),mlang_message("MORE_THAN"),mlang_message("LESS_THAN"),mlang_message("EQUAL_OR_MORE"),mlang_message("EQUAL_OR_LESS"),mlang_message("BETWEEN"),mlang_message("EMPTY"));
$ret=1;
}
else if($fmt==EDIT_FORMAT_LOOKUP_WIZARD )
{
$strSize=1;
GetLookupData($field);
if($strSize==1)
{
$a=array("Equals");
$b=array(mlang_message("EQUALS"));
}
else
{
$a=array("Contains");
$b=array(mlang_message("CONTAINS"));
}
}
else
{
$a=array("Equals");
$b=array(mlang_message("EQUALS"));
}
echo "<SELECT ID=\"SearchOption\" NAME=\"asearchopt[]\" SIZE=1 onChange=\"return ShowHideControls();\">";
foreach($a as $key=>$o)
echo "<OPTION VALUE=\"".$o."\" ".(($opt==$o)?"selected":"").">".$b[$key]."</option>";
echo "</SELECT>";
return $ret;
}
?>
End of construction_data_list_select.php file
Second
Then I modified the list.php in my template folder and added a file check as below.
I placed the coded just above the list details. This way I ended up with a nice grey row
at the top of the list with this picklist in it. Also now I can employ the feature on any
list that I may need to pretty easily.
<?php if(file_exists("##SHORTTABLENAME##_list_select.php"))
include("##SHORTTABLENAME##_list_select.php");
?>
Third
I modified the functions.php in my template folder as below. I needed the search to happen
as soon as I changed the picklist. Similar to the way changing the number of records per
page does. The function below was changed just a little bit.
From ==>
LogInfo($LookupSQL);
$rs=db_query($LookupSQL,$conn);
if(!db_numrows($rs))
return "";
$onchange="";
To ==>
LogInfo($LookupSQL);
$rs=db_query($LookupSQL,$conn);
if(!db_numrows($rs))
return "";
global $strTableName;
if (($strTableName == "construction_data") || ($strTableName == "customer") || ($strTableName == "credit_data") )
$onchange="document.forms.by_select.submit();";
else
$onchange="";
As you can see, I have it on three lists currently, the if statement checks to see if the altered onchange should be used or the original function untouched.
That's it, generated my pages from Phprunner and all done. I havent come accross any issues
yet, seems to be working quite fine.
I am not experienced with php or mysql so if there was an easier way or a better way to do
this I sure would love the tips. I hate playing in that function.php file and there are
a ton of functions in there Im sure I could use if I had more experience.
I am thinking of using that nice band accross the top for a Button row. I have also
added a function to batch email to any viewed customer list. I currently have a new
button named Batch Email on the list page. Im thinking I'll get a toolbar button and
place it in this band. I could lots of things with this area.
Anyway, I have to get back at it. Hope this is a help to you. Any comments welcome.
Dale Miller