Optimized the textwraplines in pdf_report.inc and header2.inc
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Tue, 19 Aug 2008 14:23:23 +0000 (14:23 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Tue, 19 Aug 2008 14:23:23 +0000 (14:23 +0000)
CHANGELOG.txt
reporting/includes/header2.inc
reporting/includes/pdf_report.inc

index d205269de5fd8eb616c254213968576ddda03f43..b3b26f8f1caa9ce12cefcd5a2270dbf441b8e298 100644 (file)
@@ -19,6 +19,11 @@ Legend:
 ! -> Note
 $ -> Affected files
 
+19-Aut-2008 Joe Hunt
+! Optimized the textwraplines in pdf_report.inc and header2.inc
+  /reporting/includes/pdf_report.inc
+  /reporting/includes/header2.inc (This is important to download too!)
+  
 19-Aug-2008 Joe Hunt
 ! Replacing the PDF Engine with a slightly modified TCPDF
 $ /reporting/fonts/helvetica*.php (new php files)
index 31b0ad2336b0c7c6abb3737a95cb8a08ed64a07c..84d93e1e738236ae21b34a0d4b5a49a379084c2d 100644 (file)
@@ -84,7 +84,6 @@
                if ($doctype == 9)
                {
                        $this->Text($ccol, $myrow['name'], $icol);
-                       $adr = array();
                }
                else
                {
                                $this->Text($ccol, $myrow['supp_name'], $icol);
                        else
                                $this->Text($ccol, $myrow['DebtorName'], $icol);
-                       $adr = explode("\n", $myrow['address']);
-               }
-               for ($i = 0; $i < count($adr); $i++)
-               {
                        $this->NewLine();
-                       $this->Text($ccol, $adr[$i], $icol);
+                       $this->TextWrapLines($ccol, $icol - $ccol, $myrow['address']);
                }
                if ($sales_order != NULL)
                {
                                $this->Text($mcol, $this->company['coy_name']);
                        else
                                $this->Text($mcol, $sales_order['deliver_to']);
-                       $adr = explode("\n", $sales_order['delivery_address']);
-                       for ($i = 0; $i < count($adr); $i++)
-                       {
-                               $this->NewLine();
-                               $this->Text($mcol, $adr[$i]);
-                       }
+                       $this->NewLine();
+                       $this->TextWrapLines($mcol, $this->rightMargin - $mcol, $sales_order['delivery_address']);
                }
                $this->row = $iline2 - 2 * $this->lineHeight;
                $this->Text($ccol, $doc_Shipping_Company . ":", $ccol2);
                $this->fontSize += 4;
                $this->NewLine();
                $adrline = $this->row;
-
-               $adr = explode("\n", $this->company['postal_address']);
-               for ($i = 0; $i < count($adr); $i++)
-               {
-                       $this->Text($ccol, $adr[$i], $ccol2 + 40);
-                       $this->NewLine();
-               }
+               $this->TextWrapLines($ccol, $ccol2 + 40 - $ccol, $this->company['postal_address']);
                $this->row = $adrline;
                $this->Text($ccol2 + 30, $this->company['phone'], $mcol);
                $this->NewLine();
                $this->row = $adrline;
                if (isset($bankaccount['bank_name']))
                        $this->Text($mcol, $bankaccount['bank_name'], $mcol2);
-               if (isset($bankaccount['bank_address']))
-                       $adr = explode("\n", $bankaccount['bank_address']);
-               else
-                       $adr = array();
-               for ($i = 0; $i < count($adr); $i++)
-               {
-                       $this->NewLine();
-                       $this->Text($mcol, $adr[$i], $mcol2);
-               }
-
+               $this->NewLine();
+               $this->TextWrapLines($mcol, $mcol2 - $mcol, $bankaccount['bank_address']);
                $this->row = $adrline;
                if (isset($bankaccount['bank_account_name']))
                        $this->Text($mcol2, $bankaccount['bank_account_name']);
index 9b0c9d4584029006a684ecf0535e5d7a4373767a..744e92bfcbe56a86955efcbb23c7f84ccd0eddaa 100644 (file)
@@ -314,7 +314,13 @@ class FrontReport extends Cpdf
                return $this->TextWrap($this->cols2[$c], $this->row - $r, $this->cols2[$n] - $this->cols2[$c] + $corr, $txt, $this->aligns2[$c]);
        }
 
-       function TextColLines($c, $n, $txt, $corr=0)
+       function TextColLines($c, $n, $txt, $corr=0, $r=0)
+       {
+               $this->row -= $r;
+               $this->TextWrapLines($this->cols[$c], $this->cols[$n] - $this->cols[$c] + $corr, $txt, $this->aligns[$c]);
+       }
+
+       function TextWrapLines($c, $width, $txt, $align='left')
        {
                $str = Explode("\n", $txt);
                for ($i = 0; $i < count($str); $i++)
@@ -322,7 +328,7 @@ class FrontReport extends Cpdf
                        $l = $str[$i];
                        do
                        {
-                               $l = $this->TextCol($c, $n, $l, $corr);
+                               $l = $this->TextWrap($c, $this->row , $width, $l, $align);
                                $this->NewLine();
                        }
                        while ($l != '');