class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_ContributionBase {
/**
- * The id of the contact associated with this contribution
+ * The id of the contact associated with this contribution.
*
* @var int
*/
/**
- * The id of the contribution object that is created when the form is submitted
+ * The id of the contribution object that is created when the form is submitted.
*
* @var int
*/
public $_contributionID;
/**
- * Set the parameters to be passed to contribution create function
+ * Set the parameters to be passed to contribution create function.
*
* @param array $params
* @param int $contactID
}
/**
- * Set variables up before form is built
+ * Set variables up before form is built.
*
* @return void
*/
$payment = CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this);
$expressParams = $payment->getExpressCheckoutDetails($this->get('token'));
- $this->_params['payer'] = $expressParams['payer'];
+ $this->_params['payer'] = CRM_Utils_Array::value('payer', $expressParams);
$this->_params['payer_id'] = $expressParams['payer_id'];
$this->_params['payer_status'] = $expressParams['payer_status'];
}
/**
- * Build the form object
+ * Build the form object.
*
* @return void
*/
}
/**
- * Set default values for the form. Note that in edit/view mode
- * the default values are retrieved from the database
+ * Set default values for the form.
*
+ * Note that in edit/view mode
+ * the default values are retrieved from the database
*
* @return void
*/
}
/**
- * Process the form
+ * Process the form.
*
* @return void
*/
}
/**
+ * Wrangle financial type ID.
+ *
* This wrangling of the financialType ID was happening in a shared function rather than in the form it relates to & hence has been moved to that form
* Pledges are not relevant to the membership code so that portion will not go onto the membership form.
*
- * Comments from previous refactor indicate doubt as to what was going on
+ * Comments from previous refactor indicate doubt as to what was going on.
+ *
* @param int $contributionTypeId
*
* @return null|string
}
/**
- * Process the form
+ * Process the form.
*
* @param array $premiumParams
* @param $contribution
- *
- * @return void
*/
public function postProcessPremium($premiumParams, $contribution) {
$hour = $minute = $second = 0;
}
/**
- * Process the contribution
+ * Process the contribution.
*
* @param CRM_Core_Form $form
* @param array $params
}
/**
- * Create the recurring contribution record
+ * Create the recurring contribution record.
*
* @param CRM_Core_Form $form
* @param array $params
}
/**
- * Add on behalf of organization and it's location
+ * Add on behalf of organization and it's location.
*
* @param array $behalfOrganization
* array of organization info.
* form values array.
* @param array $params
* @param null $fields
- *
- * @return void
*/
public static function processOnBehalfOrganization(&$behalfOrganization, &$contactID, &$values, &$params, $fields = NULL) {
$isCurrentEmployer = FALSE;
// create relationship
$relParams['contact_check'][$orgID] = 1;
$cid = array('contact' => $contactID);
- CRM_Contact_BAO_Relationship::createMultiple($relParams, $cid);
+ CRM_Contact_BAO_Relationship::legacyCreateMultiple($relParams, $cid);
// if multiple match - send a duplicate alert
if ($dupeIDs && (count($dupeIDs) > 1)) {
}
/**
- * Function used to save pcp / soft credit entry
+ * Function used to save pcp / soft credit entry.
+ *
* This is used by contribution and also event pcps
*
* @param array $params
* @param object $contribution
* Contribution object.
- *
*/
public static function processPcpSoft(&$params, &$contribution) {
- //add soft contribution due to pcp or Submit Credit / Debit Card Contribution by admin.
+ // Add soft contribution due to pcp or Submit Credit / Debit Card Contribution by admin.
if (!empty($params['soft_credit_to'])) {
$contributionSoftParams = array();
foreach (array(
- 'pcp_display_in_roll',
- 'pcp_roll_nickname',
- 'pcp_personal_note',
- 'amount',
- ) as $val) {
+ 'pcp_display_in_roll',
+ 'pcp_roll_nickname',
+ 'pcp_personal_note',
+ 'amount',
+ ) as $val) {
if (!empty($params[$val])) {
$contributionSoftParams[$val] = $params[$val];
}
$contributionSoftParams['soft_credit_type_id'] = CRM_Core_OptionGroup::getValue('soft_credit_type', 'pcp', 'name');
- CRM_Contribute_BAO_ContributionSoft::add($contributionSoftParams);
+ $contributionSoft = CRM_Contribute_BAO_ContributionSoft::add($contributionSoftParams);
+
+ //Send notification to owner for PCP
+ if ($contributionSoft->id && $contributionSoft->pcp_id) {
+ CRM_Contribute_Form_Contribution_Confirm::pcpNotifyOwner($contribution, $contributionSoft);
+ }
}
}
/**
- * Function used to se pcp related defaults / params
- * This is used by contribution and also event pcps
+ * Function used to send notification mail to pcp owner.
+ *
+ * This is used by contribution and also event PCPs.
+ *
+ * @param object $contribution
+ * @param object $contributionSoft
+ * Contribution object.
+ */
+ public static function pcpNotifyOwner($contribution, $contributionSoft) {
+ $params = array('id' => $contributionSoft->pcp_id);
+ CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCP', $params, $pcpInfo);
+ $ownerNotifyID = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCPBlock', $pcpInfo['pcp_block_id'], 'owner_notify_id');
+
+ if ($ownerNotifyID != CRM_Core_OptionGroup::getValue('pcp_owner_notify', 'no_notifications', 'name') &&
+ (($ownerNotifyID == CRM_Core_OptionGroup::getValue('pcp_owner_notify', 'owner_chooses', 'name') &&
+ CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $contributionSoft->pcp_id, 'is_notify')) ||
+ $ownerNotifyID == CRM_Core_OptionGroup::getValue('pcp_owner_notify', 'all_owners', 'name'))) {
+ $pcpInfoURL = CRM_Utils_System::url('civicrm/pcp/info',
+ "reset=1&id={$contributionSoft->pcp_id}",
+ TRUE, NULL, FALSE, TRUE
+ );
+ // set email in the template here
+ // get the billing location type
+ $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
+ $billingLocationTypeId = array_search('Billing', $locationTypes);
+
+ if ($billingLocationTypeId) {
+ list($donorName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contribution->contact_id, FALSE, $billingLocationTypeId);
+ }
+ // get primary location email if no email exist( for billing location).
+ if (!$email) {
+ list($donorName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contribution->contact_id);
+ }
+ list($ownerName, $ownerEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contributionSoft->contact_id);
+ $tplParams = array(
+ 'page_title' => $pcpInfo['title'],
+ 'receive_date' => $contribution->receive_date,
+ 'total_amount' => $contributionSoft->amount,
+ 'donors_display_name' => $donorName,
+ 'donors_email' => $email,
+ 'pcpInfoURL' => $pcpInfoURL,
+ 'is_honor_roll_enabled' => $contributionSoft->pcp_display_in_roll,
+ );
+ $domainValues = CRM_Core_BAO_Domain::getNameAndEmail();
+ $sendTemplateParams = array(
+ 'groupName' => 'msg_tpl_workflow_contribution',
+ 'valueName' => 'pcp_owner_notify',
+ 'contactId' => $contributionSoft->contact_id,
+ 'toEmail' => $ownerEmail,
+ 'toName' => $ownerName,
+ 'from' => "$domainValues[0] <$domainValues[1]>",
+ 'tplParams' => $tplParams,
+ 'PDFFilename' => 'receipt.pdf',
+ );
+ CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
+ }
+ }
+
+ /**
+ * Function used to se pcp related defaults / params.
+ *
+ * This is used by contribution and also event PCPs
*
* @param CRM_Core_Form $page
* Form object.
}
/**
+ * Process membership.
+ *
* @param array $membershipParams
* @param int $contactID
* @param array $customFieldsFormatted
}
/**
- * Are we going to do 2 financial transactions?
- * ie the membership block supports a separate transactions AND the contribution form has been configured for a contribution
- * transaction AND a membership transaction AND the payment processor supports double financial transactions (ie. NOT doTransferPayment style)
+ * Are we going to do 2 financial transactions.
*
+ * Ie the membership block supports a separate transactions AND the contribution form has been configured for a
+ * contribution
+ * transaction AND a membership transaction AND the payment processor supports double financial transactions (ie. NOT doTransferPayment style)
*
* @param int $formID
* @param bool $amountBlockActiveOnForm
}
/**
- * This function sets the fields
+ * This function sets the fields.
+ *
* - $this->_params['amount_level']
* - $this->_params['selectMembership']
* And under certain circumstances sets
$this->_params['selectMembership'] = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue',
$this->_params["price_{$priceField->id}"], 'membership_type_id');
}
- } // if separate payment we set contribution amount to be null, so that it will not show contribution amount same as membership amount.
+ }
+ // If separate payment we set contribution amount to be null, so that it will not show contribution amount same
+ // as membership amount.
// @todo - this needs more documentation - it appears the setting to null is tied up with separate membership payments
// but the circumstances are very confusing. Many of these conditions are repeated in the next conditional
// so we should merge them together
}
/**
+ * Submit function.
+ *
* @param array $params
*
* @throws CiviCRM_API3_Exception
}
/**
- * Helper function for static submit function - set relevant params - help us to build up an array that we can pass in
+ * Helper function for static submit function - set relevant params - help us to build up an array that we can pass
+ * in.
+ *
* @param int $id
* @param array $params
*