summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FS/FS.pm4
-rw-r--r--FS/FS/AccessRight.pm3
-rw-r--r--FS/FS/Schema.pm14
-rw-r--r--FS/FS/msg_template.pm144
-rw-r--r--FS/MANIFEST2
-rw-r--r--FS/t/msg_template.t5
-rw-r--r--httemplate/browse/msg_template.html27
-rw-r--r--httemplate/edit/msg_template.html16
-rw-r--r--httemplate/edit/process/msg_template.html12
-rw-r--r--httemplate/elements/menu.html5
-rw-r--r--httemplate/elements/tr-htmlarea.html25
11 files changed, 255 insertions, 2 deletions
diff --git a/FS/FS.pm b/FS/FS.pm
index abeb14074..8613c71f0 100644
--- a/FS/FS.pm
+++ b/FS/FS.pm
@@ -350,7 +350,9 @@ L<FS::queue_arg> - Job arguments
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>
diff --git a/FS/FS/AccessRight.pm b/FS/FS/AccessRight.pm
index 1e1b9ead3..9e79754d3 100644
--- a/FS/FS/AccessRight.pm
+++ b/FS/FS/AccessRight.pm
@@ -288,6 +288,9 @@ tie my %rights, 'Tie::IxHash',
'Edit billing events',
{ rightname=>'Edit global billing events', global=>1 },
+ 'Edit templates',
+ { rightname=>'Edit global templates', global=>1 },
+
'Edit inventory',
{ rightname=>'Edit global inventory', global=>1 },
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index f113146ca..7c30b4331 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -2906,6 +2906,20 @@ sub tables_hashref {
'index' => [ [ 'billbatchnum' ], [ 'optionname' ] ],
},
+ '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
diff --git a/FS/FS/msg_template.pm b/FS/FS/msg_template.pm
new file mode 100644
index 000000000..7bf050441
--- /dev/null
+++ b/FS/FS/msg_template.pm
@@ -0,0 +1,144 @@
+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;
+
diff --git a/FS/MANIFEST b/FS/MANIFEST
index 03d56ac58..f2c3362ab 100644
--- a/FS/MANIFEST
+++ b/FS/MANIFEST
@@ -520,3 +520,5 @@ FS/cgp_rule_condition.pm
t/cgp_rule_condition.t
FS/cgp_rule_action.pm
t/cgp_rule_action.t
+FS/msg_template.pm
+t/msg_template.t
diff --git a/FS/t/msg_template.t b/FS/t/msg_template.t
new file mode 100644
index 000000000..cec1d41af
--- /dev/null
+++ b/FS/t/msg_template.t
@@ -0,0 +1,5 @@
+BEGIN { $| = 1; print "1..1\n" }
+END {print "not ok 1\n" unless $loaded;}
+use FS::msg_template;
+$loaded=1;
+print "ok 1\n";
diff --git a/httemplate/browse/msg_template.html b/httemplate/browse/msg_template.html
new file mode 100644
index 000000000..331906ccf
--- /dev/null
+++ b/httemplate/browse/msg_template.html
@@ -0,0 +1,27 @@
+<% 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>
diff --git a/httemplate/edit/msg_template.html b/httemplate/edit/msg_template.html
new file mode 100644
index 000000000..6632d027a
--- /dev/null
+++ b/httemplate/edit/msg_template.html
@@ -0,0 +1,16 @@
+<% 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>
diff --git a/httemplate/edit/process/msg_template.html b/httemplate/edit/process/msg_template.html
new file mode 100644
index 000000000..5cf88bfad
--- /dev/null
+++ b/httemplate/edit/process/msg_template.html
@@ -0,0 +1,12 @@
+<% 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>
diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html
index ef105b1d6..190455772 100644
--- a/httemplate/elements/menu.html
+++ b/httemplate/elements/menu.html
@@ -472,12 +472,15 @@ tie my %config_phone, 'Tie::IxHash',
;
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.' ]
if $curuser->access_right('Edit advertising sources')
|| $curuser->access_right('Edit global advertising sources');
if ( $curuser->access_right('Configuration') ) {
$config_misc{'Virtual fields'} = [ $fsurl.'browse/part_virtual_field.cgi', 'Locally defined fields', ];
- $config_misc{'Message catalog'} = [ $fsurl.'browse/msgcat.cgi', 'Change error messages and other customizable labels' ];
+ $config_misc{'Error catalog'} = [ $fsurl.'browse/msgcat.cgi', 'Change error messages and other customizable labels' ];
}
$config_misc{'Inventory classes and inventory'} = [ $fsurl.'browse/inventory_class.html', 'Setup inventory classes and stock inventory' ]
if $curuser->access_right('Edit inventory')
diff --git a/httemplate/elements/tr-htmlarea.html b/httemplate/elements/tr-htmlarea.html
new file mode 100644
index 000000000..1a4e25080
--- /dev/null
+++ b/httemplate/elements/tr-htmlarea.html
@@ -0,0 +1,25 @@
+<% 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>