Commit | Line | Data |
---|---|---|
e8cca51a | 1 | {*\r |
2 | +--------------------------------------------------------------------+\r | |
2c4c49ca | 3 | | CiviCRM version 4.7 |\r |
e8cca51a | 4 | +--------------------------------------------------------------------+\r |
e7112fa7 | 5 | | Copyright CiviCRM LLC (c) 2004-2015 |\r |
e8cca51a | 6 | +--------------------------------------------------------------------+\r |
7 | | This file is a part of CiviCRM. |\r | |
8 | | |\r | |
9 | | CiviCRM is free software; you can copy, modify, and distribute it |\r | |
10 | | under the terms of the GNU Affero General Public License |\r | |
11 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |\r | |
12 | | |\r | |
13 | | CiviCRM is distributed in the hope that it will be useful, but |\r | |
14 | | WITHOUT ANY WARRANTY; without even the implied warranty of |\r | |
15 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |\r | |
16 | | See the GNU Affero General Public License for more details. |\r | |
17 | | |\r | |
18 | | You should have received a copy of the GNU Affero General Public |\r | |
19 | | License and the CiviCRM Licensing Exception along |\r | |
20 | | with this program; if not, contact CiviCRM LLC |\r | |
21 | | at info[AT]civicrm[DOT]org. If you have questions about the |\r | |
22 | | GNU Affero General Public License or the licensing of CiviCRM, |\r | |
23 | | see the CiviCRM license FAQ at http://civicrm.org/licensing |\r | |
24 | +--------------------------------------------------------------------+\r | |
25 | *}\r | |
0e2d8aaf | 26 | {if $hasParent || $isRepeatingEntity || $scheduleReminderId}\r |
b1e18356 | 27 | {capture assign='entity_type'}{$recurringEntityType|lower}{/capture}\r |
0e2d8aaf | 28 | <script type="text/template" id="recurring-dialog-tpl">\r |
b1e18356 CW |
29 | <div class="recurring-dialog">\r |
30 | <h4>{ts}How should this change affect others in the series?{/ts}</h4>\r | |
31 | <div>\r | |
0e2d8aaf | 32 | <input type="radio" id="recur-only-this-entity" name="recur_mode" value="1">\r |
b1e18356 CW |
33 | <label for="recur-only-this-entity">{ts 1=$entity_type}Only this %1{/ts}</label>\r |
34 | <div class="description">{ts}All others in the series will remain unchanged.{/ts}</div>\r | |
e8cca51a | 35 | \r |
0e2d8aaf | 36 | <input type="radio" id="recur-this-and-all-following-entity" name="recur_mode" value="2">\r |
b1e18356 CW |
37 | <label for="recur-this-and-all-following-entity">{ts 1=$entity_type}This %1 onwards{/ts}</label>\r |
38 | <div class="description">{ts 1=$entity_type}Change applies to this %1 and all that come after it.{/ts}</div>\r | |
0e2d8aaf CW |
39 | \r |
40 | <input type="radio" id="recur-all-entity" name="recur_mode" value="3">\r | |
b1e18356 CW |
41 | <label for="recur-all-entity">{ts 1=$entity_type}Every %1{/ts}</label>\r |
42 | <div class="description">{ts 1=$entity_type}Change applies to every %1 in the series.{/ts}</div>\r | |
0e2d8aaf | 43 | </div>\r |
b1e18356 | 44 | <div class="status help"><div class="icon ui-icon-lightbulb"></div>{ts}Changes to date or time will <em>not</em> be applied to others in the series.{/ts}</div>\r |
e8cca51a | 45 | </div>\r |
0e2d8aaf | 46 | </script>\r |
e8cca51a | 47 | {literal}\r |
48 | <script type="text/javascript">\r | |
49 | CRM.$(function($) {\r | |
0e2d8aaf CW |
50 | var $form, formClass,\r |
51 | /** Add your linked entity mapper here **/\r | |
52 | mapper = {\r | |
53 | 'CRM_Event_Form_ManageEvent_EventInfo': '',\r | |
54 | 'CRM_Event_Form_ManageEvent_Location': '',\r | |
55 | 'CRM_Event_Form_ManageEvent_Fee': '',\r | |
56 | 'CRM_Event_Form_ManageEvent_Registration': '',\r | |
57 | 'CRM_Friend_Form_Event': 'civicrm_tell_friend',\r | |
58 | 'CRM_PCP_Form_Event': 'civicrm_pcp_block',\r | |
59 | 'CRM_Activity_Form_Activity': ''\r | |
60 | };\r | |
61 | \r | |
e8cca51a | 62 | function cascadeChangesDialog() {\r |
0e2d8aaf | 63 | CRM.confirm({\r |
b24ba619 | 64 | title: "{/literal}{ts escape='js' 1=$entity_type}Update repeating %1{/ts}{literal}",\r |
0e2d8aaf CW |
65 | message: $('#recurring-dialog-tpl').html()\r |
66 | })\r | |
67 | .on('crmConfirm:yes', updateMode)\r | |
68 | .on('click change', 'input[name=recur_mode]', function() {\r | |
69 | $('button[data-op=yes]').prop('disabled', false);\r | |
70 | })\r | |
71 | .parent().find('button[data-op=yes]').prop('disabled', true)\r | |
e8cca51a | 72 | }\r |
e8cca51a | 73 | \r |
83f3c8a3 CW |
74 | // Intercept form submissions and check if they will impact the recurring entity\r |
75 | // This ought to attach the handler to the the dialog if we're in a popup, or the page wrapper if we're not\r | |
76 | $('#recurring-dialog-tpl').closest('.crm-container').on('click', '.crm-form-submit.validate', function(e) {\r | |
0e2d8aaf CW |
77 | $form = $(this).closest('form');\r |
78 | var className = ($form.attr('class') || '').match(/CRM_\S*/);\r | |
79 | formClass = className && className[0];\r | |
80 | if (formClass && mapper.hasOwnProperty(formClass) &&\r | |
81 | // For activities, only show this if the changes were not made to the recurring settings\r | |
82 | (formClass !== 'CRM_Activity_Form_Activity' || !CRM.utils.initialValueChanged('.crm-core-form-recurringentity-block'))\r | |
83 | ) {\r | |
84 | cascadeChangesDialog();\r | |
85 | e.preventDefault();\r | |
86 | }\r | |
e8cca51a | 87 | });\r |
88 | \r | |
0e2d8aaf CW |
89 | function updateMode() {\r |
90 | var mode = $('input[name=recur_mode]:checked', this).val(),\r | |
91 | entityID = parseInt('{/literal}{$entityID}{literal}'),\r | |
92 | entityTable = '{/literal}{$entityTable}{literal}';\r | |
93 | if (entityID != "" && mode && mapper.hasOwnProperty(formClass) && entityTable !="") {\r | |
94 | $.getJSON(CRM.url("civicrm/ajax/recurringentity/update-mode",\r | |
95 | {mode: mode, entityId: entityID, entityTable: entityTable, linkedEntityTable: mapper[formClass]})\r | |
96 | ).done(function (result) {\r | |
e8cca51a | 97 | if (result.status != "" && result.status == 'Done') {\r |
0e2d8aaf | 98 | $form.submit();\r |
e8cca51a | 99 | } else if (result.status != "" && result.status == 'Error') {\r |
b1e18356 | 100 | if (confirm("{/literal}{ts escape='js' 1=$entity_type}Mode could not be updated, save only this %1?{/ts}{literal}")) {\r |
0e2d8aaf | 101 | $form.submit();\r |
e8cca51a | 102 | }\r |
103 | }\r | |
0e2d8aaf | 104 | });\r |
e8cca51a | 105 | }\r |
106 | }\r | |
107 | });\r | |
108 | </script>\r | |
109 | {/literal}\r | |
110 | {/if}\r |