-
Notifications
You must be signed in to change notification settings - Fork 0
/
defaultFilters.php
309 lines (279 loc) · 11.5 KB
/
defaultFilters.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
<?php if(!isset($Translation)) { @header('Location: index.php'); exit; } ?>
<div class="page-header"><h1>
<span id="table-title-img"><img align="top" src="<?php echo $this->TableIcon; ?>" /></span> <?php echo $this->TableTitle . " " . $Translation['filters']; ?>
</h1></div>
<?php
/* SPM link for admin */
if(getLoggedAdmin()) {
$spm_installed = false;
$plugins = get_plugins();
foreach($plugins as $pl) {
if($pl['title'] == 'Search Page Maker') $spm_installed = true;
}
if(!$spm_installed) echo Notification::show(array(
'message' => '<i class="glyphicon glyphicon-info-sign"></i> Wish to offer your users an easier, more-tailored search experience? <a href="https://bigprof.com/appgini/applications/search-page-maker-plugin-discount" target="_blank" class="alert-link"><i class="glyphicon glyphicon-hand-right"></i> Click here to learn how Search Page Maker plugin can help</a>.',
'dismiss_days' => 30,
'class' => 'success',
'id' => 'spm_notification'
));
}
?>
<!-- checkboxes for parent filterers -->
<?php
foreach($this->filterers as $filterer => $caption) {
$fltrr_name = 'filterer_' . $filterer;
$fltrr_val = $_REQUEST[$fltrr_name];
if($fltrr_val != '') {
?>
<div class="row">
<div class="col-md-offset-3 col-md-7">
<div class="checkbox">
<label>
<input type="checkbox" id="<?php echo $fltrr_name; ?>" name="<?php echo $fltrr_name; ?>" value="<?php echo html_attr($fltrr_val); ?>" checked>
<strong><?php printf($Translation['Only show records having filterer'], $caption, "<span class=\"text-info\" id=\"{$fltrr_name}_display_value\"></span>"); ?></strong>
</label>
<script>
jQuery(function() {
jQuery.ajax({
url: 'ajax_combo.php',
dataType: 'json',
data: <?php echo json_encode(array('id' => to_utf8($fltrr_val), 't' => $this->TableName, 'f' => $filterer, 'o' => 0)); ?>
}).done(function(resp) {
jQuery('#<?php echo $fltrr_name; ?>_display_value').html(resp.results[0].text);
});
});
</script>
</div>
</div>
</div>
<?php
break; // currently, only one filterer can be applied at a time
}
}
?>
<!-- filters header -->
<div class="row hidden-sm hidden-xs" style="border-bottom: solid 2px #DDD;">
<div class="col-md-2 col-md-offset-4 vspacer-lg"><strong><?php echo $Translation['filtered field']; ?></strong></div>
<div class="col-md-2 vspacer-lg"><strong><?php echo $Translation['comparison operator']; ?></strong></div>
<div class="col-md-2 vspacer-lg"><strong><?php echo $Translation['comparison value']; ?></strong></div>
</div>
<!-- filter groups -->
<?php
for($i = 1; $i <= (3 * $FiltersPerGroup); $i++) { // Number of filters allowed
$fields = '';
$operators = '';
if(($i % $FiltersPerGroup == 1) && $i != 1) {
$seland = new Combo;
$seland->ListItem = array($Translation["or"], $Translation["and"]);
$seland->ListData = array("or", "and");
$seland->SelectName = "FilterAnd[$i]";
$seland->SelectedData = $FilterAnd[$i];
$seland->Render();
?>
<!-- how to combine next group with previous one: and/or? -->
<div class="row FilterSet<?php echo ($i - 1); ?>" style="border-bottom: dotted 1px #DDD;">
<div class="col-md-5 vspacer-md"></div>
<div class="col-md-2 vspacer-md">
<?php echo $seland->HTML; ?>
</div>
</div>
<?php } ?>
<!-- filter rule -->
<div class="row FilterSet<?php echo $i; ?>" style="border-bottom: dotted 1px #DDD;">
<div class="col-md-2 vspacer-md"></div>
<div class="col-md-1 text-right hidden-sm hidden-xs vspacer-md"><strong><?php echo $Translation["filter"] . sprintf(" %02d", $i); ?></strong></div>
<div class="col-md-1 hidden-md hidden-lg vspacer-md"><strong><?php echo $Translation["filter"] . sprintf(" %02d", $i); ?></strong></div>
<div class="col-md-1 vspacer-md">
<?php
// And, Or select
if($i % $FiltersPerGroup != 1) {
$seland = new Combo;
$seland->ListItem = array($Translation["and"], $Translation["or"]);
$seland->ListData = array("and", "or");
$seland->SelectName = "FilterAnd[$i]";
$seland->SelectedData = $FilterAnd[$i];
$seland->Render();
echo $seland->HTML;
}
?>
</div>
<div class="col-md-2 vspacer-md">
<?php
// Fields list
$selfields = new Combo;
$selfields->SelectName = "FilterField[$i]";
$selfields->SelectedData = $FilterField[$i];
$selfields->ListItem = array_values($this->QueryFieldsFilters);
$selfields->ListData = array_keys($this->QueryFieldsIndexed);
$selfields->Render();
echo $selfields->HTML;
?>
</div>
<div class="col-md-2 vspacer-md">
<?php
// Operators list
$selop = new Combo;
$selop->ListItem = array($Translation["equal to"], $Translation["not equal to"], $Translation["greater than"], $Translation["greater than or equal to"], $Translation["less than"], $Translation["less than or equal to"] , $Translation["like"] , $Translation["not like"], $Translation["is empty"], $Translation["is not empty"]);
$selop->ListData = array_keys($GLOBALS['filter_operators']);
$selop->SelectName = "FilterOperator[$i]";
$selop->SelectedData = $FilterOperator[$i];
$selop->Render();
echo $selop->HTML;
?>
</div>
<div class="col-md-2 vspacer-md">
<?php /* Comparison expression */ ?>
<input name="FilterValue[<?php echo $i; ?>]" value="<?php echo html_attr($FilterValue[$i]); ?>" class="form-control">
</div>
<div class="col-md-2 vspacer-md">
<button type="button" class="btn btn-default clear_filter" id="filter_<?php echo $i; ?>"><i class="glyphicon glyphicon-trash text-danger"></i></button>
</div>
</div>
<?php
}
?>
<script>
$j(function() {
$j('.clear_filter').click(function() {
var filt_num = $j(this).attr('id').replace(/^filter_/, '');
$j('#FilterAnd_' + filt_num + '_').select2('val', '');
$j('#FilterField_' + filt_num + '_').select2('val', '');
$j('#FilterOperator_' + filt_num + '_').select2('val', '');
$j('[name="FilterValue[' + filt_num + ']"]').val('');
});
// focus 1st select
$j('#FilterField_1_').select2('focus');
})
</script>
<!-- sorting header -->
<div class="row" style="border-bottom: solid 2px #DDD;">
<div class="col-md-offset-2 col-md-8 vspacer-lg"><strong><?php echo $Translation['order by']; ?></strong></div>
</div>
<!-- sorting rules -->
<?php
// Fields list
$sortFields = new Combo;
$sortFields->ListItem = $this->ColCaption;
$sortFields->ListData = $this->ColNumber;
// sort direction
$sortDirs = new Combo;
$sortDirs->ListItem = array($Translation['ascending'], $Translation['descending']);
$sortDirs->ListData = array('asc', 'desc');
$num_rules = min(maxSortBy, count($this->ColCaption));
for($i = 0; $i < $num_rules; $i++) {
$sfi = $sd = '';
if(isset($orderBy[$i])) foreach($orderBy[$i] as $sfi => $sd);
$sortFields->SelectName = "OrderByField$i";
$sortFields->SelectID = "OrderByField$i";
$sortFields->SelectedData = $sfi;
$sortFields->SelectedText = '';
$sortFields->Render();
$sortDirs->SelectName = "OrderDir$i";
$sortDirs->SelectID = "OrderDir$i";
$sortDirs->SelectedData = $sd;
$sortDirs->SelectedText = '';
$sortDirs->Render();
$border_style = ($i == $num_rules - 1 ? 'solid 2px #DDD' : 'dotted 1px #DDD');
?>
<!-- sorting rule -->
<div class="row" style="border-bottom: <?php echo $border_style; ?>;">
<div class="col-xs-2 vspacer-md hidden-md hidden-lg"><strong><?php echo ($i ? $Translation['then by'] : $Translation['order by']); ?></strong></div>
<div class="col-md-2 col-md-offset-2 vspacer-md hidden-xs hidden-sm text-right"><strong><?php echo ($i ? $Translation['then by'] : $Translation['order by']); ?></strong></div>
<div class="col-xs-6 col-md-4 vspacer-md"><?php echo $sortFields->HTML; ?></div>
<div class="col-xs-4 col-md-2 vspacer-md"><?php echo $sortDirs->HTML; ?></div>
</div>
<?php
}
// ownership options
$mi = getMemberInfo();
$adminConfig = config('adminConfig');
$isAnonymous = ($mi['group'] == $adminConfig['anonymousGroup']);
if(!$isAnonymous) {
?>
<!-- ownership header -->
<div class="row filterByOwnership" style="border-bottom: solid 2px #DDD;">
<div class="col-md-offset-2 col-md-8 vspacer-lg"><strong><?php echo $Translation['Records to display']; ?></strong></div>
</div>
<!-- ownership options -->
<div class="row" style="border-bottom: dotted 2px #DDD;">
<div class="col-md-8 col-md-offset-2">
<div class="radio filterByOwnership">
<label>
<input type="radio" name="DisplayRecords" id="DisplayRecordsUser" value="user"/>
<?php echo $Translation['Only your own records']; ?>
</label>
</div>
<div class="radio filterByOwnership">
<label>
<input type="radio" name="DisplayRecords" id="DisplayRecordsGroup" value="group"/>
<?php echo $Translation['All records owned by your group']; ?>
</label>
</div>
<div class="radio filterByOwnership">
<label>
<input type="radio" name="DisplayRecords" id="DisplayRecordsAll" value="all"/>
<?php echo $Translation['All records']; ?>
</label>
</div>
</div>
</div>
<?php
}
?>
<!-- filter actions -->
<div class="row">
<div class="col-md-2 col-md-offset-2 vspacer-lg">
<input type="hidden" name="apply_sorting" value="1">
<button type="submit" id="applyFilters" class="btn btn-success btn-block btn-lg"><i class="glyphicon glyphicon-ok"></i> <?php echo $Translation['apply filters']; ?></button>
</div>
<?php if($this->AllowSavingFilters) { ?>
<div class="col-md-3 vspacer-lg">
<button type="submit" class="btn btn-default btn-block btn-lg" id="SaveFilter" name="SaveFilter_x" value="1"><i class="glyphicon glyphicon-align-left"></i> <?php echo $Translation['save filters']; ?></button>
</div>
<?php } ?>
<div class="col-md-2 vspacer-lg">
<button onclick="jQuery('form')[0].reset();" type="submit" id="cancelFilters" class="btn btn-warning btn-block btn-lg"><i class="glyphicon glyphicon-remove"></i> <?php echo $Translation['Cancel']; ?></button>
</div>
</div>
<script>
var FiltersPerGroup = <?php echo $FiltersPerGroup; ?>;
function filterGroupDisplay(groupIndex, hide, animate) {
for(i = ((groupIndex - 1) * FiltersPerGroup + 1); i <= (groupIndex * FiltersPerGroup); i++) {
if(animate) {
if(hide) jQuery('div.FilterSet' + i).fadeOut();
if(!hide) jQuery('div.FilterSet' + i).fadeIn(function() {
jQuery('#FilterField_' + ((groupIndex - 1) * FiltersPerGroup + 1) + '_').focus();
});
}else{
if(hide) jQuery('div.FilterSet' + i).hide();
if(!hide) jQuery('div.FilterSet' + i).show(function() {
jQuery('#FilterField_' + ((groupIndex - 1) * FiltersPerGroup + 1) + '_').focus();
});
}
}
}
jQuery(function() {
for(i = (FiltersPerGroup + 1); i <= (3 * FiltersPerGroup); i++) {
jQuery('div.FilterSet' + i).hide();
}
jQuery('#FilterAnd_' + (FiltersPerGroup + 1) + '_').change(function() {
filterGroupDisplay(2, (jQuery(this).val() ? false : true), true);
});
jQuery('#FilterAnd_' + (2 * FiltersPerGroup + 1) + '_').change(function() {
filterGroupDisplay(3, (jQuery(this).val() ? false : true), true);
});
if(jQuery('#FilterAnd_' + ( FiltersPerGroup + 1) + '_').val()) { filterGroupDisplay(2); }
if(jQuery('#FilterAnd_' + (2 * FiltersPerGroup + 1) + '_').val()) { filterGroupDisplay(3); }
var DisplayRecords = <?php echo json_encode($_REQUEST['DisplayRecords']); ?>;
switch(DisplayRecords) {
case 'user':
jQuery('#DisplayRecordsUser').prop('checked', true);
break;
case 'group':
jQuery('#DisplayRecordsGroup').prop('checked', true);
break;
default:
jQuery('#DisplayRecordsAll').prop('checked', true);
}
});
</script>