--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.4 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2013 |
+ +--------------------------------------------------------------------+
+ | 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-2013
+ * $Id$
+ *
+ */
+class CRM_Contact_Form_ProfileContact {
+
+ protected $_mode;
+
+ /**
+ * Function to set variables up before form is built
+ *
+ * @return void
+ * @access public
+ */
+ static function preProcess(&$form) {
+ $session = CRM_Core_Session::singleton();
+ $contactID = $session->get('userID');
+
+ $ufJoinParams = array(
+ 'module' => 'soft_credit',
+ 'entity_table' => 'civicrm_contribution_page',
+ 'entity_id' => $form->_id,
+ );
+ $profileId = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
+ $form->_honoreeProfileId = $profileId[0];
+
+ if (!$form->_honoreeProfileId ||
+ !CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $form->_honoreeProfileId, 'is_active')
+ ) {
+ CRM_Core_Error::fatal(ts('This contribution page has been configured for contribution on behalf of honoree and the selected honoree profile is either disabled or not found.'));
+ }
+
+ $profileContactType = CRM_Core_BAO_UFGroup::getContactType($form->_honoreeProfileId);
+ $requiredProfileFields = array(
+ 'Individual' => array('first_name', 'last_name'),
+ 'Organization' => array('organization_name', 'email'),
+ 'Household' => array('household_name', 'email')
+ );
+ $validProfile = CRM_Core_BAO_UFGroup::checkValidProfile($form->_honoreeProfileId, $requiredProfileFields[$profileContactType]);
+ if (!$validProfile) {
+ 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.'));
+ }
+ }
+
+ /**
+ * Function to build form for honoree contact / on behalf of organization.
+ *
+ * @param $form object invoking Object
+ * @param $contactType string contact type
+ * @param $title string fieldset title
+ *
+ * @static
+ */
+ static function buildQuickForm(&$form) {
+ $ufGroup = new CRM_Core_DAO_UFGroup();
+ $ufGroup->id = $form->_honoreeProfileId;
+ if (!$ufGroup->find(TRUE)) {
+ CRM_Core_Error::fatal(ts('Chosen honoree profile is for this contribution is disabled'));
+ }
+
+ $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) &&
+ !CRM_Utils_Array::value('soft_credit_type_id', $form->_submitValues) &&
+ CRM_Utils_Array::value('is_required', $field)
+ ) {
+ $field['is_required'] = FALSE;
+ }
+ CRM_Core_BAO_UFGroup::buildProfile($form, $field, CRM_Profile_Form::MODE_CREATE, NULL, FALSE, FALSE, NULL, $prefix);
+ }
+ }
+
+ static function postProcess($form) {
+ $params = $form->_params;
+ $values = $form->_values;
+ if ($form->get('honor_block_is_active') && CRM_Utils_Array::value('soft_credit_type_id', $params)) {
+ $honorId = null;
+
+ //check if there is any duplicate contact
+ $profileContactType = CRM_Core_BAO_UFGroup::getContactType($params['honoree_profile_id']);
+ CRM_Core_Error::debug( '$profileContactType', $profileContactType );
+ $dedupeParams = CRM_Dedupe_Finder::formatParams($params['honor'], $profileContactType);
+ $dedupeParams['check_permission'] = FALSE;
+ $ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, $profileContactType);
+ if(count($ids)) {
+ $honorId = CRM_Utils_Array::value(0, $ids);
+ }
+
+ $honorId = CRM_Contact_BAO_Contact::createProfileContact(
+ $params['honor'], CRM_Core_DAO::$_nullArray,
+ $honorId, NULL,
+ $params['honoree_profile_id']
+ );
+ $softParams = array();
+ $softParams['contribution_id'] = $form->_contributionID;
+ $softParams['contact_id'] = $honorId;
+ $softParams['soft_credit_type_id'] = $params['soft_credit_type_id'];
+ $contribution = new CRM_Contribute_DAO_Contribution();
+ $contribution->id = $form->_contributionID;
+ $contribution->find();
+ while ($contribution->fetch()) {
+ $softParams['currency'] = $contribution->currency;
+ $softParams['amount'] = $contribution->total_amount;
+ }
+ CRM_Contribute_BAO_ContributionSoft::add($softParams);
+ }
+ }
+}
+
foreach ($softParams as $softParam) {
$softParam['contribution_id'] = $contribution->id;
$softParam['currency'] = $contribution->currency;
- $softParam['pcp_id'] = 'null';
- $softParam['pcp_display_in_roll'] = 'null';
- $softParam['pcp_roll_nickname'] = 'null';
- $softParam['pcp_personal_note'] = 'NULL';
CRM_Contribute_BAO_ContributionSoft::add($softParam);
}
}
}
}
- /**
- * Function to create is honor of
- *
- * @param array $params associated array of fields (by reference)
- * @param int $honorId honor Id
- * @param array $honorParams any params that should be send to the create function
- *
- * @return contact id
- */
- static function createHonorContact(&$params, $honorId = NULL, $honorParams = array()) {
- $honorParams = array_merge(
- array(
- 'first_name' => $params['honor_first_name'],
- 'last_name' => $params['honor_last_name'],
- 'prefix_id' => $params['honor_prefix_id'],
- 'email-Primary' => $params['honor_email'],
- ),
- $honorParams
- );
- if (!$honorId) {
- $honorParams['email'] = $params['honor_email'];
-
- $dedupeParams = CRM_Dedupe_Finder::formatParams($honorParams, 'Individual');
- $dedupeParams['check_permission'] = FALSE;
- $ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, 'Individual');
-
- // if we find more than one contact, use the first one
- $honorId = CRM_Utils_Array::value(0, $ids);
- }
-
- $contactID = CRM_Contact_BAO_Contact::createProfileContact(
- $honorParams,
- CRM_Core_DAO::$_nullArray,
- $honorId
- );
- return $contactID;
- }
-
/**
* Function to get list of contribution In Honor of contact Ids
*
return $componentDetails;
}
- static function contributionCount($contactId, $includeSoftCredit = TRUE, $includeHonoree = TRUE) {
+ static function contributionCount($contactId, $includeSoftCredit = TRUE) {
if (!$contactId) {
return 0;
}
FROM civicrm_contribution contribution
WHERE contribution.is_test = 0 AND contribution.contact_id = {$contactId} ";
- $contactHonoreeContributionsSQL = "
- SELECT contribution.id
- FROM civicrm_contribution contribution
- WHERE contribution.is_test = 0 AND contribution.honor_contact_id = {$contactId} ";
-
$contactSoftCreditContributionsSQL = "
SELECT contribution.id
FROM civicrm_contribution contribution INNER JOIN civicrm_contribution_soft softContribution
$query .= $contactSoftCreditContributionsSQL;
}
- if ($includeHonoree) {
- $query .= " UNION ";
- $query .= $contactHonoreeContributionsSQL;
- }
-
$query .= ") x";
return CRM_Core_DAO::singleValueQuery($query);
$query->_tables['contribution_payment_instrument'] = 1;
}
- // get honor contact name
- if (CRM_Utils_Array::value('honor_contact_name', $query->_returnProperties)) {
- $query->_select['contribution_honor_contact_name'] = "civicrm_contact_c.display_name as contribution_honor_contact_name";
- $query->_element['contribution_honor_contact_name'] = 1;
- $query->_tables['civicrm_contribution'] = 1;
- $query->_tables['contribution_honor_contact_name'] = 1;
- }
-
- // get honor type label
- if (CRM_Utils_Array::value('honor_type_label', $query->_returnProperties)) {
- $query->_select['contribution_honor_type_label'] = "honor_type.label as contribution_honor_type_label";
- $query->_element['contribution_honor_type_label'] = 1;
- $query->_tables['civicrm_contribution'] = 1;
- $query->_tables['contribution_honor_type_label'] = 1;
- }
-
- // get honor contact email
- if (CRM_Utils_Array::value('honor_contact_email', $query->_returnProperties)) {
- $query->_select['contribution_honor_contact_email'] = "honor_email.email as contribution_honor_contact_email";
- $query->_element['contribution_honor_contact_email'] = 1;
- $query->_tables['civicrm_contribution'] = 1;
- $query->_tables['contribution_honor_contact_email'] = 1;
- }
-
- // get honor contact id
- if (CRM_Utils_Array::value('honor_contact_id', $query->_returnProperties)) {
- $query->_select['contribution_honor_contact_id'] = "civicrm_contribution.honor_contact_id as contribution_honor_contact_id";
- $query->_element['contribution_honor_contact_id'] = 1;
- $query->_tables['civicrm_contribution'] = 1;
- }
-
-
if (CRM_Utils_Array::value('check_number', $query->_returnProperties)) {
$query->_select['contribution_check_number'] = "civicrm_contribution.check_number as contribution_check_number";
$query->_element['contribution_check_number'] = 1;
$query->_tables['civicrm_contribution'] = $query->_whereTables['civicrm_contribution'] = 1;
return;
- case 'contribution_in_honor_of':
- $name = trim($value);
- $newName = str_replace(',', " ", $name);
- $pieces = explode(' ', $newName);
- foreach ($pieces as $piece) {
- $value = $strtolower(CRM_Core_DAO::escapeString(trim($piece)));
- $value = "'%$value%'";
- $sub[] = " ( contact_b.sort_name LIKE $value )";
- }
-
- $query->_where[$grouping][] = ' ( ' . implode(' OR ', $sub) . ' ) ';
- $query->_qill[$grouping][] = ts('Honor name like - \'%1\'', array(1 => $name));
- $query->_tables['civicrm_contact_b'] = $query->_whereTables['civicrm_contact_b'] = 1;
- $query->_tables['civicrm_contribution'] = $query->_whereTables['civicrm_contribution'] = 1;
- return;
-
case 'contribution_status':
case 'contribution_status_id':
if (is_array($value)) {
AND option_group_payment_instrument.id = payment_instrument.option_group_id ) ";
break;
- case 'civicrm_contact_b':
- $from .= " $side JOIN civicrm_contact contact_b ON (civicrm_contribution.honor_contact_id = contact_b.id )";
- break;
-
case 'contribution_status':
$from = " $side JOIN civicrm_option_group option_group_contribution_status ON (option_group_contribution_status.name = 'contribution_status')";
$from .= " $side JOIN civicrm_option_value contribution_status ON (civicrm_contribution.contribution_status_id = contribution_status.value
civicrm_contribution.id = civicrm_note.entity_id )";
break;
- case 'contribution_honor_contact_name':
- $from .= " $side JOIN civicrm_contact civicrm_contact_c ON (civicrm_contribution.honor_contact_id = civicrm_contact_c.id )";
- break;
-
- case 'contribution_honor_contact_email':
- $from .= " $side JOIN civicrm_email as honor_email ON (civicrm_contribution.honor_contact_id = honor_email.contact_id AND honor_email.is_primary = 1 )";
- break;
-
- case 'contribution_honor_type_label':
- $from = " $side JOIN civicrm_option_group option_group_honor_type ON ( option_group_honor_type.name = 'honor_type')";
- $from .= " $side JOIN civicrm_option_value honor_type ON (civicrm_contribution.honor_type_id = honor_type.value
- AND option_group_honor_type.id = honor_type.option_group_id ) ";
- break;
-
case 'contribution_membership':
$from = " $side JOIN civicrm_membership_payment ON civicrm_membership_payment.contribution_id = civicrm_contribution.id";
$from .= " $side JOIN civicrm_membership ON civicrm_membership_payment.membership_id = civicrm_membership.id ";
$form->addYesNo('contribution_thankyou_date_is_not_null', ts('Thank-you sent?'));
$form->addYesNo('contribution_receipt_date_is_not_null', ts('Receipt sent?'));
- // Add fields for honor search
- $form->addElement('text', 'contribution_in_honor_of', ts("In Honor Of"));
-
$form->addYesNo('contribution_pay_later', ts('Contribution is Pay Later?'));
$form->addYesNo('contribution_recurring', ts('Contribution is Recurring?'));
$params['receipt_date'] = $formatted['receipt_date'] = date('YmdHis');
}
- if (CRM_Utils_Array::value('honor_type_id', $params)) {
- if ($form->_honorID) {
- $honorId = CRM_Contribute_BAO_Contribution::createHonorContact($params, $form->_honorID);
- }
- else {
- $honorId = CRM_Contribute_BAO_Contribution::createHonorContact($params);
- }
- $formatted["honor_contact_id"] = $honorId;
- }
- else {
- $formatted["honor_contact_id"] = 'null';
- }
-
//special case to handle if all checkboxes are unchecked
$customFields = CRM_Core_BAO_CustomField::getFields('Contribution',
FALSE,
*/
public $_options;
- /**
- * stores the honor id
- *
- * @var int
- * @public
- */
- public $_honorID = NULL;
-
/**
* Store the contribution Type ID
*
//set defaults for pledge payment.
if ($this->_ppID) {
$defaults['total_amount'] = CRM_Utils_Array::value('scheduled_amount', $this->_pledgeValues['pledgePayment']);
- $defaults['honor_type_id'] = CRM_Utils_Array::value('honor_type_id', $this->_pledgeValues);
- $defaults['honor_contact_id'] = CRM_Utils_Array::value('honor_contact_id', $this->_pledgeValues);
$defaults['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $this->_pledgeValues);
$defaults['currency'] = CRM_Utils_Array::value('currency', $this->_pledgeValues);
$defaults['option_type'] = 1;
if ($this->_contributionType) {
$defaults['financial_type_id'] = $this->_contributionType;
}
-
+
if (!CRM_Utils_Array::value('payment_instrument_id', $defaults)) {
$defaults['payment_instrument_id'] = key(CRM_Core_OptionGroup::values('payment_instrument', FALSE, FALSE, FALSE, 'AND is_default = 1'));
}
$this->assign('is_test', TRUE);
}
- if (isset($defaults['honor_contact_id'])) {
- $honorDefault = $ids = array();
- $this->_honorID = $defaults['honor_contact_id'];
- $honorType = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'honor_type_id');
- $idParams = array(
- 'id' => $defaults['honor_contact_id'],
- 'contact_id' => $defaults['honor_contact_id'],
- );
- CRM_Contact_BAO_Contact::retrieve($idParams, $honorDefault, $ids);
-
- $defaults['honor_prefix_id'] = CRM_Utils_Array::value('prefix_id', $honorDefault);
- $defaults['honor_first_name'] = CRM_Utils_Array::value('first_name', $honorDefault);
- $defaults['honor_last_name'] = CRM_Utils_Array::value('last_name', $honorDefault);
- $defaults['honor_email'] = CRM_Utils_Array::value('email', $honorDefault['email'][1]);
- $defaults['honor_type'] = $honorType[$defaults['honor_type_id']];
- }
-
$this->assign('showOption', TRUE);
// for Premium section
if ($this->_premiumID) {
}
}
- $honorFields = array(
- 'honor_type_id',
- 'honor_prefix_id',
- 'honor_first_name',
- 'honor_lastname',
- 'honor_email',
- );
- foreach ($honorFields as $key) {
- if (!empty($defaults[$key])) {
- $defaults['hidden_Honoree'] = 1;
- break;
- }
- }
-
- //check for honoree pane.
- if ($this->_ppID && CRM_Utils_Array::value('honor_contact_id', $this->_pledgeValues)) {
- $defaults['hidden_Honoree'] = 1;
- }
-
if ($this->_productDAO) {
if ($this->_productDAO->product_id) {
$defaults['hidden_Premium'] = 1;
$paneNames = array(
ts('Additional Details') => 'AdditionalDetail',
- ts('Honoree Information') => 'Honoree'
);
//Add Premium pane only if Premium is exists.
$errors['contact[1]'] = ts('Please select a contact or create new contact');
}
- if (isset($fields['honor_type_id'])) {
- if (!((CRM_Utils_Array::value('honor_first_name', $fields) &&
- CRM_Utils_Array::value('honor_last_name', $fields)
- ) ||
- CRM_Utils_Array::value('honor_email', $fields)
- )
- ) {
- $errors['honor_first_name'] = ts('Honor First Name and Last Name OR an email should be set.');
- }
- }
-
//check for Credit Card Contribution.
if ($self->_mode) {
if (empty($fields['payment_processor_id'])) {
&& $financialType = CRM_Contribute_BAO_Contribution::validateFinancialType($fields['financial_type_id'])) {
$errors['financial_type_id'] = ts("Financial Account of account relationship of 'Expense Account is' is not configured for Financial Type : ") . $financialType;
}
-
+
// $trxn_id must be unique CRM-13919
if (!empty($fields['trxn_id'])) {
$queryParams = array(1 => array($fields['trxn_id'], 'String'));
$tCnt = CRM_Core_DAO::singleValueQuery($query, $queryParams);
if ($tCnt) {
$errors['trxn_id'] = ts('Transaction ID\'s must be unique. Transaction \'%1\' already exists in your database.', array(1 => $fields['trxn_id']));
- }
+ }
}
$errors = array_merge($errors, $softErrors);
$params = $this->_params;
$honor_block_is_active = $this->get('honor_block_is_active');
// make sure we have values for it
- if ($honor_block_is_active &&
- ((!empty($params['honor_first_name']) && !empty($params['honor_last_name'])) ||
- (!empty($params['honor_email']))
- )
- ) {
+ if ($honor_block_is_active && CRM_Utils_Array::value('soft_credit_type_id', $params)) {
+ $honorName = null;
+ $softCreditTypes = CRM_Core_OptionGroup::values("soft_credit_type", FALSE);
+
$this->assign('honor_block_is_active', $honor_block_is_active);
- $this->assign('honor_block_title', CRM_Utils_Array::value('honor_block_title', $this->_values));
+ $this->assign('soft_credit_type', $softCreditTypes[$params['soft_credit_type_id']]);
+ $profileContactType = CRM_Core_BAO_UFGroup::getContactType($params['honoree_profile_id']);
+ switch ($profileContactType) {
+ case 'Individual':
+ if (array_key_exists('prefix_id', $params['honor'])) {
+ $honorName = CRM_Utils_Array::value(CRM_Utils_Array::value('prefix_id',$params['honor']),
+ CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id')
+ );
+ }
+ $honorName .= ' ' . $params['honor']['first_name'] . ' ' . $params['honor']['last_name'];
+ if (array_key_exists('suffix_id', $params['honor'])) {
+ $honorName .= ' ' . CRM_Utils_Array::value(CRM_Utils_Array::value('suffix_id',$params['honor']),
+ CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id')
+ );
+ }
+ break;
+ case 'Organization':
+ $honorName = $params['honor']['organization_name'];
+ break;
+ case 'Household':
+ $honorName = $params['honor']['household_name'];
+ break;
+ }
+ $this->assign('honorName', $honorName);
- $prefix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id');
- $honor = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'honor_type_id');
- $this->assign('honor_type', CRM_Utils_Array::value($params['honor_type_id'], $honor));
- $this->assign('honor_prefix', CRM_Utils_Array::value($params['honor_prefix_id'], $prefix));
- $this->assign('honor_first_name', $params['honor_first_name']);
- $this->assign('honor_last_name', $params['honor_last_name']);
- $this->assign('honor_email', $params['honor_email']);
+ $fieldTypes = array('Contact');
+ $fieldTypes[] = CRM_Core_BAO_UFGroup::getContactType($params['honoree_profile_id']);
+ $this->buildCustom($params['honoree_profile_id'], 'honoreeProfileFields', TRUE, 'honor', $fieldTypes);
}
$this->assign('receiptFromEmail', CRM_Utils_Array::value('receipt_from_email', $this->_values));
$amount_block_is_active = $this->get('amount_block_is_active');
$fieldTypes = array_merge($fieldTypes, array('Contribution'));
}
- $this->buildCustom($profileId, 'onbehalfProfile', TRUE, TRUE, $fieldTypes);
+ $this->buildCustom($profileId, 'onbehalfProfile', TRUE, 'onbehalf', $fieldTypes);
}
$this->_separateMembershipPayment = $this->get('separateMembershipPayment');
$defaults = array();
$fields = array();
foreach ($this->_fields as $name => $dontCare) {
- if ($name == 'onbehalf') {
- foreach ($dontCare as $key => $value) {
- $fields['onbehalf'][$key] = 1;
- }
- }
- else {
+ if ($name != 'onbehalf' || $name != 'honor') {
$fields[$name] = 1;
}
}
$contact = $this->_params;
foreach ($fields as $name => $dontCare) {
- if ($name == 'onbehalf') {
- foreach ($dontCare as $key => $value) {
- if (isset($contact['onbehalf'][$key])) {
- $defaults[$key] = $contact['onbehalf'][$key];
- }
- if (isset($contact['onbehalf']["{$key}_id"])) {
- $defaults["{$key}_id"] = $contact['onbehalf']["{$key}_id"];
- }
- }
- }
- elseif (isset($contact[$name])) {
+ if (isset($contact[$name])) {
$defaults[$name] = $contact[$name];
if (substr($name, 0, 7) == 'custom_') {
$timeField = "{$name}_time";
$fieldTypes
);
}
+
+ //processing honor contact into soft-credit contribution
+ CRM_Contact_Form_ProfileContact::postProcess($this);
}
/**
) {
$transaction = new CRM_Core_Transaction();
$className = get_class($form);
- $honorCId = $recurringContributionID = NULL;
-
- if ($online && $form->get('honor_block_is_active')) {
- $honorCId = $form->createHonorContact();
- }
+ $recurringContributionID = NULL;
// add these values for the recurringContrib function ,CRM-10188
$params['financial_type_id'] = $contributionType->id;
}
$recurringContributionID = self::processRecurringContribution($form, $params, $contactID, $contributionType, $online);
- if (!$online && isset($params['honor_contact_id'])) {
- $honorCId = $params['honor_contact_id'];
- }
-
$config = CRM_Core_Config::singleton();
// CRM-11885
// if non_deductible_amount exists i.e. Additional Details fieldset was opened [and staff typed something] -> keep it.
);
}
- if (isset($honorCId)) {
- $contribParams['honor_contact_id'] = $honorCId;
- $contribParams['honor_type_id'] = $params['honor_type_id'];
- }
-
if ($recurringContributionID) {
$contribParams['contribution_recur_id'] = $recurringContributionID;
}
return $recurring->id;
}
- /**
- * Create the Honor contact
- *
- * @return void
- * @access public
- */
- function createHonorContact() {
- $params = $this->controller->exportValues('Main');
-
- // email is enough to create a contact
- if (! CRM_Utils_Array::value('honor_email', $params) &&
- // or we need first name AND last name
- (! CRM_Utils_Array::value('honor_first_name', $params)
- || ! CRM_Utils_Array::value('honor_last_name', $params))) {
- //don't create contact - possibly the form was left blank
- return null;
- }
-
- //assign to template for email receipt
- $honor_block_is_active = $this->get('honor_block_is_active');
-
- $this->assign('honor_block_is_active', $honor_block_is_active);
- $this->assign('honor_block_title', CRM_Utils_Array::value('honor_block_title', $this->_values));
-
- $prefix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id');
- $honorType = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'honor_type_id');
- $this->assign('honor_type', CRM_Utils_Array::value(CRM_Utils_Array::value('honor_type_id', $params), $honorType));
- $this->assign('honor_prefix', CRM_Utils_Array::value(CRM_Utils_Array::value('honor_prefix_id', $params), $prefix));
- $this->assign('honor_first_name', CRM_Utils_Array::value('honor_first_name', $params));
- $this->assign('honor_last_name', CRM_Utils_Array::value('honor_last_name', $params));
- $this->assign('honor_email', CRM_Utils_Array::value('honor_email', $params));
-
- //create honoree contact
- return CRM_Contribute_BAO_Contribution::createHonorContact($params);
- }
-
/**
* Function to add on behalf of organization and it's location
*
}
$this->assign('onBehalfRequired', $this->_onBehalfRequired);
+ if (CRM_Utils_Array::value('honor_block_is_active', $this->_values)) {
+ CRM_Contact_Form_ProfileContact::preprocess($this);
+ }
+
if (!empty($this->_pcpInfo['id']) && !empty($this->_pcpInfo['intro_text'])) {
$this->assign('intro_text', $this->_pcpInfo['intro_text']);
}
//build set default for pledge overdue payment.
if (CRM_Utils_Array::value('pledge_id', $this->_values)) {
- //get all payment statuses.
- $statuses = array();
- $returnProperties = array('status_id');
- CRM_Core_DAO::commonRetrieveAll('CRM_Pledge_DAO_PledgePayment', 'pledge_id', $this->_values['pledge_id'],
- $statuses, $returnProperties
- );
+ //get all pledge payment records of current pledge id.
+ $pledgePayments = array();
+
+ //used to record completed pledge payment ids used later for honor default
+ $completedContributionIds = array();
+
+ $pledgePayments = CRM_Pledge_BAO_PledgePayment::getPledgePayments($this->_values['pledge_id']);
- $paymentStatusTypes = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
$duePayment = FALSE;
- foreach ($statuses as $payId => $value) {
- if ($paymentStatusTypes[$value['status_id']] == 'Overdue') {
+ foreach ($pledgePayments as $payId => $value) {
+ if ($value['status'] == 'Overdue') {
$this->_defaults['pledge_amount'][$payId] = 1;
}
- elseif (!$duePayment && $paymentStatusTypes[$value['status_id']] == 'Pending') {
+ elseif (!$duePayment && $value['status'] == 'Pending') {
$this->_defaults['pledge_amount'][$payId] = 1;
$duePayment = TRUE;
}
+ elseif ($value['status'] == 'Completed' && $value['contribution_id']) {
+ $completedContributionIds[] = $value['contribution_id'];
+ }
+ }
+
+ if (CRM_Utils_Array::value('honor_block_is_active', $this->_values) && count($completedContributionIds)) {
+ $softCredit = array();
+ foreach ($completedContributionIds as $id) {
+ $softCredit = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($id);
+ }
+ if (isset($softCredit['soft_credit'])) {
+ $this->_defaults['soft_credit_type_id'] = $softCredit['soft_credit'][1]['soft_credit_type'];
+
+ //since honoree profile fieldname of fields are prefixed with 'honor'
+ //we need to reformat the fieldname to append prefix during setting default values
+ CRM_Core_BAO_UFGroup::setProfileDefaults(
+ $softCredit['soft_credit'][1]['contact_id'],
+ CRM_Core_BAO_UFGroup::getFields($this->_honoreeProfileId),
+ $defaults
+ );
+ foreach ($defaults as $fieldName => $value) {
+ $this->_defaults['honor[' . $fieldName . ']'] = $value;
+ }
+ }
}
}
elseif (CRM_Utils_Array::value('pledge_block_id', $this->_values)) {
CRM_Contribute_BAO_Premium::buildPremiumBlock($this, $this->_id, TRUE);
}
+ //add honor block
if ($this->_values['honor_block_is_active']) {
- $this->buildHonorBlock();
+ $this->assign('honor_block_is_active', TRUE);
+ $this->set('honor_block_is_active', TRUE);
+
+ //build soft-credit section
+ CRM_Contribute_Form_SoftCredit::buildQuickForm($this);
+ //build honoree profile section
+ CRM_Contact_Form_ProfileContact::buildQuickForm($this);
}
$this->addFormRule(array('CRM_Contribute_Form_Contribution_Main', 'formRule'), $this);
}
- /**
- * Function to add the honor block
- *
- * @return void
- * @access public
- */
- function buildHonorBlock() {
- $this->assign('honor_block_is_active', TRUE);
- $this->set('honor_block_is_active', TRUE);
-
- $this->assign('honor_block_title', CRM_Utils_Array::value('honor_block_title', $this->_values));
- $this->assign('honor_block_text', CRM_Utils_Array::value('honor_block_text', $this->_values));
-
- $attributes = CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact');
- $extraOption = array('onclick' => "enableHonorType();");
- // radio button for Honor Type
- $honorOptions = array();
- $honor = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'honor_type_id');
- foreach ($honor as $key => $var) {
- $honorTypes[$key] = $this->createElement('radio', NULL, NULL, $var, $key, $extraOption);
- }
- $this->addGroup($honorTypes, 'honor_type_id', NULL);
-
- // prefix
- $this->addElement('select', 'honor_prefix_id', ts('Prefix'), array('' => ts('- prefix -')) + CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id'));
- // first_name
- $this->addElement('text', 'honor_first_name', ts('First Name'), $attributes['first_name']);
-
- //last_name
- $this->addElement('text', 'honor_last_name', ts('Last Name'), $attributes['last_name']);
-
- //email
- $this->addElement('text', 'honor_email', ts('Email Address'), array('class' => 'email'));
- $this->addRule('honor_email', ts('Honoree Email is not valid.'), 'email');
- }
-
/**
* build elements to enable pay on behalf of an organization.
*
}
}
- if ($self->_values['honor_block_is_active'] && CRM_Utils_Array::value('honor_type_id', $fields)) {
- // make sure there is a first name and last name if email is not there
- if (!CRM_Utils_Array::value('honor_email', $fields)) {
- if (!CRM_Utils_Array::value('honor_first_name', $fields) ||
- !CRM_Utils_Array::value('honor_last_name', $fields)
- ) {
- $errors['honor_last_name'] = ts('In Honor Of - First Name and Last Name, OR an Email Address is required.');
- }
- }
- }
-
if ( CRM_Utils_Array::value( 'is_recur', $fields ) ) {
if ($fields['frequency_interval'] <= 0) {
$errors['frequency_interval'] = ts('Please enter a number for how often you want to make this recurring contribution (EXAMPLE: Every 3 months).');
$params = $this->_params;
$honor_block_is_active = $this->get('honor_block_is_active');
- if ($honor_block_is_active &&
- ((!empty($params["honor_first_name"]) && !empty($params["honor_last_name"])) ||
- (!empty($params["honor_email"]))
- )
- ) {
+ if ($honor_block_is_active && CRM_Utils_Array::value('soft_credit_type_id', $params)) {
+ $honorName = null;
+ $softCreditTypes = CRM_Core_OptionGroup::values("soft_credit_type", FALSE);
+
$this->assign('honor_block_is_active', $honor_block_is_active);
- $this->assign('honor_block_title', CRM_Utils_Array::value('honor_block_title', $this->_values));
+ $this->assign('soft_credit_type', $softCreditTypes[$params['soft_credit_type_id']]);
+ $profileContactType = CRM_Core_BAO_UFGroup::getContactType($params['honoree_profile_id']);
+ switch ($profileContactType) {
+ case 'Individual':
+ if (array_key_exists('prefix_id', $params['honor'])) {
+ $honorName = CRM_Utils_Array::value(CRM_Utils_Array::value('prefix_id',$params['honor']),
+ CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id')
+ );
+ }
+ $honorName .= ' ' . $params['honor']['first_name'] . ' ' . $params['honor']['last_name'];
+ if (array_key_exists('suffix_id', $params['honor'])) {
+ $honorName .= ' ' . CRM_Utils_Array::value(CRM_Utils_Array::value('suffix_id',$params['honor']),
+ CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id')
+ );
+ }
+ break;
+ case 'Organization':
+ $honorName = $params['honor']['organization_name'];
+ break;
+ case 'Household':
+ $honorName = $params['honor']['household_name'];
+ break;
+ }
+ $this->assign('honorName', $honorName);
- $prefix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id');
- $honor = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'honor_type_id');
- $this->assign('honor_type', $honor[$params["honor_type_id"]]);
- $this->assign('honor_prefix', ($params["honor_prefix_id"]) ? $prefix[$params["honor_prefix_id"]] : ' ');
- $this->assign('honor_first_name', $params["honor_first_name"]);
- $this->assign('honor_last_name', $params["honor_last_name"]);
- $this->assign('honor_email', $params["honor_email"]);
+ $fieldTypes = array('Contact');
+ $fieldTypes[] = CRM_Core_BAO_UFGroup::getContactType($params['honoree_profile_id']);
+ $this->buildCustom($params['honoree_profile_id'], 'honoreeProfileFields', TRUE, 'honor', $fieldTypes);
}
$qParams = "reset=1&id={$this->_id}";
$fieldTypes = array_merge($fieldTypes, array('Contribution'));
}
- $this->buildCustom($profileId, 'onbehalfProfile', TRUE, TRUE, $fieldTypes);
+ $this->buildCustom($profileId, 'onbehalfProfile', TRUE, 'onbehalf', $fieldTypes);
}
$this->assign('trxn_id',
$defaults = array();
$fields = array();
foreach ($this->_fields as $name => $dontCare) {
- if ($name == 'onbehalf') {
- foreach ($dontCare as $key => $value) {
- $fields['onbehalf'][$key] = 1;
- }
- }
- else {
+ if ($name != 'onbehalf' || $name != 'honor') {
$fields[$name] = 1;
}
}
$contact = $this->_params = $this->controller->exportValues('Main');
foreach ($fields as $name => $dontCare) {
- if ($name == 'onbehalf') {
- foreach ($dontCare as $key => $value) {
- //$defaults[$key] = $contact['onbehalf'][$key];
- if (isset($contact['onbehalf'][$key])) {
- $defaults[$key] = $contact['onbehalf'][$key];
- }
- if (isset($contact['onbehalf']["{$key}_id"])) {
- $defaults["{$key}_id"] = $contact['onbehalf']["{$key}_id"];
- }
-
- }
- }
- elseif (isset($contact[$name])) {
+ if (isset($contact[$name])) {
$defaults[$name] = $contact[$name];
if (substr($name, 0, 7) == 'custom_') {
$timeField = "{$name}_time";
* @return void
* @access public
*/
- function buildCustom($id, $name, $viewOnly = FALSE, $onBehalf = FALSE, $fieldTypes = NULL) {
+ function buildCustom($id, $name, $viewOnly = FALSE, $profileContactType = NULL, $fieldTypes = NULL) {
$stateCountryMap = array();
if ($id) {
$stateCountryMap[$index][$prefixName] = $key;
if ($prefixName == "state_province") {
- if ($onBehalf) {
+ if ($profileContactType == 'onbehalf') {
//CRM-11881: Bypass required-ness check for state/province on Contribution Confirm page
//as already done during Contribution registration via onBehalf's quickForm
$field['is_required'] = FALSE;
}
}
- if ($onBehalf) {
+ if ($profileContactType) {
+ //Since we are showing honoree name separately so we are removing it from honoree profile just for display
+ $honoreeNamefields = array('prefix_id', 'first_name', 'last_name', 'suffix_id', 'organization_name', 'household_name');
+ if ($profileContactType == 'honor' && in_array($field['name'], $honoreeNamefields)) {
+ unset($fields[$field['name']]);
+ continue;
+ }
if (!empty($fieldTypes) && in_array($field['field_type'], $fieldTypes)) {
CRM_Core_BAO_UFGroup::buildProfile(
$this,
$field,
CRM_Profile_Form::MODE_CREATE,
$contactID,
- TRUE
+ TRUE,
+ $profileContactType
);
- $this->_fields['onbehalf'][$key] = $field;
+ $this->_fields[$profileContactType][$key] = $field;
}
else {
unset($fields[$key]);
}
// Preload libraries required by the "Profiles" tab
- $schemas = array('IndividualModel', 'ContributionModel');
+ $schemas = array('IndividualModel', 'OrganizationModel', 'ContributionModel');
if (in_array('CiviMember', CRM_Core_Config::singleton()->enableComponents)) {
$schemas[] = 'MembershipModel';
}
$this->freeze();
$this->addElement('button', 'done', ts('Done'), array('onclick' => "location.href='civicrm/admin/custom/group?reset=1&action=browse'"));
}
-
+
// don't show option for contribution amounts section if membership price set
// this flag is sent to template
-
+
$membershipBlock = new CRM_Member_DAO_MembershipBlock();
$membershipBlock->entity_table = 'civicrm_contribution_page';
$membershipBlock->entity_id = $this->_id;
$membershipBlock->is_active = 1;
$hasMembershipBlk = FALSE;
- if ($membershipBlock->find(TRUE) &&
+ if ($membershipBlock->find(TRUE) &&
($setID = CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $this->_id, NULL, 1))
) {
$extends = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $setID, 'extends');
// get the first one only
$defaults['onbehalf_profile_id'] = $onBehalfIDs[0];
}
+
+ $ufJoinDAO = new CRM_Core_DAO_UFJoin();
+ $ufJoinDAO->module = 'soft_credit';
+ $ufJoinDAO->entity_id = $this->_id;
+ if ($ufJoinDAO->find(TRUE)) {
+ $defaults['honoree_profile'] = $ufJoinDAO->uf_group_id;
+ $jsonData = json_decode($ufJoinDAO->module_data);
+ if ($jsonData) {
+ foreach ($jsonData->soft_credit as $index => $value){
+ $defaults[$index] = $value;
+ }
+ }
+ }
}
else {
CRM_Utils_System::setTitle(ts('Title and Settings'));
}
+ if (!CRM_Utils_Array::value('soft_credit_types', $defaults)) {
+ $defaults['soft_credit_types'] = array(1, 2);
+ }
+
return $defaults;
}
// should the honor be enabled
$this->addElement('checkbox', 'honor_block_is_active', ts('Honoree Section Enabled'), NULL, array('onclick' => "showHonor()"));
- $this->add('text', 'honor_block_title', ts('Honoree Section Title'), $attributes['honor_block_title']);
+ $this->add('text', 'honor_block_title', ts('Honoree Section Title'), array('maxlength' => 255, 'size' => 45));
- $this->add('textarea', 'honor_block_text', ts('Honoree Introductory Message'), $attributes['honor_block_text']);
+ $this->add('textarea', 'honor_block_text', ts('Honoree Introductory Message'), array('rows' => 2, 'cols' => 50));
+
+ $softCreditTypes = &$this->add('select', 'soft_credit_types',
+ ts('Honor Types'),
+ CRM_Core_OptionGroup::values("soft_credit_type", FALSE),
+ FALSE,
+ array(
+ 'id' => 'soft_credit_types',
+ 'multiple' => 'multiple',
+ 'title' => '- ' . ts('select') . ' -',
+ )
+ );
+
+ $entities = array();
+ $entities[] = array('entity_name' => 'contact_1', 'entity_type' => 'IndividualModel');
+ //$entities[] = array('entity_name' => 'contact_1', 'entity_type' => 'OrganizationModel');
+ $allowCoreTypes = array_merge(array('Contact', 'Individual', 'Organization', 'Household'), CRM_Contact_BAO_ContactType::subTypes('Individual'));
+ $allowSubTypes = array();
+
+ $this->addProfileSelector('honoree_profile', ts('Honoree Profile'), $allowCoreTypes, $allowSubTypes, $entities);
+
+ if (CRM_Utils_Array::value('honor_block_is_active', $this->_submitValues)) {
+ $this->addRule('soft_credit_types', ts('At least one value must be selected if Honor Section is active'), 'required');
+ $this->addRule('honoree_profile', ts('Please select a profile used for honoree'), 'required');
+ }
// add optional start and end dates
$this->addDateTime('start_date', ts('Start Date'));
if (($end < $start) && ($end != 0)) {
$errors['end_date'] = ts('End date should be after Start date.');
}
-
- if (CRM_Utils_Array::value('payment_processor', $self->_values)
+
+ if (CRM_Utils_Array::value('payment_processor', $self->_values)
&& $financialType = CRM_Contribute_BAO_Contribution::validateFinancialType($values['financial_type_id'])) {
- $errors['financial_type_id'] = ts("Financial Account of account relationship of 'Expense Account is' is not configured for Financial Type : ") . $financialType;
+ $errors['financial_type_id'] = ts("Financial Account of account relationship of 'Expense Account is' is not configured for Financial Type : ") . $financialType;
}
-
+
//dont allow on behalf of save when
//pre or post profile consists of membership fields
if ($contributionPageId && CRM_Utils_Array::value('is_organization', $values)) {
$conProfileType = "'Includes Profile (top of page)'";
}
}
-
+
if ($contributionProfiles['custom_post_id']) {
$postProfileType = CRM_Core_BAO_UFField::getProfileType($contributionProfiles['custom_post_id']);
if ($postProfileType == 'Membership') {
$params['honor_block_title'] = NULL;
$params['honor_block_text'] = NULL;
}
+ else {
+ $sctJSON = json_encode(array(
+ 'soft_credit' => array(
+ 'soft_credit_types' => $params['soft_credit_types'],
+ 'honor_block_title' => $params['honor_block_title'],
+ 'honor_block_text' => $params['honor_block_text']
+ )
+ )
+ );
+ }
$dao = CRM_Contribute_BAO_ContributionPage::create($params);
- // make entry in UF join table for onbehalf of org profile
$ufJoinParams = array(
- 'is_active' => 1,
- 'module' => 'OnBehalf',
- 'entity_table' => 'civicrm_contribution_page',
- 'entity_id' => $dao->id,
+ 'onbehalf_profile_id' =>
+ array(
+ 'is_active' => 1,
+ 'module' => 'OnBehalf',
+ 'entity_table' => 'civicrm_contribution_page',
+ 'entity_id' => $dao->id,
+ ),
+ 'honor_block_is_active' =>
+ array(
+ 'module' => 'soft_credit',
+ 'entity_table' => 'civicrm_contribution_page',
+ 'entity_id' => $dao->id,
+ )
);
- // first delete all past entries
- CRM_Core_BAO_UFJoin::deleteAll($ufJoinParams);
- if (CRM_Utils_Array::value('onbehalf_profile_id', $params)) {
- $ufJoinParams['weight'] = 1;
- $ufJoinParams['uf_group_id'] = $params['onbehalf_profile_id'];
- CRM_Core_BAO_UFJoin::create($ufJoinParams);
+ foreach ($ufJoinParams as $index => $ufJoinParam) {
+ if (CRM_Utils_Array::value($index, $params)) {
+ $ufJoinParam['weight'] = 1;
+ if ($index == 'honor_block_is_active') {
+ $ufJoinParam['is_active'] = 1;
+ $ufJoinParam['uf_group_id'] = $params['honoree_profile'];
+ $ufJoinParam['module_data'] = $sctJSON;
+ }
+ else {
+ // first delete all past entries
+ CRM_Core_BAO_UFJoin::deleteAll($ufJoinParam);
+ $ufJoinParam['uf_group_id'] = $params[$index];
+ }
+ CRM_Core_BAO_UFJoin::create($ufJoinParam);
+ }
+ elseif ($index == 'honor_block_is_active') {
+ //On subsequent honor_block_is_active uncheck, disable(don't delete)
+ //that particular honoree profile entry in UFjoin table, CRM-13981
+ $ufId = CRM_Core_BAO_UFJoin::findJoinEntryId($ufJoinParam);
+ if ($ufId) {
+ $ufJoinParam['uf_group_id'] = CRM_Core_BAO_UFJoin::findUFGroupId($ufJoinParam);
+ $ufJoinParam['is_active'] = 0;
+ CRM_Core_BAO_UFJoin::create($ufJoinParam);
+ }
+ }
}
$this->set('id', $dao->id);
* @return void
*/
static function buildQuickForm(&$form) {
+ if ($form->_mode == 'live' && CRM_Utils_Array::value('honor_block_is_active', $form->_values)) {
+ $ufJoinDAO = new CRM_Core_DAO_UFJoin();
+ $ufJoinDAO->module = 'soft_credit';
+ $ufJoinDAO->entity_id = $form->_id;
+ if ($ufJoinDAO->find(TRUE)) {
+ $jsonData = json_decode($ufJoinDAO->module_data);
+ if ($jsonData) {
+ $form->assign('honor_block_title', $jsonData->soft_credit->honor_block_title);
+ $form->assign('honor_block_text', $jsonData->soft_credit->honor_block_text);
+
+ $softCreditTypes = CRM_Core_OptionGroup::values("soft_credit_type", FALSE);
+ $extraOption = array('onclick' => "enableHonorType();");
+
+ // radio button for Honor Type
+ foreach ($jsonData->soft_credit->soft_credit_types as $value) {
+ $honorTypes[$value] = $form->createElement('radio', NULL, NULL, $softCreditTypes[$value], $value, $extraOption);
+ }
+ $form->addGroup($honorTypes, 'soft_credit_type_id', NULL);
+ }
+ }
+ return $form;
+ }
+
$prefix = 'soft_credit_';
// by default generate 5 blocks
$item_count = 6;
$showCreateNew = TRUE;
if ($form->_action & CRM_Core_Action::UPDATE) {
$form->_softCreditInfo = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($form->_id, TRUE);
+ }
+ elseif ($form->_pledgeID) {
+ //Check and select most recent completed contrubtion and use it to retrieve
+ //soft-credit information to use as default for current pledge payment, CRM-13981
+ $pledgePayments = CRM_Pledge_BAO_PledgePayment::getPledgePayments($form->_pledgeID);
+ foreach ($pledgePayments as $id => $record) {
+ if ($record['contribution_id']) {
+ $softCredits = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($record['contribution_id'], TRUE);
+ if ($record['status'] == 'Completed' && count($softCredits) > 0) {
+ $form->_softCreditInfo = $softCredits;
+ }
+ }
+ }
+ }
+
+ if (property_exists($form, "_softCreditInfo")) {
if (!empty($form->_softCreditInfo['soft_credit'])) {
$showSoftCreditRow = count($form->_softCreditInfo['soft_credit']);
$showSoftCreditRow++;
$defaults["soft_credit_type[$key]"] = $value['soft_credit_type'];
}
}
-
elseif (CRM_Utils_Array::value('pcp_id', $form->_softCreditInfo)) {
$pcpInfo = $form->_softCreditInfo;
$pcpId = CRM_Utils_Array::value('pcp_id', $pcpInfo);
* @params array $field array field properties
* @params int $mode profile mode
* @params int $contactID contact id
+ * @params string $usedFor for building up prefixed fieldname for special cases (e.g. onBehalf, Honor)
*
* @return null
* @static
$mode,
$contactId = NULL,
$online = FALSE,
- $onBehalf = FALSE,
+ $usedFor = NULL,
$rowNumber = NULL ,
$prefix = ''
) {
return;
}
- if ($onBehalf) {
+ if ($usedFor == 'onbehalf') {
$name = "onbehalf[$fieldName]";
}
+ elseif ($usedFor == 'honor') {
+ $name = "honor[$fieldName]";
+ }
elseif ($contactId && !$online) {
$name = "field[$contactId][$fieldName]";
}
elseif (substr($fieldName, 0, 2) === 'im') {
$form->add('text', $name, $title, $attributes, $required);
if (!$contactId) {
- if ($onBehalf) {
+ if ($usedFor) {
if (substr($name, -1) == ']') {
$providerName = substr($name, 0, -1) . '-provider_id]';
}
}
elseif ($fieldName === 'contact_sub_type') {
$gId = $form->get('gid') ? $form->get('gid') : CRM_Utils_Array::value('group_id', $field);
- if ($onBehalf) {
+ if ($usedFor == 'onbehalf') {
$profileType = 'Organization';
}
+ elseif ($usedFor == 'honor') {
+ $profileType = CRM_Core_BAO_UFField::getProfileType($form->_params['honoree_profile_id']);
+ }
else {
$profileType = $gId ? CRM_Core_BAO_UFField::getProfileType($gId) : NULL;
if ($profileType == 'Contact') {
$form->addRule($name, ts('Enter a valid Website.'), 'url');
//Website type select
- if ($onBehalf) {
+ if ($usedFor) {
if (substr($name, -1) == ']') {
$websiteTypeName = substr($name, 0, -1) . '-website_type_id]';
}
// lets always add the hidden
//subtype value if there is any, and we won't have to
// compute it while processing.
- if ($onBehalf) {
- $form->addElement('hidden', 'onbehalf[contact_sub_type]', $field['field_type']);
+ if ($usedFor) {
+ $form->addElement('hidden', $usedFor . '[contact_sub_type]', $field['field_type']);
}
else {
$form->addElement('hidden', 'contact_sub_type_hidden', $field['field_type']);
$recordContribution = array(
'contact_id', 'total_amount', 'receive_date', 'financial_type_id',
'payment_instrument_id', 'trxn_id', 'invoice_id', 'is_test',
- 'honor_contact_id', 'honor_type_id',
'contribution_status_id', 'check_number', 'campaign_id', 'is_pay_later',
);
foreach ($recordContribution as $f) {
}
}
}
-
+
if (CRM_Utils_Array::value('record_contribution', $defaults) && !$this->_mode) {
$contributionParams = array('id' => $defaults['record_contribution']);
$contributionIds = array();
//CRM-10223 - allow contribution to be recorded against different contact
// causes a conflict in standalone mode so skip in standalone for now
$this->addElement('checkbox', 'is_different_contribution_contact', ts('Record Payment from a Different Contact?'));
- $this->add('select', 'honor_type_id', ts('Membership payment is : '),
- array('' => ts('-')) + CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'honor_type_id'));
+ $this->add('select', 'soft_credit_type_id', ts('Membership payment is : '),
+ array('' => ts('- Select - ')) + CRM_Core_OptionGroup::values("soft_credit_type", FALSE));
CRM_Contact_Form_NewContact::buildQuickForm($this, 1, NULL, FALSE, 'contribution_');
}
if (!$priceSetId && $self->_mode && !CRM_Utils_Array::value('financial_type_id', $params)) {
$errors['financial_type_id'] = ts('Please enter the financial Type.');
}
-
+
if (CRM_Utils_Array::value('record_contribution', $params) && !CRM_Utils_Array::value('payment_instrument_id', $params)) {
$errors['payment_instrument_id'] = ts('Paid By is a required field.');
}
+ if (CRM_Utils_Array::value('is_different_contribution_contact', $params)) {
+ if (!CRM_Utils_Array::value('soft_credit_type_id', $params)) {
+ $errors['soft_credit_type_id'] = ts('Please Select a Soft Credit Type');
+ }
+ if (!CRM_Utils_Array::value(1, $params['contribution_contact'])) {
+ $errors['contribution_contact[1]'] = ts('Please select a contact');
+ }
+ }
+
if (CRM_Utils_Array::value('payment_processor_id', $params)) {
// make sure that credit card number and cvv are valid
CRM_Core_Payment_Form::validateCreditCard($params, $errors);
$this->_params = $formValues = $this->controller->exportValues($this->_name);
$this->convertDateFieldsToMySQL($formValues);
- $params = $ids = array();
+ $params = $softParams = $ids = array();
$membershipTypeValues = array();
foreach ($this->_memTypeSelected as $memType) {
//CRM-10223 - allow contribution to be recorded against different contact
if ($this->_contributorContactID != $this->_contactID) {
$params['contribution_contact_id'] = $this->_contributorContactID;
- if (CRM_Utils_Array::value('honor_type_id', $this->_params)) {
- $params['honor_type_id'] = $this->_params['honor_type_id'];
- $params['honor_contact_id'] = $params['contact_id'];
+ if (CRM_Utils_Array::value('soft_credit_type_id', $this->_params)) {
+ $softParams['soft_credit_type_id'] = $this->_params['soft_credit_type_id'];
+ $softParams['contact_id'] = $params['contact_id'];
}
}
if (CRM_Utils_Array::value('record_contribution', $formValues)) {
$recordContribution = array(
'total_amount',
- 'honor_type_id',
'financial_type_id',
'payment_instrument_id',
'trxn_id',
//CRM-10377 if payment is by an alternate contact then we need to set that person
// as the contact in the payment params
if ($this->_contributorContactID != $this->_contactID) {
- if (CRM_Utils_Array::value('honor_type_id', $this->_params)) {
- $paymentParams['honor_contact_id'] = $this->_contactID;
- $paymentParams['honor_type_id'] = $this->_params['honor_type_id'];
+ if (CRM_Utils_Array::value('soft_credit_type_id', $this->_params)) {
+ $softParams['contact_id'] = $params['contact_id'];
+ $softParams['soft_credit_type_id'] = $this->_params['soft_credit_type_id'];
}
}
if (CRM_Utils_Array::value('send_receipt', $this->_params)) {
TRUE,
FALSE
);
+
+ //create new soft-credit record, CRM-13981
+ $softParams['contribution_id'] = $contribution->id;
+ $softParams['currency'] = $contribution->currency;
+ $softParams['amount'] = $contribution->total_amount;
+ CRM_Contribute_BAO_ContributionSoft::add($softParams);
+
$paymentParams['contactID'] = $contactID;
$paymentParams['contributionID'] = $contribution->id;
$paymentParams['contributionTypeID'] = $contribution->financial_type_id;
$lineItems[$itemId]['id'] = $itemId;
$lineItem[$priceSetId] = $lineItems;
CRM_Price_BAO_LineItem::processPriceSet($params['contribution_id'], $lineItem);
+
+ //create new soft-credit record, CRM-13981
+ $softParams['contribution_id'] = $params['contribution_id'];
+ $dao = new CRM_Contribute_DAO_Contribution();
+ $dao->id = $params['contribution_id'];
+ $dao->find();
+ while ($dao->fetch()) {
+ $softParams['currency'] = $dao->currency;
+ $softParams['amount'] = $dao->total_amount;
+ }
+ CRM_Contribute_BAO_ContributionSoft::add($softParams);
}
//carry updated membership object.
}
$defaults['financial_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'financial_type_id');
-
+
//CRM-13420
if (!CRM_Utils_Array::value('payment_instrument_id', $defaults)) {
$defaults['payment_instrument_id'] = key(CRM_Core_OptionGroup::values('payment_instrument', FALSE, FALSE, FALSE, 'AND is_default = 1'));
//CRM-10223 - allow contribution to be recorded against different contact
// causes a conflict in standalone mode so skip in standalone for now
$this->addElement('checkbox', 'contribution_contact', ts('Record Payment from a Different Contact?'));
- $this->add( 'select', 'honor_type_id', ts('Membership payment is : '),
- array( '' => ts( '-') ) + CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'honor_type_id') );
+ $this->add('select', 'soft_credit_type_id', ts('Membership payment is : '),
+ array('' => ts('- Select - ')) + CRM_Core_OptionGroup::values("soft_credit_type", FALSE));
require_once 'CRM/Contact/Form/NewContact.php';
CRM_Contact_Form_NewContact::buildQuickForm($this,1, null, false,'contribution_');
}
//assign contribution contact id to the field expected by recordMembershipContribution
if($this->_contributorContactID != $this->_contactID){
$formValues['contribution_contact_id'] = $this->_contributorContactID;
- if(CRM_Utils_Array::value('honor_type_id', $this->_params)){
- $formValues['honor_contact_id'] = $this->_contactID;
+ if(CRM_Utils_Array::value('soft_credit_type_id', $this->_params)){
+ $formValues['soft_credit'][] = array(
+ 'soft_credit_type_id' => $this->_params['soft_credit_type_id'],
+ 'contact_id' => $this->_contactID,
+ 'amount' => $formValues['total_amount'],
+ );
}
}
$formValues['contact_id'] = $this->_contactID;
*/
public $_values;
- /**
- * stores the honor id
- *
- * @var int
- * @public
- */
- public $_honorID = NULL;
-
/**
* The Pledge frequency Units
* @public
$params = array('id' => $this->_id);
CRM_Pledge_BAO_Pledge::getValues($params, $this->_values);
- //get the honorID
- $this->_honorID = CRM_Utils_Array::value('honor_contact_id', $this->_values);
-
$paymentStatusTypes = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
//check for pending pledge.
$defaultPledgeStatus
));
- //honoree contact.
- if ($this->_honorID) {
- $honorDefault = array();
- $idParams = array('contact_id' => $this->_honorID);
- CRM_Contact_BAO_Contact::retrieve($idParams, $honorDefault);
- $honorType = CRM_Core_PseudoConstant::get('CRM_Pledge_DAO_Pledge', 'honor_type_id');
- $defaults['honor_prefix_id'] = $honorDefault['prefix_id'];
- $defaults['honor_first_name'] = CRM_Utils_Array::value('first_name', $honorDefault);
- $defaults['honor_last_name'] = CRM_Utils_Array::value('last_name', $honorDefault);
- $defaults['honor_email'] = CRM_Utils_Array::value('email', $honorDefault['email'][1]);
- $defaults['honor_type'] = $honorType[$defaults['honor_type_id']];
- }
-
if (isset($this->userEmail)) {
$this->assign('email', $this->userEmail);
}
$showAdditionalInfo = FALSE;
$this->_formType = CRM_Utils_Array::value('formType', $_GET);
- //fix to load honoree pane on edit.
$defaults = array();
- if ($this->_honorID) {
- $defaults['hidden_Honoree'] = 1;
- }
$paneNames = array(
- 'Honoree Information' => 'Honoree',
'Payment Reminders' => 'PaymentReminders',
);
foreach ($paneNames as $name => $type) {
$errors['contact[1]'] = ts('Please select a contact or create new contact');
}
- if (isset($fields['honor_type_id'])) {
- if (!((CRM_Utils_Array::value('honor_first_name', $fields) &&
- CRM_Utils_Array::value('honor_last_name', $fields)
- ) ||
- CRM_Utils_Array::value('honor_email', $fields)
- )) {
- $errors['honor_first_name'] = ts('Honor First Name and Last Name OR an email should be set.');
- }
- }
if ($fields['amount'] <= 0) {
$errors['amount'] = ts('Total Pledge Amount should be greater than zero.');
}
'initial_reminder_day',
'max_reminders',
'additional_reminder_day',
- 'honor_type_id',
- 'honor_prefix_id',
- 'honor_first_name',
- 'honor_last_name',
- 'honor_email',
'contribution_page_id',
'campaign_id',
);
$params['contact_id'] = $this->_contactID;
- //handle Honoree contact.
- if (CRM_Utils_Array::value('honor_type_id', $params)) {
- if ($this->_honorID) {
- $honorID = CRM_Contribute_BAO_Contribution::createHonorContact($params, $this->_honorID);
- }
- else {
- $honorID = CRM_Contribute_BAO_Contribution::createHonorContact($params);
- }
- $params['honor_contact_id'] = $honorID;
- }
- else {
- $params['honor_contact_id'] = 'null';
- }
-
//format custom data
if (CRM_Utils_Array::value('hidden_custom', $formValues)) {
$params['hidden_custom'] = 1;
protected $_addressField = FALSE;
protected $_emailField = FALSE;
- protected $_emailFieldHonor = FALSE;
-
- protected $_nameFieldHonor = FALSE;
protected $_summary = NULL;
protected $_allBatches = NULL;
),
'grouping' => 'contact-fields',
),
- 'civicrm_contact_honor' =>
- array(
- 'dao' => 'CRM_Contact_DAO_Contact',
- 'fields' =>
- array(
- 'sort_name_honor' =>
- array('title' => ts('Honoree Name'),
- 'name' => 'sort_name',
- 'alias' => 'contacthonor',
- 'default' => FALSE,
- ),
- 'id_honor' =>
- array(
- 'no_display' => TRUE,
- 'title' => ts('Honoree ID'),
- 'name' => 'id',
- 'alias' => 'contacthonor',
- 'required' => TRUE,
- ),
- ),
- ),
- 'civicrm_email_honor' =>
- array(
- 'dao' => 'CRM_Core_DAO_Email',
- 'fields' =>
- array(
- 'email_honor' =>
- array('title' => ts('Honoree Email'),
- 'name' => 'email',
- 'alias' => 'emailhonor',
- 'default' => FALSE,
- ),
- ),
- 'grouping' => 'contact-fields',
- ),
'civicrm_contribution' =>
array(
'dao' => 'CRM_Contribute_DAO_Contribution',
'trxn_id' => NULL,
'receive_date' => array('default' => TRUE),
'receipt_date' => NULL,
- 'honor_type_id' => array('title' => ts('Honor Type'),
- 'default' => FALSE,
- ),
'fee_amount' => NULL,
'net_amount' => NULL,
'total_amount' => array('title' => ts('Amount'),
function select() {
$this->_columnHeaders = array();
- foreach ($this->_columns as $tableName => $table) {
- if (array_key_exists('fields', $table)) {
- foreach ($table['fields'] as $fieldName => $field) {
- if (CRM_Utils_Array::value('required', $field) ||
- CRM_Utils_Array::value($fieldName, $this->_params['fields'])
- ) {
- if ($tableName == 'civicrm_email_honor') {
- $this->_emailFieldHonor = TRUE;
- }
- if ($tableName == 'civicrm_contact_honor') {
- $this->_nameFieldHonor = TRUE;
- }
- }
- }
- }
- }
parent::select();
}
ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_email']}.contact_id AND
{$this->_aliases['civicrm_email']}.is_primary = 1\n";
}
-
- // include Honor name field
- if ($this->_nameFieldHonor) {
- $this->_from .= "
- LEFT JOIN civicrm_contact contacthonor
- ON contacthonor.id = {$this->_aliases['civicrm_contribution']}.honor_contact_id";
- }
- // include Honor email field
- if ($this->_emailFieldHonor) {
- $this->_from .= "
- LEFT JOIN civicrm_email emailhonor
- ON emailhonor.contact_id = {$this->_aliases['civicrm_contribution']}.honor_contact_id
- AND emailhonor.is_primary = 1\n";
- }
// include contribution note
if (CRM_Utils_Array::value('contribution_note', $this->_params['fields']) ||
CRM_Utils_Array::value('note_value', $this->_params)) {
$contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus();
$paymentInstruments = CRM_Contribute_PseudoConstant::paymentInstrument();
$contributionPages = CRM_Contribute_PseudoConstant::contributionPage();
- $honorTypes = CRM_Core_OptionGroup::values('honor_type', FALSE, FALSE, FALSE, NULL, 'label');
-
foreach ($rows as $rowNum => $row) {
if (!empty($this->_noRepeats) && $this->_outputMode != 'csv') {
$rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts("View Contact Summary for this Contact.");
}
- // convert honoree sort name to link
- if (array_key_exists('civicrm_contact_honor_sort_name_honor', $row) &&
- CRM_Utils_Array::value('civicrm_contact_honor_sort_name_honor', $rows[$rowNum]) &&
- array_key_exists('civicrm_contact_honor_id_honor', $row)
- ) {
-
- $url = CRM_Utils_System::url("civicrm/contact/view",
- 'reset=1&cid=' . $row['civicrm_contact_honor_id_honor'],
- $this->_absoluteUrl
- );
- $rows[$rowNum]['civicrm_contact_honor_sort_name_honor_link'] = $url;
- $rows[$rowNum]['civicrm_contact_honor_sort_name_honor_hover'] = ts("View Contact Summary for Honoree.");
- }
-
if ($value = CRM_Utils_Array::value('civicrm_contribution_financial_type_id', $row)) {
$rows[$rowNum]['civicrm_contribution_financial_type_id'] = $contributionTypes[$value];
$entryFound = TRUE;
$rows[$rowNum]['civicrm_contribution_payment_instrument_id'] = $paymentInstruments[$value];
$entryFound = TRUE;
}
- if ($value = CRM_Utils_Array::value('civicrm_contribution_honor_type_id', $row)) {
- $rows[$rowNum]['civicrm_contribution_honor_type_id'] = $honorTypes[$value];
- $entryFound = TRUE;
- }
if (array_key_exists('civicrm_batch_batch_id', $row)) {
if ($value = $row['civicrm_batch_batch_id']) {
$rows[$rowNum]['civicrm_batch_batch_id'] = CRM_Core_DAO::getFieldValue('CRM_Batch_DAO_Batch', $value, 'title');
protected $_addressField = FALSE;
protected $_emailField = FALSE;
- protected $_emailFieldHonor = FALSE;
-
- protected $_nameFieldHonor = FALSE;
protected $_summary = NULL;
protected $_allBatches = NULL;
),
'grouping' => 'contact-fields',
),
- 'civicrm_contact_honor' =>
- array(
- 'dao' => 'CRM_Contact_DAO_Contact',
- 'fields' =>
- array(
- 'sort_name_honor' =>
- array('title' => ts('Honoree Name'),
- 'name' => 'sort_name',
- 'alias' => 'contacthonor',
- 'default' => FALSE,
- 'no_repeat' => TRUE,
- ),
- 'id_honor' =>
- array(
- 'no_display' => TRUE,
- 'title' => ts('Honoree ID'),
- 'name' => 'id',
- 'alias' => 'contacthonor',
- 'required' => TRUE,
- ),
- ),
- ),
- 'civicrm_email_honor' =>
- array(
- 'dao' => 'CRM_Core_DAO_Email',
- 'fields' =>
- array(
- 'email_honor' =>
- array('title' => ts('Honoree Email'),
- 'name' => 'email',
- 'alias' => 'emailhonor',
- 'default' => FALSE,
- 'no_repeat' => TRUE,
- ),
- ),
- 'grouping' => 'contact-fields',
- ),
'first_donation' => array(
'dao' => 'CRM_Contribute_DAO_Contribution',
'fields' =>
'trxn_id' => NULL,
'receive_date' => array('default' => TRUE),
'receipt_date' => NULL,
- 'honor_type_id' => array('title' => ts('Honor Type'),
- 'default' => FALSE,
- ),
'fee_amount' => NULL,
'net_amount' => NULL,
'total_amount' => array('title' => ts('Amount'),
if ($tableName == 'civicrm_email') {
$this->_emailField = TRUE;
}
- elseif ($tableName == 'civicrm_email_honor') {
- $this->_emailFieldHonor = TRUE;
- }
-
- if ($tableName == 'civicrm_contact_honor') {
- $this->_nameFieldHonor = TRUE;
- }
// only include statistics columns if set
if (CRM_Utils_Array::value('statistics', $field)) {
ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_email']}.contact_id AND
{$this->_aliases['civicrm_email']}.is_primary = 1\n";
}
-
- // include Honor name field
- if ($this->_nameFieldHonor) {
- $this->_from .= "
- LEFT JOIN civicrm_contact contacthonor
- ON contacthonor.id = {$this->_aliases['civicrm_contribution']}.honor_contact_id";
- }
-
- // include Honor email field
- if ($this->_emailFieldHonor) {
- $this->_from .= "
- LEFT JOIN civicrm_email emailhonor
- ON emailhonor.contact_id = {$this->_aliases['civicrm_contribution']}.honor_contact_id
- AND emailhonor.is_primary = 1\n";
- }
}
function tempTable($applyLimit = TRUE) {
$contributionTypes = CRM_Contribute_PseudoConstant::financialType();
$contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus();
$paymentInstruments = CRM_Contribute_PseudoConstant::paymentInstrument();
- $honorTypes = CRM_Core_OptionGroup::values('honor_type', FALSE, FALSE, FALSE, NULL, 'label');
//altering the csv display adding additional fields
if ($this->_outputMode == 'csv') {
$rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts('View Contact Summary for this Contact.');
}
- // convert honoree sort name to link
- if (array_key_exists('civicrm_contact_honor_sort_name_honor', $row) &&
- CRM_Utils_Array::value('civicrm_contact_honor_sort_name_honor', $rows[$rowNum]) &&
- array_key_exists('civicrm_contact_honor_id_honor', $row)
- ) {
-
- $url = CRM_Utils_System::url('civicrm/contact/view',
- 'reset=1&cid=' . $row['civicrm_contact_honor_id_honor'],
- $this->_absoluteUrl
- );
- $rows[$rowNum]['civicrm_contact_honor_sort_name_honor_link'] = $url;
- $rows[$rowNum]['civicrm_contact_honor_sort_name_honor_hover'] = ts('View Contact Summary for Honoree.');
- }
-
if ($value = CRM_Utils_Array::value('civicrm_contribution_financial_type_id', $row)) {
$rows[$rowNum]['civicrm_contribution_financial_type_id'] = $contributionTypes[$value];
$entryFound = TRUE;
$rows[$rowNum]['civicrm_contribution_payment_instrument_id'] = $paymentInstruments[$value];
$entryFound = TRUE;
}
- if ($value = CRM_Utils_Array::value('civicrm_contribution_honor_type_id', $row)) {
- $rows[$rowNum]['civicrm_contribution_honor_type_id'] = $honorTypes[$value];
- $entryFound = TRUE;
- }
if (($value = CRM_Utils_Array::value('civicrm_contribution_total_amount_sum', $row)) &&
CRM_Core_Permission::check('access CiviContribute')
) {
* @param array $entityTypes strings, e.g. "IndividualModel", "ActivityModel"
*/
static function registerSchemas($entityTypes) {
+ /* CRM_Core_Error::backtrace(); */
+ /* CRM_Core_Error::debug( '$entityTypes', $entityTypes ); */
// TODO in cases where registerSchemas is called multiple times for same entity, be more efficient
CRM_Core_Resources::singleton()->addSettingsFactory(function () use ($entityTypes) {
return array(
$availableFields
);
break;
+ case 'OrganizationModel':
+ $civiSchema[$entityType] = self::convertCiviModelToBackboneModel(
+ 'Organization',
+ ts('Organization'),
+ $availableFields
+ );
case 'ActivityModel':
$civiSchema[$entityType] = self::convertCiviModelToBackboneModel(
'Activity',
ALTER TABLE civicrm_action_schedule ADD sms_provider_id int(10) unsigned NULL COMMENT 'FK to civicrm_sms_provider id ';
ALTER TABLE civicrm_action_schedule ADD CONSTRAINT FK_civicrm_action_schedule_sms_provider_id FOREIGN KEY (`sms_provider_id`) REFERENCES `civicrm_sms_provider` (`id`) ON DELETE SET NULL;
+
+--CRM-13981 migrate 'In Honor of' to Soft Credits
+INSERT INTO `civicrm_uf_group`
+ (`name`, `group_type`, {localize field='title'}`title`{/localize}, `is_cms_user`, `is_reserved`)
+VALUES
+ ('honoree_individual', 'Individual, Contact', {localize}'{ts escape="sql"}Honoree Individual{/ts}'{/localize}, 0, 1);
+
+SELECT @uf_group_id_honoree_individual := max(id) from civicrm_uf_group where name = 'honoree_individual';
+
+INSERT INTO `civicrm_uf_field`
+ (`uf_group_id`, `field_name`, `is_required`, `is_reserved`, `weight`, `visibility`, `in_selector`, `is_searchable`, {localize field='label'}`label`{/localize}, field_type)
+VALUES
+ (@uf_group_id_honoree_individual, 'honor_prefix_id', 0, 1, 1, 'User and User Admin Only', 0, 1, '{ts escape="sql"}Individual Prefix{/ts}', 'Individual'),
+ (@uf_group_id_honoree_individual, 'honor_first_name', 0, 1, 2, 'User and User Admin Only', 0, 1, '{ts escape="sql"}First Name{/ts}', 'Individual'),
+ (@uf_group_id_honoree_individual, 'honor_last_name', 0, 1, 3, 'User and User Admin Only', 0, 1, '{ts escape="sql"}Last Name{/ts}', 'Individual');
+
+ALTER TABLE `civicrm_uf_join`
+ ADD COLUMN `module_data` varchar(255) COMMENT 'Json serialized array of data used by the ufjoin.module';
+
+{if $multilingual}
+ {foreach from=$locales item=loc}
+ ALTER TABLE civicrm_contribution_page DROP honor_block_title_{$loc};
+ ALTER TABLE civicrm_contribution_page DROP honor_block_text_{$loc};
+ {/foreach}
+{else}
+ ALTER TABLE civicrm_contribution_page DROP honor_block_title;
+ ALTER TABLE civicrm_contribution_page DROP honor_block_text;
+{/if}
+
+ALTER TABLE civicrm_contribution DROP honor_contact_id;
+ALTER TABLE civicrm_contribution DROP honor_type_id;
+
+ALTER TABLE civicrm_pledge DROP honor_contact_id;
+ALTER TABLE civicrm_pledge DROP honor_type_id;
private function addPledge() {
$pledge = "INSERT INTO civicrm_pledge
- (contact_id, financial_type_id, contribution_page_id, amount, original_installment_amount, currency,frequency_unit, frequency_interval, frequency_day, installments, start_date, create_date, acknowledge_date, modified_date, cancel_date, end_date, honor_contact_id, honor_type_id, status_id, is_test)
+ (contact_id, financial_type_id, contribution_page_id, amount, original_installment_amount, currency,frequency_unit, frequency_interval, frequency_day, installments, start_date, create_date, acknowledge_date, modified_date, cancel_date, end_date, status_id, is_test)
VALUES
- (71, 1, 1, 500.00, '500', 'USD', 'month', 1, 1, 1, '2009-07-01 00:00:00', '2009-06-26 00:00:00', NULL, NULL, NULL,'2009-07-01 00:00:00', NULL, NULL, 1, 0),
- (43, 1, 1, 800.00, '200', 'USD', 'month', 3, 1, 4, '2009-07-01 00:00:00', '2009-06-23 00:00:00', '2009-06-23 00:00:00', NULL, NULL, '2009-04-01 10:11:40', NULL, NULL, 5, 0),
- (32, 1, 1, 600.00, '200', 'USD', 'month', 1, 1, 3, '2009-10-01 00:00:00', '2009-09-14 00:00:00', '2009-09-14 00:00:00', NULL, NULL, '2009-12-01 00:00:00', NULL, NULL, 5, 0);
+ (71, 1, 1, 500.00, '500', 'USD', 'month', 1, 1, 1, '2009-07-01 00:00:00', '2009-06-26 00:00:00', NULL, NULL, NULL,'2009-07-01 00:00:00', 1, 0),
+ (43, 1, 1, 800.00, '200', 'USD', 'month', 3, 1, 4, '2009-07-01 00:00:00', '2009-06-23 00:00:00', '2009-06-23 00:00:00', NULL, NULL, '2009-04-01 10:11:40', 5, 0),
+ (32, 1, 1, 600.00, '200', 'USD', 'month', 1, 1, 3, '2009-10-01 00:00:00', '2009-09-14 00:00:00', '2009-09-14 00:00:00', NULL, NULL, '2009-12-01 00:00:00', 5, 0);
";
$this->_query($pledge);
}
</div>
</div>
{/if}
- {include file="CRM/Contribute/Form/Contribution/Honor.tpl"}
+
+ {if $honor_block_is_active}
+ <div class="crm-group honor_block-group">
+ <div class="header-dark">
+ {$soft_credit_type}
+ </div>
+ <div class="display-block">
+ <div class="label-left crm-section honoree_profile-section">
+ {$honorName}</br></br>
+ {include file="CRM/UF/Form/Block.tpl" fields=$honoreeProfileFields prefix='honor'}
+ </div>
+ </div>
+ </div>
+ {/if}
{if $customPre}
<fieldset class="label-left crm-profile-view">
{if $onbehalfProfile}
<div class="crm-group onBehalf_display-group label-left crm-profile-view">
- {include file="CRM/UF/Form/Block.tpl" fields=$onbehalfProfile}
+ {include file="CRM/UF/Form/Block.tpl" fields=$onbehalfProfile prefix='onbehalf'}
<div class="crm-section organization_email-section">
<div class="label">{ts}Organization Email{/ts}</div>
<div class="content">{$onBehalfEmail}</div>
+++ /dev/null
-{*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.4 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013 |
- +--------------------------------------------------------------------+
- | 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 |
- +--------------------------------------------------------------------+
-*}
-{if $honor_block_is_active}
-<div class="crm-group honor_block-group">
- <div class="header-dark">
- {$honor_block_title}
- </div>
- <div class="display-block">
- <strong>{$honor_type} : </strong>
- {$honor_prefix} {$honor_first_name} {$honor_last_name}<br />
- <strong>Email : </strong>{$honor_email}<br />
- </div>
-</div>
-{/if}
{if $honor_block_is_active}
<fieldset class="crm-group honor_block-group">
- <legend>{$honor_block_title}</legend>
- <div class="crm-section honor_block_text-section">
- {$honor_block_text}
- </div>
- {if $form.honor_type_id.html}
- <div class="crm-section {$form.honor_type_id.name}-section">
- <div class="content" >
- {$form.honor_type_id.html}
- <span class="crm-clear-link">(<a href="#" title="unselect" onclick="unselectRadio('honor_type_id', '{$form.formName}');enableHonorType(); return false;">{ts}clear{/ts}</a>)</span>
- <div class="description">{ts}Select an option to reveal honoree information fields.{/ts}</div>
- </div>
- </div>
- {/if}
+ {include file="CRM/Contribute/Form/SoftCredit.tpl"}
<div id="honorType" class="honoree-name-email-section">
- <div class="crm-section {$form.honor_prefix_id.name}-section">
- <div class="content">{$form.honor_prefix_id.html}</div>
- </div>
- <div class="crm-section {$form.honor_first_name.name}-section">
- <div class="label">{$form.honor_first_name.label}</div>
- <div class="content">
- {$form.honor_first_name.html}
- </div>
- <div class="clear"></div>
- </div>
- <div class="crm-section {$form.honor_last_name.name}-section">
- <div class="label">{$form.honor_last_name.label}</div>
- <div class="content">
- {$form.honor_last_name.html}
- </div>
- <div class="clear"></div>
- </div>
- <div id="honorTypeEmail" class="crm-section {$form.honor_email.name}-section">
- <div class="label">{$form.honor_email.label}</div>
- <div class="content">
- {$form.honor_email.html}
- </div>
- <div class="clear"></div>
- </div>
+ {include file="CRM/UF/Form/Block.tpl" fields=$honoreeProfileFields mode=8 prefix='honor'}
</div>
</fieldset>
{/if}
showOnBehalf(true);
{/if}
- {if $honor_block_is_active AND $form.honor_type_id.html}
+ {if $honor_block_is_active AND $form.soft_credit_type_id.html}
enableHonorType();
{/if}
{literal}
function enableHonorType( ) {
- var element = document.getElementsByName("honor_type_id");
+ var element = document.getElementsByName("soft_credit_type_id");
for (var i = 0; i < element.length; i++ ) {
var isHonor = false;
if ( element[i].checked == true ) {
cj('#honorTypeEmail').show();
}
else {
- document.getElementById('honor_first_name').value = '';
- document.getElementById('honor_last_name').value = '';
- document.getElementById('honor_email').value = '';
- document.getElementById('honor_prefix_id').value = '';
cj('#honorType').hide();
cj('#honorTypeEmail').hide();
}
</div>
{/if}
- {include file="CRM/Contribute/Form/Contribution/Honor.tpl"}
+ {if $honor_block_is_active}
+ <div class="crm-group honor_block-group">
+ <div class="header-dark">
+ {$soft_credit_type}
+ </div>
+ <div class="display-block">
+ <div class="label-left crm-section honoree_profile-section">
+ {$honorName}</br></br>
+ {include file="CRM/UF/Form/Block.tpl" fields=$honoreeProfileFields prefix='honor'}
+ </div>
+ </div>
+ </div>
+ {/if}
{if $customPre}
<fieldset class="label-left crm-profile-view">
</tr>
</table>
<table class="form-layout-compressed" id="honor">
- <tr class="crm-contribution-contributionpage-settings-form-block-honor_block_title"><td class="label">{$form.honor_block_title.label} {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_contribution_page' field='honor_block_title' id=$contributionPageID}{/if}</td><td>{$form.honor_block_title.html}<br />
- <span class="description">{ts}Title for the Honoree section (e.g. "Honoree Information").{/ts}</span></td>
+ <tr class="crm-contribution-contributionpage-settings-form-block-honor_block_title">
+ <td class="label">
+ {$form.honor_block_title.label}
+ {if $action == 2}
+ {include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_contribution_page' field='honor_block_title' id=$contributionPageID}
+ {/if}
+ </td>
+ <td>
+ {$form.honor_block_title.html}<br />
+ <span class="description">{ts}Title for the Honoree section (e.g. "Honoree Information").{/ts}</span>
+ </td>
+ </tr>
+ <tr class="crm-contribution-contributionpage-settings-form-block-honor_block_text">
+ <td class="label">
+ {crmAPI var='result' entity='OptionGroup' action='get' sequential=1 name='soft_credit_type'}
+ {$form.honor_block_text.label}
+ {if $action == 2}
+ {include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_contribution_page' field='honor_block_text' id=$contributionPageID}
+ {/if}
+ </td>
+ <td>
+ {$form.honor_block_text.html}<br />
+ <span class="description">{ts}Optional explanatory text for the Honoree section (displayed above the Honoree fields).{/ts}</span>
+ </td>
</tr>
- <tr class="crm-contribution-contributionpage-settings-form-block-honor_block_text">
- <td class="label">{$form.honor_block_text.label} {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_contribution_page' field='honor_block_text' id=$contributionPageID}{/if}</td><td>{$form.honor_block_text.html}<br />
- <span class="description">{ts}Optional explanatory text for the Honoree section (displayed above the Honoree fields).{/ts}</span></td>
+ <tr class="crm-contribution-contributionpage-settings-form-block-honor_soft_credit_types">
+ <td class="label">
+ <a class="optionvalue-link" href="#"><span class="batch-edit"></span></a>
+ {$form.soft_credit_types.label}</td><td>{$form.soft_credit_types.html}
+ </td>
</tr>
+ <tr class="crm-contribution-contributionpage-custom-form-block-custom_pre_id">
+ <td class="label">
+ {$form.honoree_profile.label}
+ </td>
+ <td class="html-adjust">
+ {$form.honoree_profile.html}
+ <span class="description">{ts}Profile to be included in the honoree section{/ts}</span>
+ </td>
+ </tr>
</table>
<table class="form-layout-compressed">
<tr class="crm-contribution-contributionpage-settings-form-block-is_confirm_enabled">
document.getElementById("honor").style.display = "none";
}
}
+ cj('.optionvalue-link').click(function() {
+ {/literal}"{crmAPI var='result' entity='OptionGroup' action='get' sequential=1 name='soft_credit_type'}"{literal};
+ var postURL = {/literal}"{crmURL p='civicrm/admin/optionValue' q="gid="}{$result.id}"{literal};
+ CRM.loadForm(postURL).on('crmFormSuccess', function(e, data) {
+ cj('.ui-dialog a').click(function(){
+ //Todo: inline edit facility for soft_credit_type option group in jquery popup dialog
+ });
+ });
+ return false;
+ })
+
+ cj("select#soft_credit_types").crmasmSelect({
+ addItemTarget: 'bottom',
+ animate: false,
+ highlight: true,
+ respectParents: true
+ });
{/literal}
</script>
return false;
}
- $('#addMoreSoftCredit').click(function(){
+ $('#addMoreSoftCredit').live('click', function () {
$('.crm-contribution-form-block-soft_credit_to tr.hiddenElement').filter(':first').show().removeClass('hiddenElement');
- if ( $('.crm-soft-credit-block tr.hiddenElement').length < 1 ) {
+ if ($('.crm-soft-credit-block tr.hiddenElement').length < 1) {
$('#addMoreSoftCredit').hide();
}
return false;
});
$('input[name^="soft_credit_contact["]').change(function(){
- var rowNum = $(this).attr('id').replace('soft_credit_contact_','');
+ var rowNum = $(this).prop('id').replace('soft_credit_contact_','');
var totalAmount = $('#total_amount').val();
//assign total amount as default soft credit amount
$('#soft_credit_amount_'+ rowNum).val(totalAmount);
+--------------------------------------------------------------------+
*}
{* 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}
+ <span class="crm-clear-link">(<a href="#" title="unselect" onclick="unselectRadio('soft_credit_type_id', '{$form.formName}');enableHonorType(); return false;">{ts}clear{/ts}</a>)</span>
+ <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}
+++ /dev/null
-{*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.4 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013 |
- +--------------------------------------------------------------------+
- | 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 |
- +--------------------------------------------------------------------+
-*}
-{if $action eq 1 or $action eq 2 or $action eq 8} {* add, update or view *}
- {include file="CRM/Contribute/Form/Contribution.tpl"}
-{elseif $action eq 4}
- {include file="CRM/Contribute/Form/ContributionView.tpl"}
-{/if}
-{if $honorRows}
- {strip}
- <table class="selector">
- <tr class="columnheader">
- <th scope="col">{ts}Contributor{/ts}</th>
- <th scope="col">{ts}Amount{/ts}</th>
- <th scope="col">{ts}Type{/ts}</th>
- <th scope="col">{ts}Source{/ts}</th>
- <th scope="col">{ts}Received{/ts}</th>
- <th scope="col">{ts}Status{/ts}</th>
- <th> </th>
- </tr>
- {foreach from=$honorRows item=row}
- <tr id='rowid{$row.honorId}' class="{cycle values="odd-row,even-row"}">
- <td><a href="{crmURL p="civicrm/contact/view" q="reset=1&cid=`$row.honorId`"}" id="view_contact">{$row.display_name}</a></td>
- <td>{$row.amount}</td>
- <td>{$row.type}</td>
- <td>{$row.source}</td>
- <td>{$row.receive_date|truncate:10:''|crmDate}</td>
- <td>{$row.contribution_status}</td>
- <td>{$row.action|replace:'xx':$row.honorId}</td>
- </tr>
- {/foreach}
- </table>
- {/strip}
-{/if}
-
{include file="CRM/Contribute/Page/ContributionRecur.tpl"}
{/if}
- {if $honor}
- <div class="solid-border-top">
- <br /><label>{ts 1=$displayName}Contributions made in honor of %1{/ts}</label>
- </div>
- {include file="CRM/Contribute/Page/ContributionHonor.tpl"}
- {/if}
-
{if $softCredit}
<div class="solid-border-top">
<br />
<td>
<table class="compressed">
<tr class="crm-membership-form-block-honor-type">
- <td class="label">{$form.honor_type_id.label}</td>
- <td>{$form.honor_type_id.html}</td>
+ <td class="label">{$form.soft_credit_type.label}</td>
+ <td>{$form.soft_credit_type.html}</td>
</tr>
<tr id ='contributionContact' class="crm-membership-form-block-contribution-type">
{include file="CRM/Contact/Form/NewContact.tpl"}
<td>
<table class="compressed">
<tr class="crm-membership-form-block-honor-type">
- <td class="label">{$form.honor_type_id.label}</td>
- <td>{$form.honor_type_id.html}</td>
+ <td class="label">{$form.soft_credit_type_id.label}</td>
+ <td>{$form.soft_credit_type_id.html}</td>
</tr>
<tr id ='contributionContact' class="crm-membership-form-block-contribution-type">
{include file="CRM/Contact/Form/NewContact.tpl"}
<td>
<table class="compressed">
<tr class="crm-membership-form-block-honor-type">
- <td class="label">{$form.honor_type_id.label}</td>
- <td>{$form.honor_type_id.html}</td>
+ <td class="label">{$form.soft_credit_type_id.label}</td>
+ <td>{$form.soft_credit_type_id.html}</td>
</tr>
<tr id='contributionContact' class="crm-membership-form-block-contribution-type">
{include file="CRM/Contact/Form/NewContact.tpl"}
<fieldset class="crm-profile crm-profile-id-{$field.group_id} crm-profile-name-{$field.groupName}"><legend>{$field.groupTitle}</legend>
{/if}
- {if $form.formName eq 'Confirm' OR $form.formName eq 'ThankYou'}
+ {if ($form.formName eq 'Confirm' OR $form.formName eq 'ThankYou') AND $prefix neq 'honor'}
<div class="header-dark">{$field.groupTitle} </div>
{/if}
{assign var=fieldset value=`$field.groupTitle`}
{else}
<div class="crm-section editrow_{$n}-section form-item" id="editrow-{$n}">
<div class="label">
- {$form.$n.label}
+ {if $prefix}{$form.$prefix.$n.label}{else}{$form.$n.label}{/if}
</div>
<div class="content">
{if $n|substr:0:3 eq 'im-'}
{include file="CRM/common/jcalendar.tpl" elementName=$n}
{elseif $n|substr:0:5 eq 'phone'}
{assign var="phone_ext_field" value=$n|replace:'phone':'phone_ext'}
- {$form.$n.html}
+ {if $prefix}{$form.$prefix.$n.html}{else}{$form.$n.html}{/if}
{if $form.$phone_ext_field.html}
{$form.$phone_ext_field.html}
{/if}
{else}
- {$form.$n.html}
+ {if $prefix}{$form.$prefix.$n.html}{else}{$form.$n.html}{/if}
{if $n eq 'gender' && $form.$fieldName.frozen neq true}
<span class="crm-clear-link">(<a href="#" title="unselect" onclick="unselectRadio('{$n}', '{$form.formName}');return false;">{ts}clear{/ts}</a>)</span>
{/if}
<add>1.4</add>
<onDelete>SET NULL</onDelete>
</foreignKey>
- <field>
- <name>honor_contact_id</name>
- <title>Honor Contact</title>
- <type>int unsigned</type>
- <comment>FK to contact ID</comment>
- <add>1.3</add>
- <html>
- <type>Autocomplete-Select</type>
- </html>
- </field>
- <foreignKey>
- <name>honor_contact_id</name>
- <table>civicrm_contact</table>
- <key>id</key>
- <add>1.6</add>
- <onDelete>SET NULL</onDelete>
- </foreignKey>
<field>
<name>is_test</name>
<title>Test</title>
</html>
<add>1.6</add>
</field>
- <field>
- <name>honor_type_id</name>
- <title>Honor Type</title>
- <type>int unsigned</type>
- <comment>Implicit FK to civicrm_option_value.</comment>
- <add>2.0</add>
- <onDelete>SET NULL</onDelete>
- <pseudoconstant>
- <optionGroupName>honor_type</optionGroupName>
- </pseudoconstant>
- <html>
- <type>Select</type>
- </html>
- </field>
<index>
<name>index_contribution_status</name>
<fieldName>contribution_status_id</fieldName>
<comment>Should this contribution have the honor block enabled?</comment>
<add>1.6</add>
</field>
- <field>
- <name>honor_block_title</name>
- <title>Contribution Page Honor Block Title</title>
- <type>varchar</type>
- <length>255</length>
- <localizable>true</localizable>
- <comment>Title for honor block.</comment>
- <add>1.5</add>
- </field>
- <field>
- <name>honor_block_text</name>
- <title>Contribution Page Honor Block Text</title>
- <type>text</type>
- <html>
- <type>TextArea</type>
- <rows>2</rows>
- <cols>50</cols>
- </html>
- <localizable>true</localizable>
- <comment>text for honor block.</comment>
- <add>1.5</add>
- </field>
<field>
<name>start_date</name>
<type>datetime</type>
<key>id</key>
<add>1.3</add>
</foreignKey>
+ <field>
+ <name>module_data</name>
+ <type>varchar</type>
+ <length>255</length>
+ <comment>Json serialized array of data used by the ufjoin.module</comment>
+ <add>4.5</add>
+ </field>
</table>
<type>Select Date</type>
</html>
</field>
- <field>
- <name>honor_contact_id</name>
- <type>int unsigned</type>
- <title>Pledge Honor Contact</title>
- <comment>FK to contact ID. Used when pledge is made in honor of another contact. This is propagated to contribution records when pledge payments are made.</comment>
- <add>2.1</add>
- <html>
- <type>Autocomplete-Select</type>
- </html>
- </field>
- <foreignKey>
- <name>honor_contact_id</name>
- <table>civicrm_contact</table>
- <key>id</key>
- <add>2.1</add>
- <onDelete>SET NULL</onDelete>
- </foreignKey>
- <field>
- <name>honor_type_id</name>
- <title>Honor Type</title>
- <type>int unsigned</type>
- <comment>Implicit FK to civicrm_option_value.</comment>
- <add>2.1</add>
- <onDelete>SET NULL</onDelete>
- <pseudoconstant>
- <optionGroupName>honor_type</optionGroupName>
- </pseudoconstant>
- <html>
- <type>Select</type>
- </html>
- </field>
<field>
<name>max_reminders</name>
<title>Maximum Number of Reminders</title>
(11, 'membership_batch_entry', 'Membership', '{ts escape="sql"}Membership Bulk Entry{/ts}' , 0, 1, NULL),
(12, 'event_registration', 'Individual, Contact', '{ts escape="sql"}Your Registration Info{/ts}', 0, 0, NULL);
+
INSERT INTO civicrm_uf_join
(is_active,module,entity_table,entity_id,weight,uf_group_id)
VALUES
INSERT INTO civicrm_uf_field
( uf_group_id, field_name, is_required, is_reserved, weight, visibility, in_selector, is_searchable, location_type_id, label, field_type, help_post, phone_type_id ) VALUES
( 10, 'soft_credit_type', 0, 1, 11, 'User and User Admin Only', 0, 1, NULL, '{ts escape="sql"}Soft Credit Type{/ts}', 'Contribution', NULL, NULL );
+
+-- CRM-13981
+INSERT INTO civicrm_uf_group
+ (name, group_type, title, is_cms_user, is_reserved, help_post)
+VALUES
+ ('honoree_individual', 'Individual, Contact', '{ts escape="sql"}Honoree Individual{/ts}', 0, 1, NULL);
+
+SELECT @uf_group_id_honoree_individual := max(id) from civicrm_uf_group where name = 'honoree_individual';
+
+INSERT INTO civicrm_uf_field
+ ( uf_group_id, field_name, is_required, is_reserved, weight, visibility, in_selector, is_searchable, location_type_id, label, field_type)
+VALUES
+ (@uf_group_id_honoree_individual, 'honor_prefix_id', 0, 1, 1, 'User and User Admin Only', 0, 1, NULL, '{ts escape="sql"}Individual Prefix{/ts}', 'Individual'),
+ (@uf_group_id_honoree_individual, 'honor_first_name', 1, 1, 2, 'User and User Admin Only', 0, 1, NULL, '{ts escape="sql"}First Name{/ts}', 'Individual'),
+ (@uf_group_id_honoree_individual, 'honor_last_name', 1, 1, 3, 'User and User Admin Only', 0, 1, NULL, '{ts escape="sql"}Last Name{/ts}', 'Individual'),
+ (@uf_group_id_honoree_individual, 'honor_first_name', 1, 1, 2, 'User and User Admin Only', 0, 1, NULL, '{ts escape="sql"}First Name{/ts}', 'Individual'),
+ (@uf_group_id_honoree_individual, 'honor_email', 0, 1, 3, 'User and User Admin Only', 0, 1, 1, '{ts escape="sql"}Last Name{/ts}', 'Individual');
+
+INSERT INTO civicrm_uf_join
+ (is_active, module, weight, uf_group_id)
+VALUES
+ (1, 'Profile', 1, @uf_group_id_honoree_individual);
(@priceFieldID, 'other_amount', 'Other Amount', 1, 3, 1, 0, 1);
INSERT INTO civicrm_contribution_page
- (title,intro_text,financial_type_id,is_monetary,is_allow_other_amount,default_amount_id,min_amount,max_amount,goal_amount,thankyou_title,thankyou_text,thankyou_footer,receipt_from_name,receipt_from_email,cc_receipt,bcc_receipt,receipt_text,is_active,footer_text,amount_block_is_active,honor_block_is_active,honor_block_title,honor_block_text,currency,is_email_receipt)
+ (title,intro_text,financial_type_id,is_monetary,is_allow_other_amount,default_amount_id,min_amount,max_amount,goal_amount,thankyou_title,thankyou_text,thankyou_footer,receipt_from_name,receipt_from_email,cc_receipt,bcc_receipt,receipt_text,is_active,footer_text,amount_block_is_active,honor_block_is_active,currency,is_email_receipt)
VALUES
- ('Help Support CiviCRM!','Do you love CiviCRM? Do you use CiviCRM? Then please support CiviCRM and Contribute NOW by trying out our new online contribution features!',1,1,1,137,'10.00','10000.00','100000.00','Thanks for Your Support!','<p>Thank you for your support. Your contribution will help us build even better tools.</p><p>Please tell your friends and colleagues about CiviCRM!</p>','<p><a href=http://civicrm.org>Back to CiviCRM Home Page</a></p>','CiviCRM Fundraising Dept.','donationFake@civicrm.org','receipt@example.com','bcc@example.com','Your donation is tax deductible under IRS 501(c)(3) regulation. Our tax identification number is: 93-123-4567',1, NULL, 1,NULL, NULL, NULL, 'USD', 1),
- ('Member Signup and Renewal', 'Members are the life-blood of our organization. If you''re not already a member - please consider signing up today. You can select the membership level the fits your budget and needs below.', 2, 1, NULL, NULL, NULL, NULL, NULL, 'Thanks for Your Support!', 'Thanks for supporting our organization with your membership. You can learn more about membership benefits from our members only page.', NULL, 'Membership Department', 'memberships@civicrm.org', NULL, NULL, 'Thanks for supporting our organization with your membership. You can learn more about membership benefits from our members only page.\r\n\r\nKeep this receipt for your records.', 1, NULL, 0, NULL, NULL,NULL, 'USD', 1),
- ('Pledge for CiviCRM!','Do you love CiviCRM? Do you use CiviCRM? Then please support CiviCRM and Pledge NOW by trying out our online contribution features!',1,1,1,NULL,'10.00','10000.00','100000.00','Thanks for Your Support!','<p>Thank you for your support. Your contribution will help us build even better tools like Pledge.</p><p>Please tell your friends and colleagues about CiviPledge!</p>','<p><a href=http://civicrm.org>Back to CiviCRM Home Page</a></p>','CiviCRM Fundraising Dept.','donationFake@civicrm.org','receipt@example.com','bcc@example.com','Your donation is tax deductible under IRS 501(c)(3) regulation. Our tax identification number is: 93-123-4567',1, NULL, 1,NULL, NULL, NULL, 'USD', 1);
+ ('Help Support CiviCRM!','Do you love CiviCRM? Do you use CiviCRM? Then please support CiviCRM and Contribute NOW by trying out our new online contribution features!',1,1,1,137,'10.00','10000.00','100000.00','Thanks for Your Support!','<p>Thank you for your support. Your contribution will help us build even better tools.</p><p>Please tell your friends and colleagues about CiviCRM!</p>','<p><a href=http://civicrm.org>Back to CiviCRM Home Page</a></p>','CiviCRM Fundraising Dept.','donationFake@civicrm.org','receipt@example.com','bcc@example.com','Your donation is tax deductible under IRS 501(c)(3) regulation. Our tax identification number is: 93-123-4567',1, NULL, 1,NULL, 'USD', 1),
+ ('Member Signup and Renewal', 'Members are the life-blood of our organization. If you''re not already a member - please consider signing up today. You can select the membership level the fits your budget and needs below.', 2, 1, NULL, NULL, NULL, NULL, NULL, 'Thanks for Your Support!', 'Thanks for supporting our organization with your membership. You can learn more about membership benefits from our members only page.', NULL, 'Membership Department', 'memberships@civicrm.org', NULL, NULL, 'Thanks for supporting our organization with your membership. You can learn more about membership benefits from our members only page.\r\n\r\nKeep this receipt for your records.', 1, NULL, 0, NULL, 'USD', 1),
+ ('Pledge for CiviCRM!','Do you love CiviCRM? Do you use CiviCRM? Then please support CiviCRM and Pledge NOW by trying out our online contribution features!',1,1,1,NULL,'10.00','10000.00','100000.00','Thanks for Your Support!','<p>Thank you for your support. Your contribution will help us build even better tools like Pledge.</p><p>Please tell your friends and colleagues about CiviPledge!</p>','<p><a href=http://civicrm.org>Back to CiviCRM Home Page</a></p>','CiviCRM Fundraising Dept.','donationFake@civicrm.org','receipt@example.com','bcc@example.com','Your donation is tax deductible under IRS 501(c)(3) regulation. Our tax identification number is: 93-123-4567',1, NULL, 1,NULL, 'USD', 1);
INSERT INTO `civicrm_tell_friend`
(`entity_table`, `entity_id`, `title`, `intro`, `suggested_message`, `general_link`, `thankyou_title`, `thankyou_text`, `is_active`)