Merge pull request #1765 from lynndanzig/master
[civicrm-core.git] / templates / CRM / Activity / Form / Activity.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.4 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2013 |
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 {* this template is used for adding/editing other (custom) activities. *}
27 {if $cdType }
28 {include file="CRM/Custom/Form/CustomData.tpl"}
29 {else}
30 {if $action eq 4}
31 <div class="crm-block crm-content-block crm-activity-view-block">
32 {else}
33 {if $context NEQ 'standalone'}
34 <h3>{if $action eq 1 or $action eq 1024}{ts 1=$activityTypeName}New activity: %1{/ts}{elseif $action eq 8}{ts 1=$activityTypeName}Delete %1{/ts}{else}{ts 1=$activityTypeName}Edit %1{/ts}{/if}</h3>
35 {/if}
36 {if $activityTypeDescription }
37 <div class="help">{$activityTypeDescription}</div>
38 {/if}
39 <div class="crm-block crm-form-block crm-activity-form-block">
40 {/if}
41 {* added onload javascript for source contact*}
42 {literal}
43 <script type="text/javascript">
44 var assignee_contact = '';
45
46 {/literal}
47 {if $assignee_contact}
48 var assignee_contact = {$assignee_contact};
49 {/if}
50 {literal}
51
52 //loop to set the value of cc and bcc if form rule.
53 var assignee_contact_id = null;
54 var toDataUrl = "{/literal}{crmURL p='civicrm/ajax/checkemail' q='id=1&noemail=1' h=0 }{literal}"; {/literal}
55 {foreach from=","|explode:"assignee" key=key item=element}
56 {assign var=currentElement value=`$element`_contact_id}
57 {if $form.$currentElement.value }
58 {literal} var {/literal}{$currentElement}{literal} = cj.ajax({ url: toDataUrl + "&cid={/literal}{$form.$currentElement.value}{literal}", async: false }).responseText;{/literal}
59 {/if}
60 {/foreach}
61 {literal}
62
63 if ( assignee_contact_id ) {
64 eval( 'assignee_contact = ' + assignee_contact_id );
65 }
66
67 cj(function( ) {
68 {/literal}
69 {if $source_contact and $admin and $action neq 4}
70 {literal} cj( '#source_contact_id' ).val( "{/literal}{$source_contact}{literal}");{/literal}
71 {/if}
72 {literal}
73
74 var sourceDataUrl = "{/literal}{$dataUrl}{literal}";
75 var tokenDataUrl_assignee = "{/literal}{$tokenUrl}&context=activity_assignee{literal}";
76 var hintText = "{/literal}{ts escape='js'}Type in a partial or complete name of an existing contact.{/ts}{literal}";
77 cj( "#assignee_contact_id").tokenInput( tokenDataUrl_assignee, { prePopulate: assignee_contact, theme: 'facebook', hintText: hintText });
78 cj( 'ul.token-input-list-facebook, div.token-input-dropdown-facebook' ).css( 'width', '450px' );
79 cj('#source_contact_id').autocomplete( sourceDataUrl, { width : 180, selectFirst : false, hintText: hintText, matchContains: true, minChars: 1, max: {/literal}{crmSetting name="search_autocomplete_count" group="Search Preferences"}{literal}
80 }).result( function(event, data, formatted) { cj( "#source_contact_qid" ).val( data[1] );
81 }).bind( 'click', function( ) { if (!cj("#source_contact_id").val()) { cj( "#source_contact_qid" ).val(''); } });
82 });
83 </script>
84
85 {/literal}
86 {if !$action or ( $action eq 1 ) or ( $action eq 2 ) }
87 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
88 {/if}
89
90 {if $action eq 8} {* Delete action. *}
91 <table class="form-layout">
92 <tr>
93 <td colspan="2">
94 <div class="status">{ts 1=$delName}Are you sure you want to delete '%1'?{/ts}</div>
95 </td>
96 </tr>
97 {elseif $action eq 1 or $action eq 2 or $action eq 4 or $context eq 'search' or $context eq 'smog'}
98
99 <table class="{if $action eq 4}crm-info-panel{else}form-layout{/if}">
100
101 {if $action eq 4}
102 <h3>{$activityTypeName}</h3>
103 {if $activityTypeDescription }
104 <div class="help">{$activityTypeDescription}</div>
105 {/if}
106 {else}
107 {if $context eq 'standalone' or $context eq 'search' or $context eq 'smog'}
108 <tr class="crm-activity-form-block-activity_type_id">
109 <td class="label">{$form.activity_type_id.label}</td><td class="view-value">{$form.activity_type_id.html}</td>
110 </tr>
111 {/if}
112 {/if}
113
114 {if $surveyActivity}
115 <tr class="crm-activity-form-block-survey">
116 <td class="label">{ts}Survey Title{/ts}</td><td class="view-value">{$surveyTitle}</td>
117 </tr>
118 {/if}
119
120 <tr class="crm-activity-form-block-source_contact_id">
121 <td class="label">{$form.source_contact_id.label}</td>
122 <td class="view-value">
123 {if $admin and $action neq 4}{$form.source_contact_id.html} {else} {$source_contact_value} {/if}
124 </td>
125 </tr>
126
127 <tr class="crm-activity-form-block-target_contact_id">
128 {if $single eq false}
129 <td class="label">{ts}With Contact(s){/ts}</td>
130 <td class="view-value" style="white-space: normal">
131 {$with|escape}
132 <br/>
133 {$form.is_multi_activity.html}&nbsp;{$form.is_multi_activity.label} {help id="id-is_multi_activity"}
134 </td>
135 {elseif $action neq 4}
136 <td class="label">{ts}With Contact{/ts}</td>
137 <td class="view-value">
138 {include file="CRM/Contact/Form/NewContact.tpl" noLabel=true skipBreak=true multiClient=true parent="activity" showNewSelect=true}
139 {if $action eq 1}
140 <br/>
141 {$form.is_multi_activity.html}&nbsp;{$form.is_multi_activity.label} {help id="id-is_multi_activity"}
142 {/if}
143 </td>
144 {else}
145 <td class="label">{ts}With Contact{/ts}</td>
146 <td class="view-value" style="white-space: normal">
147 {foreach from=$target_contact key=id item=name}
148 <a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=$id"}">{$name}</a>;&nbsp;
149 {/foreach}
150 </td>
151 {/if}
152 </tr>
153
154 <tr class="crm-activity-form-block-assignee_contact_id">
155 {if $action eq 4}
156 <td class="label">{ts}Assigned To{/ts}</td><td class="view-value">
157 {foreach from=$assignee_contact key=id item=name}
158 <a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=$id"}">{$name}</a>;&nbsp;
159 {/foreach}
160 </td>
161 {else}
162 <td class="label">{ts}Assigned To{/ts}</td>
163 <td>
164 <a href="#" class="button" id="swap_target_assignee" title="{ts}Swap Target and Assignee Contacts{/ts}" style="float:right;">
165 <span>
166 <div class="icon swap-icon"></div>
167 </span>
168 </a>
169 {$form.assignee_contact_id.html}
170 {edit}
171 <span class="description">{ts}You can optionally assign this activity to someone. Assigned activities will appear in their Activities listing at CiviCRM Home.{/ts}
172 {if $activityAssigneeNotification}
173 <br />{ts}A copy of this activity will be emailed to each Assignee.{/ts}
174 {/if}
175 </span>
176 {/edit}
177 </td>
178 {/if}
179 </tr>
180
181 {if $activityTypeFile}
182 {include file="CRM/$crmDir/Form/Activity/$activityTypeFile.tpl"}
183 {/if}
184
185 <tr class="crm-activity-form-block-subject">
186 <td class="label">{$form.subject.label}</td><td class="view-value">{$form.subject.html|crmAddClass:huge}</td>
187 </tr>
188
189 {* CRM-7362 --add campaign to activities *}
190 {include file="CRM/Campaign/Form/addCampaignToComponent.tpl"
191 campaignTrClass="crm-activity-form-block-campaign_id"}
192
193 {* build engagement level CRM-7775 *}
194 {if $buildEngagementLevel}
195 <tr class="crm-activity-form-block-engagement_level">
196 <td class="label">{$form.engagement_level.label}</td>
197 <td class="view-value">{$form.engagement_level.html}</td>
198 </tr>
199 {/if}
200
201 <tr class="crm-activity-form-block-location">
202 <td class="label">{$form.location.label}</td><td class="view-value">{$form.location.html|crmAddClass:huge}</td>
203 </tr>
204 <tr class="crm-activity-form-block-activity_date_time">
205 <td class="label">{$form.activity_date_time.label}</td>
206 {if $action neq 4}
207 <td class="view-value">{include file="CRM/common/jcalendar.tpl" elementName=activity_date_time}</td>
208 {else}
209 <td class="view-value">{$form.activity_date_time.html|crmDate}</td>
210 {/if}
211 </tr>
212 <tr class="crm-activity-form-block-duration">
213 <td class="label">{$form.duration.label}</td>
214 <td class="view-value">
215 {$form.duration.html}
216 {if $action neq 4}<span class="description">{ts}Total time spent on this activity (in minutes).{/ts}{/if}
217 </td>
218 </tr>
219 <tr class="crm-activity-form-block-status_id">
220 <td class="label">{$form.status_id.label}</td><td class="view-value">{$form.status_id.html}</td>
221 </tr>
222 <tr class="crm-activity-form-block-details">
223 <td class="label">{$form.details.label}</td>
224 {if $activityTypeName eq "Print PDF Letter"}
225 <td class="view-value">
226 {* If using plain textarea, assign class=huge to make input large enough. *}
227 {if $defaultWysiwygEditor eq 0}{$form.details.html|crmAddClass:huge}{else}{$form.details.html}{/if}
228 </td>
229 {else}
230 <td class="view-value">
231 {* If using plain textarea, assign class=huge to make input large enough. *}
232 {if $defaultWysiwygEditor eq 0}{$form.details.html|crmStripAlternatives|crmAddClass:huge}{else}{$form.details.html|crmStripAlternatives}{/if}
233 </td>
234 {/if}
235 </tr>
236 <tr class="crm-activity-form-block-priority_id">
237 <td class="label">{$form.priority_id.label}</td><td class="view-value">{$form.priority_id.html}</td>
238 </tr>
239 {if $surveyActivity }
240 <tr class="crm-activity-form-block-result">
241 <td class="label">{$form.result.label}</td><td class="view-value">{$form.result.html}</td>
242 </tr>
243 {/if}
244 {if $form.tag.html}
245 <tr class="crm-activity-form-block-tag">
246 <td class="label">{$form.tag.label}</td>
247 <td class="view-value"><div class="crm-select-container">{$form.tag.html}</div>
248 {literal}
249 <script type="text/javascript">
250 cj(".crm-activity-form-block-tag select[multiple]").crmasmSelect({
251 addItemTarget: 'bottom',
252 animate: true,
253 highlight: true,
254 sortable: true,
255 respectParents: true
256 });
257 </script>
258 {/literal}
259 </td>
260 </tr>
261 {/if}
262
263 {if $tagsetInfo_activity}
264 <tr class="crm-activity-form-block-tag_set"><td colspan="2">{include file="CRM/common/Tag.tpl" tagsetType='activity'}</td></tr>
265 {/if}
266
267 {if $action neq 4 OR $viewCustomData}
268 <tr class="crm-activity-form-block-custom_data">
269 <td colspan="2">
270 {if $action eq 4}
271 {include file="CRM/Custom/Page/CustomDataView.tpl"}
272 {else}
273 <div id="customData"></div>
274 {/if}
275 </td>
276 </tr>
277 {/if}
278
279 {if $action eq 4 AND $currentAttachmentInfo}
280 {include file="CRM/Form/attachment.tpl"}{* For view action the include provides the row and cells. *}
281 {elseif $action eq 1 OR $action eq 2}
282 <tr class="crm-activity-form-block-attachment">
283 <td colspan="2">
284 {include file="CRM/Form/attachment.tpl"}
285 </td>
286 </tr>
287 {/if}
288
289 {if $action neq 4} {* Don't include "Schedule Follow-up" section in View mode. *}
290 <tr class="crm-activity-form-block-schedule_followup">
291 <td colspan="2">
292 <div class="crm-accordion-wrapper collapsed">
293 <div class="crm-accordion-header">
294 {ts}Schedule Follow-up{/ts}
295 </div><!-- /.crm-accordion-header -->
296 <div class="crm-accordion-body">
297 <table class="form-layout-compressed">
298 <tr><td class="label">{ts}Schedule Follow-up Activity{/ts}</td>
299 <td>{$form.followup_activity_type_id.html}&nbsp;&nbsp;{ts}on{/ts}
300 {include file="CRM/common/jcalendar.tpl" elementName=followup_date}
301 </td>
302 </tr>
303 <tr>
304 <td class="label">{$form.followup_activity_subject.label}</td>
305 <td>{$form.followup_activity_subject.html|crmAddClass:huge}</td>
306 </tr>
307 </table>
308 </div><!-- /.crm-accordion-body -->
309 </div><!-- /.crm-accordion-wrapper -->
310 {literal}
311 <script type="text/javascript">
312 cj(function() {
313 cj().crmAccordions();
314 cj('.crm-accordion-body').each( function() {
315 //open tab if form rule throws error
316 if ( cj(this).children( ).find('span.crm-error').text( ).length > 0 ) {
317 cj(this).parent('.collapsed').crmAccordionToggle();
318 }
319 });
320 });
321 cj('#swap_target_assignee').click( function() {
322 var assignees = cj('input#assignee_contact_id').tokenInput("get");
323 var targets = cj('input#contact_1').tokenInput("get");
324 cj('#assignee_contact_id').tokenInput("clear");
325 cj('#contact_1').tokenInput("clear");
326 cj(assignees).each( function() {
327 cj('#contact_1').tokenInput("add", this);
328 });
329 cj(targets).each( function() {
330 cj('#assignee_contact_id').tokenInput("add", this);
331 });
332 return false;
333 });
334 </script>
335 {/literal}
336 </td>
337 </tr>
338 {/if}
339 {/if} {* End Delete vs. Add / Edit action *}
340 </table>
341 <div class="crm-submit-buttons">
342 {if $action eq 4 && $activityTName neq 'Inbound Email'}
343 {if !$context }
344 {assign var="context" value='activity'}
345 {/if}
346 {if $permission EQ 'edit'}
347 {assign var='urlParams' value="reset=1&atype=$atype&action=update&reset=1&id=$entityID&cid=$contactId&context=$context"}
348 {if ($context eq 'fulltext' || $context eq 'search') && $searchKey}
349 {assign var='urlParams' value="reset=1&atype=$atype&action=update&reset=1&id=$entityID&cid=$contactId&context=$context&key=$searchKey"}
350 {/if}
351 <a href="{crmURL p='civicrm/activity/add' q=$urlParams}" class="edit button" title="{ts}Edit{/ts}"><span><div class="icon edit-icon"></div>{ts}Edit{/ts}</span></a>
352 {/if}
353
354 {if call_user_func(array('CRM_Core_Permission','check'), 'delete activities')}
355 {assign var='urlParams' value="reset=1&atype=$atype&action=delete&reset=1&id=$entityID&cid=$contactId&context=$context"}
356 {if ($context eq 'fulltext' || $context eq 'search') && $searchKey}
357 {assign var='urlParams' value="reset=1&atype=$atype&action=delete&reset=1&id=$entityID&cid=$contactId&context=$context&key=$searchKey"}
358 {/if}
359 <a href="{crmURL p='civicrm/contact/view/activity' q=$urlParams}" class="delete button" title="{ts}Delete{/ts}"><span><div class="icon delete-icon"></div>{ts}Delete{/ts}</span></a>
360 {/if}
361 {/if}
362 {include file="CRM/common/formButtons.tpl" location="bottom"}
363 </div>
364
365 {include file="CRM/Case/Form/ActivityToCase.tpl"}
366
367 {if $action eq 1 or $action eq 2 or $context eq 'search' or $context eq 'smog'}
368 {*include custom data js file*}
369 {include file="CRM/common/customData.tpl"}
370 {literal}
371 <script type="text/javascript">
372 cj(function() {
373 {/literal}
374 {if $customDataSubType}
375 CRM.buildCustomData( '{$customDataType}', {$customDataSubType} );
376 {else}
377 CRM.buildCustomData( '{$customDataType}' );
378 {/if}
379 {literal}
380 });
381 </script>
382 {/literal}
383 {/if}
384 {if ! $form.case_select}
385 {include file="CRM/common/formNavigate.tpl"}
386 {/if}
387 </div>{* end of form block*}
388 {/if} {* end of snippet if*}