-if ($ret = context_restore()) {
- // return from new customer add
- copy_from_cn();
- if(isset($ret['customer_id']))
- $_POST['customer_id'] = $ret['customer_id'];
- if(isset($ret['branch_id']))
- $_POST['branch_id'] = $ret['branch_id'];
-}
-if (isset($_POST['_customer_id_editor'])) {
- copy_to_cn(); //store context
- context_call($path_to_root.'/sales/manage/customers.php?debtor_no='.$_POST['customer_id'], 'Items');
+
+if (list_updated('branch_id')) {
+ // when branch is selected via external editor also customer can change
+ $br = get_branch(get_post('branch_id'));
+ $_POST['customer_id'] = $br['debtor_no'];
+ $Ajax->activate('customer_id');