/
filter.php
executable file
·99 lines (79 loc) · 2.39 KB
/
filter.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
<?php
/**
* set which custom field to display
************************/
/*
provided values are:
table = name of the table
*/
/* functions */
require_once( dirname(__FILE__) . '/../../../functions/functions.php' );
# initialize user object
$Database = new Database_PDO;
$User = new User ($Database);
$Tools = new Tools ($Database);
$Result = new Result ();
# verify that user is logged in
$User->check_user_session();
# strip tags - XSS
$_POST = $User->strip_input_tags ($_POST);
# get hidden custom fields from settings
$filters = json_decode($User->settings->hiddenCustomFields, true);
isset($filters[$_POST['table']]) ? : $filters[$_POST['table']] = array();
# fetch custom fields
$custom = $Tools->fetch_custom_fields($_POST['table']);
?>
<script>
$(document).ready(function() {
/* bootstrap switch */
var switch_options = {
onText: "Hidden",
offText: "Visible",
onColor: 'default',
offColor: 'default',
size: "mini",
inverse: true
};
$(".input-switch").bootstrapSwitch(switch_options);
});
</script>
<!-- header -->
<div class="pHeader"><?php print _('Filter custom field display'); ?></div>
<!-- content -->
<div class="pContent">
<form id="editCustomFieldsFilter">
<table id="editCustomFields" class="table table-noborder table-condensed">
<input type="hidden" name="table" value="<?php print $_POST['table']; ?>">
<?php
foreach($custom as $k=>$c) {
$kNew = str_replace(" ", "___", $k);
print "<tr>";
# select
print " <td style='width:20px;'>";
if(in_array($k, $filters[$_POST['table']])) { print "<input type='checkbox' class='input-switch' name='$kNew' checked>"; }
else { print "<input type='checkbox' class='input-switch' name='$kNew'>"; }
print " </td>";
# remove custom_
$k1 = $Tools->print_custom_field_name ($k);
# name and comment
print " <td>".$k1." (".$c['Comment'].")</td>";
print "</tr>";
}
?>
</table>
</form>
<hr>
<div class="text-muted">
<?php print _("Selected fields will not be visible in table view, only in detail view"); ?>
</div>
<hr>
</div>
<!-- footer -->
<div class="pFooter">
<div class="btn-group">
<button class="btn btn-sm btn-default hidePopups"><?php print _('Close'); ?></button>
<button class="btn btn-sm btn-default " id="editcustomFilterSubmit"><i class="fa fa-check"></i> <?php print ucwords(_("Save filter")); ?></button>
</div>
<!-- result -->
<div class="customEditFilterResult"></div>
</div>