Added Sales Quotations, inquiry and report
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Mon, 7 Sep 2009 22:58:22 +0000 (22:58 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Mon, 7 Sep 2009 22:58:22 +0000 (22:58 +0000)
29 files changed:
CHANGELOG.txt
applications/customers.php
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/rep105.php
reporting/rep107.php
reporting/rep109.php
reporting/rep110.php
reporting/rep111.php [new file with mode: 0644]
reporting/reports_main.php
sales/customer_delivery.php
sales/customer_invoice.php
sales/includes/cart_class.inc
sales/includes/db/sales_delivery_db.inc
sales/includes/db/sales_order_db.inc
sales/includes/ui/sales_order_ui.inc
sales/inquiry/sales_orders_view.php
sales/sales_order_entry.php
sales/view/view_dispatch.php
sales/view/view_invoice.php
sales/view/view_sales_order.php
sql/alter2.2.sql
sql/en_US-demo.sql
sql/en_US-new.sql

index 7e5f11d002cf48c351fe178ceaaa43651002202d..b3ce5ec6650ddf9594cc804c63a964ccf423bb50 100644 (file)
@@ -19,6 +19,37 @@ Legend:
 ! -> Note
 $ -> Affected files
 
+08-Sep-2009 Joe Hunt
++ Added Sales Quotations, inquiry and report
+$ /applications/customers.php
+  /includes/types.inc
+  /includes/ui/ui_view.inc
+  /reporting/rep105.php
+  /reporting/rep107.php
+  /reporting/rep109.php
+  /reporting/rep110.php
+  /reporting/rep111.php (new file)
+  /reporting/reports_main.php
+  /reporting/includes/doctext.php
+  /reporting/includes/doctext2.php
+  /reporting/includes/header2.inc
+  /reporting/includes/reporting.inc
+  /reporting/includes/reports_classes.inc
+  /sales/customer_delivery.php
+  /sales/customer_invoice.php
+  /sales/sales_order_entry.php
+  /sales/includes/cart_class.inc
+  /sales/includes/db/sales_delivery_db.inc
+  /sales/includes/db/sales_order_db.inc
+  /sales/includes/ui/sales_order_ui.inc
+  /sales/inquiry/sales_orders_view.php
+  /sales/view/view_dispatch.php
+  /sales/view/view_invoice.php
+  /sales/view/view_sales_order.php
+  /sql/alter2.2.sql
+  /sql/en_US-demo.sql
+  /sql/en_US-new.sql
+  
 01-Sep-2009 Janusz Dobrowolski
 # Fixed security sections db update.
 $ /admin/security_roles.php
index 78e49e5447574e5d81d4bc7c0ef77778b90890e0..c00b2f7640221ec13f2c24ec9e64bd88bdb7065d 100644 (file)
@@ -17,6 +17,7 @@
                        $this->application("orders",_("&Sales"));
                
                        $this->add_module(_("Transactions"));
+                       $this->add_lapp_function(0, _("Sales &Quotation Entry"),"sales/sales_order_entry.php?NewQuotation=Yes");
                        $this->add_lapp_function(0, _("Sales &Order Entry"),"sales/sales_order_entry.php?NewOrder=Yes");
                        $this->add_lapp_function(0, _("Direct &Delivery"),"sales/sales_order_entry.php?NewDelivery=0");                 
                        $this->add_lapp_function(0, _("Direct &Invoice"),"sales/sales_order_entry.php?NewInvoice=0");
@@ -33,7 +34,8 @@
                        $this->add_rapp_function(0, _("&Allocate Customer Payments or Credit Notes"),"sales/allocations/customer_allocation_main.php?");
 
                        $this->add_module(_("Inquiries and Reports"));
-                       $this->add_lapp_function(1, _("Sales Order &Inquiry"),"sales/inquiry/sales_orders_view.php?");
+                       $this->add_lapp_function(1, _("Sales Quotation I&nquiry"),"sales/inquiry/sales_orders_view.php?type=32");
+                       $this->add_lapp_function(1, _("Sales Order &Inquiry"),"sales/inquiry/sales_orders_view.php?type=30");
                        $this->add_lapp_function(1, _("Customer Transaction &Inquiry"),"sales/inquiry/customer_inquiry.php?");
                        $this->add_lapp_function(1, "","");
                        $this->add_lapp_function(1, _("Customer Allocation &Inquiry"),"sales/inquiry/customer_allocation_inquiry.php?");
index ced641c24f0e55a3d353678aff36d545e5b86c98..94d1f80c35441c7da80436e5e049f9bd7d33a588 100644 (file)
@@ -31,6 +31,7 @@ $systypes_array = array (
                     28=> array ('name' => _("Work Order Issue")),
                     29=> array ('name' => _("Work Order Production")),
                     30=> array ('name' => _("Sales Order")),
+                    32=> array ('name' => _("Sales Quotations")),
                     35=> array ('name' => _("Cost Update")),
                     40=> array ('name' => _("Dimension"))
                                        );
@@ -97,6 +98,11 @@ class systypes
                return 30;
        }
 
+       function sales_quotation() 
+       {
+               return 32;
+       }
+
        function cost_update() 
        {
                return 35;
index bc444a09b6097a3f36ae21565834e457b0ac16e1..bedf484a9c9112144ff7da880852e119b82473bb 100644 (file)
@@ -81,7 +81,7 @@ function get_customer_trans_view_str($type, $trans_no, $label="", $icon=false,
                $viewer .= "view_receipt.php";
        elseif ($type == 13)
                $viewer .= "view_dispatch.php";
-       elseif ($type == 30)
+       elseif ($type == 30 || $type == 32)
                $viewer .= "view_sales_order.php";
        else
                return null;
@@ -96,7 +96,7 @@ function get_customer_trans_view_str($type, $trans_no, $label="", $icon=false,
                $lbl = $trans;
        if($preview_str!='') $preview_str .= ',';
 
-       $preview_str .= viewer_link($lbl, $viewer."?trans_no=$trans", 
+       $preview_str .= viewer_link($lbl, $viewer."?trans_no=$trans&trans_type=$type", 
                $class, $id, $icon);
 
   }
index dfd8f62991a1d235cfd89b9613af6d36287d19f1..23a8c65d02aa8dc8f5c226eb66c89b516ff60046 100644 (file)
@@ -24,7 +24,9 @@ if (isset($header2type))
                $doc_Delivered_To = _("Delivered To");
        }       
        $doc_Shipping_Company = _("Shipping Company");
-       if ($doctype == 9)
+       if ($doctype == 7)
+               $doc_Due_Date = _("Valid until");
+       elseif ($doctype == 9)
                $doc_Due_Date = _("Delivery Date");
        else
                $doc_Due_Date = _("Due Date");
@@ -48,7 +50,7 @@ if (isset($header2type))
        }
        $doc_Our_VAT_no = _("Our VAT No.");
        $doc_Domicile = _("Domicile");
-       if($doctype == 13 || $doctype == 8 || $doctype == 9) {
+       if($doctype == 13 || $doctype == 7 || $doctype == 8 || $doctype == 9) {
         $doc_Bank_Account = '';
         $doc_Please_Quote = _("All amounts stated in");
   } else {
@@ -62,9 +64,11 @@ if (isset($header2type))
        $doc_Bank = _("Bank");
        $doc_Bank_Account = _("Bank Account");
        $doc_Payment_Link = _("You can pay through");
-       if ($doctype == 8 || $doctype == 9 || $doctype == 10 || $doctype == 11 || $doctype == 13 || $doctype == 26)
+       if ($doctype == 7 || $doctype == 8 || $doctype == 9 || $doctype == 10 || $doctype == 11 || $doctype == 13 || $doctype == 26)
        {
-               if ($doctype == 8)
+               if ($doctype == 7)
+                       $this->title = _("SALES QUOTATION");
+               elseif ($doctype == 8)
                        $this->title = _("PURCHASE ORDER");
                elseif ($doctype == 13)
                        $this->title = _("DELIVERY NOTE");
@@ -102,14 +106,14 @@ if (isset($emailtype))
 }
 if (isset($header2type) || isset($linetype))
 {
-       $doc_Invoice_no = ($doctype==13 ? _("Delivery Note No.") : (($doctype==8 || $doctype==9) ? _("Order no.") : 
+       $doc_Invoice_no = ($doctype==13 ? _("Delivery Note No.") : (($doctype==7 || $doctype==8 || $doctype==9) ? _("Order no.") : 
                ($doctype==10 ? _("Invoice No.") : ($doctype==26 ? _("Word Order No") : _("Credit No.")))));
        $doc_Delivery_no = _("Delivery Note No.");
        $doc_Order_no = _("Order no.");
 }
 if (isset($linetype))
 {
-       if ($doctype == 8 || $doctype == 9 || $doctype == 10 || $doctype == 11 || $doctype == 13)
+       if ($doctype == 7 || $doctype == 8 || $doctype == 9 || $doctype == 10 || $doctype == 11 || $doctype == 13)
        {
                $doc_Sub_total = _("Sub-total");
                $doc_Shipping = _("Shipping");
index 92f27507146a60b36ca82ba2c53d600d5f591f3a..9f94b1b4c26fa33ed895d052be912659b03e78d6 100644 (file)
@@ -24,6 +24,8 @@ if (isset($header2type))
                $doc_Delivered_To = "Delivered To";
        }       
        $doc_Shipping_Company = "Shipping Company";
+       if ($doctype == 7)
+               $doc_Due_Date = "Valid until";
        if ($doctype == 9)
                $doc_Due_Date = "Delivery Date";
        else
@@ -48,7 +50,7 @@ if (isset($header2type))
        }
        $doc_Our_VAT_no = "Our VAT No.";
        $doc_Domicile = "Domicile";
-       if($doctype == 13 || $doctype == 8 || $doctype == 9) {
+       if($doctype == 13 || $doctype == 7 || $doctype == 8 || $doctype == 9) {
         $doc_Bank_Account = '';
         $doc_Please_Quote = "All amounts stated in";
   } else {
@@ -61,9 +63,11 @@ if (isset($header2type))
        $doc_Bank = "Bank";
        $doc_Bank_Account = "Bank Account";
        $doc_Payment_Link = "You can pay through";
-       if ($doctype == 8 || $doctype == 9 || $doctype == 10 || $doctype == 11 || $doctype == 13 || $doctype == 26)
+       if ($doctype == 7 || $doctype == 8 || $doctype == 9 || $doctype == 10 || $doctype == 11 || $doctype == 13 || $doctype == 26)
        {
-               if ($doctype == 8)
+               if ($doctype == 7)
+                       $this->title = "SALES QUOTATION";
+               elseif ($doctype == 8)
                        $this->title = "PURCHASE ORDER";
                elseif ($doctype == 9)
                        $this->title = ($print_as_quote==1 ? "QUOTE" : "SALES ORDER");
@@ -101,14 +105,14 @@ if (isset($emailtype))
 }
 if (isset($header2type) || isset($linetype))
 {
-       $doc_Invoice_no = ($doctype==13 ? "Delivery Note No." : (($doctype==8 || $doctype==9) ? "Order no." : 
+       $doc_Invoice_no = ($doctype==13 ? "Delivery Note No." : (($doctype == 7 || $doctype==8 || $doctype==9) ? "Order no." : 
        ($doctype==10 ? "Invoice No." : ($doctype == 26 ? "Work Order No" : "Credit No."))));
        $doc_Delivery_no = "Delivery Note No.";
        $doc_Order_no = "Order no.";
 }
 if (isset($linetype))
 {
-       if ($doctype == 8 || $doctype == 9 || $doctype == 10 || $doctype == 11 || $doctype == 13)
+       if ($doctype == 7 || $doctype == 8 || $doctype == 9 || $doctype == 10 || $doctype == 11 || $doctype == 13)
        {
                $doc_Sub_total = "Sub-total";
                $doc_Shipping = "Shipping";
index 64f391de30daf9e1f6501871aa551601d2d208d0..90cf3b63f5636866a97a62695333bb7b782517e8 100644 (file)
                $this->row = $adrline;
                $this->NewLine(3);
                $this->Text($mcol + 100, $doc_Date.":");
-               if ($doctype == 8 || $doctype == 9)
+               if ($doctype == 7 || $doctype == 8 || $doctype == 9)
                        $this->Text($mcol + 180, sql2date($myrow['ord_date']));
                elseif ($doctype == 26) 
                        $this->Text($mcol + 180, sql2date($myrow['date_']));
                        $this->Text($mcol + 180, sql2date($myrow['tran_date']));
                $this->NewLine();
                $this->Text($mcol + 100, $doc_Invoice_no);
-               if ($doctype == 8 || $doctype == 9) // PO or SO
+               if ($doctype == 7 || $doctype == 8 || $doctype == 9) // QUOTE, PO or SO
                        $this->Text($mcol + 180, $myrow['order_no']);
                elseif ($doctype == 26) 
                        $this->Text($mcol + 180, $myrow['id']);
                $this->row = $this->row - $this->lineHeight - 5;
 
                $temp = $this->row;
-               if ($doctype == 9)
+               if ($doctype == 7 || $doctype == 9)
                {
                        $this->Text($ccol, $myrow['name'], $icol);
                }
                        $this->TextWrap($col, $this->row, $width, $row["terms"], 'C');
                }       
                $col += $width; 
-               if ($doctype == 9)
+               if ($doctype == 9 || $doctype == 7)
                        $this->TextWrap($col, $this->row, $width, sql2date($myrow['delivery_date']), 'C');
                elseif ($doctype == 26) 
                        $this->TextWrap($col, $this->row, $width, $myrow["units_issued"], 'C');
index 43d03ef0a8cab7d9a1f9fe3c046bf77fbae02031..7fa0c122ad1d9754951e5be3be79da37f35d6f5b 100644 (file)
@@ -24,6 +24,17 @@ function print_document_link($doc_no, $link_text, $link=true, $type_no,
 
        switch ($type_no)
        {
+               case systypes::sales_quotation() :
+                       $rep = 111;
+                       // from, to, currency, bank acc, email, quote, comments
+                       $ar = array(
+                               'PARAM_0' => $doc_no, 
+                               'PARAM_1' => $doc_no, 
+                               'PARAM_2' => "", 
+                               'PARAM_3' => get_first_bank_account(), 
+                               'PARAM_4' => $email, 
+                               'PARAM_5' => "");
+                       break;
                case systypes::sales_order() :
                        $rep = 109;
                        // from, to, currency, bank acc, email, quote, comments
index 62dcd582b8eef99fe2ddab4948e6d0ea9dd6f333..2b1c6d5557965eff7dd4f7b507545084de3fd678 100644 (file)
@@ -284,7 +284,15 @@ class Report
                                case 'ORDERS':
                                        $sql = "SELECT ".TB_PREF."sales_orders.order_no, concat(".TB_PREF."sales_orders.order_no, '-',
                                                ".TB_PREF."debtors_master.name) as IName
-                                               FROM ".TB_PREF."debtors_master, ".TB_PREF."sales_orders WHERE ".TB_PREF."debtors_master.debtor_no=".TB_PREF."sales_orders.debtor_no ORDER BY ".TB_PREF."sales_orders.order_no DESC";
+                                               FROM ".TB_PREF."debtors_master, ".TB_PREF."sales_orders WHERE ".TB_PREF."debtors_master.debtor_no=".TB_PREF."sales_orders.debtor_no 
+                                               AND ".TB_PREF."sales_orders.trans_type=30 ORDER BY ".TB_PREF."sales_orders.order_no DESC";
+                                       $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy);
+                                       break;
+                               case 'QUOTATIONS':
+                                       $sql = "SELECT ".TB_PREF."sales_orders.order_no, concat(".TB_PREF."sales_orders.order_no, '-',
+                                               ".TB_PREF."debtors_master.name) as IName
+                                               FROM ".TB_PREF."debtors_master, ".TB_PREF."sales_orders WHERE ".TB_PREF."debtors_master.debtor_no=".TB_PREF."sales_orders.debtor_no 
+                                               AND ".TB_PREF."sales_orders.trans_type=32 ORDER BY ".TB_PREF."sales_orders.order_no DESC";
                                        $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy);
                                        break;
                                case 'PO':
index 63a804d685a6f0a0ceb7be7b9c85bae54c9dd4c8..3af56221bb43ea155ef02ca1734dbca32e5ea938 100644 (file)
@@ -49,7 +49,9 @@ function GetSalesOrders($from, $to, $category=0, $location=null, $backorder=0)
                 ".TB_PREF."sales_order_details.qty_sent
             FROM ".TB_PREF."sales_orders
                INNER JOIN ".TB_PREF."sales_order_details
-                   ON ".TB_PREF."sales_orders.order_no = ".TB_PREF."sales_order_details.order_no
+                   ON (".TB_PREF."sales_orders.order_no = ".TB_PREF."sales_order_details.order_no
+                   AND ".TB_PREF."sales_orders.trans_type = ".TB_PREF."sales_order_details.trans_type
+                   AND ".TB_PREF."sales_orders.trans_type = 30)
                INNER JOIN ".TB_PREF."stock_master
                    ON ".TB_PREF."sales_order_details.stk_code = ".TB_PREF."stock_master.stock_id
             WHERE ".TB_PREF."sales_orders.ord_date >='$fromdate'
index 262d04dab3f0238114e980191e0d16a25a2fa4d0..a265bd603a69c9442ff3f5ad4fb38c427628d405 100644 (file)
@@ -85,7 +85,7 @@ function print_invoices()
                        $branch = get_branch($myrow["branch_code"]);
                        $branch['disable_branch'] = $paylink; // helper
                        if ($j == 10)
-                               $sales_order = get_sales_order_header($myrow["order_"]);
+                               $sales_order = get_sales_order_header($myrow["order_"], 30);
                        else
                                $sales_order = null;
                        if ($email == 1)
index 66cdad59ef380e4ce45a149f45765616f1c9f77e..2a151def233bde1eaeac89f9791a6d098b6765c7 100644 (file)
@@ -74,7 +74,7 @@ function print_sales_orders()
 
        for ($i = $from; $i <= $to; $i++)
        {
-               $myrow = get_sales_order_header($i);
+               $myrow = get_sales_order_header($i, 30);
                $branch = get_branch($myrow["branch_code"]);
                if ($email == 1)
                {
@@ -97,7 +97,7 @@ function print_sales_orders()
                        $rep->title = ($print_as_quote==1 ? _("QUOTE") : _("SALES ORDER"));
                $rep->Header2($myrow, $branch, $myrow, $baccount, 9);
 
-               $result = get_sales_order_details($i);
+               $result = get_sales_order_details($i, 30);
                $SubTotal = 0;
                while ($myrow2=db_fetch($result))
                {
@@ -166,7 +166,7 @@ function print_sales_orders()
                                        $myrow['contact_email'] = $myrow['master_email'];
                                $myrow['DebtorName'] = $branch['br_name'];
                        }
-                       $myrow['reference'] = $i;
+                       //$myrow['reference'] = $i;
                        $rep->End($email, $doc_Invoice_no . " " . $i, $myrow);
                }
        }
index 271b0fc079eea60859f415f95e6fd2f84af53b22..a0051c4586d4c1ed3c550363ba35283a4b2cb541 100644 (file)
@@ -74,7 +74,7 @@ function print_deliveries()
                                continue;
                        $myrow = get_customer_trans($i, 13);
                        $branch = get_branch($myrow["branch_code"]);
-                       $sales_order = get_sales_order_header($myrow["order_"]); // ?
+                       $sales_order = get_sales_order_header($myrow["order_"], 30); // ?
                        if ($email == 1)
                        {
                                $rep = new FrontReport("", "", user_pagesize());
diff --git a/reporting/rep111.php b/reporting/rep111.php
new file mode 100644 (file)
index 0000000..4272dbf
--- /dev/null
@@ -0,0 +1,161 @@
+<?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:      Print Sales Quotations
+// ----------------------------------------------------------------
+$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");
+include_once($path_to_root . "/sales/includes/sales_db.inc");
+
+//----------------------------------------------------------------------------------------------------
+
+print_sales_quotations();
+
+function print_sales_quotations()
+{
+       global $path_to_root, $print_as_quote;
+
+       include_once($path_to_root . "/reporting/includes/pdf_report.inc");
+
+       $from = $_POST['PARAM_0'];
+       $to = $_POST['PARAM_1'];
+       $currency = $_POST['PARAM_2'];
+       $bankaccount = $_POST['PARAM_3'];
+       $email = $_POST['PARAM_4'];
+       $comments = $_POST['PARAM_5'];
+
+       if ($from == null)
+               $from = 0;
+       if ($to == null)
+               $to = 0;
+       $dec = user_price_dec();
+
+       $cols = array(4, 60, 225, 300, 325, 385, 450, 515);
+
+       // $headers in doctext.inc
+       $aligns = array('left', 'left', 'right', 'left', 'right', 'right', 'right');
+
+       $params = array('comments' => $comments,
+                                       'bankaccount' => $bankaccount);
+
+       $baccount = get_bank_account($params['bankaccount']);
+       $cur = get_company_Pref('curr_default');
+
+       if ($email == 0)
+       {
+               $rep = new FrontReport(_("SALES QUOTATION"), "SalesQuotationBulk", user_pagesize());
+               $rep->currency = $cur;
+               $rep->Font();
+               $rep->Info($params, $cols, null, $aligns);
+       }
+
+       for ($i = $from; $i <= $to; $i++)
+       {
+               $myrow = get_sales_order_header($i, 32);
+               $branch = get_branch($myrow["branch_code"]);
+               if ($email == 1)
+               {
+                       $rep = new FrontReport("", "", user_pagesize());
+                       $rep->currency = $cur;
+                       $rep->Font();
+                       $rep->filename = "SalesQuotation" . $i . ".pdf";
+                       $rep->Info($params, $cols, null, $aligns);
+               }
+               $rep->title = _("SALES QUOTATION");
+               $rep->Header2($myrow, $branch, $myrow, $baccount, 7);
+
+               $result = get_sales_order_details($i, 32);
+               $SubTotal = 0;
+               while ($myrow2=db_fetch($result))
+               {
+                       $Net = round2(((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]),
+                          user_price_dec());
+                       $SubTotal += $Net;
+                       $DisplayPrice = number_format2($myrow2["unit_price"],$dec);
+                       $DisplayQty = number_format2($myrow2["quantity"],get_qty_dec($myrow2['stk_code']));
+                       $DisplayNet = number_format2($Net,$dec);
+                       if ($myrow2["discount_percent"]==0)
+                               $DisplayDiscount ="";
+                       else
+                               $DisplayDiscount = number_format2($myrow2["discount_percent"]*100,user_percent_dec()) . "%";
+                       $rep->TextCol(0, 1,     $myrow2['stk_code'], -2);
+                       $oldrow = $rep->row;
+                       $rep->TextColLines(1, 2, $myrow2['description'], -2);
+                       $newrow = $rep->row;
+                       $rep->row = $oldrow;
+                       $rep->TextCol(2, 3,     $DisplayQty, -2);
+                       $rep->TextCol(3, 4,     $myrow2['units'], -2);
+                       $rep->TextCol(4, 5,     $DisplayPrice, -2);
+                       $rep->TextCol(5, 6,     $DisplayDiscount, -2);
+                       $rep->TextCol(6, 7,     $DisplayNet, -2);
+                       $rep->row = $newrow;
+                       //$rep->NewLine(1);
+                       if ($rep->row < $rep->bottomMargin + (15 * $rep->lineHeight))
+                               $rep->Header2($myrow, $branch, $myrow, $baccount, 9);
+               }
+               if ($myrow['comments'] != "")
+               {
+                       $rep->NewLine();
+                       $rep->TextColLines(1, 5, $myrow['comments'], -2);
+               }
+               $DisplaySubTot = number_format2($SubTotal,$dec);
+               $DisplayFreight = number_format2($myrow["freight_cost"],$dec);
+
+               $rep->row = $rep->bottomMargin + (15 * $rep->lineHeight);
+               $linetype = true;
+               $doctype = 9;
+               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_Sub_total, -2);
+               $rep->TextCol(6, 7,     $DisplaySubTot, -2);
+               $rep->NewLine();
+               $rep->TextCol(3, 6, $doc_Shipping, -2);
+               $rep->TextCol(6, 7,     $DisplayFreight, -2);
+               $rep->NewLine();
+               $DisplayTotal = number_format2($myrow["freight_cost"] + $SubTotal, $dec);
+               $rep->Font('bold');
+               $rep->TextCol(3, 6, $doc_TOTAL_ORDER, - 2);
+               $rep->TextCol(6, 7,     $DisplayTotal, -2);
+               $rep->Font();
+               if ($email == 1)
+               {
+                       if ($myrow['contact_email'] == '')
+                       {
+                               $myrow['contact_email'] = $branch['email'];
+                               if ($myrow['contact_email'] == '')
+                                       $myrow['contact_email'] = $myrow['master_email'];
+                               $myrow['DebtorName'] = $branch['br_name'];
+                       }
+                       //$myrow['reference'] = $i;
+                       $rep->End($email, $doc_Invoice_no . " " . $i, $myrow);
+               }
+       }
+       if ($email == 0)
+               $rep->End();
+}
+
+?>
\ No newline at end of file
index 7536d2b2b88e7cbc0ae739c38e5e7281c48dcc8f..4c5deab50382da37952f1fa9c55d5092b7a77b3d 100644 (file)
@@ -99,6 +99,13 @@ $reports->addReport(_('Customer'),109,_('&Print Sales Orders'),
                        new ReportParam(_('Email Customers'),'YES_NO'),
                        new ReportParam(_('Print as Quote'),'YES_NO'),
                        new ReportParam(_('Comments'),'TEXTBOX')));
+$reports->addReport(_('Customer'),111,_('&Print Sales Quotations'),
+       array(  new ReportParam(_('From'),'QUOTATIONS'),
+                       new ReportParam(_('To'),'QUOTATIONS'),
+                       new ReportParam(_('Currency Filter'),'CURRENCY'),
+                       new ReportParam(_('Bank Account'),'BANK_ACCOUNTS'),
+                       new ReportParam(_('Email Customers'),'YES_NO'),
+                       new ReportParam(_('Comments'),'TEXTBOX')));
 
 $reports->addReportClass(_('Supplier'));
 $reports->addReport(_('Supplier'),201,_('Supplier &Balances'),
index 74a4c81d772f22e2f4aa3c91bae96e59d0537552..cbc5e08107c4e9909dbcc2abd51b9376b3358caa 100644 (file)
@@ -52,7 +52,7 @@ if (isset($_GET['AddedID'])) {
        display_note(get_customer_trans_view_str(13, $dispatch_no, _("&View This Delivery")), 0, 1);
 
        display_note(print_document_link($dispatch_no, _("&Print Delivery Note"), true, 13));
-       display_note(print_document_link($dispatch_no, _("&Email Delivery Note"), true, 13, false, "", "", 1),0, 1);
+       display_note(print_document_link($dispatch_no, _("&Email Delivery Note"), true, 13, false, "", "", 1), 1);
 
        display_note(get_gl_view_str(13, $dispatch_no, _("View the GL Journal Entries for this Dispatch")),1);
 
index 2e92bc1b929455bcf6df7d033cd051daf3979a91..c6a045823d1f4d775689edfd6159ed1cab90e4d0 100644 (file)
@@ -57,7 +57,7 @@ if (isset($_GET['AddedID'])) {
        display_note(get_customer_trans_view_str($trans_type, $invoice_no, _("&View This Invoice")), 0, 1);
 
        display_note(print_document_link($invoice_no, _("&Print This Invoice"), true, 10));
-       display_note(print_document_link($invoice_no, _("&Email This Invoice"), true, 10, false, "", "", 1),0, 1);
+       display_note(print_document_link($invoice_no, _("&Email This Invoice"), true, 10, false, "", "", 1),1);
 
        display_note(get_gl_view_str($trans_type, $invoice_no, _("View the GL &Journal Entries for this Invoice")),1);
 
index f388b54cac18e438ba4c17d63eb5db614642814c..719f661733c058e8bc11c8dc5a5b400d3011ec7d 100644 (file)
@@ -23,7 +23,7 @@ include_once($path_to_root . "/taxes/tax_calc.inc");
 
 class cart
 {
-       var $trans_type; // invoice, order, delivery note ...
+       var $trans_type; // invoice, order, quotation, delivery note ...
        var $trans_no = array();// array (num1=>ver1,..) or 0 for new
        var $so_type = 0;               // for sales order: simple=0 template=1
        var $cart_id;           // used to detect multi-tab edition conflits
@@ -82,7 +82,10 @@ class cart
                /*Constructor function initialises a new shopping cart */
                $this->line_items = array();
                $this->sales_type = "";
-               $this->trans_type = 30;
+               if ($type == 32)
+                       $this->trans_type = $type;
+               else    
+                       $this->trans_type = 30;
                $this->dimension_id = 0;
                $this->dimension2_id = 0;
                $this->read($type, $trans_no, $view );
@@ -96,8 +99,8 @@ class cart
 
                if (!is_array($trans_no)) $trans_no = array($trans_no);
                if ($trans_no[0]) {
-                       if ($type == 30) { // sales order
-                               read_sales_order($trans_no[0], $this);
+                       if ($type == 30 || $type == 32) { // sales order || sales quotation
+                               read_sales_order($trans_no[0], $this, $type);
                                if ($view) {    // prepare for DN/IV entry
                                        for($line_no = 0; $line_no < count($this->line_items); $line_no++) {
                                                $line = &$this->line_items[$line_no];
@@ -108,7 +111,7 @@ class cart
                        } else {        // derivative transaction
                                        read_sales_trans($type, $trans_no, $this);
                                        if ($this->order_no) { // free hand credit notes have no order_no
-                                               $sodata = get_sales_order_header($this->order_no);
+                                               $sodata = get_sales_order_header($this->order_no, 30);
                                                $this->cust_ref = $sodata["customer_ref"];
                                        // currently currency is hard linked to debtor account
                                        //      $this->customer_currency = $sodata["curr_code"];
@@ -120,7 +123,7 @@ class cart
                                                $src_details = 0;
                                                if ($src_type == 30) { // get src data from sales_orders
                                                        $this->src_docs = array( $sodata['order_no']=>$sodata['version']);
-                                                       $srcdetails = get_sales_order_details($this->order_no);
+                                                       $srcdetails = get_sales_order_details($this->order_no, 30);
                                                } else {        // get src_data from debtor_trans
                                                        $this->src_docs = get_customer_trans_version($src_type, get_parent_trans($type,$trans_no[0]));
                                                        $srcdetails = get_customer_trans_details($src_type,array_keys($this->src_docs));
@@ -155,7 +158,7 @@ class cart
                                if (!is_date_in_fiscalyear($this->document_date))
                                        $this->document_date = end_fiscalyear();
                                $this->reference = references::get_next($this->trans_type);
-                               if ($type != 30) // Added 2.1 Joe Hunt 2008-11-12
+                               if ($type != 30 && $type != 32) // Added 2.1 Joe Hunt 2008-11-12
                                {
                                        $dim = get_company_pref('use_dimension');
                                        if ($dim > 0)
@@ -236,6 +239,7 @@ class cart
                        case 13:
                                return write_sales_delivery($this, $policy);
                        case 30:
+                       case 32:
                                if ($this->trans_no==0) // new document
                                        return add_sales_order($this);
                                else
index 3945f286c7fc389027cb8d7863b6ea80ea324967..17affbe754eb7616a399ac9e3cc25f52f664c360 100644 (file)
@@ -157,7 +157,7 @@ function void_sales_delivery($type, $type_no)
        $order = get_customer_trans_order($type, $type_no);
 
        if ($order) {
-               $order_items = get_sales_order_details($order);
+               $order_items = get_sales_order_details($order, 30);
                while ($row = db_fetch($items_result)) {
                        $order_line = db_fetch($order_items);
                        update_parent_line(13, $order_line['id'], -$row['quantity']);
index 55d9b8ff990b58e6ab83924d17c9bfd9795e5582..1a11323e7330a6b5ebe2854891c9a60e36001ec5 100644 (file)
@@ -16,14 +16,16 @@ function add_sales_order(&$order)
 
        begin_transaction();
 
+       $order_no = get_next_trans_no($order->trans_type);
        $del_date = date2sql($order->due_date);
        $order_type = 0; // this is default on new order
-       $sql = "INSERT INTO ".TB_PREF."sales_orders (type, debtor_no, branch_code, customer_ref, comments, ord_date,
+       $sql = "INSERT INTO ".TB_PREF."sales_orders (order_no, type, debtor_no, trans_type, branch_code, customer_ref, reference, comments, ord_date,
                order_type, ship_via, deliver_to, delivery_address, contact_phone,
                contact_email, freight_cost, from_stk_loc, delivery_date)
-               VALUES (" .db_escape($order_type) . "," . db_escape($order->customer_id) .
-                ", " . db_escape($order->Branch) . ", ".
+               VALUES (" .db_escape($order_no) . "," .db_escape($order_type) . "," . db_escape($order->customer_id) .
+                ", " .db_escape($order->trans_type) . "," .db_escape($order->Branch) . ", ".
                        db_escape($order->cust_ref) .",". 
+                       db_escape($order->reference) .",". 
                        db_escape($order->Comments) .",'" . 
                        date2sql($order->document_date) . "', " .
                        db_escape($order->sales_type) . ", " .
@@ -38,7 +40,6 @@ function add_sales_order(&$order)
 
        db_query($sql, "order Cannot be Added");
 
-       $order_no = db_insert_id();
        $order->trans_no = array($order_no=>0);
 
        if ($loc_notification == 1)
@@ -76,8 +77,8 @@ function add_sales_order(&$order)
                        }
                }
 
-               $sql = "INSERT INTO ".TB_PREF."sales_order_details (order_no, stk_code, description, unit_price, quantity, discount_percent) VALUES (";
-               $sql .= $order_no .
+               $sql = "INSERT INTO ".TB_PREF."sales_order_details (order_no, trans_type, stk_code, description, unit_price, quantity, discount_percent) VALUES (";
+               $sql .= $order_no . ",".$order->trans_type .
                                ",".db_escape($line->stock_id).", "
                                .db_escape($line->item_description).", $line->price,
                                $line->quantity,
@@ -86,7 +87,8 @@ function add_sales_order(&$order)
 
        } /* inserted line items into sales order details */
 
-       add_audit_trail(30, $order_no, $order->document_date);
+       add_audit_trail($order->trans_type, $order_no, $order->document_date);
+       references::save($order->trans_type, $order_no, $order->reference);
        commit_transaction();
 
        if ($loc_notification == 1 && count($st_ids) > 0)
@@ -112,17 +114,17 @@ function add_sales_order(&$order)
 
 //----------------------------------------------------------------------------------------
 
-function delete_sales_order($order_no)
+function delete_sales_order($order_no, $trans_type)
 {
        begin_transaction();
 
-       $sql = "DELETE FROM ".TB_PREF."sales_orders WHERE order_no=" . $order_no;
+       $sql = "DELETE FROM ".TB_PREF."sales_orders WHERE order_no=" . $order_no . " AND trans_type=".$trans_type;
        db_query($sql, "order Header Delete");
 
-       $sql = "DELETE FROM ".TB_PREF."sales_order_details WHERE order_no =" . $order_no;
+       $sql = "DELETE FROM ".TB_PREF."sales_order_details WHERE order_no =" . $order_no . " AND trans_type=".$trans_type;
        db_query($sql, "order Detail Delete");
 
-       add_audit_trail(30, $order_no, Today(), _("Deleted."));
+       add_audit_trail($trans_type, $order_no, Today(), _("Deleted."));
        commit_transaction();
 }
 
@@ -133,7 +135,7 @@ function update_sales_order_version($order)
 {
   foreach ($order as $so_num => $so_ver) {
   $sql= 'UPDATE '.TB_PREF.'sales_orders SET version=version+1 WHERE order_no='. $so_num.
-       ' AND version='.$so_ver;
+       ' AND version='.$so_ver . " AND trans_type=30";
   db_query($sql, 'Concurrent editing conflict while sales order update');
   }
 }
@@ -155,6 +157,7 @@ function update_sales_order($order)
                debtor_no = " . db_escape($order->customer_id) . ",
                branch_code = " . db_escape($order->Branch) . ",
                customer_ref = ". db_escape($order->cust_ref) .",
+               reference = ". db_escape($order->reference) .",
                comments = ". db_escape($order->Comments) .",
                ord_date = " . db_escape($ord_date) . ",
                order_type = " .db_escape($order->sales_type) . ",
@@ -168,10 +171,10 @@ function update_sales_order($order)
                delivery_date = " .db_escape($del_date). ",
                version = ".($version+1)."
         WHERE order_no=" . $order_no ."
-        AND version=".$version;
+        AND trans_type=".$order->trans_type." AND version=".$version;
        db_query($sql, "order Cannot be Updated, this can be concurrent edition conflict");
 
-       $sql = "DELETE FROM ".TB_PREF."sales_order_details WHERE order_no =" . $order_no;
+       $sql = "DELETE FROM ".TB_PREF."sales_order_details WHERE order_no =" . $order_no . " AND trans_type=".$order->trans_type;
 
        db_query($sql, "Old order Cannot be Deleted");
 
@@ -213,10 +216,10 @@ function update_sales_order($order)
                        }
                }
                $sql = "INSERT INTO ".TB_PREF."sales_order_details
-                (order_no, stk_code,  description, unit_price, quantity,
+                (order_no, trans_type, stk_code,  description, unit_price, quantity,
                  discount_percent, qty_sent)
                 VALUES (";
-               $sql .= $order_no . ","
+               $sql .= $order_no . ",".$order->trans_type.","
                  .db_escape($line->stock_id) . ","
                  .db_escape($line->item_description) . ", "
                  .db_escape($line->price) . ", "
@@ -228,7 +231,9 @@ function update_sales_order($order)
 
        } /* inserted line items into sales order details */
 
-       add_audit_trail(30, $order_no, $order->document_date, _("Updated."));
+       add_audit_trail($order->trans_type, $order_no, $order->document_date, _("Updated."));
+       references::delete($order->trans_type, $order_no);
+       references::save($order->trans_type, $order_no, $order->reference);
        commit_transaction();
        if ($loc_notification == 1 && count($st_ids) > 0)
        {
@@ -254,7 +259,7 @@ function update_sales_order($order)
 
 //----------------------------------------------------------------------------------------
 
-function get_sales_order_header($order_no)
+function get_sales_order_header($order_no, $trans_type)
 {
        $sql = "SELECT ".TB_PREF."sales_orders.*, "
          .TB_PREF."debtors_master.name, "
@@ -282,6 +287,7 @@ function get_sales_order_header($order_no)
                AND ".TB_PREF."sales_orders.debtor_no = ".TB_PREF."debtors_master.debtor_no
                AND ".TB_PREF."locations.loc_code = ".TB_PREF."sales_orders.from_stk_loc
                AND ".TB_PREF."shippers.shipper_id = ".TB_PREF."sales_orders.ship_via
+               AND ".TB_PREF."sales_orders.trans_type = " . $trans_type ."
                AND ".TB_PREF."sales_orders.order_no = " . $order_no ;
        $result = db_query($sql, "order Retreival");
 
@@ -301,7 +307,7 @@ function get_sales_order_header($order_no)
 
 //----------------------------------------------------------------------------------------
 
-function get_sales_order_details($order_no) {
+function get_sales_order_details($order_no, $trans_type) {
        $sql = "SELECT id, stk_code, unit_price, "
                .TB_PREF."sales_order_details.description,"
                .TB_PREF."sales_order_details.quantity,
@@ -313,17 +319,17 @@ function get_sales_order_details($order_no) {
                        .TB_PREF."stock_master.overhead_cost AS standard_cost
        FROM ".TB_PREF."sales_order_details, ".TB_PREF."stock_master
        WHERE ".TB_PREF."sales_order_details.stk_code = ".TB_PREF."stock_master.stock_id
-       AND order_no =" . $order_no . " ORDER BY id";
+       AND order_no =" . $order_no . " AND trans_type = " . $trans_type . " ORDER BY id";
 
        return db_query($sql, "Retreive order Line Items");
 }
 //----------------------------------------------------------------------------------------
 
-function read_sales_order($order_no, &$order)
+function read_sales_order($order_no, &$order, $trans_type)
 {
-       $myrow = get_sales_order_header($order_no);
+       $myrow = get_sales_order_header($order_no, $trans_type);
 
-       $order->trans_type = 30;
+       $order->trans_type = $myrow['trans_type'];
        $order->so_type =  $myrow["type"];
        $order->trans_no = array($order_no=> $myrow["version"]);
 
@@ -343,11 +349,12 @@ function read_sales_order($order_no, &$order)
 
        $order->cust_ref = $myrow["customer_ref"];
        $order->sales_type =$myrow["order_type"];
+       $order->reference = $myrow["reference"];
        $order->Comments = $myrow["comments"];
        $order->due_date = sql2date($myrow["delivery_date"]);
        $order->document_date = sql2date($myrow["ord_date"]);
 
-       $result = get_sales_order_details($order_no);
+       $result = get_sales_order_details($order_no, $order->trans_type);
        if (db_num_rows($result) > 0)
        {
                $line_no=0;
index 401a725c27b3cef3f61fc4cd417dfd5724b4871b..3fa6c32b477eb16a0a2d1c026256e33c3811e68a 100644 (file)
@@ -58,7 +58,7 @@ function add_to_order(&$order, $new_item, $new_item_qty, $price, $discount)
                        if (strcasecmp($order_item->stock_id, $item['stock_id']) == 0)
                        {
                                display_warning(_("For Part :").$item['stock_id']. " " 
-                                       . _("This item is already on this order. You have been warned."));
+                                       . _("This item is already on this document. You have been warned."));
                                break;
                        }
                }
@@ -340,9 +340,7 @@ function display_order_header(&$order, $editable, $date_text, $display_tax_group
                }
        }
 
-       if ($order->trans_type != 30) {
-               ref_cells(_("Reference").':', 'ref', _('Reference number unique for this document type'), null, '');
-       }
+       ref_cells(_("Reference").':', 'ref', _('Reference number unique for this document type'), null, '');
 
        if (!is_company_currency($order->customer_currency))
        {
@@ -411,7 +409,7 @@ function display_order_header(&$order, $editable, $date_text, $display_tax_group
                        $Ajax->activate('items_table');
                        $Ajax->activate('delivery_date');
                }
-               if ($order->trans_type != 30)
+               if ($order->trans_type != 30 && $order->trans_type != 32)
                {       // 2008-11-12 Joe Hunt added dimensions
                        $dim = get_company_pref('use_dimension');
                        if ($dim > 0)
@@ -563,6 +561,11 @@ function display_delivery_details(&$order)
                        $title = _("Invoice Delivery Details");
                        $delname = _("Invoice before").':';
                }
+               elseif ($order->trans_type==32)
+               {
+                       $title = _("Quotation Delivery Details");
+                       $delname = _("Valid until").':';
+               }
                else
                {
                        $title = _("Order Delivery Details");
@@ -579,7 +582,7 @@ function display_delivery_details(&$order)
 
 
                date_row($delname, 'delivery_date',
-                       $order->trans_type==30 ?  _('Enter requested day of delivery') : '');
+                       $order->trans_type==30 ?  _('Enter requested day of delivery') : $order->trans_type==32 ? _('Enter Valid until Date') : '');
                text_row(_("Deliver To:"), 'deliver_to', $order->deliver_to, 40, 40,
                        _('Additional identifier for delivery e.g. name of receiving person'));
 
index 2269561f4e3cccc38dde98a27683253758a99d7b..9d42b4ad0b8ddba06ffbe74bea3063a02abce21d 100644 (file)
@@ -23,27 +23,40 @@ if ($use_popup_windows)
 if ($use_date_picker)
        $js .= get_js_date_picker();
 
-if (isset($_GET['OutstandingOnly']) && ($_GET['OutstandingOnly'] == true))
-{
-       $_POST['order_view_mode'] = 'OutstandingOnly';
-       $_SESSION['page_title'] = _("Search Outstanding Sales Orders");
-}
-elseif (isset($_GET['InvoiceTemplates']) && ($_GET['InvoiceTemplates'] == true))
-{
-       $_POST['order_view_mode'] = 'InvoiceTemplates';
-       $_SESSION['page_title'] = _("Search Template for Invoicing");
-}
-elseif (isset($_GET['DeliveryTemplates']) && ($_GET['DeliveryTemplates'] == true))
+if (get_post('type'))
+       $trans_type = $_POST['type'];
+elseif (isset($_GET['type']) && $_GET['type'] == 32)
+       $trans_type = 32;
+else
+       $trans_type = 30;
+if ($trans_type == 30)
 {
-       $_POST['order_view_mode'] = 'DeliveryTemplates';
-       $_SESSION['page_title'] = _("Select Template for Delivery");
+       if (isset($_GET['OutstandingOnly']) && ($_GET['OutstandingOnly'] == true))
+       {
+               $_POST['order_view_mode'] = 'OutstandingOnly';
+               $_SESSION['page_title'] = _("Search Outstanding Sales Orders");
+       }
+       elseif (isset($_GET['InvoiceTemplates']) && ($_GET['InvoiceTemplates'] == true))
+       {
+               $_POST['order_view_mode'] = 'InvoiceTemplates';
+               $_SESSION['page_title'] = _("Search Template for Invoicing");
+       }
+       elseif (isset($_GET['DeliveryTemplates']) && ($_GET['DeliveryTemplates'] == true))
+       {
+               $_POST['order_view_mode'] = 'DeliveryTemplates';
+               $_SESSION['page_title'] = _("Select Template for Delivery");
+       }
+       elseif (!isset($_POST['order_view_mode']))
+       {
+               $_POST['order_view_mode'] = false;
+               $_SESSION['page_title'] = _("Search All Sales Orders");
+       }
 }
-elseif (!isset($_POST['order_view_mode']))
+else
 {
-       $_POST['order_view_mode'] = false;
-       $_SESSION['page_title'] = _("Search All Sales Orders");
+       $_POST['order_view_mode'] = "Quotations";
+       $_SESSION['page_title'] = _("Search All Sales Quotations");
 }
-
 page($_SESSION['page_title'], false, false, "", $js);
 
 if (isset($_GET['selected_customer']))
@@ -80,30 +93,43 @@ function check_overdue($row)
 
 function view_link($dummy, $order_no)
 {
-       return  get_customer_trans_view_str(systypes::sales_order(), $order_no);
+       global $trans_type;
+       return  get_customer_trans_view_str($trans_type, $order_no);
 }
 
 function prt_link($row)
 {
-       return print_document_link($row['order_no'], _("Print"), true, 30, ICON_PRINT);
+       global $trans_type;
+       return print_document_link($row['order_no'], _("Print"), true, $trans_type, ICON_PRINT);
 }
 
 function edit_link($row) 
 {
+       global $trans_type;
+       $modify = ($trans_type == 30 ? "ModifyOrderNumber" : "ModifyQuotationNumber");
   return pager_link( _("Edit"),
-    "/sales/sales_order_entry.php?ModifyOrderNumber=" . $row['order_no'], ICON_EDIT);
+    "/sales/sales_order_entry.php?$modify=" . $row['order_no'], ICON_EDIT);
 }
 
 function dispatch_link($row)
 {
-  return pager_link( _("Dispatch"),
-       "/sales/customer_delivery.php?OrderNumber=" .$row['order_no'], ICON_DOC);
+       global $trans_type;
+       if ($trans_type == 30)
+               return pager_link( _("Dispatch"),
+                       "/sales/customer_delivery.php?OrderNumber=" .$row['order_no'], ICON_DOC);
+       else            
+               return pager_link( _("Sales Order"),
+                       "/sales/sales_order_entry.php?OrderNumber=" .$row['order_no'], ICON_DOC);
 }
 
 function invoice_link($row)
 {
-  return pager_link( _("Invoice"),
-       "/sales/sales_order_entry.php?NewInvoice=" .$row["order_no"], ICON_DOC);
+       global $trans_type;
+       if ($trans_type == 30)
+               return pager_link( _("Invoice"),
+                       "/sales/sales_order_entry.php?NewInvoice=" .$row["order_no"], ICON_DOC);
+       else
+               return '';
 }
 
 function delivery_link($row)
@@ -112,8 +138,17 @@ function delivery_link($row)
        "/sales/sales_order_entry.php?NewDelivery=" .$row['order_no'], ICON_DOC);
 }
 
+function order_link($row)
+{
+  return pager_link( _("Sales Order"),
+       "/sales/sales_order_entry.php?NewQuoteToSalesOrder=" .$row['order_no'], ICON_DOC);
+}
+
 function tmpl_checkbox($row)
 {
+       global $trans_type;
+       if ($trans_type == 32)
+               return '';
        $name = "chgtpl" .$row['order_no'];
        $value = $row['type'] ? 1:0;
 
@@ -187,6 +222,7 @@ stock_items_list_cells(_("Item:"), 'SelectStockFromList', null, true);
 submit_cells('SearchOrders', _("Search"),'',_('Select documents'), 'default');
 
 hidden('order_view_mode', $_POST['order_view_mode']);
+hidden('type', $trans_type);
 
 end_row();
 
@@ -197,6 +233,7 @@ end_form();
 //
 $sql = "SELECT 
                sorder.order_no,
+               sorder.reference,
                debtor.name,
                branch.br_name,"
                .($_POST['order_view_mode']=='InvoiceTemplates' 
@@ -215,6 +252,8 @@ $sql = "SELECT
                .TB_PREF."debtors_master as debtor, "
                .TB_PREF."cust_branch as branch
                WHERE sorder.order_no = line.order_no
+               AND sorder.trans_type = line.trans_type
+               AND sorder.trans_type = $trans_type
                AND sorder.debtor_no = debtor.debtor_no
                AND sorder.branch_code = branch.branch_code
                AND debtor.debtor_no = branch.debtor_no";
@@ -257,19 +296,34 @@ else      // ... or select inquiry constraints
                                sorder.deliver_to";
 }
 
-$cols = array(
-       _("Order #") => array('fun'=>'view_link'),
-       _("Customer"),
-       _("Branch"), 
-       _("Cust Order Ref"),
-       _("Order Date") => 'date',
-       _("Required By") =>array('type'=>'date', 'ord'=>''),
-       _("Delivery To"), 
-       _("Order Total") => array('type'=>'amount', 'ord'=>''),
-       'Type' => 'skip',
-       _("Currency") => array('align'=>'center')
-);
-
+if ($trans_type == 30)
+       $cols = array(
+               _("Order #") => array('fun'=>'view_link'),
+               _("Ref"),
+               _("Customer"),
+               _("Branch"), 
+               _("Cust Order Ref"),
+               _("Order Date") => 'date',
+               _("Required By") =>array('type'=>'date', 'ord'=>''),
+               _("Delivery To"), 
+               _("Order Total") => array('type'=>'amount', 'ord'=>''),
+               'Type' => 'skip',
+               _("Currency") => array('align'=>'center')
+       );
+else
+       $cols = array(
+               _("Quote #") => array('fun'=>'view_link'),
+               _("Ref"),
+               _("Customer"),
+               _("Branch"), 
+               _("Cust Order Ref"),
+               _("Quote Date") => 'date',
+               _("Valid until") =>array('type'=>'date', 'ord'=>''),
+               _("Delivery To"), 
+               _("Quote Total") => array('type'=>'amount', 'ord'=>''),
+               'Type' => 'skip',
+               _("Currency") => array('align'=>'center')
+       );
 if ($_POST['order_view_mode'] == 'OutstandingOnly') {
        //array_replace($cols, 3, 1, _("Cust Order Ref"));
        array_append($cols, array(array('insert'=>true, 'fun'=>'dispatch_link')));
@@ -284,7 +338,12 @@ if ($_POST['order_view_mode'] == 'OutstandingOnly') {
                        array('insert'=>true, 'fun'=>'delivery_link'))
        );
 
-} else {
+} elseif ($trans_type == 32) {
+        array_append($cols,array(
+                                       array('insert'=>true, 'fun'=>'edit_link'),
+                                       array('insert'=>true, 'fun'=>'order_link'),
+                                       array('insert'=>true, 'fun'=>'prt_link')));
+} elseif ($trans_type == 30) {
         array_append($cols,array(
                        _("Tmpl") => array('insert'=>true, 'fun'=>'tmpl_checkbox'),
                                        array('insert'=>true, 'fun'=>'edit_link'),
index d429648b08fb376f6a636b6fe897bdbfd27b92c2..e1c6b759edf706cf92e912d3583b4c168164e034 100644 (file)
@@ -11,6 +11,7 @@
 ***********************************************************************/
 //-----------------------------------------------------------------------------
 //
+//     Entry/Modify Sales Quotations
 //     Entry/Modify Sales Order
 //     Entry Direct Delivery
 //     Entry Direct Invoice
@@ -52,10 +53,23 @@ if (isset($_GET['NewDelivery']) && is_numeric($_GET['NewDelivery'])) {
        $_SESSION['page_title'] = sprintf( _("Modifying Sales Order # %d"), $_GET['ModifyOrderNumber']);
        create_cart(30, $_GET['ModifyOrderNumber']);
 
+} elseif (isset($_GET['ModifyQuotationNumber']) && is_numeric($_GET['ModifyQuotationNumber'])) {
+
+       $help_page_title = _('Modifying Sales Quotation');
+       $_SESSION['page_title'] = sprintf( _("Modifying Sales Quotation # %d"), $_GET['ModifyQuotationNumber']);
+       create_cart(32, $_GET['ModifyQuotationNumber']);
+
 } elseif (isset($_GET['NewOrder'])) {
 
        $_SESSION['page_title'] = _("New Sales Order Entry");
        create_cart(30, 0);
+} elseif (isset($_GET['NewQuotation'])) {
+
+       $_SESSION['page_title'] = _("New Sales Quotation Entry");
+       create_cart(32, 0);
+} elseif (isset($_GET['NewQuoteToSalesOrder'])) {
+       $_SESSION['page_title'] = _("Sales Order Entry");
+       create_cart(32, $_GET['NewQuoteToSalesOrder']);
 }
 
 page($_SESSION['page_title'], false, false, "", $js);
@@ -104,6 +118,41 @@ if (isset($_GET['AddedID'])) {
 
        display_footer_exit();
 
+} elseif (isset($_GET['AddedQU'])) {
+       $order_no = $_GET['AddedQU'];
+       display_notification_centered(sprintf( _("Quotation # %d has been entered."),$order_no));
+
+       submenu_view(_("&View This Quotation"), 32, $order_no);
+
+       submenu_print(_("&Print This Quotation"), 32, $order_no, 'prtopt');
+       submenu_print(_("&Email This Quotation"), 32, $order_no, null, 1);
+       set_focus('prtopt');
+       
+       submenu_option(_("Make &Sales Order Against This Quotation"),
+               "/sales/sales_order_entry.php?NewQuoteToSalesOrder=$order_no");
+
+       submenu_option(_("Enter a New &Quotation"),     "/sales/sales_order_entry.php?NewQuotation=0");
+
+       display_footer_exit();
+
+} elseif (isset($_GET['UpdatedQU'])) {
+       $order_no = $_GET['UpdatedQU'];
+
+       display_notification_centered(sprintf( _("Quotation # %d has been updated."),$order_no));
+
+       submenu_view(_("&View This Quotation"), 32, $order_no);
+
+       submenu_print(_("&Print This Quotation"), 32, $order_no, 'prtopt');
+       submenu_print(_("&Email This Quotation"), 32, $order_no, null, 1);
+       set_focus('prtopt');
+
+       submenu_option(_("Make &Sales Order Against This Quotation"),
+               "/sales/sales_order_entry.php?NewQuoteToSalesOrder=$order_no");
+
+       submenu_option(_("Select A Different &Quotation"),
+               "/sales/inquiry/sales_orders_view.php?type=32");
+
+       display_footer_exit();
 } elseif (isset($_GET['AddedDN'])) {
        $delivery = $_GET['AddedDN'];
 
@@ -158,9 +207,8 @@ function copy_to_cart()
 {
        $cart = &$_SESSION['Items'];
 
-       if ($cart->trans_type!=30) {
-               $cart->reference = $_POST['ref'];
-       } 
+       $cart->reference = $_POST['ref'];
+
        $cart->Comments =  $_POST['Comments'];
 
        $cart->document_date = $_POST['OrderDate'];
@@ -190,7 +238,7 @@ function copy_to_cart()
        $cart->Branch = $_POST['branch_id'];
        $cart->sales_type = $_POST['sales_type'];
        // POS
-       if ($cart->trans_type!=30) { // 2008-11-12 Joe Hunt
+       if ($cart->trans_type!=30 && $cart->trans_type!=32) { // 2008-11-12 Joe Hunt
                $cart->dimension_id = $_POST['dimension_id'];
                $cart->dimension2_id = $_POST['dimension2_id'];
        }       
@@ -201,9 +249,7 @@ function copy_to_cart()
 function copy_from_cart()
 {
        $cart = &$_SESSION['Items'];
-       if ($cart->trans_type!=30) {
-               $_POST['ref'] = $cart->reference;
-       }
+       $_POST['ref'] = $cart->reference;
        $_POST['Comments'] = $cart->Comments;
 
        $_POST['OrderDate'] = $cart->document_date;
@@ -224,7 +270,7 @@ function copy_from_cart()
        // POS 
        if ($cart->trans_type == 10)
                $_POST['cash'] = $cart->cash;
-       if ($cart->trans_type!=30) { // 2008-11-12 Joe Hunt
+       if ($cart->trans_type!=30 && $cart->trans_type!=32) { // 2008-11-12 Joe Hunt
                $_POST['dimension_id'] = $cart->dimension_id;
                $_POST['dimension2_id'] = $cart->dimension2_id;
        }       
@@ -247,7 +293,7 @@ function can_process() {
                set_focus('OrderDate');
                return false;
        }
-       if ($_SESSION['Items']->trans_type!=30 && !is_date_in_fiscalyear($_POST['OrderDate'])) {
+       if ($_SESSION['Items']->trans_type!=30 && $_SESSION['Items']->trans_type!=32 && !is_date_in_fiscalyear($_POST['OrderDate'])) {
                display_error(_("The entered date is not in fiscal year"));
                set_focus('OrderDate');
                return false;
@@ -279,18 +325,24 @@ function can_process() {
                        return false;
                }
                if (!is_date($_POST['delivery_date'])) {
-                       display_error(_("The delivery date is invalid."));
+                       if ($_SESSION['Items']->trans_type==32)
+                               display_error(_("The Valid date is invalid."));
+                       else    
+                               display_error(_("The delivery date is invalid."));
                        set_focus('delivery_date');
                        return false;
                }
                //if (date1_greater_date2($_SESSION['Items']->document_date, $_POST['delivery_date'])) {
                if (date1_greater_date2($_POST['OrderDate'], $_POST['delivery_date'])) {
-                       display_error(_("The requested delivery date is before the date of the order."));
+                       if ($_SESSION['Items']->trans_type==32)
+                               display_error(_("The requested valid date is before the date of the quotation."));
+                       else    
+                               display_error(_("The requested delivery date is before the date of the order."));
                        set_focus('delivery_date');
                        return false;
                }
        }
-       if ($_SESSION['Items']->trans_type != 30 && !references::is_valid($_POST['ref'])) {
+       if (!references::is_valid($_POST['ref'])) {
                display_error(_("You must enter a reference."));
                set_focus('ref');
                return false;
@@ -315,9 +367,14 @@ if (isset($_POST['ProcessOrder']) && can_process()) {
        new_doc_date($_SESSION['Items']->document_date);
        processing_end();
        if ($modified) {
-               meta_forward($_SERVER['PHP_SELF'], "UpdatedID=$trans_no");
+               if ($trans_type == 32)
+                       meta_forward($_SERVER['PHP_SELF'], "UpdatedQU=$trans_no");
+               else    
+                       meta_forward($_SERVER['PHP_SELF'], "UpdatedID=$trans_no");
        } elseif ($trans_type == 30) {
                meta_forward($_SERVER['PHP_SELF'], "AddedID=$trans_no");
+       } elseif ($trans_type == 32) {
+               meta_forward($_SERVER['PHP_SELF'], "AddedQU=$trans_no");
        } elseif ($trans_type == 10) {
                meta_forward($_SERVER['PHP_SELF'], "AddedDI=$trans_no&Type=$so_type");
        } else {
@@ -344,7 +401,7 @@ function check_item_data()
                display_error(_("You attempting to make the quantity ordered a quantity less than has already been delivered. The quantity delivered cannot be modified retrospectively."));
                return false;
        } // Joe Hunt added 2008-09-22 -------------------------
-       elseif ($_SESSION['Items']->trans_type!=30 && !sys_prefs::allow_negative_stock() &&
+       elseif ($_SESSION['Items']->trans_type!=30 && $_SESSION['Items']->trans_type!=32 && !sys_prefs::allow_negative_stock() &&
                is_inventory_item($_POST['stock_id']))
        {
                $qoh = get_qoh_on_date($_POST['stock_id'], $_POST['Location'], $_POST['OrderDate']);
@@ -418,11 +475,18 @@ function  handle_cancel_order()
                        if (sales_order_has_deliveries(key($_SESSION['Items']->trans_no)))
                                display_error(_("This order cannot be cancelled because some of it has already been invoiced or dispatched. However, the line item quantities may be modified."));
                        else {
-                               delete_sales_order(key($_SESSION['Items']->trans_no));
-
-                       display_note(_("This sales order has been cancelled as requested."), 1);
-                       submenu_option(_("Enter a New Sales Order"), $_SERVER['PHP_SELF']."?NewOrder=Yes");
-                       }
+                               delete_sales_order(key($_SESSION['Items']->trans_no), $_SESSION['Items']->trans_type);
+                               if ($_SESSION['Items']->trans_type == 32)
+                               {
+                                       display_note(_("This sales quotation has been cancelled as requested."), 1);
+                                       submenu_option(_("Enter a New Sales Quotation"), $_SERVER['PHP_SELF']."?NewQuotation=Yes");
+                               }
+                               else
+                               {
+                                       display_note(_("This sales order has been cancelled as requested."), 1);
+                                       submenu_option(_("Enter a New Sales Order"), $_SERVER['PHP_SELF']."?NewOrder=Yes");
+                               }
+                       }       
                } else {
                        processing_end();
                        meta_forward($path_to_root.'/index.php','application=orders');
@@ -442,7 +506,18 @@ function create_cart($type, $trans_no)
        processing_start();
        $doc_type = $type;
 
-       if($type != 30 && $trans_no != 0) { // this is template
+       if (isset($_GET['NewQuoteToSalesOrder']))
+       {
+               $trans_no = $_GET['NewQuoteToSalesOrder'];
+               $doc = new Cart(32, $trans_no);
+               $doc->trans_no = 0;
+               $doc->trans_type = 30;
+               $doc->reference = references::get_next($doc->trans_type);
+               $doc->document_date = $doc->due_date = new_doc_date();
+               $doc->Comments = _("Sales Quotation") . " # " . $trans_no;
+               $_SESSION['Items'] = $doc;
+       }       
+       elseif($type != 30 && $type != 32 && $trans_no != 0) { // this is template
                $doc_type = 30;
 
                $doc = new Cart(30, array($trans_no));
@@ -507,6 +582,13 @@ if ($_SESSION['Items']->trans_type == 10) {
        $deliverydetails = _("Enter Delivery Details and Confirm Dispatch");
        $cancelorder = _("Cancel Delivery");
        $porder = _("Place Delivery");
+} elseif ($_SESSION['Items']->trans_type == 32) {
+       $idate = _("Quotation Date:");
+       $orderitems = _("Sales Quotation Items");
+       $deliverydetails = _("Enter Delivery Details and Confirm Quotation");
+       $cancelorder = _("Cancel Quotation");
+       $porder = _("Place Quotation");
+       $corder = _("Commit Quotations Changes");
 } else {
        $idate = _("Order Date:");
        $orderitems = _("Sales Order Items");
@@ -536,7 +618,7 @@ if ($customer_error == "") {
 
                submit_center_first('ProcessOrder', $porder,
                    _('Check entered data and save document'), 'default');
-               submit_js_confirm('CancelOrder', _('You are about to void this Sales Order.\nDo you want to continue?'));
+               submit_js_confirm('CancelOrder', _('You are about to void this Document.\nDo you want to continue?'));
        } else {
                submit_center_first('ProcessOrder', $corder,
                    _('Validate changes and update document'), 'default');
index 45df15d5df0670bfd9002a1393fabfa763b30d3b..9e499eda7474c13d6d7f61ec76974ec81be12226 100644 (file)
@@ -38,7 +38,7 @@ $myrow = get_customer_trans($trans_id, 13);
 
 $branch = get_branch($myrow["branch_code"]);
 
-$sales_order = get_sales_order_header($myrow["order_"]);
+$sales_order = get_sales_order_header($myrow["order_"], 30);
 
 display_heading(sprintf(_("DISPATCH NOTE #%d"),$trans_id));
 
index b1aa50c5e3bb80b850b2410db2f5549e3d0d2449..410629a030cf2b62f7b9b55aca6eaa1fd37426f4 100644 (file)
@@ -38,7 +38,7 @@ $myrow = get_customer_trans($trans_id, 10);
 
 $branch = get_branch($myrow["branch_code"]);
 
-$sales_order = get_sales_order_header($myrow["order_"]);
+$sales_order = get_sales_order_header($myrow["order_"], 30);
 
 display_heading(sprintf(_("SALES INVOICE #%d"),$trans_id));
 
index 2426549546ccce2e1ad85d8f62f52c28c11d92eb..40902e445cd759d8486c870a0e0fbd688cf1dd27 100644 (file)
@@ -23,24 +23,34 @@ $js = "";
 if ($use_popup_windows)
        $js .= get_js_open_window(900, 600);
 
-page(_("View Sales Order"), true, false, "", $js);
-
-display_heading(sprintf(_("Sales Order #%d"),$_GET['trans_no']));
+if ($_GET['trans_type'] == 32)
+{
+       page(_("View Sales Quotation"), true, false, "", $js);
+       display_heading(sprintf(_("Sales Quotation #%d"),$_GET['trans_no']));
+}      
+else
+{
+       page(_("View Sales Order"), true, false, "", $js);
+       display_heading(sprintf(_("Sales Order #%d"),$_GET['trans_no']));
+}
 
 if (isset($_SESSION['View']))
 {
        unset ($_SESSION['View']);
 }
 
-$_SESSION['View'] = new Cart(30, $_GET['trans_no'], true);
+$_SESSION['View'] = new Cart($_GET['trans_type'], $_GET['trans_no'], true);
 
 start_table("$table_style2 width=95%", 5);
 echo "<tr valign=top><td>";
 display_heading2(_("Order Information"));
-echo "</td><td>";
-display_heading2(_("Deliveries"));
-echo "</td><td>";
-display_heading2(_("Invoices/Credits"));
+if ($_GET['trans_type'] != 32)
+{
+       echo "</td><td>";
+       display_heading2(_("Deliveries"));
+       echo "</td><td>";
+       display_heading2(_("Invoices/Credits"));
+}      
 echo "</td></tr>";
 
 echo "<tr valign=top><td>";
@@ -54,7 +64,10 @@ label_cells(_("Deliver To Branch"), $_SESSION['View']->deliver_to, "class='table
 end_row();
 start_row();
 label_cells(_("Ordered On"), $_SESSION['View']->document_date, "class='tableheader2'");
-label_cells(_("Requested Delivery"), $_SESSION['View']->due_date, "class='tableheader2'");
+if ($_GET['trans_type'] == 32)
+       label_cells(_("Valid until"), $_SESSION['View']->due_date, "class='tableheader2'");
+else
+       label_cells(_("Requested Delivery"), $_SESSION['View']->due_date, "class='tableheader2'");
 end_row();
 start_row();
 label_cells(_("Order Currency"), $_SESSION['View']->customer_currency, "class='tableheader2'");
@@ -63,117 +76,120 @@ end_row();
 
 label_row(_("Delivery Address"), nl2br($_SESSION['View']->delivery_address),
        "class='tableheader2'", "colspan=3");
+label_row(_("Reference"), $_SESSION['View']->reference, "class='tableheader2'", "colspan=3");
 label_row(_("Telephone"), $_SESSION['View']->phone, "class='tableheader2'", "colspan=3");
 label_row(_("E-mail"), "<a href='mailto:" . $_SESSION['View']->email . "'>" . $_SESSION['View']->email . "</a>",
        "class='tableheader2'", "colspan=3");
 label_row(_("Comments"), $_SESSION['View']->Comments, "class='tableheader2'", "colspan=3");
 end_table();
 
-echo "</td><td valign='top'>";
-
-start_table($table_style);
-display_heading2(_("Delivery Notes"));
+if ($_GET['trans_type'] != 32)
+{
+       echo "</td><td valign='top'>";
 
-$th = array(_("#"), _("Ref"), _("Date"), _("Total"));
-table_header($th);
+       start_table($table_style);
+       display_heading2(_("Delivery Notes"));
 
-$sql = "SELECT * FROM ".TB_PREF."debtor_trans WHERE type=13 AND order_=" . $_GET['trans_no'];
-$result = db_query($sql,"The related delivery notes could not be retreived");
+       $th = array(_("#"), _("Ref"), _("Date"), _("Total"));
+       table_header($th);
 
-$delivery_total = 0;
-$k = 0;
+       $sql = "SELECT * FROM ".TB_PREF."debtor_trans WHERE type=13 AND order_=" . $_GET['trans_no'];
+       $result = db_query($sql,"The related delivery notes could not be retreived");
 
-while ($del_row = db_fetch($result))
-{
+       $delivery_total = 0;
+       $k = 0;
 
-       alt_table_row_color($k);
+       while ($del_row = db_fetch($result))
+       {
 
-       $this_total = $del_row["ov_freight"]+ $del_row["ov_amount"] + $del_row["ov_freight_tax"]  + $del_row["ov_gst"] ;
-       $delivery_total += $this_total;
+               alt_table_row_color($k);
 
-       label_cell(get_customer_trans_view_str($del_row["type"], $del_row["trans_no"]));
-       label_cell($del_row["reference"]);
-       label_cell(sql2date($del_row["tran_date"]));
-       amount_cell($this_total);
-       end_row();
+               $this_total = $del_row["ov_freight"]+ $del_row["ov_amount"] + $del_row["ov_freight_tax"]  + $del_row["ov_gst"] ;
+               $delivery_total += $this_total;
 
-}
+               label_cell(get_customer_trans_view_str($del_row["type"], $del_row["trans_no"]));
+               label_cell($del_row["reference"]);
+               label_cell(sql2date($del_row["tran_date"]));
+               amount_cell($this_total);
+               end_row();
 
-label_row(null, price_format($delivery_total), "", "colspan=4 align=right");
+       }
 
-end_table();
-echo "</td><td valign='top'>";
+       label_row(null, price_format($delivery_total), "", "colspan=4 align=right");
 
-start_table($table_style);
-display_heading2(_("Sales Invoices"));
+       end_table();
+       echo "</td><td valign='top'>";
 
-$th = array(_("#"), _("Ref"), _("Date"), _("Total"));
-table_header($th);
+       start_table($table_style);
+       display_heading2(_("Sales Invoices"));
 
-$sql = "SELECT * FROM ".TB_PREF."debtor_trans WHERE type=10 AND order_=" . $_GET['trans_no'];
-$result = db_query($sql,"The related invoices could not be retreived");
+       $th = array(_("#"), _("Ref"), _("Date"), _("Total"));
+       table_header($th);
 
-$invoices_total = 0;
-$k = 0;
+       $sql = "SELECT * FROM ".TB_PREF."debtor_trans WHERE type=10 AND order_=" . $_GET['trans_no'];
+       $result = db_query($sql,"The related invoices could not be retreived");
 
-while ($inv_row = db_fetch($result))
-{
+       $invoices_total = 0;
+       $k = 0;
 
-       alt_table_row_color($k);
+       while ($inv_row = db_fetch($result))
+       {
 
-       $this_total = $inv_row["ov_freight"] + $inv_row["ov_freight_tax"]  + $inv_row["ov_gst"] + $inv_row["ov_amount"];
-       $invoices_total += $this_total;
+               alt_table_row_color($k);
 
-       label_cell(get_customer_trans_view_str($inv_row["type"], $inv_row["trans_no"]));
-       label_cell($inv_row["reference"]);
-       label_cell(sql2date($inv_row["tran_date"]));
-       amount_cell($this_total);
-       end_row();
+               $this_total = $inv_row["ov_freight"] + $inv_row["ov_freight_tax"]  + $inv_row["ov_gst"] + $inv_row["ov_amount"];
+               $invoices_total += $this_total;
 
-}
+               label_cell(get_customer_trans_view_str($inv_row["type"], $inv_row["trans_no"]));
+               label_cell($inv_row["reference"]);
+               label_cell(sql2date($inv_row["tran_date"]));
+               amount_cell($this_total);
+               end_row();
 
-label_row(null, price_format($invoices_total), "", "colspan=4 align=right");
+       }
 
-end_table();
+       label_row(null, price_format($invoices_total), "", "colspan=4 align=right");
 
-display_heading2(_("Credit Notes"));
+       end_table();
 
-start_table($table_style);
-$th = array(_("#"), _("Ref"), _("Date"), _("Total"));
-table_header($th);
+       display_heading2(_("Credit Notes"));
 
-$sql = "SELECT * FROM ".TB_PREF."debtor_trans WHERE type=11 AND order_=" . $_GET['trans_no'];
-$result = db_query($sql,"The related credit notes could not be retreived");
+       start_table($table_style);
+       $th = array(_("#"), _("Ref"), _("Date"), _("Total"));
+       table_header($th);
 
-$credits_total = 0;
-$k = 0;
+       $sql = "SELECT * FROM ".TB_PREF."debtor_trans WHERE type=11 AND order_=" . $_GET['trans_no'];
+       $result = db_query($sql,"The related credit notes could not be retreived");
 
-while ($credits_row = db_fetch($result))
-{
+       $credits_total = 0;
+       $k = 0;
 
-       alt_table_row_color($k);
+       while ($credits_row = db_fetch($result))
+       {
 
-       $this_total = $credits_row["ov_freight"] + $credits_row["ov_freight_tax"]  + $credits_row["ov_gst"] + $credits_row["ov_amount"];
-       $credits_total += $this_total;
+               alt_table_row_color($k);
 
-       label_cell(get_customer_trans_view_str($credits_row["type"], $credits_row["trans_no"]));
-       label_cell($credits_row["reference"]);
-       label_cell(sql2date($credits_row["tran_date"]));
-       amount_cell(-$this_total);
-       end_row();
+               $this_total = $credits_row["ov_freight"] + $credits_row["ov_freight_tax"]  + $credits_row["ov_gst"] + $credits_row["ov_amount"];
+               $credits_total += $this_total;
 
-}
+               label_cell(get_customer_trans_view_str($credits_row["type"], $credits_row["trans_no"]));
+               label_cell($credits_row["reference"]);
+               label_cell(sql2date($credits_row["tran_date"]));
+               amount_cell(-$this_total);
+               end_row();
 
-label_row(null, "<font color=red>" . price_format(-$credits_total) . "</font>",
-       "", "colspan=4 align=right");
+       }
 
+       label_row(null, "<font color=red>" . price_format(-$credits_total) . "</font>",
+               "", "colspan=4 align=right");
 
-end_table();
 
-echo "</td></tr>";
+       end_table();
 
-end_table();
+       echo "</td></tr>";
 
+       end_table();
+}
 echo "<center>";
 display_heading2(_("Line Details"));
 
index 470ffd95b7aa28fe207d1f336194143f3326de54..25a406f1c7588d4ef8086f0b3ecf5ac84559cf91 100644 (file)
@@ -98,3 +98,11 @@ CREATE TABLE `0_security_roles` (
 ALTER TABLE `0_company` ADD COLUMN `login_tout` SMALLINT(6) NOT NULL DEFAULT '600';
 ALTER TABLE `0_users` CHANGE COLUMN `full_access` `role_id` int(11) NOT NULL default '1';
 
+ALTER TABLE `0_sales_order_details` ADD COLUMN `trans_type` SMALLINT(6) NOT NULL DEFAULT '30' AFTER `order_no`;
+ALTER TABLE `0_sales_orders` CHANGE COLUMN `order_no` `order_no` int(11) NOT NULL;
+ALTER TABLE `0_sales_orders` ADD COLUMN `trans_type` SMALLINT(6) NOT NULL DEFAULT '30' AFTER `order_no`;
+ALTER TABLE `0_sales_orders` ADD COLUMN `reference` varchar(100) NOT NULL DEFAULT '' AFTER `branch_code`;
+ALTER TABLE `0_sales_orders` DROP PRIMARY KEY;
+ALTER TABLE `0_sales_orders` ADD PRIMARY KEY ( `trans_type` , `order_no` ); 
+UPDATE `0_sys_types` SET `type_no`=(SELECT MAX(`order_no`) FROM `0_sales_orders`), `next_reference`=(SELECT MAX(`order_no`)+1 FROM `0_sales_orders`) WHERE `type_id`=30;
+INSERT INTO `0_sys_types` (`type_id`, `type_no`, `next_reference`) VALUES (32, 0, '1');
\ No newline at end of file
index 0e10cc2ac5c1219709fc364d9cd00639ae99b460..d7d593aa339892852e3d27b0dc4972df3683ef9f 100644 (file)
@@ -1276,6 +1276,7 @@ DROP TABLE IF EXISTS `0_sales_order_details`;
 CREATE TABLE `0_sales_order_details` (
   `id` int(11) NOT NULL auto_increment,
   `order_no` int(11) NOT NULL default '0',
+  `trans_type` smallint(6) NOT NULL default '30',
   `stk_code` varchar(20) NOT NULL default '',
   `description` tinytext,
   `qty_sent` double NOT NULL default '0',
@@ -1288,11 +1289,11 @@ CREATE TABLE `0_sales_order_details` (
 
 ### Data of table `0_sales_order_details` ###
 
-INSERT INTO `0_sales_order_details` VALUES ('1', '1', '102', '17inch VGA Monitor', '2', '30.4', '2', '0');
-INSERT INTO `0_sales_order_details` VALUES ('2', '2', '102', '17inch VGA Monitor', '1', '50', '1', '0');
-INSERT INTO `0_sales_order_details` VALUES ('3', '3', '102', '17inch VGA Monitor', '1', '35.89', '1', '0');
-INSERT INTO `0_sales_order_details` VALUES ('4', '4', '102', '17inch VGA Monitor', '0', '21.28', '2', '0');
-INSERT INTO `0_sales_order_details` VALUES ('5', '5', '102', '17inch VGA Monitor', '1', '50', '1', '0');
+INSERT INTO `0_sales_order_details` VALUES ('1', '1', '30', '102', '17inch VGA Monitor', '2', '30.4', '2', '0');
+INSERT INTO `0_sales_order_details` VALUES ('2', '2', '30', '102', '17inch VGA Monitor', '1', '50', '1', '0');
+INSERT INTO `0_sales_order_details` VALUES ('3', '3', '30', '102', '17inch VGA Monitor', '1', '35.89', '1', '0');
+INSERT INTO `0_sales_order_details` VALUES ('4', '4', '30', '102', '17inch VGA Monitor', '0', '21.28', '2', '0');
+INSERT INTO `0_sales_order_details` VALUES ('5', '5', '30', '102', '17inch VGA Monitor', '1', '50', '1', '0');
 
 
 ### Structure of table `0_sales_orders` ###
@@ -1301,10 +1302,12 @@ DROP TABLE IF EXISTS `0_sales_orders`;
 
 CREATE TABLE `0_sales_orders` (
   `order_no` int(11) NOT NULL auto_increment,
+  `trans_type` smallint(6) NOT NULL default '30',
   `version` tinyint(1) unsigned NOT NULL default '0',
   `type` tinyint(1) NOT NULL default '0',
   `debtor_no` int(11) NOT NULL default '0',
   `branch_code` int(11) NOT NULL default '0',
+  `reference` varchar(100) NOT NULL default '',
   `customer_ref` tinytext NOT NULL,
   `comments` tinytext,
   `ord_date` date NOT NULL default '0000-00-00',
@@ -1317,17 +1320,16 @@ CREATE TABLE `0_sales_orders` (
   `freight_cost` double NOT NULL default '0',
   `from_stk_loc` varchar(5) NOT NULL default '',
   `delivery_date` date NOT NULL default '0000-00-00',
-  PRIMARY KEY  (`order_no`)
-) TYPE=InnoDB AUTO_INCREMENT=6 ;
-
+  PRIMARY KEY  (`trans_type`, `order_no`)
+) TYPE=InnoDB;
 
 ### Data of table `0_sales_orders` ###
 
-INSERT INTO `0_sales_orders` VALUES ('1', '1', '0', '1', '1', '', '', '2009-06-21', '2', '1', 'Address 1\r\nAddress 2\r\nAddress 3', '', '', 'Beefeater Ltd.', '10', 'DEF', '2009-06-22');
-INSERT INTO `0_sales_orders` VALUES ('2', '1', '0', '2', '2', '', '', '2009-06-21', '1', '1', 'Address 1\r\nAddress 2\r\nAddress 3', '', '', 'Ghostbusters Corp.', '0', 'DEF', '2009-06-22');
-INSERT INTO `0_sales_orders` VALUES ('3', '1', '0', '3', '3', '', '', '2009-06-21', '2', '1', 'Address 1\r\nAddress 2\r\nAddress 3', '', '', 'Brezan', '0', 'DEF', '2009-07-01');
-INSERT INTO `0_sales_orders` VALUES ('4', '0', '0', '1', '1', '', '', '2009-06-21', '2', '1', 'Address 1\r\nAddress 2\r\nAddress 3', '', '', 'Beefeater Ltd.', '0', 'DEF', '2009-06-22');
-INSERT INTO `0_sales_orders` VALUES ('5', '1', '0', '2', '2', '', '', '2009-06-21', '1', '1', 'Address 1\r\nAddress 2\r\nAddress 3', '', '', 'Ghostbusters Corp.', '5', 'DEF', '2009-06-22');
+INSERT INTO `0_sales_orders` VALUES ('1', '30', '1', '0', '1', '1', '1', '', '', '2009-06-21', '2', '1', 'Address 1\r\nAddress 2\r\nAddress 3', '', '', 'Beefeater Ltd.', '10', 'DEF', '2009-06-22');
+INSERT INTO `0_sales_orders` VALUES ('2', '30', '1', '0', '2', '2', '2', '', '', '2009-06-21', '1', '1', 'Address 1\r\nAddress 2\r\nAddress 3', '', '', 'Ghostbusters Corp.', '0', 'DEF', '2009-06-22');
+INSERT INTO `0_sales_orders` VALUES ('3', '30', '1', '0', '3', '3', '3', '', '', '2009-06-21', '2', '1', 'Address 1\r\nAddress 2\r\nAddress 3', '', '', 'Brezan', '0', 'DEF', '2009-07-01');
+INSERT INTO `0_sales_orders` VALUES ('4', '30', '0', '0', '1', '1', '4', '', '', '2009-06-21', '2', '1', 'Address 1\r\nAddress 2\r\nAddress 3', '', '', 'Beefeater Ltd.', '0', 'DEF', '2009-06-22');
+INSERT INTO `0_sales_orders` VALUES ('5', '30', '1', '0', '2', '2', '5', '', '', '2009-06-21', '1', '1', 'Address 1\r\nAddress 2\r\nAddress 3', '', '', 'Ghostbusters Corp.', '5', 'DEF', '2009-06-22');
 
 
 ### Structure of table `0_sales_pos` ###
@@ -1705,27 +1707,28 @@ CREATE TABLE `0_sys_types` (
 
 ### Data of table `0_sys_types` ###
 
-INSERT INTO `0_sys_types` VALUES ('0', 'Journal - GL', '19', '3');
-INSERT INTO `0_sys_types` VALUES ('1', 'Payment - GL', '8', '2');
-INSERT INTO `0_sys_types` VALUES ('2', 'Receipt - GL', '5', '2');
-INSERT INTO `0_sys_types` VALUES ('4', 'Funds Transfer', '3', '1');
-INSERT INTO `0_sys_types` VALUES ('10', 'Sales Invoice', '19', '4');
-INSERT INTO `0_sys_types` VALUES ('11', 'Credit Note', '3', '2');
-INSERT INTO `0_sys_types` VALUES ('12', 'Receipt', '6', '1');
-INSERT INTO `0_sys_types` VALUES ('13', 'Delivery', '5', '2');
-INSERT INTO `0_sys_types` VALUES ('16', 'Location Transfer', '2', '1');
-INSERT INTO `0_sys_types` VALUES ('17', 'Inventory Adjustment', '2', '1');
-INSERT INTO `0_sys_types` VALUES ('18', 'Purchase Order', '1', '3');
-INSERT INTO `0_sys_types` VALUES ('20', 'Supplier Invoice', '8', '3');
-INSERT INTO `0_sys_types` VALUES ('21', 'Supplier Credit Note', '1', '1');
-INSERT INTO `0_sys_types` VALUES ('22', 'Supplier Payment', '4', '2');
-INSERT INTO `0_sys_types` VALUES ('25', 'Purchase Order Delivery', '1', '2');
-INSERT INTO `0_sys_types` VALUES ('26', 'Work Order', '1', '8');
-INSERT INTO `0_sys_types` VALUES ('28', 'Work Order Issue', '1', '1');
-INSERT INTO `0_sys_types` VALUES ('29', 'Work Order Production', '1', '2');
-INSERT INTO `0_sys_types` VALUES ('30', 'Sales Order', '1', '1');
-INSERT INTO `0_sys_types` VALUES ('35', 'Cost Update', '1', '1');
-INSERT INTO `0_sys_types` VALUES ('40', 'Dimension', '1', '3');
+INSERT INTO `0_sys_types` VALUES ('0', '19', '3');
+INSERT INTO `0_sys_types` VALUES ('1', '8', '2');
+INSERT INTO `0_sys_types` VALUES ('2', '5', '2');
+INSERT INTO `0_sys_types` VALUES ('4', '3', '1');
+INSERT INTO `0_sys_types` VALUES ('10', '19', '4');
+INSERT INTO `0_sys_types` VALUES ('11', '3', '2');
+INSERT INTO `0_sys_types` VALUES ('12', '6', '1');
+INSERT INTO `0_sys_types` VALUES ('13', '5', '2');
+INSERT INTO `0_sys_types` VALUES ('16', '2', '1');
+INSERT INTO `0_sys_types` VALUES ('17', '2', '1');
+INSERT INTO `0_sys_types` VALUES ('18', '1', '3');
+INSERT INTO `0_sys_types` VALUES ('20', '8', '3');
+INSERT INTO `0_sys_types` VALUES ('21', '1', '1');
+INSERT INTO `0_sys_types` VALUES ('22', '4', '2');
+INSERT INTO `0_sys_types` VALUES ('25', '1', '2');
+INSERT INTO `0_sys_types` VALUES ('26', '1', '8');
+INSERT INTO `0_sys_types` VALUES ('28', '1', '1');
+INSERT INTO `0_sys_types` VALUES ('29', '1', '2');
+INSERT INTO `0_sys_types` VALUES ('30', '5', '6');
+INSERT INTO `0_sys_types` VALUES ('32', '0', '1');
+INSERT INTO `0_sys_types` VALUES ('35', '1', '1');
+INSERT INTO `0_sys_types` VALUES ('40', '1', '3');
 
 
 ### Structure of table `0_tax_group_items` ###
index 27593590e54b7de38f2107f4b2c25a1fb98398f7..a36884e81d80f5aee711283a03ab6232aafe4c6c 100644 (file)
@@ -1117,6 +1117,7 @@ DROP TABLE IF EXISTS `0_sales_order_details`;
 CREATE TABLE `0_sales_order_details` (
   `id` int(11) NOT NULL auto_increment,
   `order_no` int(11) NOT NULL default '0',
+  `trans_type` smallint(6) NOT NULL default '30',
   `stk_code` varchar(20) NOT NULL default '',
   `description` tinytext,
   `qty_sent` double NOT NULL default '0',
@@ -1137,10 +1138,12 @@ DROP TABLE IF EXISTS `0_sales_orders`;
 
 CREATE TABLE `0_sales_orders` (
   `order_no` int(11) NOT NULL auto_increment,
+  `trans_type` smallint(6) NOT NULL default '30',
   `version` tinyint(1) unsigned NOT NULL default '0',
   `type` tinyint(1) NOT NULL default '0',
   `debtor_no` int(11) NOT NULL default '0',
   `branch_code` int(11) NOT NULL default '0',
+  `reference` varchar(100) NOT NULL default '',
   `customer_ref` tinytext NOT NULL,
   `comments` tinytext,
   `ord_date` date NOT NULL default '0000-00-00',
@@ -1153,8 +1156,8 @@ CREATE TABLE `0_sales_orders` (
   `freight_cost` double NOT NULL default '0',
   `from_stk_loc` varchar(5) NOT NULL default '',
   `delivery_date` date NOT NULL default '0000-00-00',
-  PRIMARY KEY  (`order_no`)
-) TYPE=InnoDB  AUTO_INCREMENT=1 ;
+  PRIMARY KEY  (`trans_type`, `order_no`)
+) TYPE=InnoDB;
 
 
 ### Data of table `0_sales_orders` ###
@@ -1484,27 +1487,28 @@ CREATE TABLE `0_sys_types` (
 
 ### Data of table `0_sys_types` ###
 
-INSERT INTO `0_sys_types` VALUES ('0', 'Journal - GL', '17', '1');
-INSERT INTO `0_sys_types` VALUES ('1', 'Payment - GL', '7', '1');
-INSERT INTO `0_sys_types` VALUES ('2', 'Receipt - GL', '4', '1');
-INSERT INTO `0_sys_types` VALUES ('4', 'Funds Transfer', '3', '1');
-INSERT INTO `0_sys_types` VALUES ('10', 'Sales Invoice', '16', '1');
-INSERT INTO `0_sys_types` VALUES ('11', 'Credit Note', '2', '1');
-INSERT INTO `0_sys_types` VALUES ('12', 'Receipt', '6', '1');
-INSERT INTO `0_sys_types` VALUES ('13', 'Delivery', '1', '1');
-INSERT INTO `0_sys_types` VALUES ('16', 'Location Transfer', '2', '1');
-INSERT INTO `0_sys_types` VALUES ('17', 'Inventory Adjustment', '2', '1');
-INSERT INTO `0_sys_types` VALUES ('18', 'Purchase Order', '1', '1');
-INSERT INTO `0_sys_types` VALUES ('20', 'Supplier Invoice', '6', '1');
-INSERT INTO `0_sys_types` VALUES ('21', 'Supplier Credit Note', '1', '1');
-INSERT INTO `0_sys_types` VALUES ('22', 'Supplier Payment', '3', '1');
-INSERT INTO `0_sys_types` VALUES ('25', 'Purchase Order Delivery', '1', '1');
-INSERT INTO `0_sys_types` VALUES ('26', 'Work Order', '1', '1');
-INSERT INTO `0_sys_types` VALUES ('28', 'Work Order Issue', '1', '1');
-INSERT INTO `0_sys_types` VALUES ('29', 'Work Order Production', '1', '1');
-INSERT INTO `0_sys_types` VALUES ('30', 'Sales Order', '1', '1');
-INSERT INTO `0_sys_types` VALUES ('35', 'Cost Update', '1', '1');
-INSERT INTO `0_sys_types` VALUES ('40', 'Dimension', '1', '1');
+INSERT INTO `0_sys_types` VALUES ('0', '17', '1');
+INSERT INTO `0_sys_types` VALUES ('1', '7', '1');
+INSERT INTO `0_sys_types` VALUES ('2', '4', '1');
+INSERT INTO `0_sys_types` VALUES ('4', '3', '1');
+INSERT INTO `0_sys_types` VALUES ('10', '16', '1');
+INSERT INTO `0_sys_types` VALUES ('11', '2', '1');
+INSERT INTO `0_sys_types` VALUES ('12', '6', '1');
+INSERT INTO `0_sys_types` VALUES ('13', '1', '1');
+INSERT INTO `0_sys_types` VALUES ('16', '2', '1');
+INSERT INTO `0_sys_types` VALUES ('17', '2', '1');
+INSERT INTO `0_sys_types` VALUES ('18', '1', '1');
+INSERT INTO `0_sys_types` VALUES ('20', '6', '1');
+INSERT INTO `0_sys_types` VALUES ('21', '1', '1');
+INSERT INTO `0_sys_types` VALUES ('22', '3', '1');
+INSERT INTO `0_sys_types` VALUES ('25', '1', '1');
+INSERT INTO `0_sys_types` VALUES ('26', '1', '1');
+INSERT INTO `0_sys_types` VALUES ('28', '1', '1');
+INSERT INTO `0_sys_types` VALUES ('29', '1', '1');
+INSERT INTO `0_sys_types` VALUES ('30', '0', '1');
+INSERT INTO `0_sys_types` VALUES ('32', '0', '1');
+INSERT INTO `0_sys_types` VALUES ('35', '1', '1');
+INSERT INTO `0_sys_types` VALUES ('40', '1', '1');
 
 
 ### Structure of table `0_tax_group_items` ###