]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - src/squid-accounting/acct-lib.pl
squid-accounting: create billpreview file as temporary file
[ipfire-2.x.git] / src / squid-accounting / acct-lib.pl
index 96456c9b0bf9c11626eacac5594bfe846f882c38..f0081b7ef9551049e8ef027dc63e879a6aa496a8 100644 (file)
@@ -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';
 }