mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 08:14:38 +02:00
event filters tags, date, module name
This commit is contained in:
parent
dc81d168e0
commit
d8a331bf77
@ -482,14 +482,55 @@ function events_get_all(
|
|||||||
throw new Exception('[events_get_all] Fields must be an array or "count".');
|
throw new Exception('[events_get_all] Fields must be an array or "count".');
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql_filters = [];
|
if (isset($filter['date_from']) && $filter['date_from'] != '0000-00-00') {
|
||||||
if (isset($filter['event_view_hr']) && ($filter['event_view_hr'] > 0)) {
|
$date_from = $filter['date_from'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($filter['time_from'])) {
|
||||||
|
$time_from = $filter['time_from'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($date_from)) {
|
||||||
|
if (!isset($time_from)) {
|
||||||
|
$time_from = '00:00:00';
|
||||||
|
}
|
||||||
|
|
||||||
|
$from = $date_from.' '.$time_from;
|
||||||
$sql_filters[] = sprintf(
|
$sql_filters[] = sprintf(
|
||||||
' AND utimestamp > UNIX_TIMESTAMP(now() - INTERVAL %d HOUR) ',
|
' AND te.utimestamp >= %d',
|
||||||
$filter['event_view_hr']
|
strtotime($from)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($filter['date_to']) && $filter['date_to'] != '0000-00-00') {
|
||||||
|
$date_to = $filter['date_to'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($filter['time_to'])) {
|
||||||
|
$time_to = $filter['time_to'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($date_to)) {
|
||||||
|
if (!isset($time_to)) {
|
||||||
|
$time_to = '23:59:59';
|
||||||
|
}
|
||||||
|
|
||||||
|
$to = $date_to.' '.$time_to;
|
||||||
|
$sql_filters[] = sprintf(
|
||||||
|
' AND te.utimestamp <= %d',
|
||||||
|
strtotime($to)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($from)) {
|
||||||
|
if (isset($filter['event_view_hr']) && ($filter['event_view_hr'] > 0)) {
|
||||||
|
$sql_filters[] = sprintf(
|
||||||
|
' AND utimestamp > UNIX_TIMESTAMP(now() - INTERVAL %d HOUR) ',
|
||||||
|
$filter['event_view_hr']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($filter['id_agent']) && $filter['id_agent'] > 0) {
|
if (isset($filter['id_agent']) && $filter['id_agent'] > 0) {
|
||||||
$sql_filters[] = sprintf(
|
$sql_filters[] = sprintf(
|
||||||
' AND te.id_agente = %d ',
|
' AND te.id_agente = %d ',
|
||||||
@ -728,43 +769,36 @@ function events_get_all(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$_tmp = ' AND (';
|
|
||||||
foreach ($tags as $id_tag) {
|
foreach ($tags as $id_tag) {
|
||||||
if (!isset($tags_names[$id_tag])) {
|
if (!isset($tags_names[$id_tag])) {
|
||||||
$tags_names[$id_tag] = tags_get_name($id_tag);
|
$tags_names[$id_tag] = tags_get_name($id_tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($first) {
|
$_tmp .= ' AND ( ';
|
||||||
$_tmp .= ' ( ';
|
|
||||||
$first = false;
|
|
||||||
} else {
|
|
||||||
$_tmp .= ' AND ( ';
|
|
||||||
}
|
|
||||||
|
|
||||||
$_tmp .= sprintf(
|
$_tmp .= sprintf(
|
||||||
'tags LIKE "%s"',
|
' tags LIKE "%s" OR',
|
||||||
$tag_names[$id_tag]
|
$tags_names[$id_tag]
|
||||||
);
|
);
|
||||||
|
|
||||||
$_tmp .= sprintf(
|
$_tmp .= sprintf(
|
||||||
'tags LIKE "%s,%%"',
|
' tags LIKE "%s,%%" OR',
|
||||||
$tag_names[$id_tag]
|
$tags_names[$id_tag]
|
||||||
);
|
);
|
||||||
|
|
||||||
$_tmp .= sprintf(
|
$_tmp .= sprintf(
|
||||||
'tags LIKE "%%,%s"',
|
' tags LIKE "%%,%s" OR',
|
||||||
$tag_names[$id_tag]
|
$tags_names[$id_tag]
|
||||||
);
|
);
|
||||||
|
|
||||||
$_tmp .= sprintf(
|
$_tmp .= sprintf(
|
||||||
'tags LIKE "%%,%s,%%"',
|
' tags LIKE "%%,%s,%%" ',
|
||||||
$tag_names[$id_tag]
|
$tags_names[$id_tag]
|
||||||
);
|
);
|
||||||
|
|
||||||
$_tmp .= ') ';
|
$_tmp .= ') ';
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql_filters[] = $_tmp.') ';
|
$sql_filters[] = $_tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -773,7 +807,6 @@ function events_get_all(
|
|||||||
$tag_without = base64_decode($filter['tag_without']);
|
$tag_without = base64_decode($filter['tag_without']);
|
||||||
$tags = json_decode($tag_without, true);
|
$tags = json_decode($tag_without, true);
|
||||||
if (is_array($tags) && !in_array('0', $tags)) {
|
if (is_array($tags) && !in_array('0', $tags)) {
|
||||||
$_tmp = ' AND (';
|
|
||||||
foreach ($tags as $id_tag) {
|
foreach ($tags as $id_tag) {
|
||||||
if (!isset($tags_names[$id_tag])) {
|
if (!isset($tags_names[$id_tag])) {
|
||||||
$tags_names[$id_tag] = tags_get_name($id_tag);
|
$tags_names[$id_tag] = tags_get_name($id_tag);
|
||||||
@ -781,23 +814,23 @@ function events_get_all(
|
|||||||
|
|
||||||
$_tmp .= sprintf(
|
$_tmp .= sprintf(
|
||||||
' AND tags NOT LIKE "%s" ',
|
' AND tags NOT LIKE "%s" ',
|
||||||
$tag_names[$id_tag]
|
$tags_names[$id_tag]
|
||||||
);
|
);
|
||||||
$_tmp .= sprintf(
|
$_tmp .= sprintf(
|
||||||
' AND tags NOT LIKE "%s,%%" ',
|
' AND tags NOT LIKE "%s,%%" ',
|
||||||
$tag_names[$id_tag]
|
$tags_names[$id_tag]
|
||||||
);
|
);
|
||||||
$_tmp .= sprintf(
|
$_tmp .= sprintf(
|
||||||
' AND tags NOT LIKE "%%,%s" ',
|
' AND tags NOT LIKE "%%,%s" ',
|
||||||
$tag_names[$id_tag]
|
$tags_names[$id_tag]
|
||||||
);
|
);
|
||||||
$_tmp .= sprintf(
|
$_tmp .= sprintf(
|
||||||
' AND tags NOT LIKE "%%,%s,%%" ',
|
' AND tags NOT LIKE "%%,%s,%%" ',
|
||||||
$tag_names[$id_tag]
|
$tags_names[$id_tag]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql_filters[] = $_tmp.') ';
|
$sql_filters[] = $_tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -891,6 +924,17 @@ function events_get_all(
|
|||||||
$sql_filters[] = $tags_acls_condition;
|
$sql_filters[] = $tags_acls_condition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Module search.
|
||||||
|
$agentmodule_join = '';
|
||||||
|
if (!empty($filter['module_search'])) {
|
||||||
|
$agentmodule_join = 'INNER JOIN tagente_modulo am
|
||||||
|
ON te.id_agentmodule = am.id_agente_modulo';
|
||||||
|
$sql_filters[] = sprintf(
|
||||||
|
' AND am.nombre = "%s" ',
|
||||||
|
$filter['module_search']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Order.
|
// Order.
|
||||||
$order_by = '';
|
$order_by = '';
|
||||||
if (isset($order, $sort_field)) {
|
if (isset($order, $sort_field)) {
|
||||||
@ -899,7 +943,7 @@ function events_get_all(
|
|||||||
|
|
||||||
// Pagination.
|
// Pagination.
|
||||||
$pagination = '';
|
$pagination = '';
|
||||||
if (isset($limit, $offset)) {
|
if (isset($limit, $offset) && $limit > 0) {
|
||||||
$pagination = sprintf(' LIMIT %d OFFSET %d', $limit, $offset);
|
$pagination = sprintf(' LIMIT %d OFFSET %d', $limit, $offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -977,6 +1021,7 @@ function events_get_all(
|
|||||||
%s
|
%s
|
||||||
FROM %s
|
FROM %s
|
||||||
%s
|
%s
|
||||||
|
%s
|
||||||
%s JOIN %s ta
|
%s JOIN %s ta
|
||||||
ON ta.%s = te.id_agente
|
ON ta.%s = te.id_agente
|
||||||
%s
|
%s
|
||||||
@ -994,6 +1039,7 @@ function events_get_all(
|
|||||||
$group_selects,
|
$group_selects,
|
||||||
$tevento,
|
$tevento,
|
||||||
$event_lj,
|
$event_lj,
|
||||||
|
$agentmodule_join,
|
||||||
$tagente_join,
|
$tagente_join,
|
||||||
$tagente_table,
|
$tagente_table,
|
||||||
$tagente_field,
|
$tagente_field,
|
||||||
|
@ -3127,10 +3127,16 @@ function ui_print_datatable(array $parameters)
|
|||||||
$table .= '</tr></thead>';
|
$table .= '</tr></thead>';
|
||||||
$table .= '</table>';
|
$table .= '</table>';
|
||||||
|
|
||||||
|
$pagination_class = 'pandora_pagination';
|
||||||
|
if (!empty($parameters['pagination_class'])) {
|
||||||
|
$pagination_class = $parameters['pagination_class'];
|
||||||
|
}
|
||||||
|
|
||||||
// Javascript controller.
|
// Javascript controller.
|
||||||
$js = '<script type="text/javascript">
|
$js = '<script type="text/javascript">
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$.fn.dataTable.ext.errMode = "none";
|
$.fn.dataTable.ext.errMode = "none";
|
||||||
|
$.fn.dataTable.ext.classes.sPageButton = "'.$pagination_class.'";
|
||||||
dt_'.$table_id.' = $("#'.$table_id.'").DataTable({
|
dt_'.$table_id.' = $("#'.$table_id.'").DataTable({
|
||||||
';
|
';
|
||||||
if (isset($parameters['drawCallback'])) {
|
if (isset($parameters['drawCallback'])) {
|
||||||
@ -3146,7 +3152,7 @@ function ui_print_datatable(array $parameters)
|
|||||||
pageLength: '.$parameters['default_pagination'].',
|
pageLength: '.$parameters['default_pagination'].',
|
||||||
searching: false,
|
searching: false,
|
||||||
responsive: true,
|
responsive: true,
|
||||||
dom: "lBfrtip",
|
dom: "plfrtipB",
|
||||||
buttons: [
|
buttons: [
|
||||||
{
|
{
|
||||||
extend: "csv",
|
extend: "csv",
|
||||||
|
@ -310,42 +310,6 @@ tr.group * {
|
|||||||
background: #e2e2e2;
|
background: #e2e2e2;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dt-button.buttons-csv.buttons-html5 {
|
|
||||||
float: right;
|
|
||||||
font-weight: normal;
|
|
||||||
-moz-border-radius: 2px;
|
|
||||||
-webkit-border-radius: 2px;
|
|
||||||
border-radius: 2px;
|
|
||||||
font-size: 1.2em;
|
|
||||||
background-color: #fff;
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
background-position: 92% 10px;
|
|
||||||
color: #000;
|
|
||||||
padding-bottom: 10px;
|
|
||||||
padding-top: 10px;
|
|
||||||
padding-left: 15px;
|
|
||||||
border: 1px solid #888;
|
|
||||||
font-family: "lato", "Open Sans", sans-serif;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dt-button.buttons-csv.buttons-html5:hover {
|
|
||||||
border: 1px solid #333;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dt-button.buttons-csv.buttons-html5:active {
|
|
||||||
border: 1px solid #000;
|
|
||||||
color: #333;
|
|
||||||
background-color: #e1e1e1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dt-button.buttons-csv.buttons-html5[disabled] {
|
|
||||||
color: #b4b4b4;
|
|
||||||
background-color: #f3f3f3;
|
|
||||||
border-color: #b6b6b6;
|
|
||||||
cursor: default;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.multi-response-buttons {
|
div.multi-response-buttons {
|
||||||
margin-top: 2em;
|
margin-top: 2em;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
@ -253,11 +253,65 @@ table.dataTable.info_table.no-footer {
|
|||||||
|
|
||||||
/* Datatables pagination */
|
/* Datatables pagination */
|
||||||
.dataTables_paginate.paging_simple_numbers {
|
.dataTables_paginate.paging_simple_numbers {
|
||||||
|
margin: 2em 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
|
a.pandora_pagination {
|
||||||
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
|
padding: 5px;
|
||||||
|
color: #000;
|
||||||
|
border: 1px solid #cacaca;
|
||||||
|
min-width: 12px;
|
||||||
|
margin-right: -1px;
|
||||||
|
text-decoration: none;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
a.pandora_pagination.disabled {
|
||||||
|
color: #cacaca;
|
||||||
|
}
|
||||||
|
a.pandora_pagination:hover {
|
||||||
|
text-decoration: none;
|
||||||
|
background-color: #e2e2e2;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.pandora_pagination.current,
|
||||||
|
a.pandora_pagination.current:hover {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
background-color: #82b92e;
|
background-color: #82b92e;
|
||||||
border-color: #82b92e;
|
}
|
||||||
|
|
||||||
|
/* CSV button datatables */
|
||||||
|
.dt-button.buttons-csv.buttons-html5 {
|
||||||
|
background-image: url(../../images/input_delete.png);
|
||||||
|
background-position: center center;
|
||||||
|
-moz-border-radius: 2px;
|
||||||
|
-webkit-border-radius: 2px;
|
||||||
|
border-radius: 2px;
|
||||||
|
background-color: #fff;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
color: #000;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
padding-top: 10px;
|
||||||
|
padding-left: 15px;
|
||||||
|
border: 1px solid #888;
|
||||||
|
font-family: "lato", "Open Sans", sans-serif;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.dt-button.buttons-csv.buttons-html5 span {
|
||||||
|
font-size: 0;
|
||||||
|
}
|
||||||
|
.dt-button.buttons-csv.buttons-html5:hover {
|
||||||
|
border: 1px solid #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dt-button.buttons-csv.buttons-html5:active {
|
||||||
|
border: 1px solid #000;
|
||||||
|
color: #333;
|
||||||
|
background-color: #e1e1e1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dt-button.buttons-csv.buttons-html5[disabled] {
|
||||||
|
color: #b4b4b4;
|
||||||
|
background-color: #f3f3f3;
|
||||||
|
border-color: #b6b6b6;
|
||||||
|
cursor: default;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user