From 12e53254279b8e94878e1c0ad6c26e9094508b17 Mon Sep 17 00:00:00 2001 From: Edsel Date: Mon, 15 Aug 2016 13:12:02 +0530 Subject: [PATCH] CRM-19153 Bug fixes for start date display & star date calculations ---------------------------------------- * CRM-19153: Future pledge start date causes improper future pledge payment dates https://issues.civicrm.org/jira/browse/CRM-19153 --- CRM/Contribute/BAO/Contribution/Utils.php | 2 +- CRM/Contribute/Form/Contribution/Confirm.php | 5 ++--- CRM/Pledge/BAO/Pledge.php | 4 +++- CRM/Pledge/BAO/PledgeBlock.php | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution/Utils.php b/CRM/Contribute/BAO/Contribution/Utils.php index de4c2e4105..d29ef9f9a2 100644 --- a/CRM/Contribute/BAO/Contribution/Utils.php +++ b/CRM/Contribute/BAO/Contribution/Utils.php @@ -139,7 +139,7 @@ class CRM_Contribute_BAO_Contribution_Utils { $paymentParams['source'] = $paymentParams['contribution_source']; } - if ($form->_values['is_recur'] && $contribution->contribution_recur_id) { + if ($form->_params['is_recur'] && $contribution->contribution_recur_id) { $paymentParams['contributionRecurID'] = $contribution->contribution_recur_id; } if (isset($paymentParams['contribution_source'])) { diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php index 3b7a63dd9f..05311f75e1 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -951,7 +951,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $pledgeParams['create_date'] = $pledgeParams['start_date'] = $pledgeParams['scheduled_date'] = date("Ymd"); if (CRM_Utils_Array::value('start_date', $params)) { $pledgeParams['frequency_day'] = intval(date("d", strtotime(CRM_Utils_Array::value('start_date', $params)))); - $pledgeParams['start_date'] = $pledgeParams['scheduled_date'] = CRM_Utils_Array::value('start_date', $params); + $pledgeParams['start_date'] = $pledgeParams['scheduled_date'] = date('Ymd', strtotime(CRM_Utils_Array::value('start_date', $params))); } $pledgeParams['status_id'] = $contribution->contribution_status_id; $pledgeParams['max_reminders'] = $form->_values['max_reminders']; @@ -1093,7 +1093,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $recurParams['start_date'] = $recurParams['create_date'] = $recurParams['modified_date'] = date('YmdHis'); if (!empty($params['receive_date'])) { - $recurParams['start_date'] = $params['receive_date']; + $recurParams['start_date'] = date('YmdHis', strtotime($params['receive_date'])); } $recurParams['invoice_id'] = CRM_Utils_Array::value('invoiceID', $params); $recurParams['contribution_status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Pending'); @@ -1110,7 +1110,6 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $campaignId = CRM_Utils_Array::value('campaign_id', $params, CRM_Utils_Array::value('campaign_id', $form->_values)); $recurParams['campaign_id'] = $campaignId; - $recurring = CRM_Contribute_BAO_ContributionRecur::add($recurParams); if (is_a($recurring, 'CRM_Core_Error')) { CRM_Core_Error::displaySessionError($recurring); diff --git a/CRM/Pledge/BAO/Pledge.php b/CRM/Pledge/BAO/Pledge.php index 24ea4a8a52..e4b989a18c 100644 --- a/CRM/Pledge/BAO/Pledge.php +++ b/CRM/Pledge/BAO/Pledge.php @@ -1215,7 +1215,9 @@ SELECT pledge.contact_id as contact_id, } switch ($field) { case 'contribution_date': - $date = date('Ymd'); + if (empty($date)) { + $date = date('Ymd'); + } break; case 'calendar_date': diff --git a/CRM/Pledge/BAO/PledgeBlock.php b/CRM/Pledge/BAO/PledgeBlock.php index 357686bf42..1419c47341 100644 --- a/CRM/Pledge/BAO/PledgeBlock.php +++ b/CRM/Pledge/BAO/PledgeBlock.php @@ -311,7 +311,7 @@ class CRM_Pledge_BAO_PledgeBlock extends CRM_Pledge_DAO_PledgeBlock { case 'contribution_date': $form->addDate('start_date', ts('First installment payment')); $paymentDate = $value = date('d/m/Y'); - list($defaults['start_date'], $defaults['start_date_time']) = CRM_Utils_Date::setDateDefaults($value); + list($defaults['start_date'], $defaults['start_date_time']) = CRM_Utils_Date::setDateDefaults(NULL); $form->assign('is_date', TRUE); break; -- 2.25.1