Merge pull request #2498 from kurund/CRM-14181
[civicrm-core.git] / templates / CRM / Event / Form / ManageEvent / ScheduleReminders.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.4 |
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-event-manage-scheduleReminder-form-block">
29
30 {if $rows}
31 <div id="reminder">
32 {include file="CRM/Admin/Page/Reminders.tpl"}
33
34 <div class="action-link">
35 <a href="{crmURL q="action=update&reset=1&id=$eventId&new=1"}" id="newScheduleReminder" class="button"><span><div class="icon add-icon"></div>{ts}Add Reminder{/ts}</span></a>
36 </div>
37 </div>
38
39 {else}
40
41 <div class="crm-submit-buttons">
42 {include file="CRM/common/formButtons.tpl" location="top"}
43 </div>
44 {if $action eq 8}
45 <div class="messages status no-popup">
46 <div class="icon inform-icon"></div>
47 {ts 1=$reminderName}WARNING: You are about to delete the Reminder titled <strong>%1</strong>.{/ts} {ts}Do you want to continue?{/ts}
48 </div>
49 {else}
50 {* added onload javascript for source contact*}
51 {literal}
52 <script type="text/javascript">
53 cj().crmAccordions();
54 var recipient_manual = '';
55 var recipient_manual_id = null;
56 var toDataUrl = "{/literal}{crmURL p='civicrm/ajax/checkemail' q='id=1&noemail=1' h=0 }{literal}"; {/literal}
57
58 {if $recipients}
59 {foreach from=$recipients key=id item=name}
60 {literal} recipient_manual += '{"name":"'+{/literal}"{$name}"{literal}+'","id":"'+{/literal}"{$id}"{literal}+'"},';{/literal}
61 {/foreach}
62 {literal} eval( 'recipient_manual = [' + recipient_manual + ']'); {/literal}
63 {/if}
64
65 {literal}
66 if ( recipient_manual_id ) {
67 eval( 'recipient_manual = ' + recipient_manual_id );
68 }
69
70 cj(document).ready( function( ) {
71 {/literal}
72 {literal}
73
74 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" } ');
75
76 var sourceDataUrl = "{/literal}{$dataUrl}{literal}";
77 var tokenDataUrl = "{/literal}{$tokenUrl}{literal}";
78 var hintText = "{/literal}{ts escape='js'}Type in a partial or complete name of an existing recipient.{/ts}{literal}";
79 cj( "#recipient_manual_id").tokenInput( tokenDataUrl, { prePopulate: recipient_manual, classes: tokenClass, hintText: hintText });
80 cj( 'ul.token-input-list-facebook, div.token-input-dropdown-facebook' ).css( 'width', '450px' );
81 cj('#source_contact_id').autocomplete( sourceDataUrl, { width : 180, selectFirst : false, hintText: hintText, matchContains: true, minChars: 1
82 }).result( function(event, data, formatted) {
83 }).bind( 'click', function( ) { });
84 });
85 </script>
86 {/literal}
87 <table class="form-layout-compressed">
88 <tr class="crm-scheduleReminder-form-block-title">
89 <td class="right">{$form.title.label}</td><td colspan="3">{$form.title.html}</td>
90 </tr>
91 <tr>
92 <td class="label">{$form.entity.label}</td>
93 <td>{$form.entity.html}</td>
94 </tr>
95 <tr class="crm-scheduleReminder-form-block-when">
96 <td class="right">{$form.start_action_offset.label}</td>
97 <td colspan="3">{include file="CRM/common/jcalendar.tpl" elementName=absolute_date} <strong>{ts}OR{/ts}</strong><br /></td>
98 </tr>
99 <tr id="relativeDate" class="crm-scheduleReminder-form-block-description">
100 <td class="right"></td>
101 <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>
102 </tr>
103 <tr id="recordActivity" class="crm-scheduleReminder-form-block-record_activity">
104 <td class="label" width="20%">{$form.record_activity.label}</td>
105 <td>{$form.record_activity.html}</td>
106 </tr>
107 <tr id="relativeDateRepeat" class="crm-scheduleReminder-form-block-is_repeat"><td class="label" width="20%">{$form.is_repeat.label}</td>
108 <td>{$form.is_repeat.html}&nbsp;&nbsp;<span class="description">{ts}Enable repetition.{/ts}</span></td>
109 </tr>
110 <tr id="repeatFields" class="crm-scheduleReminder-form-block-repeatFields">
111 <td></td>
112 <td>
113 <table class="form-layout-compressed">
114 <tr class="crm-scheduleReminder-form-block-repetition_frequency_interval">
115 <td class="label">{$form.repetition_frequency_interval.label}&nbsp;&nbsp;&nbsp;{$form.repetition_frequency_interval.html}</td>
116 <td>{$form.repetition_frequency_unit.html}</td>
117 </tr>
118 <tr class="crm-scheduleReminder-form-block-repetition_frequency_interval">
119 <td class="label">{$form.end_frequency_interval.label}&nbsp;&nbsp;&nbsp;{$form.end_frequency_interval.html}
120 <td>{$form.end_frequency_unit.html}&nbsp;&nbsp;&nbsp;{$form.end_action.html}&nbsp;&nbsp;&nbsp;{$form.end_date.html}</td>
121 </tr>
122 </table>
123 </td>
124 </tr>
125 <tr class="crm-scheduleReminder-form-block-recipient">
126 <td class="right">{$form.recipient.label}</td><td colspan="3">{$form.limit_to.html}&nbsp;&nbsp;{$form.recipient.html}&nbsp;&nbsp;{help id="recipient" file="CRM/Admin/Page/ScheduleReminders.hlp" title=$form.recipient.label}</td>
127 </tr>
128 <tr id="recipientList" class="crm-scheduleReminder-form-block-recipientListing">
129 <td class="right">{$form.recipient_listing.label}</td><td colspan="3">{$form.recipient_listing.html}</td>
130 </tr>
131 <tr id="recipientManual" class="crm-scheduleReminder-form-block-recipient_manual_id">
132 <td class="label">{$form.recipient_manual_id.label}</td>
133 <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>
134 </tr>
135 <tr id="recipientGroup" class="crm-scheduleReminder-form-block-recipient_group_id">
136 <td class="label">{$form.group_id.label}</td>
137 <td>{$form.group_id.html}</td>
138 </tr>
139
140 </table>
141 <fieldset id="compose_id"><legend>{ts}Email{/ts}</legend>
142 <table id="email-field-table" class="form-layout-compressed">
143 <tr class="crm-scheduleReminder-form-block-active">
144 <td class="label"></td>
145 <td>{$form.is_active.html}&nbsp;{$form.is_active.label}</td>
146 </tr>
147 <tr class="crm-scheduleReminder-form-block-template">
148 <td class="label">{$form.template.label}</td>
149 <td>{$form.template.html}</td>
150 </tr>
151 <tr class="crm-scheduleReminder-form-block-subject">
152 <td class="label">{$form.subject.label}</td>
153 <td>{$form.subject.html}</td>
154 </tr>
155 </table>
156 {include file="CRM/Contact/Form/Task/EmailCommon.tpl" upload=1 noAttach=1}
157 </fieldset>
158
159 {include file="CRM/common/showHideByFieldValue.tpl"
160 trigger_field_id = "is_repeat"
161 trigger_value = "true"
162 target_element_id = "repeatFields"
163 target_element_type = "table-row"
164 field_type = "radio"
165 invert = "false"
166 }
167
168 {include file="CRM/common/showHideByFieldValue.tpl"
169 trigger_field_id ="recipient"
170 trigger_value = 'manual'
171 target_element_id ="recipientManual"
172 target_element_type ="table-row"
173 field_type ="select"
174 invert = 0
175 }
176
177 {include file="CRM/common/showHideByFieldValue.tpl"
178 trigger_field_id ="recipient"
179 trigger_value = 'group'
180 target_element_id ="recipientGroup"
181 target_element_type ="table-row"
182 field_type ="select"
183 invert = 0
184 }
185
186 {literal}
187 <script type='text/javascript'>
188 cj(function() {
189 populateRecipient();
190 cj('#recipient').click( function( ) {
191 populateRecipient();
192 });
193 });
194
195 function populateRecipient( ) {
196 var recipientMapping = eval({/literal}{$recipientMapping}{literal});
197 var recipient = cj("#recipient option:selected").val();
198 var postUrl = "{/literal}{crmURL p='civicrm/ajax/populateRecipient' h=0}{literal}";
199 if(recipientMapping[recipient] == 'Participant Status' || recipientMapping[recipient] == 'participant_role'){
200 var elementID = '#recipient_listing';
201 cj( elementID ).html('');
202 cj.post(postUrl, {recipient: recipientMapping[recipient]},
203 function ( response ) {
204 response = eval( response );
205 for (iota = 0; iota < response.length; iota++) {
206 cj( elementID ).get(0).add(new Option(response[iota].name, response[iota].value), document.all ? iota : null);
207 }
208 }
209 );
210 cj("#recipientList").show();
211 } else {
212 cj("#recipientList").hide();
213 }
214 }
215
216 cj('#absolute_date_display').click( function( ) {
217 if(cj('#absolute_date_display').val()) {
218 cj('#relativeDate').hide();
219 cj('#relativeDateRepeat').hide();
220 cj('#repeatFields').hide();
221 } else {
222 cj('#relativeDate').show();
223 cj('#relativeDateRepeat').show();
224 }
225 });
226
227 </script>
228 {/literal}
229 {/if}
230 <div class="crm-submit-buttons">
231 {include file="CRM/common/formButtons.tpl" location="bottom"}</div>
232 </div>
233 {/if}