本文整理汇总了PHP中CRM_Pledge_BAO_PledgePayment::add方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Pledge_BAO_PledgePayment::add方法的具体用法?PHP CRM_Pledge_BAO_PledgePayment::add怎么用?PHP CRM_Pledge_BAO_PledgePayment::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Pledge_BAO_PledgePayment
的用法示例。
在下文中一共展示了CRM_Pledge_BAO_PledgePayment::add方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: civicrm_api3_pledge_payment_create
/**
* Add or update a plege payment. Pledge Payment API doesn't actually add a pledge
* if the request is to 'create' and 'id' is not passed in
* the oldest pledge with no associated contribution is updated
*
* @todo possibly add ability to add payment if there are less payments than pledge installments
* @todo possibily add ability to recalc dates if the schedule is changed
*
* @param array $params input parameters
* {@getfields PledgePayment_create}
* @example PledgePaymentCreate.php
*
* @return array API Result
* @static void
* @access public
*/
function civicrm_api3_pledge_payment_create($params)
{
$paymentParams = $params;
if (empty($params['id']) && !CRM_Utils_Array::value('option.create_new', $params)) {
$paymentDetails = CRM_Pledge_BAO_PledgePayment::getOldestPledgePayment($params['pledge_id']);
if (empty($paymentDetails)) {
return civicrm_api3_create_error("There are no unmatched payment on this pledge. Pass in the pledge_payment id to specify one or 'option.create_new' to create one");
} elseif (is_array($paymentDetails)) {
$paymentParams = array_merge($params, $paymentDetails);
}
}
$dao = CRM_Pledge_BAO_PledgePayment::add($paymentParams);
_civicrm_api3_object_to_array($dao, $result[$dao->id]);
//update pledge status
CRM_Pledge_BAO_PledgePayment::updatePledgePaymentStatus($params['pledge_id']);
return civicrm_api3_create_success($result, $params, 'pledge_payment', 'create', $dao);
}
示例2: testAdd
/**
* Test for Add/Update Pledge Payment.
*/
function testAdd()
{
$pledge = CRM_Core_DAO::createTestObject('CRM_Pledge_BAO_Pledge');
$params = array('pledge_id' => $pledge->id, 'scheduled_amount' => 100.55, 'currency' => 'USD', 'scheduled_date' => '20100512000000', 'reminder_date' => '20100520000000', 'reminder_count' => 5, 'status_id' => 1);
//do test for normal add.
$payment = CRM_Pledge_BAO_PledgePayment::add($params);
foreach ($params as $param => $value) {
$this->assertEquals($value, $payment->{$param});
}
//do test for update mode.
$params = array('id' => $payment->id, 'pledge_id' => $pledge->id, 'scheduled_amount' => 55.55, 'currency' => 'USD', 'scheduled_date' => '20100415000000', 'reminder_date' => '20100425000000', 'reminder_count' => 10, 'status_id' => 2);
$payment = CRM_Pledge_BAO_PledgePayment::add($params);
foreach ($params as $param => $value) {
$this->assertEquals($value, $payment->{$param});
}
$result = CRM_Pledge_BAO_Pledge::deletePledge($pledge->id);
}
示例3: updateRecurLinkedPledge
function updateRecurLinkedPledge(&$contribution)
{
$returnProperties = array('id', 'pledge_id');
$paymentDetails = $paymentIDs = array();
if (CRM_Core_DAO::commonRetrieveAll('CRM_Pledge_DAO_PledgePayment', 'contribution_id', $contribution->id, $paymentDetails, $returnProperties)) {
foreach ($paymentDetails as $key => $value) {
$paymentIDs[] = $value['id'];
$pledgeId = $value['pledge_id'];
}
} else {
//payment is not already linked - if it is linked with a pledge we need to create a link.
// return if it is not recurring contribution
if (!$contribution->contribution_recur_id) {
return;
}
$relatedContributions = new CRM_Contribute_DAO_Contribution();
$relatedContributions->contribution_recur_id = $contribution->contribution_recur_id;
$relatedContributions->find();
while ($relatedContributions->fetch()) {
CRM_Core_DAO::commonRetrieveAll('CRM_Pledge_DAO_PledgePayment', 'contribution_id', $relatedContributions->id, $paymentDetails, $returnProperties);
}
if (empty($paymentDetails)) {
// payment is not linked with a pledge and neither are any other contributions on this
return;
}
foreach ($paymentDetails as $key => $value) {
$pledgeId = $value['pledge_id'];
}
// we have a pledge now we need to get the oldest unpaid payment
$paymentDetails = CRM_Pledge_BAO_PledgePayment::getOldestPledgePayment($pledgeId);
if (empty($paymentDetails['id'])) {
// we can assume this pledge is now completed
// return now so we don't create a core error & roll back
return;
}
$paymentDetails['contribution_id'] = $contribution->id;
$paymentDetails['status_id'] = $contribution->contribution_status_id;
$paymentDetails['actual_amount'] = $contribution->total_amount;
// put contribution against it
$payment = CRM_Pledge_BAO_PledgePayment::add($paymentDetails);
$paymentIDs[] = $payment->id;
}
// update pledge and corresponding payment statuses
CRM_Pledge_BAO_PledgePayment::updatePledgePaymentStatus($pledgeId, $paymentIDs, $contribution->contribution_status_id, NULL, $contribution->total_amount);
}
示例4: processFormContribution
/**
* Process the contribution.
*
* @param CRM_Core_Form $form
* @param array $params
* @param array $result
* @param array $contributionParams
* Parameters to be passed to contribution create action.
* This differs from params in that we are currently adding params to it and 1) ensuring they are being
* passed consistently & 2) documenting them here.
* - contact_id
* - line_item
* - is_test
* - campaign_id
* - contribution_page_id
* - source
* - payment_type_id
* - thankyou_date (not all forms will set this)
*
* @param CRM_Financial_DAO_FinancialType $financialType
* @param bool $online
* Is the form a front end form? If so set a bunch of unpredictable things that should be passed in from the form.
*
* @param int $billingLocationID
* ID of billing location type.
* @param bool $isRecur
* Is this recurring?
*
* @return \CRM_Contribute_DAO_Contribution
* @throws \Exception
*/
public static function processFormContribution(&$form, $params, $result, $contributionParams, $financialType, $online, $billingLocationID, $isRecur)
{
$transaction = new CRM_Core_Transaction();
$contactID = $contributionParams['contact_id'];
$isEmailReceipt = !empty($form->_values['is_email_receipt']);
$isSeparateMembershipPayment = empty($params['separate_membership_payment']) ? FALSE : TRUE;
$pledgeID = !empty($params['pledge_id']) ? $params['pledge_id'] : CRM_Utils_Array::value('pledge_id', $form->_values);
if (!$isSeparateMembershipPayment && !empty($form->_values['pledge_block_id']) && (!empty($params['is_pledge']) || $pledgeID)) {
$isPledge = TRUE;
} else {
$isPledge = FALSE;
}
// add these values for the recurringContrib function ,CRM-10188
$params['financial_type_id'] = $financialType->id;
$contributionParams['address_id'] = CRM_Contribute_BAO_Contribution::createAddress($params, $billingLocationID);
//@todo - this is being set from the form to resolve CRM-10188 - an
// eNotice caused by it not being set @ the front end
// however, we then get it being over-written with null for backend contributions
// a better fix would be to set the values in the respective forms rather than require
// a function being shared by two forms to deal with their respective values
// moving it to the BAO & not taking the $form as a param would make sense here.
if (!isset($params['is_email_receipt']) && $isEmailReceipt) {
$params['is_email_receipt'] = $isEmailReceipt;
}
$params['is_recur'] = $isRecur;
$recurringContributionID = self::processRecurringContribution($form, $params, $contactID, $financialType);
$nonDeductibleAmount = self::getNonDeductibleAmount($params, $financialType, $online);
$now = date('YmdHis');
$receiptDate = CRM_Utils_Array::value('receipt_date', $params);
if ($isEmailReceipt) {
$receiptDate = $now;
}
if (isset($params['amount'])) {
$contributionParams = array_merge(self::getContributionParams($params, $financialType->id, $nonDeductibleAmount, TRUE, $result, $receiptDate, $recurringContributionID), $contributionParams);
$contribution = CRM_Contribute_BAO_Contribution::add($contributionParams);
$invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
$invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
if ($invoicing) {
$dataArray = array();
// @todo - interrogate the line items passed in on the params array.
// No reason to assume line items will be set on the form.
foreach ($form->_lineItem as $lineItemKey => $lineItemValue) {
foreach ($lineItemValue as $key => $value) {
if (isset($value['tax_amount']) && isset($value['tax_rate'])) {
if (isset($dataArray[$value['tax_rate']])) {
$dataArray[$value['tax_rate']] = $dataArray[$value['tax_rate']] + CRM_Utils_Array::value('tax_amount', $value);
} else {
$dataArray[$value['tax_rate']] = CRM_Utils_Array::value('tax_amount', $value);
}
}
}
}
$smarty = CRM_Core_Smarty::singleton();
$smarty->assign('dataArray', $dataArray);
$smarty->assign('totalTaxAmount', $params['tax_amount']);
}
if (is_a($contribution, 'CRM_Core_Error')) {
$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;
}
// process soft credit / pcp params first
CRM_Contribute_BAO_ContributionSoft::formatSoftCreditParams($params, $form);
//CRM-13981, processing honor contact into soft-credit contribution
CRM_Contribute_BAO_ContributionSoft::processSoftContribution($params, $contribution);
//handle pledge stuff.
if ($isPledge) {
//.........这里部分代码省略.........
示例5: processContribution
//.........这里部分代码省略.........
$campaignId = CRM_Utils_Array::value('campaign_id', $params);
}
// first create the contribution record
$contribParams = array('contact_id' => $contactID, 'financial_type_id' => $contributionType->id, 'contribution_page_id' => $contributionPageId, 'receive_date' => CRM_Utils_Array::value('receive_date', $params) ? CRM_Utils_Date::processDate($params['receive_date']) : date('YmdHis'), 'non_deductible_amount' => $nonDeductibleAmount, 'total_amount' => $params['amount'], 'amount_level' => CRM_Utils_Array::value('amount_level', $params), 'invoice_id' => $params['invoiceID'], 'currency' => $params['currencyID'], 'source' => !$online || !empty($params['source']) ? CRM_Utils_Array::value('source', $params) : CRM_Utils_Array::value('description', $params), 'is_pay_later' => CRM_Utils_Array::value('is_pay_later', $params, 0), 'cancel_reason' => CRM_Utils_Array::value('cancel_reason', $params, 0), 'cancel_date' => isset($params['cancel_date']) ? CRM_Utils_Date::format($params['cancel_date']) : NULL, 'thankyou_date' => isset($params['thankyou_date']) ? CRM_Utils_Date::format($params['thankyou_date']) : NULL, 'campaign_id' => $campaignId);
if (!$online && isset($params['thankyou_date'])) {
$contribParams['thankyou_date'] = $params['thankyou_date'];
}
if (!$online || $form->_values['is_monetary']) {
if (empty($params['is_pay_later'])) {
$contribParams['payment_instrument_id'] = 1;
}
}
if (!$pending && $result) {
$contribParams += array('fee_amount' => CRM_Utils_Array::value('fee_amount', $result), 'net_amount' => CRM_Utils_Array::value('net_amount', $result, $params['amount']), 'trxn_id' => $result['trxn_id'], 'receipt_date' => $receiptDate, 'trxn_result_code' => CRM_Utils_Array::value('trxn_result_code', $result), 'payment_processor' => CRM_Utils_Array::value('payment_processor', $result));
}
if ($recurringContributionID) {
$contribParams['contribution_recur_id'] = $recurringContributionID;
}
$contribParams['contribution_status_id'] = $pending ? 2 : 1;
$contribParams['is_test'] = 0;
if ($form->_mode == 'test') {
$contribParams['is_test'] = 1;
}
$ids = array();
if (isset($contribParams['invoice_id'])) {
$contribID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contribParams['invoice_id'], 'id', 'invoice_id');
if (isset($contribID)) {
$ids['contribution'] = $contribID;
$contribParams['id'] = $contribID;
}
}
//create an contribution address
if ($form->_contributeMode != 'notify' && empty($params['is_pay_later']) && !empty($form->_values['is_monetary'])) {
$contribParams['address_id'] = CRM_Contribute_BAO_Contribution::createAddress($params, $form->_bltID);
}
// CRM-4038: for non-en_US locales, CRM_Contribute_BAO_Contribution::add() expects localised amounts
$contribParams['non_deductible_amount'] = trim(CRM_Utils_Money::format($contribParams['non_deductible_amount'], ' '));
$contribParams['total_amount'] = trim(CRM_Utils_Money::format($contribParams['total_amount'], ' '));
// Prepare soft contribution due to pcp or Submit Credit / Debit Card Contribution by admin.
if (!empty($params['pcp_made_through_id']) || !empty($params['soft_credit_to'])) {
// if its due to pcp
if (!empty($params['pcp_made_through_id'])) {
$contribSoftContactId = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $params['pcp_made_through_id'], 'contact_id');
} else {
$contribSoftContactId = CRM_Utils_Array::value('soft_credit_to', $params);
}
// Pass these details onto with the contribution to make them
// available at hook_post_process, CRM-8908
$contribParams['soft_credit_to'] = $params['soft_credit_to'] = $contribSoftContactId;
}
if (isset($params['amount'])) {
$contribParams['line_item'] = $form->_lineItem;
//add contribution record
$contribution = CRM_Contribute_BAO_Contribution::add($contribParams, $ids);
if (is_a($contribution, 'CRM_Core_Error')) {
$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.
示例6: postProcess
/**
* Process the form submission.
*
*
* @return void
*/
public function postProcess()
{
//get the submitted form values.
$formValues = $this->controller->exportValues($this->_name);
$params = array();
$formValues['scheduled_date'] = CRM_Utils_Date::processDate($formValues['scheduled_date']);
$params['scheduled_date'] = CRM_Utils_Date::format($formValues['scheduled_date']);
$params['currency'] = CRM_Utils_Array::value('currency', $formValues);
$now = date('Ymd');
$contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
if (CRM_Utils_Date::overdue(CRM_Utils_Date::customFormat($params['scheduled_date'], '%Y%m%d'), $now)) {
$params['status_id'] = array_search('Overdue', $contributionStatus);
} else {
$params['status_id'] = array_search('Pending', $contributionStatus);
}
$params['id'] = $this->_id;
$pledgeId = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_PledgePayment', $params['id'], 'pledge_id');
CRM_Pledge_BAO_PledgePayment::add($params);
$adjustTotalAmount = FALSE;
if (CRM_Utils_Array::value('option_type', $formValues) == 2) {
$adjustTotalAmount = TRUE;
}
$pledgeScheduledAmount = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_PledgePayment', $params['id'], 'scheduled_amount', 'id');
$oldestPaymentAmount = CRM_Pledge_BAO_PledgePayment::getOldestPledgePayment($pledgeId, 2);
if ($oldestPaymentAmount['count'] != 1 && $oldestPaymentAmount['id'] == $params['id']) {
$oldestPaymentAmount = CRM_Pledge_BAO_PledgePayment::getOldestPledgePayment($pledgeId);
}
if ($formValues['scheduled_amount'] - $pledgeScheduledAmount >= $oldestPaymentAmount['amount']) {
$adjustTotalAmount = TRUE;
}
//update pledge status
CRM_Pledge_BAO_PledgePayment::updatePledgePaymentStatus($pledgeId, array($params['id']), $params['status_id'], NULL, $formValues['scheduled_amount'], $adjustTotalAmount);
$statusMsg = ts('Pledge Payment Schedule has been updated.');
CRM_Core_Session::setStatus($statusMsg, ts('Saved'), 'success');
}
示例7: _civicrm_initialize
/**
* Add or update a plege payment
*
* @param array $params (reference ) input parameters
*
* @return array (reference ) pledge_id of created or updated record
* @static void
* @access public
*/
function &civicrm_pledge_payment_create(&$params)
{
_civicrm_initialize();
//GAP - update doesn't recalculate payment dates on existing payment schedule - not the sure the code is in Civi to leverage
if (empty($params)) {
return civicrm_create_error(ts('No input parameters present'));
}
if (!is_array($params)) {
return civicrm_create_error(ts('Input parameters is not an array'));
}
$error = _civicrm_pledgepayment_check_params($params);
if (civicrm_error($error)) {
return $error;
}
$values = array();
require_once 'CRM/Pledge/BAO/PledgePayment.php';
$error = _civicrm_pledgepayment_format_params($params, $values);
if (civicrm_error($error)) {
return $error;
}
$pledge = CRM_Pledge_BAO_PledgePayment::getOldestPledgePayment($params['pledge_id']);
$params['id'] = $pledge['id'];
//params ID needs to be pledge payment ID
// pledge payment isn't retrieved if only one exists - the status is not set correctly causing this so let's get it for now as a cludgey make it work
// copied from getOldestPayment function
if (!$params['id']) {
$query = "\nSELECT civicrm_pledge_payment.id id, civicrm_pledge_payment.scheduled_amount amount\nFROM civicrm_pledge, civicrm_pledge_payment\nWHERE civicrm_pledge.id = civicrm_pledge_payment.pledge_id\n AND civicrm_pledge.id = %1\nLIMIT 0, 1 \n";
$params[1] = array($params['pledge_id'], 'Integer');
$payment = CRM_Core_DAO::executeQuery($query, $params);
$paymentDetails = NULL;
if ($payment->fetch()) {
$params['id'] = $payment->id;
}
}
CRM_Pledge_BAO_PledgePayment::add($params);
//update pledge status
CRM_Pledge_BAO_PledgePayment::updatePledgePaymentStatus($params['pledge_id']);
return $errors;
}
示例8: processContribution
/**
* Process the contribution
*
* @return void
* @access public
*/
static function processContribution(&$form, $params, $result, $contactID, $contributionType, $deductibleMode = TRUE, $pending = FALSE, $online = TRUE)
{
$transaction = new CRM_Core_Transaction();
$className = get_class($form);
$honorCId = $recurringContributionID = NULL;
if ($online && $form->get('honor_block_is_active')) {
$honorCId = $form->createHonorContact();
}
// add these values for the recurringContrib function ,CRM-10188
$params['contribution_type_id'] = $contributionType->id;
$params['is_email_receipt'] = CRM_Utils_Array::value('is_email_receipt', $form->_values);
$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();
if (!$online && isset($params['non_deductible_amount'])) {
$nonDeductibleAmount = $params['non_deductible_amount'];
} else {
$nonDeductibleAmount = $params['amount'];
}
if ($online && $contributionType->is_deductible && $deductibleMode) {
$selectProduct = CRM_Utils_Array::value('selectProduct', $params);
if ($selectProduct && $selectProduct != 'no_thanks') {
$productDAO = new CRM_Contribute_DAO_Product();
$productDAO->id = $selectProduct;
$productDAO->find(TRUE);
if ($params['amount'] < $productDAO->price) {
$nonDeductibleAmount = $params['amount'];
} else {
$nonDeductibleAmount = $productDAO->price;
}
} else {
$nonDeductibleAmount = '0.00';
}
}
$now = date('YmdHis');
$receiptDate = CRM_Utils_Array::value('receipt_date', $params);
if (CRM_Utils_Array::value('is_email_receipt', $form->_values)) {
$receiptDate = $now;
}
//get the contrib page id.
$campaignId = $contributionPageId = NULL;
if ($online) {
$contributionPageId = $form->_id;
$campaignId = CRM_Utils_Array::value('campaign_id', $params);
if (!array_key_exists('campaign_id', $params)) {
$campaignId = CRM_Utils_Array::value('campaign_id', $form->_values);
}
} else {
//also for offline we do support - CRM-7290
$contributionPageId = CRM_Utils_Array::value('contribution_page_id', $params);
$campaignId = CRM_Utils_Array::value('campaign_id', $params);
}
// first create the contribution record
$contribParams = array('contact_id' => $contactID, 'contribution_type_id' => $contributionType->id, 'contribution_page_id' => $contributionPageId, 'receive_date' => CRM_Utils_Array::value('receive_date', $params) ? CRM_Utils_Date::processDate($params['receive_date']) : date('YmdHis'), 'non_deductible_amount' => $nonDeductibleAmount, 'total_amount' => $params['amount'], 'amount_level' => CRM_Utils_Array::value('amount_level', $params), 'invoice_id' => $params['invoiceID'], 'currency' => $params['currencyID'], 'source' => !$online || CRM_Utils_Array::value('source', $params) ? CRM_Utils_Array::value('source', $params) : CRM_Utils_Array::value('description', $params), 'is_pay_later' => CRM_Utils_Array::value('is_pay_later', $params, 0), 'cancel_reason' => CRM_Utils_Array::value('cancel_reason', $params, 0), 'cancel_date' => isset($params['cancel_date']) ? CRM_Utils_Date::format($params['cancel_date']) : NULL, 'thankyou_date' => isset($params['thankyou_date']) ? CRM_Utils_Date::format($params['thankyou_date']) : NULL, 'campaign_id' => $campaignId);
if (!$online && isset($params['thankyou_date'])) {
$contribParams['thankyou_date'] = $params['thankyou_date'];
}
if (!$online || $form->_values['is_monetary']) {
if (!CRM_Utils_Array::value('is_pay_later', $params)) {
$contribParams['payment_instrument_id'] = 1;
}
}
if (!$pending && $result) {
$contribParams += array('fee_amount' => CRM_Utils_Array::value('fee_amount', $result), 'net_amount' => CRM_Utils_Array::value('net_amount', $result, $params['amount']), 'trxn_id' => $result['trxn_id'], 'receipt_date' => $receiptDate, 'trxn_result_code' => CRM_Utils_Array::value('trxn_result_code', $result), 'payment_processor' => CRM_Utils_Array::value('payment_processor', $result));
}
if (isset($honorCId)) {
$contribParams['honor_contact_id'] = $honorCId;
$contribParams['honor_type_id'] = $params['honor_type_id'];
}
if ($recurringContributionID) {
$contribParams['contribution_recur_id'] = $recurringContributionID;
}
$contribParams['contribution_status_id'] = $pending ? 2 : 1;
$contribParams['is_test'] = 0;
if ($form->_mode == 'test') {
$contribParams['is_test'] = 1;
}
$ids = array();
if (isset($contribParams['invoice_id'])) {
$contribID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contribParams['invoice_id'], 'id', 'invoice_id');
if (isset($contribID)) {
$ids['contribution'] = $contribID;
$contribParams['id'] = $contribID;
}
}
//create an contribution address
if ($form->_contributeMode != 'notify' && !CRM_Utils_Array::value('is_pay_later', $params) && CRM_Utils_Array::value('is_monetary', $form->_values)) {
$contribParams['address_id'] = CRM_Contribute_BAO_Contribution::createAddress($params, $form->_bltID);
}
// CRM-4038: for non-en_US locales, CRM_Contribute_BAO_Contribution::add() expects localised amounts
$contribParams['non_deductible_amount'] = trim(CRM_Utils_Money::format($contribParams['non_deductible_amount'], ' '));
$contribParams['total_amount'] = trim(CRM_Utils_Money::format($contribParams['total_amount'], ' '));
//.........这里部分代码省略.........
示例9: processFormContribution
/**
* Process the contribution.
*
* @param CRM_Core_Form $form
* @param array $params
* @param array $result
* @param int $contactID
* @param CRM_Financial_DAO_FinancialType $financialType
* @param bool $pending
* @param bool $online
*
* @param bool $isTest
* @param array $lineItems
*
* @param int $billingLocationID
* ID of billing location type.
*
* @return \CRM_Contribute_DAO_Contribution
* @throws \Exception
*/
public static function processFormContribution(&$form, $params, $result, $contactID, $financialType, $pending, $online, $isTest, $lineItems, $billingLocationID)
{
$transaction = new CRM_Core_Transaction();
$contribSoftContactId = $addressID = NULL;
$contributeMode = $form->_contributeMode;
$isMonetary = !empty($form->_values['is_monetary']);
$isEmailReceipt = !empty($form->_values['is_email_receipt']);
// How do these vary from params? These are currently passed to
// - custom data function....
$formParams = $form->_params;
$isSeparateMembershipPayment = empty($formParams['separate_membership_payment']) ? FALSE : TRUE;
$pledgeID = empty($formParams['pledge_id']) ? NULL : $formParams['pledge_id'];
if (!$isSeparateMembershipPayment && !empty($form->_values['pledge_block_id']) && (!empty($formParams['is_pledge']) || $pledgeID)) {
$isPledge = TRUE;
} else {
$isPledge = FALSE;
}
// add these values for the recurringContrib function ,CRM-10188
$params['financial_type_id'] = $financialType->id;
//create an contribution address
if ($contributeMode != 'notify' && empty($params['is_pay_later']) && $isMonetary) {
$addressID = CRM_Contribute_BAO_Contribution::createAddress($params, $billingLocationID);
}
//@todo - this is being set from the form to resolve CRM-10188 - an
// eNotice caused by it not being set @ the front end
// however, we then get it being over-written with null for backend contributions
// a better fix would be to set the values in the respective forms rather than require
// a function being shared by two forms to deal with their respective values
// moving it to the BAO & not taking the $form as a param would make sense here.
if (!isset($params['is_email_receipt']) && $isEmailReceipt) {
$params['is_email_receipt'] = $isEmailReceipt;
}
$recurringContributionID = self::processRecurringContribution($form, $params, $contactID, $financialType, $online);
$nonDeductibleAmount = self::getNonDeductibleAmount($params, $financialType, $online);
$now = date('YmdHis');
$receiptDate = CRM_Utils_Array::value('receipt_date', $params);
if ($isEmailReceipt) {
$receiptDate = $now;
}
//get the contrib page id.
$contributionPageId = NULL;
if ($online) {
$contributionPageId = $form->_id;
$campaignId = CRM_Utils_Array::value('campaign_id', $params);
if (!array_key_exists('campaign_id', $params)) {
$campaignId = CRM_Utils_Array::value('campaign_id', $form->_values);
}
} else {
//also for offline we do support - CRM-7290
$contributionPageId = CRM_Utils_Array::value('contribution_page_id', $params);
$campaignId = CRM_Utils_Array::value('campaign_id', $params);
}
// Prepare soft contribution due to pcp or Submit Credit / Debit Card Contribution by admin.
if (!empty($params['pcp_made_through_id']) || !empty($params['soft_credit_to'])) {
// if its due to pcp
if (!empty($params['pcp_made_through_id'])) {
$contribSoftContactId = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $params['pcp_made_through_id'], 'contact_id');
} else {
$contribSoftContactId = CRM_Utils_Array::value('soft_credit_to', $params);
}
// Pass these details onto with the contribution to make them
// available at hook_post_process, CRM-8908
$params['soft_credit_to'] = $contribSoftContactId;
}
if (isset($params['amount'])) {
$contribParams = self::getContributionParams($params, $contactID, $financialType->id, $online, $contributionPageId, $nonDeductibleAmount, $campaignId, $isMonetary, $pending, $result, $receiptDate, $recurringContributionID, $isTest, $addressID, $contribSoftContactId, $lineItems);
$contribution = CRM_Contribute_BAO_Contribution::add($contribParams);
$invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
$invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
if ($invoicing) {
$dataArray = array();
foreach ($form->_lineItem as $lineItemKey => $lineItemValue) {
foreach ($lineItemValue as $key => $value) {
if (isset($value['tax_amount']) && isset($value['tax_rate'])) {
if (isset($dataArray[$value['tax_rate']])) {
$dataArray[$value['tax_rate']] = $dataArray[$value['tax_rate']] + CRM_Utils_Array::value('tax_amount', $value);
} else {
$dataArray[$value['tax_rate']] = CRM_Utils_Array::value('tax_amount', $value);
}
}
//.........这里部分代码省略.........