- // delete all the order items - drastic but necessary because of
- // change of currency, sales type, etc
- // $order->clear_items();
- // clear the branch selection
- unset($_POST['branch_id']);
- }
- if (!isset($_POST['branch_id']))
- $_POST['branch_id'] = "";
-
- customer_branches_list_row(_("Branch:"), $_POST['customer_id'], 'branch_id', null, false, true, true);
-
- if (!isset($_POST['branch_id']) || $_POST['branch_id'] == "")
- {
- $customer_error = _("The selected customer does not have any branches. Please create at least one branch.");
- unset($_POST['branch_id']);
- $order->Branch = 0;
- } else
- {
- //set_global_customer($_POST['customer_id']);
- if (($order->customer_id != $_POST['customer_id']) ||
- ($order->Branch != $_POST['branch_id'])) {
-
- $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;
- $_POST['deliver_to'] = $order->deliver_to;
- $_POST['delivery_address'] = $order->delivery_address;
- $_POST['phone'] = $order->phone;
- $_POST['sales_type'] = $order->sales_type;
-
- // change prices if necessary
- // what about discount in template case?
- if ( $old_order->customer_currency!=$order->customer_currency
- || $old_order->sales_type!=$order->sales_type
- // || $old_order->default_discount!=$order->default_discount
- ) {
- $change_prices = 1;
- }
-
- }
- } // changed branch
- set_global_customer($_POST['customer_id']);
+ if (!isset($_POST['branch_id']) || $_POST['branch_id'] == "")
+ {
+ // ignore errors on customer search box call
+ if ($_POST['customer_id'] == '')
+ $customer_error = _("No customer found for entered text.");
+ else
+ $customer_error = _("The selected customer does not have any branches. Please create at least one branch.");
+ unset($_POST['branch_id']);
+ $order->Branch = 0;
+ }
+ else
+ {
+
+ $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;
+ $_POST['deliver_to'] = $order->deliver_to;
+ $_POST['delivery_address'] = $order->delivery_address;
+ $_POST['phone'] = $order->phone;
+ if (get_post('cash') !== $order->cash) {
+ $_POST['cash'] = $order->cash;
+ $Ajax->activate('delivery');
+ $Ajax->activate('cash');
+ } else {
+ if ($order->trans_type == 10)
+ {
+ $_POST['delivery_date'] = $order->due_date;
+ $Ajax->activate('delivery_date');
+ }
+ $Ajax->activate('Location');
+ $Ajax->activate('deliver_to');
+ $Ajax->activate('phone');
+ $Ajax->activate('delivery_address');
+ }
+ // change prices if necessary
+ // what about discount in template case?
+ if ($old_order->customer_currency != $order->customer_currency) {
+ $change_prices = 1;
+ }
+ if ($old_order->sales_type != $order->sales_type) {
+ // || $old_order->default_discount!=$order->default_discount
+ $_POST['sales_type'] = $order->sales_type;
+ $Ajax->activate('sales_type');
+ $change_prices = 1;
+ }
+ if ($old_order->dimension_id != $order->dimension_id) {
+ $_POST['dimension_id'] = $order->dimension_id;
+ $Ajax->activate('dimension_id');
+ }
+ if ($old_order->dimension2_id != $order->dimension2_id) {
+ $_POST['dimension2_id'] = $order->dimension2_id;
+ $Ajax->activate('dimension2_id');
+ }
+ unset($old_order);
+ }
+ set_global_customer($_POST['customer_id']);
+ } // changed branch
+ else
+ {
+ $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.");
+
+ }