CRM-12674
[civicrm-core.git] / templates / CRM / Admin / Form / ScheduleReminders.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.3 |
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 {* added onload javascript for source contact*}
38 {literal}
39 <script type="text/javascript">
40 var recipient_manual = '';
41 var recipient_manual_id = null;
42 var toDataUrl = "{/literal}{crmURL p='civicrm/ajax/checkemail' q='id=1&noemail=1' h=0 }{literal}"; {/literal}
43
44 {if $recipients}
45 {foreach from=$recipients key=id item=name}
46 {literal} recipient_manual += '{"name":"'+{/literal}"{$name}"{literal}+'","id":"'+{/literal}"{$id}"{literal}+'"},';{/literal}
47 {/foreach}
48 {literal} eval( 'recipient_manual = [' + recipient_manual + ']'); {/literal}
49 {/if}
50
51 {literal}
52 if ( recipient_manual_id ) {
53 eval( 'recipient_manual = ' + recipient_manual_id );
54 }
55
56 cj(document).ready( function( ) {
57 {/literal}
58 {literal}
59
60 eval( 'tokenClass = { tokenList: "token-input-list-facebook", token: "token-input-token-facebook", tokenDelete: "token-input-delete-token-facebook", selectedToken: "token-input-selected-token-facebook", highlightedToken: "token-input-highlighted-token-facebook", dropdown: "token-input-dropdown-facebook", dropdownItem: "token-input-dropdown-item-facebook", dropdownItem2: "token-input-dropdown-item2-facebook", selectedDropdownItem: "token-input-selected-dropdown-item-facebook", inputToken: "token-input-input-token-facebook" } ');
61
62 var sourceDataUrl = "{/literal}{$dataUrl}{literal}";
63 var tokenDataUrl = "{/literal}{$tokenUrl}{literal}";
64 var hintText = "{/literal}{ts escape='js'}Type in a partial or complete name of an existing recipient.{/ts}{literal}";
65 cj( "#recipient_manual_id").tokenInput( tokenDataUrl, { prePopulate: recipient_manual, classes: tokenClass, hintText: hintText });
66 cj( 'ul.token-input-list-facebook, div.token-input-dropdown-facebook' ).css( 'width', '450px' );
67 cj('#source_contact_id').autocomplete( sourceDataUrl, { width : 180, selectFirst : false, hintText: hintText, matchContains: true, minChars: 1
68 }).result( function(event, data, formatted) {
69 }).bind( 'click', function( ) { });
70 });
71 </script>
72 {/literal}
73 <table class="form-layout-compressed">
74 <tr class="crm-scheduleReminder-form-block-title">
75 <td class="right">{$form.title.label}</td><td colspan="3">{$form.title.html}</td>
76 </tr>
77 <tr>
78 <td class="label">{$form.entity.label}</td>
79 <td>{$form.entity.html}</td>
80 </tr>
81
82 <tr class="crm-scheduleReminder-form-block-when">
83 <td class="right">{$form.start_action_offset.label}</td>
84 <td colspan="3">{include file="CRM/common/jcalendar.tpl" elementName=absolute_date} <strong>{ts}OR{/ts}</strong><br /></td>
85 </tr>
86
87 <tr id="relativeDate" class="crm-scheduleReminder-form-block-description">
88 <td class="right"></td>
89 <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>
90 </tr>
91 <tr id="recordActivity" class="crm-scheduleReminder-form-block-record_activity"><td class="label" width="20%">{$form.record_activity.label}</td>
92 <td>{$form.record_activity.html}</td>
93 </tr>
94 <tr id="relativeDateRepeat" class="crm-scheduleReminder-form-block-is_repeat"><td class="label" width="20%">{$form.is_repeat.label}</td>
95 <td>{$form.is_repeat.html}&nbsp;&nbsp;<span class="description">{ts}Enable repetition.{/ts}</span></td>
96 </tr>
97 <tr id="repeatFields" class="crm-scheduleReminder-form-block-repeatFields"><td></td><td>
98 <table class="form-layout-compressed">
99 <tr class="crm-scheduleReminder-form-block-repetition_frequency_interval">
100 <td class="label">{$form.repetition_frequency_interval.label}&nbsp;&nbsp;&nbsp;{$form.repetition_frequency_interval.html}</td>
101 <td>{$form.repetition_frequency_unit.html}</td>
102 </tr>
103 <tr class="crm-scheduleReminder-form-block-repetition_frequency_interval">
104 <td class="label">{$form.end_frequency_interval.label}&nbsp;&nbsp;&nbsp;{$form.end_frequency_interval.html}
105 <td>{$form.end_frequency_unit.html}&nbsp;&nbsp;&nbsp;{$form.end_action.html}&nbsp;&nbsp;&nbsp;{$form.end_date.html}</td>
106 </tr>
107 </table>
108 </td>
109 </tr>
110 <tr class="crm-scheduleReminder-form-block-recipient">
111 <td id="recipientLabel" class="right">{$form.recipient.label}</td><td colspan="3">{$form.recipient.html}</td>
112 </tr>
113 <tr id="recipientList" class="crm-scheduleReminder-form-block-recipientListing">
114 <td class="right">{$form.recipient_listing.label}</td><td colspan="3">{$form.recipient_listing.html}</td>
115 </tr>
116 <tr id="recipientManual" class="crm-scheduleReminder-form-block-recipient_manual_id">
117 <td class="label">{$form.recipient_manual_id.label}</td>
118 <td>{$form.recipient_manual_id.html}{edit}<span class="description">{ts}You can manually send out the reminders to these recipients.{/ts}</span>{/edit}</td>
119 </tr>
120
121 <tr id="recipientGroup" class="crm-scheduleReminder-form-block-recipient_group_id">
122 <td class="label">{$form.group_id.label}</td>
123 <td>{$form.group_id.html}</td>
124 </tr>
125
126 </table>
127 <fieldset id="compose_id"><legend>{ts}Email{/ts}</legend>
128 <table id="email-field-table" class="form-layout-compressed">
129 <tr class="crm-scheduleReminder-form-block-active">
130 <td class="label"></td>
131 <td>{$form.is_active.html}&nbsp;{$form.is_active.label}</td>
132 </tr>
133 <tr class="crm-scheduleReminder-form-block-template">
134 <td class="label">{$form.template.label}</td>
135 <td>{$form.template.html}</td>
136 </tr>
137 <tr class="crm-scheduleReminder-form-block-subject">
138 <td class="label">{$form.subject.label}</td>
139 <td>{$form.subject.html}</td>
140 </tr>
141
142 </table>
143 {include file="CRM/Contact/Form/Task/EmailCommon.tpl" upload=1 noAttach=1}
144 </fieldset>
145
146 {/if}
147
148 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
149 </div>
150
151 {include file="CRM/common/showHideByFieldValue.tpl"
152 trigger_field_id = "is_repeat"
153 trigger_value = "true"
154 target_element_id = "repeatFields"
155 target_element_type = "table-row"
156 field_type = "radio"
157 invert = "false"
158 }
159
160 {include file="CRM/common/showHideByFieldValue.tpl"
161 trigger_field_id ="recipient"
162 trigger_value = 'manual'
163 target_element_id ="recipientManual"
164 target_element_type ="table-row"
165 field_type ="select"
166 invert = 0
167 }
168
169 {include file="CRM/common/showHideByFieldValue.tpl"
170 trigger_field_id ="recipient"
171 trigger_value = 'group'
172 target_element_id ="recipientGroup"
173 target_element_type ="table-row"
174 field_type ="select"
175 invert = 0
176 }
177
178 {literal}
179 <script type='text/javascript'>
180 var entityMapping = eval({/literal}{$entityMapping}{literal});
181 var recipientMapping = eval({/literal}{$recipientMapping}{literal});
182
183 cj('#absolute_date_display').change( function() {
184 if(cj('#absolute_date_display').val()) {
185 cj('#relativeDate').hide();
186 cj('#relativeDateRepeat').hide();
187 cj('#repeatFields').hide();
188 } else {
189 cj('#relativeDate').show();
190 cj('#relativeDateRepeat').show();
191 }
192 });
193
194 cj('#absolute_date_display').parent( ).children('.crm-clear-link').children('a').click( function() {
195 cj('#relativeDate').show();
196 cj('#relativeDateRepeat').show();
197 });
198
199 cj(function() {
200 if (cj('#absolute_date_display').val()) {
201 cj('#relativeDate').hide();
202 cj('#relativeDateRepeat').hide();
203 cj('#repeatFields').hide();
204 }
205
206 cj('#entity_0').change( function( ) {
207 buildSelect("start_action_date");
208 buildSelect("end_date");
209 buildSelect1("recipient");
210 });
211 });
212
213 cj(function() {
214 if ( cj('#is_recipient_listing').val( ) ) {
215 cj('#recipientList').show();
216 } else {
217 cj('#recipientList').hide();
218 }
219 cj('#recipient').change( function( ) {
220 populateRecipient();
221 });
222 });
223
224 function populateRecipient( ) {
225 var recipient = cj("#recipient option:selected").val();
226 var entity = cj("#entity_0 option:selected").val();
227 var postUrl = "{/literal}{crmURL p='civicrm/ajax/populateRecipient' h=0}{literal}";
228
229 if(recipientMapping[recipient] == 'Participant Status' || recipientMapping[recipient] == 'Participant Role') {
230 var elementID = '#recipient_listing';
231 cj( elementID ).html('');
232 cj.post(postUrl, {recipient: recipientMapping[recipient]},
233 function ( response ) {
234 response = eval( response );
235 for (i = 0; i < response.length; i++) {
236 cj( elementID ).get(0).add(new Option(response[i].name, response[i].value), document.all ? i : null);
237 }
238 });
239 cj("#recipientList").show();
240 cj('#is_recipient_listing').val(1);
241 } else {
242 cj("#recipientList").hide();
243 cj('#is_recipient_listing').val('');
244 }
245
246 if (entityMapping[entity] == 'civicrm_activity') {
247 cj("#recipientLabel").text("Recipient(s)");
248 } else {
249 cj("#recipientLabel").text("Additional Recipient(s)");
250 }
251 }
252 function buildSelect( selectID ) {
253 var elementID = '#' + selectID;
254 cj( elementID ).html('');
255 var mappingID = cj('#entity_0').val();
256 var postUrl = "{/literal}{crmURL p='civicrm/ajax/mapping' h=0}{literal}";
257 cj.post( postUrl, { mappingID: mappingID},
258 function ( response ) {
259 response = eval( response );
260 for (i = 0; i < response.length; i++) {
261 cj( elementID ).get(0).add(new Option(response[i].name, response[i].value), document.all ? i : null);
262 }
263 }
264 );
265
266 }
267
268 function buildSelect1( selectID ) {
269 var elementID = '#' + selectID;
270 cj( elementID ).html('');
271 var mappingID = cj('#entity_0').val();
272 var postUrl1 = "{/literal}{crmURL p='civicrm/ajax/mapping1' h=0}{literal}";
273
274 cj('#is_recipient_listing').val('');
275 cj.post( postUrl1, { mappingID: mappingID},
276 function ( result ) {
277 var responseResult = cj.parseJSON(result);
278 var response = eval(responseResult.sel5);
279 recipientMapping = eval(responseResult.recipientMapping);
280 for (i = 0; i < response.length; i++) {
281 cj( elementID ).get(0).add(new Option(response[i].name, response[i].value), document.all ? i : null);
282 }
283 populateRecipient();
284 }
285 );
286 }
287
288 </script>
289 {/literal}