本文整理汇总了PHP中CRM_Contribute_BAO_ContributionSoft::del方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contribute_BAO_ContributionSoft::del方法的具体用法?PHP CRM_Contribute_BAO_ContributionSoft::del怎么用?PHP CRM_Contribute_BAO_ContributionSoft::del使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contribute_BAO_ContributionSoft
的用法示例。
在下文中一共展示了CRM_Contribute_BAO_ContributionSoft::del方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: civicrm_api3_contribution_soft_delete
/**
* Deletes an existing Soft Credit.
*
* @param array $params
*/
function civicrm_api3_contribution_soft_delete($params)
{
// Non standard BAO - we have to write custom code to cope.
$result = CRM_Contribute_BAO_ContributionSoft::del(array('id' => $params['id']));
if (!$result) {
throw new API_Exception('Cannot delete contributionSoft ' . $params['id']);
}
civicrm_api3_create_success(TRUE);
}
示例2: submit
/**
* @param array $submittedValues
*
* @param int $action
* Action constant
* - CRM_Core_Action::UPDATE
*
* @param $pledgePaymentID
*
* @return array
* @throws \Exception
*/
protected function submit($submittedValues, $action, $pledgePaymentID)
{
$softParams = $softIDs = array();
$pId = $contribution = $isRelatedId = FALSE;
$this->_params = $submittedValues;
$this->beginPostProcess();
if (!empty($submittedValues['price_set_id']) && $action & CRM_Core_Action::UPDATE) {
$line = CRM_Price_BAO_LineItem::getLineItems($this->_id, 'contribution');
$lineID = key($line);
$priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', CRM_Utils_Array::value('price_field_id', $line[$lineID]), 'price_set_id');
$quickConfig = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'is_quick_config');
// Why do we do this? Seems like a like a wrapper for old functionality - but single line price sets & quick
// config should be treated the same.
if ($quickConfig) {
CRM_Price_BAO_LineItem::deleteLineItems($this->_id, 'civicrm_contribution');
}
}
// Process price set and get total amount and line items.
$lineItem = array();
$priceSetId = CRM_Utils_Array::value('price_set_id', $submittedValues);
if (empty($priceSetId) && !$this->_id) {
$this->_priceSetId = $priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', 'default_contribution_amount', 'id', 'name');
$this->_priceSet = current(CRM_Price_BAO_PriceSet::getSetDetail($priceSetId));
$fieldID = key($this->_priceSet['fields']);
$fieldValueId = key($this->_priceSet['fields'][$fieldID]['options']);
$this->_priceSet['fields'][$fieldID]['options'][$fieldValueId]['amount'] = $submittedValues['total_amount'];
$submittedValues['price_' . $fieldID] = 1;
}
// Every contribution has a price-set - the only reason it shouldn't be set is if we are dealing with
// quick config (very very arguably) & yet we see that this could still be quick config so this should be understood
// as a point of fragility rather than a logical 'if' clause.
if ($priceSetId) {
CRM_Price_BAO_PriceSet::processAmount($this->_priceSet['fields'], $submittedValues, $lineItem[$priceSetId]);
// Unset tax amount for offline 'is_quick_config' contribution.
// @todo WHY - quick config was conceived as a quick way to configure contribution forms.
// this is an example of 'other' functionality being hung off it.
if ($this->_priceSet['is_quick_config'] && !array_key_exists($submittedValues['financial_type_id'], CRM_Core_PseudoConstant::getTaxRates())) {
unset($submittedValues['tax_amount']);
}
$submittedValues['total_amount'] = CRM_Utils_Array::value('amount', $submittedValues);
}
if ($this->_id) {
if ($this->_compId) {
if ($this->_context == 'participant') {
$pId = $this->_compId;
} elseif ($this->_context == 'membership') {
$isRelatedId = TRUE;
} else {
$pId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_id, 'participant_id', 'contribution_id');
}
} else {
$contributionDetails = CRM_Contribute_BAO_Contribution::getComponentDetails($this->_id);
if (array_key_exists('membership', $contributionDetails)) {
$isRelatedId = TRUE;
} elseif (array_key_exists('participant', $contributionDetails)) {
$pId = $contributionDetails['participant'];
}
}
}
if (!$priceSetId && !empty($submittedValues['total_amount']) && $this->_id) {
// CRM-10117 update the line items for participants.
// @todo - if we are completing a contribution then the api call
// civicrm_api3('Contribution', 'completetransaction') should take care of
// all associated updates rather than replicating them on the form layer.
if ($pId) {
$entityTable = 'participant';
$entityID = $pId;
$isRelatedId = FALSE;
$participantParams = array('fee_amount' => $submittedValues['total_amount'], 'id' => $entityID);
CRM_Event_BAO_Participant::add($participantParams);
if (empty($this->_lineItems)) {
$this->_lineItems[] = CRM_Price_BAO_LineItem::getLineItems($entityID, 'participant', 1);
}
} else {
$entityTable = 'contribution';
$entityID = $this->_id;
}
$lineItems = CRM_Price_BAO_LineItem::getLineItems($entityID, $entityTable, NULL, TRUE, $isRelatedId);
foreach (array_keys($lineItems) as $id) {
$lineItems[$id]['id'] = $id;
}
$itemId = key($lineItems);
if ($itemId && !empty($lineItems[$itemId]['price_field_id'])) {
$this->_priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $lineItems[$itemId]['price_field_id'], 'price_set_id');
}
// @todo see above - new functionality has been inappropriately added to the quick config concept
// and new functionality has been added onto the form layer rather than the BAO :-(
if ($this->_priceSetId && CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config')) {
//.........这里部分代码省略.........
示例3: create
/**
* Takes an associative array and creates a contribution object.
*
* @param array $params
* (reference ) an assoc array of name/value pairs.
* @param array $ids
* The array that holds all the db ids.
*
* @return CRM_Contribute_BAO_Contribution
*/
public static function create(&$params, $ids = array())
{
$dateFields = array('receive_date', 'cancel_date', 'receipt_date', 'thankyou_date');
foreach ($dateFields as $df) {
if (isset($params[$df])) {
$params[$df] = CRM_Utils_Date::isoToMysql($params[$df]);
}
}
$transaction = new CRM_Core_Transaction();
$contribution = self::add($params, $ids);
if (is_a($contribution, 'CRM_Core_Error')) {
$transaction->rollback();
return $contribution;
}
$params['contribution_id'] = $contribution->id;
if (!empty($params['custom']) && is_array($params['custom'])) {
CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_contribution', $contribution->id);
}
$session = CRM_Core_Session::singleton();
if (!empty($params['note'])) {
$noteParams = array('entity_table' => 'civicrm_contribution', 'note' => $params['note'], 'entity_id' => $contribution->id, 'contact_id' => $session->get('userID'), 'modified_date' => date('Ymd'));
if (!$noteParams['contact_id']) {
$noteParams['contact_id'] = $params['contact_id'];
}
CRM_Core_BAO_Note::add($noteParams);
}
// make entry in batch entity batch table
if (!empty($params['batch_id'])) {
// in some update cases we need to get extra fields - ie an update that doesn't pass in all these params
$titleFields = array('contact_id', 'total_amount', 'currency', 'financial_type_id');
$retrieveRequired = 0;
foreach ($titleFields as $titleField) {
if (!isset($contribution->{$titleField})) {
$retrieveRequired = 1;
break;
}
}
if ($retrieveRequired == 1) {
$contribution->find(TRUE);
}
}
// Handle soft credit and / or link to personal campaign page
$softIDs = CRM_Contribute_BAO_ContributionSoft::getSoftCreditIds($contribution->id);
$pcpId = CRM_Contribute_BAO_ContributionSoft::getSoftCreditIds($contribution->id, TRUE);
if ($pcp = CRM_Utils_Array::value('pcp', $params)) {
$softParams = array();
$softParams['id'] = $pcpId ? $pcpId : NULL;
$softParams['contribution_id'] = $contribution->id;
$softParams['pcp_id'] = $pcp['pcp_made_through_id'];
$softParams['contact_id'] = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $pcp['pcp_made_through_id'], 'contact_id');
$softParams['currency'] = $contribution->currency;
$softParams['amount'] = $contribution->total_amount;
$softParams['pcp_display_in_roll'] = CRM_Utils_Array::value('pcp_display_in_roll', $pcp);
$softParams['pcp_roll_nickname'] = CRM_Utils_Array::value('pcp_roll_nickname', $pcp);
$softParams['pcp_personal_note'] = CRM_Utils_Array::value('pcp_personal_note', $pcp);
$softParams['soft_credit_type_id'] = CRM_Core_OptionGroup::getValue('soft_credit_type', 'pcp', 'name');
$contributionSoft = CRM_Contribute_BAO_ContributionSoft::add($softParams);
//Send notification to owner for PCP
if ($contributionSoft->pcp_id && empty($pcpId)) {
CRM_Contribute_Form_Contribution_Confirm::pcpNotifyOwner($contribution, $contributionSoft);
}
} elseif (array_key_exists('pcp', $params) && $pcpId) {
$deleteParams = array('id' => $pcpId);
CRM_Contribute_BAO_ContributionSoft::del($deleteParams);
}
if (isset($params['soft_credit'])) {
$softParams = $params['soft_credit'];
foreach ($softParams as $softParam) {
if (!empty($softIDs)) {
$key = key($softIDs);
$softParam['id'] = $softIDs[$key];
unset($softIDs[$key]);
}
$softParam['contribution_id'] = $contribution->id;
$softParam['currency'] = $contribution->currency;
//case during Contribution Import when we assign soft contribution amount as contribution's total_amount by default
if (empty($softParam['amount'])) {
$softParam['amount'] = $contribution->total_amount;
}
CRM_Contribute_BAO_ContributionSoft::add($softParam);
}
if (!empty($softIDs)) {
foreach ($softIDs as $softID) {
if (!in_array($softID, $params['soft_credit_ids'])) {
$deleteParams = array('id' => $softID);
CRM_Contribute_BAO_ContributionSoft::del($deleteParams);
}
}
}
}
//.........这里部分代码省略.........
示例4: import
//.........这里部分代码省略.........
if ($onDuplicate != CRM_Import_Parser::DUPLICATE_UPDATE) {
$formatted['custom'] = CRM_Core_BAO_CustomField::postProcess($formatted, NULL, 'Contribution');
} else {
//fix for CRM-2219 - Update Contribution
// onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE
if (!empty($paramValues['invoice_id']) || !empty($paramValues['trxn_id']) || !empty($paramValues['contribution_id'])) {
$dupeIds = array('id' => CRM_Utils_Array::value('contribution_id', $paramValues), 'trxn_id' => CRM_Utils_Array::value('trxn_id', $paramValues), 'invoice_id' => CRM_Utils_Array::value('invoice_id', $paramValues));
$ids['contribution'] = CRM_Contribute_BAO_Contribution::checkDuplicateIds($dupeIds);
if ($ids['contribution']) {
$formatted['id'] = $ids['contribution'];
$formatted['custom'] = CRM_Core_BAO_CustomField::postProcess($formatted, $formatted['id'], 'Contribution');
//process note
if (!empty($paramValues['note'])) {
$noteID = array();
$contactID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $ids['contribution'], 'contact_id');
$daoNote = new CRM_Core_BAO_Note();
$daoNote->entity_table = 'civicrm_contribution';
$daoNote->entity_id = $ids['contribution'];
if ($daoNote->find(TRUE)) {
$noteID['id'] = $daoNote->id;
}
$noteParams = array('entity_table' => 'civicrm_contribution', 'note' => $paramValues['note'], 'entity_id' => $ids['contribution'], 'contact_id' => $contactID);
CRM_Core_BAO_Note::add($noteParams, $noteID);
unset($formatted['note']);
}
//need to check existing soft credit contribution, CRM-3968
if (!empty($formatted['soft_credit'])) {
$dupeSoftCredit = array('contact_id' => $formatted['soft_credit'], 'contribution_id' => $ids['contribution']);
//Delete all existing soft Contribution from contribution_soft table for pcp_id is_null
$existingSoftCredit = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($dupeSoftCredit['contribution_id']);
if (isset($existingSoftCredit['soft_credit']) && !empty($existingSoftCredit['soft_credit'])) {
foreach ($existingSoftCredit['soft_credit'] as $key => $existingSoftCreditValues) {
if (!empty($existingSoftCreditValues['soft_credit_id'])) {
$deleteParams = array('id' => $existingSoftCreditValues['soft_credit_id'], 'pcp_id' => NULL);
CRM_Contribute_BAO_ContributionSoft::del($deleteParams);
}
}
}
}
$newContribution = CRM_Contribute_BAO_Contribution::create($formatted, $ids);
$this->_newContributions[] = $newContribution->id;
//return soft valid since we need to show how soft credits were added
if (!empty($formatted['soft_credit'])) {
return CRM_Contribute_Import_Parser::SOFT_CREDIT;
}
// process pledge payment assoc w/ the contribution
return self::processPledgePayments($formatted);
return CRM_Import_Parser::VALID;
} else {
$labels = array('id' => 'Contribution ID', 'trxn_id' => 'Transaction ID', 'invoice_id' => 'Invoice ID');
foreach ($dupeIds as $k => $v) {
if ($v) {
$errorMsg[] = "{$labels[$k]} {$v}";
}
}
$errorMsg = implode(' AND ', $errorMsg);
array_unshift($values, 'Matching Contribution record not found for ' . $errorMsg . '. Row was skipped.');
return CRM_Import_Parser::ERROR;
}
}
}
if ($this->_contactIdIndex < 0) {
// set the contact type if its not set
if (!isset($paramValues['contact_type'])) {
$paramValues['contact_type'] = $this->_contactType;
}
示例5: postProcess
/**
* Process the form submission.
*/
public function postProcess()
{
$sendReceipt = $pId = $contribution = $isRelatedId = FALSE;
$softParams = $softIDs = array();
if ($this->_action & CRM_Core_Action::DELETE) {
CRM_Contribute_BAO_Contribution::deleteContribution($this->_id);
CRM_Core_Session::singleton()->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->_contactID}&selectedChild=contribute"));
return;
}
// Get the submitted form values.
$submittedValues = $this->controller->exportValues($this->_name);
if (!empty($submittedValues['price_set_id']) && $this->_action & CRM_Core_Action::UPDATE) {
$line = CRM_Price_BAO_LineItem::getLineItems($this->_id, 'contribution');
$lineID = key($line);
$priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', CRM_Utils_Array::value('price_field_id', $line[$lineID]), 'price_set_id');
$quickConfig = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'is_quick_config');
if ($quickConfig) {
CRM_Price_BAO_LineItem::deleteLineItems($this->_id, 'civicrm_contribution');
}
}
// Process price set and get total amount and line items.
$lineItem = array();
$priceSetId = CRM_Utils_Array::value('price_set_id', $submittedValues);
if (empty($priceSetId) && !$this->_id) {
$this->_priceSetId = $priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', 'default_contribution_amount', 'id', 'name');
$this->_priceSet = current(CRM_Price_BAO_PriceSet::getSetDetail($priceSetId));
$fieldID = key($this->_priceSet['fields']);
$fieldValueId = key($this->_priceSet['fields'][$fieldID]['options']);
$this->_priceSet['fields'][$fieldID]['options'][$fieldValueId]['amount'] = $submittedValues['total_amount'];
$submittedValues['price_' . $fieldID] = 1;
}
if ($priceSetId) {
CRM_Price_BAO_PriceSet::processAmount($this->_priceSet['fields'], $submittedValues, $lineItem[$priceSetId]);
// Unset tax amount for offline 'is_quick_config' contribution.
if ($this->_priceSet['is_quick_config'] && !array_key_exists($submittedValues['financial_type_id'], CRM_Core_PseudoConstant::getTaxRates())) {
unset($submittedValues['tax_amount']);
}
$submittedValues['total_amount'] = CRM_Utils_Array::value('amount', $submittedValues);
}
if ($this->_id) {
if ($this->_compId) {
if ($this->_context == 'participant') {
$pId = $this->_compId;
} elseif ($this->_context == 'membership') {
$isRelatedId = TRUE;
} else {
$pId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_id, 'participant_id', 'contribution_id');
}
} else {
$contributionDetails = CRM_Contribute_BAO_Contribution::getComponentDetails($this->_id);
if (array_key_exists('membership', $contributionDetails)) {
$isRelatedId = TRUE;
} elseif (array_key_exists('participant', $contributionDetails)) {
$pId = $contributionDetails['participant'];
}
}
}
if (!$priceSetId && !empty($submittedValues['total_amount']) && $this->_id) {
// CRM-10117 update the line items for participants.
if ($pId) {
$entityTable = 'participant';
$entityID = $pId;
$isRelatedId = FALSE;
$participantParams = array('fee_amount' => $submittedValues['total_amount'], 'id' => $entityID);
CRM_Event_BAO_Participant::add($participantParams);
if (empty($this->_lineItems)) {
$this->_lineItems[] = CRM_Price_BAO_LineItem::getLineItems($entityID, 'participant', 1);
}
} else {
$entityTable = 'contribution';
$entityID = $this->_id;
}
$lineItems = CRM_Price_BAO_LineItem::getLineItems($entityID, $entityTable, NULL, TRUE, $isRelatedId);
foreach (array_keys($lineItems) as $id) {
$lineItems[$id]['id'] = $id;
}
$itemId = key($lineItems);
if ($itemId && !empty($lineItems[$itemId]['price_field_id'])) {
$this->_priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $lineItems[$itemId]['price_field_id'], 'price_set_id');
}
if ($this->_priceSetId && CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config')) {
$lineItems[$itemId]['unit_price'] = $lineItems[$itemId]['line_total'] = CRM_Utils_Rule::cleanMoney(CRM_Utils_Array::value('total_amount', $submittedValues));
// Update line total and total amount with tax on edit.
$financialItemsId = CRM_Core_PseudoConstant::getTaxRates();
if (array_key_exists($submittedValues['financial_type_id'], $financialItemsId)) {
$lineItems[$itemId]['tax_rate'] = $financialItemsId[$submittedValues['financial_type_id']];
} else {
$lineItems[$itemId]['tax_rate'] = $lineItems[$itemId]['tax_amount'] = "";
$submittedValues['tax_amount'] = 'null';
}
if ($lineItems[$itemId]['tax_rate']) {
$lineItems[$itemId]['tax_amount'] = $lineItems[$itemId]['tax_rate'] / 100 * $lineItems[$itemId]['line_total'];
$submittedValues['total_amount'] = $lineItems[$itemId]['line_total'] + $lineItems[$itemId]['tax_amount'];
$submittedValues['tax_amount'] = $lineItems[$itemId]['tax_amount'];
}
}
// CRM-10117 update the line items for participants.
//.........这里部分代码省略.........
示例6: submit
/**
* @param array $submittedValues
*
* @param int $action
* Action constant
* - CRM_Core_Action::UPDATE
*
* @param $pledgePaymentID
*
* @return array
* @throws \Exception
*/
protected function submit($submittedValues, $action, $pledgePaymentID)
{
$softParams = $softIDs = array();
$pId = $contribution = $isRelatedId = FALSE;
if (!empty($submittedValues['price_set_id']) && $action & CRM_Core_Action::UPDATE) {
$line = CRM_Price_BAO_LineItem::getLineItems($this->_id, 'contribution');
$lineID = key($line);
$priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', CRM_Utils_Array::value('price_field_id', $line[$lineID]), 'price_set_id');
$quickConfig = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'is_quick_config');
if ($quickConfig) {
CRM_Price_BAO_LineItem::deleteLineItems($this->_id, 'civicrm_contribution');
}
}
// Process price set and get total amount and line items.
$lineItem = array();
$priceSetId = CRM_Utils_Array::value('price_set_id', $submittedValues);
if (empty($priceSetId) && !$this->_id) {
$this->_priceSetId = $priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', 'default_contribution_amount', 'id', 'name');
$this->_priceSet = current(CRM_Price_BAO_PriceSet::getSetDetail($priceSetId));
$fieldID = key($this->_priceSet['fields']);
$fieldValueId = key($this->_priceSet['fields'][$fieldID]['options']);
$this->_priceSet['fields'][$fieldID]['options'][$fieldValueId]['amount'] = $submittedValues['total_amount'];
$submittedValues['price_' . $fieldID] = 1;
}
if ($priceSetId) {
CRM_Price_BAO_PriceSet::processAmount($this->_priceSet['fields'], $submittedValues, $lineItem[$priceSetId]);
// Unset tax amount for offline 'is_quick_config' contribution.
if ($this->_priceSet['is_quick_config'] && !array_key_exists($submittedValues['financial_type_id'], CRM_Core_PseudoConstant::getTaxRates())) {
unset($submittedValues['tax_amount']);
}
$submittedValues['total_amount'] = CRM_Utils_Array::value('amount', $submittedValues);
}
if ($this->_id) {
if ($this->_compId) {
if ($this->_context == 'participant') {
$pId = $this->_compId;
} elseif ($this->_context == 'membership') {
$isRelatedId = TRUE;
} else {
$pId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_id, 'participant_id', 'contribution_id');
}
} else {
$contributionDetails = CRM_Contribute_BAO_Contribution::getComponentDetails($this->_id);
if (array_key_exists('membership', $contributionDetails)) {
$isRelatedId = TRUE;
} elseif (array_key_exists('participant', $contributionDetails)) {
$pId = $contributionDetails['participant'];
}
}
}
if (!$priceSetId && !empty($submittedValues['total_amount']) && $this->_id) {
// CRM-10117 update the line items for participants.
if ($pId) {
$entityTable = 'participant';
$entityID = $pId;
$isRelatedId = FALSE;
$participantParams = array('fee_amount' => $submittedValues['total_amount'], 'id' => $entityID);
CRM_Event_BAO_Participant::add($participantParams);
if (empty($this->_lineItems)) {
$this->_lineItems[] = CRM_Price_BAO_LineItem::getLineItems($entityID, 'participant', 1);
}
} else {
$entityTable = 'contribution';
$entityID = $this->_id;
}
$lineItems = CRM_Price_BAO_LineItem::getLineItems($entityID, $entityTable, NULL, TRUE, $isRelatedId);
foreach (array_keys($lineItems) as $id) {
$lineItems[$id]['id'] = $id;
}
$itemId = key($lineItems);
if ($itemId && !empty($lineItems[$itemId]['price_field_id'])) {
$this->_priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $lineItems[$itemId]['price_field_id'], 'price_set_id');
}
if ($this->_priceSetId && CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config')) {
$lineItems[$itemId]['unit_price'] = $lineItems[$itemId]['line_total'] = CRM_Utils_Rule::cleanMoney(CRM_Utils_Array::value('total_amount', $submittedValues));
// Update line total and total amount with tax on edit.
$financialItemsId = CRM_Core_PseudoConstant::getTaxRates();
if (array_key_exists($submittedValues['financial_type_id'], $financialItemsId)) {
$lineItems[$itemId]['tax_rate'] = $financialItemsId[$submittedValues['financial_type_id']];
} else {
$lineItems[$itemId]['tax_rate'] = $lineItems[$itemId]['tax_amount'] = "";
$submittedValues['tax_amount'] = 'null';
}
if ($lineItems[$itemId]['tax_rate']) {
$lineItems[$itemId]['tax_amount'] = $lineItems[$itemId]['tax_rate'] / 100 * $lineItems[$itemId]['line_total'];
$submittedValues['total_amount'] = $lineItems[$itemId]['line_total'] + $lineItems[$itemId]['tax_amount'];
$submittedValues['tax_amount'] = $lineItems[$itemId]['tax_amount'];
}
//.........这里部分代码省略.........
示例7: civicrm_api3_contribution_soft_delete
/**
* Deletes an existing Soft Credit
*
* @param array $params
*
* @example ContributionSoftDelete.php Standard Delete Example
*
* @return boolean | error true if successfull, error otherwise
* {@getfields contribution_soft_delete}
* @access public
*/
function civicrm_api3_contribution_soft_delete($params)
{
// non standard BAO - we have to write custom code to cope
CRM_Contribute_BAO_ContributionSoft::del(array('id' => $params['id']));
}
示例8: processSoftContribution
/**
* Process the soft contribution and/or link to personal campaign page.
*
* @param array $params
* @param object $contribution CRM_Contribute_DAO_Contribution
*
*/
public static function processSoftContribution($params, $contribution)
{
//retrieve existing soft-credit and pcp id(s) if any against $contribution
$softIDs = self::getSoftCreditIds($contribution->id);
$pcpId = self::getSoftCreditIds($contribution->id, TRUE);
if ($pcp = CRM_Utils_Array::value('pcp', $params)) {
$softParams = array();
$softParams['id'] = $pcpId ? $pcpId : NULL;
$softParams['contribution_id'] = $contribution->id;
$softParams['pcp_id'] = $pcp['pcp_made_through_id'];
$softParams['contact_id'] = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $pcp['pcp_made_through_id'], 'contact_id');
$softParams['currency'] = $contribution->currency;
$softParams['amount'] = $contribution->total_amount;
$softParams['pcp_display_in_roll'] = CRM_Utils_Array::value('pcp_display_in_roll', $pcp);
$softParams['pcp_roll_nickname'] = CRM_Utils_Array::value('pcp_roll_nickname', $pcp);
$softParams['pcp_personal_note'] = CRM_Utils_Array::value('pcp_personal_note', $pcp);
$softParams['soft_credit_type_id'] = CRM_Core_OptionGroup::getValue('soft_credit_type', 'pcp', 'name');
$contributionSoft = self::add($softParams);
//Send notification to owner for PCP
if ($contributionSoft->pcp_id && empty($pcpId)) {
CRM_Contribute_Form_Contribution_Confirm::pcpNotifyOwner($contribution, $contributionSoft);
}
} elseif (array_key_exists('pcp', $params) && $pcpId) {
$deleteParams = array('id' => $pcpId);
CRM_Contribute_BAO_ContributionSoft::del($deleteParams);
}
if (isset($params['soft_credit'])) {
$softParams = $params['soft_credit'];
foreach ($softParams as $softParam) {
if (!empty($softIDs)) {
$key = key($softIDs);
$softParam['id'] = $softIDs[$key];
unset($softIDs[$key]);
}
$softParam['contribution_id'] = $contribution->id;
$softParam['currency'] = $contribution->currency;
//case during Contribution Import when we assign soft contribution amount as contribution's total_amount by default
if (empty($softParam['amount'])) {
$softParam['amount'] = $contribution->total_amount;
}
CRM_Contribute_BAO_ContributionSoft::add($softParam);
}
// delete any extra soft-credit while updating back-office contribution
foreach ((array) $softIDs as $softID) {
if (!in_array($softID, $params['soft_credit_ids'])) {
$deleteParams = array('id' => $softID);
CRM_Contribute_BAO_ContributionSoft::del($deleteParams);
}
}
}
}