Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE » How To » List View page break after additional rows
List View page break after additional rows [message #2297] Mon, 07 September 2009 11:20 Go to next message
gpatti is currently offline  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 messageGo to next message
AJM is currently offline  AJM
Messages: 2371
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.


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 messageGo to next message
gpatti is currently offline  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 #2300 is a reply to message #2299] Tue, 08 September 2009 05:17 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
gpatti wrote on Tue, 08 September 2009 10:00

Do I need to upgrade to 1.51 to avoid this?

Yes. Any updated files I supply are always based on the latest version.


Re: List View page break after additional rows [message #2301 is a reply to message #2297] Tue, 08 September 2009 05:43 Go to previous messageGo to next message
gpatti is currently offline  gpatti
Messages: 283
Registered: August 2008
Senior Member
Thanks.

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?
Re: List View page break after additional rows [message #2302 is a reply to message #2297] Tue, 08 September 2009 08:41 Go to previous messageGo to next message
gpatti is currently offline  gpatti
Messages: 283
Registered: August 2008
Senior Member
Tony,

I've moved everyting to v1.51 but I still get the same error message. It seems there is a function convertTZ() in include.general.inc but std.pdf.class.inc is trying to call convertTZdate()
Re: List View page break after additional rows [message #2303 is a reply to message #2302] Tue, 08 September 2009 12:44 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
gpatti wrote on Tue, 08 September 2009 13:41

I've moved everyting to v1.51 but I still get the same error message. It seems there is a function convertTZ() in include.general.inc but std.pdf.class.inc is trying to call convertTZdate()

Whoops! My mistake Embarassed I'd forgotten that I'd updated include.general.inc AFTER I had released version 1.51, so attached is an up-to-date copy.


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 messageGo to next message
AJM is currently offline  AJM
Messages: 2371
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.


Re: List View page break after additional rows [message #2305 is a reply to message #2297] Tue, 08 September 2009 14:26 Go to previous messageGo to next message
gpatti is currently offline  gpatti
Messages: 283
Registered: August 2008
Senior Member
That still seems to be the same version of include.general.inc Tony.
Re: List View page break after additional rows [message #2306 is a reply to message #2305] Tue, 08 September 2009 19:48 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
Trust me to look in the wrong directory! Try the attached version.

Re: List View page break after additional rows [message #2307 is a reply to message #2297] Wed, 09 September 2009 05:26 Go to previous messageGo to next message
gpatti is currently offline  gpatti
Messages: 283
Registered: August 2008
Senior Member
Thanks Tony.

Everything works as required now with all the new functions.

Graham
Re: List View page break after additional rows [message #2316 is a reply to message #2297] Tue, 29 September 2009 06:24 Go to previous messageGo to next message
gpatti is currently offline  gpatti
Messages: 283
Registered: August 2008
Senior Member
Tony,

Have noticed that my LIST reports now seem to have an extra blank line printed at the end of the report (last page only).

I'm guessing that may have been introduced with these recent changes. Is not a major issue, but maybe something you want to take a look at.

Graham
Re: List View page break after additional rows [message #2317 is a reply to message #2316] Tue, 29 September 2009 07:02 Go to previous message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
I have already spotted this, and it will be fixed in the next release (which is due in a few day's time).

Previous Topic: curr_or_hist='C' and output2
Next Topic: Maximum Query Execution Time
Goto Forum:
  


Current Time: Thu Nov 28 17:58:26 EST 2024

Total time taken to generate the page: 0.01588 seconds