Fix undefined var
[civicrm-core.git] / templates / CRM / Contact / Form / Search / Custom.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{* Default template custom searches. This template is used automatically if templateFile() function not defined in
27 custom search .php file. If you want a different layout, clone and customize this file and point to new file using
28 templateFile() function.*}
29<div class="crm-block crm-form-block crm-contact-custom-search-form-block">
30<div class="crm-accordion-wrapper crm-custom_search_form-accordion {if $rows}collapsed{/if}">
31 <div class="crm-accordion-header crm-master-accordion-header">
32 {ts}Edit Search Criteria{/ts}
33 </div><!-- /.crm-accordion-header -->
34 <div class="crm-accordion-body">
35 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
36 <table class="form-layout-compressed">
37 {* Loop through all defined search criteria fields (defined in the buildForm() function). *}
38 {foreach from=$elements item=element}
39 <tr class="crm-contact-custom-search-form-row-{$element}">
40 <td class="label">{$form.$element.label}</td>
41 {if $element eq 'start_date'}
42 <td>{include file="CRM/common/jcalendar.tpl" elementName=start_date}</td>
43 {elseif $element eq 'end_date'}
44 <td>{include file="CRM/common/jcalendar.tpl" elementName=end_date}</td>
45 {else}
46 <td>{$form.$element.html}</td>
47 {/if}
48 </tr>
49 {/foreach}
50 </table>
51 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
52 </div><!-- /.crm-accordion-body -->
53</div><!-- /.crm-accordion-wrapper -->
54</div><!-- /.crm-form-block -->
55
56{if $rowsEmpty || $rows}
57<div class="crm-content-block">
58{if $rowsEmpty}
59 {include file="CRM/Contact/Form/Search/Custom/EmptyResults.tpl"}
60{/if}
61
62{if $summary}
63 {$summary.summary}: {$summary.total}
64{/if}
65
66{if $rows}
67 <div class="crm-results-block">
68 {* Search request has returned 1 or more matching rows. Display results and collapse the search criteria fieldset. *}
69 {* This section handles form elements for action task select and submit *}
70 <div class="crm-search-tasks">
71 {include file="CRM/Contact/Form/Search/ResultTasks.tpl"}
72 </div>
73 {* This section displays the rows along and includes the paging controls *}
74 <div class="crm-search-results">
75
76 {include file="CRM/common/pager.tpl" location="top"}
77
78 {* Include alpha pager if defined. *}
79 {if $atoZ}
80 {include file="CRM/common/pagerAToZ.tpl"}
81 {/if}
82
83 {strip}
84 <table class="selector" summary="{ts}Search results listings.{/ts}">
85 <thead class="sticky">
86 <tr>
87 <th scope="col" title="Select All Rows">{$form.toggleSelect.html}</th>
88 {foreach from=$columnHeaders item=header}
89 <th scope="col">
90 {if $header.sort}
91 {assign var='key' value=$header.sort}
92 {$sort->_response.$key.link}
93 {else}
94 {$header.name}
95 {/if}
96 </th>
97 {/foreach}
98 <th>&nbsp;</th>
99 </tr>
100 </thead>
101
102 {counter start=0 skip=1 print=false}
103 {foreach from=$rows item=row}
104 <tr id='rowid{$row.contact_id}' class="{cycle values="odd-row,even-row"}">
105 {assign var=cbName value=$row.checkbox}
106 <td>{$form.$cbName.html}</td>
107 {foreach from=$columnHeaders item=header}
108 {assign var=fName value=$header.sort}
109 {if $fName eq 'sort_name'}
110 <td><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.contact_id`"}">{$row.sort_name}</a></td>
111 {else}
112 <td>{$row.$fName}</td>
113 {/if}
114 {/foreach}
115 <td>{$row.action}</td>
116 </tr>
117 {/foreach}
118 </table>
119 {/strip}
120
121 <script type="text/javascript">
122 {* this function is called to change the color of selected row(s) *}
123 var fname = "{$form.formName}";
124 on_load_init_checkboxes(fname);
125 </script>
126
127 {include file="CRM/common/pager.tpl" location="bottom"}
128
129 </p>
130 {* END Actions/Results section *}
131 </div>
132 </div>
133{/if}
134
135
136
137</div>
138{/if}
139{literal}
140<script type="text/javascript">
141cj(function() {
142 cj().crmAccordions();
143});
144
145function toggleContactSelection( name, qfKey, selection ){
146 var Url = "{/literal}{crmURL p='civicrm/ajax/markSelection' h=0}{literal}";
147
148 if ( selection == 'multiple' ) {
149 var rowArr = new Array( );
150 {/literal}{foreach from=$rows item=row key=keyVal}
151 {literal}rowArr[{/literal}{$keyVal}{literal}] = '{/literal}{$row.checkbox}{literal}';
152 {/literal}{/foreach}{literal}
153 var elements = rowArr.join('-');
154
155 if ( cj('#' + name).is(':checked') ){
156 cj.post( Url, { name: elements , qfKey: qfKey , variableType: 'multiple' } );
157 }
158 else {
159 cj.post( Url, { name: elements , qfKey: qfKey , variableType: 'multiple' , action: 'unselect' } );
160 }
161 }
162 else if ( selection == 'single' ) {
163 if ( cj('#' + name).is(':checked') ){
164 cj.post( Url, { name: name , qfKey: qfKey } );
165 }
166 else {
167 cj.post( Url, { name: name , qfKey: qfKey , state: 'unchecked' } );
168 }
169 }
170 else if ( name == 'resetSel' && selection == 'reset' ) {
171 cj.post( Url, { qfKey: qfKey , variableType: 'multiple' , action: 'unselect' } );
172 {/literal}
173 {foreach from=$rows item=row}{literal}
174 cj("#{/literal}{$row.checkbox}{literal}").removeAttr('checked');{/literal}
175 {/foreach}
176 {literal}
177 cj("#toggleSelect").removeAttr('checked');
178 var formName = "{/literal}{$form.formName}{literal}";
179 on_load_init_checkboxes(formName);
180 }
181}
182</script>
183
184{/literal}