Merge pull request #1976 from eileenmcnaughton/CRM-13737
[civicrm-core.git] / templates / CRM / Activity / Form / Search / Common.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 <tr>
27 <td colspan="2">
28 {$form.activity_role.html}
29 <span class="crm-clear-link">
30 (<a href="#" title="unselect"
31 onclick="unselectRadio('activity_role', '{$form.formName}');
32 return false;">
33 {ts}clear{/ts}
34 </a>)
35 </span>
36 </td>
37 </tr>
38 <tr>
39 {if $form.activity_type_id}
40 <td><label>{ts}Activity Type(s){/ts}</label>
41 <div id="Activity" class="listing-box">
42 {foreach from=$form.activity_type_id item="activity_type_val"}
43 <div class="{cycle values='odd-row,even-row'}">
44 {$activity_type_val.html}
45 </div>
46 {/foreach}
47 </div>
48 </td>
49 {else}
50 <td>&nbsp;</td>
51 {/if}
52 {if $form.activity_survey_id || $buildEngagementLevel}
53 <td>
54 {if $form.activity_survey_id}
55 <label>{$form.activity_survey_id.label}</label>
56 <br/>
57 {$form.activity_survey_id.html}
58 {/if}
59 {if $buildEngagementLevel}
60 <br
61 / >
62 <br/>
63 <label>{$form.activity_engagement_level.label}</label>
64 <br/>
65 {$form.activity_engagement_level.html}
66 {/if}
67 </td>
68 {/if}
69
70 {if $form.activity_tags}
71 <td><label>{ts}Activity Tag(s){/ts}</label>
72 <div id="Tags" class="listing-box">
73 {foreach from=$form.activity_tags item="tag_val"}
74 <div class="{cycle values='odd-row,even-row'}">
75 {$tag_val.html}
76 </div>
77 {/foreach}
78 </td>
79 {else}
80 <td>&nbsp;</td>
81 {/if}
82 </tr>
83
84 <tr>
85 <td><label>{ts}Activity Dates{/ts}</label></td>
86 </tr>
87 <tr>
88 {include file="CRM/Core/DateRange.tpl" fieldName="activity_date" from='_low' to='_high'}
89 </tr>
90 <tr>
91 <td>
92 {$form.activity_subject.label}<br/>
93 {$form.activity_subject.html|crmAddClass:big}
94 </td>
95 <td colspan="2">
96 {$form.activity_status.label}<br/>
97 {$form.activity_status.html}
98 </td>
99 </tr>
100 <tr>
101 {* td intentionally left blank to align the 'is test' widget on the right *}
102 <td></td>
103 <td colspan="2">
104 {$form.activity_test.label} {help id="is-test" file="CRM/Contact/Form/Search/Advanced"}
105 &nbsp; {$form.activity_test.html}
106 <span class="crm-clear-link">
107 (<a href="#" onclick="unselectRadio('activity_test','{$form.formName}'); return false;">{ts}clear{/ts}</a>)
108 </span>
109 </td>
110 </tr>
111
112 <tr>
113 <td colspan="3">{include file="CRM/common/Tag.tpl" tagsetType='activity'}</td>
114 </tr>
115
116 {* campaign in activity search *}
117 {include file="CRM/Campaign/Form/addCampaignToComponent.tpl"
118 campaignContext="componentSearch" campaignTrClass='' campaignTdClass=''}
119
120 {if $activityGroupTree}
121 <tr id="activityCustom">
122 <td id="activityCustomData" colspan="2">
123 {include file="CRM/Custom/Form/Search.tpl" groupTree=$activityGroupTree showHideLinks=false}
124 </td>
125 </tr>
126 {/if}
127
128 {literal}
129 <script type="text/javascript">
130 cj(function() {
131 //Searchable activity custom fields which extend ALL activity types are always displayed in the form
132 //hence hide remaining activity custom data
133 cj('#activityCustom').children( ).each( function( ) {
134 cj('#'+cj(this).attr('id')+' div').each( function( ) {
135 if (cj(this).children( ).attr('id')) {
136 var activityCustomdataGroup = cj(this).attr('id'); //div id
137 var fieldsetId = cj(this).children( ).attr('id'); // fieldset id
138 var splitFieldsetId = fieldsetId.split("\ 1");
139 var splitFieldsetLength = splitFieldsetId.length; //length of fieldset
140 var show = 0;
141 //setdefault activity custom data group if corresponding activity type is checked
142 cj('#Activity div').each(function( ) {
143 var checkboxId = cj(this).children().attr('id'); //activity type element name
144 if (document.getElementById( checkboxId ).checked ) {
145 var element = checkboxId.split('[');
146 var splitElement = element[1].split(']'); // get activity type id
147 for (var i=0; i<splitFieldsetLength; i++) {
148 var singleFieldset = splitFieldsetId[i];
149 if (parseInt( singleFieldset)) {
150 if (singleFieldset == splitElement[0]) {
151 show++;
152 }
153 }
154 }
155 }
156 });
157 if (show < 1) {
158 cj('#'+activityCustomdataGroup).hide( );
159 }
160 }
161 });
162 });
163 });
164 </script>
165
166
167 <script type="text/javascript">
168
169 function showCustomData(chkbox) {
170 if (document.getElementById(chkbox).checked) {
171 //inject Searchable activity custom fields according to activity type selected
172 var element = chkbox.split("[");
173 var splitElement = element[1].split("]");
174 cj('#activityCustom').children().each(function( ) {
175 cj('#'+cj(this).attr( 'id' )+' div').each(function( ) {
176 if (cj(this).children().attr('id')) {
177 if (cj('#'+cj(this).attr('id')+(' fieldset')).attr('id')) {
178 var fieldsetId = cj('#' + cj(this).attr('id')+(' fieldset')).attr('id').split("\ 1");
179 var activityTypeId = jQuery.inArray(splitElement[0], fieldsetId);
180 if (fieldsetId[activityTypeId] == splitElement[0]) {
181 cj(this).show();
182 }
183 }
184 }
185 });
186 });
187 }
188 else {
189 //hide activity custom fields if the corresponding activity type is unchecked
190 var setcount = 0;
191 var element = chkbox.split( "[" );
192 var splitElement = element[1].split( "]" );
193 cj('#activityCustom').children().each( function( ) {
194 cj('#'+cj(this).attr( 'id' )+' div').each(function() {
195 if (cj(this).children().attr('id')) {
196 if (cj('#'+cj(this).attr('id')+(' fieldset')).attr('id')) {
197 var fieldsetId = cj( '#'+cj(this).attr('id')+(' fieldset')).attr('id').split("\ 1");
198 var activityTypeId = jQuery.inArray( splitElement[0],fieldsetId);
199 if (fieldsetId[activityTypeId] == splitElement[0]) {
200 cj('#'+cj(this).attr('id')).each( function() {
201 if (cj(this).children().attr('id')) {
202 //if activity custom data extends more than one activity types then
203 //hide that only when all the extended activity types are unchecked
204 cj('#'+cj(this).attr('id')+(' fieldset')).each( function( ) {
205 var splitFieldsetId = cj( this ).attr('id').split("\ 1");
206 var splitFieldsetLength = splitFieldsetId.length;
207 for( var i=0;i<splitFieldsetLength;i++ ) {
208 var setActivityTypeId = splitFieldsetId[i];
209 if (parseInt(setActivityTypeId)) {
210 var activityTypeId = 'activity_type_id['+setActivityTypeId+']';
211 if (document.getElementById(activityTypeId).checked) {
212 return false;
213 }
214 else {
215 setcount++;
216 }
217 }
218 }
219 if (setcount > 0) {
220 cj('#'+cj(this).parent().attr('id')).hide();
221 }
222 });
223 }
224 });
225 }
226 }
227 }
228 });
229 });
230 }
231 }
232 {/literal}
233 </script>