X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=sales%2Fsales_order_entry.php;h=f9933b318d7919f7ce3750cd605c2a2c2aa94210;hb=d5618f84e921515fa6ce6ec05180f0651119c297;hp=9b7e46b4dc57adf2eaff3d70aa0f635390119800;hpb=be99f1e63f8e27c2c5db75f93cd9956eb2239a03;p=fa-stable.git diff --git a/sales/sales_order_entry.php b/sales/sales_order_entry.php index 9b7e46b4..f9933b31 100644 --- a/sales/sales_order_entry.php +++ b/sales/sales_order_entry.php @@ -333,7 +333,10 @@ function line_start_focus() { //-------------------------------------------------------------------------------- function can_process() { - global $Refs; + + global $Refs, $SysPrefs; + + copy_to_cart(); if (!get_post('customer_id')) { @@ -364,14 +367,20 @@ function can_process() { set_focus('AddItem'); return false; } - if ($_SESSION['Items']->payment_terms['cash_sale'] == 0) { - if (strlen($_POST['deliver_to']) <= 1) { - display_error(_("You must enter the person or company to whom delivery should be made to.")); - set_focus('deliver_to'); + + if (!$SysPrefs->allow_negative_stock() && ($low_stock = $_SESSION['Items']->check_qoh())) + { + display_error(_("This document cannot be processed because there is insufficient quantity for items marked.")); return false; } + if ($_SESSION['Items']->payment_terms['cash_sale'] == 0) { + if (strlen($_POST['deliver_to']) <= 1) { + display_error(_("You must enter the person or company to whom delivery should be made to.")); + set_focus('deliver_to'); + return false; + } if ($_SESSION['Items']->trans_type != ST_SALESQUOTE && strlen($_POST['delivery_address']) <= 1) { display_error( _("You should enter the street address in the box provided. Orders cannot be accepted without a valid street address.")); set_focus('delivery_address'); @@ -394,7 +403,6 @@ function can_process() { 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'])) { if ($_SESSION['Items']->trans_type==ST_SALESQUOTE) display_error(_("The requested valid date is before the date of the quotation.")); @@ -435,7 +443,7 @@ if (isset($_POST['update'])) { } if (isset($_POST['ProcessOrder']) && can_process()) { - copy_to_cart(); + $modified = ($_SESSION['Items']->trans_no != 0); $so_type = $_SESSION['Items']->so_type; @@ -505,21 +513,8 @@ function check_item_data() set_focus('qty'); 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 ($is_inventory_item && $_SESSION['Items']->trans_type!=ST_SALESORDER && $_SESSION['Items']->trans_type!=ST_SALESQUOTE - && !$SysPrefs->allow_negative_stock()) - { - $qoh = get_qoh_on_date($_POST['stock_id'], $_POST['Location'], $_POST['OrderDate']); - if (input_num('qty') > $qoh) - { - $stock = get_item($_POST['stock_id']); - display_error(_("The delivery cannot be processed because there is an insufficient quantity for item:") . - " " . $stock['stock_id'] . " - " . $stock['description'] . " - " . - _("Quantity On Hand") . " = " . number_format2($qoh, get_qty_dec($_POST['stock_id']))); - return false; - } - return true; } + $cost_home = get_standard_cost(get_post('stock_id')); // Added 2011-03-27 Joe Hunt $cost = $cost_home / get_exchange_rate_from_home_currency($_SESSION['Items']->customer_currency, $_SESSION['Items']->document_date); if (input_num('price') < $cost) @@ -595,7 +590,8 @@ function handle_cancel_order() submenu_option(_("Enter a New Sales Invoice"), "/sales/sales_order_entry.php?NewInvoice=1"); } elseif ($_SESSION['Items']->trans_type == ST_SALESQUOTE) { - delete_sales_order(key($_SESSION['Items']->trans_no), $_SESSION['Items']->trans_type); + if ($_SESSION['Items']->trans_no != 0) + delete_sales_order(key($_SESSION['Items']->trans_no), $_SESSION['Items']->trans_type); display_notification(_("This sales quotation has been cancelled as requested."), 1); submenu_option(_("Enter a New Sales Quotation"), "/sales/sales_order_entry.php?NewQuotation=Yes"); } else { // sales order @@ -720,7 +716,7 @@ $customer_error = display_order_header($_SESSION['Items'], ($_SESSION['Items']->any_already_delivered() == 0), $idate); if ($customer_error == "") { - start_table(TABLESTYLE, "width=80%", 10); + start_table(TABLESTYLE, "width='80%'", 10); echo ""; display_order_summary($orderitems, $_SESSION['Items'], true); echo ""; @@ -733,16 +729,20 @@ if ($customer_error == "") { submit_center_first('ProcessOrder', $porder, _('Check entered data and save document'), 'default'); + submit_center_last('CancelOrder', $cancelorder, + _('Cancels document entry or removes sales order when editing an old document'), true); submit_js_confirm('CancelOrder', _('You are about to void this Document.\nDo you want to continue?')); } else { - if ($_SESSION['Items']->trans_type==ST_SALESORDER) - submit_js_confirm('CancelOrder', _('You are about to cancel undelivered part of this order.\nDo you want to continue?')); submit_center_first('ProcessOrder', $corder, _('Validate changes and update document'), 'default'); + submit_center_last('CancelOrder', $cancelorder, + _('Cancels document entry or removes sales order when editing an old document'), true); + if ($_SESSION['Items']->trans_type==ST_SALESORDER) + submit_js_confirm('CancelOrder', _('You are about to cancel undelivered part of this order.\nDo you want to continue?')); + else + submit_js_confirm('CancelOrder', _('You are about to void this Document.\nDo you want to continue?')); } - submit_center_last('CancelOrder', $cancelorder, - _('Cancels document entry or removes sales order when editing an old document')); } else { display_error($customer_error); }