Added document Receipt and small rearrangements and bugfixes
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Mon, 25 Jan 2010 09:12:02 +0000 (09:12 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Mon, 25 Jan 2010 09:12:02 +0000 (09:12 +0000)
20 files changed:
CHANGELOG.txt
includes/types.inc
includes/ui/ui_view.inc
reporting/includes/doctext.inc
reporting/includes/doctext2.inc
reporting/includes/header2.inc
reporting/includes/reporting.inc
reporting/includes/reports_classes.inc
reporting/rep107.php
reporting/rep108.php
reporting/rep109.php
reporting/rep110.php
reporting/rep111.php
reporting/rep112.php [new file with mode: 0644]
reporting/rep209.php
reporting/rep210.php
reporting/reports_main.php
sales/customer_payments.php
sales/inquiry/customer_inquiry.php
sales/sales_order_entry.php

index 5f3b242b983f274d4109d08fc4f864466e8a7aed..8af8641b29c454ea2bdef81e1ad2906f31b2f089 100644 (file)
@@ -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
index 3636a4936e3eee4287504da194059956ee210755..c7bb52c2b3e013cd982285922cfee684891b823c 100644 (file)
@@ -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"),
index 039a9b795b8169c7da5c48f7c91ac937a728f460..5e3a8a157bd069004617be15bfc365e30dba70b4 100644 (file)
@@ -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)
 {
index 40a0802b5a3fa65224c72e28861a15b34586460d..e15a5df9305bb728eb02f1d56c05369184bb23ba 100644 (file)
@@ -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");
index 554409e774acb5c4bfa6ec6111063fb24e059729..2550dbb7247eca23da79deb3e35442e15e73901f 100644 (file)
@@ -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";
index 2da3c7c0a3c6a66431a3b6bf20baf4b384535f67..ab21d9f22334df2fca8247787e3fc805b40b4c1b 100644 (file)
                        $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);
                        $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)
                {
                        $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');
                }
                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)
                {
                                $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');
                }
index 4ce4d148d3a37f31b309795a31d2999f9d772c1e..2bfa425748808030cf87e4797b27f40260124be3 100644 (file)
@@ -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
index d26fd2ad044157c7a089f7c831b63c4f28f0eb38..9cb78d8764f036c2873539bc6cd60ba52f179d58 100644 (file)
@@ -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);
 
index 5d181090fe02a27242deaa06525bb61a51d1b79a..54aefe044b6a0eae4b6078fa2da5fd17be5113bb 100644 (file)
@@ -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)
                        {
index d5b1c022b480f231ef86745fe2d90541630cb73b..b896b73b46ca72123ca4a1b874dfb7687bca47a5 100644 (file)
@@ -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)
index 5b049c111ce799fd0a4be400fe0b6a03ab392320..a6a4a434e9b08f12952221aceea5dee802532017 100644 (file)
@@ -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)
                {
index a8fdbc4a6caae71abf175ab090c49b5b6d9d4ac8..5afa8b825f5be99aa0791c89253ad4e5263ad54e 100644 (file)
@@ -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)
index 0301ed616e2f8677c3765cb3f703702f0e16aca9..a8440dfd9b7e1c6c9a4be834a3d06180164481dc 100644 (file)
@@ -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 (file)
index 0000000..07e312c
--- /dev/null
@@ -0,0 +1,185 @@
+<?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>.
+***********************************************************************/
+
+$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
index e8278e60e13036c644e5742654c61c983c4b0a79..cbdf485f2a9ddec60fd6e493e358f425a4057a1d 100644 (file)
@@ -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)
                {
index f25b792543661359c681f12216a107c2814bde31..27d56cd704a3ad7f51053bda7a44b284f37b04c4 100644 (file)
@@ -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)
                        {
index a36a043cd87826ed9429ff446005604e77310712..d1ba1b3686effd2f261a12fc48f9d7c2bbd03bec 100644 (file)
@@ -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'),
index 7170d4fdd9ee07433f43f7def08d373cb3be9b11..20f9d3ab0a6127a704e78382672649cb06432f15 100644 (file)
@@ -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");
index de745b5a1a86ff07ee19777f18da28b01af050ae..426e135b8f0156894b69ab691855fcdb39d8a5c3 100644 (file)
@@ -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)
index c7255881b92864033b91df8305d2373ca9129513..475548abed7c2a66f267060c9dfdde033fb8aa40 100644 (file)
@@ -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);