'Customer invoice / financial info rights' => [
'View invoices',
'Resend invoices', #NEWNEW
+ { rightname=>'Print and mail invoices', desc=>"Print and mail via Freeside's web service", }, ##NEWER than NEWNEWNEW
'Void invoices',
'Unvoid invoices',
'View customer tax exemptions', #yow
'Add on-the-fly void credit reason' => 'Add on-the-fly void credit reason',
'_ALL' => 'Employee preference telephony integration',
'Edit customer package dates' => 'Change package start date', #4.x
+ 'Resend invoices' => 'Print and mail invoices',
);
# foreach my $old_acl ( keys %onetime ) {
--- /dev/null
+% my $title = $error ? 'Error printing and mailing invoice' : 'Invoice printed and mailed';
+<% include('/elements/header-popup.html', $title ) %>
+<DIV STYLE="text-align: center;">
+<SPAN STYLE="color: red; font-weight: bold;"><% $error %></SPAN><BR>
+<BUTTON TYPE="button" onClick="parent.cClick();">Close</BUTTON>
+</DIV>
+<% include('/elements/footer-popup.html') %>
+
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Print and mail invoices');
+
+my $invnum = $cgi->param('invnum');
+
+my $template = $cgi->param('template');
+my $notice_name = $cgi->param('notice_name') if $cgi->param('notice_name');
+my $no_coupon = $cgi->param('no_coupon');
+
+#XXX agent-virt
+my $cust_bill = qsearchs('cust_bill',{'invnum'=>$invnum})
+ or die "Unknown invnum\n";
+
+my $mode;
+if ( $cgi->param('mode') =~ /^(\d+)$/ ) {
+ $mode = $1;
+}
+$cust_bill->set('mode' => $mode) if $mode;
+
+#these methods die instead of return errors, so, handle that without a backtrace
+local $@;
+my $letter_id =
+ eval { $cust_bill->postal_mail_fsinc( 'template' => $template,
+ 'notice_name' => $notice_name,
+ 'no_coupon' => $no_coupon,
+ );
+ };
+my $error = "$@";
+
+$error ||= 'Unknown print and mail error: no letter ID returned'
+ unless $letter_id;
+
+</%init>
% }
% if ( $curuser->access_right('Resend invoices') ) {
+ <A HREF="<% $p %>misc/send-invoice.cgi?method=print;<% $link %>"><% mt('Print this invoice') |h %></A>
+% }
+
+% if ( $curuser->access_right('Print and mail invoices') ) {
+ | <& /elements/popup_link.html,
+ 'action' => $p."misc/post_fsinc-invoice.cgi?$link",
+ 'label' => 'Print and mail this invoice online',
+ 'actionlabel' => 'Invoice printing and mailing',
+ &>
+% }
- <A HREF="<% $p %>misc/send-invoice.cgi?method=print;<% $link %>"><% mt('Re-print this invoice') |h %></A>
+% if ( $curuser->access_right('Resend invoices') ) {
% if ( grep { $_ ne 'POST' } $cust_bill->cust_main->invoicing_list ) {
| <A HREF="<% $p %>misc/send-invoice.cgi?method=email;<% $link %>"><% mt('Re-email this invoice') |h %></A>
| <A HREF="<% $p %>misc/send-invoice.cgi?method=fax;<% $link %>"><% mt('Re-fax this invoice') |h %></A>
% }
- <BR><BR>
+% }
+% if ( $curuser->access_right('Resend invoices')
+% || $curuser->access_right('Print and mail invoices') ) {
+ <BR><BR>
% }
% my $br = 0;