/** * function to add the financial types * * @param array $params reference array contains the values submitted by the form * @param array $ids reference array contains the id * * @access public * @static * @return object */ static function add(&$params, &$ids) { $params['is_active'] = CRM_Utils_Array::value('is_active', $params, false); $params['is_deductible'] = CRM_Utils_Array::value('is_deductible', $params, false); $params['is_reserved'] = CRM_Utils_Array::value('is_reserved', $params, false); // action is taken depending upon the mode $financialType = new CRM_Financial_DAO_FinancialType(); $financialType->copyValues($params); if (CRM_Utils_Array::value('financialType', $ids)) { $financialType->id = CRM_Utils_Array::value('financialType', $ids); } $financialType->save(); // CRM-12470 if (!CRM_Utils_Array::value('financialType', $ids)) { $titles = CRM_Financial_BAO_FinancialTypeAccount::createDefaultFinancialAccounts($financialType); $financialType->titles = $titles; } return $financialType; }
/** * Add the financial types. * * @param array $params * Reference array contains the values submitted by the form. * @param array $ids * Reference array contains the id. * * @return object */ public static function add(&$params, &$ids = array()) { if (empty($params['id'])) { $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE); $params['is_deductible'] = CRM_Utils_Array::value('is_deductible', $params, FALSE); $params['is_reserved'] = CRM_Utils_Array::value('is_reserved', $params, FALSE); } // action is taken depending upon the mode $financialType = new CRM_Financial_DAO_FinancialType(); $financialType->copyValues($params); if (!empty($ids['financialType'])) { $financialType->id = CRM_Utils_Array::value('financialType', $ids); if (self::isACLFinancialTypeStatus()) { $prevName = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', $financialType->id, 'name'); if ($prevName != $params['name']) { CRM_Core_Session::setStatus(ts("Changing the name of a Financial Type will result in losing the current permissions associated with that Financial Type.\n Before making this change you should likely note the existing permissions at Administer > Users and Permissions > Permissions (Access Control),\n then clicking the Access Control link for your Content Management System, then noting down the permissions for 'CiviCRM: {financial type name} view', etc.\n Then after making the change of name, reset the permissions to the way they were."), ts('Warning'), 'warning'); } } } $financialType->save(); // CRM-12470 if (empty($ids['financialType']) && empty($params['id'])) { $titles = CRM_Financial_BAO_FinancialTypeAccount::createDefaultFinancialAccounts($financialType); $financialType->titles = $titles; } return $financialType; }