[NFC] fix line endings, using windows line endings, change to 'unix
[civicrm-core.git] / templates / CRM / Core / Form / RecurringEntity.tpl
index f22866499592b2b7098dd6eb62362a0dfe594c50..d697566ad84fdd48b5458a432c7bf6b5930627e0 100644 (file)
-{*\r
- +--------------------------------------------------------------------+\r
- | CiviCRM version 4.7                                                |\r
- +--------------------------------------------------------------------+\r
- | Copyright CiviCRM LLC (c) 2004-2018                                |\r
- +--------------------------------------------------------------------+\r
- | This file is a part of CiviCRM.                                    |\r
- |                                                                    |\r
- | CiviCRM is free software; you can copy, modify, and distribute it  |\r
- | under the terms of the GNU Affero General Public License           |\r
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |\r
- |                                                                    |\r
- | CiviCRM is distributed in the hope that it will be useful, but     |\r
- | WITHOUT ANY WARRANTY; without even the implied warranty of         |\r
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |\r
- | See the GNU Affero General Public License for more details.        |\r
- |                                                                    |\r
- | You should have received a copy of the GNU Affero General Public   |\r
- | License and the CiviCRM Licensing Exception along                  |\r
- | with this program; if not, contact CiviCRM LLC                     |\r
- | at info[AT]civicrm[DOT]org. If you have questions about the        |\r
- | GNU Affero General Public License or the licensing of CiviCRM,     |\r
- | see the CiviCRM license FAQ at http://civicrm.org/licensing        |\r
- +--------------------------------------------------------------------+\r
-*}\r
-\r
-<div class="crm-core-form-recurringentity-block crm-accordion-wrapper{if $recurringFormIsEmbedded && !$scheduleReminderId} collapsed{/if}" id="recurring-entity-block">\r
-  <div class="crm-accordion-header">\r
-    {ts 1=$recurringEntityType}Repeat %1{/ts}\r
-  </div>\r
-  <div class="crm-accordion-body">\r
-    {if !$recurringFormIsEmbedded}\r
-      <div class="crm-submit-buttons">\r
-        {include file="CRM/common/formButtons.tpl" location="top"}\r
-      </div>\r
-    {/if}\r
-    <table class="form-layout-compressed">\r
-      <tr class="crm-core-form-recurringentity-block-repetition_start_date" id="tr-repetition_start_date">\r
-        <td class="label">{$form.repetition_start_date.label}</td>\r
-        <td>{include file="CRM/common/jcalendar.tpl" elementName=repetition_start_date}</td>\r
-      </tr>\r
-      <tr class="crm-core-form-recurringentity-block-repetition_frequency">\r
-        <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>\r
-        <td>{$form.repetition_frequency_interval.html} {$form.repetition_frequency_unit.html}</td>\r
-      </tr>\r
-      <tr class="crm-core-form-recurringentity-block-start_action_condition">\r
-        <td class="label">\r
-          <label for="repeats_on">{$form.start_action_condition.label} {help id="id-repeats-on" entityType=$recurringEntityType file="CRM/Core/Form/RecurringEntity.hlp"}</label>\r
-        </td>\r
-        <td>\r
-          {$form.start_action_condition.html}\r
-        </td>\r
-      </tr>\r
-      <tr class="crm-core-form-recurringentity-block-repeats_by">\r
-        <td class="label">{$form.repeats_by.label} {help id="id-repeats-by-month" entityType=$recurringEntityType file="CRM/Core/Form/RecurringEntity.hlp"}</td>\r
-        <td>{$form.repeats_by.1.html}&nbsp;&nbsp;{$form.limit_to.html}\r
-        </td>\r
-      </tr>\r
-      <tr class="crm-core-form-recurringentity-block-repeats_by">\r
-        <td class="label">{help id="id-repeats-by-week" entityType=$recurringEntityType file="CRM/Core/Form/RecurringEntity.hlp"}</td>\r
-        <td>{$form.repeats_by.2.html}&nbsp;&nbsp;{$form.entity_status_1.html}&nbsp;&nbsp;{$form.entity_status_2.html}\r
-        </td>\r
-      </tr>\r
-      <tr class="crm-core-form-recurringentity-block-ends">\r
-        <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>\r
-        <td>{$form.ends.1.html}&nbsp;{$form.start_action_offset.html} {ts}occurrences{/ts}</td>\r
-      </tr>\r
-      <tr class="crm-core-form-recurringentity-block-absolute_date">\r
-        <td class="label"> {help id="id-ends-on" entityType=$recurringEntityType file="CRM/Core/Form/RecurringEntity.hlp"}</td>\r
-        <td>{$form.ends.2.html}&nbsp;{include file="CRM/common/jcalendar.tpl" elementName=repeat_absolute_date}\r
-        </td>\r
-      </tr>\r
-      <tr class="crm-core-form-recurringentity-block-exclude_date">\r
-        <td class="label">{$form.exclude_date_list.label} {help id="id-exclude-date" entityType=$recurringEntityType file="CRM/Core/Form/RecurringEntity.hlp"}</td>\r
-        <td>{$form.exclude_date_list.html}</td>\r
-      </tr>\r
-    </table>\r
-    {if !$recurringFormIsEmbedded}\r
-      <div class="crm-submit-buttons">\r
-        {include file="CRM/common/formButtons.tpl" location="bottom"}\r
-      </div>\r
-    {/if}\r
-  </div>\r
-</div>\r
-{literal}\r
-<script type="text/javascript">\r
-(function (_) {\r
-  CRM.$(function($) {\r
-    var $form = $('form.{/literal}{$form.formClass}{literal}'),\r
-      defaultDate = null;\r
-\r
-    // Prevent html5 errors\r
-    $form.attr('novalidate', 'novalidate');\r
-\r
-    function changeFrequencyUnit() {\r
-      switch ($(this).val()) {\r
-        case 'week':\r
-          //Show "Repeats On" block when week is selected\r
-          $('.crm-core-form-recurringentity-block-start_action_condition', $form).show();\r
-          $('.crm-core-form-recurringentity-block-repeats_by td', $form).hide();\r
-          break;\r
-        case 'month':\r
-          //Show "Repeats By" block when month is selected\r
-          $('.crm-core-form-recurringentity-block-start_action_condition', $form).hide();\r
-          $('.crm-core-form-recurringentity-block-repeats_by td', $form).show();\r
-          break;\r
-        default:\r
-          $('.crm-core-form-recurringentity-block-start_action_condition', $form).hide();\r
-          $('.crm-core-form-recurringentity-block-repeats_by td', $form).hide();\r
-      }\r
-    }\r
-    $('#repetition_frequency_unit', $form).each(changeFrequencyUnit).change(changeFrequencyUnit);\r
-\r
-    function disableUnselected() {\r
-      $('input:radio[name=ends], input[name=repeats_by]', $form).not(':checked').siblings(':input').prop('disabled', true).removeClass('required');\r
-    }\r
-    disableUnselected();\r
-\r
-    $('input:radio[name=ends], input[name=repeats_by]', $form).click(function() {\r
-      $(this).siblings(':input').prop('disabled', false).filter(':visible').addClass('required').focus();\r
-      disableUnselected();\r
-    });\r
-\r
-    $('input:radio[name=ends]').siblings('.crm-clear-link').click(function() {\r
-      $('input:radio[name=ends][value=1]').prop('checked', true).trigger('click');\r
-    });\r
-\r
-    function validate() {\r
-      var valid = $(':input', '#recurring-entity-block').valid(),\r
-        modified = CRM.utils.initialValueChanged('#recurring-entity-block');\r
-      $('#allowRepeatConfigToSubmit', $form).val(valid && modified ? '1' : '0');\r
-      return valid;\r
-    }\r
-\r
-    function getDisplayDate(date) {\r
-      return $.datepicker.formatDate(CRM.config.dateInputFormat, $.datepicker.parseDate('yy-mm-dd', date));\r
-    }\r
-\r
-    // Combine select2 and datepicker into a multi-select-date widget\r
-    $('#exclude_date_list', $form).crmSelect2({\r
-      multiple: true,\r
-      data: [],\r
-      initSelection: function(element, callback) {\r
-        var values = [];\r
-        $.each($(element).val().split(','), function(k, v) {\r
-          values.push({\r
-            text: getDisplayDate(v),\r
-            id: v\r
-          });\r
-        });\r
-        callback(values);\r
-      }\r
-    })\r
-      .on('select2-opening', function(e) {\r
-        var $el = $(this),\r
-          $input = $('.select2-search-field input', $el.select2('container'));\r
-        // Prevent select2 from opening and show a datepicker instead\r
-        e.preventDefault();\r
-        if (!$input.data('datepicker')) {\r
-          $input\r
-            .datepicker({\r
-              beforeShow: function() {\r
-                var existingSelections = _.pluck($el.select2('data') || [], 'id');\r
-                return {\r
-                  changeMonth: true,\r
-                  changeYear: true,\r
-                  defaultDate: defaultDate,\r
-                  beforeShowDay: function(date) {\r
-                    // Don't allow the same date to be selected twice\r
-                    var dateStr = $.datepicker.formatDate('yy-mm-dd', date);\r
-                    if (_.includes(existingSelections, dateStr)) {\r
-                      return [false, '', '{/literal}{ts escape='js'}Already selected{/ts}{literal}'];\r
-                    }\r
-                    return [true, '', ''];\r
-                  }\r
-                };\r
-              }\r
-            })\r
-            .datepicker('show')\r
-            .on('change.crmDate', function() {\r
-              if ($(this).val()) {\r
-                var date = defaultDate = $(this).datepicker('getDate'),\r
-                data = $el.select2('data') || [];\r
-                data.push({\r
-                  text: $.datepicker.formatDate(CRM.config.dateInputFormat, date),\r
-                  id: $.datepicker.formatDate('yy-mm-dd', date)\r
-                });\r
-                $el.select2('data', data, true);\r
-              }\r
-            })\r
-            .on('keyup', function() {\r
-              $(this).val('').datepicker('show');\r
-            });\r
-        }\r
-      })\r
-      // Don't leave datepicker open when clearing selections\r
-      .on('select2-removed', function() {\r
-        $('input.hasDatepicker', $(this).select2('container'))\r
-          .datepicker('hide');\r
-      });\r
-\r
-\r
-    // Dialog for preview repeat Configuration dates\r
-    function previewDialog() {\r
-      // Set default value for start date on activity forms before generating preview\r
-      if (!$('#repetition_start_date', $form).val() && $('#activity_date_time', $form).val()) {\r
-        $('#repetition_start_date', $form)\r
-          .val($('#activity_date_time', $form).val())\r
-          .next().val($('#activity_date_time', $form).next().val())\r
-          .siblings('.hasTimeEntry').val($('#activity_date_time', $form).siblings('.hasTimeEntry').val());\r
-      }\r
-      var payload = $form.serialize() + '{/literal}&entity_table={$entityTable}&entity_id={$currentEntityId}{literal}';\r
-      CRM.confirm({\r
-        width: '50%',\r
-        url: CRM.url("civicrm/recurringentity/preview", payload)\r
-      }).on('crmConfirm:yes', function() {\r
-          $form.submit();\r
-        });\r
-    }\r
-\r
-    $('#_qf_Repeat_submit-top, #_qf_Repeat_submit-bottom').click(function (e) {\r
-      if (validate()) {\r
-        previewDialog();\r
-      }\r
-      e.preventDefault();\r
-    });\r
-\r
-    $('#_qf_Activity_upload-top, #_qf_Activity_upload-bottom').click(function (e) {\r
-      if (CRM.utils.initialValueChanged('#recurring-entity-block')) {\r
-        e.preventDefault();\r
-        if (validate()) {\r
-          previewDialog();\r
-        }\r
-      }\r
-    });\r
-\r
-    // Enable/disable form buttons when not embedded in another form\r
-    $form.on('change', function() {\r
-      $('#_qf_Repeat_submit-top, #_qf_Repeat_submit-bottom').prop('disabled', !CRM.utils.initialValueChanged('#recurring-entity-block'));\r
-    });\r
-\r
-    // Pluralize frequency options\r
-    var recurringFrequencyOptions = {/literal}{$recurringFrequencyOptions|@json_encode}{literal};\r
-    function pluralizeUnits() {\r
-      CRM.utils.setOptions($('[name=repetition_frequency_unit]', $form),\r
-        $(this).val() === '1' ? recurringFrequencyOptions.single : recurringFrequencyOptions.plural);\r
-    }\r
-    $('[name=repetition_frequency_interval]', $form).each(pluralizeUnits).change(pluralizeUnits);\r
-\r
-  });\r
-})(CRM._);\r
-</script>\r
-{/literal}\r
+{*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.7                                                |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2018                                |
+ +--------------------------------------------------------------------+
+ | 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        |
+ +--------------------------------------------------------------------+
+*}
+
+<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_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>
+      </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} {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>
+      </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>
+      </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>
+      </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>
+      </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 disableUnselected() {
+      $('input:radio[name=ends], input[name=repeats_by]', $form).not(':checked').siblings(':input').prop('disabled', true).removeClass('required');
+    }
+    disableUnselected();
+
+    $('input:radio[name=ends], input[name=repeats_by]', $form).click(function() {
+      $(this).siblings(':input').prop('disabled', false).filter(':visible').addClass('required').focus();
+      disableUnselected();
+    });
+
+    $('input:radio[name=ends]').siblings('.crm-clear-link').click(function() {
+      $('input:radio[name=ends][value=1]').prop('checked', true).trigger('click');
+    });
+
+    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}