本文整理汇总了PHP中CRM_Contribute_BAO_Contribution::checkDuplicateIds方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contribute_BAO_Contribution::checkDuplicateIds方法的具体用法?PHP CRM_Contribute_BAO_Contribution::checkDuplicateIds怎么用?PHP CRM_Contribute_BAO_Contribution::checkDuplicateIds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contribute_BAO_Contribution
的用法示例。
在下文中一共展示了CRM_Contribute_BAO_Contribution::checkDuplicateIds方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: import
/**
* Handle the values in import mode.
*
* @param int $onDuplicate
* The code for what action to take on duplicates.
* @param array $values
* The array of values belonging to this line.
*
* @return bool
* the result of this processing
*/
public function import($onDuplicate, &$values)
{
// first make sure this is a valid line
$response = $this->summary($values);
if ($response != CRM_Import_Parser::VALID) {
return $response;
}
$params =& $this->getActiveFieldParams();
$formatted = array('version' => 3);
// don't add to recent items, CRM-4399
$formatted['skipRecentView'] = TRUE;
//for date-Formats
$session = CRM_Core_Session::singleton();
$dateType = $session->get('dateTypes');
$customDataType = !empty($params['contact_type']) ? $params['contact_type'] : 'Contribution';
$customFields = CRM_Core_BAO_CustomField::getFields($customDataType);
//CRM-10994
if (isset($params['total_amount']) && $params['total_amount'] == 0) {
$params['total_amount'] = '0.00';
}
foreach ($params as $key => $val) {
if ($val) {
switch ($key) {
case 'receive_date':
case 'cancel_date':
case 'receipt_date':
case 'thankyou_date':
$params[$key] = CRM_Utils_Date::formatDate($params[$key], $dateType);
break;
case 'pledge_payment':
$params[$key] = CRM_Utils_String::strtobool($val);
break;
}
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) {
if ($customFields[$customFieldID]['data_type'] == 'Date') {
CRM_Contact_Import_Parser_Contact::formatCustomDate($params, $formatted, $dateType, $key);
unset($params[$key]);
} elseif ($customFields[$customFieldID]['data_type'] == 'Boolean') {
$params[$key] = CRM_Utils_String::strtoboolstr($val);
}
}
}
}
//date-Format part ends
static $indieFields = NULL;
if ($indieFields == NULL) {
$tempIndieFields = CRM_Contribute_DAO_Contribution::import();
$indieFields = $tempIndieFields;
}
$paramValues = array();
foreach ($params as $key => $field) {
if ($field == NULL || $field === '') {
continue;
}
$paramValues[$key] = $field;
}
//import contribution record according to select contact type
if ($onDuplicate == CRM_Import_Parser::DUPLICATE_SKIP && (!empty($paramValues['contribution_contact_id']) || !empty($paramValues['external_identifier']))) {
$paramValues['contact_type'] = $this->_contactType;
} elseif ($onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE && (!empty($paramValues['contribution_id']) || !empty($values['trxn_id']) || !empty($paramValues['invoice_id']))) {
$paramValues['contact_type'] = $this->_contactType;
} elseif (!empty($params['soft_credit'])) {
$paramValues['contact_type'] = $this->_contactType;
} elseif (!empty($paramValues['pledge_payment'])) {
$paramValues['contact_type'] = $this->_contactType;
}
//need to pass $onDuplicate to check import mode.
if (!empty($paramValues['pledge_payment'])) {
$paramValues['onDuplicate'] = $onDuplicate;
}
require_once 'CRM/Utils/DeprecatedUtils.php';
$formatError = _civicrm_api3_deprecated_formatted_param($paramValues, $formatted, TRUE, $onDuplicate);
if ($formatError) {
array_unshift($values, $formatError['error_message']);
if (CRM_Utils_Array::value('error_data', $formatError) == 'soft_credit') {
return CRM_Contribute_Import_Parser::SOFT_CREDIT_ERROR;
} elseif (CRM_Utils_Array::value('error_data', $formatError) == 'pledge_payment') {
return CRM_Contribute_Import_Parser::PLEDGE_PAYMENT_ERROR;
}
return CRM_Import_Parser::ERROR;
}
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);
//.........这里部分代码省略.........
示例2: testcheckDuplicateIds
/**
* Check duplicate contribution id
* during the contribution import
* checkDuplicateIds();
*/
function testcheckDuplicateIds()
{
$contactId = Contact::createIndividual();
$ids = array('contribution' => null);
$param = array('contact_id' => $contactId, 'currency' => 'USD', 'contribution_type_id' => 1, 'contribution_status_id' => 1, 'payment_instrument_id' => 1, 'source' => 'STUDENT', 'receive_date' => '20080522000000', 'receipt_date' => '20080522000000', 'id' => null, 'non_deductible_amount' => 0.0, 'total_amount' => 300.0, 'fee_amount' => 5, 'net_amount' => 295, 'trxn_id' => '22ereerwww323', 'invoice_id' => '22ed39c9e9ee621ce0eafe6da70', 'thankyou_date' => '20080522');
require_once 'CRM/Contribute/BAO/Contribution.php';
$contribution = CRM_Contribute_BAO_Contribution::create($param, $ids);
$this->assertEquals($param['trxn_id'], $contribution->trxn_id, 'Check for transcation id creation.');
$this->assertEquals($contactId, $contribution->contact_id, 'Check for contact id creation.');
$data = array('id' => $contribution->id, 'trxn_id' => $contribution->trxn_id, 'invoice_id' => $contribution->invoice_id);
$contributionID = CRM_Contribute_BAO_Contribution::checkDuplicateIds($data);
$this->assertEquals($contributionID, $contribution->id, 'Check for duplicate transcation id .');
Contact::delete($contactId);
}
示例3: testcheckDuplicateIds
/**
* Check duplicate contribution id.
* during the contribution import
* checkDuplicateIds();
*/
public function testcheckDuplicateIds()
{
$contactId = Contact::createIndividual();
$ids = array('contribution' => NULL);
$param = array('contact_id' => $contactId, 'currency' => 'USD', 'financial_type_id' => 1, 'contribution_status_id' => 1, 'payment_instrument_id' => 1, 'source' => 'STUDENT', 'receive_date' => '20080522000000', 'receipt_date' => '20080522000000', 'id' => NULL, 'non_deductible_amount' => 0.0, 'total_amount' => 300.0, 'fee_amount' => 5, 'net_amount' => 295, 'trxn_id' => '76ereeswww835', 'invoice_id' => '93ed39a9e9hd621bs0eafe3da82', 'thankyou_date' => '20080522');
$contribution = CRM_Contribute_BAO_Contribution::create($param, $ids);
$this->assertEquals($param['trxn_id'], $contribution->trxn_id, 'Check for transcation id creation.');
$this->assertEquals($contactId, $contribution->contact_id, 'Check for contact id creation.');
$data = array('id' => $contribution->id, 'trxn_id' => $contribution->trxn_id, 'invoice_id' => $contribution->invoice_id);
$contributionID = CRM_Contribute_BAO_Contribution::checkDuplicateIds($data);
$this->assertEquals($contributionID, $contribution->id, 'Check for duplicate transcation id .');
// Delete Contribution
$this->contributionDelete($contribution->id);
// Delete Contact
Contact::delete($contactId);
}
示例4: import
//.........这里部分代码省略.........
if (!empty($params['soft_credit'])) {
$paramValues['contact_type'] = $this->_contactType;
} else {
if (CRM_Utils_Array::value('pledge_payment', $paramValues)) {
$paramValues['contact_type'] = $this->_contactType;
}
}
}
}
//need to pass $onDuplicate to check import mode.
if (CRM_Utils_Array::value('pledge_payment', $paramValues)) {
$paramValues['onDuplicate'] = $onDuplicate;
}
$formatError = _civicrm_contribute_formatted_param($paramValues, $formatted, true);
if ($formatError) {
array_unshift($values, $formatError['error_message']);
if (CRM_Utils_Array::value('error_data', $formatError) == 'soft_credit') {
return CRM_Contribute_Import_Parser::SOFT_CREDIT_ERROR;
} else {
if (CRM_Utils_Array::value('error_data', $formatError) == 'pledge_payment') {
return CRM_Contribute_Import_Parser::PLEDGE_PAYMENT_ERROR;
}
}
return CRM_Contribute_Import_Parser::ERROR;
}
if ($onDuplicate != CRM_Contribute_Import_Parser::DUPLICATE_UPDATE) {
$formatted['custom'] = CRM_Core_BAO_CustomField::postProcess($formatted, CRM_Core_DAO::$_nullObject, null, 'Contribution');
} else {
//fix for CRM-2219 - Update Contribution
// onDuplicate == CRM_Contribute_Import_Parser::DUPLICATE_UPDATE
if ($paramValues['invoice_id'] || $paramValues['trxn_id'] || $paramValues['contribution_id']) {
require_once 'CRM/Contribute/BAO/Contribution.php';
$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, CRM_Core_DAO::$_nullObject, $formatted['id'], 'Contribution');
//process note
if ($paramValues['note']) {
$noteID = array();
$contactID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $ids['contribution'], 'contact_id');
require_once 'CRM/Core/BAO/Note.php';
$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 (CRM_Utils_Array::value('soft_credit_to', $formatted)) {
$dupeSoftCredit = array('contact_id' => $formatted['soft_credit_to'], 'contribution_id' => $ids['contribution']);
$existingSoftCredit = CRM_Contribute_BAO_Contribution::getSoftContribution($dupeSoftCredit);
if (CRM_Utils_Array::value('soft_credit_id', $existingSoftCredit)) {
$formatted['softID'] = $existingSoftCredit['soft_credit_id'];
}
}
$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 (CRM_Utils_Array::value('soft_credit_to', $formatted)) {
return CRM_Contribute_Import_Parser::SOFT_CREDIT;
}