Skip to content

Commit

Permalink
Merge pull request #12746 from mattwire/repeat_converttodatepicker
Browse files Browse the repository at this point in the history
Convert RecurringEntity form to datepicker
  • Loading branch information
eileenmcnaughton authored Sep 13, 2018
2 parents 53258b7 + aff91e5 commit 8e39301
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 31 deletions.
14 changes: 6 additions & 8 deletions CRM/Core/Form/RecurringEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public static function setDefaultValues() {
if (self::$_scheduleReminderDetails->start_action_offset) {
$defaults['ends'] = 1;
}
list($defaults['repeat_absolute_date']) = CRM_Utils_Date::setDateDefaults(self::$_scheduleReminderDetails->absolute_date);
$defaults['repeat_absolute_date'] = self::$_scheduleReminderDetails->absolute_date;
if (self::$_scheduleReminderDetails->absolute_date) {
$defaults['ends'] = 2;
}
Expand Down Expand Up @@ -184,7 +184,7 @@ public static function buildQuickForm(&$form) {
$form->add('select', 'repetition_frequency_unit', ts('Repeats every'), CRM_Core_SelectValues::getRecurringFrequencyUnits(), FALSE, array('class' => 'required'));
$numericOptions = CRM_Core_SelectValues::getNumericOptions(1, 30);
$form->add('select', 'repetition_frequency_interval', NULL, $numericOptions, FALSE, array('class' => 'required'));
$form->addDateTime('repetition_start_date', ts('Repetition Start Date'), FALSE, array('formatType' => 'activityDateTime'));
$form->add('datepicker', 'repetition_start_date', ts('Start Date'), array(), FALSE, array('time' => TRUE));
foreach ($dayOfTheWeek as $key => $val) {
$startActionCondition[] = $form->createElement('checkbox', $key, NULL, $val);
}
Expand All @@ -193,7 +193,7 @@ public static function buildQuickForm(&$form) {
'1' => ts('day of the month'),
'2' => ts('day of the week'),
);
$form->addRadio('repeats_by', ts("Repeats by"), $roptionTypes, array('required' => TRUE), NULL);
$form->addRadio('repeats_by', ts("Repeats on"), $roptionTypes, array('required' => TRUE), NULL);
$form->add('select', 'limit_to', '', CRM_Core_SelectValues::getNumericOptions(1, 31));
$dayOfTheWeekNo = array(
'first' => ts('First'),
Expand All @@ -215,10 +215,8 @@ public static function buildQuickForm(&$form) {
unset($offsetOptions[0]);
$form->add('select', 'start_action_offset', NULL, $offsetOptions, FALSE);
$form->addFormRule(array('CRM_Core_Form_RecurringEntity', 'formRule'));
$form->addDate('repeat_absolute_date', ts('On'), FALSE, array('formatType' => 'mailing'));
$form->add('text', 'exclude_date_list', ts('Exclude Dates'), array(
'class' => 'twenty',
));
$form->add('datepicker', 'repeat_absolute_date', ts('On'), array(), FALSE, array('time' => FALSE));
$form->add('text', 'exclude_date_list', ts('Exclude Dates'), array('class' => 'twenty'));
$form->addElement('hidden', 'allowRepeatConfigToSubmit', '', array('id' => 'allowRepeatConfigToSubmit'));
$form->addButtons(array(
array(
Expand Down Expand Up @@ -334,7 +332,7 @@ public static function formRule($values) {
* @throws \CiviCRM_API3_Exception
*/
public static function postProcess($params = array(), $type, $linkedEntities = array()) {
//Check entity_id not present in params take it from class variable
// Check entity_id not present in params take it from class variable
if (empty($params['entity_id'])) {
$params['entity_id'] = self::$_entityId;
}
Expand Down
48 changes: 25 additions & 23 deletions templates/CRM/Core/Form/RecurringEntity.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@
</div>
{/if}
<table class="form-layout-compressed">
<tr class="crm-core-form-recurringentity-block-repetition_start_date" id="tr-repetition_start_date">
<td class="label">{$form.repetition_start_date.label}</td>
<td>{include file="CRM/common/jcalendar.tpl" elementName=repetition_start_date}</td>
</tr>
<tr class="crm-core-form-recurringentity-block-repetition_frequency">
<td class="label">{$form.repetition_frequency_unit.label}&nbsp;<span class="crm-marker">*</span> {help id="id-repeats" entityType=$recurringEntityType file="CRM/Core/Form/RecurringEntity.hlp"}</td>
<td>{$form.repetition_frequency_interval.html} {$form.repetition_frequency_unit.html}</td>
Expand All @@ -52,23 +48,27 @@
</td>
</tr>
<tr class="crm-core-form-recurringentity-block-repeats_by">
<td class="label">{$form.repeats_by.label} {help id="id-repeats-by-month" entityType=$recurringEntityType file="CRM/Core/Form/RecurringEntity.hlp"}</td>
<td>{$form.repeats_by.1.html}&nbsp;&nbsp;{$form.limit_to.html}
<td class="label">{$form.repeats_by.label}&nbsp;<span class="crm-marker">*</span></td>
<td>{help id="id-repeats-by-month" entityType=$recurringEntityType file="CRM/Core/Form/RecurringEntity.hlp"} {$form.repeats_by.1.html} {$form.limit_to.html}
</td>
</tr>
<tr class="crm-core-form-recurringentity-block-repeats_by">
<td class="label">{help id="id-repeats-by-week" entityType=$recurringEntityType file="CRM/Core/Form/RecurringEntity.hlp"}</td>
<td>{$form.repeats_by.2.html}&nbsp;&nbsp;{$form.entity_status_1.html}&nbsp;&nbsp;{$form.entity_status_2.html}
<td class="label"></td>
<td>{help id="id-repeats-by-week" entityType=$recurringEntityType file="CRM/Core/Form/RecurringEntity.hlp"} {$form.repeats_by.2.html} {$form.entity_status_1.html} {$form.entity_status_2.html}
</td>
</tr>
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr class="crm-core-form-recurringentity-block-repetition_start_date" id="tr-repetition_start_date">
<td class="label">{$form.repetition_start_date.label}</td>
<td>{$form.repetition_start_date.html}</td>
</tr>
<tr class="crm-core-form-recurringentity-block-ends">
<td class="label">{$form.ends.label}&nbsp;<span class="crm-marker">*</span> {help id="id-ends-after" entityType=$recurringEntityType file="CRM/Core/Form/RecurringEntity.hlp"}</td>
<td>{$form.ends.1.html}&nbsp;{$form.start_action_offset.html} {ts}occurrences{/ts}</td>
<td class="label">{$form.ends.label}&nbsp;<span class="crm-marker">*</span></td>
<td>{help id="id-ends-after" entityType=$recurringEntityType file="CRM/Core/Form/RecurringEntity.hlp"} {$form.ends.1.html} {$form.start_action_offset.html} {ts}occurrences{/ts}</td>
</tr>
<tr class="crm-core-form-recurringentity-block-absolute_date">
<td class="label"> {help id="id-ends-on" entityType=$recurringEntityType file="CRM/Core/Form/RecurringEntity.hlp"}</td>
<td>{$form.ends.2.html}&nbsp;{include file="CRM/common/jcalendar.tpl" elementName=repeat_absolute_date}
</td>
<td class="label"> </td>
<td>{help id="id-ends-on" entityType=$recurringEntityType file="CRM/Core/Form/RecurringEntity.hlp"} {$form.ends.2.html} {$form.repeat_absolute_date.html}</td>
</tr>
<tr class="crm-core-form-recurringentity-block-exclude_date">
<td class="label">{$form.exclude_date_list.label} {help id="id-exclude-date" entityType=$recurringEntityType file="CRM/Core/Form/RecurringEntity.hlp"}</td>
Expand Down Expand Up @@ -111,19 +111,21 @@
}
$('#repetition_frequency_unit', $form).each(changeFrequencyUnit).change(changeFrequencyUnit);

function disableUnselected() {
$('input:radio[name=ends], input[name=repeats_by]', $form).not(':checked').siblings(':input').prop('disabled', true).removeClass('required');
}
disableUnselected();
function disableEnds() {
$("#repeat_absolute_date, #start_action_offset").prop('disabled', true).removeClass('required');
$('input:radio[name=ends], input[name=repeats_by]', $form).click(function() {
$(this).siblings(':input').prop('disabled', false).filter(':visible').addClass('required').focus();
disableUnselected();
});
if ($('input[name=ends][value=2]').prop('checked')) {
$("#repeat_absolute_date").prop('disabled', false).addClass('required').focus();
}
else if ($('input[name=ends][value=1]').prop('checked')) {
$('#start_action_offset').prop('disabled', false).addClass('required').focus();
}
}

$('input:radio[name=ends]').siblings('.crm-clear-link').click(function() {
$('input:radio[name=ends][value=1]').prop('checked', true).trigger('click');
$('input[name=ends]').click(function() {
disableEnds();
});
disableEnds();

function validate() {
var valid = $(':input', '#recurring-entity-block').valid(),
Expand Down

0 comments on commit 8e39301

Please sign in to comment.