本文整理汇总了PHP中CRM_Batch_BAO_Batch::addBatchEntity方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Batch_BAO_Batch::addBatchEntity方法的具体用法?PHP CRM_Batch_BAO_Batch::addBatchEntity怎么用?PHP CRM_Batch_BAO_Batch::addBatchEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Batch_BAO_Batch
的用法示例。
在下文中一共展示了CRM_Batch_BAO_Batch::addBatchEntity方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: recordFinancialAccounts
//.........这里部分代码省略.........
// CRM-17751 This has previously been deliberately set. No explanation as to why one variant
// gets preference over another so I am only 'protecting' a very specific tested flow
// and letting natural justice take care of the rest.
$params['trxnParams']['trxn_id'] = $params['contribution']->trxn_id;
}
if (!empty($params['contribution_status_id']) && $params['prevContribution']->contribution_status_id != $params['contribution']->contribution_status_id) {
//Update Financial Records
self::updateFinancialAccounts($params, 'changedStatus');
$updated = TRUE;
}
// change Payment Instrument for a Completed contribution
// first handle special case when contribution is changed from Pending to Completed status when initial payment
// instrument is null and now new payment instrument is added along with the payment
$params['trxnParams']['payment_instrument_id'] = $params['contribution']->payment_instrument_id;
$params['trxnParams']['check_number'] = CRM_Utils_Array::value('check_number', $params);
if (array_key_exists('payment_instrument_id', $params)) {
$params['trxnParams']['total_amount'] = -$trxnParams['total_amount'];
if (CRM_Utils_System::isNull($params['prevContribution']->payment_instrument_id) && !CRM_Utils_System::isNull($params['contribution']->payment_instrument_id)) {
//check if status is changed from Pending to Completed
// do not update payment instrument changes for Pending to Completed
if (!($params['contribution']->contribution_status_id == array_search('Completed', $contributionStatuses) && in_array($params['prevContribution']->contribution_status_id, $pendingStatus))) {
// for all other statuses create new financial records
self::updateFinancialAccounts($params, 'changePaymentInstrument');
$params['total_amount'] = $params['trxnParams']['total_amount'] = $trxnParams['total_amount'];
self::updateFinancialAccounts($params, 'changePaymentInstrument');
$updated = TRUE;
}
} elseif ((!CRM_Utils_System::isNull($params['contribution']->payment_instrument_id) || !CRM_Utils_System::isNull($params['prevContribution']->payment_instrument_id)) && $params['contribution']->payment_instrument_id != $params['prevContribution']->payment_instrument_id) {
// for any other payment instrument changes create new financial records
self::updateFinancialAccounts($params, 'changePaymentInstrument');
$params['total_amount'] = $params['trxnParams']['total_amount'] = $trxnParams['total_amount'];
self::updateFinancialAccounts($params, 'changePaymentInstrument');
$updated = TRUE;
} elseif (!CRM_Utils_System::isNull($params['contribution']->check_number) && $params['contribution']->check_number != $params['prevContribution']->check_number) {
// another special case when check number is changed, create new financial records
// create financial trxn with negative amount
$params['trxnParams']['check_number'] = $params['prevContribution']->check_number;
self::updateFinancialAccounts($params, 'changePaymentInstrument');
// create financial trxn with positive amount
$params['trxnParams']['check_number'] = $params['contribution']->check_number;
$params['total_amount'] = $params['trxnParams']['total_amount'] = $trxnParams['total_amount'];
self::updateFinancialAccounts($params, 'changePaymentInstrument');
$updated = TRUE;
}
}
//if Change contribution amount
$params['trxnParams']['fee_amount'] = CRM_Utils_Array::value('fee_amount', $params);
$params['trxnParams']['net_amount'] = CRM_Utils_Array::value('net_amount', $params);
$params['trxnParams']['total_amount'] = $trxnParams['total_amount'] = $params['total_amount'] = $totalAmount;
$params['trxnParams']['trxn_id'] = $params['contribution']->trxn_id;
if (isset($totalAmount) && $totalAmount != $params['prevContribution']->total_amount) {
//Update Financial Records
$params['trxnParams']['from_financial_account_id'] = NULL;
self::updateFinancialAccounts($params, 'changedAmount');
$updated = TRUE;
}
if (!$updated) {
// Looks like we might have a data correction update.
// This would be a case where a transaction id has been entered but it is incorrect &
// the person goes back in & fixes it, as opposed to a new transaction.
// Currently the UI doesn't support multiple refunds against a single transaction & we are only supporting
// the data fix scenario.
// CRM-17751.
if (isset($params['refund_trxn_id'])) {
$refundIDs = CRM_Core_BAO_FinancialTrxn::getRefundTransactionIDs($params['id']);
if ($refundIDs['trxn_id'] != $params['refund_trxn_id']) {
civicrm_api3('FinancialTrxn', 'create', array('id' => $refundIDs['financialTrxnId'], 'trxn_id' => $params['refund_trxn_id']));
}
}
}
}
if (!$update) {
// records finanical trxn and entity financial trxn
// also make it available as return value
$return = $financialTxn = CRM_Core_BAO_FinancialTrxn::create($trxnParams);
$params['entity_id'] = $financialTxn->id;
}
}
// record line items and financial items
if (empty($params['skipLineItem'])) {
CRM_Price_BAO_LineItem::processPriceSet($entityId, CRM_Utils_Array::value('line_item', $params), $params['contribution'], $entityTable, $update);
}
// create batch entry if batch_id is passed and
// ensure no batch entry is been made on 'Pending' or 'Failed' contribution, CRM-16611
if (!empty($params['batch_id']) && !empty($financialTxn)) {
$entityParams = array('batch_id' => $params['batch_id'], 'entity_table' => 'civicrm_financial_trxn', 'entity_id' => $financialTxn->id);
CRM_Batch_BAO_Batch::addBatchEntity($entityParams);
}
// when a fee is charged
if (!empty($params['fee_amount']) && (empty($params['prevContribution']) || $params['contribution']->fee_amount != $params['prevContribution']->fee_amount) && $skipRecords) {
CRM_Core_BAO_FinancialTrxn::recordFees($params);
}
if (!empty($params['prevContribution']) && $entityTable == 'civicrm_participant' && $params['prevContribution']->contribution_status_id != $params['contribution']->contribution_status_id) {
$eventID = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $entityId, 'event_id');
$feeLevel[] = str_replace('', '', $params['prevContribution']->amount_level);
CRM_Event_BAO_Participant::createDiscountTrxn($eventID, $params, $feeLevel);
}
unset($params['line_item']);
return $return;
}
示例2: recordFinancialAccounts
//.........这里部分代码省略.........
$incomeTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Income Account is' "));
$oldFinancialAccount = CRM_Contribute_PseudoConstant::financialAccountType($params['prevContribution']->financial_type_id, $incomeTypeId);
$newFinancialAccount = CRM_Contribute_PseudoConstant::financialAccountType($params['financial_type_id'], $incomeTypeId);
if ($oldFinancialAccount != $newFinancialAccount) {
$params['total_amount'] = 0;
if (in_array($params['contribution']->contribution_status_id, $pendingStatus)) {
$params['trxnParams']['to_financial_account_id'] = CRM_Contribute_PseudoConstant::financialAccountType($params['prevContribution']->financial_type_id, $relationTypeId);
} else {
$lastFinancialTrxnId = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($params['prevContribution']->id, 'DESC');
if (!empty($lastFinancialTrxnId['financialTrxnId'])) {
$params['trxnParams']['to_financial_account_id'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialTrxn', $lastFinancialTrxnId['financialTrxnId'], 'to_financial_account_id');
}
}
self::updateFinancialAccounts($params, 'changeFinancialType');
/* $params['trxnParams']['to_financial_account_id'] = $trxnParams['to_financial_account_id']; */
$params['financial_account_id'] = $newFinancialAccount;
$params['total_amount'] = $params['trxnParams']['total_amount'] = $trxnParams['total_amount'];
self::updateFinancialAccounts($params);
$params['trxnParams']['to_financial_account_id'] = $trxnParams['to_financial_account_id'];
}
}
//Update contribution status
$params['trxnParams']['status_id'] = $params['contribution']->contribution_status_id;
$params['trxnParams']['trxn_id'] = $params['contribution']->trxn_id;
if (!empty($params['contribution_status_id']) && $params['prevContribution']->contribution_status_id != $params['contribution']->contribution_status_id) {
//Update Financial Records
self::updateFinancialAccounts($params, 'changedStatus');
}
// change Payment Instrument for a Completed contribution
// first handle special case when contribution is changed from Pending to Completed status when initial payment
// instrument is null and now new payment instrument is added along with the payment
$params['trxnParams']['payment_instrument_id'] = $params['contribution']->payment_instrument_id;
$params['trxnParams']['check_number'] = CRM_Utils_Array::value('check_number', $params);
if (array_key_exists('payment_instrument_id', $params)) {
$params['trxnParams']['total_amount'] = -$trxnParams['total_amount'];
if (CRM_Utils_System::isNull($params['prevContribution']->payment_instrument_id) && !CRM_Utils_System::isNull($params['contribution']->payment_instrument_id)) {
//check if status is changed from Pending to Completed
// do not update payment instrument changes for Pending to Completed
if (!($params['contribution']->contribution_status_id == array_search('Completed', $contributionStatuses) && in_array($params['prevContribution']->contribution_status_id, $pendingStatus))) {
// for all other statuses create new financial records
self::updateFinancialAccounts($params, 'changePaymentInstrument');
$params['total_amount'] = $params['trxnParams']['total_amount'] = $trxnParams['total_amount'];
self::updateFinancialAccounts($params, 'changePaymentInstrument');
}
} elseif ((!CRM_Utils_System::isNull($params['contribution']->payment_instrument_id) || !CRM_Utils_System::isNull($params['prevContribution']->payment_instrument_id)) && $params['contribution']->payment_instrument_id != $params['prevContribution']->payment_instrument_id) {
// for any other payment instrument changes create new financial records
self::updateFinancialAccounts($params, 'changePaymentInstrument');
$params['total_amount'] = $params['trxnParams']['total_amount'] = $trxnParams['total_amount'];
self::updateFinancialAccounts($params, 'changePaymentInstrument');
} elseif (!CRM_Utils_System::isNull($params['contribution']->check_number) && $params['contribution']->check_number != $params['prevContribution']->check_number) {
// another special case when check number is changed, create new financial records
// create financial trxn with negative amount
$params['trxnParams']['check_number'] = $params['prevContribution']->check_number;
self::updateFinancialAccounts($params, 'changePaymentInstrument');
// create financial trxn with positive amount
$params['trxnParams']['check_number'] = $params['contribution']->check_number;
$params['total_amount'] = $params['trxnParams']['total_amount'] = $trxnParams['total_amount'];
self::updateFinancialAccounts($params, 'changePaymentInstrument');
}
}
//if Change contribution amount
$params['trxnParams']['fee_amount'] = CRM_Utils_Array::value('fee_amount', $params);
$params['trxnParams']['net_amount'] = CRM_Utils_Array::value('net_amount', $params);
$params['trxnParams']['total_amount'] = $trxnParams['total_amount'] = $params['total_amount'] = $totalAmount;
$params['trxnParams']['trxn_id'] = $params['contribution']->trxn_id;
if (isset($totalAmount) && $totalAmount != $params['prevContribution']->total_amount) {
//Update Financial Records
$params['trxnParams']['from_financial_account_id'] = NULL;
self::updateFinancialAccounts($params, 'changedAmount');
}
}
if (!$update) {
// records finanical trxn and entity financial trxn
// also make it available as return value
$return = $financialTxn = CRM_Core_BAO_FinancialTrxn::create($trxnParams);
$params['entity_id'] = $financialTxn->id;
}
}
// record line items and financial items
if (empty($params['skipLineItem'])) {
CRM_Price_BAO_LineItem::processPriceSet($entityId, CRM_Utils_Array::value('line_item', $params), $params['contribution'], $entityTable, $update);
}
// create batch entry if batch_id is passed and
// ensure no batch entry is been made on 'Pending' or 'Failed' contribution, CRM-16611
if (!empty($params['batch_id']) && !empty($financialTxn)) {
$entityParams = array('batch_id' => $params['batch_id'], 'entity_table' => 'civicrm_financial_trxn', 'entity_id' => $financialTxn->id);
CRM_Batch_BAO_Batch::addBatchEntity($entityParams);
}
// when a fee is charged
if (!empty($params['fee_amount']) && (empty($params['prevContribution']) || $params['contribution']->fee_amount != $params['prevContribution']->fee_amount) && $skipRecords) {
CRM_Core_BAO_FinancialTrxn::recordFees($params);
}
if (!empty($params['prevContribution']) && $entityTable == 'civicrm_participant' && $params['prevContribution']->contribution_status_id != $params['contribution']->contribution_status_id) {
$eventID = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $entityId, 'event_id');
$feeLevel[] = str_replace('', '', $params['prevContribution']->amount_level);
CRM_Event_BAO_Participant::createDiscountTrxn($eventID, $params, $feeLevel);
}
unset($params['line_item']);
return $return;
}
示例3: bulkAssignRemove
public static function bulkAssignRemove()
{
$checkIDs = $_REQUEST['ID'];
$entityID = CRM_Utils_Type::escape($_REQUEST['entityID'], 'String');
$action = CRM_Utils_Type::escape($_REQUEST['action'], 'String');
foreach ($checkIDs as $key => $value) {
if (substr($value, 0, 7) == "mark_x_" && $action == 'Assign' || substr($value, 0, 7) == "mark_y_" && $action == 'Remove') {
$contributions = explode("_", $value);
$cIDs[] = $contributions[2];
}
}
$batchPID = CRM_Core_DAO::getFieldValue('CRM_Batch_DAO_Batch', $entityID, 'payment_instrument_id');
$paymentInstrument = CRM_Core_OptionGroup::getLabel('payment_instrument', $batchPID);
foreach ($cIDs as $key => $value) {
$recordPID = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialTrxn', $value, 'payment_instrument_id');
if ($action == 'Remove' || $recordPID == $batchPID && $action == 'Assign' || !isset($batchPID)) {
$params = array('entity_id' => $value, 'entity_table' => 'civicrm_financial_trxn', 'batch_id' => $entityID);
if ($action == 'Assign') {
$updated = CRM_Batch_BAO_Batch::addBatchEntity($params);
} else {
$updated = CRM_Batch_BAO_Batch::removeBatchEntity($params);
}
}
}
if ($updated) {
$status = array('status' => 'record-updated-success');
} else {
$status = array('status' => ts("This batch is configured to include only transactions using %1 payment method. If you want to include other transactions, please edit the batch first and modify the Payment Method.", array(1 => $paymentInstrument)));
}
CRM_Utils_JSON::output($status);
}