so Search.tsf and Search.rdf work
[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 $template = $2;
10 my $invnum = $3;
11 my $cust_bill = qsearchs('cust_bill',{'invnum'=>$invnum});
12 die "Can't find invoice!\n" unless $cust_bill;
13
14         open(LPR,"|$lpr") or die "Can't open $lpr: $!";
15
16         if ( $conf->exists('invoice_latex') ) {
17           print LPR $cust_bill->print_ps('', $template); #( date )
18         } else {
19           print LPR $cust_bill->print_text('', $template); #( date )
20         }
21
22         close LPR
23           or die $! ? "Error closing $lpr: $!"
24                        : "Exit status $? from $lpr";
25
26 my $custnum = $cust_bill->getfield('custnum');
27
28 print $cgi->redirect("${p}view/cust_main.cgi?$custnum");
29
30 %>