| 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 | {* Advanced Search Criteria Fieldset *} |
| 27 | {literal} |
| 28 | <script type="text/javascript"> |
| 29 | cj(function($) { |
| 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')); |
| 36 | }); |
| 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', |
| 65 | '6': 'CiviCase', |
| 66 | '8': 'CiviMail' |
| 67 | }; |
| 68 | // Handle change of results mode |
| 69 | $('#component_mode').change(function() { |
| 70 | // Reset task dropdown |
| 71 | $('#task').val(''); |
| 72 | var mode = modes[$('#component_mode').val()] || null; |
| 73 | if (mode) { |
| 74 | $('.crm-' + mode + '-accordion.collapsed').crmAccordionToggle(); |
| 75 | loadPanes(mode); |
| 76 | } |
| 77 | if ($('#component_mode').val() == '7') { |
| 78 | $('#crm-display_relationship_type').show(); |
| 79 | } |
| 80 | else { |
| 81 | $('#display_relationship_type').val(''); |
| 82 | $('#crm-display_relationship_type').hide(); |
| 83 | } |
| 84 | }).change(); |
| 85 | /** |
| 86 | * Loads snippet based on id of crm-accordion-header |
| 87 | */ |
| 88 | function loadPanes(id) { |
| 89 | var url = "{/literal}{crmURL p='civicrm/contact/search/advanced' q="qfKey=`$qfKey`&searchPane=" h=0}{literal}" + id; |
| 90 | var header = $('#' + id); |
| 91 | var body = $('.crm-accordion-body.' + id); |
| 92 | if (header.length > 0 && body.length > 0 && !body.html()) { |
| 93 | body.html('<div class="crm-loading-element"><span class="loading-text">{/literal}{ts escape='js'}Loading{/ts}{literal}...</span></div>'); |
| 94 | header.append('{/literal}<a href="#" class="crm-close-accordion crm-hover-button css_right" title="{ts escape='js'}Remove from search criteria{/ts}"><span class="icon close-icon"></span></a>{literal}'); |
| 95 | header.addClass('active'); |
| 96 | CRM.loadPage(url, {target: body, block: false}); |
| 97 | } |
| 98 | } |
| 99 | }); |
| 100 | </script> |
| 101 | {/literal} |
| 102 | |
| 103 | {if $context EQ 'smog' || $context EQ 'amtg' || $savedSearch} |
| 104 | <h3> |
| 105 | {if $context EQ 'smog'}{ts}Find Contacts within this Group{/ts} |
| 106 | {elseif $context EQ 'amtg'}{ts}Find Contacts to Add to this Group{/ts} |
| 107 | {elseif $savedSearch}{ts 1=$savedSearch.name}%1 Smart Group Criteria{/ts} {help id='id-advanced-smart'} |
| 108 | {/if} |
| 109 | </h3> |
| 110 | {/if} |
| 111 | |
| 112 | {strip} |
| 113 | <div class="crm-accordion-wrapper crm-search_criteria_basic-accordion "> |
| 114 | <div class="crm-accordion-header"> |
| 115 | {ts}Basic Criteria{/ts} |
| 116 | </div><!-- /.crm-accordion-header --> |
| 117 | <div class="crm-accordion-body"> |
| 118 | {include file="CRM/Contact/Form/Search/Criteria/Basic.tpl"} |
| 119 | </div><!-- /.crm-accordion-body --> |
| 120 | </div><!-- /.crm-accordion-wrapper --> |
| 121 | |
| 122 | {foreach from=$allPanes key=paneName item=paneValue} |
| 123 | <div class="crm-accordion-wrapper crm-ajax-accordion crm-{$paneValue.id}-accordion {if $paneValue.open eq 'true' and $openedPanes.$paneName} {else}collapsed{/if}"> |
| 124 | <div class="crm-accordion-header" id="{$paneValue.id}"> |
| 125 | {$paneName} |
| 126 | </div> |
| 127 | <div class="crm-accordion-body {$paneValue.id}"></div> |
| 128 | </div> |
| 129 | {/foreach} |
| 130 | <div class="spacer"></div> |
| 131 | |
| 132 | <table class="form-layout"> |
| 133 | <tr> |
| 134 | <td>{$form.buttons.html}</td> |
| 135 | </tr> |
| 136 | </table> |
| 137 | {/strip} |