Commit 0787ece8 authored by mattwire's avatar mattwire
Browse files

Use our version of formRule instead of core version

parent ae58a997
......@@ -171,7 +171,7 @@ class CRM_AdvancedEvents_Form_RecurringEntity {
$offsetOptions = range(1, 30);
unset($offsetOptions[0]);
$form->add('select', 'start_action_offset', NULL, $offsetOptions, FALSE);
$form->addFormRule(['CRM_Core_Form_RecurringEntity', 'formRule']);
$form->addFormRule(['CRM_AdvancedEvents_Form_RecurringEntity', 'formRule']);
$form->add('datepicker', 'repeat_absolute_date', ts('On'), [], FALSE, ['time' => FALSE]);
$form->add('text', 'exclude_date_list', ts('Exclude Dates'), ['class' => 'twenty']);
$form->addElement('hidden', 'allowRepeatConfigToSubmit', '', ['id' => 'allowRepeatConfigToSubmit']);
......
{* http://civicrm.org/licensing *}
{capture assign='entityType'}{$params.entityType|lower}{/capture}
{htxt id="id-repeats-title"}
{ts}Repeats{/ts}
{/htxt}
{htxt id="id-repeats"}
{ts 1=$entityType}Access the drop-down menus here to select how frequently your %1 occurs.{/ts}
{ts 1=$entityType}Example: You would select options "1 month", if your %1 occurs every month.{/ts}
{/htxt}
{htxt id="id-repeats-on-title"}
{ts}Repeats on{/ts}
{/htxt}
{htxt id="id-repeats-on"}
{ts 1=$entityType}You can choose to select your %1 to repeat on weekdays, weekends or any combination of day of the week.{/ts}<br/>
{ts 1=$entityType}Example: You can select Monday, Wednesday and Friday for your %1 to occur on alternate weekdays.{/ts}
{/htxt}
{htxt id="id-repeats-by-month-title"}
{ts}Repeats by day of the month{/ts}
{/htxt}
{htxt id="id-repeats-by-month"}
{ts}Options given here are days of a month from 1 - 31{/ts}<br/>
{ts 1=$entityType}Example: If your %1 repeats 8th of every month then you would select 8.{/ts}
{/htxt}
{htxt id="id-repeats-by-week-title"}
{ts}Repeats by day of the week{/ts}
{/htxt}
{htxt id="id-repeats-by-week"}
{ts 1=$entityType}You can choose to select %1 occurring every third Friday, last Monday, fourth Wednesday of the month and various other combinations given in the dropdown.{/ts}
{/htxt}
{htxt id="id-ends-after-title"}
{ts}Ends{/ts}
{/htxt}
{htxt id="id-ends-after"}
{ts 1=$entityType}Use this field to limit/end the repetition of the %1.{/ts}<br/>
{ts 1=$entityType}Example: If you want to repeat an %1 6 times, then set 6 as a value for this field.{/ts}
{/htxt}
{htxt id="id-ends-on-title"}
{ts}Ends{/ts}
{/htxt}
{htxt id="id-ends-on"}
{ts}Choose a specific date to limit/end the repetition.{/ts}
{/htxt}
{htxt id="id-exclude-date-title"}
{ts}Exclude Date(s){/ts}
{/htxt}
{htxt id="id-exclude-date"}
{ts}This field enables you to alter certain sessions, skip holidays, or create gaps in the sequence for other reasons.{/ts}
{/htxt}
\ No newline at end of file
{* http://civicrm.org/licensing *}
<div class="crm-core-form-recurringentity-block crm-accordion-wrapper{if $recurringFormIsEmbedded && !$scheduleReminderId} collapsed{/if}" id="recurring-entity-block">
<div class="crm-accordion-header">
{ts 1=$recurringEntityType}Repeat %1{/ts}
</div>
<div class="crm-accordion-body">
{if !$recurringFormIsEmbedded}
<div class="crm-submit-buttons">
{include file="CRM/common/formButtons.tpl" location="top"}
</div>
{/if}
<table class="form-layout-compressed">
<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>
</tr>
<tr class="crm-core-form-recurringentity-block-start_action_condition">
<td class="label">
<label for="repeats_on">{$form.start_action_condition.label} {help id="id-repeats-on" entityType=$recurringEntityType file="CRM/Core/Form/RecurringEntity.hlp"}</label>
</td>
<td>
{$form.start_action_condition.html}
</td>
</tr>
<tr class="crm-core-form-recurringentity-block-repeats_by">
<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"></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></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"> </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>
<td>{$form.exclude_date_list.html}</td>
</tr>
</table>
{if !$recurringFormIsEmbedded}
<div class="crm-submit-buttons">
{include file="CRM/common/formButtons.tpl" location="bottom"}
</div>
{/if}
</div>
</div>
{literal}
<script type="text/javascript">
(function (_) {
CRM.$(function($) {
var $form = $('form.{/literal}{$form.formClass}{literal}'),
defaultDate = null;
// Prevent html5 errors
$form.attr('novalidate', 'novalidate');
function changeFrequencyUnit() {
switch ($(this).val()) {
case 'week':
//Show "Repeats On" block when week is selected
$('.crm-core-form-recurringentity-block-start_action_condition', $form).show();
$('.crm-core-form-recurringentity-block-repeats_by td', $form).hide();
break;
case 'month':
//Show "Repeats By" block when month is selected
$('.crm-core-form-recurringentity-block-start_action_condition', $form).hide();
$('.crm-core-form-recurringentity-block-repeats_by td', $form).show();
break;
default:
$('.crm-core-form-recurringentity-block-start_action_condition', $form).hide();
$('.crm-core-form-recurringentity-block-repeats_by td', $form).hide();
}
}
$('#repetition_frequency_unit', $form).each(changeFrequencyUnit).change(changeFrequencyUnit);
function disableEnds() {
$("#repeat_absolute_date, #start_action_offset").prop('disabled', true).removeClass('required');
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[name=ends]').click(function() {
disableEnds();
});
disableEnds();
function validate() {
var valid = $(':input', '#recurring-entity-block').valid(),
modified = CRM.utils.initialValueChanged('#recurring-entity-block');
$('#allowRepeatConfigToSubmit', $form).val(valid && modified ? '1' : '0');
return valid;
}
function getDisplayDate(date) {
return $.datepicker.formatDate(CRM.config.dateInputFormat, $.datepicker.parseDate('yy-mm-dd', date));
}
// Combine select2 and datepicker into a multi-select-date widget
$('#exclude_date_list', $form).crmSelect2({
multiple: true,
data: [],
initSelection: function(element, callback) {
var values = [];
$.each($(element).val().split(','), function(k, v) {
values.push({
text: getDisplayDate(v),
id: v
});
});
callback(values);
}
})
.on('select2-opening', function(e) {
var $el = $(this),
$input = $('.select2-search-field input', $el.select2('container'));
// Prevent select2 from opening and show a datepicker instead
e.preventDefault();
if (!$input.data('datepicker')) {
$input
.datepicker({
beforeShow: function() {
var existingSelections = _.pluck($el.select2('data') || [], 'id');
return {
changeMonth: true,
changeYear: true,
defaultDate: defaultDate,
beforeShowDay: function(date) {
// Don't allow the same date to be selected twice
var dateStr = $.datepicker.formatDate('yy-mm-dd', date);
if (_.includes(existingSelections, dateStr)) {
return [false, '', '{/literal}{ts escape='js'}Already selected{/ts}{literal}'];
}
return [true, '', ''];
}
};
}
})
.datepicker('show')
.on('change.crmDate', function() {
if ($(this).val()) {
var date = defaultDate = $(this).datepicker('getDate'),
data = $el.select2('data') || [];
data.push({
text: $.datepicker.formatDate(CRM.config.dateInputFormat, date),
id: $.datepicker.formatDate('yy-mm-dd', date)
});
$el.select2('data', data, true);
}
})
.on('keyup', function() {
$(this).val('').datepicker('show');
});
}
})
// Don't leave datepicker open when clearing selections
.on('select2-removed', function() {
$('input.hasDatepicker', $(this).select2('container'))
.datepicker('hide');
});
// Dialog for preview repeat Configuration dates
function previewDialog() {
// Set default value for start date on activity forms before generating preview
if (!$('#repetition_start_date', $form).val() && $('#activity_date_time', $form).val()) {
$('#repetition_start_date', $form)
.val($('#activity_date_time', $form).val())
.next().val($('#activity_date_time', $form).next().val())
.siblings('.hasTimeEntry').val($('#activity_date_time', $form).siblings('.hasTimeEntry').val());
}
var payload = $form.serialize() + '{/literal}&entity_table={$entityTable}&entity_id={$currentEntityId}{literal}';
CRM.confirm({
width: '50%',
url: CRM.url("civicrm/recurringentity/preview", payload)
}).on('crmConfirm:yes', function() {
$form.submit();
});
}
$('#_qf_Repeat_submit-top, #_qf_Repeat_submit-bottom').click(function (e) {
if (validate()) {
previewDialog();
}
e.preventDefault();
});
$('#_qf_Activity_upload-top, #_qf_Activity_upload-bottom').click(function (e) {
if (CRM.utils.initialValueChanged('#recurring-entity-block')) {
e.preventDefault();
if (validate()) {
previewDialog();
}
}
});
// Enable/disable form buttons when not embedded in another form
$form.on('change', function() {
$('#_qf_Repeat_submit-top, #_qf_Repeat_submit-bottom').prop('disabled', !CRM.utils.initialValueChanged('#recurring-entity-block'));
});
// Pluralize frequency options
var recurringFrequencyOptions = {/literal}{$recurringFrequencyOptions|@json_encode}{literal};
function pluralizeUnits() {
CRM.utils.setOptions($('[name=repetition_frequency_unit]', $form),
$(this).val() === '1' ? recurringFrequencyOptions.single : recurringFrequencyOptions.plural);
}
$('[name=repetition_frequency_interval]', $form).each(pluralizeUnits).change(pluralizeUnits);
});
})(CRM._);
</script>
{/literal}
{*
+--------------------------------------------------------------------+
| CiviCRM version 5 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2019 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*}
{* No matches for submitted search request. *}
<div class="messages status no-popup">
<div class="icon inform-icon"></div> &nbsp;
{if $qill}{ts}No matches found for:{/ts}
{include file="CRM/common/displaySearchCriteria.tpl"}
{else}
{ts}None found.{/ts}
{/if}
<br />
{ts}Suggestions:{/ts}
<ul>
<li>{ts}if you are searching by participant name, check your spelling{/ts}</li>
<li>{ts}try a different spelling or use fewer letters{/ts}</li>
<li>{ts}if you are searching within a date range, try a wider range of values{/ts}</li>
<li>{ts}make sure you have enough privileges in the access control system{/ts}</li>
</ul>
</div>
......@@ -23,16 +23,16 @@
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*}
<div class="help">{ts}View and create events from this template{/ts}</div>
<div class="help">{ts}Create events from this template{/ts}</div>
<div class="crm-block crm-form-block crm-event-manage-repeat-form-block">
{include file="CRM/Core/Form/RecurringEntity.tpl" recurringFormIsEmbedded=false}
{include file="CRM/AdvancedEvents/Form/ManageEvent/RecurringEntity.tpl" recurringFormIsEmbedded=false}
</div>
<div>
{if $rowsEmpty|| $rows}
<div class="crm-block crm-content-block">
{if $rowsEmpty}
<div class="crm-results-block crm-results-block-empty">
{include file="CRM/Event/Form/Search/EmptyResults.tpl"}
{include file="CRM/AdvancedEvents/Form/Search/EmptyResults.tpl"}
</div>
{/if}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment