-<%
+<% $cgi->redirect("${p}view/cust_main.cgi?$custnum") %>
+<%init>
-my $conf = new FS::Conf;
-my $lpr = $conf->config('lpr');
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Resend invoices');
#untaint invnum
my($query) = $cgi->keywords;
-$query =~ /^(\d*)$/;
-my $invnum = $1;
+$query =~ /^((.+)-)?(\d+)$/;
+my $template = $2;
+my $invnum = $3;
my $cust_bill = qsearchs('cust_bill',{'invnum'=>$invnum});
die "Can't find invoice!\n" unless $cust_bill;
- open(LPR,"|$lpr") or die "Can't open $lpr: $!";
-
- if ( $conf->exists('invoice_latex') ) {
- print LPR $cust_bill->print_ps; #( date )
- } else {
- print LPR $cust_bill->print_text; #( date )
- }
-
- close LPR
- or die $! ? "Error closing $lpr: $!"
- : "Exit status $? from $lpr";
+$cust_bill->print($template);
my $custnum = $cust_bill->getfield('custnum');
-print $cgi->redirect("${p}view/cust_main.cgi?$custnum");
-
-%>
+</%init>