Update version numbers to 4.4 and lint php
[civicrm-core.git] / templates / CRM / Group / Form / Search.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 <div class="crm-block crm-form-block crm-group-search-form-block">
27
28 <h3>{ts}Find Groups{/ts}</h3>
29 <table class="form-layout">
30 <tr>
31 <td>
32 {$form.title.label}<br />
33 {$form.title.html}<br />
34 <span class="description font-italic">
35 {ts}Complete OR partial group name.{/ts}
36 </span>
37 </td>
38 <td>
39 {$form.created_by.label}<br />
40 {$form.created_by.html}<br />
41 <span class="description font-italic">
42 {ts}Complete OR partial creator name.{/ts}
43 </span>
44 </td>
45 <td id="group_type-block">
46 {$form.group_type.label}<br />
47 {$form.group_type.html}<br />
48 <span class="description font-italic">
49 {ts}Filter search by group type(s).{/ts}
50 </span>
51 </td>
52 <td>
53 {$form.visibility.label}<br />
54 {$form.visibility.html}<br />
55 <span class="description font-italic">
56 {ts}Filter search by visibility.{/ts}
57 </span>
58 </td>
59 <td>
60 {$form.group_status.label}<br />
61 {$form.group_status.html}
62 </td>
63 </tr>
64 <tr>
65 <td>{$form.buttons.html}</td><td colspan="2">
66 </tr>
67 </table>
68 </div>
69 <br/>
70 <table id="crm-group-selector">
71 <thead>
72 <tr>
73 <th class='crm-group-name'>{ts}Name{/ts}</th>
74 <th class='crm-group-group_id'>{ts}ID{/ts}</th>
75 <th class='crm-group-created_by'>{ts}Created By{/ts}</th>
76 <th class='crm-group-description'>{ts}Description{/ts}</th>
77 <th class='crm-group-group_type'>{ts}Group Type{/ts}</th>
78 <th class='crm-group-visibility'>{ts}Visibility{/ts}</th>
79 {if $showOrgInfo}
80 <th class='crm-group-org_info'>{ts}Organization{/ts}</th>
81 {/if}
82 <th class='crm-group-group_links nosort'>&nbsp;</th>
83 <th class='hiddenElement'>&nbsp;</th>
84 </tr>
85 </thead>
86 </table>
87
88 {* handle enable/disable actions*}
89 {include file="CRM/common/enableDisable.tpl"}
90
91 {literal}
92 <script type="text/javascript">
93 cj( function() {
94 buildGroupSelector( false );
95 cj('#_qf_Search_refresh').click( function() {
96 buildGroupSelector( true );
97 });
98 });
99
100 function buildGroupSelector( filterSearch ) {
101 if ( filterSearch ) {
102 crmGroupSelector.fnDestroy();
103 var parentsOnly = 0;
104 var ZeroRecordText = '<div class="status messages">{/literal}{ts escape="js"}No matching Groups found for your search criteria. Suggestions:{/ts}{literal}<div class="spacer"></div><ul><li>{/literal}{ts escape="js"}Check your spelling.{/ts}{literal}</li><li>{/literal}{ts escape="js"}Try a different spelling or use fewer letters.{/ts}{literal}</li><li>{/literal}{ts escape="js"}Make sure you have enough privileges in the access control system.{/ts}{literal}</li></ul></div>';
105 } else {
106 var parentsOnly = 1;
107 var ZeroRecordText = {/literal}'{ts escape="js"}<div class="status messages">No Groups have been created for this site.{/ts}</div>'{literal};
108 }
109
110 var columns = '';
111 var sourceUrl = {/literal}'{crmURL p="civicrm/ajax/grouplist" h=0 q="snippet=4"}'{literal};
112 var showOrgInfo = {/literal}"{$showOrgInfo}"{literal};
113
114 crmGroupSelector = cj('#crm-group-selector').dataTable({
115 "bFilter" : false,
116 "bAutoWidth" : false,
117 "aaSorting" : [],
118 "aoColumns" : [
119 {sClass:'crm-group-name'},
120 {sClass:'crm-group-group_id'},
121 {sClass:'crm-group-created_by'},
122 {sClass:'crm-group-description', bSortable:false},
123 {sClass:'crm-group-group_type'},
124 {sClass:'crm-group-visibility'},
125 {sClass:'crm-group-group_links', bSortable:false},
126 {/literal}{if $showOrgInfo}{literal}
127 {sClass:'crm-group-org_info', bSortable:false},
128 {/literal}{/if}{literal}
129 {sClass:'hiddenElement', bSortable:false}
130 ],
131 "bProcessing": true,
132 "asStripClasses" : [ "odd-row", "even-row" ],
133 "sPaginationType": "full_numbers",
134 "sDom" : '<"crm-datatable-pager-top"lfp>rt<"crm-datatable-pager-bottom"ip>',
135 "bServerSide": true,
136 "bJQueryUI": true,
137 "sAjaxSource": sourceUrl,
138 "iDisplayLength": 25,
139 "oLanguage": { "sZeroRecords": ZeroRecordText,
140 "sProcessing": {/literal}"{ts escape='js'}Processing...{/ts}"{literal},
141 "sLengthMenu": {/literal}"{ts escape='js'}Show _MENU_ entries{/ts}"{literal},
142 "sInfo": {/literal}"{ts escape='js'}Showing _START_ to _END_ of _TOTAL_ entries{/ts}"{literal},
143 "sInfoEmpty": {/literal}"{ts escape='js'}Showing 0 to 0 of 0 entries{/ts}"{literal},
144 "sInfoFiltered": {/literal}"{ts escape='js'}(filtered from _MAX_ total entries){/ts}"{literal},
145 "sSearch": {/literal}"{ts escape='js'}Search:{/ts}"{literal},
146 "oPaginate": {
147 "sFirst": {/literal}"{ts escape='js'}First{/ts}"{literal},
148 "sPrevious": {/literal}"{ts escape='js'}Previous{/ts}"{literal},
149 "sNext": {/literal}"{ts escape='js'}Next{/ts}"{literal},
150 "sLast": {/literal}"{ts escape='js'}Last{/ts}"{literal}
151 }
152 },
153 "fnDrawCallback": function() { setSelectorClass( parentsOnly, showOrgInfo ); },
154 "fnServerData": function ( sSource, aoData, fnCallback ) {
155 aoData.push( {name:'showOrgInfo', value: showOrgInfo },
156 {name:'parentsOnly', value: parentsOnly }
157 );
158 if ( filterSearch ) {
159 var groupTypes = '';
160 cj('#group_type-block input').each(function(index) {
161 if (cj(this).prop('checked')) {
162 if (groupTypes) {
163 groupTypes = groupTypes + ',' + cj(this).attr('id').substr(11);
164 }
165 else {
166 groupTypes = cj(this).attr('id').substr(11);
167 }
168 }
169 });
170
171 var groupStatus = '';
172 if ( cj('.crm-group-search-form-block #group_status_1').prop('checked') ) {
173 groupStatus = '1';
174 }
175
176 if ( cj('.crm-group-search-form-block #group_status_2').prop('checked') ) {
177 if ( groupStatus ) {
178 groupStatus = '3';
179 } else {
180 groupStatus = '2';
181 }
182 }
183
184 aoData.push(
185 {name:'title', value: cj('.crm-group-search-form-block #title').val()},
186 {name:'created_by', value: cj('.crm-group-search-form-block #created_by').val()},
187 {name:'group_type', value: groupTypes },
188 {name:'visibility', value: cj('.crm-group-search-form-block #visibility').val()},
189 {name:'status', value: groupStatus }
190 );
191 }
192 cj.ajax( {
193 "dataType": 'json',
194 "type": "POST",
195 "url": sSource,
196 "data": aoData,
197 "success": fnCallback
198 } );
199 }
200 });
201 }
202
203 function setSelectorClass( parentsOnly, showOrgInfo ) {
204 cj('#crm-group-selector tr').each( function( ) {
205 var className = cj(this).find('td:last-child').text();
206 cj(this).addClass( className );
207 var rowID = cj(this).find('td:nth-child(2)').text();
208 cj(this).prop( 'id', 'row_' + rowID );
209 if (parentsOnly) {
210 if ( cj(this).hasClass('crm-group-parent') ) {
211 cj(this).find('td:first').prepend('{/literal}<span class="collapsed show-children" title="{ts}show child groups{/ts}"/></span>{literal}');
212 }
213 }
214 });
215 }
216
217 // show hide children
218 cj('#crm-group-selector').on( 'click', 'span.show-children', function(){
219 var showOrgInfo = {/literal}"{$showOrgInfo}"{literal};
220 var rowID = cj(this).parents('tr').prop('id');
221 var parentRow = rowID.split('_');
222 var parent_id = parentRow[1];
223 var group_id = '';
224 if ( parentRow[2]) {
225 group_id = parentRow[2];
226 }
227 var levelClass = 'level_2';
228 // check enclosing td if already at level 2
229 if ( cj(this).parent().hasClass('level_2') ) {
230 levelClass = 'level_3';
231 }
232 if ( cj(this).hasClass('collapsed') ) {
233 cj(this).removeClass("collapsed").addClass("expanded").attr("title",{/literal}"{ts escape='js'}hide child groups{/ts}"{literal});
234 showChildren( parent_id, showOrgInfo, group_id, levelClass );
235 }
236 else {
237 cj(this).removeClass("expanded").addClass("collapsed").attr("title",{/literal}"{ts escape='js'}show child groups{/ts}"{literal});
238 cj('.parent_is_' + parent_id).find('.show-children').removeClass("expanded").addClass("collapsed").attr("title",{/literal}"{ts escape='js'}show child groups{/ts}"{literal});
239 cj('.parent_is_' + parent_id).hide();
240 cj('.parent_is_' + parent_id).each(function(i, obj) {
241 // also hide children of children
242 var gID = cj(this).find('td:nth-child(2)').text();
243 cj('.parent_is_' + gID).hide();
244 });
245 }
246 });
247
248 function showChildren( parent_id, showOrgInfo, group_id, levelClass) {
249 var rowID = '#row_' + parent_id;
250 if ( group_id ) {
251 rowID = '#row_' + parent_id + '_' + group_id;
252 }
253 if ( cj(rowID).next().hasClass('parent_is_' + parent_id ) ) {
254 // child rows for this parent have already been retrieved so just show them
255 cj('.parent_is_' + parent_id ).show();
256 } else {
257 var sourceUrl = {/literal}'{crmURL p="civicrm/ajax/grouplist" h=0 q="snippet=4"}'{literal};
258 cj.ajax( {
259 "dataType": 'json',
260 "url": sourceUrl,
261 "data": {'parent_id': parent_id, 'showOrgInfo': showOrgInfo},
262 "success": function(response){
263 var appendHTML = '';
264 cj.each( response, function( i, val ) {
265 appendHTML += '<tr id="row_'+ val.group_id +'_'+parent_id+'" class="parent_is_' + parent_id + ' crm-row-child ' + val.class + '">';
266 if ( val.is_parent ) {
267 appendHTML += '<td class="crm-group-name ' + levelClass + '">' + '{/literal}<span class="collapsed show-children" title="{ts}show child groups{/ts}"/></span>{literal}' + val.group_name + '</td>';
268 }
269 else {
270 appendHTML += '<td class="crm-group-name ' + levelClass + '"><span class="crm-no-children"></span>' + val.group_name + '</td>';
271 }
272 appendHTML += "<td>" + val.group_id + "</td>";
273 appendHTML += "<td>" + val.created_by + "</td>";
274 if (val.group_description) {
275 appendHTML += "<td>" + val.group_description + "</td>";
276 } else {
277 appendHTML += "<td>&nbsp;</td>";
278 }
279 appendHTML += "<td>" + val.group_type + "</td>";
280 appendHTML += "<td>" + val.visibility + "</td>";
281 appendHTML += "<td>" + val.links + "</td>";
282 appendHTML += "</tr>";
283 });
284 cj( rowID ).after( appendHTML );
285 }
286 } );
287 }
288 }
289
290 </script>
291 {/literal}