Release 2.2.2
[fa-stable.git] / reporting / includes / pdf_report.inc
index 2e1654d192390b9d57fa841e2a7c1fd8afcdf23e..b17d5700d5407d7b651ce89cf9ce11330e1047e9 100644 (file)
@@ -46,6 +46,7 @@ class FrontReport extends Cpdf
        var $oldFontSize;
        var $currency;
        var $companyLogoEnable;  // select whether to use a company logo graphic in some header templates
+       var $scaleLogoWidth;
        var $footerEnable;  // select whether to print a page footer or not
        var $footerText;  // store user-generated footer text
        var $headerFunc;  // store the name of the currently selected header function
@@ -196,6 +197,7 @@ class FrontReport extends Cpdf
                $this->oldFontSize = 0;
                $this->row = $this->pageHeight - $this->topMargin;
                $this->currency = '';
+               $this->scaleLogoWidth = false; // if Logo, scale on width (else height).
                $this->headerFunc = 'Header';  // default to the original header template
                $rtl = ($_SESSION['language']->dir === 'rtl' ? 'rtl' : 'ltr');
                $code = $_SESSION['language']->code;
@@ -469,7 +471,10 @@ class FrontReport extends Cpdf
 
                        // Width being zero means that the image will be scaled to the specified height
                        // keeping its aspect ratio intact.
-                       $this->AddImage($logo, $companyCol, $this->row - (LOGO_HEIGHT * LOGO_Y_POS_ADJ_FACTOR), 0, LOGO_HEIGHT);
+                       if ($this->scaleLogoWidth)
+                               $this->AddImage($logo, $companyCol, $this->row, COMPANY_WIDTH, 0);
+                       else    
+                               $this->AddImage($logo, $companyCol, $this->row - (LOGO_HEIGHT * LOGO_Y_POS_ADJ_FACTOR), 0, LOGO_HEIGHT);
                }
                else
                        $this->Text($companyCol, $this->company['coy_name']);
@@ -523,7 +528,7 @@ class FrontReport extends Cpdf
                $str = _("Report Period") . ':';
                $this->Text($this->leftMargin, $str, $headerFieldCol);
                $str = '';
-               if ($this->params[1]['from'] != '')
+               if (isset($this->params[1]['from']) && $this->params[1]['from'] != '')
                        $str = $this->params[1]['from'] . ' - ';
                $str .= $this->params[1]['to'];
                $this->Text($headerFieldCol, $str, $companyCol);
@@ -711,15 +716,25 @@ class FrontReport extends Cpdf
                return $this->TextWrap($this->cols[$c], $this->row - $r, $this->cols[$n] - $this->cols[$c] + $corr, $txt, $this->aligns[$c], $border, $fill, $link, $stretch);
        }
        
-       function AmountCol($c, $n, $txt, $dec=0, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=0)
+       function AmountCol($c, $n, $txt, $dec=0, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=0, $color_red=false)
        {
-               return $this->TextCol($c, $n, number_format2($txt, $dec), $corr, $r, $border, $fill, $link, $stretch);
+               if ($color_red && $txt < 0)
+                       $this->SetTextColor(255, 0, 0);
+               $ret = $this->TextCol($c, $n, number_format2($txt, $dec), $corr, $r, $border, $fill, $link, $stretch);
+               if ($color_red && $txt < 0)
+                       $this->SetTextColor(0, 0, 0);
+               return $ret;    
        }
 
-       function AmountCol2($c, $n, $txt, $dec=0, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=0, $amount_locale = 'en_US.UTF-8', $amount_format = '%(!.2n')
+       function AmountCol2($c, $n, $txt, $dec=0, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=0, $color_red=false, $amount_locale = 'en_US.UTF-8', $amount_format = '%(!.2n')
        {
                setlocale(LC_MONETARY, $amount_locale);
-               return $this->TextCol($c, $n, money_format($amount_format, $txt), $corr, $r, $border, $fill, $link, $stretch);
+               if ($color_red && $txt < 0)
+                       $this->SetTextColor(255, 0, 0);
+               $ret = $this->TextCol($c, $n, money_format($amount_format, $txt), $corr, $r, $border, $fill, $link, $stretch);
+               if ($color_red && $txt < 0)
+                       $this->SetTextColor(0, 0, 0);
+               return $ret;    
        }
        
        function DateCol($c, $n, $txt, $conv=false, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=0)