This topic is locked

PDF Issues - PDF View Button Disappears

12/6/2017 4:52:53 PM
PHPRunner General questions
K
kelgate author

Apologies in advance if the following are real noob questions...
I have an application built with PHPR 9.8 here: http://demo.asprunner.net/accounts_azpire_co_uk/hsp_lite_0_4

U: admin

P: admin
Customers have Contracts and there are Invoices and Visits associated with each Contract. Visits also have Appointment Letters.
I am trying to view Letters and Invoices as PDFs so that they can be printed and saved from the application (the client does not want to do Word mail merges).
I can open list pages for Customer Letters and Customer Invoices from the top-level menu and if I then view a letter or an invoice from either of these lists there is a PDF View button presented at the top of the page.
Issue 1 - PDFs for Customer Letters are created OK, but for Invoices the PDF Build never completes.
There are also copies of the above list pages when you expand a Customer list record.
Issue 2 - The View pages for Customer Letters and Customer Invoices do not show any PDF View buttons.
If you expand a Contract record and open the Visit tab, you will see a button labelled "PDF" at the end of each visit record. This is because PDF View buttons were not appearing for the Appointment Letter views under expanded Visit records and I was attempting a work around with Dompdf.
The test On Server code within these buttons is very basic and was taken from a Dompdf site and is as follows:

require_once 'plugins/dompdf/include/autoload.inc.php';

// reference the Dompdf namespace

use Dompdf\Dompdf;
// instantiate and use the dompdf class

$dompdf = new Dompdf();

$dompdf->loadHtml('<h1>DOMPDF Demo</h1>
<p>Hello World !</p>');
// (Optional) Setup the paper size and orientation

$dompdf->setPaper('A4', 'portrait');
// Render the HTML as PDF

$dompdf->render();
// Output the generated PDF to Browser

$dompdf->stream();
** Issue 3 - I get "Parse error: syntax error, unexpected 'use' (T_USE) in C:\UserAccounts\www\accounts_azpire_co_uk\hsp_lite_0_4_20171206043246\buttonhandler.php on line 77".
These issues are causing dents in my desk because I've been running around in ever decreasing cirles, so any advice would be very much appreciated.
Many, many thanks.
Kelvin
PS - The PHPR Invoice template is great, but it won't address my need for all of the types of output my client requires.

Cheers.

admin 12/6/2017

Check this:

https://stackoverflow.com/questions/18227439/use-php-namespace-inside-function
"use" keyword should be outside of any functions. You cannot use it in button's server code. Use built-in PDF export functionality.

K
kelgate author 12/7/2017



Check this:

https://stackoverflow.com/questions/18227439/use-php-namespace-inside-function
"use" keyword should be outside of any functions. You cannot use it in button's server code. Use built-in PDF export functionality.


OK - thanks. That reply addresses Issue 3.
Unfortunately, issue 3 arose because of Issue 2 - the disappearance of PDF View buttons from any list pages that are not accessed directly from the top-level menu. This is important because the client needs to view those letters and invoices directly associated with visits (appointments) and contracts rather than having to trawl through all of the documents ever produced by the application.
And Issue 1 is still outstanding and this uses the built-in PDF export functionality!