PHP Report Maker 6 generates your reports which has the Pagination style based on the setting you chose from it; either using the drop down or link of number style. In addition, either using top, bottom, or top and bottom position. Unfortunately, you have to choose one of those two or three options. If you want to switch from one to another style, then you have to re-generate your script files. Besides that, you have to define the value of the Page Size from PHP Report Maker application. In other words, there are some preferences that still not provided from the configuration file.
This following customization will solve all those issues above by adding some constants in configuration file. Most of the default constants values will be derived from your own/default settings in PHP Report Maker. However, you will be able to change the settings based on your choice by simply adjusting the related constants in that configuration file.
The customization will give you the flexibility and the ability as the following:
- The ability to use the pagination style by simply adjusting the related constant in your configuration (ewrcfg6.php) file, so that you will be able to switch it from one to another without having to re-generate your script files.
- The ability to define the pagination position; whether only at the top of the page, only at the bottom of the page, or at the both top and bottom of the page, by setting the related constant in the configuration file, so that you will be able to switch it from one to another without having to re-generate your script files.
- The ability to define the values of the page size in a string format with comma separated between the values, such as: "1, 5, 10, 15, 20" from the related constant in your configuration file. It means that user will be able to switch the page size based on those five option values you defined. This will make you easier to define with your own values from the configuration file anytime you want.
- The ability to define the maximum selected groups your user can choose from your configuration file. For example, from the five options above, you should set this maximum selected groups value to 20. This will be useful whenever you want to prevent your user displaying the groups per page exceed 20 groups per page from the related parameter in the URL, then your system will automatically limit to 20 groups per page. Generally, this will limit the bandwidth usage of your web application. Does it sound a little smart, huh?
- The ability to define the default maximum groups per page when users load the list page, by setting it up from the related constant in the configuration file. This default constant value is derived from the default setting in your PHP Report Maker application. Of course you can define with your own value from the configuration file.
- The ability whether to display the page number if the maximum groups per page not over the page size or not by setting up the related constant in your configuration file. This will be useful if you donβt want to display the page number one whenever there is only one page.
- Switching the position of Page Size from the most right to the most left of your pagination style. It does more make sense to show the page size first, and then show the page navigation afterwards. This will make your users easier to select the maximum groups per page first, and then they will know how many pages based on that maximum groups per page value, following with the information of displaying from groups number x to y.
- New: Now you can define whether to use the settings from your Project settings or use the settings from the new related constants we just added into the configuration file.
In addition to customize PHP Report Maker template file, then the following modification will synchronize the pagination settings in report pages that generated by PHP Report Maker so it will look similar with the pagination in web applications that generated by PHPMaker. Please note that there is the different term of "record(s)" between PHPMaker and PHP Report Maker. In PHPMaker, we called it with "record(s)" whereas in PHP Report Maker, we called it with "group(s)" for reports, and "record(s)" for tables. Remember, PHP Report Maker also supports for generate report for table, too.
All we have to do is customizing PHP Report Maker template files. In other words, we will not modify the generated script files, so you can re-use this template for your other future projects.
Sounds promising, eh? So, prove it now! π
[hidepost]
-
Open your \Script\rpt-config.php file, and find this code:
// General
before that line, please insert the following code:
// Begin of modification Pagination, by Masino Sinaga, December 4, 2012 define("MSR_TABLE_SETTING_FROM_PROJECT_SETTING", TRUE, TRUE); // Set to TRUE if you want to get from PHPReportMaker setting and ignore the table level constants below define("MSR_PAGINATION_STYLE", <!--##=PROJ.PagerStyle##-->, TRUE); // Whether to use drop down selection (2) or numeric link (1) for pagination style <!--## // Get Pagination position setting from PHP Report Maker application var bTopPosition = PROJ.TopPageLink; var bBottomPosition = PROJ.BottomPageLink; var vPaginationPosition = 2; // default at the bottom of page if (bTopPosition && bBottomPosition) { vPaginationPosition = 3; // top and bottom } else if (bTopPosition && !bBottomPosition) { vPaginationPosition = 1; // top only } else { vPaginationPosition = 2; // bottom only } ##--> define("MSR_PAGINATION_POSITION", <!--##=vPaginationPosition##-->, TRUE); // 1 = Top, 2 = Bottom, 3 = Top and Bottom define("MSR_TABLE_SELECTABLE_GRP_PER_PAGE_LIST", "<!--##=PROJ.RecPerPageList##-->", TRUE); // Selectable records per page list define("MSR_TABLE_GROUPPERPAGE_VALUE", <!--##=PROJ.RecPerPage##-->, TRUE); // Default records/groups per page define("MSR_TABLE_MAXIMUM_SELECTED_GROUPS", 20, TRUE); // Maximum selected groups per page (customized setting) define("MSR_SHOW_PAGENUM_IF_REC_NOT_OVER_PAGESIZE", FALSE, TRUE); // Whether to show or hide the pagenumber if records not over pagesize. Set the second parameter to FALSE if you want to hide the pagenumber, otherwise set to TRUE in order to always show the pagenumber. // End of modification Pagination, by Masino Sinaga, December 4, 2012
-
Open your \Script\rpt-pager.php file, and then replace (yes, replace!) all of the content of that file (Warning: Backup your file before doing this step! This is only for PHP Report Maker 6.0.0. Do not do this customization for the older version!):
<!--##session phppager##--> <!--## if (TABLE.TblType != "REPORT") { sItem = "<?php echo $ReportLanguage->Phrase(\"Record\") ?>"; sItemsPerPage = "<?php echo $ReportLanguage->Phrase(\"RecordsPerPage\") ?>"; } else { sItem = "<?php echo $ReportLanguage->Phrase(\"Group\") ?>"; sItemsPerPage = "<?php echo $ReportLanguage->Phrase(\"GroupsPerPage\") ?>"; } sImageFolder = ew_FolderPath("_images") + "/"; iAnonymous = TABLE.TblAnonymous; bAnonymous = ((iAnonymous & 8) == 8); ##--> <form action="<?php echo ewr_CurrentPage() ?>" name="ewpagerform" id="ewpagerform" class="msPagination"> <table class="ewPager"><tr><td> <?php if (MSR_PAGINATION_STYLE==1) { // Numeric link style (not dropdown) ?> <span class="phpreportmaker"> <?php if (!isset($Pager)) $Pager = new crNumericPager($<!--##=gsPageObj##-->->StartGrp, $<!--##=gsPageObj##-->->DisplayGrps, $<!--##=gsPageObj##-->->TotalGrps, $<!--##=gsPageObj##-->->GrpRange) ?> <?php if ($Pager->RecordCount > 0) { ?> <!--## if (ew_IsNotEmpty(sGrpPerPageList)) { arrGrpPerPage = sGrpPerPageList.split(","); ##--> <?php if ($<!--##=gsPageObj##-->->TotalGrps > 0) { ?> <span class="phpreportmaker"><!--##=sItemsPerPage##--> <select name="<?php echo EWR_TABLE_GROUP_PER_PAGE; ?>" onchange="this.form.submit();"> <?php if (MSR_TABLE_SETTING_FROM_PROJECT_SETTING==FALSE) { $sGrpPerPageList = explode(',',MSR_TABLE_SELECTABLE_GRP_PER_PAGE_LIST); foreach ($sGrpPerPageList as $a) { $thisDisplayGrps = $a; if ($thisDisplayGrps > 0 ) { $thisValue = $thisDisplayGrps; ?> <option value="<?php echo $thisDisplayGrps; ?>"<?php if ($<!--##=sPageObj##-->->DisplayGrps == $thisValue) echo " selected=\"selected\"" ?>><?php echo $thisDisplayGrps; ?></option> <?php } else { ?> <option value="ALL"<?php if ($<!--##=gsPageObj##-->->getGroupPerPage() == -1) echo " selected=\"selected\"" ?>><!--##@AllRecords##--></option> <?php } } } else { ?> <!--## for (var i = 0; i < arrGrpPerPage.length; i++) { thisDisplayGrps = arrGrpPerPage[i]; if (parseInt(thisDisplayGrps) > 0) { thisValue = parseInt(thisDisplayGrps); ##--> <option value="<!--##=thisDisplayGrps##-->"<?php if ($<!--##=gsPageObj##-->->DisplayGrps == <!--##=thisValue##-->) echo " selected=\"selected\"" ?>><!--##=thisDisplayGrps##--></option> <!--## } else { ##--> <option value="ALL"<?php if ($<!--##=gsPageObj##-->->getGroupPerPage() == -1) echo " selected=\"selected\"" ?>><!--##@AllRecords##--></option> <!--## } } ##--> <?php } ?> </select> </span> <?php } ?> <!--## } ##--> <?php if ($Pager->FirstButton->Enabled) { ?> <a href="<?php echo ewr_CurrentPage() ?>?start=<?php echo $Pager->FirstButton->Start ?>"><b><!--##@PagerFirst##--></b></a> <?php } ?> <?php if ($Pager->PrevButton->Enabled) { ?> <a href="<?php echo ewr_CurrentPage() ?>?start=<?php echo $Pager->PrevButton->Start ?>"><b><!--##@PagerPrevious##--></b></a> <?php } ?> <?php foreach ($Pager->Items as $PagerItem) { ?> <?php if ($PagerItem->Enabled) { ?><a href="<?php echo ewr_CurrentPage() ?>?start=<?php echo $PagerItem->Start ?>"><?php } ?><b><?php echo $PagerItem->Text ?></b><?php if ($PagerItem->Enabled) { ?></a><?php } ?> <?php } ?> <?php if ($Pager->NextButton->Enabled) { ?> <a href="<?php echo ewr_CurrentPage() ?>?start=<?php echo $Pager->NextButton->Start ?>"><b><!--##@PagerNext##--></b></a> <?php } ?> <?php if ($Pager->LastButton->Enabled) { ?> <a href="<?php echo ewr_CurrentPage() ?>?start=<?php echo $Pager->LastButton->Start ?>"><b><!--##@PagerLast##--></b></a> <?php } ?> <?php if ($Pager->ButtonCount > 0) { ?> <?php } ?> <!--##@Record##--> <?php echo $Pager->FromIndex ?> <!--##@To##--> <?php echo $Pager->ToIndex ?> <!--##@Of##--> <?php echo $Pager->RecordCount ?> <?php } else { ?> <!--## if (bUserLevel && !bAnonymous) { ##--> <?php if (($Security->CurrentUserLevel() & EWR_ALLOW_LIST) == EWR_ALLOW_LIST) { ?> <!--## } ##--> <?php if ($<!--##=gsPageObj##-->->Filter == "0=101") { ?> <!--##@EnterSearchCriteria##--> <?php } else { ?> <!--##@NoRecord##--> <?php } ?> <!--## if (bUserLevel && !bAnonymous) { ##--> <?php } else { ?> <!--##@NoPermission##--> <?php } ?> <!--## } ##--> <?php } ?> </span> <?php } elseif (MSR_PAGINATION_STYLE==2) { ?> <?php if (!isset($Pager)) $Pager = new crPrevNextPager($<!--##=gsPageObj##-->->StartGrp, $<!--##=gsPageObj##-->->DisplayGrps, $<!--##=gsPageObj##-->->TotalGrps) ?> <?php if ($Pager->RecordCount > 0) { ?> <table cellspacing="0" class="ewStdTable"><tbody> <tr> <!--## if (ew_IsNotEmpty(sGrpPerPageList)) { arrGrpPerPage = sGrpPerPageList.split(","); ##--> <?php if ($<!--##=gsPageObj##-->->TotalGrps > 0) { ?> <td><table cellspacing="0" class="ewStdTable"><tbody><tr><td><!--##=sItemsPerPage##--> <select name="<?php echo EWR_TABLE_GROUP_PER_PAGE; ?>" onchange="this.form.submit();"> <?php if (MSR_TABLE_SETTING_FROM_PROJECT_SETTING==FALSE) { $sGrpPerPageList = explode(',',MSR_TABLE_SELECTABLE_GRP_PER_PAGE_LIST); foreach ($sGrpPerPageList as $a) { $thisDisplayGrps = $a; if ($thisDisplayGrps > 0 ) { $thisValue = $thisDisplayGrps; ?> <option value="<?php echo $thisDisplayGrps; ?>"<?php if ($<!--##=sPageObj##-->->DisplayGrps == $thisValue) echo " selected=\"selected\"" ?>><?php echo $thisDisplayGrps; ?></option> <?php } else { ?> <option value="ALL"<?php if ($<!--##=sPageObj##-->->getGroupPerPage() == -1) echo " selected=\"selected\"" ?>><!--##@AllRecords##--></option> <?php } } } else { ?> <!--## for (var i = 0; i < arrGrpPerPage.length; i++) { thisDisplayGrps = arrGrpPerPage[i]; if (parseInt(thisDisplayGrps) > 0) { thisValue = parseInt(thisDisplayGrps); ##--> <option value="<!--##=thisDisplayGrps##-->"<?php if ($<!--##=gsPageObj##-->->DisplayGrps == <!--##=thisValue##-->) echo " selected=\"selected\"" ?>><!--##=thisDisplayGrps##--></option> <!--## } else { ##--> <option value="ALL"<?php if ($<!--##=gsPageObj##-->->getGroupPerPage() == -1) echo " selected=\"selected\"" ?>><!--##@AllRecords##--></option> <!--## } } ##--> <?php } ?> </select></td></tr></tbody></table> </td> <td> </td> <?php } ?> <!--## } ##--> <?php if (($Pager->PageCount==1) && ($Pager->CurrentPage == 1) ) { ?> <?php if (MSR_SHOW_PAGENUM_IF_REC_NOT_OVER_PAGESIZE) { ?> <td><span class="phpreportmaker"><!--##@Page##--> </span></td> <!--first page button--> <?php if ($Pager->FirstButton->Enabled) { ?> <td><a href="<?php echo ewr_CurrentPage() ?>?start=<?php echo $Pager->FirstButton->Start ?>"><img src="<!--##=sImageFolder##-->first.gif" width="16" height="16" alt="<!--##@PagerFirst##-->" style="border: 0;" /></a></td> <?php } else { ?> <td><img src="<!--##=sImageFolder##-->firstdisab.gif" width="16" height="16" alt="<!--##@PagerFirst##-->" style="border: 0;" /></td> <?php } ?> <!--previous page button--> <?php if ($Pager->PrevButton->Enabled) { ?> <td><a href="<?php echo ewr_CurrentPage() ?>?start=<?php echo $Pager->PrevButton->Start ?>"><img src="<!--##=sImageFolder##-->prev.gif" width="16" height="16" alt="<!--##@PagerPrevious##-->" style="border: 0;" /></a></td> <?php } else { ?> <td><img src="<!--##=sImageFolder##-->prevdisab.gif" width="16" height="16" alt="<!--##@PagerPrevious##-->" style="border: 0;" /></td> <?php } ?> <!--current page number--> <td><input type="text" name="pageno" id="pageno" value="<?php echo $Pager->CurrentPage ?>" size="4"></td> <!--next page button--> <?php if ($Pager->NextButton->Enabled) { ?> <td><a href="<?php echo ewr_CurrentPage() ?>?start=<?php echo $Pager->NextButton->Start ?>"><img src="<!--##=sImageFolder##-->next.gif" width="16" height="16" alt="<!--##@PagerNext##-->" style="border: 0;" /></a></td> <?php } else { ?> <td><img src="<!--##=sImageFolder##-->nextdisab.gif" width="16" height="16" alt="<!--##@PagerNext##-->" style="border: 0;" /></td> <?php } ?> <!--last page button--> <?php if ($Pager->LastButton->Enabled) { ?> <td><a href="<?php echo ewr_CurrentPage() ?>?start=<?php echo $Pager->LastButton->Start ?>"><img src="<!--##=sImageFolder##-->last.gif" width="16" height="16" alt="<!--##@PagerLast##-->" style="border: 0;" /></a></td> <?php } else { ?> <td><img src="<!--##=sImageFolder##-->lastdisab.gif" width="16" height="16" alt="<!--##@PagerLast##-->" style="border: 0;" /></td> <?php } ?> <td><span class="phpreportmaker"> <!--##@of##--> <?php echo $Pager->PageCount ?></span></td> <?php } // End of MSR_SHOW_PAGENUM_IF_REC_NOT_OVER_PAGESIZE ?> <?php } else { // Else of CurrentPage == 1 ?> <td><span class="phpreportmaker"><!--##@Page##--> </span></td> <!--first page button--> <?php if ($Pager->FirstButton->Enabled) { ?> <td><a href="<?php echo ewr_CurrentPage() ?>?start=<?php echo $Pager->FirstButton->Start ?>"><img src="<!--##=sImageFolder##-->first.gif" width="16" height="16" alt="<!--##@PagerFirst##-->" style="border: 0;" /></a></td> <?php } else { ?> <td><img src="<!--##=sImageFolder##-->firstdisab.gif" width="16" height="16" alt="<!--##@PagerFirst##-->" style="border: 0;" /></td> <?php } ?> <!--previous page button--> <?php if ($Pager->PrevButton->Enabled) { ?> <td><a href="<?php echo ewr_CurrentPage() ?>?start=<?php echo $Pager->PrevButton->Start ?>"><img src="<!--##=sImageFolder##-->prev.gif" width="16" height="16" alt="<!--##@PagerPrevious##-->" style="border: 0;" /></a></td> <?php } else { ?> <td><img src="<!--##=sImageFolder##-->prevdisab.gif" width="16" height="16" alt="<!--##@PagerPrevious##-->" style="border: 0;" /></td> <?php } ?> <!--current page number--> <td><input type="text" name="pageno" id="pageno" value="<?php echo $Pager->CurrentPage ?>" size="4"></td> <!--next page button--> <?php if ($Pager->NextButton->Enabled) { ?> <td><a href="<?php echo ewr_CurrentPage() ?>?start=<?php echo $Pager->NextButton->Start ?>"><img src="<!--##=sImageFolder##-->next.gif" width="16" height="16" alt="<!--##@PagerNext##-->" style="border: 0;" /></a></td> <?php } else { ?> <td><img src="<!--##=sImageFolder##-->nextdisab.gif" width="16" height="16" alt="<!--##@PagerNext##-->" style="border: 0;" /></td> <?php } ?> <!--last page button--> <?php if ($Pager->LastButton->Enabled) { ?> <td><a href="<?php echo ewr_CurrentPage() ?>?start=<?php echo $Pager->LastButton->Start ?>"><img src="<!--##=sImageFolder##-->last.gif" width="16" height="16" alt="<!--##@PagerLast##-->" style="border: 0;" /></a></td> <?php } else { ?> <td><img src="<!--##=sImageFolder##-->lastdisab.gif" width="16" height="16" alt="<!--##@PagerLast##-->" style="border: 0;" /></td> <?php } ?> <td><span class="phpreportmaker"> <!--##@of##--> <?php echo $Pager->PageCount ?></span></td> <?php } // End of CurrentPage == 1 ?> </tr></tbody></table> </td> <td> </td> <td> <span class="phpreportmaker"><!--##@Record##--> <?php echo $Pager->FromIndex ?> <!--##@To##--> <?php echo $Pager->ToIndex ?> <!--##@Of##--> <?php echo $Pager->RecordCount ?></span> <?php } else { ?> <!--## if (bUserLevel && !bAnonymous) { ##--> <?php if (($Security->CurrentUserLevel() & EWR_ALLOW_LIST) == EWR_ALLOW_LIST) { ?> <!--## } ##--> <?php if ($<!--##=gsPageObj##-->->Filter == "0=101") { ?> <span class="phpreportmaker"><!--##@EnterSearchCriteria##--></span> <?php } else { ?> <span class="phpreportmaker"><!--##@NoRecord##--></span> <?php } ?> <!--## if (bUserLevel && !bAnonymous) { ##--> <?php } else { ?> <span class="phpreportmaker"><!--##@NoPermission##--></span> <?php } ?> <!--## } ##--> <?php } ?> <?php } // End of Pagination Style ?> </td> </tr></table> </form> <!--##/session##--> <?php <!--##session setupdisplaygrps##--> // Set up number of groups displayed per page function SetUpDisplayGrps() { //$sWrk = @$_GET[EWR_TABLE_GROUP_PER_PAGE]; // Begin of modification Customize Navigation/Pager Panel, by Masino Sinaga, December 4, 2012 global $ReportLanguage; $sWrk = @$_GET[EWR_TABLE_GROUP_PER_PAGE]; if ($sWrk > MSR_TABLE_MAXIMUM_SELECTED_GROUPS) { $sWrk = MSR_TABLE_MAXIMUM_SELECTED_GROUPS; $this->setFailureMessage(str_replace("%t", MSR_TABLE_MAXIMUM_SELECTED_GROUPS, $ReportLanguage->Phrase("MaximumRecordsGroupsPerPage"))); } // End of modification Customize Navigation/Pager Panel, by Masino Sinaga, December 4, 2012 if ($sWrk <> "") { if (is_numeric($sWrk)) { $this->DisplayGrps = intval($sWrk); } else { if (strtoupper($sWrk) == "ALL") { // display all groups $this->DisplayGrps = -1; } else { $this->DisplayGrps = <!--##=iGrpPerPage##-->; // Non-numeric, load default } } $this->setGroupPerPage($this->DisplayGrps); // Save to session // Reset start position (reset command) $this->StartGrp = 1; $this->setStartGroup($this->StartGrp); } else { if ($this->getGroupPerPage() <> "") { $this->DisplayGrps = $this->getGroupPerPage(); // Restore from session } else { $this->DisplayGrps = <!--##=iGrpPerPage##-->; // Load default } } } <!--##/session##--> ?>
-
Open your \Script\rpt-phpcommon-table.php file, and find this code:
<!--## if (bTopPageLink) { ##--> <!--##=sPagerExpStart##--> <div class="ewGridUpperPanel"> <!--##include rpt-pager.php/phppager##--> </div> <!--##=sPagerExpEnd##--> <!--## }; // End top page link ##-->
then replace it with the following code:
<?php // Begin of modification Pagination, by Masino Sinaga, December 4, 2012 ?> <?php if ( (MSR_PAGINATION_POSITION==1) || (MSR_PAGINATION_POSITION==3) ) { ?> <!--##=sPagerExpStart##--> <div class="ewGridUpperPanel"> <!--##include rpt-pager.php/phppager##--> </div> <!--##=sPagerExpEnd##--> <?php } ?> <?php // End of modification Pagination, by Masino Sinaga, December 4, 2012 ?>
-
Still in that \Script\rpt-phpcommon-table.php file, find again this code:
<!--## if (bBottomPageLink) { ##--> <!--## if (bTopPageLink) { ##--> <?php if ($<!--##=gsPageObj##-->->TotalGrps > 0) { ?> <!--## } ##--> <!--##=sPagerExpStart##--> <div class="ewGridLowerPanel"> <!--##include rpt-pager.php/phppager##--> </div> <!--##=sPagerExpEnd##--> <!--## if (bTopPageLink) { ##--> <?php } ?> <!--## } ##--> <!--## }; // End bottom page link ##-->
then replace it with the following code:
<?php // Begin of modification Pagination, by Masino Sinaga, December 4, 2012 ?> <?php if ( (MSR_PAGINATION_POSITION==2) || (MSR_PAGINATION_POSITION==3) ) { ?> <?php if ($<!--##=gsPageObj##-->->TotalGrps > 0) { ?> <!--##=sPagerExpStart##--> <div class="ewGridLowerPanel"> <!--##include rpt-pager.php/phppager##--> </div> <!--##=sPagerExpEnd##--> <?php } ?> <?php } ?> <?php // End of modification Pagination, by Masino Sinaga, December 4, 2012 ?>
-
Next step, we will add our new style to the .css file that will be generated by PHPMaker. This will beautify your search panel by adding colored background and outlined around its panel. From your PHPMaker application, go to HTML tab, then click on Styles sub-tab, and then click on Edit Styles button. You will see a CSS Editor window shown up afterwards. Scroll down to the bottom of that textbox, and find this code:
/*END_USER_STYLES*/
before that line, please insert the following code:
/* Begin of modification Customize Navigation/Pager Panel, by Masino Sinaga, May 2, 2012 */ .msPagination { background-color: #EEEEEE; border-left: 1px solid #CACACA; border-right: 1px solid #CACACA; border-top: 1px solid #CACACA; border-bottom: 1px solid #CACACA; padding: 0.5em; text-align: left; font-family: tahoma; /* font name */ display: block; vertical-align:top; } /* End of modification Customize Navigation/Pager Panel, by Masino Sinaga, May 2, 2012 */
afterwards click on OK button to save the changes and close the CSS Editor window.
-
Open your C:\Program Files\PHP Report Maker 6\languages\english.xml file, and find this code:
<global>
after that line, yes, after that line, please insert the following code:
<phrase id="MaximumRecordsGroupsPerPage" value="Maximum %t groups/records per page."/>
- Finally, re-generate your script files using PHP Report Maker as always.
[/hidepost]
Leave a Reply
You must be logged in to post a comment.