<% 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

NAME

FS::msg_template - Object methods for msg_template records

SYNOPSIS

  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;

DESCRIPTION

An FS::msg_template object represents a customer message template. FS::msg_template inherits from FS::Record. The following fields are currently supported:

msgnum - primary key
msgname - Name of the template. This will appear in the user interface; if it needs to be localized for some users, add it to the message catalog.
agentnum - Agent associated with this template. Can be NULL for a global template.
mime_type - MIME type. Defaults to text/html.
from_addr - Source email address.
disabled - disabled ('Y' or NULL).

METHODS

new HASHREF

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.

insert [ CONTENT ]

Adds this record to the database. If there is an error, returns the error, otherwise returns false.

A default (no locale) FS::template_content object will be created. CONTENT is an optional hash containing 'subject' and 'body' for this object.

delete

Delete this record from the database.

replace [ OLD_RECORD ] [ CONTENT ]

Replaces the OLD_RECORD with this one in the database. If there is an error, returns the error, otherwise returns false.

CONTENT is an optional hash containing 'subject', 'body', and 'locale'. If supplied, an FS::template_content object will be created (or modified, if one already exists for this locale).

check

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.

content_locales

Returns a hashref of the FS::template_content objects attached to this template, with the locale as key.

prepare OPTION => VALUE

Fills in the template and returns a hash of the 'from' address, 'to' addresses, subject line, and body.

Options are passed as a list of name/value pairs:

cust_main

Customer object (optional)

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.

from_config

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.

to

Destination address. The default is to use the customer's invoicing_list addresses. Multiple addresses may be comma-separated.

substitutions

A hash reference of additional substitutions

send OPTION => VALUE

Fills in the template and sends it to the customer. Options are as for 'prepare', plus 'attach', a MIME::Entity (or arrayref of them) to attach to the message.

render OPTION => VALUE ...

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.

print OPTIONS

Render a PDF and send it to the printer. OPTIONS are as for 'render'.

content LOCALE

Returns the FS::template_content object appropriate to LOCALE, if there is one. If not, returns the one with a NULL locale.

agent

Returns the FS::agent object for this template.

BUGS

SEE ALSO

FS::Record, schema.html from the base documentation.

<% include ('/elements/footer.html' ) %>