From 31fdc7057e9af6530d4b45432ea991fe2a580bb8 Mon Sep 17 00:00:00 2001 From: Edsel Date: Fri, 2 Sep 2016 13:28:25 +0530 Subject: [PATCH] CRM-19153 Fixed freeze date display, recurring for weekly installments ---------------------------------------- * CRM-19153: Future pledge start date causes improper future pledge payment dates https://issues.civicrm.org/jira/browse/CRM-19153 --- CRM/Contribute/Form/ContributionPage/Amount.php | 2 +- CRM/Pledge/BAO/Pledge.php | 9 +++------ CRM/Pledge/BAO/PledgeBlock.php | 2 +- CRM/Pledge/BAO/PledgePayment.php | 7 +------ 4 files changed, 6 insertions(+), 14 deletions(-) diff --git a/CRM/Contribute/Form/ContributionPage/Amount.php b/CRM/Contribute/Form/ContributionPage/Amount.php index b646d04b94..bb381e69db 100644 --- a/CRM/Contribute/Form/ContributionPage/Amount.php +++ b/CRM/Contribute/Form/ContributionPage/Amount.php @@ -518,7 +518,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(array('contribution_date' => date('Ymd'))); + $fieldValue = json_encode(array('contribution_date' => date('m/d/Y'))); } else { foreach ($pledgeDateFields as $key => $pledgeDateField) { diff --git a/CRM/Pledge/BAO/Pledge.php b/CRM/Pledge/BAO/Pledge.php index e4b989a18c..c8594c0618 100644 --- a/CRM/Pledge/BAO/Pledge.php +++ b/CRM/Pledge/BAO/Pledge.php @@ -1204,15 +1204,12 @@ SELECT pledge.contact_id as contact_id, public static function getPledgeStartDate($date, $pledgeBlock) { $startDate = (array) json_decode($pledgeBlock['pledge_start_date']); list($field, $value) = each($startDate); - if (!CRM_Utils_Array::value('is_pledge_start_date_visible', $pledgeBlock)) { - if ($field == 'calendar_month') { - $value = self::getPaymentDate($value); - } - return date('Ymd', strtotime($value)); - } if (!empty($date) && !CRM_Utils_Array::value('is_pledge_start_date_editable', $pledgeBlock)) { return $date; } + if (empty($date)) { + $date = $value; + } switch ($field) { case 'contribution_date': if (empty($date)) { diff --git a/CRM/Pledge/BAO/PledgeBlock.php b/CRM/Pledge/BAO/PledgeBlock.php index 1419c47341..a35796dea4 100644 --- a/CRM/Pledge/BAO/PledgeBlock.php +++ b/CRM/Pledge/BAO/PledgeBlock.php @@ -310,7 +310,7 @@ class CRM_Pledge_BAO_PledgeBlock extends CRM_Pledge_DAO_PledgeBlock { switch ($field) { case 'contribution_date': $form->addDate('start_date', ts('First installment payment')); - $paymentDate = $value = date('d/m/Y'); + $paymentDate = $value = date('m/d/Y'); list($defaults['start_date'], $defaults['start_date_time']) = CRM_Utils_Date::setDateDefaults(NULL); $form->assign('is_date', TRUE); break; diff --git a/CRM/Pledge/BAO/PledgePayment.php b/CRM/Pledge/BAO/PledgePayment.php index 6c9e037f17..5f5043aa8b 100644 --- a/CRM/Pledge/BAO/PledgePayment.php +++ b/CRM/Pledge/BAO/PledgePayment.php @@ -528,13 +528,8 @@ WHERE civicrm_pledge.id = %2 } } elseif ($params['frequency_unit'] == 'week') { - - // for week calculate day of week ie. Sunday,Monday etc. as next payment date - $dayOfWeek = date('w', mktime(0, 0, 0, $date['month'], $date['day'], $date['year'])); - $frequencyDay = $params['frequency_day'] - $dayOfWeek; - $scheduleDate = explode("-", date('n-j-Y', mktime(0, 0, 0, $date['month'], - $date['day'] + $frequencyDay, $date['year'] + $date['day'], $date['year'] ))); $date['month'] = $scheduleDate[0]; $date['day'] = $scheduleDate[1]; -- 2.25.1