cfbd681aa872341f3596243063bd3fc7d266ec76
[civicrm-core.git] / templates / CRM / Report / Form / Criteria.tpl
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 {* Report form criteria section *}
27 {if $colGroups}
28 <div id="col-groups" class="civireport-criteria" >
29 {if $componentName eq 'Grant'}
30 <h3>{ts}Include these Statistics{/ts}</h3>
31 {else}
32 <h3>Display Columns</h3>
33 {/if}
34 {foreach from=$colGroups item=grpFields key=dnc}
35 {assign var="count" value="0"}
36 {* Wrap custom field sets in collapsed accordion pane. *}
37 {if $grpFields.group_title}
38 <div class="crm-accordion-wrapper crm-accordion collapsed">
39 <div class="crm-accordion-header">
40 {$grpFields.group_title}
41 </div><!-- /.crm-accordion-header -->
42 <div class="crm-accordion-body">
43 {/if}
44 <table class="criteria-group">
45 <tr class="crm-report crm-report-criteria-field crm-report-criteria-field-{$dnc}">
46 {foreach from=$grpFields.fields item=title key=field}
47 {assign var="count" value=`$count+1`}
48 <td width="25%">{$form.fields.$field.html}</td>
49 {if $count is div by 4}
50 </tr><tr class="crm-report crm-report-criteria-field crm-report-criteria-field_{$dnc}">
51 {/if}
52 {/foreach}
53 {if $count is not div by 4}
54 <td colspan="4 - ($count % 4)"></td>
55 {/if}
56 </tr>
57 </table>
58 {if $grpFields.group_title}
59 </div><!-- /.crm-accordion-body -->
60 </div><!-- /.crm-accordion-wrapper -->
61 {/if}
62 {/foreach}
63 </div>
64 {/if}
65
66 {if $groupByElements}
67 <div id="group-by-elements" class="civireport-criteria" >
68 <h3>Group by Columns</h3>
69 {assign var="count" value="0"}
70 <table class="report-layout">
71 <tr class="crm-report crm-report-criteria-groupby">
72 {foreach from=$groupByElements item=gbElem key=dnc}
73 {assign var="count" value=`$count+1`}
74 <td width="25%" {if $form.fields.$gbElem}"{/if}>
75 {$form.group_bys[$gbElem].html}
76 {if $form.group_bys_freq[$gbElem].html}:<br>
77 &nbsp;&nbsp;{$form.group_bys_freq[$gbElem].label}&nbsp;{$form.group_bys_freq[$gbElem].html}
78 {/if}
79 </td>
80 {if $count is div by 4}
81 </tr><tr class="crm-report crm-report-criteria-groupby">
82 {/if}
83 {/foreach}
84 {if $count is not div by 4}
85 <td colspan="4 - ($count % 4)"></td>
86 {/if}
87 </tr>
88 </table>
89 </div>
90 {/if}
91
92 {if $orderByOptions}
93 <div id="order-by-elements" class="civireport-criteria" >
94 <h3>Order by Columns</h3>
95
96 <table id="optionField">
97 <tr>
98 <th>&nbsp;</th>
99 <th> Column</th>
100 <th> Order</th>
101 <th> Section Header / Group By</th>
102 <th> Page Break</th>
103 </tr>
104
105 {section name=rowLoop start=1 loop=6}
106 {assign var=index value=$smarty.section.rowLoop.index}
107 <tr id="optionField_{$index}" class="form-item {cycle values="odd-row,even-row"}">
108 <td>
109 {if $index GT 1}
110 <a onclick="hideRow({$index}); return false;" name="orderBy_{$index}" href="#" class="form-link"><img src="{$config->resourceBase}i/TreeMinus.gif" class="action-icon" alt="{ts}hide field or section{/ts}"/></a>
111 {/if}
112 </td>
113 <td> {$form.order_bys.$index.column.html}</td>
114 <td> {$form.order_bys.$index.order.html}</td>
115 <td> {$form.order_bys.$index.section.html}</td>
116 <td> {$form.order_bys.$index.pageBreak.html}</td>
117 </tr>
118 {/section}
119 </table>
120 <div id="optionFieldLink" class="add-remove-link">
121 <a onclick="showHideRow(); return false;" name="optionFieldLink" href="#" class="form-link"><img src="{$config->resourceBase}i/TreePlus.gif" class="action-icon" alt="{ts}show field or section{/ts}"/>{ts}another column{/ts}</a>
122 </div>
123 <script type="text/javascript">
124 var showRows = new Array({$showBlocks});
125 var hideBlocks = new Array({$hideBlocks});
126 var rowcounter = 0;
127 {literal}
128 if (navigator.appName == "Microsoft Internet Explorer") {
129 for ( var count = 0; count < hideBlocks.length; count++ ) {
130 var r = document.getElementById(hideBlocks[count]);
131 r.style.display = 'none';
132 }
133 }
134
135 // hide and display the appropriate blocks as directed by the php code
136 on_load_init_blocks( showRows, hideBlocks, '' );
137
138 cj('input[id^="order_by_section_"]').click(disPageBreak).each(disPageBreak);
139
140 function disPageBreak() {
141 if (!cj(this).prop('checked')) {
142 cj(this).parent('td').next('td').children('input[id^="order_by_pagebreak_"]').attr({checked: false, disabled: "disabled"});
143 }
144 else {
145 cj(this).parent('td').next('td').children('input[id^="order_by_pagebreak_"]').attr({disabled: false});
146 }
147 }
148
149 function hideRow(i) {
150 showHideRow(i);
151 // clear values on hidden field, so they're not saved
152 cj('select#order_by_column_'+ i).val('');
153 cj('select#order_by_order_'+ i).val('ASC');
154 cj('input#order_by_section_'+ i).prop('checked', false);
155 cj('input#order_by_pagebreak_'+ i).prop('checked', false);
156 }
157
158 {/literal}
159 </script>
160 </div>
161 {/if}
162
163 {if $otherOptions}
164 <div id="other-options" class="civireport-criteria" >
165 <h3>Other Options</h3>
166 <table class="report-layout">
167 {assign var="optionCount" value=0}
168 <tr class="crm-report crm-report-criteria-field">
169 {foreach from=$otherOptions item=optionField key=optionName}
170 {assign var="optionCount" value=`$optionCount+1`}
171 <td>{if $form.$optionName.label}{$form.$optionName.label}&nbsp;{/if}{$form.$optionName.html}</td>
172 {if $optionCount is div by 2}
173 </tr><tr class="crm-report crm-report-criteria-field">
174 {/if}
175 {/foreach}
176 {if $optionCount is not div by 2}
177 <td colspan="2 - ($count % 2)"></td>
178 {/if}
179 </tr>
180 </table>
181 </div>
182 {/if}
183
184 {if $filters}
185 <div id="set-filters" class="civireport-criteria" >
186 <h3>Set Filters</h3>
187 <table class="report-layout">
188 {assign var="counter" value=1}
189 {foreach from=$filters item=table key=tableName}
190 {assign var="filterCount" value=$table|@count}
191 {* Wrap custom field sets in collapsed accordion pane. *}
192 {if $colGroups.$tableName.group_title and $filterCount gte 1}
193 {* we should close table that contains other filter elements before we start building custom group accordian *}
194 {if $counter eq 1}
195 </table>
196 {assign var="counter" value=0}
197 {/if}
198 <div class="crm-accordion-wrapper crm-accordion collapsed">
199 <div class="crm-accordion-header">
200 {$colGroups.$tableName.group_title}
201 </div><!-- /.crm-accordion-header -->
202 <div class="crm-accordion-body">
203 <table class="report-layout">
204 {/if}
205 {foreach from=$table item=field key=fieldName}
206 {assign var=fieldOp value=$fieldName|cat:"_op"}
207 {assign var=filterVal value=$fieldName|cat:"_value"}
208 {assign var=filterMin value=$fieldName|cat:"_min"}
209 {assign var=filterMax value=$fieldName|cat:"_max"}
210 {if $field.operatorType & 4}
211 <tr class="report-contents crm-report crm-report-criteria-filter crm-report-criteria-filter-{$tableName}">
212 <td class="label report-contents">{$field.title}</td>
213 {include file="CRM/Core/DateRange.tpl" fieldName=$fieldName from='_from' to='_to'}
214 </tr>
215 {elseif $form.$fieldOp.html}
216 <tr class="report-contents crm-report crm-report-criteria-filter crm-report-criteria-filter-{$tableName}" {if $field.no_display} style="display: none;"{/if}>
217 <td class="label report-contents">{$field.title}</td>
218 <td class="report-contents">{$form.$fieldOp.html}</td>
219 <td>
220 <span id="{$filterVal}_cell">{$form.$filterVal.label}&nbsp;{$form.$filterVal.html}</span>
221 <span id="{$filterMin}_max_cell">{$form.$filterMin.label}&nbsp;{$form.$filterMin.html}&nbsp;&nbsp;{$form.$filterMax.label}&nbsp;{$form.$filterMax.html}</span>
222 </td>
223 </tr>
224 {/if}
225 {/foreach}
226 {if $colGroups.$tableName.group_title}
227 </table>
228 </div><!-- /.crm-accordion-body -->
229 </div><!-- /.crm-accordion-wrapper -->
230 {assign var=closed value=1"} {*-- ie table tags are closed-- *}
231 {else}
232 {assign var=closed value=0"} {*-- ie table tags are not closed-- *}
233 {/if}
234
235 {/foreach}
236 {if $closed eq 0 }</table>{/if}
237 </div>
238 {/if}
239
240 {literal}
241 <script type="text/javascript">
242 {/literal}
243 {foreach from=$filters item=table key=tableName}
244 {foreach from=$table item=field key=fieldName}
245 {literal}var val = "dnc";{/literal}
246 {assign var=fieldOp value=$fieldName|cat:"_op"}
247 {if !($field.operatorType & 4) && !$field.no_display && $form.$fieldOp.html}
248 {literal}var val = document.getElementById("{/literal}{$fieldOp}{literal}").value;{/literal}
249 {/if}
250 {literal}showHideMaxMinVal( "{/literal}{$fieldName}{literal}", val );{/literal}
251 {/foreach}
252 {/foreach}
253
254 {literal}
255 function showHideMaxMinVal( field, val ) {
256 var fldVal = field + "_value_cell";
257 var fldMinMax = field + "_min_max_cell";
258 if ( val == "bw" || val == "nbw" ) {
259 cj('#' + fldVal ).hide();
260 cj('#' + fldMinMax ).show();
261 } else if (val =="nll" || val == "nnll") {
262 cj('#' + fldVal).hide() ;
263 cj('#' + field + '_value').val('');
264 cj('#' + fldMinMax ).hide();
265 } else {
266 cj('#' + fldVal ).show();
267 cj('#' + fldMinMax ).hide();
268 }
269 }
270
271 cj(document).ready(function(){
272 cj('.crm-report-criteria-groupby input:checkbox').click(function() {
273 cj('#fields_' + this.id.substr(10)).prop('checked', this.checked);
274 });
275 {/literal}{if $displayToggleGroupByFields}{literal}
276 cj('.crm-report-criteria-field input:checkbox').click(function() {
277 cj('#group_bys_' + this.id.substr(7)).prop('checked', this.checked);
278 });
279 {/literal}{/if}{literal}
280 });
281 </script>
282 {/literal}
283
284 <div>{$form.buttons.html}</div>