if ($module == 'soft_credit') {
$form->_honoreeProfileId = $ufJoin->uf_group_id;
+ $form->_honor_block_is_active = $ufJoin->is_active;
if (!$form->_honoreeProfileId ||
!CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $form->_honoreeProfileId, 'is_active')
}
else {
$form->_onbehalf = FALSE;
- $params = CRM_Contribute_BAO_ContributionPage::formatMultilingualOnBehalfParams($ufJoin->module_data, TRUE);
+ $params = CRM_Contribute_BAO_ContributionPage::formatModuleData($ufJoin->module_data, TRUE, 'on_behalf');
+ $form->_values = array_merge($params, $form->_values);
if (CRM_Utils_Array::value('is_for_organization', $params)) {
if ($params['is_for_organization'] == 2) {
$form->_onBehalfRequired = TRUE;
!empty($_POST['is_for_organization'])
) {
$form->_onbehalf = TRUE;
- $form->_profileId = $ufJoin->uf_group_id;
+ $form->_onBehalfProfileId = $ufJoin->uf_group_id;
- if (!$form->_profileId ||
- !CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $form->_profileId, 'is_active')
+ if (!$form->_onBehalfProfileId ||
+ !CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $form->_onBehalfProfileId, 'is_active')
) {
CRM_Core_Error::fatal(ts('This contribution page has been configured for contribution on behalf of an organization and the selected onbehalf profile is either disabled or not found.'));
}
$requiredProfileFields = array('organization_name', 'email');
- $validProfile = CRM_Core_BAO_UFGroup::checkValidProfile($form->_profileId, $requiredProfileFields);
+ $validProfile = CRM_Core_BAO_UFGroup::checkValidProfile($form->_onBehalfProfileId, $requiredProfileFields);
if (!$validProfile) {
CRM_Core_Error::fatal(ts('This contribution page has been configured for contribution on behalf of an organization and the required fields of the selected onbehalf profile are disabled.'));
}
$member = CRM_Member_BAO_Membership::getMembershipBlock($form->_id);
if (empty($member['is_active'])) {
$msg = ts('Mixed profile not allowed for on behalf of registration/sign up.');
- $onBehalfProfile = CRM_Core_BAO_UFGroup::profileGroups($form->_profileId);
+ $onBehalfProfile = CRM_Core_BAO_UFGroup::profileGroups($form->_onBehalfProfileId);
foreach (array(
'Individual',
'Organization',
}
}
- $form->assign('profileId', $form->_profileId);
+ $form->assign('profileId', $form->_onBehalfProfileId);
$form->assign('mode', $form->_mode);
if ($contactID) {
}
public static function buildOnBehalfBlock(&$form) {
- $form->assign('fieldSetTitle', ts('Organization Details'));
$form->assign('buildOnBehalfForm', TRUE);
+ $form->assign('fieldSetTitle', ts('Organization Details'));
$contactID = $form->_contactID;
}
$prefix = 'onbehalf';
- $profileFields = CRM_Core_BAO_UFGroup::getFields($form->_profileId, FALSE, CRM_Core_Action::VIEW, NULL,
+ $profileFields = CRM_Core_BAO_UFGroup::getFields($form->_onBehalfProfileId, FALSE, CRM_Core_Action::VIEW, NULL,
NULL, FALSE, NULL, FALSE, NULL,
CRM_Core_Permission::CREATE, NULL
);
}
$form->assign('onBehalfOfFields', $profileFields);
- $form->addElement('hidden', 'hidden_onbehalf_profile', 1);
+ $form->addElement('hidden', 'onbehalf_profile_id', $form->_onBehalfProfileId);
}
}
}
/**
- * Get or Set multilingually affected honor params for processing module_data or setting default values.
+ * Get or Set honor/on_behalf params for processing module_data or setting default values.
*
- * @param string $params :
+ * @param array $params :
* @param bool $setDefault : If yes then returns array to used for setting default value afterward
+ * @param string $module : processing module_data for which module? e.g. soft_credit, on_behalf
*
* @return array|string
*/
- public static function formatMultilingualHonorParams($params, $setDefault = FALSE) {
+ public static function formatModuleData($params, $setDefault = FALSE, $module) {
$config = CRM_Core_Config::singleton();
- $sctJson = $sctJsonDecode = NULL;
+ $json = $jsonDecode = NULL;
$domain = new CRM_Core_DAO_Domain();
$domain->find(TRUE);
+ $moduleDataFormat = array(
+ 'soft_credit' => array(
+ 'soft_credit_types',
+ 'multilingual' => array(
+ 'honor_block_title',
+ 'honor_block_text'
+ ),
+ ),
+ 'on_behalf' => array(
+ 'is_for_organization',
+ 'multilingual' => array(
+ 'for_organization'
+ ),
+ ),
+ );
+
//When we are fetching the honor params respecting both multi and mono lingual state
//and setting it to default param of Contribution Page's Main and Setting form
if ($setDefault) {
- $sctJsonDecode = json_decode($params);
- $sctJsonDecode = (array) $sctJsonDecode->soft_credit;
- if (!$domain->locales && !empty($sctJsonDecode['default'])) {
+ $jsonDecode = json_decode($params);
+ $jsonDecode = (array) $jsonDecode->$module;
+ if (!$domain->locales && !empty($jsonDecode['default'])) {
//monolingual state
- $sctJsonDecode += (array) $sctJsonDecode['default'];
+ $jsonDecode += (array) $jsonDecode['default'];
+ unset($jsonDecode['default']);
}
- elseif (!empty($sctJsonDecode[$config->lcMessages])) {
+ elseif (!empty($jsonDecode[$config->lcMessages])) {
//multilingual state
- foreach ($sctJsonDecode[$config->lcMessages] as $column => $value) {
- $sctJsonDecode[$column] = $value;
+ foreach ($jsonDecode[$config->lcMessages] as $column => $value) {
+ $jsonDecode[$column] = $value;
}
- unset($sctJsonDecode[$config->lcMessages]);
+ unset($jsonDecode[$config->lcMessages]);
}
- return $sctJsonDecode;
+ return $jsonDecode;
}
//check and handle multilingual honoree params
if (!$domain->locales) {
//if in singlelingual state simply return the array format
- $sctJson = json_encode(
- array(
- 'soft_credit' => array(
- 'soft_credit_types' => $params['soft_credit_types'],
- 'default' => array(
- 'honor_block_title' => $params['honor_block_title'],
- 'honor_block_text' => $params['honor_block_text'],
- ),
- ),
- )
- );
+ $json = array($module => NULL);
+ foreach ($moduleDataFormat[$module] as $key => $attribute) {
+ if ($key === 'multilingual') {
+ $json[$module]['default'] = array();
+ foreach ($attribute as $attr) {
+ $json[$module]['default'][$attr] = $params[$attr];
+ }
+ }
+ else {
+ $json[$module][$attribute] = $params[$attribute];
+ }
+ }
+ $json = json_encode($json);
}
else {
//if in multilingual state then retrieve the module_data against this contribution and
//merge with earlier module_data json data to current so not to lose earlier multilingual module_data information
- $sctJson = array(
- 'soft_credit' => array(
- 'soft_credit_types' => $params['soft_credit_types'],
- $config->lcMessages => array(
- 'honor_block_title' => $params['honor_block_title'],
- 'honor_block_text' => $params['honor_block_text'],
- ),
- ),
- );
-
- $ufJoinDAO = new CRM_Core_DAO_UFJoin();
- $ufJoinDAO->module = 'soft_credit';
- $ufJoinDAO->entity_id = $params['id'];
- $ufJoinDAO->find(TRUE);
- $jsonData = json_decode($ufJoinDAO->module_data);
- if ($jsonData) {
- $sctJson['soft_credit'] = array_merge((array) $jsonData->soft_credit, $sctJson['soft_credit']);
- }
- $sctJson = json_encode($sctJson);
- }
- return $sctJson;
- }
-
- /**
- * Get or Set multilingually affected on behalf params for processing module_data or setting default values.
- *
- * @param string $params :
- * @param bool $setDefault : If yes then returns array to used for setting default value afterward
- *
- * @return array|string
- */
- public static function formatMultilingualOnBehalfParams($params, $setDefault = FALSE) {
- $config = CRM_Core_Config::singleton();
- $onBehalfJson = $onBehalfJsonDecode = NULL;
- $domain = new CRM_Core_DAO_Domain();
- $domain->find(TRUE);
-
- if ($setDefault) {
- $onBehalfJsonDecode = json_decode($params);
- $onBehalfJsonDecode = (array) $onBehalfJsonDecode->on_behalf;
- if (!$domain->locales && !empty($onBehalfJsonDecode['default'])) {
- //monolingual state
- $onBehalfJsonDecode += (array) $onBehalfJsonDecode['default'];
- }
- elseif (!empty($onBehalfJsonDecode[$config->lcMessages])) {
- //multilingual state
- foreach ($sctJsonDecode[$config->lcMessages] as $column => $value) {
- $onBehalfJsonDecode[$column] = $value;
+ $json = array($module => NULL);
+ foreach ($moduleDataFormat[$module] as $key => $attribute) {
+ if ($key === 'multilingual') {
+ $json[$module][$config->lcMessages] = array();
+ foreach ($attribute as $attr) {
+ $json[$module][$config->lcMessages][$attr] = $params[$attr];
+ }
+ }
+ else {
+ $json[$module][$attribute] = $params[$attribute];
}
- unset($onBehalfJsonDecode[$config->lcMessages]);
}
- return $onBehalfJsonDecode;
- }
-
- //check and handle multilingual honoree params
- if (!$domain->locales) {
- //if in singlelingual state simply return the array format
- $onBehalfJson = json_encode(
- array(
- 'on_behalf' => array(
- 'is_for_organization' => $params['is_for_organization'],
- 'default' => array(
- 'for_organization' => $params['for_organization'],
- ),
- ),
- )
- );
- }
- else {
- $onBehalfJson = array(
- 'on_behalf' => array(
- 'is_for_organization' => $params['is_for_organization'],
- $config->lcMessages => array(
- 'for_organization' => $params['for_organization'],
- ),
- ),
- );
$ufJoinDAO = new CRM_Core_DAO_UFJoin();
- $ufJoinDAO->module = 'on_behalf';
+ $ufJoinDAO->module = $module;
$ufJoinDAO->entity_id = $params['id'];
$ufJoinDAO->find(TRUE);
$jsonData = json_decode($ufJoinDAO->module_data);
if ($jsonData) {
- $onBehalfJson['on_behalf'] = array_merge((array) $jsonData->on_behalf, $onBehalfJson['on_behalf']);
+ $json[$module] = array_merge((array) $jsonData->$module, $json[$module]);
}
- $onBehalfJson = json_encode($onBehalfJson);
+ $json = json_encode($json);
}
- return $onBehalfJson;
+ return $json;
}
/**
$this->assign('pay_later_receipt', $this->_values['pay_later_receipt']);
}
// if onbehalf-of-organization
- if (!empty($this->_params['hidden_onbehalf_profile'])) {
+ if (!empty($this->_params['onbehalf_profile_id'])) {
// CRM-15182
if (empty($this->_params['org_option']) && empty($this->_params['organization_id'])) {
if (!empty($this->_params['onbehalfof_id'])) {
}
$this->buildCustom($this->_values['custom_pre_id'], 'customPre', TRUE);
$this->buildCustom($this->_values['custom_post_id'], 'customPost', TRUE);
+ CRM_Core_Error::debug( '$params', $params );
- if (!empty($params['hidden_onbehalf_profile'])) {
- $ufJoinParams = array(
- 'module' => 'onBehalf',
- 'entity_table' => 'civicrm_contribution_page',
- 'entity_id' => $this->_id,
- );
- $OnBehalfProfile = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
- $profileId = $OnBehalfProfile[0];
+ if (!empty($params['onbehalf_profile_id'])) {
$fieldTypes = array('Contact', 'Organization');
$contactSubType = CRM_Contact_BAO_ContactType::subTypes('Organization');
$fieldTypes = array_merge($fieldTypes, array('Contribution'));
}
- $this->buildCustom($profileId, 'onbehalfProfile', TRUE, 'onbehalf', $fieldTypes);
+ $this->buildCustom($params['onbehalf_profile_id'], 'onbehalfProfile', TRUE, 'onbehalf', $fieldTypes);
}
$this->_separateMembershipPayment = $this->get('separateMembershipPayment');
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
- */
-class CRM_Contribute_Form_Contribution_OnBehalfOf {
-
- /**
- * Set variables up before form is built.
- *
- * @param CRM_Core_Form $form
- */
- public static function preProcess(&$form) {
- $session = CRM_Core_Session::singleton();
- $contactID = $form->_contactID;
-
- $ufJoinParams = array(
- 'module' => 'onBehalf',
- 'entity_table' => 'civicrm_contribution_page',
- 'entity_id' => $form->_id,
- );
- $profileId = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
- $form->_profileId = $profileId[0];
-
- if (!$form->_profileId ||
- !CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $form->_profileId, 'is_active')
- ) {
- CRM_Core_Error::fatal(ts('This contribution page has been configured for contribution on behalf of an organization and the selected onbehalf profile is either disabled or not found.'));
- }
-
- $requiredProfileFields = array('organization_name', 'email');
- $validProfile = CRM_Core_BAO_UFGroup::checkValidProfile($form->_profileId, $requiredProfileFields);
- if (!$validProfile) {
- CRM_Core_Error::fatal(ts('This contribution page has been configured for contribution on behalf of an organization and the required fields of the selected onbehalf profile are disabled.'));
- }
-
- $form->assign('profileId', $form->_profileId);
- $form->assign('mode', $form->_mode);
-
- if ($contactID) {
- $form->_employers = CRM_Contact_BAO_Relationship::getPermissionedEmployer($contactID);
-
- if (!empty($form->_membershipContactID) && $contactID != $form->_membershipContactID) {
- // renewal case - membership being renewed may or may not be for organization
- if (!empty($form->_employers) && array_key_exists($form->_membershipContactID, $form->_employers)) {
- // if _membershipContactID belongs to employers list, we can say:
- $form->_relatedOrganizationFound = TRUE;
- }
- }
- elseif (!empty($form->_employers)) {
- // not a renewal case and _employers list is not empty
- $form->_relatedOrganizationFound = TRUE;
- }
-
- if ($form->_relatedOrganizationFound) {
- // Related org url - pass checksum if needed
- $args = array('cid' => '');
- if (!empty($_GET['cs'])) {
- $args = array(
- 'uid' => $form->_contactID,
- 'cs' => $_GET['cs'],
- 'cid' => '',
- );
- }
- $locDataURL = CRM_Utils_System::url('civicrm/ajax/permlocation', $args, FALSE, NULL, FALSE);
- $form->assign('locDataURL', $locDataURL);
-
- if (!empty($form->_submitValues['onbehalf'])) {
- if (!empty($form->_submitValues['onbehalfof_id'])) {
- $form->assign('submittedOnBehalf', $form->_submitValues['onbehalfof_id']);
- }
- $form->assign('submittedOnBehalfInfo', json_encode($form->_submitValues['onbehalf']));
- }
- }
-
- if ($form->_values['is_for_organization'] != 2) {
- $form->assign('relatedOrganizationFound', $form->_relatedOrganizationFound);
- }
- else {
- $form->assign('onBehalfRequired', $form->_onBehalfRequired);
- }
-
- if (count($form->_employers) == 1) {
- foreach ($form->_employers as $id => $value) {
- $form->_organizationName = $value['name'];
- $orgId = $id;
- }
- $form->assign('orgId', $orgId);
- $form->assign('organizationName', $form->_organizationName);
- }
- }
- }
-
- /**
- * Build form for related contacts / on behalf of organization.
- *
- * @param CRM_Core_Form $form
- *
- */
- public static function buildQuickForm(&$form) {
- $form->assign('fieldSetTitle', ts('Organization Details'));
- $form->assign('buildOnBehalfForm', TRUE);
-
- $contactID = $form->_contactID;
-
- if ($contactID && count($form->_employers) >= 1) {
- $form->add('text', 'organization_id', ts('Select an existing related Organization OR enter a new one'));
-
- $form->add('select', 'onbehalfof_id', '', CRM_Utils_Array::collect('name', $form->_employers));
-
- $orgOptions = array(
- 0 => ts('Select an existing organization'),
- 1 => ts('Enter a new organization'),
- );
-
- $form->addRadio('org_option', ts('options'), $orgOptions);
- $form->setDefaults(array('org_option' => 0));
- $form->add('checkbox', 'mode', '');
- }
-
- $profileFields = CRM_Core_BAO_UFGroup::getFields($form->_profileId, FALSE, CRM_Core_Action::VIEW, NULL,
- NULL, FALSE, NULL, FALSE, NULL,
- CRM_Core_Permission::CREATE, NULL
- );
- $fieldTypes = array('Contact', 'Organization');
- $contactSubType = CRM_Contact_BAO_ContactType::subTypes('Organization');
- $fieldTypes = array_merge($fieldTypes, $contactSubType);
-
- if (is_array($form->_membershipBlock) && !empty($form->_membershipBlock)) {
- $fieldTypes = array_merge($fieldTypes, array('Membership'));
- }
- else {
- $fieldTypes = array_merge($fieldTypes, array('Contribution'));
- }
-
- foreach ($profileFields as $name => $field) {
- if (in_array($field['field_type'], $fieldTypes)) {
- list($prefixName, $index) = CRM_Utils_System::explode('-', $name, 2);
- if (in_array($prefixName, array('organization_name', 'email')) && empty($field['is_required'])) {
- $field['is_required'] = 1;
- }
-
- CRM_Core_BAO_UFGroup::buildProfile($form, $field, NULL, NULL, FALSE, 'onbehalf');
- }
- }
-
- $form->assign('onBehalfOfFields', $profileFields);
- $form->addElement('hidden', 'hidden_onbehalf_profile', 1);
- }
-
-}
$this->buildCustom($this->_values['custom_pre_id'], 'customPre', TRUE);
$this->buildCustom($this->_values['custom_post_id'], 'customPost', TRUE);
- if (!empty($params['hidden_onbehalf_profile'])) {
- $ufJoinParams = array(
- 'module' => 'onBehalf',
- 'entity_table' => 'civicrm_contribution_page',
- 'entity_id' => $this->_id,
- );
- $OnBehalfProfile = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
- $profileId = $OnBehalfProfile[0];
-
+ if (!empty($params['onbehalf_profile_id'])) {
$fieldTypes = array('Contact', 'Organization');
$contactSubType = CRM_Contact_BAO_ContactType::subTypes('Organization');
$fieldTypes = array_merge($fieldTypes, $contactSubType);
$fieldTypes = array_merge($fieldTypes, array('Contribution'));
}
- $this->buildCustom($profileId, 'onbehalfProfile', TRUE, 'onbehalf', $fieldTypes);
+ $this->buildCustom($params['onbehalf_profile_id'], 'onbehalfProfile', TRUE, 'onbehalf', $fieldTypes);
}
$this->assign('trxn_id',
$this->assign('address', CRM_Utils_Address::format($addressFields));
- if (!empty($this->_params['hidden_onbehalf_profile'])) {
+ if (!empty($this->_params['onbehalf_profile_id'])) {
$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']);
$ufJoinDAO->module = $module;
$ufJoinDAO->entity_id = $this->_id;
if ($ufJoinDAO->find(TRUE)) {
+ $jsonData = CRM_Contribute_BAO_ContributionPage::formatModuleData($ufJoinDAO->module_data, TRUE, $module);
if ($module == 'soft_credit') {
$defaults['honoree_profile'] = $ufJoinDAO->uf_group_id;
- $jsonData = CRM_Contribute_BAO_ContributionPage::formatMultilingualHonorParams($ufJoinDAO->module_data, TRUE);
$defaults = array_merge($defaults, $jsonData);
$defaults['honor_block_is_active'] = $ufJoinDAO->is_active;
}
else {
$defaults['onbehalf_profile_id'] = $ufJoinDAO->uf_group_id;
- $jsonData = CRM_Contribute_BAO_ContributionPage::formatMultilingualOnBehalfParams($ufJoinDAO->module_data, TRUE);
$defaults = array_merge($defaults, $jsonData);
$defaults['is_organization'] = $ufJoinDAO->is_active;
}
$ufJoinParam['is_active'] = 1;
if ($index == 'honor_block_is_active') {
$ufJoinParam['uf_group_id'] = $params['honoree_profile'];
- $ufJoinParam['module_data'] = CRM_Contribute_BAO_ContributionPage::formatMultilingualHonorParams($params);
+ $ufJoinParam['module_data'] = CRM_Contribute_BAO_ContributionPage::formatModuleData($params, FALSE, 'soft_credit');
}
else {
$ufJoinParam['uf_group_id'] = $params['onbehalf_profile_id'];
- $ufJoinParam['module_data'] = CRM_Contribute_BAO_ContributionPage::formatMultilingualOnBehalfParams($params);
+ $ufJoinParam['module_data'] = CRM_Contribute_BAO_ContributionPage::formatModuleData($params, FALSE, 'on_behalf');
}
CRM_Core_BAO_UFJoin::create($ufJoinParam);
}
$ufJoinDAO->module = 'soft_credit';
$ufJoinDAO->entity_id = $form->_id;
if ($ufJoinDAO->find(TRUE)) {
- $jsonData = CRM_Contribute_BAO_ContributionPage::formatMultilingualHonorParams($ufJoinDAO->module_data, TRUE);
+ $jsonData = CRM_Contribute_BAO_ContributionPage::formatModuleData($ufJoinDAO->module_data, TRUE, 'soft_credit');
if ($jsonData) {
foreach (array('honor_block_title', 'honor_block_text') as $name) {
$form->assign($name, $jsonData[$name]);
*}
{* Callback snippet: On-behalf profile *}
{if $snippet and !empty($isOnBehalfCallback)}
- {* include file="CRM/Contribute/Form/Contribution/OnBehalfOf.tpl" context="front-end" *}
+ {include file="CRM/Contribute/Form/Contribution/OnBehalfOf.tpl" context="front-end"}
{else}
{literal}
{/if}
{if $is_for_organization}
- <div id='onBehalfOfOrg' class="crm-section">
- {include file="CRM/UF/Form/Block.tpl" fields=$onBehalfOfFields mode=8 prefix='onbehalf'}
- </div>
+ {include file="CRM/Contribute/Form/Contribution/OnBehalfOf.tpl"}
{/if}
{* User account registration option. Displays if enabled for one of the profiles on this page. *}
*}
{if $buildOnBehalfForm or $onBehalfRequired}
-<fieldset id="for_organization" class="for_organization-group">
-<legend>{$fieldSetTitle}</legend>
- {if ( $relatedOrganizationFound or $onBehalfRequired ) and !$organizationName}
- <div id='orgOptions' class="section crm-section">
- <div class="content">
- {$form.org_option.html}
+ {if !empty($context)}
+ <fieldset id="for_organization" class="for_organization-group">
+ <legend>{$fieldSetTitle}</legend>
+ {if ( $relatedOrganizationFound or $onBehalfRequired ) and !$organizationName and $form.org_option.html}
+ <div id='orgOptions' class="section crm-section">
+ <div class="content">
+ {$form.org_option.html}
+ </div>
</div>
- </div>
- {/if}
-
-<div id="select_org" class="crm-section">
- {foreach from=$onBehalfOfFields item=onBehaldField key=fieldName}
- {if $onBehalfOfFields.$fieldName.skipDisplay}
- {continue}
- {/if}
- {if $onBehalfOfFields.$fieldName.field_type eq "Formatting"}
- {$onBehalfOfFields.$fieldName.help_pre}
- {continue}
{/if}
- <div class="crm-section {$onBehalfOfFields.$fieldName.name}-section">
- {if $onBehalfOfFields.$fieldName.help_pre}
- <span class='description'>{$onBehalfOfFields.$fieldName.help_pre}</span>
- {/if}
+ {/if}
+ <div id='onBehalfOfOrg' class="crm-section">
+ {include file="CRM/UF/Form/Block.tpl" fields=$onBehalfOfFields mode=8 prefix='onbehalf'}
+ </div>
- {if ( $fieldName eq 'organization_name' ) and $organizationName}
- <div id='org_name' class="label">{$form.onbehalf.$fieldName.label}</div>
- <div class="content">
- {$form.onbehalf.$fieldName.html|crmAddClass:big}
- <span>
- ( <a id='createNewOrg' href="#" onclick="createNew( ); return false;">{ts}Enter a new organization{/ts}</a> )
- </span>
- <div id="id-onbehalf-orgname-enter-help" class="description">
- {ts}Organization details have been prefilled for you. If this is not the organization you want to use, click "Enter a new organization" above.{/ts}
- </div>
- {if $onBehalfOfFields.$fieldName.help_post}
- <span class='description'>{$onBehalfOfFields.$fieldName.help_post}</span>
- {/if}
- </div>
- {else}
- {if $onBehalfOfFields.$fieldName.options_per_line}
- <div class="label option-label">{$form.onbehalf.$fieldName.label}</div>
- <div class="content">
- {assign var="count" value="1"}
- {strip}
- <table class="form-layout-compressed">
- <tr>
- {* sort by fails for option per line. Added a variable to iterate through the element array*}
- {assign var="index" value="1"}
- {foreach name=outer key=key item=item from=$form.onbehalf.$fieldName}
- {if $index < 10}
- {assign var="index" value=`$index+1`}
- {else}
- <td class="labels font-light">{$form.onbehalf.$fieldName.$key.html}</td>
- {if $count == $onBehalfOfFields.$fieldName.options_per_line}
- </tr>
- <tr>
- {assign var="count" value="1"}
- {else}
- {assign var="count" value=`$count+1`}
- {/if}
- {/if}
- {/foreach}
- </tr>
- </table>
- {/strip}
- {if $onBehalfOfFields.$fieldName.help_post}
- <span class='description'>{$onBehalfOfFields.$fieldName.help_post}</span>
- {/if}
- </div>
- {else}
- <div class="label">{$form.onbehalf.$fieldName.label}</div>
- <div class="content">
- {if $fieldName eq 'organization_name' and !empty($form.onbehalfof_id)}
- {$form.onbehalfof_id.html}
- {/if}
- {$form.onbehalf.$fieldName.html}
- {if !empty($onBehalfOfFields.$fieldName.html_type) && $onBehalfOfFields.$fieldName.html_type eq 'Autocomplete-Select'}
- {assign var=elementName value=onbehalf[$fieldName]}
- {if $onBehalfOfFields.$fieldName.data_type eq 'ContactReference'}
- {include file="CRM/Custom/Form/ContactReference.tpl" element_name = $elementName}
- {/if}
- {/if}
- {if $onBehalfOfFields.$fieldName.name|substr:0:5 eq 'phone'}
- {assign var="phone_ext_field" value=$onBehalfOfFields.$fieldName.name|replace:'phone':'phone_ext'}
- {if $form.onbehalf.$phone_ext_field.html}
- {$form.onbehalf.$phone_ext_field.html}
- {/if}
- {/if}
- {if $onBehalfOfFields.$fieldName.data_type eq 'Date'}
- {assign var=elementName value=onbehalf[$fieldName]}
- {include file="CRM/common/jcalendar.tpl" elementName=$elementName elementId=onbehalf_$fieldName}
- {/if}
- {if $onBehalfOfFields.$fieldName.help_post}
- <br /><span class='description'>{$onBehalfOfFields.$fieldName.help_post}</span>
- {/if}
- </div>
- {/if}
- {/if}
- <div class="clear"></div>
- </div>
- {/foreach}
-</div>
-<div>{$form.mode.html}</div>
-</fieldset>
+ <div>{$form.mode.html}</div>
+ {if !empty($context)}
+ </fieldset>
+ {/if}
{/if}
-{if empty($snippet)}
{literal}
<script type="text/javascript">
{/if}
</script>
-{/if}
{$form.$phone_ext_field.html}
{/if}
{else}
- {if $prefix}{$form.$prefix.$n.html}{else}{$form.$n.html}{/if}
+ {if $prefix}
+ {if $n eq 'organization_name'}
+ {if !empty($form.onbehalfof_id)}
+ {$form.onbehalfof_id.html}
+ {/if}
+ {if $organizationName}
+ <span>
+ ( <a id='createNewOrg' href="#" onclick="createNew( ); return false;">{ts}Enter a new organization{/ts}</a> )
+ </span>
+ {/if}
+ {/if}
+ {$form.$prefix.$n.html}
+ {else}
+ {$form.$n.html}
+ {/if}
{/if}
{*CRM-4564*}