summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorivan <ivan>2008-06-17 03:35:56 +0000
committerivan <ivan>2008-06-17 03:35:56 +0000
commit7153190ee1bfeb6d3ad9e6da270a41a949333a7e (patch)
tree4f3f13115ed182e1d219c136f559eb2fa04a1183 /httemplate
parent97c8cbe1a7645ecce1192a1c3c20807e428f907c (diff)
finish adding a feature to easily list all email addresses for an agent & send them email
Diffstat (limited to 'httemplate')
-rw-r--r--httemplate/edit/invoice_template.html23
-rw-r--r--httemplate/elements/htmlarea.html36
-rw-r--r--httemplate/misc/email-customers.html145
-rw-r--r--httemplate/misc/process/email-customers.html9
-rwxr-xr-xhttemplate/search/cust_main.html25
5 files changed, 216 insertions, 22 deletions
diff --git a/httemplate/edit/invoice_template.html b/httemplate/edit/invoice_template.html
index 851ab5ecf..9cec62c86 100644
--- a/httemplate/edit/invoice_template.html
+++ b/httemplate/edit/invoice_template.html
@@ -10,23 +10,12 @@
% if ( $type eq 'html' ) {
-% #init
- <SCRIPT TYPE="text/javascript" src="<% $p %>elements/fckeditor/fckeditor.js">
- </SCRIPT>
-
-% #editor
- <SCRIPT TYPE="text/javascript">
- var oFCKeditor = new FCKeditor('value');
- oFCKeditor.Value = <% $value |js_string %>;
-
- oFCKeditor.BasePath = '<% $p %>elements/fckeditor/';
- oFCKeditor.Config['SkinPath'] = '<% $p %>elements/fckeditor/editor/skins/silver/';
- oFCKeditor.Height = '800';
- oFCKeditor.Config['StartupFocus'] = true;
-
- oFCKeditor.Create();
-
- </SCRIPT>
+ <% include('/elements/htmlarea.html',
+ 'field' => 'value',
+ 'curr_value' => $value,
+ 'height' => 800,
+ )
+ %>
% } else {
diff --git a/httemplate/elements/htmlarea.html b/httemplate/elements/htmlarea.html
new file mode 100644
index 000000000..f27c4b5e6
--- /dev/null
+++ b/httemplate/elements/htmlarea.html
@@ -0,0 +1,36 @@
+<%doc>
+
+Example:
+
+ include('/elements/htmlarea.html',
+ 'field' => 'fieldname',
+ 'curr_value' => $curr_value,
+ 'height' => 800,
+ );
+
+</%doc>
+
+% #init
+<SCRIPT TYPE="text/javascript" src="<% $p %>elements/fckeditor/fckeditor.js">
+</SCRIPT>
+
+% #editor
+<SCRIPT TYPE="text/javascript">
+
+ var oFCKeditor = new FCKeditor('<% $opt{'field'} %>');
+ oFCKeditor.Value = <% $opt{'curr_value'} |js_string %>;
+
+ oFCKeditor.BasePath = '<% $p %>elements/fckeditor/';
+ oFCKeditor.Config['SkinPath'] = '<% $p %>elements/fckeditor/editor/skins/silver/';
+ oFCKeditor.Height = '<% $opt{'height'} || 420 %>';
+ oFCKeditor.Config['StartupFocus'] = true;
+
+ oFCKeditor.Create();
+
+</SCRIPT>
+
+<%init>
+
+my %opt = @_;
+
+</%init>
diff --git a/httemplate/misc/email-customers.html b/httemplate/misc/email-customers.html
new file mode 100644
index 000000000..0d3d622c3
--- /dev/null
+++ b/httemplate/misc/email-customers.html
@@ -0,0 +1,145 @@
+<% include('/elements/header.html', $title) %>
+
+<FORM NAME="OneTrueForm" ACTION="email-customers.html" METHOD="POST">
+% foreach my $key ( keys %search ) {
+% my @values = ref($search{$key}) ? @{$search{$key}} : ( $search{$key} );
+% foreach my $value ( @values ) {
+ <INPUT TYPE="hidden" NAME="<% $key |h %>" VALUE="<% $value |h %>">
+% }
+% }
+
+% if ( $cgi->param('magic') eq 'send' ) {
+
+ <FONT SIZE="+2">Sending notice</FONT>
+
+ <% include('/elements/progress-init.html',
+ 'OneTrueForm',
+ [ keys(%search), qw( from subject html_body text_body ) ],
+ 'process/email-customers.html',
+ { 'message' => "Notice sent" }, #would be nice to show #, but..
+ )
+ %>
+
+% } elsif ( $cgi->param('magic') eq 'preview' ) {
+
+ <FONT SIZE="+2">Preview notice</FONT>
+
+% }
+
+% if ( $cgi->param('magic') ) {
+
+ <TABLE BGCOLOR="#cccccc" CELLSPACING=0>
+
+ <% include('/elements/tr-fixed.html',
+ 'field' => 'from',
+ 'label' => 'From:',
+ 'value' => scalar( $cgi->param('from') ),
+ )
+ %>
+
+ <% include('/elements/tr-fixed.html',
+ 'field' => 'subject',
+ 'label' => 'Subject:',
+ 'value' => scalar( $cgi->param('subject') ),
+ )
+ %>
+
+ <INPUT TYPE="hidden" NAME="html_body" VALUE="<% $cgi->param('html_body') |h %>">
+ <TR>
+ <TD ALIGN="right" VALIGN="top">Message (HTML display): </TD>
+ <TD BGCOLOR="#e8e8e8" ALIGN="left"><% $cgi->param('html_body') %></TD>
+ </TR>
+
+% my $text_body = HTML::FormatText->new(leftmargin=>0)->format(
+% HTML::TreeBuilder->new_from_content(
+% $cgi->param('html_body')
+% )
+% );
+ <INPUT TYPE="hidden" NAME="text_body" VALUE="<% $text_body |h %>">
+ <TR>
+ <TD ALIGN="right" VALIGN="top">Message (Text display): </TD>
+ <TD BGCOLOR="#e8e8e8" ALIGN="left"><PRE><% $text_body %></PRE></TD>
+ </TR>
+
+ </TABLE>
+
+% if ( $cgi->param('magic') eq 'preview' ) {
+
+ <SCRIPT>
+ function areyousure(href) {
+ return confirm("Send this notice to <% $num_cust %> customers?");
+ }
+ </SCRIPT>
+
+ <BR>
+ <INPUT TYPE="hidden" NAME="magic" VALUE="send">
+ <INPUT TYPE="submit" VALUE="Send notice" onClick="return areyousure()">
+
+% }
+
+% } else {
+
+ <TABLE BGCOLOR="#cccccc" CELLSPACING=0 WIDTH="100%">
+
+ <% include('/elements/tr-input-text.html',
+ 'field' => 'from',
+ 'label' => 'From:',
+ )
+ %>
+
+ <% include('/elements/tr-input-text.html',
+ 'field' => 'subject',
+ 'label' => 'Subject:',
+ )
+ %>
+
+ <TR>
+ <TD ALIGN="right" VALIGN="top">Message: </TD>
+ <TD><% include('/elements/htmlarea.html', 'field'=>'html_body') %></TD>
+ </TR>
+
+ </TABLE>
+
+%#Substitution vars:
+
+ <BR><BR>
+ <INPUT TYPE="hidden" NAME="magic" VALUE="preview">
+ <INPUT TYPE="submit" VALUE="Preview notice">
+
+% }
+
+</FORM>
+
+% if ( $cgi->param('magic') eq 'send' ) {
+ <SCRIPT TYPE="text/javascript">
+ process();
+ </SCRIPT>
+% }
+
+<% include('/elements/footer.html') %>
+
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Bulk send customer notices');
+
+my %search = $cgi->Vars;
+delete $search{$_} for qw( magic from subject html_body text_body );
+$search{$_} = [ split(/\0/, $search{$_}) ]
+ foreach grep $search{$_} =~ /\0/, keys %search;
+
+my $title = 'Bulk send customer notices';
+
+my $num_cust;
+if ( $cgi->param('magic') eq 'preview' ) {
+ my $sql_query = FS::cust_main->search_sql(\%search);
+ my $count_query = delete($sql_query->{'count_query'});
+ my $count_sth = dbh->prepare($count_query)
+ or die "Error preparing $count_query: ". dbh->errstr;
+ $count_sth->execute
+ or die "Error executing $count_query: ". $count_sth->errstr;
+ my $count_arrayref = $count_sth->fetchrow_arrayref;
+ $num_cust = $count_arrayref->[0];
+}
+
+</%init>
diff --git a/httemplate/misc/process/email-customers.html b/httemplate/misc/process/email-customers.html
new file mode 100644
index 000000000..d254cfecb
--- /dev/null
+++ b/httemplate/misc/process/email-customers.html
@@ -0,0 +1,9 @@
+<% $server->process %>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Bulk send customer notices');
+
+my $server = new FS::UI::Web::JSRPC 'FS::cust_main::process_email_search_sql', $cgi;
+
+</%init>
diff --git a/httemplate/search/cust_main.html b/httemplate/search/cust_main.html
index a2ecd047c..cd5e51f25 100755
--- a/httemplate/search/cust_main.html
+++ b/httemplate/search/cust_main.html
@@ -1,5 +1,6 @@
<% include( 'elements/search.html',
'title' => 'Customer Search Results',
+ 'menubar' => $menubar,
'name' => 'customers',
'query' => $sql_query,
'count_query' => $count_query,
@@ -30,11 +31,6 @@
],
)
%>
-<%once>
-
-my $link = [ "${p}view/cust_main.cgi?", 'custnum' ];
-
-</%once>
<%init>
die "access denied"
@@ -89,4 +85,23 @@ my $count_query = delete($sql_query->{'count_query'});
my @extra_headers = @{ delete($sql_query->{'extra_headers'}) };
my @extra_fields = @{ delete($sql_query->{'extra_fields'}) };
+my $link = [ "${p}view/cust_main.cgi?", 'custnum' ];
+
+###
+# email links
+###
+
+my $menubar = [];
+
+if ( $FS::CurrentUser::CurrentUser->access_right('Bulk send customer notices') ) {
+
+ my $uri = new URI::URL;
+ $uri->query_form( \%search_hash );
+ my $query = $uri->query;
+
+ push @$menubar, 'Email a notice to these customers' =>
+ "${p}misc/email-customers.html?$query",
+
+}
+
</%init>