2 <% include('email-customers.html',
3 'form_action' => 'email-customer-statement.html',
4 'title' => 'Send statement to customer',
5 'no_search_fields' => [ 'start_date', 'end_date' ],
6 'alternate_form' => $alternate_form,
7 'post_search_hook' => $post_search_hook,
9 'process_url' => 'process/email-customer-statement.html',
15 my $acl = 'Resend invoices';
18 unless $FS::CurrentUser::CurrentUser->access_right($acl);
20 my $alternate_form = sub {
21 # this could maaaybe be a separate element, for cleanliness
22 # but it's really only for use by this page, and it's not overly complicated
28 my $label = ucfirst($_);
30 include('/elements/tr-input-date-field.html',{
32 'value' => ( scalar($cgi->param($_)) || '' ),
37 qw( start_date end_date )
40 '<INPUT TYPE="hidden" NAME="action" VALUE="preview">',
41 '<INPUT TYPE="submit" VALUE="Preview notice">',
45 my $post_search_hook = sub {
47 return unless $cgi->param('action') eq 'preview';
48 my $cust_main = qsearchs('cust_main',$opt{'search'})
49 or die "Could not find customer";
51 # so that the statement indicates the latest date
52 my $date_format = $opt{'conf'}->config('date_format') || '%m/%d/%Y';
53 $cgi->param('end_date', time2str($date_format, time))
54 unless $cgi->param('end_date');
56 # set from/subject/html_body based on date range
59 $opt{'conf'}->config('invoice_from')
62 # shortcut for common text
63 my $summary_text = $cust_main->name_short .
64 ($cgi->param('start_date') ? ' from ' : '') .
65 $cgi->param('start_date') .
66 ($cgi->param('end_date') ? ' through ' : '') .
67 $cgi->param('end_date');
69 $cgi->param('subject',
70 $opt{'conf'}->config('company_name') .
75 $cgi->param('html_body',
77 $opt{'conf'}->config('company_name') .
78 ' statement of charges and payments for ' .
81 include('/elements/customer-statement.html',
83 $cust_main->payment_history(
85 $_ => parse_datetime(scalar($cgi->param($_)))
87 qw( start_date end_date ),