document trouble schema changes backported to 1.4.2
[freeside.git] / httemplate / misc / print-invoice.cgi
1 <%
2
3 my $conf = new FS::Conf;
4 my $lpr = $conf->config('lpr');
5
6 #untaint invnum
7 my($query) = $cgi->keywords;
8 $query =~ /^(\d*)$/;
9 my $invnum = $1;
10 my $cust_bill = qsearchs('cust_bill',{'invnum'=>$invnum});
11 die "Can't find invoice!\n" unless $cust_bill;
12
13         open(LPR,"|$lpr") or die "Can't open $lpr: $!";
14
15         if ( $conf->exists('invoice_latex') ) {
16           print LPR $cust_bill->print_ps; #( date )
17         } else {
18           print LPR $cust_bill->print_text; #( date )
19         }
20
21         close LPR
22           or die $! ? "Error closing $lpr: $!"
23                        : "Exit status $? from $lpr";
24
25 my $custnum = $cust_bill->getfield('custnum');
26
27 print $cgi->redirect("${p}view/cust_main.cgi?$custnum");
28
29 %>