edit current fillter

This public forum is for user-to-user discussions of PHP Report Maker. Note that this is not support forum.

edit current fillter

Postby pphacker » Thu Nov 09, 2017 11:54 am

please help me!

example: 'cms_date' BETWEEN '2017-09-01' AND '2017-09-30'


1.i would like to remove or edit word'cms_date'
2.i would like to Edit word 'BETWEEN' 'AND'
from my report
pphacker
 
Posts: 14
Joined: Tue Sep 05, 2017 2:08 pm

Re: edit current fillter

Postby kirondedshem » Thu Nov 09, 2017 1:50 pm

You need to explain the reason why and what you would like to change it to.
BUT
Ive had a case where I need to show a date picker and i added a custom field and set its view tage to be date picker, such that a user can select a data on the page.
But I was going to use this date to do some custom sql queries and I did not want it to affect the serach as if its applied it hides all records on my report.
As such I needed to remove the 'date_filed' BETWEEN '2017-09-01' AND '2017-09-30' from the search criteria used by list page.

1. Not recommended:If your lucky and its the only serach filed on the page, then you just have to nullify the seacrh filter in page_selecting, for example:
// Page Selecting event
function Page_Selecting(&$filter) {
// Enter your code here
//dont apply filter here
$filter = "";
}

2.REcommended as its dynamic enough
a. but if the page has some other serach parameters which you still want to apply but deny the date one. Then you can remove it using regular expression.
NOTE:if not working, edit regular expression to make it work
function Page_Selecting(&$filter) {
// Enter your code here
var_dump($filter);
//try to remove onlt the date filter and leave the rest
$filter = preg_replace("('cms_date' BETWEEN '(.+)' AND '(.+)')","(1 = 1)",$filter);
var_dump($filter);
}

b. If you cant figure out regular expresiion, then the other solution is:
-save the serach parameters into a session variable in page_load event of report list
HINT:they are always passed in url parameters when they are to change so capture them then and keep on updating session variables., for_example
function Page_Load() {
//echo "Page Load";

//incase its initial posting
if(isset($_GET["x_select_date"]) && ($_GET["x_select_date"] != null) )
{
$_SESSION["my_report_select_date_1"] = $_GET["x_select_date"];
}

}
-then formulate the serach criteria using the known serach parameter and use string replace to replace the whole searcvh filter as is:

function Page_Selecting(&$filter) {
// Enter your code here
//formulate the sercah parameter
$the_date_clause = "'' = '".$_SESSION["my_report_select_date_1"]."'";
//replace the serach with a always true condition to not mess up other searches in the list
var_dump($the_date_clause);
var_dump($filter);
$filter = str_ireplace($the_date_clause,"(1 = 1)",$filter);
var_dump($filter);

}


HINT: you can vardump the values in page_Selecting so you can be sure that tehsearch id being edited as you wanted.
kirondedshem
 
Posts: 310
Joined: Sat Jan 28, 2017 7:13 pm

Re: edit current fillter

Postby pphacker » Thu Nov 16, 2017 7:05 pm

i don't understand please example again
pphacker
 
Posts: 14
Joined: Tue Sep 05, 2017 2:08 pm

Re: edit current fillter

Postby kirondedshem » Thu Nov 16, 2017 8:24 pm

>i don't understand please example again
First explain in details what you want to achieve
Then go through the suggestions above and try using them to see if any of them can help you find a possible solution
Then tell us what you dont undertand
kirondedshem
 
Posts: 310
Joined: Sat Jan 28, 2017 7:13 pm

Re: edit current fillter

Postby Webmaster » Tue Nov 21, 2017 9:34 am

The current filter is formatted by the function "ShowFilterList". If you want custom layout, open the generated report file and customize the function.
Webmaster
 
Posts: 10731
Joined: Fri Aug 06, 2004 5:59 pm


Return to General Discussion (PHP Report Maker)



cron