! -> 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
$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");
$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?");
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"))
);
return 30;
}
+ function sales_quotation()
+ {
+ return 32;
+ }
+
function cost_update()
{
return 35;
$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;
$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);
}
$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");
}
$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 {
$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");
}
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");
$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
}
$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 {
$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");
}
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";
$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');
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
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':
".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'
$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)
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)
{
$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))
{
$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);
}
}
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());
--- /dev/null
+<?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
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'),
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);
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);
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
/*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 );
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];
} 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"];
$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));
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)
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
$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']);
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) . ", " .
db_query($sql, "order Cannot be Added");
- $order_no = db_insert_id();
$order->trans_no = array($order_no=>0);
if ($loc_notification == 1)
}
}
- $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,
} /* 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)
//----------------------------------------------------------------------------------------
-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();
}
{
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');
}
}
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) . ",
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");
}
}
$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) . ", "
} /* 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)
{
//----------------------------------------------------------------------------------------
-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, "
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");
//----------------------------------------------------------------------------------------
-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,
.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"]);
$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;
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;
}
}
}
}
- 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))
{
$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)
$title = _("Invoice Delivery Details");
$delname = _("Invoice before").':';
}
+ elseif ($order->trans_type==32)
+ {
+ $title = _("Quotation Delivery Details");
+ $delname = _("Valid until").':';
+ }
else
{
$title = _("Order Delivery Details");
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'));
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']))
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)
"/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;
submit_cells('SearchOrders', _("Search"),'',_('Select documents'), 'default');
hidden('order_view_mode', $_POST['order_view_mode']);
+hidden('type', $trans_type);
end_row();
//
$sql = "SELECT
sorder.order_no,
+ sorder.reference,
debtor.name,
branch.br_name,"
.($_POST['order_view_mode']=='InvoiceTemplates'
.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";
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')));
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'),
***********************************************************************/
//-----------------------------------------------------------------------------
//
+// Entry/Modify Sales Quotations
// Entry/Modify Sales Order
// Entry Direct Delivery
// Entry Direct Invoice
$_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);
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'];
{
$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'];
$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'];
}
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;
// 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;
}
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;
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;
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 {
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']);
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');
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));
$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");
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');
$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));
$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));
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>";
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'");
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"));
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
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',
### 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` ###
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',
`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` ###
### 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` ###
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',
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',
`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` ###
### 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` ###