CRM-16254 - Cannot create a custom Search
[civicrm-core.git] / templates / CRM / Admin / Form / ScheduleReminders.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.6 |
4 +--------------------------------------------------------------------+
5 | Copyright (C) 2011 Marty Wright |
6 | Licensed to CiviCRM under the Academic Free License version 3.0. |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
26 *}
27 {* This template is used for adding/scheduling reminders. *}
28 <div class="crm-block crm-form-block crm-scheduleReminder-form-block">
29 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
30
31 {if $action eq 8}
32 <div class="messages status no-popup">
33 <div class="icon inform-icon"></div>
34 {ts 1=$reminderName}WARNING: You are about to delete the Reminder titled <strong>%1</strong>.{/ts} {ts}Do you want to continue?{/ts}
35 </div>
36 {else}
37 <table class="form-layout-compressed">
38 <tr class="crm-scheduleReminder-form-block-title">
39 <td class="right">{$form.title.label}</td><td colspan="3">{$form.title.html}</td>
40 </tr>
41 <tr>
42 <td class="label">{$form.entity.label}</td>
43 <td>{$form.entity.html}</td>
44 </tr>
45
46 <tr class="crm-scheduleReminder-form-block-when">
47 <td class="right">{$form.start_action_offset.label}</td>
48 <td colspan="3">{include file="CRM/common/jcalendar.tpl" elementName=absolute_date} <strong id='OR'>OR</strong><br /></td>
49 </tr>
50
51 <tr id="relativeDate" class="crm-scheduleReminder-form-block-description">
52 <td class="right"></td>
53 <td colspan="3">{$form.start_action_offset.html}&nbsp;&nbsp;&nbsp;{$form.start_action_unit.html}&nbsp;&nbsp;&nbsp;{$form.start_action_condition.html}&nbsp;&nbsp;&nbsp;{$form.start_action_date.html}</td>
54 </tr>
55 <tr id="recordActivity" class="crm-scheduleReminder-form-block-record_activity"><td class="label" width="20%">{$form.record_activity.label}</td>
56 <td>{$form.record_activity.html}</td>
57 </tr>
58 <tr id="relativeDateRepeat" class="crm-scheduleReminder-form-block-is_repeat"><td class="label" width="20%">{$form.is_repeat.label}</td>
59 <td>{$form.is_repeat.html}&nbsp;&nbsp;<span class="description">{ts}Enable repetition.{/ts}</span></td>
60 </tr>
61 <tr id="repeatFields" class="crm-scheduleReminder-form-block-repeatFields"><td></td><td>
62 <table class="form-layout-compressed">
63 <tr class="crm-scheduleReminder-form-block-repetition_frequency_interval">
64 <td class="label">{$form.repetition_frequency_interval.label}&nbsp;&nbsp;&nbsp;{$form.repetition_frequency_interval.html}</td>
65 <td>{$form.repetition_frequency_unit.html}</td>
66 </tr>
67 <tr class="crm-scheduleReminder-form-block-repetition_frequency_interval">
68 <td class="label">{$form.end_frequency_interval.label}&nbsp;&nbsp;&nbsp;{$form.end_frequency_interval.html}
69 <td>{$form.end_frequency_unit.html}&nbsp;&nbsp;&nbsp;{$form.end_action.html}&nbsp;&nbsp;&nbsp;{$form.end_date.html}</td>
70 </tr>
71 </table>
72 </td>
73 </tr>
74 <tr>
75 <td class="label" width="20%">{$form.from_name.label}</td>
76 <td>{$form.from_name.html}&nbsp;&nbsp;{help id="id-from_name_email"}</td>
77 </tr>
78 <tr>
79 <td class="label" width="20%">{$form.from_email.label}</td>
80 <td>{$form.from_email.html}&nbsp;&nbsp;</td>
81 </tr>
82 <tr class="crm-scheduleReminder-form-block-recipient">
83 <td id="recipientLabel" class="right">{$form.recipient.label}</td><td colspan="3">{$form.limit_to.html}&nbsp;{help id="limit_to" class="limit_to" title=$form.recipient.label}{$form.recipient.html}&nbsp;{help id="recipient" class="recipient" title=$recipientLabels.activity}</td>
84 </tr>
85 <tr id="recipientList" class="crm-scheduleReminder-form-block-recipientListing recipient">
86 <td class="right">{$form.recipient_listing.label}</td><td colspan="3">{$form.recipient_listing.html}</td>
87 </tr>
88 <tr id="recipientManual" class="crm-scheduleReminder-form-block-recipient_manual_id recipient">
89 <td class="label">{$form.recipient_manual_id.label}</td>
90 <td>{$form.recipient_manual_id.html}{edit}<div class="description">{ts}You can manually send out the reminders to these recipients.{/ts}</div>{/edit}</td>
91 </tr>
92
93 <tr id="recipientGroup" class="crm-scheduleReminder-form-block-recipient_group_id recipient">
94 <td class="label">{$form.group_id.label}</td>
95 <td>{$form.group_id.html}</td>
96 </tr>
97 <tr id="msgMode" class="crm-scheduleReminder-form-block-mode">
98 <td class="label">{$form.mode.label}</td>
99 <td>{$form.mode.html}</td>
100 </tr>
101 <tr class="crm-scheduleReminder-form-block-active">
102 <td class="label"></td>
103 <td>{$form.is_active.html}&nbsp;{$form.is_active.label}</td>
104 </tr>
105 </table>
106 <fieldset id="email" class="crm-collapsible" style="display: block;">
107 <legend class="collapsible-title">{ts}Email Screen{/ts}</legend>
108 <div>
109 <table id="email-field-table" class="form-layout-compressed">
110 <tr class="crm-scheduleReminder-form-block-template">
111 <td class="label">{$form.template.label}</td>
112 <td>{$form.template.html}</td>
113 </tr>
114 <tr class="crm-scheduleReminder-form-block-subject">
115 <td class="label">{$form.subject.label}</td>
116 <td>{$form.subject.html}</td>
117 </tr>
118 </table>
119 {include file="CRM/Contact/Form/Task/EmailCommon.tpl" upload=1 noAttach=1}
120 </div>
121 </fieldset>
122 {if $sms}
123 <fieldset id="sms" class="crm-collapsible"><legend class="collapsible-title">{ts}SMS Screen{/ts}</legend>
124 <div>
125 <table id="sms-field-table" class="form-layout-compressed">
126 <tr id="smsProvider" class="crm-scheduleReminder-form-block-sms_provider_id">
127 <td class="label">{$form.sms_provider_id.label}</td>
128 <td>{$form.sms_provider_id.html}</td>
129 </tr>
130 <tr class="crm-scheduleReminder-form-block-sms-template">
131 <td class="label">{$form.SMStemplate.label}</td>
132 <td>{$form.SMStemplate.html}</td>
133 </tr>
134 </table>
135 {include file="CRM/Contact/Form/Task/SMSCommon.tpl" upload=1 noAttach=1}
136 <div>
137 </fieldset>
138 {/if}
139
140 {include file="CRM/common/showHideByFieldValue.tpl"
141 trigger_field_id = "is_repeat"
142 trigger_value = "true"
143 target_element_id = "repeatFields"
144 target_element_type = "table-row"
145 field_type = "radio"
146 invert = "false"
147 }
148
149 {include file="CRM/common/showHideByFieldValue.tpl"
150 trigger_field_id ="recipient"
151 trigger_value = 'manual'
152 target_element_id ="recipientManual"
153 target_element_type ="table-row"
154 field_type ="select"
155 invert = 0
156 }
157
158 {include file="CRM/common/showHideByFieldValue.tpl"
159 trigger_field_id ="recipient"
160 trigger_value = 'group'
161 target_element_id ="recipientGroup"
162 target_element_type ="table-row"
163 field_type ="select"
164 invert = 0
165 }
166
167 {literal}
168 <script type='text/javascript'>
169 CRM.$(function($) {
170 var $form = $('form.{/literal}{$form.formClass}{literal}'),
171 recipientMapping = eval({/literal}{$recipientMapping}{literal});
172
173 $('#absolute_date_display', $form).change(function() {
174 if($(this).val()) {
175 $('#relativeDate, #relativeDateRepeat, #repeatFields, #OR', $form).hide();
176 } else {
177 $('#relativeDate, #relativeDateRepeat, #OR', $form).show();
178 }
179 });
180 if ($('#absolute_date_display', $form).val()) {
181 $('#relativeDate, #relativeDateRepeat, #repeatFields, #OR', $form).hide();
182 }
183
184 loadMsgBox();
185 $('#mode', $form).change(loadMsgBox);
186
187 function populateRecipient() {
188 var recipient = $("#recipient", $form).val();
189 if ((recipientMapping[recipient] == 'Participant Status' || recipientMapping[recipient] == 'participant_role') && $('#limit_to').val() != '') {
190 CRM.api3('participant', 'getoptions', {field: recipientMapping[recipient] == 'participant_role' ? 'role_id' : 'status_id', sequential: 1})
191 .done(function(result) {
192 CRM.utils.setOptions($('#recipient_listing', $form), result.values);
193 });
194 $("#recipientList", $form).show();
195 }
196 else {
197 $("#recipientList", $form).hide();
198 }
199
200 showHideLimitTo();
201 }
202
203 // CRM-14070 Hide limit-to when entity is activity
204 function showHideLimitTo() {
205 $('#limit_to', $form).toggle(!($('#entity_0', $form).val() == '1'));
206 if ($('#entity_0', $form).val() != '1' || !($('#entity_0').length)) {
207 if ($('#limit_to', $form).val() == '') {
208 $('tr.recipient:visible, #recipientList, #recipient, a.recipient').hide();
209 $('a.limit_to').show();
210 }
211 else {
212 $('a.limit_to, a.recipient').show();
213 $('#recipient').css("margin-left", "12px");
214 }
215 $("label[for='recipient']").text('{/literal}{$recipientLabels.other}{literal}');
216 }
217 else {
218 $('#recipient, a.recipient').show()
219 $('#recipient').css("margin-left", "-2px");
220 $('a.limit_to').hide();
221 $("label[for='recipient']").text('{/literal}{$recipientLabels.activity}{literal}');
222 }
223 }
224
225 $('#recipient', $form).change(populateRecipient);
226
227 {/literal}{if !$context}{literal}
228 var entity = $('#entity_0', $form).val();
229 if (!(entity === '2' || entity === '3')) {
230 $('#recipientList', $form).hide();
231 }
232
233 $('#entity_0, #limit_to', $form).change(buildSelects);
234
235 buildSelects();
236
237 function buildSelects() {
238 var mappingID = $('#entity_0', $form).val();
239 var isLimit = $('#limit_to', $form).val();
240
241 $.getJSON(CRM.url('civicrm/ajax/mapping'), {mappingID: mappingID, isLimit: isLimit},
242 function (result) {
243 CRM.utils.setOptions($('#start_action_date', $form), result.sel4);
244 CRM.utils.setOptions($('#end_date', $form), result.sel4);
245 CRM.utils.setOptions($('#recipient', $form), result.sel5);
246 recipientMapping = result.recipientMapping;
247 populateRecipient();
248 }
249 );
250 }
251 {/literal}{else}{literal}
252 populateRecipient();
253 $('#limit_to', $form).change(populateRecipient);
254 {/literal}{/if}{literal}
255
256 function loadMsgBox() {
257 if (cj('#mode').val() == 'Email' || cj('#mode').val() == 0){
258 cj('#sms').hide();
259 cj('#email').show();
260 }
261 else if (cj('#mode').val() == 'SMS'){
262 cj('#email').hide();
263 cj('#sms').show();
264 showSaveUpdateChkBox('SMS');
265 }
266 else if (cj('#mode').val() == 'User_Preference'){
267 cj('#email').show();
268 cj('#sms').show();
269 showSaveUpdateChkBox('SMS');
270 }
271 }
272
273 });
274 </script>
275 {/literal}
276
277 {/if}
278
279 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
280 </div>