If your web application has many transactions data that entered by end-users everyday, then consider not to display all records in the List page since the page will take much longer time to be loaded to your end-users. Fortunately, PHPMaker has provided Requires Search Criteria from the Tables setup that related to the table so that the users have to enter the search criteria in order to display the records in the List page.
However, even your end-users have to enter the search criteria before displaying the records in the List page, you (as web developer) should provide them the default search criteria, moreover if they always use this page everyday. Since we are talking about the transactions data, then that would be better if we define the default of search value for the date and time field; including its search operator as well.
This following trick will show you how to define it using Server Events from PHPMaker easily and quickly. You will know how easy we can define the search criteria that contains Start DateTime and End DateTime in Advanced Search by using Server Event that belongs to the Search Page.
In this example, let's say we have a Transaction_Date as a DateTime field type, and we will define the search operator as BETWEEN for the field, and then the search value for the beginning and the end of date and time respectively as date of today from 00:00:00 until 23:59:59. So, if, for example today is July 24, 2013, then the search criteria will be displayed as BETWEEN 2013-07-24 00:00:00 AND 2013-07-24 23:59:59.
In other words, when your end-users visit the Advanced Search page, they unnecessary to enter the search criteria since the system will provide it automatically every day and will be adjusted to the date of that day accordingly.
[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 -> Search Page -> Page_DataRendering, and then insert the following code to that Page_DataRendering function:
// Make sure you have adjusted the Transaction_Date with yours if ($this->Transaction_Date->AdvancedSearch->SearchOperator == "") { $this->Transaction_Date->AdvancedSearch->SearchOperator = "BETWEEN"; } if ($this->Transaction_Date->EditValue == "") { $this->Transaction_Date->EditValue = date("Y-m-d")." 00:00:01"; // change date("Y-m-d") to your date format } if ($this->Transaction_Date->EditValue2 == "") { $this->Transaction_Date->EditValue2 = date("Y-m-d")." 23:59:59"; // change date("Y-m-d") to your date format } - Re-generate your script files using PHPMaker as always.
[/hidepost]
Leave a Reply
You must be logged in to post a comment.