mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-28 11:43:25 +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 $actyear = $now[5];
|
||||||
my ($from,$till)=&ACCT::getmonth($actmonth,$actyear);
|
my ($from,$till)=&ACCT::getmonth($actmonth,$actyear);
|
||||||
my @billar = &ACCT::GetTaValues($from,$till,$rggrp);
|
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
|
#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>;
|
my @fileholder = <DLFILE>;
|
||||||
print "Content-Type:application/pdf\n";
|
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-Length:$fileinfo[7]\n";
|
||||||
print "Content-Disposition:attachment;filename='tmp.pdf';\n\n";
|
print "Content-Disposition:attachment;filename='tmp.pdf';\n\n";
|
||||||
print @fileholder;
|
print @fileholder;
|
||||||
|
unlink ($tempfile);
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ use PDF::API2;
|
|||||||
use utf8;
|
use utf8;
|
||||||
use Encode;
|
use Encode;
|
||||||
use File::Copy;
|
use File::Copy;
|
||||||
|
use File::Temp qw/ tempfile tempdir /;
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
my $dbh;
|
my $dbh;
|
||||||
@@ -430,7 +431,7 @@ sub pdf2 {
|
|||||||
|
|
||||||
#Check if we are creating a preview or a real bill
|
#Check if we are creating a preview or a real bill
|
||||||
if($preview eq 'on'){
|
if($preview eq 'on'){
|
||||||
$filename="$path/tmp.pdf";
|
$filename="$path/".tempfile( SUFFIX => ".pdf", );
|
||||||
}
|
}
|
||||||
####################################################################
|
####################################################################
|
||||||
#Prepare DATA from arrays
|
#Prepare DATA from arrays
|
||||||
@@ -791,6 +792,9 @@ sub pdf2 {
|
|||||||
if ($preview ne 'on'){
|
if ($preview ne 'on'){
|
||||||
&fillBill($path.$grp,$name,$no,$grp);
|
&fillBill($path.$grp,$name,$no,$grp);
|
||||||
}
|
}
|
||||||
|
if($preview eq 'on'){
|
||||||
|
return $filename;
|
||||||
|
}
|
||||||
return '0';
|
return '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user