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

Convert Pledge Calander Date and Start Date for pledges to use datepic… #14099

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: 1 addition & 1 deletion CRM/Contribute/Form/ContributionPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ public function setDefaultValues() {
// @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'])) {
Expand Down
4 changes: 2 additions & 2 deletions CRM/Contribute/Form/ContributionPage/Amount.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public function buildQuickForm() {
$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 = [
Expand Down Expand Up @@ -512,7 +512,7 @@ public function postProcess() {
'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) {
Expand Down
8 changes: 8 additions & 0 deletions CRM/Core/Payment/Dummy.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@ public function supportsRefund() {
return TRUE;
}

/**
* Supports altering future start dates
* @return bool
*/
public function supportsFutureRecurStartDate() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just makes it so that when your using the dummy processor you can expose the pledge date field on contribution front page

return TRUE;
}

/**
* Submit a refund payment
*
Expand Down
12 changes: 6 additions & 6 deletions CRM/Pledge/BAO/PledgeBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,15 +308,15 @@ public static function buildPledgeBlock($form) {
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;
Expand All @@ -325,7 +325,7 @@ public static function buildPledgeBlock($form) {
$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:
Expand Down
2 changes: 1 addition & 1 deletion templates/CRM/Contribute/Form/Contribution/Main.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
<div class="clear"></div>
{if $start_date_editable}
{if $is_date}
<div class="label">{$form.start_date.label}</div><div class="content">{include file="CRM/common/jcalendar.tpl" elementName=start_date}</div>
<div class="label">{$form.start_date.label}</div><div class="content">{$form.start_date.html}</div>
{else}
<div class="label">{$form.start_date.label}</div><div class="content">{$form.start_date.html}</div>
{/if}
Expand Down
2 changes: 1 addition & 1 deletion templates/CRM/Contribute/Form/ContributionPage/Amount.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
</table>
</div>
{if $futurePaymentProcessor}
<span id="pledge_calendar_date_field">&nbsp;&nbsp;{include file="CRM/common/jcalendar.tpl" elementName=pledge_calendar_date}</span>
<span id="pledge_calendar_date_field">&nbsp;&nbsp;{$form.pledge_calendar_date.html}</span>
<span id="pledge_calendar_month_field">&nbsp;&nbsp;{$form.pledge_calendar_month.html}<br/><span class="description">{ts}Recurring payment will be processed this day of the month following submission of this contribution page.{/ts}</span></span>
{/if}

Expand Down