RT# 75095 - Added Ooma integration to one time charges
[freeside.git] / httemplate / misc / send-invoice.cgi
1 % if ($cgi->param('popup')) {
2 %   my $title = $error ? 'Error sending invoice email' : 'Invoice email sent';
3 <% include('/elements/header-popup.html', $title ) %>
4 <DIV STYLE="text-align: center;">
5 <SPAN STYLE="color: red; font-weight: bold;"><% $error %></SPAN><BR>
6 <BUTTON TYPE="button" onClick="parent.cClick();">Close</BUTTON>
7 </DIV>
8 <% include('/elements/footer.html') %>
9 % } elsif ( $error ) {
10 %   errorpage($error);
11 % } else {
12 <% $cgi->redirect("${p}view/cust_main.cgi?$custnum") %>
13 % }
14 <%once>
15
16 my %method = ( map { $_=>1 } qw( email print fax_invoice ) );
17
18 </%once>
19 <%init>
20
21 die "access denied"
22   unless $FS::CurrentUser::CurrentUser->access_right('Resend invoices');
23
24 my $invnum      = $cgi->param('invnum');
25 my $template    = $cgi->param('template');
26 my $notice_name = $cgi->param('notice_name') if $cgi->param('notice_name');
27 my $method      = $cgi->param('method');
28 my $no_coupon   = $cgi->param('no_coupon');
29 my $mode;
30 if ( $cgi->param('mode') =~ /^(\d+)$/ ) {
31   $mode = $1;
32 }
33
34 $method .= '_invoice' if $method eq 'fax'; #!
35
36 die "unknown method $method" unless $method{$method};
37
38 my $cust_bill = qsearchs('cust_bill',{'invnum'=>$invnum});
39 die "Can't find invoice!\n" unless $cust_bill;
40
41 $cust_bill->set('mode' => $mode) if $mode;
42
43 #these methods die instead of return errors, so, handle that without a backtrace
44 eval { $cust_bill->$method({ 'template'    => $template,
45                              'notice_name' => $notice_name,
46                              'no_coupon'   => $no_coupon,
47                           }); 
48      };
49 my $error = $@;
50
51 my $custnum = $cust_bill->getfield('custnum');
52
53 </%init>