X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=sales%2Fincludes%2Fui%2Fsales_order_ui.inc;h=2af450093abb0b65674e65a839d28c378db532cd;hb=84ebe8b3ebc1fc3e6508d75a4f39ce4a868b0b14;hp=841294de4ec3eb03b97c46405454cb844e59ace4;hpb=758eda4e8cef6af76516199636f64415150b6da3;p=fa-stable.git diff --git a/sales/includes/ui/sales_order_ui.inc b/sales/includes/ui/sales_order_ui.inc index 841294de..2af45009 100644 --- a/sales/includes/ui/sales_order_ui.inc +++ b/sales/includes/ui/sales_order_ui.inc @@ -72,6 +72,8 @@ function add_to_order(&$order, $new_item, $new_item_qty, $price, $discount, $des function get_customer_details_to_order(&$order, $customer_id, $branch_id) { + global $SysPrefs; + $ret_error = ""; $myrow = get_customer_to_order($customer_id); @@ -116,9 +118,11 @@ function get_customer_details_to_order(&$order, $customer_id, $branch_id) $order->set_delivery($myrow["default_ship_via"], $myrow["br_name"], $address); - if ($order->trans_type == ST_SALESINVOICE || $order->trans_type == ST_SALESORDER) { + if ($order->trans_type == ST_SALESINVOICE) { $order->due_date = get_invoice_duedate($order->payment, $order->document_date); } + elseif ($order->trans_type == ST_SALESORDER) + $order->due_date = add_days($order->document_date, $SysPrefs->default_delivery_required_by()); if($order->payment_terms['cash_sale']) { $order->set_location($order->pos["pos_location"], $order->pos["location_name"]); } else @@ -155,7 +159,8 @@ function display_order_summary($title, &$order, $editable_items=false) $id = find_submit('Edit'); $has_marked = false; - foreach ($order->line_items as $line_no=>$stock_item) + + foreach ($order->get_items() as $line_no=>$stock_item) { $line_total = round($stock_item->qty_dispatched * $stock_item->price * (1 - $stock_item->discount_percent), @@ -164,10 +169,11 @@ function display_order_summary($title, &$order, $editable_items=false) $qoh_msg = ''; if (!$editable_items || $id != $line_no) { - if (!$SysPrefs->allow_negative_stock() && is_inventory_item($stock_item->stock_id)) { + if (!$SysPrefs->allow_negative_stock() && is_inventory_item($stock_item->stock_id) && + $order->trans_type != ST_SALESORDER && $order->trans_type!=ST_SALESQUOTE) { $qoh = get_qoh_on_date($stock_item->stock_id, $_POST['Location'], $_POST['delivery_date']); - if ($stock_item->qty_dispatched > $qoh) + if (($stock_item->qty_dispatched -$stock_item->qty_done) > $qoh) { // oops, we don't have enough of one of the component items start_row("class='stockmankobg'"); @@ -366,7 +372,6 @@ function display_order_header(&$order, $editable, $date_text) $row = get_customer_to_order($_POST['customer_id']); if ($row['dissallow_invoices'] == 1) $customer_error = _("The selected customer account is currently on hold. Please contact the credit control personnel to discuss."); - } } @@ -374,10 +379,10 @@ function display_order_header(&$order, $editable, $date_text) table_section(2); - if (!is_company_currency($order->customer_currency)) + if (!is_company_currency($order->customer_currency) && in_array($order->trans_type, array(ST_SALESINVOICE, ST_CUSTDELIVERY))) { label_row(_("Customer Currency:"), $order->customer_currency); - exchange_rate_display($order->customer_currency, get_company_currency(), + exchange_rate_display(get_company_currency(), $order->customer_currency, ($editable ? $_POST['OrderDate'] : $order->document_date)); } @@ -514,7 +519,7 @@ function sales_order_item_controls(&$order, &$rowcounter, $line_no=-1) } else // prepare new line { - sales_items_list_cells(null,'stock_id', null, false, true); + sales_items_list_cells(null,'stock_id', null, false, true, true); if (list_updated('stock_id')) { $Ajax->activate('price'); $Ajax->activate('units'); @@ -588,6 +593,7 @@ function display_delivery_details(&$order) label_row(_("Cash account:"), $order->pos['bank_account_name']); textarea_row(_("Comments:"), "Comments", $order->Comments, 31, 5); end_table(); + hidden('delivery_date', $order->due_date); } else { if ($order->trans_type==ST_SALESINVOICE) {