X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=sales%2Fsales_order_entry.php;h=f9933b318d7919f7ce3750cd605c2a2c2aa94210;hb=d5618f84e921515fa6ce6ec05180f0651119c297;hp=da9b9ce9a275b94a72ae8c3a1534eeaec92d6ae3;hpb=577d3d8612aa89660a73de2ffa14b1b16f7e9758;p=fa-stable.git diff --git a/sales/sales_order_entry.php b/sales/sales_order_entry.php index da9b9ce9..f9933b31 100644 --- a/sales/sales_order_entry.php +++ b/sales/sales_order_entry.php @@ -231,6 +231,9 @@ if (isset($_GET['AddedID'])) { submenu_option(_("Enter a &New Direct Invoice"), "/sales/sales_order_entry.php?NewInvoice=0"); + if ($row === false) + submenu_option(_("Entry &customer payment for this invoice"), "/sales/customer_payments.php?SInvoice=".$invoice); + submenu_option(_("Add an Attachment"), "/admin/attachments.php?filterType=".ST_SALESINVOICE."&trans_no=$invoice"); display_footer_exit(); @@ -284,6 +287,7 @@ function copy_to_cart() $cart->dimension_id = $_POST['dimension_id']; $cart->dimension2_id = $_POST['dimension2_id']; } + $cart->ex_rate = input_num('_ex_rate', null); } //----------------------------------------------------------------------------- @@ -314,9 +318,9 @@ function copy_from_cart() if ($cart->trans_type!=ST_SALESORDER && $cart->trans_type!=ST_SALESQUOTE) { // 2008-11-12 Joe Hunt $_POST['dimension_id'] = $cart->dimension_id; $_POST['dimension2_id'] = $cart->dimension2_id; - } + } $_POST['cart_id'] = $cart->cart_id; - + $_POST['_ex_rate'] = $cart->ex_rate; } //-------------------------------------------------------------------------------- @@ -329,7 +333,10 @@ function line_start_focus() { //-------------------------------------------------------------------------------- function can_process() { - global $Refs; + + global $Refs, $SysPrefs; + + copy_to_cart(); if (!get_post('customer_id')) { @@ -360,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'); @@ -390,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.")); @@ -431,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; @@ -501,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) @@ -591,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 @@ -716,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 ""; @@ -729,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); }