Access to invoice object from within invoice template (now 1.4.0pre13) (fwd)

baloo at gimpgirl.com baloo at gimpgirl.com
Sat May 25 06:27:45 PDT 2002


This appears still applicable for pre13. Unless someone pipes up and tells
me why it would be a Bad Thing, I'll probably implement it and toss in
documentation for the template argument to print_text, and perhaps a few
things that appear to be incomplete implementation of that argument.

---------- Forwarded message ----------
Date: Fri, 10 May 2002 10:14:41 -0700 (PDT)
From: baloo at gimpgirl.com
To: ivan-freeside at sisd.com
Subject: Access to invoice object from within invoice template (1.4.0pre11)

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