% include( '/elements/header.html', 'Developer Documentation' ) %> <& /elements/menubar.html, 'Freeside Perl Modules' => $fsurl.'docs/library/FS.html', 'Complete Index' => $fsurl.'docs/library/index.html', &>
FS::msg_template - Object methods for msg_template records
use FS::msg_template;
$record = new FS::msg_template \%hash;
$record = new FS::msg_template { 'column' => 'value' };
$error = $record->insert;
$error = $new_record->replace($old_record);
$error = $record->delete;
$error = $record->check;
This uses a table-per-subclass ORM strategy, which is a somewhat cleaner version of what we do elsewhere with _option tables. We could easily extract that functionality into a base class, or even into FS::Record itself.
An FS::msg_template object represents a customer message template. FS::msg_template inherits from FS::Record. The following fields are currently supported:
Creates a new template. To add the template to the database, see "insert".
Note that this stores the hash reference, not a distinct copy of the hash it points to. You can ask the object for a copy with the hash method.
Adds this record to the database. If there is an error, returns the error, otherwise returns false.
Delete this record from the database.
Replaces the OLD_RECORD with this one in the database. If there is an error, returns the error, otherwise returns false.
Checks all fields to make sure this is a valid template. If there is an error, returns the error, otherwise returns false. Called by the insert and replace methods.
Fills in the template and returns an FS::cust_msg object, containing the message to be sent. This method must be provided by the subclass.
Options are passed as a list of name/value pairs:
Customer object
Additional context object (currently, can be a cust_main, cust_pkg, cust_bill, cust_pay, cust_pay_pending, or svc_(acct, phone, broadband, domain) ). If the object is a svc_*, its cust_pkg will be fetched and used for substitution.
As a special case, this may be an arrayref of two objects. Both objects will be available for substitution, with their field names prefixed with 'new_' and 'old_' respectively. This is used in the rt_ticket export when exporting "replace" events.
Configuration option to use as the source address, based on the customer's agentnum. If unspecified (or the named option is empty), 'invoice_from' will be used.
The from_addr field in the template takes precedence over this.
Destination address. The default is to use the customer's invoicing_list addresses. Multiple addresses may be comma-separated.
A hash reference of additional substitutions
Takes the same arguments as "prepare", and returns a hashref of the substitution variables.
Creates a message with "prepare" (taking all the same options) and sends it.
Fills in the template and renders it to a PDF document. Returns the name of the PDF file.
Options are as for 'prepare', but 'from' and 'to' are meaningless.
Render a PDF and send it to the printer. OPTIONS are as for 'render'.
Stub, returns nothing.
Returns the FS::agent object for this template.
FS::Record, schema.html from the base documentation.