From 4fe1fa31dffa6689d9cb88e2a0cda408b826b89d Mon Sep 17 00:00:00 2001 From: Jonathan Prykop Date: Mon, 22 Jun 2015 18:34:27 -0500 Subject: RT#34078: Payment History Report / Statement --- httemplate/misc/email-customers-history.html | 51 ++++++++++++++++++++++++++ httemplate/misc/email-customers.html | 53 +++++++++++++++++++++++----- 2 files changed, 96 insertions(+), 8 deletions(-) create mode 100644 httemplate/misc/email-customers-history.html (limited to 'httemplate/misc') diff --git a/httemplate/misc/email-customers-history.html b/httemplate/misc/email-customers-history.html new file mode 100644 index 000000000..2f9a38d23 --- /dev/null +++ b/httemplate/misc/email-customers-history.html @@ -0,0 +1,51 @@ + + <% include('email-customers.html', + 'form_action' => 'email-customers-history.html', + 'sub_param_process' => $sub_param_process, + 'alternate_form' => $alternate_form, + 'title' => 'Send payment history', + ) + %> + +<%init> + +my $sub_param_process = sub { + my $conf = shift; + my %sub_param; + foreach my $field ( qw( start_date end_date ) ) { + $sub_param{'payment_history'}->{$field} = parse_datetime($cgi->param($field)); + $cgi->delete($field); + } + $cgi->param('msgnum',$conf->config('payment_history_msgnum')); + return %sub_param; +}; + +my $alternate_form = sub { + my %sub_param = @_; + # this could maaaybe be a separate element, for cleanliness + # but it's really only for use by this page, and it's not overly complicated + my $noinit = 0; + return join("\n", + '', + ( + map { + my $label = ucfirst($_); + $label =~ s/_/ /; + include('/elements/tr-input-date-field.html',{ + 'name' => $_, + 'value' => $sub_param{'payment_history'}->{$_} || '', + 'label' => $label, + 'noinit' => $noinit++ + }); + } + qw( start_date end_date ) + ), + '
', + '', + '', + '', + ); +}; + + + diff --git a/httemplate/misc/email-customers.html b/httemplate/misc/email-customers.html index 83e86158f..d1d5ac735 100644 --- a/httemplate/misc/email-customers.html +++ b/httemplate/misc/email-customers.html @@ -1,3 +1,26 @@ +<%doc> + +Allows emailing one or more customers, based on a search for customers. Search can +be specified either through cust_main fields as cgi params, or through a base64 encoded +frozen hash in the 'search' cgi param. Form allows selecting an existing msg_template, +or creating a custom message, and shows a preview of the message before sending. +If linked to as a popup, include the cgi parameter 'popup' for proper header handling. + +This may also be used as an element in other pages, enabling you to pass along +additional substitution parameters to a message template, with the following options: + +form_action - the URL to submit the form to + +sub_param_process - subroutine to override cgi param values (such as msgnum) +and parse/delete additional form fields from the cgi; should return a %sub_param +hash to be passed along for message substitution + +alternate_form - an alternate form for template selection/message creation + +title - the title of the page + + + % if ($popup) { <% include('/elements/header-popup.html', $title) %> % } else { @@ -5,13 +28,16 @@ % } -
+ %# Mixing search params with from address, subject, etc. required special-case %# handling of those, risked name conflicts, and caused massive problems with %# multi-valued search params. We are no longer in search context, so we %# pack the search into a Storable string for later use. +% if (%sub_param) { + +% } @@ -21,7 +47,7 @@ <% include('/elements/progress-init.html', 'OneTrueForm', - [ qw( search table from subject html_body text_body msgnum ) ], + [ qw( search table from subject html_body text_body msgnum sub_param ) ], 'process/email-customers.html', $pdest, ) @@ -93,6 +119,10 @@ % } +% } elsif ($alternate_form) { + +<% $alternate_form %> + % } else {