X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=sales%2Fincludes%2Fui%2Fsales_order_ui.inc;h=bd99f58eeb8a5893d56cdbb2523c0c4d0800fe8a;hb=6c40a3be4a79826087d7abbdd11b483f19decc2a;hp=ce0b8604c9f6d4e3fbc1472a766c23896cd6ac04;hpb=17b390efcf904072b02ec866b2a427490471a260;p=fa-stable.git diff --git a/sales/includes/ui/sales_order_ui.inc b/sales/includes/ui/sales_order_ui.inc index ce0b8604..bd99f58e 100644 --- a/sales/includes/ui/sales_order_ui.inc +++ b/sales/includes/ui/sales_order_ui.inc @@ -10,7 +10,6 @@ See the License here . ***********************************************************************/ include_once($path_to_root . "/sales/includes/cart_class.inc"); -include_once($path_to_root . "/includes/manufacturing.inc"); //-------------------------------------------------------------------------------- function add_to_order(&$order, $new_item, $new_item_qty, $price, $discount, $description='') @@ -44,27 +43,27 @@ function add_to_order(&$order, $new_item, $new_item_qty, $price, $discount, $des } $item_price = round($item_price, user_price_dec()); - if (!$item['is_foreign'] && $item['item_code'] != $item['stock_id']) - { // this is sales kit - recurse - add_to_order($order, $item['stock_id'], $new_item_qty*$item['quantity'], - $item_price, $discount); - } - else - { // stock item record eventually with foreign code + if (!$item['is_foreign'] && $item['item_code'] != $item['stock_id']) + { // this is sales kit - recurse + add_to_order($order, $item['stock_id'], $new_item_qty*$item['quantity'], + $item_price, $discount); + } + else + { // stock item record eventually with foreign code - // check duplicate stock item - foreach ($order->line_items as $order_item) - { - if (strcasecmp($order_item->stock_id, $item['stock_id']) == 0) + // check duplicate stock item + foreach ($order->line_items as $order_item) { - display_warning(_("For Part :").$item['stock_id']. " " - . _("This item is already on this document. You have been warned.")); - break; + if (strcasecmp($order_item->stock_id, $item['stock_id']) == 0) + { + display_warning(_("For Part :").$item['stock_id']. " " + . _("This item is already on this document. You have been warned.")); + break; + } } + $order->add_to_cart (count($order->line_items), $item['stock_id'], + $new_item_qty*$item['quantity'], $item_price, $discount, 0,0, $description); } - $order->add_to_cart (count($order->line_items), $item['stock_id'], - $new_item_qty*$item['quantity'], $item_price, $discount, 0,0, $description); - } } } @@ -179,7 +178,6 @@ function display_order_summary($title, &$order, $editable_items=false) view_stock_status_cell($stock_item->stock_id); - //label_cell($stock_item->item_description, "nowrap" ); label_cell($stock_item->item_description ); $dec = get_qty_dec($stock_item->stock_id); qty_cell($stock_item->qty_dispatched, false, $dec); @@ -255,8 +253,6 @@ function display_order_header(&$order, $editable, $date_text) if (isset($order) && !$editable) { - // can't change the customer/branch if items already received on this order - //echo $order->customer_name . " - " . $order->deliver_to; label_row(null, $order->customer_name . " - " . $order->deliver_to); hidden('customer_id', $order->customer_id); hidden('branch_id', $order->Branch); @@ -296,7 +292,7 @@ function display_order_header(&$order, $editable, $date_text) else { - $old_order = (PHP_VERSION<5) ? $order : clone( $order ); + $old_order = (PHP_VERSION<5) ? $order : clone $order; $customer_error = get_customer_details_to_order($order, $_POST['customer_id'], $_POST['branch_id']); $_POST['Location'] = $order->Location; @@ -357,12 +353,12 @@ 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."); } } - ref_row(_("Reference").':', 'ref', _('Reference number unique for this document type'), null, ''); + ref_row(_("Reference").':', 'ref', _('Reference number unique for this document type'), null, '', $order->trans_type, array('date'=> @$_POST['OrderDate'])); table_section(2); @@ -382,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); @@ -466,7 +462,6 @@ function display_order_header(&$order, $editable, $date_text) $line = &$order->line_items[$line_no]; $line->price = get_kit_price($line->stock_id, $order->customer_currency, $order->sales_type, $order->price_factor, get_post('OrderDate')); - // $line->discount_percent = $order->default_discount; } $Ajax->activate('items_table'); } @@ -495,30 +490,36 @@ 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']); } -// } else { -// sales_items_list_cells(null,'item_description', null, false, true); -// } - //label_cell($order->line_items[$line_no]->item_description, "nowrap"); $Ajax->activate('items_table'); } else // prepare new line { - 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'); - } + if ($order->fixed_asset) + 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, @@ -528,7 +529,11 @@ function sales_order_item_controls(&$order, &$rowcounter, $line_no=-1) $_POST['Disc'] = percent_format($order->default_discount * 100); } - qty_cells(null, 'qty', $_POST['qty'], null, null, $dec); + if ($order->fixed_asset) { + label_cell(1, '', 'qty'); + hidden('qty', 1); + } else + qty_cells(null, 'qty', $_POST['qty'], null, null, $dec); if ($order->trans_no!=0) { qty_cell($line_no==-1 ? 0 :$order->line_items[$line_no]->qty_done, false, $dec); @@ -608,8 +613,8 @@ function display_delivery_details(&$order) start_outer_table(TABLESTYLE2, "width='90%'"); table_section(1); - locations_list_row(_("Deliver from Location:"), 'Location', null, false, true); - if ($order->payment_terms['days_before_due'] < 0) + locations_list_row(_("Deliver from Location:"), 'Location', null, false, true, $order->fixed_asset); + if ($order->payment_terms['days_before_due'] == -1) { $Ajax->addUpdate('items_table', 'prep_amount', price_format($order->get_trans_total())); // bind to items_table update if (!$order->is_started()) @@ -623,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);