2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.5 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2014 |
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
28 <div class="messages status no-popup">
29 <div class="icon inform-icon"></div>
30 {ts}No surveys found.{/ts}
33 <div class="action-link">
34 <a href="{crmURL p='civicrm/survey/add' q='reset=1' h=0 }" class="button"><span><div class="icon add-icon"></div>{ts}Add Survey{/ts}</span></a>
37 {elseif $buildSelector}
39 {* use to display result set of survey *}
40 <div id="survey-result-set-dialog" class="hiddenElement"></div>
42 {* load survey selector *}
43 {include file="CRM/common/enableDisableApi.tpl"}
44 {include file="CRM/common/crmeditable.tpl"}
47 <script type="text/javascript">
54 <table class="surveys">
56 <tr class="columnheader">
57 <th class="hiddenElement">{ts}Survey ID{/ts}</th>
58 <th>{ts}Title{/ts}</th>
59 <th class="hiddenElement">{ts}Campaign ID{/ts}</th>
60 <th>{ts}Campaign{/ts}</th>
61 <th class="hiddenElement">{ts}Survey Type ID{/ts}</th>
62 <th>{ts}Survey Type{/ts}</th>
63 <th>{ts}Release Frequency{/ts}</th>
64 <th>{ts}Reserve Each Time{/ts}</th>
65 <th>{ts}Total Reserve{/ts}</th>
66 <th>{ts}Default?{/ts}</th>
67 <th class="hiddenElement">{ts}Is Active?{/ts}</th>
68 <th>{ts}Active?{/ts}</th>
79 <div class="action-link">
80 <a href="{crmURL p='civicrm/survey/add' q='reset=1' h=0 }" class="button"><span><div class="icon add-icon"></div>{ts}Add Survey{/ts}</span></a>
83 {* build search form here *}
85 {* Search form and results for surveys *}
86 <div class="crm-block crm-form-block crm-search-form-block">
87 {assign var='searchForm' value="search_form_$searchFor"}
89 <div id="{$searchForm}" class="crm-accordion-wrapper crm-survey_search_form-accordion{if $force and !$buildSelector} collapsed{/if}">
90 <div class="crm-accordion-header">
91 {ts}Search Surveys{/ts}
92 </div><!-- /.crm-accordion-header -->
94 <div class="crm-accordion-body">
96 <table class="form-layout-compressed">
98 <td>{$form.survey_title.label}<br />
99 {$form.survey_title.html}
103 <td>{$form.activity_type_id.label}<br />
104 {$form.activity_type_id.html}
106 <td>{$form.survey_campaign_id.label}<br />
107 {$form.survey_campaign_id.html}
112 {if $context eq 'search'}
115 <a class="searchSurvey button" style="float:left;" href="#" title="{ts}Search{/ts}" onClick="searchSurveys( '{$qfKey}' );return false;">{ts}Search{/ts}</a>
124 {* search form ends here *}
126 <div id='surveyList'></div>
128 {/if} {* end of search form build *}
132 <script type="text/javascript">
135 {* load selector when force *}
136 {if $force and !$buildSelector}
139 searchSurveys( {/literal}'{$qfKey}'{literal} );
146 function searchSurveys( qfKey )
148 var dataUrl = {/literal}"{crmURL h=0 q='search=1&snippet=4&type=survey'}"{literal};
150 //lets carry qfKey to retain form session.
151 if ( qfKey ) dataUrl = dataUrl + '&qfKey=' + qfKey;
153 CRM.$.get( dataUrl, null, function( surveyList ) {
154 CRM.$( '#surveyList' ).html( surveyList ).trigger('crmLoad');
156 //collapse the search form.
157 var searchFormName = '#search_form_' + {/literal}'{$searchFor}'{literal};
158 CRM.$( searchFormName + '.crm-accordion-wrapper:not(.collapsed)').crmAccordionToggle();
162 function loadSurveyList( )
164 var sourceUrl = {/literal}"{crmURL p='civicrm/ajax/rest' h=0 q='snippet=4&className=CRM_Campaign_Page_AJAX&fnName=surveyList' }"{literal};
166 //build the search qill.
167 //get the search criteria.
168 var searchParams = {/literal}{$searchParams}{literal};
169 var surveyTypes = {/literal}{$surveyTypes}{literal};
170 var surveyCampaigns = {/literal}{$surveyCampaigns}{literal};
172 var noRecordFoundMsg = "{/literal}{ts escape='js'}No matches found for:{/ts}{literal}";
173 noRecordFoundMsg += '<div class="qill">';
176 var searchQill = new Array( );
177 for ( param in searchParams ) {
178 if ( val = CRM.$( '#' + param ).val( ) ) {
179 if ( param == 'activity_type_id' ) val = surveyTypes[val];
180 if ( param == 'survey_campaign_id' ) val = surveyCampaigns[val];
181 searchQill[count++] = searchParams[param] + ' : ' + val;
184 noRecordFoundMsg += searchQill.join( '<span class="font-italic"> ...AND... </span></div><div class="qill">' );
185 var $context = CRM.$('#surveyList');
186 CRM.$( 'table.surveys', $context).dataTable({
188 "bAutoWidth" : false,
189 "bProcessing": false,
190 "bLengthChange": false,
192 "aoColumns":[{sClass:'crm-survey-id hiddenElement' },
193 {sClass:'crm-survey-title' },
194 {sClass:'crm-survey-campaign_id hiddenElement' },
195 {sClass:'crm-survey-campaign' },
196 {sClass:'crm-survey-activity_type_id hiddenElement' },
197 {sClass:'crm-survey-activity_type' },
198 {sClass:'crm-survey-release_frequency' },
199 {sClass:'crm-survey-default_number_of_contacts' },
200 {sClass:'crm-survey-max_number_of_contacts' },
201 {sClass:'crm-survey-is_default' },
202 {sClass:'crm-survey-is_active hiddenElement' },
203 {sClass:'crm-survey-isActive' },
204 {sClass:'crm-survey-result_id', bSortable:false},
205 {sClass:'crm-survey-action', bSortable:false},
206 {sClass:'crm-campaign-voterLinks', bSortable:false}
208 "sPaginationType": "full_numbers",
209 "sDom" : 'rt<"crm-datatable-pager-bottom"ip>',
212 "sAjaxSource": sourceUrl,
213 "asStripClasses" : [ "odd-row", "even-row" ],
214 "oLanguage":{"sEmptyTable" : noRecordFoundMsg,
215 "sZeroRecords" : noRecordFoundMsg },
216 "fnDrawCallback": function() { CRM.$().crmtooltip(); },
217 "fnRowCallback": function( nRow, aData, iDisplayIndex ) {
218 //insert the id for each row for enable/disable.
219 var rowId = 'survey_row_' + aData[0];
220 CRM.$(nRow).attr( 'id', rowId );
221 //handled disabled rows.
222 var isActive = Boolean(Number(aData[10]));
223 if ( !isActive ) CRM.$(nRow).addClass( 'disabled' );
225 //add id for yes/no column.
226 CRM.$(nRow).children().eq(11).attr( 'id', rowId + '_status' );
231 "fnServerData": function ( sSource, aoData, fnCallback ) {
232 var dataLength = aoData.length;
235 var searchCriteria = new Array( );
237 //get the search criteria.
238 var searchParams = {/literal}{$searchParams}{literal};
239 for ( param in searchParams ) {
241 if ( param == 'survey_title' ) fldName = 'title';
242 if ( param == 'survey_campaign_id' ) fldName = 'campaign_id';
243 if ( val = CRM.$( '#' + param ).val( ) ) {
244 aoData[dataLength++] = {name: fldName, value: val};
246 searchCriteria[count++] = fldName;
249 //do search for surveys.
250 aoData[dataLength++] = {name: 'search_for', value: 'survey'};
252 //lets transfer search criteria.
253 aoData[dataLength++] = {name: 'searchCriteria', value:searchCriteria.join(',')};
260 "success": fnCallback
265 function displayResultSet( surveyId, surveyTitle, OptionGroupId ) {
266 var data = new Object;
267 data['option_group_id'] = OptionGroupId;
268 data['survey_id'] = surveyId;
270 var dataUrl = {/literal}"{crmURL p='civicrm/ajax/rest' h=0 q='className=CRM_Campaign_Page_AJAX&fnName=loadOptionGroupDetails' }"{literal};
271 var content = '<tr><th>{/literal}{ts escape='js'}Label{/ts}{literal}</th><th>{/literal}{ts escape='js'}Value{/ts}{literal}</th><th>{/literal}{ts escape='js'}Recontact Interval{/ts}{literal}</th><th>{/literal}{ts escape='js'}Weight{/ts}{literal}</th></tr>';
272 var setTitle = '{/literal}{ts escape='js'}Result Set for{/ts} {literal}' + surveyTitle;
274 CRM.$.post( dataUrl, data, function( opGroup ) {
275 if ( opGroup.status == 'success' ) {
276 var result = opGroup.result;
277 for( key in result ) {
279 if ( result[key].interval && result[key].interval != 'undefined' ) {
280 interval = result[key].interval;
282 content += '<tr><td>'+ result[key].label +'</td><td>'+ result[key].value +'</td><td>'+ interval +'</td><td>'+ result[key].weight +'</td></tr>';
285 CRM.$("#survey-result-set-dialog").show( ).html('<table>'+content+'</table>').dialog({
293 beforeclose: function(event, ui) {
294 CRM.$(this).dialog("destroy");