mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-09 18:45:54 +02:00
squid-accounting: create billpreview file as temporary file
This commit is contained in:
@@ -92,15 +92,16 @@ if ($cgiparams{'BILLACTION'} eq "open_preview"){
|
||||
my $actyear = $now[5];
|
||||
my ($from,$till)=&ACCT::getmonth($actmonth,$actyear);
|
||||
my @billar = &ACCT::GetTaValues($from,$till,$rggrp);
|
||||
&ACCT::pdf2(\@billar,$actmonth,$actyear,$mwst,$address_cust,$address_host,$billpos,$rggrp,$cur,"on");
|
||||
my $tempfile=&ACCT::pdf2(\@billar,$actmonth,$actyear,$mwst,$address_cust,$address_host,$billpos,$rggrp,$cur,"on");
|
||||
#Show PDF preview
|
||||
open(DLFILE, "</var/ipfire/accounting/bill/tmp.pdf") or die "Unable to open tmp.pdf: $!";
|
||||
open(DLFILE, "<$tempfile") or die "Unable to open tmp.pdf: $!";
|
||||
my @fileholder = <DLFILE>;
|
||||
print "Content-Type:application/pdf\n";
|
||||
my @fileinfo = stat("/var/ipfire/accounting/bill/tmp.pdf");
|
||||
my @fileinfo = stat($tempfile);
|
||||
print "Content-Length:$fileinfo[7]\n";
|
||||
print "Content-Disposition:attachment;filename='tmp.pdf';\n\n";
|
||||
print @fileholder;
|
||||
unlink ($tempfile);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ use PDF::API2;
|
||||
use utf8;
|
||||
use Encode;
|
||||
use File::Copy;
|
||||
use File::Temp qw/ tempfile tempdir /;
|
||||
|
||||
###############################################################################
|
||||
my $dbh;
|
||||
@@ -430,7 +431,7 @@ sub pdf2 {
|
||||
|
||||
#Check if we are creating a preview or a real bill
|
||||
if($preview eq 'on'){
|
||||
$filename="$path/tmp.pdf";
|
||||
$filename="$path/".tempfile( SUFFIX => ".pdf", );
|
||||
}
|
||||
####################################################################
|
||||
#Prepare DATA from arrays
|
||||
@@ -791,6 +792,9 @@ sub pdf2 {
|
||||
if ($preview ne 'on'){
|
||||
&fillBill($path.$grp,$name,$no,$grp);
|
||||
}
|
||||
if($preview eq 'on'){
|
||||
return $filename;
|
||||
}
|
||||
return '0';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user