From a3c366442e07bfa82a326df8fea3d9d4b35a3dd8 Mon Sep 17 00:00:00 2001 From: Joe Hunt Date: Mon, 25 Jan 2010 09:12:02 +0000 Subject: [PATCH] Added document Receipt and small rearrangements and bugfixes --- CHANGELOG.txt | 3 + includes/types.inc | 5 + includes/ui/ui_view.inc | 80 +++++++++++ reporting/includes/doctext.inc | 44 ++++-- reporting/includes/doctext2.inc | 44 ++++-- reporting/includes/header2.inc | 18 ++- reporting/includes/reporting.inc | 9 ++ reporting/includes/reports_classes.inc | 10 ++ reporting/rep107.php | 6 + reporting/rep108.php | 8 +- reporting/rep109.php | 6 + reporting/rep110.php | 6 + reporting/rep111.php | 6 + reporting/rep112.php | 185 +++++++++++++++++++++++++ reporting/rep209.php | 6 + reporting/rep210.php | 34 +++-- reporting/reports_main.php | 11 ++ sales/customer_payments.php | 2 + sales/inquiry/customer_inquiry.php | 4 +- sales/sales_order_entry.php | 11 +- 20 files changed, 449 insertions(+), 49 deletions(-) create mode 100644 reporting/rep112.php diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 5f3b242b..8af8641b 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,6 +19,9 @@ Legend: ! -> Note $ -> Affected files +25-Jan-2010 Joe Hunt ++ Added document Receipt and small rearrangements and bugfixes +$ / 22-Jan-2010 Tom Hallman/Joe Hunt # Exchange rate doesn't update table when adding new or deleting rate $ /gl/manage/exchange_rates.php diff --git a/includes/types.inc b/includes/types.inc index 3636a493..c7bb52c2 100644 --- a/includes/types.inc +++ b/includes/types.inc @@ -42,6 +42,11 @@ define('ST_SALESQUOTE', 32); define('ST_COSTUPDATE', 35); define('ST_DIMENSION', 40); +// Don't include these defines in the $systypes_array. +// They are used for documents only. +define ('ST_STATEMENT', 91); +define ('ST_CHEQUE', 92); + $systypes_array = array ( ST_JOURNAL => _("Journal Entry"), ST_BANKPAYMENT => _("Bank Payment"), diff --git a/includes/ui/ui_view.inc b/includes/ui/ui_view.inc index 039a9b79..5e3a8a15 100644 --- a/includes/ui/ui_view.inc +++ b/includes/ui/ui_view.inc @@ -630,6 +630,86 @@ function display_quick_entries(&$cart, $id, $base, $type, $descr='') return $bank_amount; } +//-------------------------------------------------------------------------------------- +// +// Simple English version of number to words conversion. +// +function _number_to_words($number) +{ + $Bn = floor($number / 1000000000); /* Billions (giga) */ + $number -= $Bn * 1000000000; + $Gn = floor($number / 1000000); /* Millions (mega) */ + $number -= $Gn * 1000000; + $kn = floor($number / 1000); /* Thousands (kilo) */ + $number -= $kn * 1000; + $Hn = floor($number / 100); /* Hundreds (hecto) */ + $number -= $Hn * 100; + $Dn = floor($number / 10); /* Tens (deca) */ + $n = $number % 10; /* Ones */ + + $res = ""; + + if ($Bn) + $res .= _number_to_words($Bn) . " Billion"; + if ($Gn) + $res .= (empty($res) ? "" : " ") . _number_to_words($Gn) . " Million"; + if ($kn) + $res .= (empty($res) ? "" : " ") . _number_to_words($kn) . " Thousand"; + if ($Hn) + $res .= (empty($res) ? "" : " ") . _number_to_words($Hn) . " Hundred"; + + $ones = array("", "One", "Two", "Three", "Four", "Five", "Six", + "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", + "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eightteen", + "Nineteen"); + $tens = array("", "", "Twenty", "Thirty", "Fourty", "Fifty", "Sixty", + "Seventy", "Eigthy", "Ninety"); + + if ($Dn || $n) + { + if (!empty($res)) + $res .= " and "; + if ($Dn < 2) + $res .= $ones[$Dn * 10 + $n]; + else + { + $res .= $tens[$Dn]; + if ($n) + $res .= "-" . $ones[$n]; + } + } + + if (empty($res)) + $res = "zero"; + return $res; +} + +function price_in_words($amount, $document=0) +{ + global $Hooks; + // use local price_in_words() if the hook is defined + if (method_exists($Hooks, 'price_in_words')) + { + return $Hooks->price_in_words($amount, $document); + } + // Only usefor Remittance and Receipts as default + if (!($document == ST_SUPPAYMENT || $document == ST_CUSTPAYMENT || $document == ST_CHEQUE)) + return ""; + if ($amount < 0 || $amount > 999999999999) + return ""; + $dec = user_price_dec(); + if ($dec > 0) + { + $divisor = pow(10, $dec); + $frac = round2($amount - floor($amount), $dec) * $divisor; + $frac = sprintf("%0{$dec}d", $frac); + $and = _("and"); + $frac = " $and $frac/$divisor"; + } + else + $frac = ""; + return _number_to_words(intval($amount)) . $frac; +} function get_js_open_window($width, $height) { diff --git a/reporting/includes/doctext.inc b/reporting/includes/doctext.inc index 40a0802b..e15a5df9 100644 --- a/reporting/includes/doctext.inc +++ b/reporting/includes/doctext.inc @@ -20,7 +20,10 @@ if (isset($header2type)) } else { - $doc_Charge_To = _("Charge To"); + 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"); @@ -42,7 +45,7 @@ if (isset($header2type)) } else { - if ($doctype == ST_SUPPAYMENT) + if ($doctype == ST_SUPPAYMENT || $doctype == ST_CUSTPAYMENT) $doc_Our_Ref = _("Type"); else $doc_Our_Ref = _("Sales Person"); @@ -54,9 +57,13 @@ if (isset($header2type)) $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) { - $doc_Bank_Account = ''; - $doc_Please_Quote = _("All amounts stated in"); + $doctype == ST_SUPPAYMENT || $doctype == ST_CUSTPAYMENT) { + if ($doctype == ST_CUSTPAYMENT) + $doc_Extra = _("* Subject to Realisation of the Cheque."); + else + $doc_Extra = ""; + $doc_Bank_Account = ''; + $doc_Please_Quote = _("All amounts stated in"); } else { $doc_Bank_Account = _("Bank Account"); $doc_Please_Quote = $doctype==ST_SALESINVOICE ? @@ -68,7 +75,8 @@ if (isset($header2type)) $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_CUSTCREDIT || $doctype == ST_CUSTDELIVERY || $doctype == ST_WORKORDER || $doctype == ST_SUPPAYMENT || + $doctype == ST_CUSTPAYMENT) { if ($doctype == ST_SALESQUOTE) $this->title = _("SALES QUOTATION"); @@ -84,6 +92,8 @@ if (isset($header2type)) $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) @@ -92,13 +102,13 @@ if (isset($header2type)) 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) + 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")); } - else if ($doctype == ST_CUSTPAYMENT) + else if ($doctype == ST_STATEMENT) { $this->title = _("STATEMENT"); $this->headers = array(_("Trans Type"), _("#"), _("Date"), _("DueDate"), _("Charges"), @@ -115,9 +125,10 @@ if (isset($emailtype)) 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 ? _("Word Order No") : _("Credit No.")))))); + ($doctype==ST_SALESINVOICE ? _("Invoice No.") : ($doctype==ST_WORKORDER ? _("Word Order No") : _("Credit No."))))))); $doc_Delivery_no = _("Delivery Note No."); $doc_Order_no = _("Order no."); } @@ -136,13 +147,22 @@ if (isset($linetype)) $doc_TOTAL_PO = _("TOTAL PO EX VAT"); $doc_TOTAL_DELIVERY = _("TOTAL DELIVERY INCL. VAT"); } - elseif ($doctype == ST_SUPPAYMENT) + elseif ($doctype == ST_SUPPAYMENT || 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"); - $doc_Total_Payment = _("TOTAL REMITTANCE"); + if ($doctype == ST_CUSTPAYMENT) + $doc_Total_Payment = _("TOTAL RECEIPT"); + else + $doc_Total_Payment = _("TOTAL REMITTANCE"); } - elseif ($doctype == ST_CUSTPAYMENT) + elseif ($doctype == ST_STATEMENT) { $doc_Outstanding = _("Outstanding Transactions"); $doc_Current = _("Current"); diff --git a/reporting/includes/doctext2.inc b/reporting/includes/doctext2.inc index 554409e7..2550dbb7 100644 --- a/reporting/includes/doctext2.inc +++ b/reporting/includes/doctext2.inc @@ -20,7 +20,10 @@ if (isset($header2type)) } else { - $doc_Charge_To = "Charge To"; + 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"; @@ -42,7 +45,7 @@ if (isset($header2type)) } else { - if ($doctype == ST_SUPPAYMENT) + if ($doctype == ST_SUPPAYMENT || $doctype == ST_CUSTPAYMENT) $doc_Our_Ref = "Type"; else $doc_Our_Ref = "Sales Person"; @@ -54,9 +57,13 @@ if (isset($header2type)) $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) { - $doc_Bank_Account = ''; - $doc_Please_Quote = "All amounts stated in"; + $doctype == ST_SUPPAYMENT || $doctype == ST_CUSTPAYMENT) { + if ($doctype == ST_CUSTPAYMENT) + $doc_Extra = "* Subject to Realisation of the Cheque."; + else + $doc_Extra = ""; + $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"; @@ -67,7 +74,8 @@ if (isset($header2type)) $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_CUSTCREDIT || $doctype == ST_CUSTDELIVERY || $doctype == ST_WORKORDER || $doctype == ST_SUPPAYMENT || + $doctype == ST_CUSTPAYMENT) { if ($doctype == ST_SALESQUOTE) $this->title = "SALES QUOTATION"; @@ -83,6 +91,8 @@ if (isset($header2type)) $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) @@ -91,13 +101,13 @@ if (isset($header2type)) 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) + 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_CUSTPAYMENT) + elseif ($doctype == ST_STATEMENT) { $this->title = "STATEMENT"; $this->headers = array('Trans Type', '#', 'Date', 'Due Date', 'Charges', @@ -114,9 +124,10 @@ if (isset($emailtype)) 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."))))); + ($doctype==ST_SALESINVOICE ? "Invoice No." : ($doctype == ST_WORKORDER ? "Work Order No" : "Credit No.")))))); $doc_Delivery_no = "Delivery Note No."; $doc_Order_no = "Order no."; } @@ -135,13 +146,22 @@ if (isset($linetype)) $doc_TOTAL_PO = "TOTAL PO EX VAT"; $doc_TOTAL_DELIVERY = "TOTAL DELIVERY INCL. VAT"; } - elseif ($doctype == ST_SUPPAYMENT) + 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"; - $doc_Total_Payment = "TOTAL REMITTANCE"; + if ($doctype == ST_CUSTPAYMENT) + $doc_Total_Payment = "TOTAL RECEIPT"; + else + $doc_Total_Payment = "TOTAL REMITTANCE"; } - elseif ($doctype == ST_CUSTPAYMENT) + elseif ($doctype == ST_STATEMENT) { $doc_Outstanding = "Outstanding Transactions"; $doc_Current = "Current"; diff --git a/reporting/includes/header2.inc b/reporting/includes/header2.inc index 2da3c7c0..ab21d9f2 100644 --- a/reporting/includes/header2.inc +++ b/reporting/includes/header2.inc @@ -111,7 +111,7 @@ $this->Text($c2col, $this->company['gst_no'], $mcol); $this->NewLine(); } - if (($doctype == ST_SALESINVOICE || $doctype == ST_CUSTPAYMENT) && $this->company['domicile'] != "") + if (($doctype == ST_SALESINVOICE || $doctype == ST_STATEMENT) && $this->company['domicile'] != "") { $this->Text($ccol, $doc_Domicile, $c2col); $this->Text($c2col, $this->company['domicile'], $mcol); @@ -218,6 +218,8 @@ $this->TextWrap($col, $this->row, $width, $myrow['wo_ref'], 'C'); elseif (isset($sales_order["customer_ref"])) $this->TextWrap($col, $this->row, $width, $sales_order["customer_ref"], 'C'); + else + $this->TextWrap($col, $this->row, $width, $myrow["debtor_ref"], 'C'); $col += $width; if ($branch != null) { @@ -227,7 +229,7 @@ $row = db_fetch($result); $this->TextWrap($col, $this->row, $width, $row['salesman_name'], 'C'); } - elseif ($doctype == ST_SUPPAYMENT) + elseif ($doctype == ST_SUPPAYMENT || $doctype == ST_CUSTPAYMENT) $this->TextWrap($col, $this->row, $width, $systypes_array[$myrow["type"]], 'C'); elseif ($doctype == ST_WORKORDER) $this->TextWrap($col, $this->row, $width, $wo_types_array[$myrow["type"]], 'C'); @@ -269,14 +271,15 @@ } elseif ($doctype == ST_WORKORDER) $this->TextWrap($col, $this->row, $width, $myrow["location_name"], 'C'); - elseif (isset($myrow['order_'])) + elseif (isset($myrow['order_']) && $myrow['order_'] != 0) $this->TextWrap($col, $this->row, $width, $myrow['order_'], 'C'); $col += $width; if ($doctype == ST_SALESORDER || $doctype == ST_SALESQUOTE) $this->TextWrap($col, $this->row, $width, sql2date($myrow['delivery_date']), 'C'); elseif ($doctype == ST_WORKORDER) $this->TextWrap($col, $this->row, $width, $myrow["units_issued"], 'C'); - elseif ($doctype != ST_PURCHORDER && $doctype != ST_CUSTCREDIT && isset($myrow['due_date'])) + elseif ($doctype != ST_PURCHORDER && $doctype != ST_CUSTCREDIT && $doctype != ST_CUSTPAYMENT && + $doctype != ST_SUPPAYMENT && isset($myrow['due_date'])) $this->TextWrap($col, $this->row, $width, sql2date($myrow['due_date']), 'C'); if (!isset($packing_slip) || $packing_slip == 0) { @@ -334,12 +337,17 @@ $this->row -= $this->lineHeight; } } + if ($doc_Extra != "") + { + $this->TextWrap($ccol, $this->row, $right - $ccol, $doc_Extra, 'C'); + $this->row -= $this->lineHeight; + } if ($this->params['comments'] != '') { $this->TextWrap($ccol, $this->row, $right - $ccol, $this->params['comments'], 'C'); $this->row -= $this->lineHeight; } - if (($doctype == ST_SALESINVOICE || $doctype == ST_CUSTPAYMENT) && $this->company['legal_text'] != "") + if (($doctype == ST_SALESINVOICE || $doctype == ST_STATEMENT) && $this->company['legal_text'] != "") { $this->TextWrapLines($ccol, $right - $ccol, $this->company['legal_text'], 'C'); } diff --git a/reporting/includes/reporting.inc b/reporting/includes/reporting.inc index 4ce4d148..2bfa4257 100644 --- a/reporting/includes/reporting.inc +++ b/reporting/includes/reporting.inc @@ -77,6 +77,15 @@ function print_document_link($doc_no, $link_text, $link=true, $type_no, 'PARAM_3' => $email, 'PARAM_4' => ''); break; + case ST_CUSTPAYMENT : + $rep = 112; + // from, to, currency, bank acc, email, comments + $ar = array( + 'PARAM_0' => $doc_no, + 'PARAM_1' => $doc_no, + 'PARAM_2' => '', + 'PARAM_4' => ''); + break; case ST_SUPPAYMENT : $rep = 210; // from, to, currency, bank acc, email, comments diff --git a/reporting/includes/reports_classes.inc b/reporting/includes/reports_classes.inc index d26fd2ad..9cb78d87 100644 --- a/reporting/includes/reports_classes.inc +++ b/reporting/includes/reports_classes.inc @@ -334,6 +334,16 @@ class BoxReports FROM ".TB_PREF."suppliers, ".TB_PREF."supp_trans WHERE (type=".ST_BANKPAYMENT." OR type=".ST_SUPPAYMENT." OR type=".ST_SUPPCREDIT.") AND ".TB_PREF."suppliers.supplier_id=".TB_PREF."supp_trans.supplier_id ORDER BY ".TB_PREF."supp_trans.trans_no DESC"; return combo_input($name, '', $sql, 'TNO', 'IName',array('order'=>false)); + case 'RECEIPT': + $BD = _("BD"); + $CP = _("CP"); + $CN = _("CN"); + $ref = ($print_invoice_no == 1 ? "trans_no" : "reference"); + $sql = "SELECT concat(".TB_PREF."debtor_trans.trans_no, '-', + ".TB_PREF."debtor_trans.type) AS TNO, concat(".TB_PREF."debtor_trans.$ref, if (type=".ST_BANKDEPOSIT.", ' $BD ', if (type=".ST_CUSTPAYMENT.", ' $CP ', ' $CN ')), ".TB_PREF."debtors_master.name) as IName + FROM ".TB_PREF."debtors_master, ".TB_PREF."debtor_trans WHERE (type=".ST_BANKDEPOSIT." OR type=".ST_CUSTPAYMENT." OR type=".ST_CUSTCREDIT.") AND ".TB_PREF."debtors_master.debtor_no=".TB_PREF."debtor_trans.debtor_no ORDER BY ".TB_PREF."debtor_trans.trans_no DESC"; + return combo_input($name, '', $sql, 'TNO', 'IName',array('order'=>false)); + case 'ITEMS': return stock_manufactured_items_list($name); diff --git a/reporting/rep107.php b/reporting/rep107.php index 5d181090..54aefe04 100644 --- a/reporting/rep107.php +++ b/reporting/rep107.php @@ -192,6 +192,12 @@ function print_invoices() $rep->Font('bold'); $rep->TextCol(3, 6, $doc_TOTAL_INVOICE, - 2); $rep->TextCol(6, 7, $DisplayTotal, -2); + $words = price_in_words($myrow['Total'], $j); + if ($words != "") + { + $rep->NewLine(1); + $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, - 2); + } $rep->Font(); if ($email == 1) { diff --git a/reporting/rep108.php b/reporting/rep108.php index d5b1c022..b896b73b 100644 --- a/reporting/rep108.php +++ b/reporting/rep108.php @@ -107,10 +107,10 @@ function print_statements() $rep->filename = "Statement" . $myrow['debtor_no'] . ".pdf"; $rep->Info($params, $cols, null, $aligns); } - $rep->Header2($myrow, null, null, $baccount, ST_CUSTPAYMENT); + $rep->Header2($myrow, null, null, $baccount, ST_STATEMENT); $rep->NewLine(); $linetype = true; - $doctype = ST_CUSTPAYMENT; + $doctype = ST_STATEMENT; if ($rep->currency != $myrow['curr_code']) { include($path_to_root . "/reporting/includes/doctext2.inc"); @@ -142,7 +142,7 @@ function print_statements() $rep->TextCol(7, 8, $DisplayNet, -2); $rep->NewLine(); if ($rep->row < $rep->bottomMargin + (10 * $rep->lineHeight)) - $rep->Header2($myrow, null, null, $baccount, ST_CUSTPAYMENT); + $rep->Header2($myrow, null, null, $baccount, ST_STATEMENT); } $nowdue = "1-" . $PastDueDays1 . " " . $doc_Days; $pastdue1 = $PastDueDays1 + 1 . "-" . $PastDueDays2 . " " . $doc_Days; @@ -163,7 +163,7 @@ function print_statements() for ($i = 0; $i < 5; $i++) $rep->TextWrap($col[$i], $rep->row, $col[$i + 1] - $col[$i], $str2[$i], 'right'); if ($email == 1) - $rep->End($email, $doc_Statement . " " . $doc_as_of . " " . sql2date($date), $myrow, ST_CUSTPAYMENT); + $rep->End($email, $doc_Statement . " " . $doc_as_of . " " . sql2date($date), $myrow, ST_STATEMENT); } if ($email == 0) diff --git a/reporting/rep109.php b/reporting/rep109.php index 5b049c11..a6a4a434 100644 --- a/reporting/rep109.php +++ b/reporting/rep109.php @@ -158,6 +158,12 @@ function print_sales_orders() else $rep->TextCol(3, 6, $doc_TOTAL_ORDER2, - 2); $rep->TextCol(6, 7, $DisplayTotal, -2); + $words = price_in_words($myrow['Total'], ST_SALESORDER); + if ($words != "") + { + $rep->NewLine(1); + $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, - 2); + } $rep->Font(); if ($email == 1) { diff --git a/reporting/rep110.php b/reporting/rep110.php index a8fdbc4a..5afa8b82 100644 --- a/reporting/rep110.php +++ b/reporting/rep110.php @@ -187,6 +187,12 @@ function print_deliveries() $rep->Font('bold'); $rep->TextCol(3, 6, $doc_TOTAL_DELIVERY, - 2); $rep->TextCol(6, 7, $DisplayTotal, -2); + $words = price_in_words($myrow['Total'], ST_CUSTDELIVERY); + if ($words != "") + { + $rep->NewLine(1); + $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, - 2); + } $rep->Font(); } if ($email == 1) diff --git a/reporting/rep111.php b/reporting/rep111.php index 0301ed61..a8440dfd 100644 --- a/reporting/rep111.php +++ b/reporting/rep111.php @@ -142,6 +142,12 @@ function print_sales_quotations() else $rep->TextCol(3, 6, $doc_TOTAL_ORDER2, - 2); $rep->TextCol(6, 7, $DisplayTotal, -2); + $words = price_in_words($myrow['Total'], ST_SALESQUOTE); + if ($words != "") + { + $rep->NewLine(1); + $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, - 2); + } $rep->Font(); if ($email == 1) { diff --git a/reporting/rep112.php b/reporting/rep112.php new file mode 100644 index 00000000..07e312cd --- /dev/null +++ b/reporting/rep112.php @@ -0,0 +1,185 @@ +. +***********************************************************************/ + +$page_security = $_POST['PARAM_0'] == $_POST['PARAM_1'] ? + 'SA_SALESTRANSVIEW' : 'SA_SALESBULKREP'; +// ---------------------------------------------------------------- +// $ Revision: 2.0 $ +// Creator: Joe Hunt +// date_: 2005-05-19 +// Title: Purchase Orders +// ---------------------------------------------------------------- +$path_to_root=".."; + +include_once($path_to_root . "/includes/session.inc"); +include_once($path_to_root . "/includes/date_functions.inc"); +include_once($path_to_root . "/includes/data_checks.inc"); + +//---------------------------------------------------------------------------------------------------- + +print_receipts(); + +//---------------------------------------------------------------------------------------------------- +function get_receipt($type, $trans_no) +{ + $sql = "SELECT ".TB_PREF."debtor_trans.*, + (".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.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 + AND ".TB_PREF."debtor_trans.type = ".db_escape($type)." + AND ".TB_PREF."debtor_trans.trans_no = ".db_escape($trans_no); + $result = db_query($sql, "The remittance cannot be retrieved"); + if (db_num_rows($result) == 0) + return false; + return db_fetch($result); +} + +function get_allocations_for_receipt($debtor_id, $type, $trans_no) +{ + $sql = get_alloc_trans_sql("amt, trans.reference, trans.alloc", "trans.trans_no = alloc.trans_no_to + AND trans.type = alloc.trans_type_to + AND alloc.trans_no_from=$trans_no + AND alloc.trans_type_from=$type + AND trans.debtor_no=".db_escape($debtor_id), + TB_PREF."cust_allocations as alloc"); + $sql .= " ORDER BY trans_no"; + return db_query($sql, "Cannot retreive alloc to transactions"); +} + +function print_receipts() +{ + global $path_to_root, $systypes_array; + + include_once($path_to_root . "/reporting/includes/pdf_report.inc"); + + $from = $_POST['PARAM_0']; + $to = $_POST['PARAM_1']; + $currency = $_POST['PARAM_2']; + $comments = $_POST['PARAM_3']; + + if ($from == null) + $from = 0; + if ($to == null) + $to = 0; + $dec = user_price_dec(); + + $fno = explode("-", $from); + $tno = explode("-", $to); + + $cols = array(4, 85, 150, 225, 275, 360, 450, 515); + + // $headers in doctext.inc + $aligns = array('left', 'left', 'left', 'left', 'right', 'right', 'right'); + + $params = array('comments' => $comments); + + $cur = get_company_Pref('curr_default'); + + if ($email == 0) + { + $rep = new FrontReport(_('RECEIPT'), "ReceiptBulk", user_pagesize()); + $rep->currency = $cur; + $rep->Font(); + $rep->Info($params, $cols, null, $aligns); + } + + for ($i = $fno[0]; $i <= $tno[0]; $i++) + { + if ($fno[0] == $tno[0]) + $types = array($fno[1]); + else + $types = array(ST_BANKDEPOSIT, ST_CUSTPAYMENT, ST_CUSTCREDIT); + foreach ($types as $j) + { + $myrow = get_receipt($j, $i); + if (!$myrow) + continue; + $baccount = get_default_bank_account($myrow['curr_code']); + $params['bankaccount'] = $baccount['id']; + + $rep->title = _('RECEIPT'); + $rep->Header2($myrow, null, $myrow, $baccount, ST_CUSTPAYMENT); + $result = get_allocations_for_receipt($myrow['debtor_no'], $myrow['type'], $myrow['trans_no']); + + $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"); + } + + $total_allocated = 0; + $rep->TextCol(0, 4, $doc_Towards, -2); + $rep->NewLine(2); + + while ($myrow2=db_fetch($result)) + { + $rep->TextCol(0, 1, $systypes_array[$myrow2['type']], -2); + $rep->TextCol(1, 2, $myrow2['reference'], -2); + $rep->TextCol(2, 3, sql2date($myrow2['tran_date']), -2); + $rep->TextCol(3, 4, sql2date($myrow2['due_date']), -2); + $rep->AmountCol(4, 5, $myrow2['Total'], $dec, -2); + $rep->AmountCol(5, 6, $myrow2['Total'] - $myrow2['alloc'], $dec, -2); + $rep->AmountCol(6, 7, $myrow2['amt'], $dec, -2); + + $total_allocated += $myrow2['amt']; + $rep->NewLine(1); + if ($rep->row < $rep->bottomMargin + (15 * $rep->lineHeight)) + $rep->Header2($myrow, null, $myrow, $baccount, ST_CUSTPAYMENT); + } + + $rep->row = $rep->bottomMargin + (15 * $rep->lineHeight); + + $rep->TextCol(3, 6, $doc_Total_Allocated, -2); + $rep->AmountCol(6, 7, $total_allocated, $dec, -2); + $rep->NewLine(); + $rep->TextCol(3, 6, $doc_Left_To_Allocate, -2); + $rep->AmountCol(6, 7, $myrow['Total'] - $total_allocated, $dec, -2); + $rep->NewLine(); + $rep->Font('bold'); + $rep->TextCol(3, 6, $doc_Total_Payment, - 2); + $rep->AmountCol(6, 7, $myrow['Total'], $dec, -2); + $words = price_in_words($myrow['Total'], ST_CUSTPAYMENT); + if ($words != "") + { + $rep->NewLine(1); + $rep->TextCol(0, 7, $myrow['curr_code'] . ": " . $words, - 2); + } + $rep->Font(); + $rep->NewLine(); + $rep->TextCol(6, 7, $doc_Received, - 2); + $rep->NewLine(); + $rep->TextCol(0, 2, $doc_by_Cheque, - 2); + $rep->TextCol(2, 4, "______________________________", - 2); + $rep->TextCol(4, 5, $doc_Dated, - 2); + $rep->TextCol(5, 6, "__________________", - 2); + $rep->NewLine(1); + $rep->TextCol(0, 2, $doc_Drawn, - 2); + $rep->TextCol(2, 4, "______________________________", - 2); + $rep->TextCol(4, 5, $doc_Drawn_Branch, - 2); + $rep->TextCol(5, 6, "__________________", - 2); + $rep->TextCol(6, 7, "__________________"); + } + } + if ($email == 0) + $rep->End(); +} + +?> \ No newline at end of file diff --git a/reporting/rep209.php b/reporting/rep209.php index e8278e60..cbdf485f 100644 --- a/reporting/rep209.php +++ b/reporting/rep209.php @@ -167,6 +167,12 @@ function print_po() $rep->Font('bold'); $rep->TextCol(3, 6, $doc_TOTAL_PO, - 2); $rep->TextCol(6, 7, $DisplayTotal, -2); + $words = price_in_words($myrow['Total'], ST_PURCHORDER); + if ($words != "") + { + $rep->NewLine(1); + $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, - 2); + } $rep->Font(); if ($email == 1) { diff --git a/reporting/rep210.php b/reporting/rep210.php index f25b7925..27d56cd7 100644 --- a/reporting/rep210.php +++ b/reporting/rep210.php @@ -90,7 +90,7 @@ function print_remittances() if ($email == 0) { - $rep = new FrontReport(_('PURCHASE ORDER'), "PurchaseOrderBulk", user_pagesize()); + $rep = new FrontReport(_('REMITTANCE'), "RemittanceBulk", user_pagesize()); $rep->currency = $cur; $rep->Font(); $rep->Info($params, $cols, null, $aligns); @@ -103,8 +103,6 @@ function print_remittances() else $types = array(ST_BANKPAYMENT, ST_SUPPAYMENT, ST_SUPPCREDIT); foreach ($types as $j) - //for ($j = ST_BANKPAYMENT; $j <= ST_SUPPAYMENT; $j = ($j == ST_BANKPAYMENT ? ST_SUPPAYMENT : 999)) - //for ($j = $ft; $j <= $tt; $j = ($j == ST_BANKPAYMENT ? ST_SUPPAYMENT : 999)) { $myrow = get_remittance($j, $i); if (!$myrow) @@ -126,7 +124,21 @@ function print_remittances() $rep->Header2($myrow, null, $myrow, $baccount, ST_SUPPAYMENT); $result = get_allocations_for_remittance($myrow['supplier_id'], $myrow['type'], $myrow['trans_no']); + $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"); + } + $total_allocated = 0; + $rep->TextCol(0, 4, $doc_Towards, -2); + $rep->NewLine(2); + while ($myrow2=db_fetch($result)) { $rep->TextCol(0, 1, $systypes_array[$myrow2['type']], -2); @@ -144,16 +156,6 @@ function print_remittances() } $rep->row = $rep->bottomMargin + (15 * $rep->lineHeight); - $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"); - } $rep->TextCol(3, 6, $doc_Total_Allocated, -2); $rep->AmountCol(6, 7, $total_allocated, $dec, -2); @@ -165,6 +167,12 @@ function print_remittances() $rep->Font('bold'); $rep->TextCol(3, 6, $doc_Total_Payment, - 2); $rep->AmountCol(6, 7, $myrow['Total'], $dec, -2); + $words = price_in_words($myrow['Total'], ST_SUPPAYMENT); + if ($words != "") + { + $rep->NewLine(2); + $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, - 2); + } $rep->Font(); if ($email == 1) { diff --git a/reporting/reports_main.php b/reporting/reports_main.php index a36a043c..d1ba1b36 100644 --- a/reporting/reports_main.php +++ b/reporting/reports_main.php @@ -103,6 +103,17 @@ $reports->addReport(_('Customer'),111,_('&Print Sales Quotations'), _('Currency Filter') => 'CURRENCY', _('Email Customers') => 'YES_NO', _('Comments') => 'TEXTBOX')); +$reports->addReport(_('Customer'),111,_('&Print Sales Quotations'), + array( _('From') => 'QUOTATIONS', + _('To') => 'QUOTATIONS', + _('Currency Filter') => 'CURRENCY', + _('Email Customers') => 'YES_NO', + _('Comments') => 'TEXTBOX')); +$reports->addReport(_('Customer'),112,_('Print Receipts'), + array( _('From') => 'RECEIPT', + _('To') => 'RECEIPT', + _('Currency Filter') => 'CURRENCY', + _('Comments') => 'TEXTBOX')); $reports->addReportClass(_('Supplier')); $reports->addReport(_('Supplier'),201,_('Supplier &Balances'), diff --git a/sales/customer_payments.php b/sales/customer_payments.php index 7170d4fd..20f9d3ab 100644 --- a/sales/customer_payments.php +++ b/sales/customer_payments.php @@ -60,6 +60,8 @@ if (isset($_GET['AddedID'])) { display_notification_centered(_("The customer payment has been successfully entered.")); + submenu_print(_("&Print This Receipt"), ST_CUSTPAYMENT, $payment_no."-".ST_CUSTPAYMENT, 'prtopt'); + display_note(get_gl_view_str(ST_CUSTPAYMENT, $payment_no, _("&View the GL Journal Entries for this Customer Payment"))); // hyperlink_params($path_to_root . "/sales/allocations/customer_allocate.php", _("&Allocate this Customer Payment"), "trans_no=$payment_no&trans_type=12"); diff --git a/sales/inquiry/customer_inquiry.php b/sales/inquiry/customer_inquiry.php index de745b5a..426e135b 100644 --- a/sales/inquiry/customer_inquiry.php +++ b/sales/inquiry/customer_inquiry.php @@ -194,7 +194,9 @@ function edit_link($row) function prt_link($row) { if ($row['type'] != ST_CUSTPAYMENT && $row['type'] != ST_BANKDEPOSIT) // customer payment or bank deposit printout not defined yet. - return print_document_link($row['trans_no'], _("Print"), true, $row['type'], ICON_PRINT); + return print_document_link($row['trans_no']."-".$row['type'], _("Print"), true, $row['type'], ICON_PRINT); + else + return print_document_link($row['trans_no']."-".$row['type'], _("Print Receipt"), true, ST_CUSTPAYMENT, ICON_PRINT); } function check_overdue($row) diff --git a/sales/sales_order_entry.php b/sales/sales_order_entry.php index c7255881..475548ab 100644 --- a/sales/sales_order_entry.php +++ b/sales/sales_order_entry.php @@ -201,9 +201,16 @@ if (isset($_GET['AddedID'])) { submenu_view(_("&View This Invoice"), ST_SALESINVOICE, $invoice); - submenu_print(_("&Print Sales Invoice"), ST_SALESINVOICE, $invoice, 'prtopt'); - submenu_print(_("&Email Sales Invoice"), ST_SALESINVOICE, $invoice, null, 1); + submenu_print(_("&Print Sales Invoice"), ST_SALESINVOICE, $invoice."-".ST_SALESINVOICE, 'prtopt'); + submenu_print(_("&Email Sales Invoice"), ST_SALESINVOICE, $invoice."-".ST_SALESINVOICE, null, 1); set_focus('prtopt'); + + $sql = "SELECT trans_type_from, trans_no_from FROM ".TB_PREF."cust_allocations + WHERE trans_type_to=".ST_SALESINVOICE." AND trans_no_to=".db_escape($invoice); + $result = db_query($sql, "could not retrieve customer allocation"); + $row = db_fetch($result); + if ($row !== false) + submenu_print(_("Print &Receipt"), $row['trans_type_from'], $row['trans_no_from']."-".$row['trans_type_from'], 'prtopt'); display_note(get_gl_view_str(ST_SALESINVOICE, $invoice, _("View the GL &Journal Entries for this Invoice")),0, 1); -- 2.30.2