Skip to content

Commit

Permalink
CRM-19153 Fixed freeze date display, recurring for weekly installments
Browse files Browse the repository at this point in the history
----------------------------------------
* CRM-19153: Future pledge start date causes improper future pledge payment dates
  https://issues.civicrm.org/jira/browse/CRM-19153
  • Loading branch information
Edzelopez committed Sep 2, 2016
1 parent 6cfe164 commit d12affc
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 14 deletions.
2 changes: 1 addition & 1 deletion CRM/Contribute/Form/ContributionPage/Amount.php
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ public function postProcess() {
'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) {
Expand Down
9 changes: 3 additions & 6 deletions CRM/Pledge/BAO/Pledge.php
Original file line number Diff line number Diff line change
Expand Up @@ -1204,15 +1204,12 @@ public static function buildRecurParams($params) {
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)) {
Expand Down
2 changes: 1 addition & 1 deletion CRM/Pledge/BAO/PledgeBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ public static function buildPledgeBlock($form) {
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;
Expand Down
7 changes: 1 addition & 6 deletions CRM/Pledge/BAO/PledgePayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -528,13 +528,8 @@ public static function calculateBaseScheduleDate(&$params) {
}
}
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];
Expand Down

0 comments on commit d12affc

Please sign in to comment.