-- fixed notice error for CRM-12794
authorPradeep Nayak <pradeep@pradeep.(none)>
Wed, 12 Jun 2013 09:26:40 +0000 (14:56 +0530)
committerPradeep Nayak <pradeep@pradeep.(none)>
Wed, 12 Jun 2013 09:26:40 +0000 (14:56 +0530)
----------------------------------------
* CRM-12794: Notice when trying to delete Expense Account is when that account is currently in use
  http://issues.civicrm.org/jira/browse/CRM-12794

CRM/Financial/BAO/FinancialTypeAccount.php

index b6f26dbc1a46f92dd5b7d9ec0cbedd17240d69c2..811670a64ef0e11b227bab064832be4f24aadd25 100644 (file)
@@ -137,13 +137,14 @@ class CRM_Financial_BAO_FinancialTypeAccount extends CRM_Financial_DAO_EntityFin
         break;
       }
     }
-
+    
     if ($check) {
       if ($name[1] == 'PremiumsProduct' || $name[1] == 'Product') {
         CRM_Core_Session::setStatus(ts('You cannot remove an account with a %1 relationship while the Financial Type is used for a Premium.', array(1 => $relationValues[$financialTypeAccountId])));
       }
       else {
-        CRM_Core_Session::setStatus(ts('You cannot remove an account with a %1 relationship because it is being referenced by one or more of the following types of records: Contributions, Contribution Pages, or Membership Types. Consider disabling this type instead if you no longer want it used.', array(1 => $relationValues[$financialTypeAccountId])));
+        $accountRelationShipId = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_EntityFinancialAccount', $financialTypeAccountId, 'account_relationship');
+        CRM_Core_Session::setStatus(ts('You cannot remove an account with a %1 relationship because it is being referenced by one or more of the following types of records: Contributions, Contribution Pages, or Membership Types. Consider disabling this type instead if you no longer want it used.', array(1 => $relationValues[$accountRelationShipId])));
       }
       return CRM_Utils_System::redirect( CRM_Utils_System::url( 'civicrm/admin/financial/financialType/accounts', "reset=1&action=browse&aid={$accountId}" ));
     }