Merge remote-tracking branch 'upstream/4.3' into 4.3-master-2013-05-28-14-04-12
[civicrm-core.git] / templates / CRM / Campaign / Form / Search / Common.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.3 |
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 {* Search form and results for voters *}
27 <div class="crm-block crm-form-block crm-search-form-block">
28
29 {assign var='searchForm' value='searchForm'}
30 {if $searchVoterFor}
31 {assign var='searchForm' value="search_form_$searchVoterFor"}
32 {/if}
33
34 <div id="{$searchForm}" class="crm-accordion-wrapper crm-contribution_search_form-accordion {if $rows}collapsed{/if}">
35 <div class="crm-accordion-header crm-master-accordion-header">
36 {ts}Edit Search Criteria{/ts}
37 </div><!-- /.crm-accordion-header -->
38
39 <div class="crm-accordion-body">
40 {strip}
41 <table class="form-layout">
42 <tr>
43 <td class="font-size12pt">
44 {$form.campaign_survey_id.label}
45 </td>
46 <td>
47 {$form.campaign_survey_id.html}
48 </td>
49
50 {if $showInterviewer}
51 <td class="font-size12pt">
52 {$form.survey_interviewer_name.label}
53 </td>
54 <td class="font-size12pt ">
55 {$form.survey_interviewer_name.html}
56 </td>
57 {/if}
58
59 </tr>
60 <tr>
61 <td class="font-size12pt">
62 {$form.sort_name.label}
63 </td>
64 <td>
65 {$form.sort_name.html|crmAddClass:'twenty'}
66 </td>
67 <td><label>{ts}Contact Type(s){/ts}</label><br />
68 {$form.contact_type.html}
69 {literal}
70 <script type="text/javascript">
71 cj("select#contact_type").crmasmSelect({
72 addItemTarget: 'bottom',
73 animate: false,
74 highlight: true,
75 sortable: true,
76 respectParents: true
77 });
78 </script>
79 {/literal}
80 </td>
81 <td><label>{ts}Group(s){/ts}</label>
82 {$form.group.html}
83 {literal}
84 <script type="text/javascript">
85 cj("select#group").crmasmSelect({
86 addItemTarget: 'bottom',
87 animate: false,
88 highlight: true,
89 sortable: true,
90 respectParents: true,
91 selectClass:'campaignGroupsSelect'
92 });
93 </script>
94 {/literal}
95 </td>
96 </tr>
97 <tr>
98 <td class="font-size12pt">
99 {$form.street_address.label}
100 </td>
101 <td>
102 {$form.street_address.html}
103 </td>
104 <td class="font-size12pt">
105 {$form.street_name.label}
106 </td>
107 <td>
108 {$form.street_name.html}
109 </td>
110 </tr>
111 <tr>
112 <td class="font-size12pt">
113 {$form.street_unit.label}
114 </td>
115 <td>
116 {$form.street_unit.html}
117 </td>
118 <td class="font-size12pt">
119 {$form.city.label}
120 </td>
121 <td>
122 {$form.city.html}
123 </td>
124 </tr>
125 <tr>
126 <td class="font-size12pt">
127 {$form.street_number.label}
128 </td>
129 <td>
130 {$form.street_number.html}
131 </td>
132
133 <td class="font-size12pt">
134 {$form.postal_code.label}
135 </td>
136 <td>
137 {$form.postal_code.html}
138 </td>
139 </tr>
140 {if $customSearchFields.ward || $customSearchFields.precinct}
141 <tr>
142 {if $customSearchFields.ward}
143 {assign var='ward' value=$customSearchFields.ward}
144 <td class="font-size12pt">
145 {$form.$ward.label}
146 </td>
147 <td>
148 {$form.$ward.html}
149 </td>
150 {/if}
151
152 {if $customSearchFields.precinct}
153 {assign var='precinct' value=$customSearchFields.precinct}
154 <td class="font-size12pt">
155 {$form.$precinct.label}
156 </td>
157 <td>
158 {$form.$precinct.html}
159 </td>
160 {/if}
161 </tr>
162 {/if}
163 <tr>
164 <td colspan="2">
165 {if $context eq 'search'}
166 {$form.buttons.html}
167 {else}
168 <a class="searchVoter button" style="float:left;" href="#" title={ts}Search{/ts} onClick="searchVoters( '{$qfKey}' );return false;">{ts}Search{/ts}</a>
169 {/if}
170 </td>
171 </tr>
172 </table>
173 {/strip}
174
175 </div>
176 </div>
177 </div>
178
179 {literal}
180 <script type="text/javascript">
181
182 cj(function() {
183 cj().crmAccordions();
184
185 {/literal}
186 {if !$isFormSubmitted}
187 buildCampaignGroups( );
188 {/if}
189 {literal}
190 });
191
192 //load interviewer autocomplete.
193 var interviewerDataUrl = "{/literal}{$dataUrl}{literal}";
194 var hintText = "{/literal}{ts escape='js'}Type in a partial or complete name of an existing contact.{/ts}{literal}";
195 cj( "#survey_interviewer_name" ).autocomplete( interviewerDataUrl,
196 { width : 256,
197 selectFirst : false,
198 hintText: hintText,
199 matchContains: true,
200 minChars: 1
201 }
202 ).result( function( event, data, formatted ) {
203 cj( "#survey_interviewer_id" ).val( data[1] );
204 }).bind( 'click', function( ) {
205 cj( "#survey_interviewer_id" ).val('');
206 });
207
208
209 function buildCampaignGroups( surveyId ) {
210 if ( !surveyId ) surveyId = cj("#campaign_survey_id").val( );
211
212 var operation = {/literal}'{$searchVoterFor}'{literal};
213 if ( !surveyId || operation != 'reserve' ) return;
214
215 var grpUrl = {/literal}"{crmURL p='civicrm/ajax/rest' h=0 q='className=CRM_Campaign_Page_AJAX&fnName=campaignGroups'}"
216 {literal};
217
218 cj.post( grpUrl,
219 {survey_id:surveyId},
220 function( data ) {
221 if ( data.status != 'success' ) return;
222
223 var selectName = 'campaignGroupsSelect';
224 var groupSelect = cj("select[id^=" + selectName + "]");
225 var groupSelectCountId = cj( groupSelect ).attr( 'id' ).replace( selectName, '' );
226
227 //first remove all groups for given survey.
228 cj( "#group" ).find('option').remove( );
229 cj( groupSelect ).find('option').remove( );
230 cj( '#crmasmContainer' + groupSelectCountId ).find( 'span' ).remove( );
231 cj( '#crmasmList' + groupSelectCountId ).find( 'li' ).remove( );
232
233 var groups = data.groups;
234
235 //build the new group options.
236 var optCount = 0;
237 for ( group in groups ) {
238 title = groups[group].title;
239 value = groups[group].value;
240 if ( !title ) continue;
241 var crmOptCount = 'asm' + groupSelectCountId + 'option' + optCount;
242
243 //add options to main group select.
244 cj( "#group" ).append( cj('<option></option>').val( value ).html( title ).attr( 'id', crmOptCount ) );
245
246 //add option to crm multi select ul.
247 cj( groupSelect ).append( cj('<option></option>').val(value).html(title).attr( 'rel', crmOptCount ) );
248
249 optCount++;
250 }
251 },
252 'json');
253 }
254
255 </script>
256 {/literal}