fixes for CRM-13476
[civicrm-core.git] / templates / CRM / Contact / Form / Search / AdvancedCriteria.tpl
CommitLineData
6a488035
TO
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{* Advanced Search Criteria Fieldset *}
27{literal}
28<script type="text/javascript">
29cj(function($) {
d2c45957
CW
30 $().crmAccordions();
31 // Bind first click of accordion header to load crm-accordion-body with snippet
32 // everything else is taken care of by crmAccordions()
33 $('.crm-search_criteria_basic-accordion .crm-accordion-header').addClass('active');
34 $('.crm-ajax-accordion').on('click', '.crm-accordion-header:not(.active)', function() {
35 loadPanes($(this).attr('id'));
6a488035 36 });
d2c45957
CW
37 $('.crm-ajax-accordion:not(.collapsed) .crm-accordion-header').each(function() {
38 loadPanes($(this).attr('id'));
39 });
40 $('.crm-ajax-accordion').on('click', '.crm-close-accordion', function() {
41 var header = $(this).parent();
42 header.next().html('');
43 header.removeClass('active');
44 header.parent('.crm-ajax-accordion:not(.collapsed)').crmAccordionToggle();
45 // Reset results-display mode if it depends on this pane
46 var mode = modes[$('#component_mode').val()] || null;
47 if (mode && header.attr('id') == mode) {
48 var oldMode = $('#component_mode :selected').text();
49 $('#component_mode').val('1');
50 {/literal}
51 var msg = '{ts escape="js"}Displaying results as "%1" is not available without search criteria from the pane you just closed.{/ts}';
52 msg = msg.replace('%1', oldMode);
53 CRM.alert(msg, '{ts escape="js"}Display Results have been Reset{/ts}');
54 {literal}
55 }
56 $(this).remove();
57 return false;
58 });
59 // TODO: Why are the modes numeric? If they used the string there would be no need for this map
60 var modes = {
61 '2': 'CiviContribute',
62 '3': 'CiviEvent',
63 '4': 'activity',
64 '5': 'CiviMember',
1dcf6b53 65 '6': 'CiviCase'
d2c45957
CW
66 };
67 // Handle change of results mode
68 $('#component_mode').change(function() {
69 // Reset task dropdown
70 $('#task').val('');
71 var mode = modes[$('#component_mode').val()] || null;
72 if (mode) {
73 $('.crm-' + mode + '-accordion.collapsed').crmAccordionToggle();
74 loadPanes(mode);
75 }
76 if ($('#component_mode').val() == '7') {
77 $('#crm-display_relationship_type').show();
78 }
79 else {
80 $('#display_relationship_type').val('');
81 $('#crm-display_relationship_type').hide();
82 }
83 }).change();
84 /**
85 * Loads snippet based on id of crm-accordion-header
86 */
6a488035
TO
87 function loadPanes(id) {
88 var url = "{/literal}{crmURL p='civicrm/contact/search/advanced' q="snippet=1&qfKey=`$qfKey`&searchPane=" h=0}{literal}" + id;
89 var header = $('#' + id);
90 var body = $('.crm-accordion-body.' + id);
91 if (header.length > 0 && body.length > 0 && !body.html()) {
92 body.html('<div class="crm-loading-element"><span class="loading-text">{/literal}{ts escape='js'}Loading{/ts}{literal}...</span></div>');
b4172122 93 header.append('{/literal}<a href="#" class="crm-close-accordion" title="{ts escape='js'}Remove from search criteria{/ts}"><span>{ts escape='js'}Reset{/ts}</span> &nbsp;<img src="{$config->resourceBase}i/close.png" /></a>{literal}');
6a488035
TO
94 header.addClass('active');
95 $.ajax({
96 url : url,
97 success: function(data) {
98 body.html(data);
99 },
100 error: function() {
101 CRM.alert({/literal}'{ts escape="js"}Sorry, could not load the requested information from the server.{/ts}', '{ts escape="js"}Network Error{/ts}'{literal});
b4172122 102 $('.crm-close-accordion', header).click();
6a488035
TO
103 }
104 });
105 }
106 }
107});
108</script>
109{/literal}
110
111 {if $context EQ 'smog' || $context EQ 'amtg' || $savedSearch}
112 <h3>
113 {if $context EQ 'smog'}{ts}Find Contacts within this Group{/ts}
114 {elseif $context EQ 'amtg'}{ts}Find Contacts to Add to this Group{/ts}
115 {elseif $savedSearch}{ts 1=$savedSearch.name}%1 Smart Group Criteria{/ts} &nbsp; {help id='id-advanced-smart'}
116 {/if}
117 </h3>
118 {/if}
119
120{strip}
121<div class="crm-accordion-wrapper crm-search_criteria_basic-accordion ">
122 <div class="crm-accordion-header">
123 {ts}Basic Criteria{/ts}
124 </div><!-- /.crm-accordion-header -->
125 <div class="crm-accordion-body">
126 {include file="CRM/Contact/Form/Search/Criteria/Basic.tpl"}
127 </div><!-- /.crm-accordion-body -->
128</div><!-- /.crm-accordion-wrapper -->
129
130 {foreach from=$allPanes key=paneName item=paneValue}
131 <div class="crm-accordion-wrapper crm-ajax-accordion crm-{$paneValue.id}-accordion {if $paneValue.open eq 'true' and $openedPanes.$paneName} {else}collapsed{/if}">
132 <div class="crm-accordion-header" id="{$paneValue.id}">
133 {$paneName}
134 </div>
135 <div class="crm-accordion-body {$paneValue.id}"></div>
136 </div>
137 {/foreach}
138 <div class="spacer"></div>
139
140 <table class="form-layout">
141 <tr>
142 <td>{$form.buttons.html}</td>
143 </tr>
144 </table>
145{/strip}