]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - src/squid-accounting/acct-lib.pl
Merge remote-tracking branch 'amarx/vpn-statistic1' into next
[people/pmueller/ipfire-2.x.git] / src / squid-accounting / acct-lib.pl
old mode 100755 (executable)
new mode 100644 (file)
index 96456c9..826be26
@@ -27,6 +27,7 @@ use PDF::API2;
 use utf8;
 use Encode;
 use File::Copy;
+use File::Temp qw/ tempfile tempdir /;
 
 ###############################################################################
 my $dbh;
@@ -336,7 +337,12 @@ sub getmonth{
                my $monat=$_[0]-1 if($_[0]);
                my $tag=1;
                my $time1=timelocal(0,0,0,$tag,$monat,$jahr);
-               my $time2=timelocal(0,0,0,$tag,($monat+1),$jahr);
+               my $time2=0;
+               if (($monat+1) == 12){
+                       $time2=timelocal(0,0,0,$tag,0,$jahr+1);
+               }else{
+                       $time2=timelocal(0,0,0,$tag,$monat+1,$jahr);
+               }
                --$time2;
                return ($time1,$time2);
 }
@@ -430,7 +436,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
@@ -459,7 +465,6 @@ sub pdf2 {
        $lines->linewidth('0.5');
 
        #Fill BILL DATA into PDF
-       setlocale(LC_ALL, "$mainsettings{'LANGUAGE'}_$uplang");
        foreach (@billar) {
                my ($a1,$a2) = split( /\,/, $_ );
                $a2=sprintf"%.2f",($a2/1024/1024);
@@ -791,6 +796,9 @@ sub pdf2 {
        if ($preview ne 'on'){
                &fillBill($path.$grp,$name,$no,$grp);
        }
+       if($preview eq 'on'){
+               return $filename;
+       }
        return '0';
 }