2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.7 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2016 |
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>
33 <div class="action-link">
34 {crmButton p='civicrm/petition/add' q='reset=1' h=0 icon="plus-circle"}{ts}Add Petition{/ts}{/crmButton}
37 {elseif $buildSelector}
39 {* use to display result set of petition *}
40 <div id="petition-result-set-dialog" class="hiddenElement"></div>
42 {* load petition selector *}
44 {include file="CRM/common/enableDisableApi.tpl"}
47 <script type="text/javascript">
54 <table class="petitions">
56 <tr class="columnheader">
57 <th class="hiddenElement">{ts}Petition 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}Petition Type ID{/ts}</th>
62 <th class="hiddenElement">{ts}Petition Type{/ts}</th>
63 <th>{ts}Default?{/ts}</th>
64 <th class="hiddenElement">{ts}Is Active?{/ts}</th>
65 <th>{ts}Active?{/ts}</th>
74 <div class="action-link">
75 {crmButton p='civicrm/petition/add' q='reset=1' h=0 icon="plus-circle"}{ts}Add Petition{/ts}{/crmButton}
78 {* build search form here *}
80 {* Search form and results for petitions *}
81 <div class="crm-block crm-form-block crm-search-form-block">
83 {assign var='searchForm' value="search_form_$searchFor"}
85 <div id="{$searchForm}" class="crm-accordion-wrapper crm-petition_search_form-accordion {if $force and !$buildSelector}collapsed{/if}">
86 <div class="crm-accordion-header">
87 {ts}Search Petitions{/ts}
88 </div><!-- /.crm-accordion-header -->
90 <div class="crm-accordion-body">
92 <table class="form-layout-compressed">
94 <td>{$form.petition_title.label}<br />
95 {$form.petition_title.html}
97 <td>{$form.petition_campaign_id.label}<br />
98 {$form.petition_campaign_id.html}
103 {if $context eq 'search'}
106 <a class="searchPetition button" style="float:left;" href="#" title={ts}Search{/ts} onClick="searchPetitions( '{$qfKey}' );return false;">{ts}Search{/ts}</a>
115 {* search form ends here *}
117 <div id='petitionList'></div>
119 {/if} {* end of search form build *}
123 <script type="text/javascript">
126 {* load selector when force *}
127 {if $force and !$buildSelector}
130 searchPetitions( {/literal}'{$qfKey}'{literal} );
137 function searchPetitions( qfKey )
139 var dataUrl = {/literal}"{crmURL h=0 q='search=1&snippet=4&type=petition'}"{literal};
141 //lets carry qfKey to retain form session.
142 if ( qfKey ) dataUrl = dataUrl + '&qfKey=' + qfKey;
144 CRM.$.get( dataUrl, null, function( petitionList ) {
145 CRM.$( '#petitionList' ).html( petitionList ).trigger('crmLoad');
147 //collapse the search form.
148 var searchFormName = '#search_form_' + {/literal}'{$searchFor}'{literal};
149 CRM.$( searchFormName + '.crm-accordion-wrapper:not(.collapsed)').crmAccordionToggle();
153 function loadPetitionList( )
155 var sourceUrl = {/literal}"{crmURL p='civicrm/ajax/rest' h=0 q='snippet=4&className=CRM_Campaign_Page_AJAX&fnName=petitionList' }"{literal};
157 //build the search qill.
158 //get the search criteria.
159 var searchParams = {/literal}{$searchParams}{literal};
160 var campaigns = {/literal}{$petitionCampaigns}{literal};
162 var noRecordFoundMsg = '{/literal}{ts escape='js'}No matches found for:{/ts}{literal}';
163 noRecordFoundMsg += '<div class="qill">';
167 for ( param in searchParams ) {
168 if ( val = CRM.$( '#' + param ).val( ) ) {
169 if ( param == 'petition_campaign_id' ) val = campaigns[val];
170 searchQill[count++] = searchParams[param] + ' : ' + val;
173 noRecordFoundMsg += searchQill.join( '<span class="font-italic"> ...AND... </span></div><div class="qill">' );
174 CRM.$( 'table.petitions', '#petitionList').dataTable({
176 "bAutoWidth" : false,
177 "bProcessing": false,
178 "bLengthChange": false,
181 {sClass:'crm-petition-id hiddenElement' },
182 {sClass:'crmf-title' },
183 {sClass:'crm-petition-campaign_id hiddenElement' },
184 {sClass:'crmf-campaign_id' },
185 {sClass:'crm-petition-activity_type_id hiddenElement' },
186 {sClass:'crm-petition-activity_type hiddenElement' },
187 {sClass:'crm-petition-is_default' },
188 {sClass:'crm-petition-is_active hiddenElement' },
189 {sClass:'crm-petition-isActive' },
190 {sClass:'crm-petition-action', bSortable:false}
192 "sPaginationType": "full_numbers",
193 "sDom" : 'rt<"crm-datatable-pager-bottom"ip>',
196 "sAjaxSource": sourceUrl,
197 "asStripClasses" : [ "odd-row", "even-row" ],
198 "oLanguage":{"sEmptyTable" : noRecordFoundMsg,
199 "sZeroRecords" : noRecordFoundMsg },
200 "fnDrawCallback": function() {
201 // FIXME: trigger crmLoad and crmEditable would happen automatically
202 CRM.$('.crm-editable').crmEditable();
204 "fnRowCallback": function( nRow, aData, iDisplayIndex ) {
207 CRM.$(nRow).children().eq(1).addClass('crm-editable');
209 //insert the id for each row for enable/disable.
210 var rowId = 'survey-' + aData[0];
211 CRM.$(nRow).attr( 'id', rowId).addClass('crm-entity');
212 //handled disabled rows.
213 var isActive = Boolean(Number(aData[7]));
214 if ( !isActive ) CRM.$(nRow).addClass( 'disabled' );
216 //add id for yes/no column.
217 CRM.$(nRow).children().eq(8).attr( 'id', rowId + '_status' );
222 "fnServerData": function ( sSource, aoData, fnCallback ) {
223 var dataLength = aoData.length;
226 var searchCriteria = [];
228 //get the search criteria.
229 var searchParams = {/literal}{$searchParams}{literal};
230 for ( param in searchParams ) {
232 if ( param == 'petition_title' ) fldName = 'title';
233 if ( param == 'petition_campaign_id' ) fldName = 'campaign_id';
234 if ( val = CRM.$( '#' + param ).val( ) ) {
235 aoData[dataLength++] = {name: fldName, value: val};
237 searchCriteria[count++] = fldName;
240 //do search for petitions.
241 aoData[dataLength++] = {name: 'search_for', value: 'petition'};
243 //lets transfer search criteria.
244 aoData[dataLength++] = {name: 'searchCriteria', value:searchCriteria.join(',')};
251 "success": fnCallback