Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions CRM/Event/Form/Participant.php
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,34 @@ public static function formRule($values, $files, $self) {
$errorMsg['contribution_status_id'] = ts("Please select a valid payment status before updating.");
}

if (CRM_Utils_Array::value('record_contribution', $values) &&
!empty($values['trxn_id'])
) {
$trxnId = $values['trxn_id'];
$excludeContributionId = NULL;

// exclude that participant's own contribution from the duplicate check.
if ($self->_id && $self->_paymentId) {
$excludeContributionId = CRM_Core_DAO::getFieldValue(
'CRM_Event_DAO_ParticipantPayment',
$self->_id,
'contribution_id',
'participant_id'
);
}

$dupQuery = "SELECT id FROM civicrm_contribution WHERE trxn_id = %1";
$dupParams = [1 => [$trxnId, 'String']];
if ($excludeContributionId) {
$dupQuery .= " AND id != %2";
$dupParams[2] = [$excludeContributionId, 'Integer'];
}
$dupDao = CRM_Core_DAO::executeQuery($dupQuery, $dupParams);
if ($dupDao->fetch()) {
$errorMsg['trxn_id'] = ts('Transaction ID already exists in Database.');
}
}

// do the amount validations.
//skip for update mode since amount is freeze, CRM-6052
if ((
Expand Down