Have a question about CiviCRM? Get it answered quickly at the new CiviCRM Stack Exchange Q+A siteThis forum was archived on 25 November 2017. Learn more.How to get involved.What to do if you think you've found a bug.
// 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);") ); $options = array(); $options[] = HTML_QuickForm::createElement('radio', null, null, ts('Optional'), 1 ); $options[] = HTML_QuickForm::createElement('radio', null, null, ts('Required'), 2 ); $this->addGroup($options, 'is_for_organization', ts('') ); $this->add('textarea', 'for_organization', ts('On behalf of Label'), $attributes['for_organization'] );
$params['is_for_organization'] = CRM_Utils_Array::value('is_organization', $params ) ? CRM_Utils_Array::value('is_for_organization', $params, false) : 0;
if (! isset($defaults['for_organization'])) { $defaults['for_organization'] = ts('I am contributing on behalf of an organization.'); }
if ( CRM_Utils_Array::value( 'is_for_organization', $defaults ) ) { $defaults['is_organization'] = 1; } else { $defaults['is_for_organization'] = 1; }
if ( CRM_Utils_Array::value( 'hidden_onbehalf_profile', $this->_params ) ) { $this->assign('onBehalfName', $this->_params['organization_name']); $locTypeId = array_keys( $this->_params['onbehalf_location']['email'] ); $this->assign('onBehalfEmail', $this->_params['onbehalf_location']['email'][$locTypeId[0]]['email']); }
if ( CRM_Utils_Array::value( 'is_for_organization', $values ) ) { if ( CRM_Utils_Array::value( 'membership_id', $values ) ) { $params['onbehalf_profile'] = array( array( 'membership_id', '=', $values['membership_id'], 0, 0 ) ); } else if ( CRM_Utils_Array::value( 'contribution_id', $values ) ) { $params['onbehalf_profile'] = array( array( 'contribution_id', '=', $values['contribution_id'], 0, 0 ) ); } }
function getOnbehalfIds( $contributionId, $contributorId = null ) { $ids = array(); if ( !$contributionId ) { return $ids; } // fetch contributor id if null if ( !$contributorId ) { require_once 'CRM/Core/DAO.php'; $contributorId = CRM_Core_DAO::getFieldValue( 'CRM_Contribute_DAO_Contribution', $contributionId, 'contact_id' ); } require_once 'CRM/Core/PseudoConstant.php'; $activityTypeIds = CRM_Core_PseudoConstant::activityType( true, false, false, 'name' ); $activityTypeId = array_search( 'Contribution', $activityTypeIds ); if ( $activityTypeId && $contributorId ) { $activityQuery = "SELECT source_contact_id FROM civicrm_activity WHERE activity_type_id = %1 AND source_record_id = %2"; $params = array( 1 => array( $activityTypeId, 'Integer' ), 2 => array( $contributionId, 'Integer' ) ); $sourceContactId = CRM_Core_DAO::singleValueQuery( $activityQuery , $params ); // for on behalf contribution source is individual and contributor is organization if ( $sourceContactId && $sourceContactId != $contributorId ) { $relationshipTypeIds = CRM_Core_PseudoConstant::relationshipType( 'name' ); // get rel type id for employee of relation foreach ( $relationshipTypeIds as $id => $typeVals ) { if ( $typeVals['name_a_b'] == 'Employee of' ) { $relationshipTypeId = $id; break; } } require_once 'CRM/Contact/DAO/Relationship.php'; $rel = new CRM_Contact_DAO_Relationship(); $rel->relationship_type_id = $relationshipTypeId; $rel->contact_id_a = $sourceContactId; $rel->contact_id_b = $contributorId; if ( $rel->find(true) ) { $ids['individual_id'] = $rel->contact_id_a; $ids['organization_id'] = $rel->contact_id_b; } } } return $ids; }
/** * if true, signup is done on behalf of an organization * * @var boolean */ public $is_for_organization; /** * This text field is shown when is_for_organization is checked. For example - I am contributing on behalf on an organization. * * @var text */ public $for_organization; /** * if true, receipt is automatically emailed to contact on success * * @var boolean */
'is_for_organization' => array( 'name' => 'is_for_organization', 'type' => CRM_Utils_Type::T_BOOLEAN, ) , 'for_organization' => array( 'name' => 'for_organization', 'type' => CRM_Utils_Type::T_TEXT, 'title' => ts('On Behalf Of Organization') , 'rows' => 2, 'cols' => 50,
$profileId = CRM_Core_DAO::getFieldValue( 'CRM_Core_DAO_UFGroup', 'on_behalf_organization', 'id', 'name' );
$fieldTypes = array( 'Contact', 'Organization' );
$profileId = CRM_Core_DAO::getFieldValue( 'CRM_Core_DAO_UFGroup', 'on_behalf_organization', 'id', 'name' ); $excludeTypes = array( 'Organization', 'Household', 'Participant', 'Activity' );