REAL email-invoice on 1.4
authorivan <ivan>
Mon, 16 Feb 2004 21:29:02 +0000 (21:29 +0000)
committerivan <ivan>
Mon, 16 Feb 2004 21:29:02 +0000 (21:29 +0000)
httemplate/misc/email-invoice.cgi

index 0dda68a..7ab1613 100755 (executable)
@@ -1,7 +1,6 @@
 <%
 
 my $conf = new FS::Conf;
-my $lpr = $conf->config('lpr');
 
 #untaint invnum
 my($query) = $cgi->keywords;
@@ -10,20 +9,15 @@ my $invnum = $1;
 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";
+my $error = send_email(
+  'from'    => $conf->config('invoice_from'),
+  'to'      => [ grep { $_ ne 'POST' } $cust_bill->cust_main->invoicing_list ],
+  'subject' => 'Invoice',
+  'body'    => [ $cust_bill->print_text ],
+);
+eidiot($error) if $error;
 
 my $custnum = $cust_bill->getfield('custnum');
-
-print $cgi->redirect(popurl(2). "view/cust_main.cgi?$custnum#history");
+print $cgi->redirect("${p}view/cust_main.cgi?$custnum");
 
 %>