From e6cf9a74a7852b3ae2e4ebb794a755b6a90ad486 Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Sun, 4 Apr 2010 12:14:13 +0000 Subject: [PATCH] Added per supplier/customer document language selection. --- purchasing/includes/db/suppliers_db.inc | 12 +- purchasing/manage/suppliers.php | 8 +- reporting/includes/class.pdf.inc | 78 +++++++---- reporting/includes/doctext2.inc | 174 ------------------------ reporting/includes/pdf_report.inc | 72 ++++------ reporting/rep107.php | 9 +- reporting/rep108.php | 11 +- reporting/rep109.php | 9 +- reporting/rep110.php | 9 +- reporting/rep111.php | 9 +- reporting/rep112.php | 12 +- reporting/rep209.php | 12 +- reporting/rep210.php | 11 +- sql/alter2.3.sql | 8 ++ sql/en_US-demo.sql | 21 +-- sql/en_US-new.sql | 3 + 16 files changed, 129 insertions(+), 329 deletions(-) delete mode 100644 reporting/includes/doctext2.inc diff --git a/purchasing/includes/db/suppliers_db.inc b/purchasing/includes/db/suppliers_db.inc index 305ce5df..80cc0f8d 100644 --- a/purchasing/includes/db/suppliers_db.inc +++ b/purchasing/includes/db/suppliers_db.inc @@ -13,11 +13,11 @@ 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"); } diff --git a/purchasing/manage/suppliers.php b/purchasing/manage/suppliers.php index f5f9445e..5fa45bcc 100644 --- a/purchasing/manage/suppliers.php +++ b/purchasing/manage/suppliers.php @@ -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); diff --git a/reporting/includes/class.pdf.inc b/reporting/includes/class.pdf.inc index 71ba2783..f3e842be 100644 --- a/reporting/includes/class.pdf.inc +++ b/reporting/includes/class.pdf.inc @@ -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 index aa5d3055..00000000 --- a/reporting/includes/doctext2.inc +++ /dev/null @@ -1,174 +0,0 @@ -. -***********************************************************************/ -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 diff --git a/reporting/includes/pdf_report.inc b/reporting/includes/pdf_report.inc index 414151ba..fdef22d2 100644 --- a/reporting/includes/pdf_report.inc +++ b/reporting/includes/pdf_report.inc @@ -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'], diff --git a/reporting/rep107.php b/reporting/rep107.php index d8004652..ea5234ae 100644 --- a/reporting/rep107.php +++ b/reporting/rep107.php @@ -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); diff --git a/reporting/rep108.php b/reporting/rep108.php index 56a09b4d..3396fc1a 100644 --- a/reporting/rep108.php +++ b/reporting/rep108.php @@ -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; diff --git a/reporting/rep109.php b/reporting/rep109.php index 96b972ed..acb0e2e6 100644 --- a/reporting/rep109.php +++ b/reporting/rep109.php @@ -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); diff --git a/reporting/rep110.php b/reporting/rep110.php index ca7a27fb..eed61e6c 100644 --- a/reporting/rep110.php +++ b/reporting/rep110.php @@ -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); diff --git a/reporting/rep111.php b/reporting/rep111.php index e3b0ab1f..c5bed8d1 100644 --- a/reporting/rep111.php +++ b/reporting/rep111.php @@ -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); diff --git a/reporting/rep112.php b/reporting/rep112.php index dd051b1c..9b22e04a 100644 --- a/reporting/rep112.php +++ b/reporting/rep112.php @@ -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); diff --git a/reporting/rep209.php b/reporting/rep209.php index 57c55ae3..767270fc 100644 --- a/reporting/rep209.php +++ b/reporting/rep209.php @@ -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); diff --git a/reporting/rep210.php b/reporting/rep210.php index 376f1c87..240dade6 100644 --- a/reporting/rep210.php +++ b/reporting/rep210.php @@ -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); diff --git a/sql/alter2.3.sql b/sql/alter2.3.sql index afb3e920..0a52f483 100644 --- a/sql/alter2.3.sql +++ b/sql/alter2.3.sql @@ -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'); diff --git a/sql/en_US-demo.sql b/sql/en_US-demo.sql index 6373df64..4e257bf4 100644 --- a/sql/en_US-demo.sql +++ b/sql/en_US-demo.sql @@ -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` ### diff --git a/sql/en_US-new.sql b/sql/en_US-new.sql index 613b2b73..30f624da 100644 --- a/sql/en_US-new.sql +++ b/sql/en_US-new.sql @@ -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', -- 2.30.2