L<FS::queue_depend> - Job dependencies
-L<FS::msgcat> - Message catalogs
+L<FS::msg_template> - Message templates (customer notices)
+
+L<FS::msgcat> - Message catalogs (error messages)
L<FS::clientapi_session>
'Edit billing events',
{ rightname=>'Edit global billing events', global=>1 },
-
+
+ 'Edit templates',
+ { rightname=>'Edit global templates', global=>1 },
+
{ rightname=>'Dialup configuration' },
{ rightname=>'Dialup global configuration', global=>1 },
'index' => [['listnum'],['svcnum'],['email']],
},
+ 'msg_template' => {
+ 'columns' => [
+ 'msgnum', 'serial', '', '', '', '',
+ 'msgname', 'varchar', '', $char_d, '', '',
+ 'agentnum', 'int', 'NULL', '', '', '',
+ 'mime_type', 'varchar', '', $char_d, '', '',
+ 'body', 'blob', 'NULL', '', '', '',
+ 'disabled', 'char', 'NULL', 1, '', '',
+ ],
+ 'primary_key' => 'msgnum',
+ 'unique' => [ ['msgname', 'mime_type'] ],
+ 'index' => [ ['agentnum'], ]
+ },
+
# name type nullability length default local
--- /dev/null
+package FS::msg_template;
+
+use strict;
+use base qw( FS::Record );
+use FS::Record qw( qsearch qsearchs );
+
+=head1 NAME
+
+FS::msg_template - Object methods for msg_template records
+
+=head1 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;
+
+=head1 DESCRIPTION
+
+An FS::msg_template object represents a customer message template.
+FS::msg_template inherits from FS::Record. The following fields are currently
+supported:
+
+=over 4
+
+=item msgnum
+
+primary key
+
+=item msgname
+
+msgname
+
+=item agentnum
+
+agentnum
+
+=item mime_type
+
+mime_type
+
+=item body
+
+body
+
+=item disabled
+
+disabled
+
+
+=back
+
+=head1 METHODS
+
+=over 4
+
+=item new HASHREF
+
+Creates a new template. To add the template to the database, see L<"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 I<hash> method.
+
+=cut
+
+# the new method can be inherited from FS::Record, if a table method is defined
+
+sub table { 'msg_template'; }
+
+=item insert
+
+Adds this record to the database. If there is an error, returns the error,
+otherwise returns false.
+
+=cut
+
+# the insert method can be inherited from FS::Record
+
+=item delete
+
+Delete this record from the database.
+
+=cut
+
+# the delete method can be inherited from FS::Record
+
+=item replace OLD_RECORD
+
+Replaces the OLD_RECORD with this one in the database. If there is an error,
+returns the error, otherwise returns false.
+
+=cut
+
+# the replace method can be inherited from FS::Record
+
+=item 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.
+
+=cut
+
+# the check method should currently be supplied - FS::Record contains some
+# data checking routines
+
+sub check {
+ my $self = shift;
+
+ my $error =
+ $self->ut_numbern('msgnum')
+ || $self->ut_text('msgname')
+ || $self->ut_foreign_keyn('agentnum', 'agent', 'agentnum')
+ || $self->ut_textn('mime_type')
+ || $self->ut_anything('body')
+ || $self->ut_enum('disabled', [ '', 'Y' ] )
+ ;
+ return $error if $error;
+
+ $self->mime_type('text/html') unless $self->mime_type;
+
+ $self->SUPER::check;
+}
+
+=back
+
+=head1 BUGS
+
+=head1 SEE ALSO
+
+L<FS::Record>, schema.html from the base documentation.
+
+=cut
+
+1;
+
t/cgp_rule_condition.t
FS/cgp_rule_action.pm
t/cgp_rule_action.t
+FS/msg_template.pm
+t/msg_template.t
--- /dev/null
+BEGIN { $| = 1; print "1..1\n" }
+END {print "not ok 1\n" unless $loaded;}
+use FS::msg_template;
+$loaded=1;
+print "ok 1\n";
--- /dev/null
+<% include( 'elements/browse.html',
+ 'title' => 'Message templates',
+ 'name_singular' => 'template',
+ 'menubar' => [ 'Add a new template' =>
+ $p.'edit/msg_template.html',
+ ],
+ 'query' => { 'table' => 'msg_template', },
+ 'count_query' => 'SELECT COUNT(*) FROM msg_template',
+ 'disableable' => 1,
+ 'disabled_statuspos' => 2,
+ 'agent_virt' => 1,
+ 'agent_null_right' => 'Edit global templates',
+ 'agent_pos' => 3,
+ 'header' => [ 'Name' ],
+ 'fields' => [ 'msgname' ],
+ 'links' => [ $link ],
+ )
+%>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Edit templates')
+ || $FS::CurrentUser::CurrentUser->access_right('Edit global templates');
+
+my $link = [ "${p}edit/msg_template.html?", 'msgnum' ];
+
+</%init>
--- /dev/null
+<% include( 'elements/edit.html',
+ 'name_singular' => 'template',
+ 'table' => 'msg_template',
+ 'viewall_dir' => 'browse',
+ 'fields' => [ 'msgname',
+ { field=>'body', type=>'htmlarea' },
+ ],
+ )
+%>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Edit templates')
+ || $FS::CurrentUser::CurrentUser->access_right('Edit global templates');
+
+</%init>
--- /dev/null
+<% include( 'elements/process.html',
+ 'table' => 'msg_template',
+ 'viewall_dir' => 'browse',
+ )
+%>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Edit templates')
+ || $FS::CurrentUser::CurrentUser->access_right('Edit global templates');
+
+</%init>
;
tie my %config_misc, 'Tie::IxHash';
+$config_misc{'Message templates'} = [ $fsurl.'browse/msg_template.html', 'Templates for customer notices' ]
+ if $curuser->access_right('Edit templates')
+ || $curuser->access_right('Edit global templates');
$config_misc{'Advertising sources'} = [ $fsurl.'browse/part_referral.html', 'Where a customer heard about your service. Tracked for informational purposes' ]
if $curuser->access_right('Edit advertising sources')
|| $curuser->access_right('Edit global advertising sources');
--- /dev/null
+<% include('tr-td-label.html', @_ ) %>
+
+ <TD <% $cell_style %>>
+
+ <% include('htmlarea.html', @_ ) %>
+
+ </TD>
+
+</TR>
+
+<%init>
+
+my %opt = @_;
+
+my $onchange = $opt{'onchange'}
+ ? 'onChange="'. $opt{'onchange'}. '(this)"'
+ : '';
+
+#my $rows = $opt{'rows'} ? 'ROWS="'.$opt{'rows'}.'"' : '';
+#my $cols = $opt{'cols'} ? 'COLS="'.$opt{'cols'}.'"' : '';
+
+my $cell_style = $opt{'cell_style'} ? 'STYLE="'. $opt{'cell_style'}. '"' : '';
+#my $curr_value = $opt{'curr_value'};
+
+</%init>