List View page break after additional rows [message #2297] |
Mon, 07 September 2009 11:20 ![Go to next message Go to next message](/theme/default/images/down.png) |
gpatti
Messages: 283 Registered: August 2008
|
Senior Member |
|
|
Got a tricky problem with forcing a page break at the correct place:
I'm creating a LIST report of people with contact information. I am printing Name and basic information and then want to print the address and other contact info over multiple lines.
I'm using _cm_ListView_pre_print() to construct the additional lines, which are printed after the main line. I'm doing this by taking the data from $prev_row.
The basic report works great. Now, I want to force a page break when the surname initial letter changes alphabetically. The problem is that the page break occurs BEFORE the contact details of the $prev_row are printed.
I need the ability to force the page break after the additional rows are printed, but before $curr_row is printed.
Can you think of a way to solve this?
Thanks,
Graham
|
|
|
Re: List View page break after additional rows [message #2298 is a reply to message #2297] |
Mon, 07 September 2009 18:52 ![Go to previous message Go to previous message](/theme/default/images/up.png) ![Go to next message Go to next message](/theme/default/images/down.png) |
AJM
Messages: 2361 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
The only way I can do this is to replace the _cm_ListView_pre_print() method with two alternative methods - _cm_ListView_print_before() and _cm_ListView_print_after(). See the attached file.
Here are some examples of both methods in use:
function _cm_ListView_print_before ($prev_row, $curr_row)
// allow extra rows to be created in List View
{
$output = array();
if (!empty($prev_row)) {
// row has changed
if (substr($prev_row['last_name'], 0, 1) != substr($curr_row['last_name'], 0, 1)) {
$this->pdf->AddPage();
} // if
} // if
$output[0]['pers_type_desc'] = 'before ' .$curr_row['person_id'];
return $output;
} // _cm_ListView_print_before
// ****************************************************************************
function _cm_ListView_print_after ($curr_row)
// allow extra rows to be created in List View
{
$output = array();
$output[0]['pers_type_desc'] = 'after ' .$curr_row['person_id'];
return $output;
} // _cm_ListView_print_after
As you can see this allows _cm_ListView_print_before() to call $this->pdf->AddPage() when the first character of the surname/last_name field changes.
NOTE: if your table class contains the old _cm_ListView_pre_print() method then this will be called in preference to the two new methods, so any code which uses the old method will still work and the new methods will not be called.
Try it out and tell me if it does what you want.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
Re: List View page break after additional rows [message #2299 is a reply to message #2297] |
Tue, 08 September 2009 05:00 ![Go to previous message Go to previous message](/theme/default/images/up.png) ![Go to next message Go to next message](/theme/default/images/down.png) |
gpatti
Messages: 283 Registered: August 2008
|
Senior Member |
|
|
I'm getting an error
Fatal error: Call to undefined function convertTZdate() in C:\xampp\includes\std.pdf.class.inc on line 1426
Do I need to upgrade to 1.51 to avoid this?
In the meantime I have removed the timezone from the user account to bypass the date conversion and the before and after functionality works perfectly. Thanks.
Graham
[Updated on: Tue, 08 September 2009 05:12] Report message to a moderator
|
|
|
|
|
|
|
Re: List View page break after additional rows [message #2304 is a reply to message #2301] |
Tue, 08 September 2009 14:24 ![Go to previous message Go to previous message](/theme/default/images/up.png) ![Go to next message Go to next message](/theme/default/images/down.png) |
AJM
Messages: 2361 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
gpatti wrote on Tue, 08 September 2009 10:43 | In addition to the split of before and afer printing I'd like to suggest an enhancement for the future - to be able (optionally?) to force lines printed before/after $curr_row to be grouped such that a page break does not split them, so they are always printed with their associated row. Do you think this might be feasible?
|
Attached is a new version of 'std.pdf.class.inc' which includes a new function which will return the number of lines remaining on the current page:
$lines_left = $this->pdf->getLinesRemaining();
You can use this to compare against the number of lines required so that you can issue a call to $this->pdf->AddPage() in order to start a new page.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
|
|
|
|