summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FS/FS/cust_main.pm11
-rw-r--r--FS/FS/msg_template.pm4
-rw-r--r--FS/FS/part_event/Action/notice.pm47
-rw-r--r--httemplate/edit/elements/edit.html5
-rw-r--r--httemplate/edit/msg_template.html8
-rw-r--r--httemplate/elements/htmlarea.html3
6 files changed, 73 insertions, 5 deletions
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 1f69bd1ca..0578a97ef 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -2464,6 +2464,17 @@ sub agent {
qsearchs( 'agent', { 'agentnum' => $self->agentnum } );
}
+=item agent_name
+
+Returns the agent name (see L<FS::agent>) for this customer.
+
+=cut
+
+sub agent_name {
+ my $self = shift;
+ $self->agent->agent;
+}
+
=item cust_class
Returns the customer class, as an FS::cust_class object, or the empty string
diff --git a/FS/FS/msg_template.pm b/FS/FS/msg_template.pm
index 83acde245..97cf50fe7 100644
--- a/FS/FS/msg_template.pm
+++ b/FS/FS/msg_template.pm
@@ -166,15 +166,11 @@ sub send {
my $subs = $self->substitutions;
- use Data::Dumper;
- warn Dumper($subs);
-
#XXX html escape this stuff
my %hash = map { $_ => $cust_main->$_() } @{ $subs->{'cust_main'} };
unless ( ! $object || $object->table eq 'cust_main' ) {
%hash = ( %hash, map { $_ => $object->$_() } @{ $subs->{$object->table} } );
}
- warn Dumper(\%hash);
my $subject_tmpl = new Text::Template (
TYPE => 'STRING',
diff --git a/FS/FS/part_event/Action/notice.pm b/FS/FS/part_event/Action/notice.pm
new file mode 100644
index 000000000..126965374
--- /dev/null
+++ b/FS/FS/part_event/Action/notice.pm
@@ -0,0 +1,47 @@
+package FS::part_event::Action::notice;
+
+use strict;
+use base qw( FS::part_event::Action );
+use FS::Record qw( qsearchs );
+use FS::msg_template;
+
+sub description { 'Send a notice from a message template'; }
+
+#sub eventtable_hashref {
+# { 'cust_main' => 1,
+# 'cust_bill' => 1,
+# 'cust_pkg' => 1,
+# };
+#}
+
+sub option_fields {
+ (
+ 'msgnum' => { 'label' => 'Template',
+ 'type' => 'select-table',
+ 'table' => 'msg_template',
+ 'name_col' => 'msgname',
+ 'disable_empty' => 1,
+ },
+ );
+}
+
+sub default_weight { 55; } #?
+
+sub do_action {
+ my( $self, $object ) = @_;
+
+ my $cust_main = $self->cust_main($object);
+
+ my $msgnum = $self->option('msgnum');
+
+ my $msg_template = qsearchs('msg_template', { 'msgnum' => $msgnum } )
+ or die "Template $msgnum not found";
+
+ $msg_template->send(
+ 'cust_main' => $cust_main,
+ 'object' => $object,
+ );
+
+}
+
+1;
diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html
index 0b5ca1737..b19b3618c 100644
--- a/httemplate/edit/elements/edit.html
+++ b/httemplate/edit/elements/edit.html
@@ -307,6 +307,11 @@ Example:
% foreach grep exists($f->{$_}),
% qw( hashref agent_virt agent_null agent_null_right );
%
+% #htmlarea
+% $include_common{$_} = $f->{$_}
+% foreach grep exists($f->{$_}), qw( width height );
+%
+%
% if ( $type eq 'tablebreak-tr-title' ) {
% $include_common{'table_id'} = 'TableNumber'. $tablenum++;
% }
diff --git a/httemplate/edit/msg_template.html b/httemplate/edit/msg_template.html
index 6632d027a..68725e243 100644
--- a/httemplate/edit/msg_template.html
+++ b/httemplate/edit/msg_template.html
@@ -3,8 +3,14 @@
'table' => 'msg_template',
'viewall_dir' => 'browse',
'fields' => [ 'msgname',
- { field=>'body', type=>'htmlarea' },
+ 'subject',
+ { field=>'body', type=>'htmlarea', width=>763 },
],
+ 'labels' => { 'msgnum' => 'Template',
+ 'msgname' => 'Template name',
+ 'subject' => 'Message subject',
+ 'body' => 'Message template',
+ },
)
%>
<%init>
diff --git a/httemplate/elements/htmlarea.html b/httemplate/elements/htmlarea.html
index dca4328ab..f00c77360 100644
--- a/httemplate/elements/htmlarea.html
+++ b/httemplate/elements/htmlarea.html
@@ -22,6 +22,9 @@ Example:
oFCKeditor.BasePath = '<% $p %>elements/fckeditor/';
oFCKeditor.Config['SkinPath'] = '<% $p %>elements/fckeditor/editor/skins/silver/';
+% if ( $opt{'width'} ) {
+ oFCKeditor.Width = '<% $opt{'width'} %>';
+% }
oFCKeditor.Height = '<% $opt{'height'} || 420 %>';
oFCKeditor.Config['StartupFocus'] = true;
oFCKeditor.Config['EnterMode'] = 'br';