Added per supplier/customer document language selection.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Sun, 4 Apr 2010 12:14:13 +0000 (12:14 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Sun, 4 Apr 2010 12:14:13 +0000 (12:14 +0000)
16 files changed:
purchasing/includes/db/suppliers_db.inc
purchasing/manage/suppliers.php
reporting/includes/class.pdf.inc
reporting/includes/doctext2.inc [deleted file]
reporting/includes/pdf_report.inc
reporting/rep107.php
reporting/rep108.php
reporting/rep109.php
reporting/rep110.php
reporting/rep111.php
reporting/rep112.php
reporting/rep209.php
reporting/rep210.php
sql/alter2.3.sql
sql/en_US-demo.sql
sql/en_US-new.sql

index 305ce5df7cfa1babf49a12e2ffbabe4a4886d952..80cc0f8dd70f08902c7709bdda1f1a5c03450c25 100644 (file)
 function add_supplier($supp_name, $supp_ref, $address, $supp_address, $phone, $phone2, $fax, $gst_no, $email,
        $website, $contact, $supp_account_no, $bank_account, $credit_limit, $dimension_id, $dimension2_id, 
        $curr_code, $payment_terms, $payable_account, $purchase_account, $payment_discount_account, 
-       $notes, $tax_group_id)
+       $notes, $tax_group_id, $rep_lang)
 {
        $sql = "INSERT INTO ".TB_PREF."suppliers (supp_name, supp_ref, address, supp_address, phone, phone2, fax, gst_no, email, website,
                contact, supp_account_no, bank_account, credit_limit, dimension_id, dimension2_id, curr_code,
-               payment_terms, payable_account, purchase_account, payment_discount_account, notes, tax_group_id)
+               payment_terms, payable_account, purchase_account, payment_discount_account, notes, tax_group_id, rep_lang)
                VALUES (".db_escape($_POST['supp_name']). ", "
                .db_escape($supp_ref). ", "
                .db_escape($address) . ", "
@@ -40,7 +40,8 @@ function add_supplier($supp_name, $supp_ref, $address, $supp_address, $phone, $p
                .db_escape($purchase_account). ", "
                .db_escape($payment_discount_account). ", "
                .db_escape($notes). ", "
-               .db_escape($tax_group_id). ")";
+               .db_escape($tax_group_id). ", "
+               .db_escape($rep_lang ? $rep_lang : null, true). ")";
 
        db_query($sql,"The supplier could not be added");
 }
@@ -48,7 +49,7 @@ function add_supplier($supp_name, $supp_ref, $address, $supp_address, $phone, $p
 function update_supplier($supplier_id, $supp_name, $supp_ref, $address, $supp_address, $phone, $phone2, $fax, $gst_no, 
        $email, $website, $contact, $supp_account_no, $bank_account, $credit_limit, $dimension_id, $dimension2_id, 
        $curr_code, $payment_terms, $payable_account, $purchase_account, $payment_discount_account, 
-       $notes, $tax_group_id)
+       $notes, $tax_group_id, $rep_lang)
 {
        $sql = "UPDATE ".TB_PREF."suppliers SET supp_name=".db_escape($supp_name) . ",
                supp_ref=".db_escape($supp_ref) . ",
@@ -72,7 +73,8 @@ function update_supplier($supplier_id, $supp_name, $supp_ref, $address, $supp_ad
                purchase_account=".db_escape($purchase_account) . ",
                payment_discount_account=".db_escape($payment_discount_account) . ",
                notes=".db_escape($notes) . ",
-               tax_group_id=".db_escape($tax_group_id) . " WHERE supplier_id = ".db_escape($supplier_id);
+               tax_group_id=".db_escape($tax_group_id) . ",
+               rep_lang=".db_escape($rep_lang ? $rep_lang : null, true) . " WHERE supplier_id = ".db_escape($supplier_id);
 
        db_query($sql,"The supplier could not be updated");
 }
index f5f9445ee1c0ed433ef495547d84516b3f1f5b87..5fa45bcceb88619e99a7e40017d828f93ec8ac6e 100644 (file)
@@ -62,7 +62,7 @@ if (isset($_POST['submit']))
                                $_POST['email'], $_POST['website'], $_POST['contact'], $_POST['supp_account_no'], $_POST['bank_account'], 
                                input_num('credit_limit', 0), $_POST['dimension_id'], $_POST['dimension2_id'], $_POST['curr_code'],
                                $_POST['payment_terms'], $_POST['payable_account'], $_POST['purchase_account'], $_POST['payment_discount_account'],
-                               $_POST['notes'], $_POST['tax_group_id']);
+                               $_POST['notes'], $_POST['tax_group_id'], $_POST['rep_lang']);
                        update_record_status($_POST['supplier_id'], $_POST['inactive'],
                                'suppliers', 'supplier_id');
 
@@ -76,7 +76,7 @@ if (isset($_POST['submit']))
                                $_POST['website'], $_POST['contact'], $_POST['supp_account_no'], $_POST['bank_account'], 
                                input_num('credit_limit',0), $_POST['dimension_id'], $_POST['dimension2_id'],
                                $_POST['curr_code'], $_POST['payment_terms'], $_POST['payable_account'], $_POST['purchase_account'],
-                               $_POST['payment_discount_account'], $_POST['notes'], $_POST['tax_group_id']);
+                               $_POST['payment_discount_account'], $_POST['notes'], $_POST['tax_group_id'], $_POST['rep_lang']);
 
                        $_POST['supplier_id'] = db_insert_id();
                        $new_supplier = false;
@@ -166,6 +166,7 @@ if (!$new_supplier)
        $_POST['dimension_id']  = $myrow["dimension_id"];
        $_POST['dimension2_id']  = $myrow["dimension2_id"];
        $_POST['curr_code']  = $myrow["curr_code"];
+       $_POST['rep_lang']  = $myrow["rep_lang"];
        $_POST['payment_terms']  = $myrow["payment_terms"];
        $_POST['credit_limit']  = price_format($myrow["credit_limit"]);
        $_POST['tax_group_id'] = $myrow["tax_group_id"];
@@ -189,6 +190,7 @@ else
 
        $company_record = get_company_prefs();
        $_POST['curr_code']  = $company_record["curr_default"];
+       $_POST['rep_lang']  = $dflt_lang;
        $_POST['payable_account'] = $company_record["creditors_act"];
        $_POST['purchase_account'] = $company_record["default_cogs_act"];
        $_POST['payment_discount_account'] = $company_record['pyt_discount_act'];
@@ -229,6 +231,8 @@ else
        currencies_list_row(_("Supplier's Currency:"), 'curr_code', null);
 }
 
+languages_list_row(_("Document Language:"), 'rep_lang', null, _('System default'));
+
 tax_groups_list_row(_("Tax Group:"), 'tax_group_id', null);
 
 payment_terms_list_row(_("Payment Terms:"), 'payment_terms', null);
index 71ba2783b209e60453e91b0b9b32a27726b04710..f3e842be078dbd97a2c3f73787f160e90c890038 100644 (file)
@@ -63,24 +63,61 @@ include_once (dirname(__FILE__).'/fpdi/fpdi.php');
 
 class Cpdf extends FPDI {
 
-       function Cpdf($pageSize='A4', $l=array(), $pageOrientation='P')
+       function Cpdf($pageSize='A4', $lang=null, $pageOrientation='P')
        {
+               $this->TCPDF($pageOrientation, 'pt', $pageSize);//, $uni, $enc);
+               $this->SetLang($lang);
+               $this->setPrintHeader(false);
+               $this->setPrintFooter(false);
+               $this->setPDFVersion("1.3");
+               $this->setAutoPageBreak(0);
+               $this->SetLineWidth(1);
+               $this->cMargin = 0;
+       }
+       /*
+               Set lamguage for next report
+       */
+       function SetLang($code=null) 
+       {
+               global $installed_languages, $dflt_lang, $path_to_root;
+
+               if (!$code)
+                       $code = $dflt_lang;
+
+               $lang = array_search_value($code, $installed_languages, 'code');
+               $_SESSION['get_text']->set_language($lang['code'], strtoupper($lang['encoding']));
+               $_SESSION['get_text']->add_domain($lang['code'], $path_to_root . "/lang");
+
+               // re-read translated sys names.
+               include($path_to_root.'/includes/sysnames.inc');
+
+               $l = array('a_meta_charset' => strtoupper($lang['encoding']), 
+                       'a_meta_dir' => @$lang['rtl'] ? 'rtl' : 'ltr',
+                       'a_meta_language' => $code, 'w_page' => 'page');
+
                if (!isset($l['a_meta_charset']))
                        $l = array('a_meta_charset' => 'ISO-8859-1', 'a_meta_dir' => 'ltr', 'a_meta_language' => 'en_GB', 'w_page' => 'page');
                $enc = $l['a_meta_charset'];
                $uni = ($enc == 'UTF-8' || $enc == 'GB2312' ? true : false);
                if ($uni)
                        ini_set("memory_limit", "48M");
-               $this->TCPDF($pageOrientation, 'pt', $pageSize, $uni, $enc);
+
+               $this->isunicode = $uni;
                $this->setLanguageArray($l);
-               $this->setPrintHeader(false);
-               $this->setPrintFooter(false);
-               $this->setPDFVersion("1.3");
-               $this->setAutoPageBreak(0);
-               $this->SetLineWidth(1);
-               $this->cMargin = 0;
+               if ($uni)
+               {
+                               global $unicode, $unicode_mirror, $unicode_arlet, $laa_array, $diacritics;
+                               include_once(dirname(__FILE__)."/unicode_data2.php");
+               }
+               $this->encoding = strtoupper($lang['encoding']);
+
+               $this->FontFamily = 'helvetica';
+               $this->FontStyle = '';
+               $this->FontSizePt = 12;
+//             $this->utf8Bidi(array(""));
        }
 
+
        // $fontname should be a standard PDF font (like 'times', 'helvetica' or 'courier')
        // or one that's been installed on your system.  An empty string can also be used
        // which will retain the font currently in use.
@@ -171,24 +208,9 @@ class Cpdf extends FPDI {
 
        function addInfo($label,$value)
        {
-               if($label=='Title')
-               {
-                       $this->SetTitle($value);
-               }
-               if ($label=='Subject')
-               {
-                       $this->SetSubject($value);
-               }
-               if($label=='Creator')
-               {
-                       // The Creator info in source is not exactly it should be ;)
-                       $value = str_replace( "ros.co.nz", "tcpdf.org", $value );
-                       $value = str_replace( "R&OS", "", $value );
-                       $this->SetCreator( $value );
-               }
-               if($label=='Author')
-               {
-                       $this->SetAuthor($value);
+               if (in_array($label, array( 'Title', 'Subject', 'Author', 'Creator'))) {
+                       $seter = "Set{$label}";
+                       $this->$seter($value);
                }
        }
 
@@ -228,9 +250,9 @@ class Cpdf extends FPDI {
                parent::Ellipse($x0, $y0, $r1, $r2, $angle, $astart. $afinish, ($close?'C':''), "", "", $nSeg);
        }
 
-       function Stream()
+       function Stream($fname='')
        {
-               parent::Output('', 'I');
+               parent::Output($fname, 'I');
        }
 
        function calcTextWrap($txt, $width, $spacebreak=false)
diff --git a/reporting/includes/doctext2.inc b/reporting/includes/doctext2.inc
deleted file mode 100644 (file)
index aa5d305..0000000
+++ /dev/null
@@ -1,174 +0,0 @@
-<?php
-/**********************************************************************
-    Copyright (C) FrontAccounting, LLC.
-       Released under the terms of the GNU General Public License, GPL, 
-       as published by the Free Software Foundation, either version 3 
-       of the License, or (at your option) any later version.
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
-    See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
-***********************************************************************/
-if (isset($header2type))
-{
-       $doc_Cust_no = "Cust no";
-       $doc_Date = "Date";
-       if ($doctype == ST_PURCHORDER || $doctype == ST_SUPPAYMENT) // Purchase Order
-       {
-               $doc_Charge_To = "Order To";
-               $doc_Delivered_To = "Charge To";
-       }
-       else
-       {
-               if ($doctype == ST_CUSTPAYMENT)
-                       $doc_Charge_To = "With thanks from";
-               else    
-                       $doc_Charge_To = "Charge To";
-               $doc_Delivered_To = "Delivered To";
-       }       
-       $doc_Shipping_Company = "Shipping Company";
-       if ($doctype == ST_SALESQUOTE)
-               $doc_Due_Date = "Valid until";
-       elseif ($doctype == ST_SALESORDER)
-               $doc_Due_Date = "Delivery Date";
-       else
-               $doc_Due_Date = "Due Date";
-       $doc_Your_Ref = "Your Ref";
-       if ($doctype == ST_WORKORDER)
-       {
-               $doc_Our_Ref = "Type";
-               $doc_Your_VAT_no = "Manufactured Item";
-               $doc_Payment_Terms = "Required By";
-               $doc_Customers_Ref = "Reference";
-               $doc_Our_Order_No = "Into Location";
-               $doc_Due_Date = "Quantity";
-       }       
-       else
-       {
-               if ($doctype == ST_SUPPAYMENT || $doctype == ST_CUSTPAYMENT)
-                       $doc_Our_Ref = "Type";
-               else    
-                       $doc_Our_Ref = "Sales Person";
-               $doc_Your_VAT_no = "Your VAT no.";
-               $doc_Payment_Terms = "Payment Terms";
-               $doc_Customers_Ref = "Customers Reference";
-               $doc_Our_Order_No = "Our Order No";
-       }
-       $doc_Extra = "";
-       $doc_Our_VAT_no = "Our VAT No.";
-       $doc_Domicile = "Domicile";
-       if($doctype == ST_CUSTDELIVERY || $doctype == ST_SALESQUOTE || $doctype == ST_PURCHORDER || $doctype == ST_SALESORDER ||
-               $doctype == ST_SUPPAYMENT || $doctype == ST_CUSTPAYMENT) {
-               if ($doctype == ST_CUSTPAYMENT)
-                       $doc_Extra = "* Subject to Realisation of the Cheque.";
-               $doc_Bank_Account = '';
-               $doc_Please_Quote = "All amounts stated in";
-  } else {
-        $doc_Please_Quote = "Please quote ".($doctype==ST_SALESINVOICE ? "Invoice" : "Credit")
-               ." no. when paying. All amounts stated in";
-        $doc_Bank_Account = "Bank Account";
-       }
-       $doc_Address = "Address";
-       $doc_Phone_Fax_Email = "Phone/Fax/Email";
-       $doc_Bank = "Bank";
-       $doc_Payment_Link = "You can pay through";
-       if ($doctype == ST_SALESQUOTE || $doctype == ST_PURCHORDER || $doctype == ST_SALESORDER || $doctype == ST_SALESINVOICE || 
-               $doctype == ST_CUSTCREDIT || $doctype == ST_CUSTDELIVERY || $doctype == ST_WORKORDER || $doctype == ST_SUPPAYMENT || 
-               $doctype == ST_CUSTPAYMENT)
-       {
-               if ($doctype == ST_SALESQUOTE)
-                       $this->title = "SALES QUOTATION";
-               elseif ($doctype == ST_PURCHORDER)
-                       $this->title = "PURCHASE ORDER";
-               elseif ($doctype == ST_SALESORDER)
-                       $this->title = ($print_as_quote==1 ? "QUOTE" : "SALES ORDER");
-               elseif ($doctype == ST_SALESINVOICE)
-                       $this->title = "INVOICE";
-               elseif ($doctype == ST_CUSTDELIVERY)
-                       $this->title = ($packing_slip==1 ? "PACKING SLIP" : "DELIVERY NOTE");
-               elseif ($doctype == ST_WORKORDER)
-                       $this->title = "WORK ORDER";
-               elseif ($doctype == ST_SUPPAYMENT)
-                       $this->title = "REMITTANCE";
-               elseif ($doctype == ST_CUSTPAYMENT)
-                       $this->title = "RECEIPT";
-               else
-                       $this->title = "CREDIT NOTE";
-               if ($doctype == ST_PURCHORDER)
-                       $this->headers = array('Item Code', 'Item Description', 'Delivery Date',
-                               'Quantity', 'Unit',     'Price', 'Total');
-               elseif ($doctype == ST_WORKORDER)
-                       $this->headers = array("Item Code", "Item Description",
-                               "From Location", "Work Centre",         "Unit Quantity", "Total Quantity", "Units Issued");
-               elseif ($doctype == ST_SUPPAYMENT || $doctype == ST_CUSTPAYMENT)
-                       $this->headers = array('Trans Type', '#', 'Date', 'Due Date', 'Total Amount', 'Left to Allocate', 'This Allocation');
-               else
-                       $this->headers = array('Item Code', 'Item Description', 'Quantity', 'Unit',
-                               'Price', 'Discount %', 'Total');
-       }
-       elseif ($doctype == ST_STATEMENT)
-       {
-               $this->title = "STATEMENT";
-               $this->headers = array('Trans Type', '#', 'Date', 'Due Date', 'Charges',
-                       'Credits', 'Allocated', 'Outstanding');
-       }
-}
-if (isset($emailtype))
-{
-       $doc_Dear_Sirs = "Dear";
-       $doc_AttachedFile = "Attached you will find ";
-       $doc_Kindest_regards = "Kindest regards";
-       $doc_Payment_Link = "You can pay through";
-}
-if (isset($header2type) || isset($linetype))
-{
-       $doc_Invoice_no = ($doctype==ST_CUSTDELIVERY ? "Delivery Note No." :
-               ($doctype == ST_CUSTPAYMENT ? "Receipt No." :
-               ($doctype == ST_SUPPAYMENT ? "Remittance No." :
-               (($doctype == ST_SALESQUOTE || $doctype==ST_PURCHORDER || $doctype==ST_SALESORDER) ? "Order no." : 
-               ($doctype==ST_SALESINVOICE ? "Invoice No." : ($doctype == ST_WORKORDER ? "Work Order No." : "Credit No."))))));
-       $doc_Delivery_no = "Delivery Note No.";
-       $doc_Order_no = "Order No.";
-}
-if (isset($linetype))
-{
-       if ($doctype == ST_SALESQUOTE || $doctype == ST_PURCHORDER || $doctype == ST_SALESORDER || $doctype == ST_SALESINVOICE || 
-               $doctype == ST_CUSTCREDIT || $doctype == ST_CUSTDELIVERY)
-       {
-               $doc_Sub_total = "Sub-total";
-               $doc_Shipping = "Shipping";
-               $doc_Included = "Included";
-               $doc_Amount = "amount";
-               $doc_TOTAL_INVOICE = $doctype==ST_SALESINVOICE ? "TOTAL INVOICE" : "TOTAL CREDIT";
-               $doc_TOTAL_ORDER = "TOTAL ORDER EX VAT";
-               $doc_TOTAL_ORDER2 = "TOTAL ORDER VAT INCL.";
-               $doc_TOTAL_PO = "TOTAL PO EX VAT";
-               $doc_TOTAL_DELIVERY = "TOTAL DELIVERY INCL. VAT";
-       }
-       elseif ($doctype == ST_SUPPAYMENT || $doctype == ST_CUSTPAYMENT)
-       {
-               $doc_Towards = "As advance / full / part / payment towards:";
-               $doc_by_Cheque = "By Cash / Cheque* / Draft No.";
-               $doc_Dated = "Dated";
-               $doc_Drawn = "Drawn on Bank";
-               $doc_Drawn_Branch = "Branch";
-               $doc_Received = "Received / Sign";
-               $doc_Total_Allocated = "Total Allocated";
-               $doc_Left_To_Allocate = "Left to Allocate";
-               if ($doctype == ST_CUSTPAYMENT)
-                       $doc_Total_Payment = "TOTAL RECEIPT";
-               else    
-                       $doc_Total_Payment = "TOTAL REMITTANCE";
-       }
-       elseif ($doctype == ST_STATEMENT)
-       {
-               $doc_Outstanding = "Outstanding Transactions";
-               $doc_Current = "Current";
-               $doc_Total_Balance = "Total Balance";
-               $doc_Statement = "Statement";
-               $doc_as_of = "as of";
-               $doc_Days = "Days";
-               $doc_Over = "Over";
-       }
-}
-?>
\ No newline at end of file
index 414151bafa3c8501e34d382bcaf7f586d0c50bf6..fdef22d2e763477de9a87dbd24214601c2bc274d 100644 (file)
@@ -219,13 +219,8 @@ class FrontReport extends Cpdf
                $this->currency = '';
                $this->scaleLogoWidth = false; // if Logo, scale on width (else height).
                $this->SetHeaderType('Header'); // default
-               
-               $rtl = ($_SESSION['language']->dir === 'rtl' ? 'rtl' : 'ltr');
-               $code = $_SESSION['language']->code;
-               $enc = strtoupper($_SESSION['language']->encoding);
-               // for the language array in class.pdf.inc
-               $l = array('a_meta_charset' => $enc, 'a_meta_dir' => $rtl, 'a_meta_language' => $code, 'w_page' => 'page');
-               $this->Cpdf($size, $l, $orientation);
+
+               $this->Cpdf($size, $_SESSION['language']->code, $orientation);
        }
        
        /*
@@ -390,22 +385,24 @@ class FrontReport extends Cpdf
                        'DebtorName', 'supp_account_no', 'wo_ref', 'debtor_ref','type', 'trans_no', 
                        'StockItemName', 'tax_id', 'order_', 'delivery_date', 'units_issued',
                        'due_date', 'required_by', 'payment_terms', 'curr_code',
-                       'ov_freight', 'ov_gst', 'ov_amount'),
-               'branch' => array('br_address', 'br_name', 'salesman', 'disable_branch'),
+                       'ov_freight', 'ov_gst', 'ov_amount', 'rep_lang'),
+               'branch' => array('br_address', 'br_name', 'salesman', 'disable_branch', 'rep_lang'),
                'sales_order' => array('deliver_to', 'delivery_address', 'customer_ref'),
                'bankaccount' => array('bank_name', 'bank_account_number')
                );
-       
+
                foreach($datnames as $var => $fields) {
                        if (isset($$var)) {
                                foreach($fields as $locname) {
-                                       if (isset(${$var}[$locname])) {
+                                       if (isset(${$var}[$locname]) && (${$var}[$locname]!==null)) {
                                                $this->formData[$locname] = ${$var}[$locname];
                                        }
                                }
                        }
                }
                $this->formData['doctype'] = $doctype;
+               error_log('cust:'.var_export($myrow, true));
+               error_log('branch:'.var_export($branch, true));
        }
        /*
                Set header handler
@@ -418,22 +415,17 @@ class FrontReport extends Cpdf
        */
        function Header2()
        {
-               global $comp_path, $path_to_root, $print_as_quote, $print_invoice_no, $packing_slip; // FIXME
+               global $path_to_root, $print_as_quote,
+                       $print_invoice_no, $packing_slip, $dflt_lang; // FIXME should be passed as params
 
                $doctype = $this->formData['doctype'];
                $header2type = true;
                
+               $this->SetLang(@$this->formData['rep_lang'] ? $this->formData['rep_lang'] : $dflt_lang);
+
                 // 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("includes/doctext2.inc");
-               }
-               else
-               {
-                       include("includes/doctext.inc");
-               }
-               
+                // modified versions from company/x/reporting directory
+               include("includes/doctext.inc");
                include("includes/header2.inc");
 
                $this->row = $temp;
@@ -442,8 +434,6 @@ class FrontReport extends Cpdf
        // Alternate header style which also supports a simple footer
        function Header3()
        {
-               global $comp_path;
-
                // Turn off cell padding for the main report header, restoring the current setting later
                $oldcMargin = $this->cMargin;
                $this->SetCellPadding(0);
@@ -524,7 +514,7 @@ class FrontReport extends Cpdf
                if ($this->companyLogoEnable && ($this->company['coy_logo'] != ''))
                {
                        // Build a string specifying the location of the company logo file
-                       $logo = $comp_path .'/'. user_company() . "/images/" . $this->company['coy_logo'];
+                       $logo = company_path() . "/images/" . $this->company['coy_logo'];
 
                        // Width being zero means that the image will be scaled to the specified height
                        // keeping its aspect ratio intact.
@@ -965,7 +955,7 @@ class FrontReport extends Cpdf
 
        function End($email=0, $subject=null, $myrow=null, $doctype = 0)
        {
-               global $pdf_debug, $path_to_root, $comp_path;
+               global $pdf_debug, $path_to_root;
 
                if ($pdf_debug == 1)
                {
@@ -978,7 +968,7 @@ class FrontReport extends Cpdf
                else
                {
 
-                       $dir =  $comp_path.'/'.user_company(). '/pdf_files';
+                       $dir =  company_path(). '/pdf_files';
                        //save the file
                        if (!file_exists($dir))
                        {
@@ -991,17 +981,13 @@ class FrontReport extends Cpdf
                        else    
                                $fname = $dir.'/'.uniqid('').'.pdf';
                        $this->Output($fname, 'F');
+
                        if ($email == 1)
                        {
                                $emailtype = true;
-                               if ($this->currency != $myrow['curr_code'])
-                               {
-                                       include("includes/doctext2.inc");
-                               }
-                               else
-                               {
-                                       include("includes/doctext.inc");
-                               }
+                               $this->SetLang($this->formData['rep_lang']);
+                               include("includes/doctext.inc");
+
                                require_once($path_to_root . "/reporting/includes/class.mail.inc");
                        $mail = new email(str_replace(",", "", $this->company['coy_name']), $this->company['email']);
                                if (!isset($myrow['email']) || $myrow['email'] == '') 
@@ -1039,7 +1025,7 @@ class FrontReport extends Cpdf
                        {
                                $printer = get_report_printer(user_print_profile(), $this->rep_id);
                                if ($printer == false) {
-                                       if(in_ajax()) {
+                                       if (in_ajax()) {
                                                global $Ajax;
 
                                                if (user_rep_popup()) 
@@ -1047,13 +1033,13 @@ class FrontReport extends Cpdf
                                                else
                                                        $Ajax->redirect($fname); // otherwise use faster method
                                        } else {
-                       header('Content-type: application/pdf');
-                   header("Content-Disposition: inline; filename=$this->filename");
-                       header('Expires: 0');
-                   header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
-                       header('Pragma: public');
-
-                       $this->Stream();
+                                               header('Content-type: application/pdf');
+                                               header('Content-Disposition: inline; filename='.$this->filename);
+                                               header('Expires: 0');
+                                               header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
+                                               header('Pragma: public');
+//                                             $this->Stream(basename($fname));
+                                               $this->Stream($this->filename);
                                        }
                                } else { // send report to network printer
                                        $prn = new remote_printer($printer['queue'],$printer['host'],
index d80046525d51e41f4f15aef17af756c017e05c23..ea5234ae13fa086cd8a7945e8fc08c1bb72e905f 100644 (file)
@@ -159,14 +159,7 @@ function print_invoices()
                $rep->row = $rep->bottomMargin + (15 * $rep->lineHeight);
                        $linetype = true;
                        $doctype = $j;
-                       if ($rep->currency != $myrow['curr_code'])
-                       {
-                               include($path_to_root . "/reporting/includes/doctext2.inc");
-                       }
-                       else
-                       {
-                               include($path_to_root . "/reporting/includes/doctext.inc");
-                       }
+                       include($path_to_root . "/reporting/includes/doctext.inc");
 
                        $rep->TextCol(3, 6, $doc_Sub_total, -2);
                        $rep->TextCol(6, 7,     $DisplaySubTot, -2);
index 56a09b4d5dce4a256813d0e28ba032de8c6a5fdb..3396fc1ac28ec0d9262f0beefd1cb3d6249517cb 100644 (file)
@@ -81,7 +81,7 @@ function print_statements()
                $rep->Info($params, $cols, null, $aligns);
        }
 
-       $sql = "SELECT debtor_no, name AS DebtorName, address, tax_id, email, curr_code, curdate() AS tran_date FROM ".TB_PREF."debtors_master";
+       $sql = "SELECT debtor_no, name AS DebtorName, address, tax_id, email, curr_code, curdate() AS tran_date, rep_lang FROM ".TB_PREF."debtors_master";
        if ($customer != ALL_NUMERIC)
                $sql .= " WHERE debtor_no = ".db_escape($customer);
        else
@@ -114,14 +114,7 @@ function print_statements()
                $rep->NewLine();
                $linetype = true;
                $doctype = ST_STATEMENT;
-               if ($rep->currency != $myrow['curr_code'])
-               {
-                       include($path_to_root . "/reporting/includes/doctext2.inc");
-               }
-               else
-               {
-                       include($path_to_root . "/reporting/includes/doctext.inc");
-               }
+               include($path_to_root . "/reporting/includes/doctext.inc");
                $rep->fontSize += 2;
                $rep->TextCol(0, 8, $doc_Outstanding);
                $rep->fontSize -= 2;
index 96b972ed3d2d4e4430853af070193d5c758ddcfb..acb0e2e6c2bafea4fcd3e745b75b713aa84689e4 100644 (file)
@@ -139,14 +139,7 @@ function print_sales_orders()
                $rep->row = $rep->bottomMargin + (15 * $rep->lineHeight);
                $linetype = true;
                $doctype = ST_SALESORDER;
-               if ($rep->currency != $myrow['curr_code'])
-               {
-                       include($path_to_root . "/reporting/includes/doctext2.inc");
-               }
-               else
-               {
-                       include($path_to_root . "/reporting/includes/doctext.inc");
-               }
+               include($path_to_root . "/reporting/includes/doctext.inc");
 
                $rep->TextCol(3, 6, $doc_Sub_total, -2);
                $rep->TextCol(6, 7,     $DisplaySubTot, -2);
index ca7a27fbf676873e5f5545a93cebba63368ee62e..eed61e6ce8077efbfd86f042b9be0f5013905ebe 100644 (file)
@@ -154,14 +154,7 @@ function print_deliveries()
                $rep->row = $rep->bottomMargin + (15 * $rep->lineHeight);
                        $linetype = true;
                        $doctype=ST_CUSTDELIVERY;
-                       if ($rep->currency != $myrow['curr_code'])
-                       {
-                               include($path_to_root . "/reporting/includes/doctext2.inc");
-                       }
-                       else
-                       {
-                               include($path_to_root . "/reporting/includes/doctext.inc");
-                       }
+                       include($path_to_root . "/reporting/includes/doctext.inc");
                        if ($packing_slip == 0)
                        {
                                $rep->TextCol(3, 6, $doc_Sub_total, -2);
index e3b0ab1fcddf684a6e85cc4cc3da6d96ff4b1e15..c5bed8d12f51c738ef94014ad6163f50557b4b9d 100644 (file)
@@ -124,14 +124,7 @@ function print_sales_quotations()
                $rep->row = $rep->bottomMargin + (15 * $rep->lineHeight);
                $linetype = true;
                $doctype = ST_SALESQUOTE;
-               if ($rep->currency != $myrow['curr_code'])
-               {
-                       include($path_to_root . "/reporting/includes/doctext2.inc");
-               }
-               else
-               {
-                       include($path_to_root . "/reporting/includes/doctext.inc");
-               }
+               include($path_to_root . "/reporting/includes/doctext.inc");
 
                $rep->TextCol(3, 6, $doc_Sub_total, -2);
                $rep->TextCol(6, 7,     $DisplaySubTot, -2);
index dd051b1c7f54411859790667b87baf7bc8844e67..9b22e04a07b42ec48bc642c803465e344981a3cb 100644 (file)
@@ -35,7 +35,8 @@ function get_receipt($type, $trans_no)
                                (".TB_PREF."debtor_trans.ov_amount + ".TB_PREF."debtor_trans.ov_gst + ".TB_PREF."debtor_trans.ov_freight + 
                                ".TB_PREF."debtor_trans.ov_freight_tax + ".TB_PREF."debtor_trans.ov_discount) AS Total, 
                                ".TB_PREF."debtors_master.name AS DebtorName,  ".TB_PREF."debtors_master.debtor_ref,
-                               ".TB_PREF."debtors_master.curr_code, ".TB_PREF."debtors_master.payment_terms, ".TB_PREF."debtors_master.tax_id AS tax_id, 
+                               ".TB_PREF."debtors_master.curr_code, ".TB_PREF."debtors_master.payment_terms, "
+                               .TB_PREF."debtors_master.tax_id AS tax_id,".TB_PREF."debtors_master.rep_lang,
                                ".TB_PREF."debtors_master.email, ".TB_PREF."debtors_master.address
                        FROM ".TB_PREF."debtor_trans, ".TB_PREF."debtors_master 
                                WHERE ".TB_PREF."debtor_trans.debtor_no = ".TB_PREF."debtors_master.debtor_no
@@ -115,14 +116,7 @@ function print_receipts()
 
                        $linetype = true;
                        $doctype = ST_CUSTPAYMENT;
-                       if ($rep->currency != $myrow['curr_code'])
-                       {
-                               include($path_to_root . "/reporting/includes/doctext2.inc");
-                       }
-                       else
-                       {
-                               include($path_to_root . "/reporting/includes/doctext.inc");
-                       }
+                       include($path_to_root . "/reporting/includes/doctext.inc");
 
                        $total_allocated = 0;
                        $rep->TextCol(0, 4,     $doc_Towards, -2);
index 57c55ae39d29a0a9a99b9b59195ad46d32d925f4..767270fc742bafa8b2c34544b4ed8d3de076002c 100644 (file)
@@ -31,7 +31,8 @@ print_po();
 //----------------------------------------------------------------------------------------------------
 function get_po($order_no)
 {
-       $sql = "SELECT ".TB_PREF."purch_orders.*, ".TB_PREF."suppliers.supp_name,  ".TB_PREF."suppliers.supp_account_no,
+       $sql = "SELECT ".TB_PREF."purch_orders.*, ".TB_PREF."suppliers.supp_name,  "
+               .TB_PREF."suppliers.rep_lang,  ".TB_PREF."suppliers.supp_account_no,
                ".TB_PREF."suppliers.curr_code, ".TB_PREF."suppliers.payment_terms, ".TB_PREF."locations.location_name,
                ".TB_PREF."suppliers.email, ".TB_PREF."suppliers.address, ".TB_PREF."suppliers.contact
                FROM ".TB_PREF."purch_orders, ".TB_PREF."suppliers, ".TB_PREF."locations
@@ -154,14 +155,7 @@ function print_po()
                $rep->row = $rep->bottomMargin + (15 * $rep->lineHeight);
                $linetype = true;
                $doctype = ST_PURCHORDER;
-               if ($rep->currency != $myrow['curr_code'])
-               {
-                       include($path_to_root . "/reporting/includes/doctext2.inc");
-               }
-               else
-               {
-                       include($path_to_root . "/reporting/includes/doctext.inc");
-               }
+               include($path_to_root . "/reporting/includes/doctext.inc");
 
                $rep->TextCol(3, 6, $doc_Sub_total, -2);
                $rep->TextCol(6, 7,     $DisplaySubTot, -2);
index 376f1c87dca672b368c0236acd934e9705bd0d84..240dade64d741a16c9b4f4ecaf29d50800eaf6bb 100644 (file)
@@ -33,7 +33,7 @@ function get_remittance($type, $trans_no)
 {
        $sql = "SELECT ".TB_PREF."supp_trans.*, 
                (".TB_PREF."supp_trans.ov_amount+".TB_PREF."supp_trans.ov_gst+".TB_PREF."supp_trans.ov_discount) AS Total, 
-               ".TB_PREF."suppliers.supp_name,  ".TB_PREF."suppliers.supp_account_no,
+               ".TB_PREF."suppliers.supp_name,  ".TB_PREF."suppliers.supp_account_no, ".TB_PREF."suppliers.rep_lang,
                ".TB_PREF."suppliers.curr_code, ".TB_PREF."suppliers.payment_terms, ".TB_PREF."suppliers.gst_no AS tax_id, 
                ".TB_PREF."suppliers.email, ".TB_PREF."suppliers.address, ".TB_PREF."suppliers.contact
                FROM ".TB_PREF."supp_trans, ".TB_PREF."suppliers
@@ -129,14 +129,7 @@ function print_remittances()
 
                        $linetype = true;
                        $doctype = ST_SUPPAYMENT;
-                       if ($rep->currency != $myrow['curr_code'])
-                       {
-                               include($path_to_root . "/reporting/includes/doctext2.inc");
-                       }
-                       else
-                       {
-                               include($path_to_root . "/reporting/includes/doctext.inc");
-                       }
+                       include($path_to_root . "/reporting/includes/doctext.inc");
 
                        $total_allocated = 0;
                        $rep->TextCol(0, 4,     $doc_Towards, -2);
index afb3e9206bdefda782fcf0b39f67018055ddb555..0a52f483453daaf489b5f502808d90850122aa7e 100644 (file)
@@ -152,3 +152,11 @@ ALTER TABLE `0_chart_types` CHANGE `parent` `parent` VARCHAR(10) NOT NULL DEFAUL
 ALTER TABLE `0_chart_types` CHANGE `class_id` `class_id` VARCHAR(3) NOT NULL DEFAULT '';
 .
 UPDATE `0_chart_types` SET parent='' WHERE parent='0' OR parent='-1';
+
+ALTER TABLE `0_debtors_master` ADD COLUMN  `rep_lang` char(5) default NULL;
+UPDATE `0_debtors_master` set `rep_lang`= 'en_GB' WHERE `curr_code`<>(SELECT value FROM `0_sys_prefs` WHERE name='curr_default');
+
+ALTER TABLE `0_cust_branch` ADD COLUMN  `rep_lang` char(5) default NULL;
+
+ALTER TABLE `0_suppliers` ADD COLUMN  `rep_lang` char(5) default NULL;
+UPDATE `0_suppliers` set `rep_lang`= 'en_GB' WHERE `curr_code`<>(SELECT value FROM `0_sys_prefs` WHERE name='curr_default');
index 6373df64632dfe640e3d70c056ee31ce067e0dc7..4e257bf4e4e612eefa3d20e019e0e795a5863358 100644 (file)
@@ -520,6 +520,7 @@ CREATE TABLE `0_cust_branch` (
   `br_post_address` tinytext NOT NULL,
   `group_no` int(11) NOT NULL default '0',
   `notes` tinytext NOT NULL,
+  `rep_lang` char(5) default NULL,
   `inactive` tinyint(1) NOT NULL default '0',
   PRIMARY KEY  (`branch_code`,`debtor_no`),
   KEY `branch_code` (`branch_code`),
@@ -530,9 +531,9 @@ CREATE TABLE `0_cust_branch` (
 
 ### Data of table `0_cust_branch` ###
 
-INSERT INTO `0_cust_branch` VALUES ('1', '1', 'Beefeater Ltd.', 'Beefeater', '', '1', '1', '', '', '', 'Main Branch', '', 'DEF', '2', '', '4510', '1200', '4500', '1', '0', 'Address 1\r\nAddress 2\r\nAddress 3', '0', '', '0');
-INSERT INTO `0_cust_branch` VALUES ('2', '2', 'Ghostbusters Corp.', 'Ghostbusters', 'Address 1\r\nAddress 2\r\nAddress 3', '1', '1', '', '', '', 'Main Branch', '', 'DEF', '1', '', '4510', '1200', '4500', '1', '0', 'Address 1\r\nAddress 2\r\nAddress 3', '0', '', '0');
-INSERT INTO `0_cust_branch` VALUES ('3', '3', 'Brezan', 'Brezan', 'Address 1\r\nAddress 2\r\nAddress 3', '1', '1', '', '', '', 'Main Branch', '', 'DEF', '1', '', '4510', '1200', '4500', '1', '0', 'Address 1\r\nAddress 2\r\nAddress 3', '0', '', '0');
+INSERT INTO `0_cust_branch` VALUES ('1', '1', 'Beefeater Ltd.', 'Beefeater', '', '1', '1', '', '', '', 'Main Branch', '', 'DEF', '2', '', '4510', '1200', '4500', '1', '0', 'Address 1\r\nAddress 2\r\nAddress 3', '0', '', '', '0');
+INSERT INTO `0_cust_branch` VALUES ('2', '2', 'Ghostbusters Corp.', 'Ghostbusters', 'Address 1\r\nAddress 2\r\nAddress 3', '1', '1', '', '', '', 'Main Branch', '', 'DEF', '1', '', '4510', '1200', '4500', '1', '0', 'Address 1\r\nAddress 2\r\nAddress 3', '0', '', '', '0');
+INSERT INTO `0_cust_branch` VALUES ('3', '3', 'Brezan', 'Brezan', 'Address 1\r\nAddress 2\r\nAddress 3', '1', '1', '', '', '', 'Main Branch', '', 'DEF', '1', '', '4510', '1200', '4500', '1', '0', 'Address 1\r\nAddress 2\r\nAddress 3', '0', '', '', '0');
 
 
 ### Structure of table `0_debtor_trans` ###
@@ -625,6 +626,7 @@ CREATE TABLE `0_debtors_master` (
   `email` varchar(100) NOT NULL default '',
   `tax_id` varchar(55) NOT NULL default '',
   `curr_code` char(3) NOT NULL default '',
+  `rep_lang` char(5) default NULL,
   `sales_type` int(11) NOT NULL default '1',
   `dimension_id` int(11) NOT NULL default '0',
   `dimension2_id` int(11) NOT NULL default '0',
@@ -643,9 +645,9 @@ CREATE TABLE `0_debtors_master` (
 
 ### Data of table `0_debtors_master` ###
 
-INSERT INTO `0_debtors_master` VALUES ('1', 'Beefeater Ltd.', 'Beefeater', 'Addr 1\r\nAddr 2\r\nAddr 3', '', '345678', 'GBP', '2', '0', '0', '1', '3', '0', '0', '1000', '', '0');
-INSERT INTO `0_debtors_master` VALUES ('2', 'Ghostbusters Corp.', 'Ghostbusters', 'Address 1\r\nAddress 2\r\nAddress 3', '', '2222222', 'USD', '1', '0', '0', '1', '4', '0', '0', '1000', '', '0');
-INSERT INTO `0_debtors_master` VALUES ('3', 'Brezan', 'Brezan', 'Address 1\r\nAddress 2\r\nAddress 3', '', '7777777', 'EUR', '2', '0', '0', '1', '3', '0', '0', '1000', '', '0');
+INSERT INTO `0_debtors_master` VALUES ('1', 'Beefeater Ltd.', 'Beefeater', 'Addr 1\r\nAddr 2\r\nAddr 3', '', '345678', 'GBP', '', '2', '0', '0', '1', '3', '0', '0', '1000', '', '0');
+INSERT INTO `0_debtors_master` VALUES ('2', 'Ghostbusters Corp.', 'Ghostbusters', 'Address 1\r\nAddress 2\r\nAddress 3', '', '2222222', 'USD', '', '1', '0', '0', '1', '4', '0', '0', '1000', '', '0');
+INSERT INTO `0_debtors_master` VALUES ('3', 'Brezan', 'Brezan', 'Address 1\r\nAddress 2\r\nAddress 3', '', '7777777', 'EUR', '', '2', '0', '0', '1', '3', '0', '0', '1000', '', '0');
 
 
 ### Structure of table `0_dimensions` ###
@@ -1745,6 +1747,7 @@ CREATE TABLE `0_suppliers` (
   `website` varchar(100) NOT NULL default '',
   `bank_account` varchar(60) NOT NULL default '',
   `curr_code` char(3) default NULL,
+  `rep_lang` char(5) default NULL,
   `payment_terms` int(11) default NULL,
   `dimension_id` int(11) default '0',
   `dimension2_id` int(11) default '0',
@@ -1762,9 +1765,9 @@ CREATE TABLE `0_suppliers` (
 
 ### Data of table `0_suppliers` ###
 
-INSERT INTO `0_suppliers` VALUES ('1', 'Junk Beer ApS', 'Junk Beer', 'Mailing 1\r\nMailing 2\r\nMailing 3', 'Address 1\r\nAddress 2\r\nAddress 3', '+45 55667788', '', '', '123456', 'Contact', '111', '', '', '', 'DKK', '3', '1', '0', '2', '1', '5010', '2100', '5060', 'A supplier with junk beers.', '0');
-INSERT INTO `0_suppliers` VALUES ('2', 'Lucky Luke Inc.', 'Lucky Luke', 'Mailing 1\r\nMailing 2\r\nMailing 3', 'Address 1\r\nAddress 2\r\nAddress 3', '(111) 222.333.444', '', '', '654321', 'Luke', '333', '', '', '', 'USD', '3', '0', '0', '1', '1', '5010', '2100', '5060', '', '0');
-INSERT INTO `0_suppliers` VALUES ('3', 'Money Makers Ltd.', 'Money Makers', 'Mailing 1\r\nMailing 2\r\nMailing 3', 'Address 1\r\nAddress 2\r\nAddress 3', '+44 444 555 666', '', '', '987654', 'Makers', '222', '', '', '', 'GBP', '3', '0', '0', '2', '1', '5010', '2100', '5060', '', '0');
+INSERT INTO `0_suppliers` VALUES ('1', 'Junk Beer ApS', 'Junk Beer', 'Mailing 1\r\nMailing 2\r\nMailing 3', 'Address 1\r\nAddress 2\r\nAddress 3', '+45 55667788', '', '', '123456', 'Contact', '111', '', '', '', 'DKK', '', '3', '1', '0', '2', '1', '5010', '2100', '5060', 'A supplier with junk beers.', '0');
+INSERT INTO `0_suppliers` VALUES ('2', 'Lucky Luke Inc.', 'Lucky Luke', 'Mailing 1\r\nMailing 2\r\nMailing 3', 'Address 1\r\nAddress 2\r\nAddress 3', '(111) 222.333.444', '', '', '654321', 'Luke', '333', '', '', '', 'USD', '', '3', '0', '0', '1', '1', '5010', '2100', '5060', '', '0');
+INSERT INTO `0_suppliers` VALUES ('3', 'Money Makers Ltd.', 'Money Makers', 'Mailing 1\r\nMailing 2\r\nMailing 3', 'Address 1\r\nAddress 2\r\nAddress 3', '+44 444 555 666', '', '', '987654', 'Makers', '222', '', '', '', 'GBP', '', '3', '0', '0', '2', '1', '5010', '2100', '5060', '', '0');
 
 ### Structure of table `0_sys_prefs` ###
 
index 613b2b73c0385c79f7309b26535f1bfb49be0038..30f624daef773fa0d4f92d09e98b2a66f2f6ed1c 100644 (file)
@@ -501,6 +501,7 @@ CREATE TABLE `0_cust_branch` (
   `br_post_address` tinytext NOT NULL,
   `group_no` int(11) NOT NULL default '0',
   `notes` tinytext NOT NULL,
+  `rep_lang` char(5) default NULL,
   `inactive` tinyint(1) NOT NULL default '0',
   PRIMARY KEY  (`branch_code`,`debtor_no`),
   KEY `branch_code` (`branch_code`),
@@ -587,6 +588,7 @@ CREATE TABLE `0_debtors_master` (
   `email` varchar(100) NOT NULL default '',
   `tax_id` varchar(55) NOT NULL default '',
   `curr_code` char(3) NOT NULL default '',
+  `rep_lang` char(5) default NULL,
   `sales_type` int(11) NOT NULL default '1',
   `dimension_id` int(11) NOT NULL default '0',
   `dimension2_id` int(11) NOT NULL default '0',
@@ -1527,6 +1529,7 @@ CREATE TABLE `0_suppliers` (
   `website` varchar(100) NOT NULL default '',
   `bank_account` varchar(60) NOT NULL default '',
   `curr_code` char(3) default NULL,
+  `rep_lang` char(5) default NULL,
   `payment_terms` int(11) default NULL,
   `dimension_id` int(11) default '0',
   `dimension2_id` int(11) default '0',