-- fixed notice errors for CRM-12470
authorPradeep Nayak <pradeep@pradeep.(none)>
Fri, 31 May 2013 08:16:53 +0000 (13:46 +0530)
committerPradeep Nayak <pradeep@pradeep.(none)>
Fri, 31 May 2013 08:16:53 +0000 (13:46 +0530)
----------------------------------------
* CRM-12470: Creating new financial type without AR account leads to unbalanced transactions
  http://issues.civicrm.org/jira/browse/CRM-12470

CRM/Financial/Form/FinancialTypeAccount.php
CRM/Financial/Page/AJAX.php

index a703c2526ccb56249047a6bce85a100f4c5f2fbf..ef991cb20e4c38f9f94cb605f3ecbebe0d9f66b2 100644 (file)
@@ -187,7 +187,7 @@ class CRM_Financial_Form_FinancialTypeAccount extends CRM_Contribute_Form {
            '9' => 3 //discount account is
           );
         
-        $financialAccountType = $financialAccountType[$this->_submitValues['account_relationship']];
+        $financialAccountType = CRM_Utils_Array::value($this->_submitValues['account_relationship'], $financialAccountType);
         $result = CRM_Contribute_PseudoConstant::financialAccount(NULL, $financialAccountType);
         
         $financialAccountSelect = array('' => ts('- select -')) + $result;
index a7cdc05d3f75bdc6e7bdef244da515f81f95fd0c..5913e692aa590de54489fdcd3af456b45b6c12c6 100644 (file)
@@ -62,10 +62,11 @@ class CRM_Financial_Page_AJAX {
         '8' => 1, //premium inventory
         '9' => 3, //discount account is
       );
-
-      $financialAccountType = "{$financialAccountType[$_GET['_value']]}";
+      $financialAccountType = CRM_Utils_Array::value($_GET['_value'], $financialAccountType);
       $result = CRM_Contribute_PseudoConstant::financialAccount(NULL, $financialAccountType);
-      $defaultId = CRM_Core_DAO::singleValueQuery("SELECT id FROM civicrm_financial_account WHERE is_default = 1 AND financial_account_type_id = $financialAccountType");
+      if ($financialAccountType) {
+        $defaultId = CRM_Core_DAO::singleValueQuery("SELECT id FROM civicrm_financial_account WHERE is_default = 1 AND financial_account_type_id = $financialAccountType");
+      }
     }
     $elements = array(
       array(