----------------------------------------
* CRM-19587: DB Error when trying to delete FInancial Account
https://issues.civicrm.org/jira/browse/CRM-19587
if ($check) {
CRM_Core_Session::setStatus(ts('This financial account cannot be deleted since it is being used as a header account. Please remove it from being a header account before trying to delete it again.'));
- return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/financial/financialAccount', "reset=1&action=browse"));
+ return FALSE;
}
// delete from financial Type table
$financialAccount = new CRM_Financial_DAO_FinancialAccount();
$financialAccount->id = $financialAccountId;
$financialAccount->delete();
+ return TRUE;
}
/**
*/
public function postProcess() {
if ($this->_action & CRM_Core_Action::DELETE) {
- CRM_Financial_BAO_FinancialAccount::del($this->_id);
- CRM_Core_Session::setStatus(ts('Selected Financial Account has been deleted.'));
+ if (CRM_Financial_BAO_FinancialAccount::del($this->_id)) {
+ CRM_Core_Session::setStatus(ts('Selected Financial Account has been deleted.'));
+ }
+ else {
+ CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/financial/financialAccount', "reset=1&action=browse"));
+ }
}
else {
// store the submitted values in an array