Sub totals and Page Breaks [message #2392] |
Sat, 16 January 2010 12:38 ![Go to next message Go to next message](/theme/default/images/down.png) |
gpatti
Messages: 283 Registered: August 2008
|
Senior Member |
|
|
Tony,
I'm struggling achieving the desired output with the ListView print_before and print_after methods - can you confirm if the following is possible with existing methods?:
I am producing a listview output for a number of entities, each of which has one or more items belonging to it, containing an amount.
I want to produce a separate page for each entiy and have a subtotal for each entity at the bottom of each page.
The page break is easy, but I can't get the subtotal to appear with the correct entity at the same time as it needs to go in the print_before method with the page break. Therefore, the total always goes at the top of the next page.
How can I achieve this?
Thanks,
Graham
|
|
|
|
|
Re: Sub totals and Page Breaks [message #2395 is a reply to message #2394] |
Sun, 17 January 2010 03:19 ![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 |
|
|
I have played around with some test data in the EXAMPLE subsystem to see if I can achieve the result you desire. The only way I could do this was to modify the _cm_ListView_print_after() method to include a second argument for $next_row. My 'before' and 'after' methods are as follows:
// ****************************************************************************
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)) {
// first character of last name has changed
$this->pdf->AddPage();
} // if
} // if
return $output;
} // _cm_ListView_print_before
// ****************************************************************************
function _cm_ListView_print_after ($curr_row, $next_row)
// allow extra rows to be created in List View
{
$output = array();
if (substr($next_row['last_name'], 0, 1) != substr($curr_row['last_name'], 0, 1)) {
// first character of last name has changed
$output[0]['pers_type_desc'] = 'after ' .$curr_row['person_id'];
} // if
return $output;
} // _cm_ListView_print_after
Attached are the framework scripts which I have modified. Try them out and let me know if they solve your problem.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
|
|
|
|
|
|
|
Re: Sub totals and Page Breaks [message #2404 is a reply to message #2392] |
Sun, 17 January 2010 12:19 ![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 |
|
|
This is giving strange results. I am now seeing the entity id as NULL in some cases, an id in some cases and a value representation in others.
I will need to debug in detail to see what is happening where.
Hold this - just spotted your later post!
[Updated on: Sun, 17 January 2010 12:20] Report message to a moderator
|
|
|
|
|
|
|