This topic is locked

Guide 14 - Use multiple pages of PRINT

5/8/2021 11:29:16 AM
PHPRunner Tips and Tricks
fhumanes author

One of the questions that came to my email was, how to have several pages of Print on a List page?

More or less, the question is how can we set a button that runs the PRINT page without maintaining the dialog that by default creates phprunner?

Thus, this guide is how to execute the functionality of the Print pages, passing all the parameters that this page requires.

Objective

On a LIST page create one or more buttons that execute the PRINT page without the dialogs that by default creates PHPRunner

DEMO: https://fhumanes.com/printt

The code and download of the project is available on my portal.

fhumanes author 5/8/2021

Technical solution

Appearance of the solution:

img alt

PHPRUNNER pages designer:

img alt

As we can appreciate, the different pages are designed in the Phprunner designer. The functionality of the designer is different depending on the version, however it has limited possibilities for printing design. In the example I have used the invoice example data that we can generate Word, Excel or PDF, but for this we are using external libraries to Phprunner.

In this case, all functionality is PHPRunner and does not require external libraries.

In analysis of the solution, I checked that Phprunner passes through post the parameters that are defined in the standard button of the PRINT button, for that reason I have had to simulate a post communication from JavaScript.

Also, I have fixed that it prints the invoices that have previously been selected and that if no invoice is selected, report that it is necessary to select at least one record.

Step to facilitate the 3 states of the buttons:

Client Before.- It has nothing.

Server.- You have the control of whether you have selected any record and if you have not done so, in the "error" variable that passes to the browser carries the error message. If you have selected records, collect all of them and create a list of the invoice IDs by saving the list in the PRINT_RECORDS session variable.

Client After.- Here I have put the post() function that JQuery uses and that it dynamically creates a form with the parameters we need, to send the Print page by post. This does it if in the variable "error" that was created in the Server state, it is empty and if not, use an alert() to display the error message.

On the Print page, we have also encoded the Print_Page event: Before SQL Query by adding a WHERE clause

I leave you the project and a backup of the database, so you can install this example on your Windows PCs.

As always, if you need any details or explanations, please contact me through my email fernandohumanes@gmail.com