CRM-13981 fix - Migrate "In Honor of" to Soft Credits
authormonishdeb <monish.deb@webaccess.co.in>
Wed, 15 Jan 2014 13:00:34 +0000 (18:30 +0530)
committerkurund <kurund@civicrm.org>
Fri, 17 Jan 2014 23:38:25 +0000 (15:38 -0800)
http://issues.civicrm.org/jira/browse/CRM-13981

Conflicts:
CRM/Upgrade/Incremental/sql/4.5.alpha1.mysql.tpl
templates/CRM/Contribute/Form/SoftCredit.js

----------------------------------------
* CRM-13981: Migrate "In Honor of" to Soft Credits
  http://issues.civicrm.org/jira/browse/CRM-13981

40 files changed:
CRM/Contact/Form/ProfileContact.php [new file with mode: 0644]
CRM/Contribute/BAO/Contribution.php
CRM/Contribute/BAO/Query.php
CRM/Contribute/Form/AdditionalInfo.php
CRM/Contribute/Form/Contribution.php
CRM/Contribute/Form/Contribution/Confirm.php
CRM/Contribute/Form/Contribution/Main.php
CRM/Contribute/Form/Contribution/ThankYou.php
CRM/Contribute/Form/ContributionBase.php
CRM/Contribute/Form/ContributionPage.php
CRM/Contribute/Form/ContributionPage/Settings.php
CRM/Contribute/Form/SoftCredit.php
CRM/Core/BAO/UFGroup.php
CRM/Member/BAO/Membership.php
CRM/Member/Form/Membership.php
CRM/Member/Form/MembershipRenewal.php
CRM/Pledge/Form/Pledge.php
CRM/Report/Form/Contribute/Detail.php
CRM/Report/Form/Member/ContributionDetail.php
CRM/UF/Page/ProfileEditor.php
CRM/Upgrade/Incremental/sql/4.5.alpha1.mysql.tpl
sql/GenerateData.php
templates/CRM/Contribute/Form/Contribution/Confirm.tpl
templates/CRM/Contribute/Form/Contribution/Honor.tpl [deleted file]
templates/CRM/Contribute/Form/Contribution/Main.tpl
templates/CRM/Contribute/Form/Contribution/ThankYou.tpl
templates/CRM/Contribute/Form/ContributionPage/Settings.tpl
templates/CRM/Contribute/Form/SoftCredit.js
templates/CRM/Contribute/Form/SoftCredit.tpl
templates/CRM/Contribute/Page/ContributionHonor.tpl [deleted file]
templates/CRM/Contribute/Page/Tab.tpl
templates/CRM/Member/Form/Membership.tpl
templates/CRM/Member/Form/MembershipRenewal.tpl
templates/CRM/UF/Form/Block.tpl
xml/schema/Contribute/Contribution.xml
xml/schema/Contribute/ContributionPage.xml
xml/schema/Core/UFJoin.xml
xml/schema/Pledge/Pledge.xml
xml/templates/civicrm_data.tpl
xml/templates/civicrm_sample.tpl

diff --git a/CRM/Contact/Form/ProfileContact.php b/CRM/Contact/Form/ProfileContact.php
new file mode 100644 (file)
index 0000000..746c056
--- /dev/null
@@ -0,0 +1,150 @@
+<?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);
+    }
+  }
+}
+
index c6e1efea20fdef1ee5b56cdbc6811ca9ad260b64..2fcd78da33c28c764afb26a98186cde192fa0e6c 100644 (file)
@@ -342,10 +342,6 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution {
       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);
       }
     }
@@ -909,44 +905,6 @@ GROUP BY p.id
     }
   }
 
-  /**
-   * 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
    *
@@ -1697,7 +1655,7 @@ LEFT JOIN  civicrm_contribution contribution ON ( componentPayment.contribution_
     return $componentDetails;
   }
 
-  static function contributionCount($contactId, $includeSoftCredit = TRUE, $includeHonoree = TRUE) {
+  static function contributionCount($contactId, $includeSoftCredit = TRUE) {
     if (!$contactId) {
       return 0;
     }
@@ -1707,11 +1665,6 @@ LEFT JOIN  civicrm_contribution contribution ON ( componentPayment.contribution_
       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
@@ -1725,11 +1678,6 @@ LEFT JOIN  civicrm_contribution contribution ON ( componentPayment.contribution_
       $query .= $contactSoftCreditContributionsSQL;
     }
 
-    if ($includeHonoree) {
-      $query .= " UNION ";
-      $query .= $contactHonoreeContributionsSQL;
-    }
-
     $query .= ") x";
 
     return CRM_Core_DAO::singleValueQuery($query);
index 7d9255329fe7b6ae6bfe9d4bf7943b03f07ba447..1d0e57d4e6598776def34d2a9247803e653c5597 100644 (file)
@@ -127,38 +127,6 @@ class CRM_Contribute_BAO_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;
@@ -373,22 +341,6 @@ class CRM_Contribute_BAO_Query {
         $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)) {
@@ -665,10 +617,6 @@ class CRM_Contribute_BAO_Query {
                                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
@@ -680,20 +628,6 @@ class CRM_Contribute_BAO_Query {
                                                     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 ";
@@ -866,9 +800,6 @@ class CRM_Contribute_BAO_Query {
     $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?'));
 
index 3d92a50b5004f66bc61edcbcf2f89ca0a33ac8f7..ead4c9c4f921d34a548e579afbec029383dab310 100644 (file)
@@ -311,19 +311,6 @@ class CRM_Contribute_Form_AdditionalInfo {
       $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,
index 401e51e2e351a677207179df131f4b9162425943..007994119e1f9768306d8e5a7995d2f6e058b7e3 100644 (file)
@@ -104,14 +104,6 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
    */
   public $_options;
 
-  /**
-   * stores the honor id
-   *
-   * @var int
-   * @public
-   */
-  public $_honorID = NULL;
-
   /**
    * Store the contribution Type ID
    *
@@ -289,8 +281,6 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
     //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;
@@ -349,7 +339,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
     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'));
     }
@@ -358,23 +348,6 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
       $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) {
@@ -493,25 +466,6 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
       }
     }
 
-    $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;
@@ -526,7 +480,6 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
 
     $paneNames = array(
       ts('Additional Details') => 'AdditionalDetail',
-      ts('Honoree Information') => 'Honoree'
     );
 
     //Add Premium pane only if Premium is exists.
@@ -895,17 +848,6 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
       $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'])) {
@@ -938,7 +880,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
       && $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'));
@@ -950,7 +892,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
       $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);
index 2f7aeea141a967632ae950c16cfb3af5c48d3b7f..974ee3ff0f8b048ce32da81736fb237ac4af13dc 100644 (file)
@@ -376,21 +376,39 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
     $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');
@@ -444,7 +462,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
         $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');
@@ -507,12 +525,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
     $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;
       }
     }
@@ -520,17 +533,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
 
     $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";
@@ -971,6 +974,9 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
         $fieldTypes
       );
     }
+
+    //processing honor contact into soft-credit contribution
+    CRM_Contact_Form_ProfileContact::postProcess($this);
   }
 
   /**
@@ -1124,11 +1130,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
   ) {
     $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;
@@ -1143,10 +1145,6 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
     }
     $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.
@@ -1264,11 +1262,6 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
       );
     }
 
-    if (isset($honorCId)) {
-      $contribParams['honor_contact_id'] = $honorCId;
-      $contribParams['honor_type_id'] = $params['honor_type_id'];
-    }
-
     if ($recurringContributionID) {
       $contribParams['contribution_recur_id'] = $recurringContributionID;
     }
@@ -1569,42 +1562,6 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
     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
    *
index 88191c7406eff6fff2cfee47b2e10ba391de47c5..64b90320fcdb709ff3407799d9ef56fba32add0f 100644 (file)
@@ -114,6 +114,10 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu
     }
     $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']);
     }
@@ -231,23 +235,47 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu
 
     //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)) {
@@ -460,8 +488,15 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu
       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);
     }
 
 
@@ -571,42 +606,6 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu
     $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.
    *
@@ -898,17 +897,6 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu
       }
     }
 
-    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).');
index c1fbad5fba8deebef93af57eab5ba4397cc6966c..5591e3e0c4e93282a6a35dece54863dcc4125130 100644 (file)
@@ -120,21 +120,39 @@ class CRM_Contribute_Form_Contribution_ThankYou extends CRM_Contribute_Form_Cont
 
     $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&amp;id={$this->_id}";
@@ -194,7 +212,7 @@ class CRM_Contribute_Form_Contribution_ThankYou extends CRM_Contribute_Form_Cont
         $fieldTypes = array_merge($fieldTypes, array('Contribution'));
       }
 
-      $this->buildCustom($profileId, 'onbehalfProfile', TRUE, TRUE, $fieldTypes);
+      $this->buildCustom($profileId, 'onbehalfProfile', TRUE, 'onbehalf', $fieldTypes);
     }
 
     $this->assign('trxn_id',
@@ -209,12 +227,7 @@ class CRM_Contribute_Form_Contribution_ThankYou extends CRM_Contribute_Form_Cont
     $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;
       }
     }
@@ -222,19 +235,7 @@ class CRM_Contribute_Form_Contribution_ThankYou extends CRM_Contribute_Form_Cont
     $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";
index 1f05911ecdf7318457b9627284fcb1e274016e99..f0763ae5aa8f927ff4a8419d0dc11c2f57d6cc0b 100644 (file)
@@ -640,7 +640,7 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
    * @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) {
@@ -709,7 +709,7 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
             $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;
@@ -728,16 +728,23 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
             }
           }
 
-          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]);
index 9fa9d093ef5cd4ad6c881f68e168a94cd741421a..6107c73625216d09c35ce855317dde152e0c789f 100644 (file)
@@ -133,7 +133,7 @@ class CRM_Contribute_Form_ContributionPage extends CRM_Core_Form {
     }
 
     // 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';
     }
@@ -218,16 +218,16 @@ class CRM_Contribute_Form_ContributionPage extends CRM_Core_Form {
       $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');
index 2af10e33e0197c66bd47ddea0524540845b04536..8c7605a7b0cd3557e0fa9c7167a41ebef0ba6b6b 100644 (file)
@@ -74,11 +74,28 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_
         // 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;
   }
 
@@ -171,9 +188,33 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_
     // 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'));
@@ -213,12 +254,12 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_
     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)) {
@@ -239,7 +280,7 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_
           $conProfileType = "'Includes Profile (top of page)'";
         }
       }
-            
+
       if ($contributionProfiles['custom_post_id']) {
         $postProfileType = CRM_Core_BAO_UFField::getProfileType($contributionProfiles['custom_post_id']);
         if ($postProfileType == 'Membership') {
@@ -291,24 +332,61 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_
       $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);
index 896d3dfa8b3e8cef0c6499240fc724ed1086ca11..7a89a959fa1c5656b75aea6a8a9431fcd7c37d0a 100644 (file)
@@ -47,6 +47,29 @@ class CRM_Contribute_Form_SoftCredit {
    * @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;
@@ -55,6 +78,22 @@ class CRM_Contribute_Form_SoftCredit {
     $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++;
@@ -119,7 +158,6 @@ class CRM_Contribute_Form_SoftCredit {
         $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);
index 637f4ee78813317ad0fa49c4fcbeae000f169910..e0d8fbd9d6495c009820cca5cc1590be5cedda75 100644 (file)
@@ -1695,6 +1695,7 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
    * @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
@@ -1706,7 +1707,7 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
     $mode,
     $contactId = NULL,
     $online = FALSE,
-    $onBehalf = FALSE,
+    $usedFor = NULL,
     $rowNumber = NULL ,
     $prefix = ''
   ) {
@@ -1726,9 +1727,12 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
       return;
     }
 
-    if ($onBehalf) {
+    if ($usedFor == 'onbehalf') {
       $name = "onbehalf[$fieldName]";
     }
+    elseif ($usedFor == 'honor') {
+      $name = "honor[$fieldName]";
+    }
     elseif ($contactId && !$online) {
       $name = "field[$contactId][$fieldName]";
     }
@@ -1814,7 +1818,7 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
     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]';
           }
@@ -1884,9 +1888,12 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
     }
     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') {
@@ -1993,7 +2000,7 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
       $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]';
         }
@@ -2169,8 +2176,8 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
       // 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']);
index 321d2e332b2b67ea19c689da223a5aef13956b88..9ca03859f79333e90f29393d3f9bdf207b037235 100644 (file)
@@ -2662,7 +2662,6 @@ WHERE      civicrm_membership.is_test = 0";
     $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) {
index 63bb3b6788be20f60d3287dd915c48321222bdb6..d1b90814a9a7ebe020ffb93906ff5f6b17bb2dd7 100644 (file)
@@ -359,7 +359,7 @@ class CRM_Member_Form_Membership extends CRM_Member_Form {
         }
       }
     }
-    
+
     if (CRM_Utils_Array::value('record_contribution', $defaults) && !$this->_mode) {
       $contributionParams = array('id' => $defaults['record_contribution']);
       $contributionIds = array();
@@ -771,8 +771,8 @@ WHERE   id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )';
       //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_');
     }
 
@@ -930,11 +930,20 @@ WHERE   id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )';
     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);
@@ -1074,7 +1083,7 @@ WHERE   id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )';
     $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) {
@@ -1249,15 +1258,14 @@ WHERE   id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )';
     //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',
@@ -1395,9 +1403,9 @@ WHERE   id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )';
       //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)) {
@@ -1427,6 +1435,13 @@ WHERE   id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )';
           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;
@@ -1547,6 +1562,17 @@ WHERE   id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )';
           $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.
index 537e6a5e4f9ec0333d82fb5095be0aa4ca419b04..02ccc85eaa9203f01a0efb6e4fc1c2ed481d24c8 100644 (file)
@@ -244,7 +244,7 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form {
     }
 
     $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'));
@@ -515,8 +515,8 @@ WHERE   id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )';
       //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_');
   }
@@ -781,8 +781,12 @@ WHERE   id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )';
       //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;
index ad2ac46ceede9bd4640dedc6cad1056d1a2c9e99..def9c51291c2a5aec2cc5ff64b16ab7c2c40c7d9 100644 (file)
@@ -62,14 +62,6 @@ class CRM_Pledge_Form_Pledge extends CRM_Core_Form {
    */
   public $_values;
 
-  /**
-   * stores the honor id
-   *
-   * @var int
-   * @public
-   */
-  public $_honorID = NULL;
-
   /**
    * The Pledge frequency Units
    * @public
@@ -134,9 +126,6 @@ class CRM_Pledge_Form_Pledge extends CRM_Core_Form {
       $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.
@@ -252,19 +241,6 @@ class CRM_Pledge_Form_Pledge extends CRM_Core_Form {
         $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);
     }
@@ -306,14 +282,9 @@ class CRM_Pledge_Form_Pledge extends CRM_Core_Form {
     $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) {
@@ -527,15 +498,6 @@ class CRM_Pledge_Form_Pledge extends CRM_Core_Form {
       $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.');
     }
@@ -592,11 +554,6 @@ class CRM_Pledge_Form_Pledge extends CRM_Core_Form {
       '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',
     );
@@ -647,20 +604,6 @@ class CRM_Pledge_Form_Pledge extends CRM_Core_Form {
 
     $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;
index 3f59c3a60090f18e9041d18dadc054c05da96e94..e5c38a3ee16c83f5e8643cf3e420bde0e1b1224d 100644 (file)
@@ -36,9 +36,6 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form {
   protected $_addressField = FALSE;
 
   protected $_emailField = FALSE;
-  protected $_emailFieldHonor = FALSE;
-
-  protected $_nameFieldHonor = FALSE;
 
   protected $_summary = NULL;
   protected $_allBatches = NULL;
@@ -133,41 +130,6 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form {
         ),
         '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',
@@ -214,9 +176,6 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form {
           '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'),
@@ -406,22 +365,6 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form {
 
   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();
   }
@@ -486,20 +429,6 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form {
                    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)) {
@@ -701,8 +630,6 @@ UNION ALL
     $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') {
@@ -751,20 +678,6 @@ UNION ALL
         $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;
@@ -781,10 +694,6 @@ UNION ALL
         $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');
index 442c6f856c8a9b3b0767934a970d65f3608b8035..a0c8a5385d65c0607e5fc65f5b827a27cdfac02f 100644 (file)
@@ -37,9 +37,6 @@ class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form {
   protected $_addressField = FALSE;
 
   protected $_emailField = FALSE;
-  protected $_emailFieldHonor = FALSE;
-
-  protected $_nameFieldHonor = FALSE;
 
   protected $_summary = NULL;
   protected $_allBatches = NULL;
@@ -138,43 +135,6 @@ class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form {
         ),
         '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' =>
@@ -227,9 +187,6 @@ class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form {
           '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'),
@@ -479,13 +436,6 @@ class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form {
             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)) {
@@ -601,21 +551,6 @@ class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form {
                    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) {
@@ -720,7 +655,6 @@ class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form {
     $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') {
@@ -840,20 +774,6 @@ class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form {
         $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;
@@ -866,10 +786,6 @@ class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form {
         $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')
       ) {
index 2f4fbb25a05ea32b134bbc8a9be95eeb0a511254..b4129226891ab413a6c0b2c4b89b6e55ffef5f31 100644 (file)
@@ -67,6 +67,8 @@ class CRM_UF_Page_ProfileEditor extends CRM_Core_Page {
    * @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(
@@ -111,6 +113,12 @@ class CRM_UF_Page_ProfileEditor extends CRM_Core_Page {
             $availableFields
           );
           break;
+        case 'OrganizationModel':
+          $civiSchema[$entityType] = self::convertCiviModelToBackboneModel(
+            'Organization',
+            ts('Organization'),
+            $availableFields
+          );
         case 'ActivityModel':
           $civiSchema[$entityType] = self::convertCiviModelToBackboneModel(
             'Activity',
index baee09572ee9df08f1fc42ef9427cb174b1afd75..7916644a0e57f2fd5ec205a1e524b9c073f0fbb6 100644 (file)
@@ -119,3 +119,37 @@ VALUES
 
 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;
index 56263a8a3c010950c5cfd017d6e1e3e6f709d46b..3a5214abc8db72711e82f1bc57b276a65958d2a7 100644 (file)
@@ -1731,11 +1731,11 @@ VALUES
 
   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);
   }
index e00f7da8f17bae6932b180904db0a0f1549b6283..315c7cccdcfdfd4c6e3337c8419a4044e1bc4aa9 100644 (file)
         </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>
diff --git a/templates/CRM/Contribute/Form/Contribution/Honor.tpl b/templates/CRM/Contribute/Form/Contribution/Honor.tpl
deleted file mode 100644 (file)
index 9664a8a..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-{*
- +--------------------------------------------------------------------+
- | 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}&nbsp;{$honor_first_name}&nbsp;{$honor_last_name}<br />
-         <strong>Email      : </strong>{$honor_email}<br />
-    </div>
-</div>
-{/if}
index 9d1b101a69858717f060ed567788051b3830cbbc..18bbb0233e9f70e7f4a134241b8621257ab38963 100644 (file)
 
   {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();
     }
index 70e2ab89341670262d70e4833516023efa3a9318..ef73f373db4816013bba9a9722b2031525637b61 100644 (file)
     </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">
index 5d73e02f675717fe235c70f6746968ee23434c31..6a2542f66b41cdb928aff7792aa62927eac7c81e 100644 (file)
   </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. &quot;Honoree Information&quot;).{/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. &quot;Honoree Information&quot;).{/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>
 
index b0ac108d72a7c3de4143016d012fdbfeafd7c6ea..b8159a47c2032a152713cfd151c7f7d56ef30e05 100644 (file)
@@ -11,9 +11,9 @@ cj(function($) {
     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;
@@ -58,7 +58,7 @@ cj(function($) {
   });
 
   $('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);
index 35e0e30e096e7c87582ae6db4741de3584670df9..f75c5883f894aa182608e80d1b8180591099a18c 100644 (file)
  +--------------------------------------------------------------------+
 *}
 {* 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}
@@ -55,3 +71,4 @@
     </td>
   </tr>
 </table>
+{/if}
diff --git a/templates/CRM/Contribute/Page/ContributionHonor.tpl b/templates/CRM/Contribute/Page/ContributionHonor.tpl
deleted file mode 100644 (file)
index aa5eff7..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-{*
- +--------------------------------------------------------------------+
- | 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>&nbsp;</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}
-
index 27c32d46da29e557ab1ee8291afb639095264a2d..b946e5d1ff309c0de98d1a9e34a4b23e9d0356bc 100644 (file)
             {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 />
index fd73e63bd7bffcf2736bf1228876e7f0daeed3b6..a02eb03e4ab36b1686075cf5604ec302e0f9f2ff 100644 (file)
               <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"}
index 554366162ad734cbc6e2772b3c83b2311b8281e4..b3da8fc1d55746b317ff5fc5ed6e03de1092e689 100644 (file)
                     <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"}
index d526339941f9d8832b5cf0fe44e8a0b274e76883..a78995130377d87c3079611b7cd7152385677d5d 100644 (file)
@@ -47,7 +47,7 @@
         <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}
                   &nbsp;{$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}
index 64d1aff60258e07eeb97dcd4110254690c0808b4..b74263329ec44e07ae12a2c14bbff859ef8c914e 100644 (file)
     <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>
index e9dd38d11d8e1b31fd52efb4cd10f6f16a2df6da..1384ffa6d8679ab980ed9f5a7655dd025736f18a 100644 (file)
     <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>
index ee55d05766c4b91da175cd9ba86ebafc5e106799..ba37a03a0d2b36761b1c137ac46f63b76ef99092 100644 (file)
        <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>
index 41ff7f2dd1eddee5c004c117395b7c83d028965e..d4cd98446bd8854c04ecb9f5e33b40fadc4011be 100644 (file)
         <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>
index ca6a66ca1e0bb945bbc1650677add3d08c1d9239..e2c07db5cb8fe1a77a7a324fe4cb21e256dd7766 100644 (file)
@@ -1349,6 +1349,7 @@ INSERT INTO civicrm_uf_group
     (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
@@ -1597,3 +1598,25 @@ 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);
index 3179303092d377570c4c2f384e72dcbb0ea449cf..83f909e86aae35690ef6ac3d941b1c9b6557c709 100644 (file)
@@ -60,11 +60,11 @@ VALUES
      (@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`)