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