71513: Card tokenization [bug fixes, removed cardtype/taxclass override ui]
[freeside.git] / httemplate / misc / post_fsinc-invoice.cgi
1 % my $title = $error ? 'Error printing and mailing invoice' : 'Invoice printed and mailed';
2 <% include('/elements/header-popup.html', $title ) %>
3 <DIV STYLE="text-align: center;">
4 <SPAN STYLE="color: red; font-weight: bold;"><% $error %></SPAN><BR>
5 <BUTTON TYPE="button" onClick="parent.cClick();">Close</BUTTON>
6 </DIV>
7 <% include('/elements/footer-popup.html') %>
8
9 <%init>
10
11 die "access denied"
12   unless $FS::CurrentUser::CurrentUser->access_right('Print and mail invoices');
13
14 my $invnum      = $cgi->param('invnum');
15
16 my $template    = $cgi->param('template');
17 my $notice_name = $cgi->param('notice_name') if $cgi->param('notice_name');
18 my $no_coupon   = $cgi->param('no_coupon');
19
20 #XXX agent-virt
21 my $cust_bill = qsearchs('cust_bill',{'invnum'=>$invnum})
22   or die "Unknown invnum\n";
23
24 my $mode;
25 if ( $cgi->param('mode') =~ /^(\d+)$/ ) {
26   $mode = $1;
27 }
28 $cust_bill->set('mode' => $mode) if $mode;
29
30 #these methods die instead of return errors, so, handle that without a backtrace
31 local $@;
32 my $letter_id = 
33   eval { $cust_bill->postal_mail_fsinc( 'template'    => $template,
34                                         'notice_name' => $notice_name,
35                                         'no_coupon'   => $no_coupon,
36                                       ); 
37        };
38 my $error = "$@";
39
40 $error ||= 'Unknown print and mail error: no letter ID returned'
41   unless $letter_id;
42
43 </%init>