From: Eileen McNaughton Date: Wed, 11 Oct 2023 01:09:29 +0000 (+1300) Subject: Fix recursive display of payment_reminders X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=0d8c495b5084ec1ca7de27645bf56b88e0596a55;p=civicrm-core.git Fix recursive display of payment_reminders --- diff --git a/CRM/Contribute/Form/AdditionalInfo.php b/CRM/Contribute/Form/AdditionalInfo.php index 86b0e94572..7f1d5e393f 100644 --- a/CRM/Contribute/Form/AdditionalInfo.php +++ b/CRM/Contribute/Form/AdditionalInfo.php @@ -147,9 +147,11 @@ class CRM_Contribute_Form_AdditionalInfo { * * Build the form object for PaymentReminders Information. * + * @deprecated since 5.68 will be removed around 5.78. * @param CRM_Core_Form $form */ public static function buildPaymentReminders(&$form) { + CRM_Core_Error::deprecatedFunctionWarning('no alternative, will be removed around 5.78'); //PaymentReminders section $form->add('hidden', 'hidden_PaymentReminders', 1); $form->add('text', 'initial_reminder_day', ts('Send Initial Reminder'), ['size' => 3]); diff --git a/CRM/Pledge/Form/Pledge.php b/CRM/Pledge/Form/Pledge.php index 696bef9b7f..b27de4d266 100644 --- a/CRM/Pledge/Form/Pledge.php +++ b/CRM/Pledge/Form/Pledge.php @@ -195,33 +195,28 @@ class CRM_Pledge_Form_Pledge extends CRM_Core_Form { $contactField->freeze(); } - $showAdditionalInfo = FALSE; - $formType = CRM_Utils_Request::retrieveValue('form_type', 'String'); - $defaults = []; + $formType = CRM_Utils_Request::retrieveValue('formType', 'String'); - $paneNames = [ - ts('Payment Reminders') => 'PaymentReminders', + $allPanes[ts('Payment Reminders')] = [ + 'open' => 'false', + 'id' => 'PaymentReminders', ]; - foreach ($paneNames as $name => $type) { - $urlParams = "snippet=4&formType={$type}"; - $allPanes[$name] = [ - 'url' => CRM_Utils_System::url('civicrm/contact/view/pledge', $urlParams), - 'open' => 'false', - 'id' => $type, - ]; - // see if we need to include this paneName in the current form - if ($formType == $type || !empty($_POST["hidden_{$type}"]) || - !empty($defaults["hidden_{$type}"]) - ) { - $showAdditionalInfo = TRUE; - $allPanes[$name]['open'] = 'true'; - } - $fnName = "build{$type}"; - CRM_Contribute_Form_AdditionalInfo::$fnName($this); + // see if we need to include this paneName in the current form + if ($formType === 'PaymentReminders' || !empty($_POST['hidden_PaymentReminders']) + ) { + $allPanes[ts('Payment Reminders')]['open'] = 'true'; } + $this->add('hidden', 'hidden_PaymentReminders', 1); + $this->add('text', 'initial_reminder_day', ts('Send Initial Reminder'), ['size' => 3]); + $this->addRule('initial_reminder_day', ts('Please enter a valid reminder day.'), 'positiveInteger'); + $this->add('text', 'max_reminders', ts('Send up to'), ['size' => 3]); + $this->addRule('max_reminders', ts('Please enter a valid No. of reminders.'), 'positiveInteger'); + $this->add('text', 'additional_reminder_day', ts('Send additional reminders'), ['size' => 3]); + $this->addRule('additional_reminder_day', ts('Please enter a valid additional reminder day.'), 'positiveInteger'); + $this->assign('allPanes', $allPanes); - $this->assign('showAdditionalInfo', $showAdditionalInfo); + $this->assign('showAdditionalInfo', TRUE); $this->assign('formType', $formType); if ($formType) { @@ -297,8 +292,8 @@ class CRM_Pledge_Form_Pledge extends CRM_Core_Form { $frequencyUnit->freeze(); $frequencyDay->freeze(); $eachPaymentAmount = $this->_values['original_installment_amount']; - $this->assign('eachPaymentAmount', $eachPaymentAmount); } + $this->assign('eachPaymentAmount', $eachPaymentAmount ?? NULL); if (($this->_values['status_id'] ?? NULL) != CRM_Core_PseudoConstant::getKey('CRM_Pledge_BAO_Pledge', 'status_id', 'Cancelled') diff --git a/templates/CRM/Pledge/Form/Pledge.tpl b/templates/CRM/Pledge/Form/Pledge.tpl index cf1850b2e8..1a3a6cc194 100644 --- a/templates/CRM/Pledge/Form/Pledge.tpl +++ b/templates/CRM/Pledge/Form/Pledge.tpl @@ -157,11 +157,6 @@ // load panes function calls for snippet based on id of crm-accordion-header function loadPanes( id ) { var url = "{/literal}{crmURL p='civicrm/contact/view/pledge' q='snippet=4&formType=' h=0}{literal}" + id; - {/literal} - {if $contributionMode} - url = url + "&mode={$contributionMode}"; - {/if} - {literal} if ( ! $('div.'+id).html() ) { var loading = '{/literal}{ts escape='js'}loading{/ts}{literal} {/literal}{ts escape='js'}Loading{/ts}{literal}...'; $('div.'+id).html(loading);