Now we are going to display records in List page on daily basis by using Server Events in web applications that generated by PHPMaker. This is very useful for web applications which have the transaction records that growing from day to day. Each time users open the List page, then only the records that have been added on that day (based on the transaction datetime field) will be displayed instead of displaying all records (even they are devided into several pages).
This is an alternative way to display the records in the List page besides by making the List page Requires Search Criteria and defining the default search criteria from the Search Page as you can read from this article. However, this following trick will also handle if the search criteria has been defined by users, then the daily basis recordset criteria will be overriden by the search criteria.
By using this trick, then you can also decrease the bandwidth usage for your web applications.
[hidepost]
- Open your PHPMaker project (.pmp) file using PHPMaker application.
-
Click on your desired transaction table from the Database pane of PHPMaker, then click on Code (Server Events, Client Scripts and Custom Templates) tab, expand the following location: Server Events -> Table-Specific -> Common -> Recordset_Selecting, and then insert the following code to that Recordset_Selecting function:
$begin_date = date("Y-m-d") . " 00:00:00";
$end_date = date("Y-m-d") . " 23:59:59";
// Only filter if there is no search criteria defined
if ($this->getSearchWhere() == "") {
// Don't forget to adjust MyDateTimeField with yours
ew_AddFilter($filter, "MyDateTimeField >= '".$begin_date."' AND MyDateTimeField <= '".$end_date."'"); } [/code] - Make sure you do not enable Requires Search Criteria for the table from its Table setup.
- Finally, re-generate your script file using PHPMaker as always.
[/hidepost]
Leave a Reply
You must be logged in to post a comment.