[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Could anyone help us understand batch printing for AR Aging in 1.2.x?



Hello,

We have been struggling for some time to make customer statements & AR Aging print in batches.  The behavior we observed in stock LSMB 1.2.x was that when we went to AR->Reports->AR Aging, and selected a number of customers on the list, the function would print only the first one.  Further research uncovered the following in rp.pl:

----------------------------------------------
sub print {

    if ( $form->{media} !~ /(screen|email)/ ) {
        $form->error( $locale->text('Select postscript or PDF!') )
          if ( $form->{format} !~ /(postscript|pdf)/ );
    }

    for $i ( 1 .. $form->{rowcount} ) {
        if ( $form->{"statement_$i"} ) {
            $form->{"$form->{ct}_id"} = $form->{"$form->{ct}_id_$i"};
            $language_code            = $form->{"language_code_$i"};
            $curr                     = $form->{"curr_$i"};
            $selected                 = 1;
            last;
        }
    }
...
----------------------------------------------

That "last" statement at the end exits the loop after the first selection, hence our problem.  However, if we remove the "last" statement, then it prints only the last statement on the list, rather than the first.  We are calling the print functions and parse_template once per loop, but apparently parse_template is getting piled up (or something) and is unable to complete a series of calls to the printer (?) in quick succession.  We even tried calling sleep() to put a mandatory pause in the process, but with no effect except slowing down the same undesired behavior.  The behavior is not solely related to the printer either, however - when we try to print PDF to screen, we get the same result: one download, not several, only the last one gets created.  When we disable the Form::cleanup function, however, we find all of our PDF files waiting in /tmp directory, they just do not make it to the final step of being sent to the browser or the printer.


We next went into rp.pl from LSMB 1.3, and found that the problem had apparently been addressed, by the following means:

   $printhash = &print_form;     
   push @batch_data, $printhash;

and then later,

    try {
        $template->render({data ="" \@batch_data});
        $template->output($form);
    }

However, this approach seems to be dependent on the fancy new 1.3 templates system, and we lack the resources to port our whole project to 1.3 at the moment... 

SO, my question is, within the context of LSMB 1.2.x, does the preceding description sound familiar to anyone or are there any pointers anyone can give us as to where we should look or how we might proceed?

Oh, and another related question is: how does any of this relate to the actual "batch printing" (bp.pl) part of LSMB, using the print spool, which seems to be called only from Queue Invoices and other similar lists - and why does the AR Aging list not call bp.pl to do its batch printing? 

Sincere apologies for not understanding anything here that should be obvious.


Many thanks,

Chris Calef
Think-Electric