/** * Fetch object based on array of properties. * * @param array $params * (reference ) an assoc array of name/value pairs. * @param array $defaults * (reference ) an assoc array to hold the flattened values. * * @param array $allValues * * @return CRM_Contribute_BAO_ContributionType */ public static function retrieve(&$params, &$defaults, &$allValues = array()) { $financialTypeAccount = new CRM_Financial_DAO_EntityFinancialAccount(); $financialTypeAccount->copyValues($params); $financialTypeAccount->find(); while ($financialTypeAccount->fetch()) { CRM_Core_DAO::storeValues($financialTypeAccount, $defaults); $allValues[] = $defaults; } return $defaults; }
/** * Browse all Financial Type Account data * * @return void * @access public * @static */ function browse() { // get all Financial Type Account data sorted by weight $financialType = array(); $params = array(); $dao = new CRM_Financial_DAO_EntityFinancialAccount(); $params['entity_id'] = $this->_aid; $params['entity_table'] = 'civicrm_financial_type'; if ($this->_aid) { $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' ")); $this->_title = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', $this->_aid, 'name'); CRM_Utils_System::setTitle($this->_title . ' - ' . ts('Assigned Financial Accounts')); $financialAccountType = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialAccount', 'financial_account_type_id'); $accountRelationship = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship'); $dao->copyValues($params); $dao->find(); while ($dao->fetch()) { $financialType[$dao->id] = array(); CRM_Core_DAO::storeValues($dao, $financialType[$dao->id]); $params = array('id' => $dao->financial_account_id); $defaults = array(); $financialAccount = CRM_Financial_BAO_FinancialAccount::retrieve($params, $defaults); if (!empty($financialAccount)) { $financialType[$dao->id]['financial_account'] = $financialAccount->name; $financialType[$dao->id]['accounting_code'] = $financialAccount->accounting_code; $financialType[$dao->id]['account_type_code'] = $financialAccount->account_type_code; $financialType[$dao->id]['is_active'] = $financialAccount->is_active; if (!empty($financialAccount->contact_id)) { $financialType[$dao->id]['owned_by'] = CRM_Contact_BAO_Contact::displayName($financialAccount->contact_id); } if (!empty($financialAccount->financial_account_type_id)) { $optionGroupName = 'financial_account_type'; $financialType[$dao->id]['financial_account_type'] = CRM_Utils_Array::value($financialAccount->financial_account_type_id, $financialAccountType); } if (!empty($dao->account_relationship)) { $optionGroupName = 'account_relationship'; $financialType[$dao->id]['account_relationship'] = CRM_Utils_Array::value($dao->account_relationship, $accountRelationship); } } // form all action links $action = array_sum(array_keys($this->links())); $links = self::links(); //CRM-12492 if ($dao->account_relationship == $relationTypeId) { unset($links[CRM_Core_Action::DELETE]); } $financialType[$dao->id]['action'] = CRM_Core_Action::formLink($links, $action, array('id' => $dao->id, 'aid' => $dao->entity_id), ts('more'), FALSE, 'financialTypeAccount.manage.action', 'FinancialTypeAccount', $dao->id); } $this->assign('rows', $financialType); $this->assign('aid', $this->_aid); $this->assign('financialTypeTitle', $this->_title); } else { CRM_Core_Error::fatal(); return null; } }