From b59a905f0a708260e92e464a5c5499728ffe0d2c Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Mon, 22 Apr 2019 09:45:41 +1000 Subject: [PATCH] Convert Pledge Calander Date and Start Date for pleges to use datepicker rather than jcalendar --- CRM/Contribute/Form/ContributionPage.php | 2 +- CRM/Contribute/Form/ContributionPage/Amount.php | 4 ++-- CRM/Core/Payment/Dummy.php | 8 ++++++++ CRM/Pledge/BAO/PledgeBlock.php | 12 ++++++------ templates/CRM/Contribute/Form/Contribution/Main.tpl | 2 +- .../CRM/Contribute/Form/ContributionPage/Amount.tpl | 2 +- 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/CRM/Contribute/Form/ContributionPage.php b/CRM/Contribute/Form/ContributionPage.php index a7e95aedfe..d47d7a5224 100644 --- a/CRM/Contribute/Form/ContributionPage.php +++ b/CRM/Contribute/Form/ContributionPage.php @@ -339,7 +339,7 @@ class CRM_Contribute_Form_ContributionPage extends CRM_Core_Form { // @todo look to change to $defaults['start_date'] = date('Ymd His'); // main settings form overrides this to implement above but this is left here // 'in case' another extending form uses start_date - for now - list($defaults['start_date'], $defaults['start_date_time']) = CRM_Utils_Date::setDateDefaults(); + $defaults['start_date'] = date('Y-m-d H:i:s'); } if (!empty($defaults['recur_frequency_unit'])) { diff --git a/CRM/Contribute/Form/ContributionPage/Amount.php b/CRM/Contribute/Form/ContributionPage/Amount.php index ed7efb2d82..29fdd78efe 100644 --- a/CRM/Contribute/Form/ContributionPage/Amount.php +++ b/CRM/Contribute/Form/ContributionPage/Amount.php @@ -179,7 +179,7 @@ class CRM_Contribute_Form_ContributionPage_Amount extends CRM_Contribute_Form_Co $this->addElement('checkbox', 'adjust_recur_start_date', ts('Adjust Recurring Start Date'), NULL, ['onclick' => "showHideByValue('adjust_recur_start_date',true,'recurDefaults','table-row','radio',false);"] ); - $this->addDate('pledge_calendar_date', ts('Specific Calendar Date')); + $this->add('datepicker', 'pledge_calendar_date', ts('Specific Calendar Date'), [], FALSE, ['time' => FALSE]); $month = CRM_Utils_Date::getCalendarDayOfMonth(); $this->add('select', 'pledge_calendar_month', ts('Specific day of Month'), $month); $pledgeDefaults = [ @@ -512,7 +512,7 @@ class CRM_Contribute_Form_ContributionPage_Amount extends CRM_Contribute_Form_Co 'calendar_month' => 'pledge_calendar_month', ]; if ($params['pledge_default_toggle'] == 'contribution_date') { - $fieldValue = json_encode(['contribution_date' => date('m/d/Y')]); + $fieldValue = json_encode(['contribution_date' => date('Y-m-d')]); } else { foreach ($pledgeDateFields as $key => $pledgeDateField) { diff --git a/CRM/Core/Payment/Dummy.php b/CRM/Core/Payment/Dummy.php index 1fdbd9cda3..d2f8c5c00d 100644 --- a/CRM/Core/Payment/Dummy.php +++ b/CRM/Core/Payment/Dummy.php @@ -146,6 +146,14 @@ class CRM_Core_Payment_Dummy extends CRM_Core_Payment { return TRUE; } + /** + * Supports altering future start dates + * @return bool + */ + public function supportsFutureRecurStartDate() { + return TRUE; + } + /** * Submit a refund payment * diff --git a/CRM/Pledge/BAO/PledgeBlock.php b/CRM/Pledge/BAO/PledgeBlock.php index bbba0e1455..732a61a450 100644 --- a/CRM/Pledge/BAO/PledgeBlock.php +++ b/CRM/Pledge/BAO/PledgeBlock.php @@ -308,15 +308,15 @@ class CRM_Pledge_BAO_PledgeBlock extends CRM_Pledge_DAO_PledgeBlock { foreach ($date as $field => $value) { switch ($field) { case 'contribution_date': - $form->addDate('start_date', ts('First installment payment')); - $paymentDate = $value = date('m/d/Y'); - list($defaults['start_date'], $defaults['start_date_time']) = CRM_Utils_Date::setDateDefaults(NULL); + $form->add('datepicker', 'start_date', ts('First installment payment'), [], FALSE, ['time' => FALSE]); + $paymentDate = $value = date('Y-m-d'); + $defaults['start_date'] = $value; $form->assign('is_date', TRUE); break; case 'calendar_date': - $form->addDate('start_date', ts('First installment payment')); - list($defaults['start_date'], $defaults['start_date_time']) = CRM_Utils_Date::setDateDefaults($value); + $form->add('datepicker', 'start_date', ts('First installment payment'), [], FALSE, ['time' => FALSE]); + $defaults['start_date'] = $value; $form->assign('is_date', TRUE); $paymentDate = $value; break; @@ -325,7 +325,7 @@ class CRM_Pledge_BAO_PledgeBlock extends CRM_Pledge_DAO_PledgeBlock { $month = CRM_Utils_Date::getCalendarDayOfMonth(); $form->add('select', 'start_date', ts('Day of month installments paid'), $month); $paymentDate = CRM_Pledge_BAO_Pledge::getPaymentDate($value); - list($defaults['start_date'], $defaults['start_date_time']) = CRM_Utils_Date::setDateDefaults($paymentDate); + $defaults['start_date'] = $paymentDate; break; default: diff --git a/templates/CRM/Contribute/Form/Contribution/Main.tpl b/templates/CRM/Contribute/Form/Contribution/Main.tpl index 838743a217..898c4e028b 100644 --- a/templates/CRM/Contribute/Form/Contribution/Main.tpl +++ b/templates/CRM/Contribute/Form/Contribution/Main.tpl @@ -135,7 +135,7 @@
{if $start_date_editable} {if $is_date} -
{$form.start_date.label}
{include file="CRM/common/jcalendar.tpl" elementName=start_date}
+
{$form.start_date.label}
{$form.start_date.html}
{else}
{$form.start_date.label}
{$form.start_date.html}
{/if} diff --git a/templates/CRM/Contribute/Form/ContributionPage/Amount.tpl b/templates/CRM/Contribute/Form/ContributionPage/Amount.tpl index 494ebba8eb..3a5213dd85 100644 --- a/templates/CRM/Contribute/Form/ContributionPage/Amount.tpl +++ b/templates/CRM/Contribute/Form/ContributionPage/Amount.tpl @@ -121,7 +121,7 @@ {if $futurePaymentProcessor} -   {include file="CRM/common/jcalendar.tpl" elementName=pledge_calendar_date} +   {$form.pledge_calendar_date.html}   {$form.pledge_calendar_month.html}
{ts}Recurring payment will be processed this day of the month following submission of this contribution page.{/ts}
{/if} -- 2.25.1