本文整理汇总了PHP中CRM_Pledge_BAO_Pledge::sendAcknowledgment方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Pledge_BAO_Pledge::sendAcknowledgment方法的具体用法?PHP CRM_Pledge_BAO_Pledge::sendAcknowledgment怎么用?PHP CRM_Pledge_BAO_Pledge::sendAcknowledgment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Pledge_BAO_Pledge
的用法示例。
在下文中一共展示了CRM_Pledge_BAO_Pledge::sendAcknowledgment方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processFormContribution
//.........这里部分代码省略.........
if ($isPledge) {
if ($pledgeID) {
//when user doing pledge payments.
//update the schedule when payment(s) are made
$amount = $params['amount'];
$pledgePaymentParams = array();
foreach ($params['pledge_amount'] as $paymentId => $dontCare) {
$scheduledAmount = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_PledgePayment', $paymentId, 'scheduled_amount', 'id');
$pledgePayment = $amount >= $scheduledAmount ? $scheduledAmount : $amount;
if ($pledgePayment > 0) {
$pledgePaymentParams[] = array('id' => $paymentId, 'contribution_id' => $contribution->id, 'status_id' => $contribution->contribution_status_id, 'actual_amount' => $pledgePayment);
$amount -= $pledgePayment;
}
}
if ($amount > 0 && count($pledgePaymentParams)) {
$pledgePaymentParams[count($pledgePaymentParams) - 1]['actual_amount'] += $amount;
}
foreach ($pledgePaymentParams as $p) {
CRM_Pledge_BAO_PledgePayment::add($p);
}
//update pledge status according to the new payment statuses
CRM_Pledge_BAO_PledgePayment::updatePledgePaymentStatus($pledgeID);
} else {
//when user creating pledge record.
$pledgeParams = array();
$pledgeParams['contact_id'] = $contribution->contact_id;
$pledgeParams['installment_amount'] = $pledgeParams['actual_amount'] = $contribution->total_amount;
$pledgeParams['contribution_id'] = $contribution->id;
$pledgeParams['contribution_page_id'] = $contribution->contribution_page_id;
$pledgeParams['financial_type_id'] = $contribution->financial_type_id;
$pledgeParams['frequency_interval'] = $params['pledge_frequency_interval'];
$pledgeParams['installments'] = $params['pledge_installments'];
$pledgeParams['frequency_unit'] = $params['pledge_frequency_unit'];
if ($pledgeParams['frequency_unit'] == 'month') {
$pledgeParams['frequency_day'] = intval(date("d"));
} else {
$pledgeParams['frequency_day'] = 1;
}
$pledgeParams['create_date'] = $pledgeParams['start_date'] = $pledgeParams['scheduled_date'] = date("Ymd");
$pledgeParams['status_id'] = $contribution->contribution_status_id;
$pledgeParams['max_reminders'] = $form->_values['max_reminders'];
$pledgeParams['initial_reminder_day'] = $form->_values['initial_reminder_day'];
$pledgeParams['additional_reminder_day'] = $form->_values['additional_reminder_day'];
$pledgeParams['is_test'] = $contribution->is_test;
$pledgeParams['acknowledge_date'] = date('Ymd');
$pledgeParams['original_installment_amount'] = $pledgeParams['installment_amount'];
//inherit campaign from contirb page.
$pledgeParams['campaign_id'] = CRM_Utils_Array::value('campaign_id', $contributionParams);
$pledge = CRM_Pledge_BAO_Pledge::create($pledgeParams);
$form->_params['pledge_id'] = $pledge->id;
//send acknowledgment email. only when pledge is created
if ($pledge->id) {
//build params to send acknowledgment.
$pledgeParams['id'] = $pledge->id;
$pledgeParams['receipt_from_name'] = $form->_values['receipt_from_name'];
$pledgeParams['receipt_from_email'] = $form->_values['receipt_from_email'];
//scheduled amount will be same as installment_amount.
$pledgeParams['scheduled_amount'] = $pledgeParams['installment_amount'];
//get total pledge amount.
$pledgeParams['total_pledge_amount'] = $pledge->amount;
CRM_Pledge_BAO_Pledge::sendAcknowledgment($form, $pledgeParams);
}
}
}
if ($online && $contribution) {
CRM_Core_BAO_CustomValueTable::postProcess($params, 'civicrm_contribution', $contribution->id, 'Contribution');
} elseif ($contribution) {
//handle custom data.
$params['contribution_id'] = $contribution->id;
if (!empty($params['custom']) && is_array($params['custom']) && !is_a($contribution, 'CRM_Core_Error')) {
CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_contribution', $contribution->id);
}
}
// Save note
if ($contribution && !empty($params['contribution_note'])) {
$noteParams = array('entity_table' => 'civicrm_contribution', 'note' => $params['contribution_note'], 'entity_id' => $contribution->id, 'contact_id' => $contribution->contact_id, 'modified_date' => date('Ymd'));
CRM_Core_BAO_Note::add($noteParams, array());
}
if (isset($params['related_contact'])) {
$contactID = $params['related_contact'];
} elseif (isset($params['cms_contactID'])) {
$contactID = $params['cms_contactID'];
}
//create contribution activity w/ individual and target
//activity w/ organisation contact id when onbelf, CRM-4027
$targetContactID = NULL;
if (!empty($params['hidden_onbehalf_profile'])) {
$targetContactID = $contribution->contact_id;
$contribution->contact_id = $contactID;
}
// create an activity record
if ($contribution) {
CRM_Activity_BAO_Activity::addActivity($contribution, NULL, $targetContactID);
}
$transaction->commit();
// CRM-13074 - create the CMSUser after the transaction is completed as it
// is not appropriate to delete a valid contribution if a user create problem occurs
CRM_Contribute_BAO_Contribution_Utils::createCMSUser($params, $contactID, 'email-' . $billingLocationID);
return $contribution;
}
示例2: processContribution
//.........这里部分代码省略.........
$message = CRM_Core_Error::getMessages($contribution);
CRM_Core_Error::fatal($message);
}
// lets store it in the form variable so postProcess hook can get to this and use it
$form->_contributionID = $contribution->id;
}
//CRM-13981, processing honor contact into soft-credit contribution
CRM_Contact_Form_ProfileContact::postProcess($form);
// process soft credit / pcp pages
CRM_Contribute_Form_Contribution_Confirm::processPcpSoft($params, $contribution);
//handle pledge stuff.
if (empty($form->_params['separate_membership_payment']) && !empty($form->_values['pledge_block_id']) && (!empty($form->_params['is_pledge']) || !empty($form->_values['pledge_id']))) {
if (!empty($form->_values['pledge_id'])) {
//when user doing pledge payments.
//update the schedule when payment(s) are made
foreach ($form->_params['pledge_amount'] as $paymentId => $dontCare) {
$scheduledAmount = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_PledgePayment', $paymentId, 'scheduled_amount', 'id');
$pledgePaymentParams = array('id' => $paymentId, 'contribution_id' => $contribution->id, 'status_id' => $contribution->contribution_status_id, 'actual_amount' => $scheduledAmount);
CRM_Pledge_BAO_PledgePayment::add($pledgePaymentParams);
}
//update pledge status according to the new payment statuses
CRM_Pledge_BAO_PledgePayment::updatePledgePaymentStatus($form->_values['pledge_id']);
} else {
//when user creating pledge record.
$pledgeParams = array();
$pledgeParams['contact_id'] = $contribution->contact_id;
$pledgeParams['installment_amount'] = $pledgeParams['actual_amount'] = $contribution->total_amount;
$pledgeParams['contribution_id'] = $contribution->id;
$pledgeParams['contribution_page_id'] = $contribution->contribution_page_id;
$pledgeParams['financial_type_id'] = $contribution->financial_type_id;
$pledgeParams['frequency_interval'] = $params['pledge_frequency_interval'];
$pledgeParams['installments'] = $params['pledge_installments'];
$pledgeParams['frequency_unit'] = $params['pledge_frequency_unit'];
if ($pledgeParams['frequency_unit'] == 'month') {
$pledgeParams['frequency_day'] = intval(date("d"));
} else {
$pledgeParams['frequency_day'] = 1;
}
$pledgeParams['create_date'] = $pledgeParams['start_date'] = $pledgeParams['scheduled_date'] = date("Ymd");
$pledgeParams['status_id'] = $contribution->contribution_status_id;
$pledgeParams['max_reminders'] = $form->_values['max_reminders'];
$pledgeParams['initial_reminder_day'] = $form->_values['initial_reminder_day'];
$pledgeParams['additional_reminder_day'] = $form->_values['additional_reminder_day'];
$pledgeParams['is_test'] = $contribution->is_test;
$pledgeParams['acknowledge_date'] = date('Ymd');
$pledgeParams['original_installment_amount'] = $pledgeParams['installment_amount'];
//inherit campaign from contirb page.
$pledgeParams['campaign_id'] = $campaignId;
$pledge = CRM_Pledge_BAO_Pledge::create($pledgeParams);
$form->_params['pledge_id'] = $pledge->id;
//send acknowledgment email. only when pledge is created
if ($pledge->id) {
//build params to send acknowledgment.
$pledgeParams['id'] = $pledge->id;
$pledgeParams['receipt_from_name'] = $form->_values['receipt_from_name'];
$pledgeParams['receipt_from_email'] = $form->_values['receipt_from_email'];
//scheduled amount will be same as installment_amount.
$pledgeParams['scheduled_amount'] = $pledgeParams['installment_amount'];
//get total pledge amount.
$pledgeParams['total_pledge_amount'] = $pledge->amount;
CRM_Pledge_BAO_Pledge::sendAcknowledgment($form, $pledgeParams);
}
}
}
if ($online && $contribution) {
CRM_Core_BAO_CustomValueTable::postProcess($form->_params, CRM_Core_DAO::$_nullArray, 'civicrm_contribution', $contribution->id, 'Contribution');
} elseif ($contribution) {
//handle custom data.
$params['contribution_id'] = $contribution->id;
if (!empty($params['custom']) && is_array($params['custom']) && !is_a($contribution, 'CRM_Core_Error')) {
CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_contribution', $contribution->id);
}
}
// Save note
if ($contribution && !empty($params['contribution_note'])) {
$noteParams = array('entity_table' => 'civicrm_contribution', 'note' => $params['contribution_note'], 'entity_id' => $contribution->id, 'contact_id' => $contribution->contact_id, 'modified_date' => date('Ymd'));
CRM_Core_BAO_Note::add($noteParams, array());
}
if (isset($params['related_contact'])) {
$contactID = $params['related_contact'];
} elseif (isset($params['cms_contactID'])) {
$contactID = $params['cms_contactID'];
}
//create contribution activity w/ individual and target
//activity w/ organisation contact id when onbelf, CRM-4027
$targetContactID = NULL;
if (!empty($params['hidden_onbehalf_profile'])) {
$targetContactID = $contribution->contact_id;
$contribution->contact_id = $contactID;
}
// create an activity record
if ($contribution) {
CRM_Activity_BAO_Activity::addActivity($contribution, NULL, $targetContactID);
}
$transaction->commit();
// CRM-13074 - create the CMSUser after the transaction is completed as it
// is not appropriate to delete a valid contribution if a user create problem occurs
CRM_Contribute_BAO_Contribution_Utils::createCMSUser($params, $contactID, 'email-' . $form->_bltID);
return $contribution;
}
示例3: postProcess
/**
* Process the form submission.
*/
public function postProcess()
{
if ($this->_action & CRM_Core_Action::DELETE) {
CRM_Pledge_BAO_Pledge::deletePledge($this->_id);
return;
}
// get the submitted form values.
$formValues = $this->controller->exportValues($this->_name);
// set the contact, when contact is selected
if (!empty($formValues['contact_id'])) {
$this->_contactID = $formValues['contact_id'];
}
$session = CRM_Core_Session::singleton();
// get All Payments status types.
$paymentStatusTypes = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
$fields = array('frequency_unit', 'frequency_interval', 'frequency_day', 'installments', 'financial_type_id', 'initial_reminder_day', 'max_reminders', 'additional_reminder_day', 'contribution_page_id', 'campaign_id');
foreach ($fields as $f) {
$params[$f] = CRM_Utils_Array::value($f, $formValues);
}
// defaults status is "Pending".
// if update get status.
if ($this->_id) {
$params['pledge_status_id'] = $params['status_id'] = $this->_values['status_id'];
} else {
$params['pledge_status_id'] = $params['status_id'] = array_search('Pending', $paymentStatusTypes);
}
// format amount
$params['amount'] = CRM_Utils_Rule::cleanMoney(CRM_Utils_Array::value('amount', $formValues));
$params['currency'] = CRM_Utils_Array::value('currency', $formValues);
$params['original_installment_amount'] = $params['amount'] / $params['installments'];
$dates = array('create_date', 'start_date', 'acknowledge_date', 'cancel_date');
foreach ($dates as $d) {
if ($this->_id && !$this->_isPending && !empty($this->_values[$d])) {
if ($d == 'start_date') {
$params['scheduled_date'] = CRM_Utils_Date::processDate($this->_values[$d]);
}
$params[$d] = CRM_Utils_Date::processDate($this->_values[$d]);
} elseif (!empty($formValues[$d]) && !CRM_Utils_System::isNull($formValues[$d])) {
if ($d == 'start_date') {
$params['scheduled_date'] = CRM_Utils_Date::processDate($formValues[$d]);
}
$params[$d] = CRM_Utils_Date::processDate($formValues[$d]);
} else {
$params[$d] = 'null';
}
}
if (!empty($formValues['is_acknowledge'])) {
$params['acknowledge_date'] = date('Y-m-d');
}
// assign id only in update mode
if ($this->_action & CRM_Core_Action::UPDATE) {
$params['id'] = $this->_id;
}
$params['contact_id'] = $this->_contactID;
// format custom data
if (!empty($formValues['hidden_custom'])) {
$params['hidden_custom'] = 1;
$customFields = CRM_Core_BAO_CustomField::getFields('Pledge');
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($formValues, $this->_id, 'Pledge');
}
// handle pending pledge.
$params['is_pledge_pending'] = $this->_isPending;
// create pledge record.
$pledge = CRM_Pledge_BAO_Pledge::create($params);
$statusMsg = NULL;
if ($pledge->id) {
// set the status msg.
if ($this->_action & CRM_Core_Action::ADD) {
$statusMsg = ts('Pledge has been recorded and the payment schedule has been created.<br />');
} elseif ($this->_action & CRM_Core_Action::UPDATE) {
$statusMsg = ts('Pledge has been updated.<br />');
}
}
// handle Acknowledgment.
if (!empty($formValues['is_acknowledge']) && $pledge->id) {
// calculate scheduled amount.
$params['scheduled_amount'] = round($params['amount'] / $params['installments']);
$params['total_pledge_amount'] = $params['amount'];
// get some required pledge values in params.
$params['id'] = $pledge->id;
$params['acknowledge_date'] = $pledge->acknowledge_date;
$params['is_test'] = $pledge->is_test;
$params['currency'] = $pledge->currency;
// retrieve 'from email id' for acknowledgement
$params['from_email_id'] = $formValues['from_email_address'];
$this->paymentId = NULL;
// send Acknowledgment mail.
CRM_Pledge_BAO_Pledge::sendAcknowledgment($this, $params);
if (!isset($this->userEmail)) {
list($this->userDisplayName, $this->userEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactID);
}
$statusMsg .= ' ' . ts("An acknowledgment email has been sent to %1.<br />", array(1 => $this->userEmail));
// build the payment urls.
if ($this->paymentId) {
$urlParams = "reset=1&action=add&cid={$this->_contactID}&ppid={$this->paymentId}&context=pledge";
$contribURL = CRM_Utils_System::url('civicrm/contact/view/contribution', $urlParams);
$urlParams .= "&mode=live";
//.........这里部分代码省略.........
示例4: processContribution
//.........这里部分代码省略.........
if (CRM_Utils_Array::value('pcp_made_through_id', $params)) {
$contribSoftParams['pcp_id'] = $params['pcp_made_through_id'];
$contribSoftParams['contact_id'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_PCP', $params['pcp_made_through_id'], 'contact_id');
} else {
$contribSoftParams['contact_id'] = CRM_Utils_Array::value('soft_credit_to', $params);
}
$softContribution = CRM_Contribute_BAO_Contribution::addSoftContribution($contribSoftParams);
}
//handle pledge stuff.
if (!CRM_Utils_Array::value('separate_membership_payment', $form->_params) && CRM_Utils_Array::value('pledge_block_id', $form->_values) && (CRM_Utils_Array::value('is_pledge', $form->_params) || CRM_Utils_Array::value('pledge_id', $form->_values))) {
if (CRM_Utils_Array::value('pledge_id', $form->_values)) {
//when user doing pledge payments.
//update the schedule when payment(s) are made
require_once 'CRM/Pledge/BAO/Payment.php';
foreach ($form->_params['pledge_amount'] as $paymentId => $dontCare) {
$pledgePaymentParams = array('id' => $paymentId, 'contribution_id' => $contribution->id, 'status_id' => $contribution->contribution_status_id);
CRM_Pledge_BAO_Payment::add($pledgePaymentParams);
}
//update pledge status according to the new payment statuses
CRM_Pledge_BAO_Payment::updatePledgePaymentStatus($form->_values['pledge_id']);
} else {
//when user creating pledge record.
$pledgeParams = array();
$pledgeParams['contact_id'] = $contribution->contact_id;
$pledgeParams['installment_amount'] = $contribution->total_amount;
$pledgeParams['contribution_id'] = $contribution->id;
$pledgeParams['contribution_page_id'] = $contribution->contribution_page_id;
$pledgeParams['contribution_type_id'] = $contribution->contribution_type_id;
$pledgeParams['frequency_interval'] = $params['pledge_frequency_interval'];
$pledgeParams['installments'] = $params['pledge_installments'];
$pledgeParams['frequency_unit'] = $params['pledge_frequency_unit'];
$pledgeParams['frequency_day'] = 1;
$pledgeParams['create_date'] = $pledgeParams['start_date'] = $pledgeParams['scheduled_date'] = date("Ymd");
$pledgeParams['status_id'] = $contribution->contribution_status_id;
$pledgeParams['max_reminders'] = $form->_values['max_reminders'];
$pledgeParams['initial_reminder_day'] = $form->_values['initial_reminder_day'];
$pledgeParams['additional_reminder_day'] = $form->_values['additional_reminder_day'];
$pledgeParams['is_test'] = $contribution->is_test;
$pledgeParams['acknowledge_date'] = date('Ymd');
require_once 'CRM/Pledge/BAO/Pledge.php';
$pledge = CRM_Pledge_BAO_Pledge::create($pledgeParams);
$form->_params['pledge_id'] = $pledge->id;
//send acknowledgment email. only when pledge is created
if ($pledge->id) {
//build params to send acknowledgment.
$pledgeParams['id'] = $pledge->id;
$pledgeParams['receipt_from_name'] = $form->_values['receipt_from_name'];
$pledgeParams['receipt_from_email'] = $form->_values['receipt_from_email'];
//scheduled amount will be same as installment_amount.
$pledgeParams['scheduled_amount'] = $pledgeParams['installment_amount'];
//get total pledge amount.
$pledgeParams['total_pledge_amount'] = $pledge->amount;
require_once 'CRM/Pledge/BAO/Pledge.php';
CRM_Pledge_BAO_Pledge::sendAcknowledgment($form, $pledgeParams);
}
}
}
if ($online) {
require_once 'CRM/Core/BAO/CustomValueTable.php';
CRM_Core_BAO_CustomValueTable::postProcess($form->_params, CRM_Core_DAO::$_nullArray, 'civicrm_contribution', $contribution->id, 'Contribution');
} else {
//handle custom data.
$params['contribution_id'] = $contribution->id;
if (CRM_Utils_Array::value('custom', $params) && is_array($params['custom']) && !is_a($contribution, 'CRM_Core_Error')) {
require_once 'CRM/Core/BAO/CustomValueTable.php';
CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_contribution', $contribution->id);
}
}
require_once "CRM/Contribute/BAO/Contribution/Utils.php";
if (isset($params['related_contact'])) {
$contactID = $params['related_contact'];
} else {
if (isset($params['cms_contactID'])) {
$contactID = $params['cms_contactID'];
}
}
CRM_Contribute_BAO_Contribution_Utils::createCMSUser($params, $contactID, 'email-' . $form->_bltID);
// return if pending
if ($pending) {
return $contribution;
}
// next create the transaction record
if ((!$online || $form->_values['is_monetary']) && $result['trxn_id']) {
$trxnParams = array('contribution_id' => $contribution->id, 'trxn_date' => $now, 'trxn_type' => 'Debit', 'total_amount' => $params['amount'], 'fee_amount' => CRM_Utils_Array::value('fee_amount', $result), 'net_amount' => CRM_Utils_Array::value('net_amount', $result, $params['amount']), 'currency' => $params['currencyID'], 'payment_processor' => $form->_paymentProcessor['payment_processor_type'], 'trxn_id' => $result['trxn_id'], 'trxn_result_code' => $result['trxn_result_code']);
require_once 'CRM/Contribute/BAO/FinancialTrxn.php';
$trxn =& CRM_Contribute_BAO_FinancialTrxn::create($trxnParams);
}
//create contribution activity w/ individual and target
//activity w/ organisation contact id when onbelf, CRM-4027
$targetContactID = null;
if (CRM_Utils_Array::value('is_for_organization', $params)) {
$targetContactID = $contribution->contact_id;
$contribution->contact_id = $contactID;
}
// create an activity record
require_once 'CRM/Activity/BAO/Activity.php';
CRM_Activity_BAO_Activity::addActivity($contribution, null, $targetContactID);
$transaction->commit();
return $contribution;
}
示例5: processContribution
//.........这里部分代码省略.........
}
} elseif (!CRM_Utils_Array::value('is_quick_config', $form->_params)) {
CRM_Contribute_Form_AdditionalInfo::processPriceSet($contribution->id, $form->_lineItem);
}
if (!$form->_separateMembershipPayment && CRM_Utils_Array::value('is_quick_config', $form->_params)) {
$form->_lineItem = null;
}
}
//handle pledge stuff.
if (!CRM_Utils_Array::value('separate_membership_payment', $form->_params) && CRM_Utils_Array::value('pledge_block_id', $form->_values) && (CRM_Utils_Array::value('is_pledge', $form->_params) || CRM_Utils_Array::value('pledge_id', $form->_values))) {
if (CRM_Utils_Array::value('pledge_id', $form->_values)) {
//when user doing pledge payments.
//update the schedule when payment(s) are made
foreach ($form->_params['pledge_amount'] as $paymentId => $dontCare) {
$scheduledAmount = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_PledgePayment', $paymentId, 'scheduled_amount', 'id');
$pledgePaymentParams = array('id' => $paymentId, 'contribution_id' => $contribution->id, 'status_id' => $contribution->contribution_status_id, 'actual_amount' => $scheduledAmount);
CRM_Pledge_BAO_PledgePayment::add($pledgePaymentParams);
}
//update pledge status according to the new payment statuses
CRM_Pledge_BAO_PledgePayment::updatePledgePaymentStatus($form->_values['pledge_id']);
} else {
//when user creating pledge record.
$pledgeParams = array();
$pledgeParams['contact_id'] = $contribution->contact_id;
$pledgeParams['installment_amount'] = $pledgeParams['actual_amount'] = $contribution->total_amount;
$pledgeParams['contribution_id'] = $contribution->id;
$pledgeParams['contribution_page_id'] = $contribution->contribution_page_id;
$pledgeParams['contribution_type_id'] = $contribution->contribution_type_id;
$pledgeParams['frequency_interval'] = $params['pledge_frequency_interval'];
$pledgeParams['installments'] = $params['pledge_installments'];
$pledgeParams['frequency_unit'] = $params['pledge_frequency_unit'];
if ($pledgeParams['frequency_unit'] == 'month') {
$pledgeParams['frequency_day'] = intval(date("d"));
} else {
$pledgeParams['frequency_day'] = 1;
}
$pledgeParams['create_date'] = $pledgeParams['start_date'] = $pledgeParams['scheduled_date'] = date("Ymd");
$pledgeParams['status_id'] = $contribution->contribution_status_id;
$pledgeParams['max_reminders'] = $form->_values['max_reminders'];
$pledgeParams['initial_reminder_day'] = $form->_values['initial_reminder_day'];
$pledgeParams['additional_reminder_day'] = $form->_values['additional_reminder_day'];
$pledgeParams['is_test'] = $contribution->is_test;
$pledgeParams['acknowledge_date'] = date('Ymd');
$pledgeParams['original_installment_amount'] = $pledgeParams['installment_amount'];
//inherit campaign from contirb page.
$pledgeParams['campaign_id'] = $campaignId;
$pledge = CRM_Pledge_BAO_Pledge::create($pledgeParams);
$form->_params['pledge_id'] = $pledge->id;
//send acknowledgment email. only when pledge is created
if ($pledge->id) {
//build params to send acknowledgment.
$pledgeParams['id'] = $pledge->id;
$pledgeParams['receipt_from_name'] = $form->_values['receipt_from_name'];
$pledgeParams['receipt_from_email'] = $form->_values['receipt_from_email'];
//scheduled amount will be same as installment_amount.
$pledgeParams['scheduled_amount'] = $pledgeParams['installment_amount'];
//get total pledge amount.
$pledgeParams['total_pledge_amount'] = $pledge->amount;
CRM_Pledge_BAO_Pledge::sendAcknowledgment($form, $pledgeParams);
}
}
}
if ($online && $contribution) {
CRM_Core_BAO_CustomValueTable::postProcess($form->_params, CRM_Core_DAO::$_nullArray, 'civicrm_contribution', $contribution->id, 'Contribution');
} elseif ($contribution) {
//handle custom data.
$params['contribution_id'] = $contribution->id;
if (CRM_Utils_Array::value('custom', $params) && is_array($params['custom']) && !is_a($contribution, 'CRM_Core_Error')) {
CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_contribution', $contribution->id);
}
}
if (isset($params['related_contact'])) {
$contactID = $params['related_contact'];
} elseif (isset($params['cms_contactID'])) {
$contactID = $params['cms_contactID'];
}
CRM_Contribute_BAO_Contribution_Utils::createCMSUser($params, $contactID, 'email-' . $form->_bltID);
// return if pending
if ($pending) {
return $contribution;
}
// next create the transaction record
if ($contribution && (!$online || $form->_values['is_monetary']) && $result['trxn_id']) {
$trxnParams = array('contribution_id' => $contribution->id, 'trxn_date' => $now, 'trxn_type' => 'Debit', 'total_amount' => $params['amount'], 'fee_amount' => CRM_Utils_Array::value('fee_amount', $result), 'net_amount' => CRM_Utils_Array::value('net_amount', $result, $params['amount']), 'currency' => $params['currencyID'], 'payment_processor' => $form->_paymentProcessor['payment_processor_type'], 'trxn_id' => $result['trxn_id'], 'trxn_result_code' => isset($result['trxn_result_code']) ? $result['trxn_result_code'] : FALSE);
$trxn = CRM_Core_BAO_FinancialTrxn::create($trxnParams);
}
//create contribution activity w/ individual and target
//activity w/ organisation contact id when onbelf, CRM-4027
$targetContactID = NULL;
if (CRM_Utils_Array::value('hidden_onbehalf_profile', $params)) {
$targetContactID = $contribution->contact_id;
$contribution->contact_id = $contactID;
}
// create an activity record
if ($contribution) {
CRM_Activity_BAO_Activity::addActivity($contribution, NULL, $targetContactID);
}
$transaction->commit();
return $contribution;
}
示例6: processFormContribution
//.........这里部分代码省略.........
$message = CRM_Core_Error::getMessages($contribution);
CRM_Core_Error::fatal($message);
}
// lets store it in the form variable so postProcess hook can get to this and use it
$form->_contributionID = $contribution->id;
}
//CRM-13981, processing honor contact into soft-credit contribution
CRM_Contact_Form_ProfileContact::postProcess($form);
// process soft credit / pcp pages
CRM_Contribute_Form_Contribution_Confirm::processPcpSoft($params, $contribution);
//handle pledge stuff.
if ($isPledge) {
if ($pledgeID) {
//when user doing pledge payments.
//update the schedule when payment(s) are made
foreach ($form->_params['pledge_amount'] as $paymentId => $dontCare) {
$scheduledAmount = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_PledgePayment', $paymentId, 'scheduled_amount', 'id');
$pledgePaymentParams = array('id' => $paymentId, 'contribution_id' => $contribution->id, 'status_id' => $contribution->contribution_status_id, 'actual_amount' => $scheduledAmount);
CRM_Pledge_BAO_PledgePayment::add($pledgePaymentParams);
}
//update pledge status according to the new payment statuses
CRM_Pledge_BAO_PledgePayment::updatePledgePaymentStatus($pledgeID);
} else {
//when user creating pledge record.
$pledgeParams = array();
$pledgeParams['contact_id'] = $contribution->contact_id;
$pledgeParams['installment_amount'] = $pledgeParams['actual_amount'] = $contribution->total_amount;
$pledgeParams['contribution_id'] = $contribution->id;
$pledgeParams['contribution_page_id'] = $contribution->contribution_page_id;
$pledgeParams['financial_type_id'] = $contribution->financial_type_id;
$pledgeParams['frequency_interval'] = $params['pledge_frequency_interval'];
$pledgeParams['installments'] = $params['pledge_installments'];
$pledgeParams['frequency_unit'] = $params['pledge_frequency_unit'];
if ($pledgeParams['frequency_unit'] == 'month') {
$pledgeParams['frequency_day'] = intval(date("d"));
} else {
$pledgeParams['frequency_day'] = 1;
}
$pledgeParams['create_date'] = $pledgeParams['start_date'] = $pledgeParams['scheduled_date'] = date("Ymd");
$pledgeParams['status_id'] = $contribution->contribution_status_id;
$pledgeParams['max_reminders'] = $form->_values['max_reminders'];
$pledgeParams['initial_reminder_day'] = $form->_values['initial_reminder_day'];
$pledgeParams['additional_reminder_day'] = $form->_values['additional_reminder_day'];
$pledgeParams['is_test'] = $contribution->is_test;
$pledgeParams['acknowledge_date'] = date('Ymd');
$pledgeParams['original_installment_amount'] = $pledgeParams['installment_amount'];
//inherit campaign from contirb page.
$pledgeParams['campaign_id'] = $campaignId;
$pledge = CRM_Pledge_BAO_Pledge::create($pledgeParams);
$form->_params['pledge_id'] = $pledge->id;
//send acknowledgment email. only when pledge is created
if ($pledge->id) {
//build params to send acknowledgment.
$pledgeParams['id'] = $pledge->id;
$pledgeParams['receipt_from_name'] = $form->_values['receipt_from_name'];
$pledgeParams['receipt_from_email'] = $form->_values['receipt_from_email'];
//scheduled amount will be same as installment_amount.
$pledgeParams['scheduled_amount'] = $pledgeParams['installment_amount'];
//get total pledge amount.
$pledgeParams['total_pledge_amount'] = $pledge->amount;
CRM_Pledge_BAO_Pledge::sendAcknowledgment($form, $pledgeParams);
}
}
}
if ($online && $contribution) {
CRM_Core_BAO_CustomValueTable::postProcess($form->_params, 'civicrm_contribution', $contribution->id, 'Contribution');
} elseif ($contribution) {
//handle custom data.
$params['contribution_id'] = $contribution->id;
if (!empty($params['custom']) && is_array($params['custom']) && !is_a($contribution, 'CRM_Core_Error')) {
CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_contribution', $contribution->id);
}
}
// Save note
if ($contribution && !empty($params['contribution_note'])) {
$noteParams = array('entity_table' => 'civicrm_contribution', 'note' => $params['contribution_note'], 'entity_id' => $contribution->id, 'contact_id' => $contribution->contact_id, 'modified_date' => date('Ymd'));
CRM_Core_BAO_Note::add($noteParams, array());
}
if (isset($params['related_contact'])) {
$contactID = $params['related_contact'];
} elseif (isset($params['cms_contactID'])) {
$contactID = $params['cms_contactID'];
}
//create contribution activity w/ individual and target
//activity w/ organisation contact id when onbelf, CRM-4027
$targetContactID = NULL;
if (!empty($params['hidden_onbehalf_profile'])) {
$targetContactID = $contribution->contact_id;
$contribution->contact_id = $contactID;
}
// create an activity record
if ($contribution) {
CRM_Activity_BAO_Activity::addActivity($contribution, NULL, $targetContactID);
}
$transaction->commit();
// CRM-13074 - create the CMSUser after the transaction is completed as it
// is not appropriate to delete a valid contribution if a user create problem occurs
CRM_Contribute_BAO_Contribution_Utils::createCMSUser($params, $contactID, 'email-' . $billingLocationID);
return $contribution;
}