add customer fields option with agent, display_custnum, status and name, RT#73721
[freeside.git] / FS / FS / template_content.pm
1 package FS::template_content;
2
3 use strict;
4 use base qw( FS::Record );
5 use FS::Record qw( qsearch qsearchs );
6
7 =head1 NAME
8
9 FS::template_content - Object methods for template_content records
10
11 =head1 SYNOPSIS
12
13   use FS::template_content;
14
15   $record = new FS::template_content \%hash;
16   $record = new FS::template_content { 'column' => 'value' };
17
18   $error = $record->insert;
19
20   $error = $new_record->replace($old_record);
21
22   $error = $record->delete;
23
24   $error = $record->check;
25
26 =head1 DESCRIPTION
27
28 An FS::template_content object represents the content of a message template
29 (subject line and body) for a specific region.  FS::template_content inherits 
30 from FS::Record.  The following fields are currently supported:
31
32 =over 4
33
34 =item contentnum - primary key
35
36 =item msgnum - the L<FS::msg_template> for which this is the content.
37
38 =item locale - locale (such as 'en_US'); can be NULL.
39
40 =item subject - Subject: line of the message, in L<Text::Template> format.
41
42 =item body - Message body, as plain text or HTML, in L<Text::Template> format.
43
44 =back
45
46 =head1 METHODS
47
48 =over 4
49
50 =item new HASHREF
51
52 Creates a new example.  To add the example to the database, see L<"insert">.
53
54 Note that this stores the hash reference, not a distinct copy of the hash it
55 points to.  You can ask the object for a copy with the I<hash> method.
56
57 =cut
58
59 # the new method can be inherited from FS::Record, if a table method is defined
60
61 sub table { 'template_content'; }
62
63 =item insert
64
65 Adds this record to the database.  If there is an error, returns the error,
66 otherwise returns false.
67
68 =cut
69
70 # the insert method can be inherited from FS::Record
71
72 =item delete
73
74 Delete this record from the database.
75
76 =cut
77
78 # the delete method can be inherited from FS::Record
79
80 =item replace OLD_RECORD
81
82 Replaces the OLD_RECORD with this one in the database.  If there is an error,
83 returns the error, otherwise returns false.
84
85 =cut
86
87 # the replace method can be inherited from FS::Record
88
89 =item check
90
91 Checks all fields to make sure this is a valid example.  If there is
92 an error, returns the error, otherwise returns false.  Called by the insert
93 and replace methods.
94
95 =cut
96
97 # the check method should currently be supplied - FS::Record contains some
98 # data checking routines
99
100 sub check {
101   my $self = shift;
102
103   my $error = 
104     $self->ut_numbern('contentnum')
105     || $self->ut_foreign_key('msgnum', 'msg_template', 'msgnum')
106     || $self->ut_textn('locale')
107     || $self->ut_anything('subject')
108     || $self->ut_anything('body')
109   ;
110   return $error if $error;
111
112   $self->SUPER::check;
113 }
114
115 =back
116
117 =head1 SEE ALSO
118
119 L<FS::Record>, schema.html from the base documentation.
120
121 =cut
122
123 1;
124