+++ /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_Contact_Form_ProfileContact extends CRM_Core_Form {
-
- protected $_profileId;
-
- protected $_prefix;
-
- /**
- * Set variables up before form is built.
- *
- * @param CRM_Core_Form $form
- */
- public function preProcess() {
- parent::preProcess();
-
- $this->_profileId = CRM_Utils_Request::retrieve('id', 'Positive', $this, NULL, FALSE, NULL, 'GET');
- $this->_prefix = CRM_Utils_Request::retrieve('prefix', 'String', $this, NULL, FALSE, NULL, 'GET');
-
- $this->assign('suppressForm', TRUE);
- $this->assign('snippet', TRUE);
- $this->controller->_generateQFKey = FALSE;
- }
-
- /**
- * Build form for honoree contact / on behalf of organization.
- *
- * @param CRM_Core_Form $form
- *
- */
- public function buildQuickForm() {
- $contactID = $this->getContactID();
-
- if ($this->_prefix == 'onbehalf') {
- $this->assign('fieldSetTitle', ts('Organization Details'));
- $this->assign('profileId', $this->_profileId);
-
- if ($contactID) {
- $employer = CRM_Contact_BAO_Relationship::getPermissionedEmployer($contactID);
-
- if (count($employer)) {
- // Related org url - pass checksum if needed
- $args = array('cid' => '');
- if (!empty($_GET['cs'])) {
- $args = array(
- 'uid' => $this->_contactID,
- 'cs' => $_GET['cs'],
- 'cid' => '',
- );
- }
- $locDataURL = CRM_Utils_System::url('civicrm/ajax/permlocation', $args, FALSE, NULL, FALSE);
- $this->assign('locDataURL', $locDataURL);
- }
- if (count($employer) > 0) {
- $this->add('select', 'onbehalfof_id', '', CRM_Utils_Array::collect('name', $employer));
-
- $orgOptions = array(
- 0 => ts('Select an existing organization'),
- 1 => ts('Enter a new organization'),
- );
- $this->addRadio('org_option', ts('options'), $orgOptions);
- $this->setDefaults(array('org_option' => 0));
- }
- }
-
- $profileFields = CRM_Core_BAO_UFGroup::getFields($this->_profileId, FALSE, CRM_Core_Action::VIEW, NULL,
- NULL, FALSE, NULL, FALSE, NULL,
- CRM_Core_Permission::CREATE, NULL
- );
- $this->assign('onBehalfOfFields', $profileFields);
- $this->addElement('hidden', 'onbehalf_profile_id', $this->_profileId);
-
- $fieldTypes = array('Contact', 'Organization');
- $contactSubType = CRM_Contact_BAO_ContactType::subTypes('Organization');
- $fieldTypes = array_merge($fieldTypes, $contactSubType);
-
- 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($this, $field, NULL, NULL, FALSE, $this->_prefix, NULL, $this->_prefix);
- }
- }
- }
-
- }
-}
'soft_credit_types',
'multilingual' => array(
'honor_block_title',
- 'honor_block_text'
+ 'honor_block_text',
),
),
'on_behalf' => array(
$this->assign('pay_later_receipt', $this->_values['pay_later_receipt']);
}
// if onbehalf-of-organization
- if (!empty($this->_params['onbehalf_profile_id'])) {
+ if (!empty($this->_params['onbehalf_profile_id']) && !empty($this->_params['onbehalf']['organization_name'])) {
// CRM-15182
$this->_params['organization_id'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_params['onbehalf']['organization_name'], 'id', 'display_name');
$this->buildCustom($this->_values['custom_pre_id'], 'customPre', TRUE);
$this->buildCustom($this->_values['custom_post_id'], 'customPost', TRUE);
- if (!empty($params['onbehalf_profile_id'])) {
+ if (!empty($params['onbehalf'])) {
$fieldTypes = array('Contact', 'Organization');
$contactSubType = CRM_Contact_BAO_ContactType::subTypes('Organization');
--- /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 extends CRM_Core_Form {
+
+ protected $_profileId;
+
+ /**
+ * Set variables up before form is built.
+ */
+ public function preProcess() {
+ parent::preProcess();
+
+ $this->_profileId = CRM_Utils_Request::retrieve('id', 'Positive', $this, NULL, FALSE, NULL, 'GET');
+
+ $this->assign('suppressForm', TRUE);
+ $this->assign('snippet', TRUE);
+ $this->controller->_generateQFKey = FALSE;
+ }
+
+ /**
+ * Build form for honoree contact / on behalf of organization.
+ */
+ public function buildQuickForm() {
+ $contactID = $this->getContactID();
+
+ $this->assign('fieldSetTitle', ts('Organization Details'));
+ $this->assign('profileId', $this->_profileId);
+
+ if ($contactID) {
+ $employer = CRM_Contact_BAO_Relationship::getPermissionedEmployer($contactID);
+
+ if (count($employer)) {
+ // Related org url - pass checksum if needed
+ $args = array('cid' => '');
+ if (!empty($_GET['cs'])) {
+ $args = array(
+ 'uid' => $this->_contactID,
+ 'cs' => $_GET['cs'],
+ 'cid' => '',
+ );
+ }
+ $locDataURL = CRM_Utils_System::url('civicrm/ajax/permlocation', $args, FALSE, NULL, FALSE);
+ $this->assign('locDataURL', $locDataURL);
+ }
+ if (count($employer) > 0) {
+ $this->add('select', 'onbehalfof_id', '', CRM_Utils_Array::collect('name', $employer));
+
+ $orgOptions = array(
+ 0 => ts('Select an existing organization'),
+ 1 => ts('Enter a new organization'),
+ );
+ $this->addRadio('org_option', ts('options'), $orgOptions);
+ $this->setDefaults(array('org_option' => 0));
+ }
+ }
+
+ $profileFields = CRM_Core_BAO_UFGroup::getFields($this->_profileId, FALSE, CRM_Core_Action::VIEW, NULL,
+ NULL, FALSE, NULL, FALSE, NULL,
+ CRM_Core_Permission::CREATE, NULL
+ );
+ $this->assign('onBehalfOfFields', $profileFields);
+ $this->addElement('hidden', 'onbehalf_profile_id', $this->_profileId);
+
+ $fieldTypes = array('Contact', 'Organization');
+ $contactSubType = CRM_Contact_BAO_ContactType::subTypes('Organization');
+ $fieldTypes = array_merge($fieldTypes, $contactSubType);
+
+ 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($this, $field, NULL, NULL, FALSE, 'onbehalf', NULL, 'onbehalf');
+ }
+ }
+ }
+
+}
$this->assign('address', CRM_Utils_Address::format($addressFields));
- if (!empty($this->_params['onbehalf_profile_id'])) {
+ if (!empty($this->_params['onbehalf_profile_id']) && !empty($this->_params['onbehalf'])) {
$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']);
continue;
}
+ $params = CRM_Contribute_BAO_ContributionPage::formatModuleData($ufJoin->module_data, TRUE, $module);
+
if ($module == 'soft_credit') {
$form->_honoreeProfileId = $ufJoin->uf_group_id;
$form->_honor_block_is_active = $ufJoin->is_active;
CRM_Core_Error::fatal(ts('This contribution page has been configured for contribution on behalf of honoree and the required fields of the selected honoree profile are disabled or doesn\'t exist.'));
}
- //build soft-credit section
- CRM_Contribute_Form_SoftCredit::buildQuickForm($form);
+ $form->assign('honor_block_is_active', $form->_honor_block_is_active);
+
+ foreach (array('honor_block_title', 'honor_block_text') as $name) {
+ $form->assign($name, $params[$name]);
+ }
+
+ $softCreditTypes = CRM_Core_OptionGroup::values("soft_credit_type", FALSE);
+
+ // radio button for Honor Type
+ foreach ($params['soft_credit_types'] as $value) {
+ $honorTypes[$value] = $form->createElement('radio', NULL, NULL, $softCreditTypes[$value], $value);
+ }
+ $form->addGroup($honorTypes, 'soft_credit_type_id', NULL)->setAttribute('allowClear', TRUE);
+
+ $prefix = 'honor';
+ $honoreeProfileFields = CRM_Core_BAO_UFGroup::getFields($form->_honoreeProfileId, FALSE, NULL,
+ NULL, NULL,
+ FALSE, NULL,
+ TRUE, NULL,
+ CRM_Core_Permission::CREATE
+ );
+ $form->addElement('hidden', 'honoree_profile_id', $form->_honoreeProfileId);
+ $form->assign('honoreeProfileFields', $honoreeProfileFields);
+
+ // add the form elements
+ foreach ($honoreeProfileFields as $name => $field) {
+ // If soft credit type is not chosen then make omit requiredness from honoree profile fields
+ if (count($form->_submitValues) &&
+ empty($form->_submitValues['soft_credit_type_id']) &&
+ !empty($field['is_required'])
+ ) {
+ $field['is_required'] = FALSE;
+ }
+ CRM_Core_BAO_UFGroup::buildProfile($form, $field, CRM_Profile_Form::MODE_CREATE, NULL, FALSE, FALSE, NULL, $prefix);
+ }
}
else {
- $params = CRM_Contribute_BAO_ContributionPage::formatModuleData($ufJoin->module_data, TRUE, 'on_behalf');
$form->_values = array_merge($params, $form->_values);
$onBehalfProfileId = $ufJoin->uf_group_id;
<page_callback>CRM_Contact_Page_AJAX::flipDupePairs</page_callback>
<access_arguments>merge duplicate contacts</access_arguments>
</item>
-<item>
- <path>civicrm/profileContact/form</path>
- <access_callback>1</access_callback>
- <page_callback>CRM_Contact_Form_ProfileContact</page_callback>
- <is_public>true</is_public>
- <weight>0</weight>
-</item>
<item>
<path>civicrm/activity/sms/add</path>
<path_arguments>action=add</path_arguments>
<access_arguments>access CiviCRM</access_arguments>
<title>Insert CiviCRM Content</title>
</item>
+ <item>
+ <path>civicrm/onbehalf/form</path>
+ <access_callback>1</access_callback>
+ <page_callback>CRM_Contribute_Form_Contribution_OnBehalfOf</page_callback>
+ <is_public>true</is_public>
+ <weight>0</weight>
+ </item>
</menu>
<div class="clear"></div>
</div>
- {include file="CRM/Contact/Form/ProfileContact.tpl"}
+ {include file="CRM/Contribute/Form/Contribution/OnBehalfOf.tpl"}
{* User account registration option. Displays if enabled for one of the profiles on this page. *}
{include file="CRM/common/CMSUser.tpl"}
{include file="CRM/Contribute/Form/Contribution/PremiumBlock.tpl" context="makeContribution"}
{if $honor_block_is_active}
- <fieldset class="crm-group honor_block-group">
- {include file="CRM/Contribute/Form/SoftCredit.tpl"}
- <div id="honorType" class="honoree-name-email-section">
- {include file="CRM/UF/Form/Block.tpl" fields=$honoreeProfileFields mode=8 prefix='honor'}
- </div>
- </fieldset>
+ <fieldset class="crm-group honor_block-group">
+ {crmRegion name="contribution-soft-credit-block"}
+ <legend>{$honor_block_title}</legend>
+ <div class="crm-section honor_block_text-section">
+ {$honor_block_text}
+ </div>
+ {if $form.soft_credit_type_id.html}
+ <div class="crm-section {$form.soft_credit_type_id.name}-section">
+ <div class="content" >
+ {$form.soft_credit_type_id.html}
+ <div class="description">{ts}Select an option to reveal honoree information fields.{/ts}</div>
+ </div>
+ </div>
+ {/if}
+ {/crmRegion}
+ <div id="honorType" class="honoree-name-email-section">
+ {include file="CRM/UF/Form/Block.tpl" fields=$honoreeProfileFields mode=8 prefix='honor'}
+ </div>
+ </fieldset>
{/if}
<div class="crm-group custom_pre_profile-group">
}
{/literal}{if $onBehalfprofileId}
{capture assign='onBehalfprofileId'}id={$onBehalfprofileId}&{/capture};
- var dataUrl = "{crmURL p='civicrm/profileContact/form' h=0 q="`$onBehalfprofileId`prefix=onbehalf"}";
+ var dataUrl = "{crmURL p='civicrm/onbehalf/form' h=0 q="`$onBehalfprofileId`prefix=onbehalf"}";
{/if}{literal}
if (typeof dataUrl != 'undefined') {CRM.loadPage(dataUrl, {target: '#on-behalf-block'})};
}
+--------------------------------------------------------------------+
*}
{* template for adding form elements for soft credit form*}
-{if $honor_block_is_active}
- {crmRegion name="contribution-soft-credit-block"}
- <legend>{$honor_block_title}</legend>
- <div class="crm-section honor_block_text-section">
- {$honor_block_text}
- </div>
- {if $form.soft_credit_type_id.html}
- <div class="crm-section {$form.soft_credit_type_id.name}-section">
- <div class="content" >
- {$form.soft_credit_type_id.html}
- <div class="description">{ts}Select an option to reveal honoree information fields.{/ts}</div>
- </div>
- </div>
- {/if}
- {/crmRegion}
-{else}
<table class="form-layout-compressed crm-soft-credit-block">
{section name='i' start=1 loop=$rowCount}
{assign var='rowNumber' value=$smarty.section.i.index}
</td>
</tr>
</table>
-{/if}
+
{literal}
<script type="text/javascript">
CRM.$(function($) {