Access to invoice object from within invoice template (1.4.0pre11)

baloo at gimpgirl.com baloo at gimpgirl.com
Fri May 10 10:14:46 PDT 2002


If I interpret the doc correctly, I can gain access to the FS::cust_bill
object for the invoice being printed (eg, to print the customer ID) using
FS::Record->qsearchs('cust_bill', {'invnum' => $invnum}). That, however,
can get both tedious and wasteful of processor time if I use it a lot,
as it presumably goes to the database each time. (Not to mention that it
may actually create a duplicate of an already existing object - I haven't
looked that closely at the source, and I'm not sure I could tell even if
I had.)

Since it's already accessible, I don't think assigning a template variable
to it would open any security hole. The required changes would be in
FS::cust_bill::print_text and in the billing verbage about the available
variables in docs/billing.html (which, BTW, doesn't mention $overdue -
diff -u available if this is an oversight). As, reading between the lines
of the pre12 announcement, there's been some changes in that method, I
won't submit a patch unless and until I have a look at pre12 beyond the
web demo when it gets there (not very high on my list of freeside things
to do ATM unless I decide I need the new template stuff) or someone tells
me it didn't change that much from pre11. It looks (in pre11) like all
that's needed is to insert something like:

  $FS::cust_bill::_template::cust_bill = $self;

just above the fill_in loop at the end of the method.

Comments and clues gratefully accepted;




More information about the freeside-users mailing list