Merge branch 'master' of git.freeside.biz:/home/git/freeside
[freeside.git] / httemplate / misc / send-invoice.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 $invnum      = $cgi->param('invnum');
13 my $template    = $cgi->param('template');
14 my $notice_name = $cgi->param('notice_name') if $cgi->param('notice_name');
15 my $method      = $cgi->param('method');
16 my $mode;
17 if ( $cgi->param('mode') =~ /^(\d+)$/ ) {
18   $mode = $1;
19 }
20
21 $method .= '_invoice' if $method eq 'fax'; #!
22
23 die "unknown method $method" unless $method{$method};
24
25 my $cust_bill = qsearchs('cust_bill',{'invnum'=>$invnum});
26 die "Can't find invoice!\n" unless $cust_bill;
27
28 $cust_bill->set('mode' => $mode) if $mode;
29 $cust_bill->$method({ 'template'    => $template,
30                       'notice_name' => $notice_name,
31                    }); 
32
33 my $custnum = $cust_bill->getfield('custnum');
34
35 </%init>