From 1da35d57d8d0905d18e771728d90f426d23d8f04 Mon Sep 17 00:00:00 2001 From: atif-shaikh Date: Fri, 9 Jan 2015 13:34:45 +0530 Subject: [PATCH] CRM-15787 - Not possible to add contribution field in profile for on behalf membership https://issues.civicrm.org/jira/browse/CRM-15787 --- CRM/Contribute/Form/Contribution/Main.php | 4 +++- .../Form/ContributionPage/Settings.php | 24 +++++++++++++------ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/CRM/Contribute/Form/Contribution/Main.php b/CRM/Contribute/Form/Contribution/Main.php index 365009a078..2dada275a7 100644 --- a/CRM/Contribute/Form/Contribution/Main.php +++ b/CRM/Contribute/Form/Contribution/Main.php @@ -138,7 +138,9 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu } //CRM-5001 - if (!empty($this->_values['is_for_organization'])) { + //CRM-15787 + $member = CRM_Member_BAO_Membership::getMembershipBlock($this->_id); + if (!empty($this->_values['is_for_organization']) && empty($member['is_active'])) { $msg = ts('Mixed profile not allowed for on behalf of registration/sign up.'); $ufJoinParams = array( 'module' => 'onBehalf', diff --git a/CRM/Contribute/Form/ContributionPage/Settings.php b/CRM/Contribute/Form/ContributionPage/Settings.php index 0298e8bce3..8a8fa5f8f0 100644 --- a/CRM/Contribute/Form/ContributionPage/Settings.php +++ b/CRM/Contribute/Form/ContributionPage/Settings.php @@ -144,15 +144,25 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_ // is on behalf of an organization ? $this->addElement('checkbox', 'is_organization', ts('Allow individuals to contribute and / or signup for membership on behalf of an organization?'), NULL, array('onclick' => "showHideByValue('is_organization',true,'for_org_text','table-row','radio',false);showHideByValue('is_organization',true,'for_org_option','table-row','radio',false);")); - $allowCoreTypes = array_merge(array('Contact', 'Organization'), CRM_Contact_BAO_ContactType::subTypes('Organization')); - $allowSubTypes = array(); - $entities = array( - array( - 'entity_name' => 'contact_1', - 'entity_type' => 'OrganizationModel', - ), + //CRM-15787 - If applicable, register 'membership_1' + $member = CRM_Member_BAO_Membership::getMembershipBlock($this->_id); + $allowMemberCoreTypes = ''; + + $entities[] = array( + 'entity_name' => array ('contact_1'), + 'entity_type' => 'OrganizationModel', ); + if ($member && $member['is_active']) { + $allowMemberCoreTypes = 'Membership'; + $entities[] = array( + 'entity_name' => array ('membership_1'), + 'entity_type' => 'MembershipModel', + ); + } + $allowCoreTypes = array_merge(array('Contact', 'Organization', $allowMemberCoreTypes), CRM_Contact_BAO_ContactType::subTypes('Organization')); + $allowSubTypes = array(); + $this->addProfileSelector('onbehalf_profile_id', ts('Organization Profile'), $allowCoreTypes, $allowSubTypes, $entities); $options = array(); -- 2.25.1