Optimize "Customer has a referring customer" condition, RT#74452
[freeside.git] / httemplate / misc / send-statement.cgi
1 <% $cgi->redirect("${p}view/cust_main.cgi?$custnum") %>
2 <%once>
3
4 my %method = map { $_=>1 } qw( email print fax_invoice );
5
6 </%once>
7 <%init>
8
9 die "access denied"
10   unless $FS::CurrentUser::CurrentUser->access_right('Resend invoices');
11
12 my $statementnum = $cgi->param('statementnum');
13 my $template     = $cgi->param('template') || 'statement'; #XXX configure... via event??  eh..
14 my $notice_name  = $cgi->param('notice_name') if $cgi->param('notice_name');
15 my $method       = $cgi->param('method');
16
17 $method .= '_invoice' if $method eq 'fax'; #!
18
19 die "unknown method $method" unless $method{$method};
20
21 my $cust_statement = qsearchs('cust_statement',{'statementnum'=>$statementnum});
22 die "Can't find statement!\n" unless $cust_statement;
23
24 $cust_statement->$method({ 'template' => $template }); 
25
26 my $custnum = $cust_statement->getfield('custnum');
27
28 </%init>