Merge pull request #4871 from eileenmcnaughton/CRM-15795
[civicrm-core.git] / templates / CRM / Event / Form / ManageEvent / ConfirmRepeatMode.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.6 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2014 |
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM. |
8 | |
9 | CiviCRM is free software; you can copy, modify, and distribute it |
10 | under the terms of the GNU Affero General Public License |
11 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
12 | |
13 | CiviCRM is distributed in the hope that it will be useful, but |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
16 | See the GNU Affero General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU Affero General Public |
19 | License and the CiviCRM Licensing Exception along |
20 | with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
25 *}
26
27 <div id="recurring-dialog" class="hide-block">
28 {ts}How would you like this change to affect other entities in the repetition set?{/ts}<br/><br/>
29 <div class="show-block">
30 <div class="recurring-dialog-inner-wrapper">
31 <div class="recurring-dialog-inner-left">
32 <button class="recurring-dialog-button only-this-event">{ts}Only this entity{/ts}</button>
33 </div>
34 <div class="recurring-dialog-inner-right">{ts}All other entities in the series will remain same.{/ts}</div>
35 </div>
36 <div class="recurring-dialog-inner-wrapper">
37 <div class="recurring-dialog-inner-left">
38 <button class="recurring-dialog-button this-and-all-following-event">{ts}This and Following entities{/ts}</button>
39 </div>
40 <div class="recurring-dialog-inner-right">{ts}Change applies to this and all the following entities.{/ts}</div>
41 </div>
42 <div class="recurring-dialog-inner-wrapper">
43 <div class="recurring-dialog-inner-left">
44 <button class="recurring-dialog-button all-events">{ts}All the entities{/ts}</button>
45 </div>
46 <div class="recurring-dialog-inner-right">{ts}Change applies to all the entities in the series.{/ts}</div>
47 </div>
48 </div>
49 <div class="status"><div class="icon ui-icon-lightbulb"></div> Changes to date or time will NOT be applied to other entities in the series.</div>
50 </div>
51 {if $hasParent || $isRepeatingEntity}
52 {literal}
53 <script type="text/javascript">
54 CRM.$(function($) {
55 var $dialog;
56 /** Add your linked entity mapper here **/
57 var mapper = {'CRM_Event_Form_ManageEvent_EventInfo': '',
58 'CRM_Event_Form_ManageEvent_Location': '',
59 'CRM_Event_Form_ManageEvent_Fee': '',
60 'CRM_Event_Form_ManageEvent_Registration': '',
61 'CRM_Friend_Form_Event': 'civicrm_tell_friend',
62 'CRM_PCP_Form_Event': 'civicrm_pcp_block',
63 'CRM_Activity_Form_Activity': ''
64 };
65 function cascadeChangesDialog() {
66 $dialog = $("#recurring-dialog").dialog({
67 title: 'How does this change affect other repeating entities in the set?',
68 modal: true,
69 width: '650',
70 buttons: {
71 Cancel: function() { //cancel
72 $( this ).dialog( "close" );
73 }
74 }
75 }).dialog('open');
76 }
77 var form = '';
78 $('#crm-main-content-wrapper').on('click', 'div.crm-submit-buttons span.crm-button input[value="Save"], div.crm-submit-buttons span.crm-button input[value="Save and Done"]', function() {
79 form = $(this).parents('form:first').attr('class');
80 if( form != "" && mapper.hasOwnProperty(form) ){
81 cascadeChangesDialog();
82 return false;
83 }
84 });
85
86 $("#_qf_Activity_upload-top, #_qf_Activity_upload-bottom").click(function() {
87 form = $(this).parents('form:first').attr('class');
88 if( form != "" && mapper.hasOwnProperty(form) ){
89 var showPreviewDialog = $.data( document.body, "preview-dialog");
90 if (showPreviewDialog == false) {
91 cascadeChangesDialog();
92 }
93 return false;
94 }
95 });
96
97 $(".only-this-event").click(function() {
98 updateMode(1);
99 });
100
101 $(".this-and-all-following-event").click(function() {
102 updateMode(2);
103 });
104
105 $(".all-events").click(function() {
106 updateMode(3);
107 });
108
109 function updateMode(mode) {
110 var entityID = parseInt('{/literal}{$entityID}{literal}');
111 var entityTable = '{/literal}{$entityTable}{literal}';
112 if (entityID != "" && mode && mapper.hasOwnProperty(form) && entityTable !="") {
113 var ajaxurl = CRM.url("civicrm/ajax/recurringentity/update-mode");
114 var data = {mode: mode, entityId: entityID, entityTable: entityTable, linkedEntityTable: mapper[form]};
115 $.ajax({
116 dataType: "json",
117 data: data,
118 url: ajaxurl,
119 success: function (result) {
120 if (result.status != "" && result.status == 'Done') {
121 $('#mainTabContainer div:visible Form, form.'+form).submit();
122 $dialog.dialog('close');
123 } else if (result.status != "" && result.status == 'Error') {
124 var errorBox = confirm(ts("Mode could not be updated, save only this event?"));
125 if (errorBox == true) {
126 $('#mainTabContainer div:visible Form, form.'+form).submit();
127 $dialog.dialog('close');
128 } else {
129 $dialog.dialog('close');
130 return false;
131 }
132 }
133 }
134 });
135 }
136 }
137 });
138 </script>
139 {/literal}
140 {/if}