X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=sales%2Fincludes%2Fui%2Fsales_order_ui.inc;h=bd99f58eeb8a5893d56cdbb2523c0c4d0800fe8a;hb=66edc790311eeda85eebd78c92d700b3b142920c;hp=4b697c514f6526d4dd2307e7e4fa2cedab40b085;hpb=61759ecf1b57f8bca2cbedf9c031974412f9e816;p=fa-stable.git diff --git a/sales/includes/ui/sales_order_ui.inc b/sales/includes/ui/sales_order_ui.inc index 4b697c51..bd99f58e 100644 --- a/sales/includes/ui/sales_order_ui.inc +++ b/sales/includes/ui/sales_order_ui.inc @@ -353,7 +353,7 @@ function display_order_header(&$order, $editable, $date_text) else { $row = get_customer_to_order($_POST['customer_id']); - if ($row['dissallow_invoices'] == 1) + if ($row && $row['dissallow_invoices'] == 1) $customer_error = _("The selected customer account is currently on hold. Please contact the credit control personnel to discuss."); } } @@ -378,7 +378,7 @@ function display_order_header(&$order, $editable, $date_text) if (($order->pos['cash_sale'] || $order->pos['credit_sale']) && !$order->is_started()) { // editable payment type - if (get_post('payment') !== $order->payment) { + if (isset($_POST['payment']) && $_POST['payment'] !== $order->payment) { $order->payment = get_post('payment'); $order->payment_terms = get_payment_terms($order->payment); $order->due_date = get_invoice_duedate($order->payment, $order->document_date); @@ -490,7 +490,7 @@ function sales_order_item_controls(&$order, &$rowcounter, $line_no=-1) hidden('stock_id', $_POST['stock_id']); label_cell($_POST['stock_id']); if ($order->line_items[$id]->descr_editable) - text_cells(null,'item_description', null, 45, 150); + text_cells(null,'item_description', null, 45, 50); else { hidden('item_description', $_POST['item_description']); label_cell($_POST['item_description']); @@ -500,19 +500,26 @@ function sales_order_item_controls(&$order, &$rowcounter, $line_no=-1) else // prepare new line { if ($order->fixed_asset) - stock_disposable_fa_list_cells(null,'stock_id', null, _('[Select item]'), true, $order->line_items); - else - sales_items_list_cells(null,'stock_id', null, false, true, true); - if (list_updated('stock_id')) { - $Ajax->activate('price'); - $Ajax->activate('units'); - $Ajax->activate('qty'); - $Ajax->activate('line_total'); - } + stock_disposable_fa_list_cells(null,'stock_id', null, _('[Select item]'), true, $order->line_items); + else { + if (!isset($_POST['stock_id'])) { // Check if stock_id dosesn't exist + $_POST['stock_id'] = last_sales_order_detail($order, 'stk_code'); //get the llast sales stock id. + } + sales_items_list_cells(null,'stock_id', $_POST['stock_id'], false, true, true); + } + if (list_updated('stock_id')) { + $Ajax->activate('price'); + $Ajax->activate('units'); + $Ajax->activate('qty'); + $Ajax->activate('line_total'); + } $item_info = get_item_edit_info($_POST['stock_id']); - $units = $item_info["units"]; - $dec = $item_info['decimals']; + $units = ''; $dec = 2; + if ($item_info) { + $units = $item_info["units"]; + $dec = $item_info['decimals']; + } $_POST['qty'] = number_format2(1, $dec); $price = get_kit_price($_POST['stock_id'], $order->customer_currency, $order->sales_type, @@ -621,11 +628,11 @@ function display_delivery_details(&$order) date_row($delname, 'delivery_date', $order->trans_type==ST_SALESORDER ? _('Enter requested day of delivery') - : $order->trans_type==ST_SALESQUOTE ? _('Enter Valid until Date') : ''); + : ($order->trans_type==ST_SALESQUOTE ? _('Enter Valid until Date') : '')); text_row(_("Deliver To:"), 'deliver_to', $order->deliver_to, 50, 60, _('Additional identifier for delivery e.g. name of receiving person')); - textarea_row(_("Address:"), 'delivery_address', $order->delivery_address, 35, 5, + textarea_row(_("Address:"), 'delivery_address', $order->delivery_address, 35, 5, 255, _('Delivery address. Default is address of customer branch')); table_section(2);