X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=reporting%2Fincludes%2Fpdf_report.inc;h=2dcafc5ca343966201e4c3f5d456a382631714d9;hb=64e653e26f141e5d27cbb8fd730b97c0c43930df;hp=2e1654d192390b9d57fa841e2a7c1fd8afcdf23e;hpb=b753cba3fcaf9e92ec40f747ded0787d10509c11;p=fa-stable.git diff --git a/reporting/includes/pdf_report.inc b/reporting/includes/pdf_report.inc index 2e1654d1..2dcafc5c 100644 --- a/reporting/includes/pdf_report.inc +++ b/reporting/includes/pdf_report.inc @@ -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; @@ -361,16 +363,19 @@ class FrontReport extends Cpdf if ($this->pageNumber > 1) $this->newPage(); $header2type = true; + + // leave layout files names without path to enable including + // modified versions from comapny/x/reporting directory if (isset($myrow['curr_code']) && $this->currency != $myrow['curr_code']) { - include($path_to_root . "/reporting/includes/doctext2.inc"); + include("includes/doctext2.inc"); } else { - include($path_to_root . "/reporting/includes/doctext.inc"); + include("includes/doctext.inc"); } - include($path_to_root . "/reporting/includes/header2.inc"); + include("includes/header2.inc"); $this->row = $temp; } @@ -469,7 +474,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 +531,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); @@ -688,7 +696,7 @@ class FrontReport extends Cpdf parent::SetCellPadding($pad); } - function Text($c, $txt, $n=0, $corr=0, $r=0, $align='left', $border=0, $fill=0, $link=NULL, $stretch=0) + function Text($c, $txt, $n=0, $corr=0, $r=0, $align='left', $border=0, $fill=0, $link=NULL, $stretch=1) { if ($n == 0) $n = $this->pageWidth - $this->rightMargin; @@ -696,7 +704,7 @@ class FrontReport extends Cpdf return $this->TextWrap($c, $this->row - $r, $n - $c + $corr, $txt, $align, $border, $fill, $link, $stretch); } - function TextWrap($xpos, $ypos, $len, $str, $align = 'left', $border = 0, $fill = 0, $link = NULL, $stretch = 0) + function TextWrap($xpos, $ypos, $len, $str, $align = 'left', $border = 0, $fill = 0, $link = NULL, $stretch = 1) { if ($this->fontSize != $this->oldFontSize) { @@ -706,41 +714,51 @@ class FrontReport extends Cpdf return $this->addTextWrap($xpos, $ypos, $len, $this->fontSize, $str, $align, $border, $fill, $link, $stretch); } - function TextCol($c, $n, $txt, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=0) + function TextCol($c, $n, $txt, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=1) { 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=1, $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=1, $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) + function DateCol($c, $n, $txt, $conv=false, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=1) { if ($conv) $txt = sql2date($txt); return $this->TextCol($c, $n, $txt, $corr, $r, $border, $fill, $link, $stretch); } - function TextCol2($c, $n, $txt, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=0) + function TextCol2($c, $n, $txt, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=1) { return $this->TextWrap($this->cols2[$c], $this->row - $r, $this->cols2[$n] - $this->cols2[$c] + $corr, $txt, $this->aligns2[$c], $border, $fill, $link, $stretch); } - function TextColLines($c, $n, $txt, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=0) + function TextColLines($c, $n, $txt, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=1) { $this->row -= $r; $this->TextWrapLines($this->cols[$c], $this->cols[$n] - $this->cols[$c] + $corr, $txt, $this->aligns[$c], $border, $fill, $link, $stretch); } - function TextWrapLines($c, $width, $txt, $align='left', $border=0, $fill=0, $link=NULL, $stretch=0) + function TextWrapLines($c, $width, $txt, $align='left', $border=0, $fill=0, $link=NULL, $stretch=1) { $str = Explode("\n", $txt); for ($i = 0; $i < count($str); $i++) @@ -901,20 +919,20 @@ class FrontReport extends Cpdf $emailtype = true; if ($this->currency != $myrow['curr_code']) { - include("doctext2.inc"); + include("includes/doctext2.inc"); } else { - include("doctext.inc"); + include("includes/doctext.inc"); } require_once($path_to_root . "/reporting/includes/class.mail.inc"); - $mail = new email($this->company['coy_name'], $this->company['email']); + $mail = new email(str_replace(",", "", $this->company['coy_name']), $this->company['email']); if (!isset($myrow['email']) || $myrow['email'] == '') $myrow['email'] = isset($myrow['contact_email']) ? $myrow['contact_email'] : ''; - $to = $myrow['DebtorName'] . " <" . $myrow['email'] . ">"; + $to = str_replace(",", "", $myrow['DebtorName']) . " <" . $myrow['email'] . ">"; $msg = $doc_Dear_Sirs . " " . $myrow['DebtorName'] . ",\n\n" . $doc_AttachedFile . " " . $subject . "\n\n"; - if (isset($myrow['dimension_id']) && $myrow['dimension_id'] > 0 && $doctype == 10) // helper for payment links + if (isset($myrow['dimension_id']) && $myrow['dimension_id'] > 0 && $doctype == ST_SALESINVOICE) // helper for payment links { if ($myrow['dimension_id'] == 1) {