-if ($ret = context_restore()) {
- if(isset($ret['customer_id']))
- $_POST['customer_id'] = $ret['customer_id'];
- if(isset($ret['branch_id']))
- $_POST['BranchID'] = $ret['branch_id'];
-}
-if (isset($_POST['_customer_id_editor'])) {
- context_call($path_to_root.'/sales/manage/customers.php?debtor_no='.$_POST['customer_id'],
- array( 'customer_id', 'BranchID', 'bank_account', 'DateBanked',
- 'ref', 'amount', 'discount', 'memo_') );
+
+if (list_updated('BranchID')) {
+ // when branch is selected via external editor also customer can change
+ $br = get_branch(get_post('BranchID'));
+ $_POST['customer_id'] = $br['debtor_no'];
+ $Ajax->activate('customer_id');