Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix recursive display of payment_reminders #27774

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions CRM/Contribute/Form/AdditionalInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,11 @@ public static function buildAdditionalDetail(&$form) {
*
* 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]);
Expand Down
41 changes: 18 additions & 23 deletions CRM/Pledge/Form/Pledge.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,33 +195,28 @@ public function buildQuickForm(): void {
$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) {
Expand Down Expand Up @@ -297,8 +292,8 @@ public function buildQuickForm(): void {
$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')
Expand Down
5 changes: 0 additions & 5 deletions templates/CRM/Pledge/Form/Pledge.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<img src="{/literal}{$config->resourceBase}i/loading.gif{literal}" alt="{/literal}{ts escape='js'}loading{/ts}{literal}" />&nbsp;{/literal}{ts escape='js'}Loading{/ts}{literal}...';
$('div.'+id).html(loading);
Expand Down