Skip to content

Commit

Permalink
Merge CIVIEWAY-266
Browse files Browse the repository at this point in the history
  • Loading branch information
agileware-fj authored and agileware-dev committed Apr 22, 2024
2 parents d1971d9 + 1c52429 commit 9d212f5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 46 deletions.
8 changes: 8 additions & 0 deletions CRM/Core/Payment/eWAYRecurring.php
Original file line number Diff line number Diff line change
Expand Up @@ -804,4 +804,12 @@ private function updateContactBillingAddress($params, $contribution) {
civicrm_api3('Address', 'create', $billingAddress);
}

/**
* Specify which fields are valid for update on Recurring Contributions
*
* @return array
*/
public function getEditableRecurringScheduleFields() {
return ['amount', 'installments', 'frequency_interval', 'frequency_unit', 'next_sched_contribution_date', 'end_date'];
}
}
45 changes: 1 addition & 44 deletions eWAYRecurring.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,34 +176,7 @@ function ewayrecurring_civicrm_entityTypes(&$entityTypes) {
* @param $form CRM_Core_Form
*/
function ewayrecurring_civicrm_buildForm($formName, &$form) {
if ($form instanceof CRM_Contribute_Form_UpdateSubscription) {
$contributionRecur = $form->_paymentProcessorObj;
if (($contributionRecur instanceof CRM_Core_Payment_eWAYRecurring)) {
$crid = $form->getEntityId();
if ($crid) {
$sql = 'SELECT next_sched_contribution_date FROM civicrm_contribution_recur WHERE id = %1';
$form->add('datepicker','next_scheduled_date', ts('Next Scheduled Date'), [ 'minDate' => date('Y-m-d')]);
if ($default_nsd = CRM_Core_DAO::singleValueQuery($sql, [
1 => [
$crid,
'Int',
],
])) {
$defaults['next_scheduled_date'] = $default_nsd;
$form->setDefaults($defaults);
}
// add next scheduled date field
$template = $form->toSmarty();
Civi::resources()
->addScript("CRM.eway.modifyUpdateSubscriptionForm(" .
json_encode([
'next_scheduled_date' => $template['next_scheduled_date'],
]) . ");"
);
}
}
}
elseif (($form instanceof CRM_Contribute_Form_CancelSubscription) &&
if (($form instanceof CRM_Contribute_Form_CancelSubscription) &&
($form->_paymentProcessor['payment_processor_type'] == 'eWay_Recurring')) {
$form->removeElement('send_cancel_request');
}
Expand Down Expand Up @@ -233,22 +206,6 @@ function ewayrecurring_civicrm_validateForm($formName, &$fields, &$files, &$form
$errors['password'] = E::ts('API Password is a required field.');
}
break;
case 'CRM_Contribute_Form_UpdateSubscription':
$submitted_nsd = strtotime(($fields['next_scheduled_date'] ?? '') . ' ' . ($fields['next_scheduled_date_time'] ?? ''));

($crid = $form->getVar('contributionRecurID')) || ($crid = $form->getVar('_crid'));

$sql = 'SELECT UNIX_TIMESTAMP(MAX(receive_date)) FROM civicrm_contribution WHERE contribution_recur_id = %1';
$current_nsd = CRM_Core_DAO::singleValueQuery($sql, [1 => [$crid, 'Int']]);
$form->setVar('_currentNSD', $current_nsd);

if ($submitted_nsd < $current_nsd) {
$errors['next_scheduled_date'] = ts('Cannot schedule next contribution date before latest received date');
}
elseif ($submitted_nsd < time()) {
$errors['next_scheduled_date'] = ts('Cannot schedule next contribution in the past');
}
break;
}
}

Expand Down
4 changes: 2 additions & 2 deletions info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<email>[email protected]</email>
</maintainer>
<develStage>stable</develStage>
<releaseDate>2023-12-15</releaseDate>
<version>2.6.5</version>
<releaseDate>2024-04-22</releaseDate>
<version>2.6.6</version>
<compatibility>
<ver>5.38</ver>
</compatibility>
Expand Down

0 comments on commit 9d212f5

Please sign in to comment.