mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
wip event view
This commit is contained in:
parent
419a90d69c
commit
d4d4509266
@ -85,6 +85,145 @@ function events_sql_db_filter($filter)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve all events filtered.
|
||||||
|
*
|
||||||
|
* @param array $fields Fields to retrieve.
|
||||||
|
* @param array $filter Filters to be applied.
|
||||||
|
* @param integer $limit Limit (pagination).
|
||||||
|
* @param integer $offset Offset (pagination).
|
||||||
|
*
|
||||||
|
* @return array Events.
|
||||||
|
* @throws Exception On error.
|
||||||
|
*/
|
||||||
|
function events_get_all(
|
||||||
|
$fields,
|
||||||
|
array $filter,
|
||||||
|
$offset=null,
|
||||||
|
$limit=null,
|
||||||
|
$order=null,
|
||||||
|
$sort_field=null
|
||||||
|
) {
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
if (!is_array($filter)) {
|
||||||
|
throw new Exception('[events_get_all] Filter must be an array.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$count = false;
|
||||||
|
if (!is_array($fields) && $fields == 'count') {
|
||||||
|
$fields = ['te.*'];
|
||||||
|
$count = true;
|
||||||
|
} else if (!is_array($fields)) {
|
||||||
|
throw new Exception('[events_get_all] Fields must be an array or "count".');
|
||||||
|
}
|
||||||
|
|
||||||
|
$hour_filter = '';
|
||||||
|
if (isset($filter['event_view_hr'])) {
|
||||||
|
$hour_filter = sprintf(
|
||||||
|
' AND utimestamp > UNIX_TIMESTAMP(now() - INTERVAL %d HOUR) ',
|
||||||
|
$filter['event_view_hr']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$agent_id_filter = '';
|
||||||
|
if (isset($filter['id_agent']) && $filter['id_agent'] > 0) {
|
||||||
|
$agent_id_filter = sprintf(
|
||||||
|
' AND id_agente = %d ',
|
||||||
|
$filter['id_agent']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$table = events_get_events_table($meta, $history);
|
||||||
|
|
||||||
|
$tevento = sprintf(
|
||||||
|
'(SELECT *
|
||||||
|
FROM %s
|
||||||
|
WHERE 1=1 %s %s) te',
|
||||||
|
$table,
|
||||||
|
$hour_filter,
|
||||||
|
$agent_id_filter
|
||||||
|
);
|
||||||
|
|
||||||
|
$agent_name_filter = '';
|
||||||
|
if (!empty($filter['agent_alias'])) {
|
||||||
|
$agent_name_filter = sprintf(
|
||||||
|
' AND ta.alias = "%s" ',
|
||||||
|
$filter['agent_alias']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$order_by = '';
|
||||||
|
if (isset($order, $sort_field)) {
|
||||||
|
$order_by = events_get_sql_order($sort_field, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
$pagination = '';
|
||||||
|
if (isset($limit, $offset)) {
|
||||||
|
$pagination = sprintf(' LIMIT %d OFFSET %d', $limit, $offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
$extra = '';
|
||||||
|
if (is_metaconsole()) {
|
||||||
|
$extra = ', server_id';
|
||||||
|
}
|
||||||
|
|
||||||
|
$group_by = 'GROUP BY ';
|
||||||
|
$tagente_join = 'LEFT';
|
||||||
|
switch ($filter['group_rep']) {
|
||||||
|
case '0':
|
||||||
|
default:
|
||||||
|
// All events.
|
||||||
|
$group_by = '';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '1':
|
||||||
|
// Group by events.
|
||||||
|
$group_by .= 'estado, evento, id_agente, id_agentmodule';
|
||||||
|
$group_by .= $extra;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '2':
|
||||||
|
// Group by agents.
|
||||||
|
$tagente_join = 'INNER';
|
||||||
|
$group_by .= 'te.id_agente, te.event_type';
|
||||||
|
$group_by .= $extra;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Secondary groups.
|
||||||
|
db_process_sql('SET group_concat_max_len = 9999999');
|
||||||
|
$event_lj = events_get_secondary_groups_left_join($table);
|
||||||
|
|
||||||
|
$sql = sprintf(
|
||||||
|
'SELECT %s
|
||||||
|
FROM %s
|
||||||
|
%s JOIN tagente ta
|
||||||
|
ON ta.id_agente = te.id_agente
|
||||||
|
%s
|
||||||
|
%s
|
||||||
|
WHERE 1=1
|
||||||
|
%s
|
||||||
|
%s
|
||||||
|
%s
|
||||||
|
',
|
||||||
|
join(',', $fields),
|
||||||
|
$tevento,
|
||||||
|
$tagente_join,
|
||||||
|
$event_lj,
|
||||||
|
$filter_extra_agents,
|
||||||
|
$group_by,
|
||||||
|
$order_by,
|
||||||
|
$pagination
|
||||||
|
);
|
||||||
|
if ($count) {
|
||||||
|
$sql = 'SELECT count(*) as nitems FROM ('.$sql.') tt';
|
||||||
|
}
|
||||||
|
|
||||||
|
return db_get_all_rows_sql($sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all rows of events from the database, that
|
* Get all rows of events from the database, that
|
||||||
* pass the filter, and can get only some fields.
|
* pass the filter, and can get only some fields.
|
||||||
@ -244,49 +383,30 @@ function events_get_events_grouped(
|
|||||||
db_process_sql('SET group_concat_max_len = 9999999');
|
db_process_sql('SET group_concat_max_len = 9999999');
|
||||||
$event_lj = events_get_secondary_groups_left_join($table);
|
$event_lj = events_get_secondary_groups_left_join($table);
|
||||||
if ($total) {
|
if ($total) {
|
||||||
$sql = sprintf(
|
$sql = "SELECT COUNT(*) FROM (SELECT id_evento
|
||||||
'SELECT COUNT(*) FROM (SELECT id_evento
|
FROM $table te $event_lj
|
||||||
FROM %s te %s
|
WHERE 1=1 ".$sql_post.'
|
||||||
WHERE 1=1 %s
|
GROUP BY estado, evento, id_agente, id_agentmodule'.$groupby_extra.') AS t';
|
||||||
GROUP BY estado, evento, id_agente, id_agentmodule %s) AS t ',
|
|
||||||
$table,
|
|
||||||
$event_lj,
|
|
||||||
$sql_post,
|
|
||||||
$groupby_extra
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
$sql = sprintf(
|
$sql = "SELECT *, MAX(id_evento) AS id_evento,
|
||||||
'SELECT *, MAX(id_evento) AS id_evento,
|
GROUP_CONCAT(DISTINCT user_comment SEPARATOR '<br>') AS user_comment,
|
||||||
GROUP_CONCAT(DISTINCT user_comment SEPARATOR "<br>") AS user_comment,
|
GROUP_CONCAT(DISTINCT id_evento SEPARATOR ',') AS similar_ids,
|
||||||
GROUP_CONCAT(DISTINCT id_evento SEPARATOR ",") AS similar_ids,
|
|
||||||
COUNT(id_evento) AS event_rep, MAX(utimestamp) AS timestamp_rep,
|
COUNT(id_evento) AS event_rep, MAX(utimestamp) AS timestamp_rep,
|
||||||
MIN(utimestamp) AS timestamp_rep_min,
|
MIN(utimestamp) AS timestamp_rep_min,
|
||||||
(SELECT owner_user FROM %s WHERE id_evento = MAX(te.id_evento)) owner_user,
|
(SELECT owner_user FROM $table WHERE id_evento = MAX(te.id_evento)) owner_user,
|
||||||
(SELECT id_usuario FROM %s WHERE id_evento = MAX(te.id_evento)) id_usuario,
|
(SELECT id_usuario FROM $table WHERE id_evento = MAX(te.id_evento)) id_usuario,
|
||||||
(SELECT id_agente FROM %s WHERE id_evento = MAX(te.id_evento)) id_agente,
|
(SELECT id_agente FROM $table WHERE id_evento = MAX(te.id_evento)) id_agente,
|
||||||
(SELECT criticity FROM %s WHERE id_evento = MAX(te.id_evento)) AS criticity,
|
(SELECT criticity FROM $table WHERE id_evento = MAX(te.id_evento)) AS criticity,
|
||||||
(SELECT ack_utimestamp FROM %s WHERE id_evento = MAX(te.id_evento)) AS ack_utimestamp,
|
(SELECT ack_utimestamp FROM $table WHERE id_evento = MAX(te.id_evento)) AS ack_utimestamp,
|
||||||
(SELECT nombre FROM tagente_modulo WHERE id_agente_modulo = te.id_agentmodule) AS module_name,
|
(SELECT nombre FROM tagente_modulo WHERE id_agente_modulo = te.id_agentmodule) AS module_name
|
||||||
(SELECT alias FROM tagente WHERE id_agente = te.id_agente) agent_name,
|
FROM $table te $event_lj
|
||||||
te.id_agente
|
WHERE 1=1 ".$sql_post.'
|
||||||
FROM %s te %s
|
GROUP BY estado, evento, id_agente, id_agentmodule'.$groupby_extra;
|
||||||
WHERE 1=1 %s
|
|
||||||
GROUP BY estado, evento, id_agente, id_agentmodule %s ',
|
|
||||||
$table,
|
|
||||||
$table,
|
|
||||||
$table,
|
|
||||||
$table,
|
|
||||||
$table,
|
|
||||||
$table,
|
|
||||||
$event_lj,
|
|
||||||
$sql_post,
|
|
||||||
$groupby_extra
|
|
||||||
);
|
|
||||||
$sql .= ' '.events_get_sql_order($sort_field, $order, 2);
|
$sql .= ' '.events_get_sql_order($sort_field, $order, 2);
|
||||||
$sql .= ' LIMIT '.$offset.','.$pagination;
|
$sql .= ' LIMIT '.$offset.','.$pagination;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract the events by filter (or not) from db.
|
// Extract the events by filter (or not) from db
|
||||||
$events = db_get_all_rows_sql($sql, $history_db);
|
$events = db_get_all_rows_sql($sql, $history_db);
|
||||||
|
|
||||||
if ($total) {
|
if ($total) {
|
||||||
|
@ -52,7 +52,7 @@ div.filter_input_little {
|
|||||||
|
|
||||||
form.flex-row div.filter_input.large {
|
form.flex-row div.filter_input.large {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 650px;
|
min-width: 470px;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.filter_input > label,
|
div.filter_input > label,
|
||||||
|
@ -245,3 +245,8 @@
|
|||||||
tr.disabled_row_user * {
|
tr.disabled_row_user * {
|
||||||
color: grey;
|
color: grey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Disable datatables border */
|
||||||
|
table.dataTable.info_table.no-footer {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
@ -79,8 +79,8 @@ $pagination = get_parameter('filter[pagination]');
|
|||||||
$event_view_hr = get_parameter('filter[event_view_hr]', 8);
|
$event_view_hr = get_parameter('filter[event_view_hr]', 8);
|
||||||
$id_user_ack = get_parameter('filter[id_user_ack]');
|
$id_user_ack = get_parameter('filter[id_user_ack]');
|
||||||
$group_rep = get_parameter('filter[group_rep]');
|
$group_rep = get_parameter('filter[group_rep]');
|
||||||
$tag_with = get_parameter('filter[tag_with]', io_json_mb_encode([]));
|
$tag_with = get_parameter('filter[tag_with]', []);
|
||||||
$tag_without = get_parameter('filter[tag_without]', io_json_mb_encode([]));
|
$tag_without = get_parameter('filter[tag_without]', []);
|
||||||
$filter_only_alert = get_parameter('filter[filter_only_alert]');
|
$filter_only_alert = get_parameter('filter[filter_only_alert]');
|
||||||
$id_group_filter = get_parameter('filter[id_group_filter]');
|
$id_group_filter = get_parameter('filter[id_group_filter]');
|
||||||
$date_from = get_parameter('filter[date_from]');
|
$date_from = get_parameter('filter[date_from]');
|
||||||
@ -91,6 +91,9 @@ $user_comment = get_parameter('filter[user_comment]');
|
|||||||
|
|
||||||
|
|
||||||
// TAGS.
|
// TAGS.
|
||||||
|
// Get the tags where the user have permissions in Events reading tasks.
|
||||||
|
$tags = tags_get_user_tags($config['id_user'], $access);
|
||||||
|
|
||||||
$tags_select_with = [];
|
$tags_select_with = [];
|
||||||
$tags_select_without = [];
|
$tags_select_without = [];
|
||||||
$tag_with_temp = [];
|
$tag_with_temp = [];
|
||||||
@ -125,7 +128,7 @@ $tabletags_with->cellspacing = 4;
|
|||||||
$tabletags_with->cellpadding = 4;
|
$tabletags_with->cellpadding = 4;
|
||||||
$tabletags_with->class = 'noshadow';
|
$tabletags_with->class = 'noshadow';
|
||||||
$tabletags_with->styleTable = 'border: 0px;';
|
$tabletags_with->styleTable = 'border: 0px;';
|
||||||
if (defined('METACONSOLE')) {
|
if (is_metaconsole()) {
|
||||||
$tabletags_with->class = 'nobady';
|
$tabletags_with->class = 'nobady';
|
||||||
$tabletags_with->cellspacing = 0;
|
$tabletags_with->cellspacing = 0;
|
||||||
$tabletags_with->cellpadding = 0;
|
$tabletags_with->cellpadding = 0;
|
||||||
@ -200,7 +203,7 @@ $tabletags_without->width = '100%';
|
|||||||
$tabletags_without->cellspacing = 4;
|
$tabletags_without->cellspacing = 4;
|
||||||
$tabletags_without->cellpadding = 4;
|
$tabletags_without->cellpadding = 4;
|
||||||
$tabletags_without->class = 'noshadow';
|
$tabletags_without->class = 'noshadow';
|
||||||
if (defined('METACONSOLE')) {
|
if (is_metaconsole()) {
|
||||||
$tabletags_without->class = 'nobady';
|
$tabletags_without->class = 'nobady';
|
||||||
$tabletags_without->cellspacing = 0;
|
$tabletags_without->cellspacing = 0;
|
||||||
$tabletags_without->cellpadding = 0;
|
$tabletags_without->cellpadding = 0;
|
||||||
@ -263,12 +266,6 @@ $data[2] = html_print_select(
|
|||||||
$tabletags_without->data[] = $data;
|
$tabletags_without->data[] = $data;
|
||||||
$tabletags_without->rowclass[] = '';
|
$tabletags_without->rowclass[] = '';
|
||||||
|
|
||||||
|
|
||||||
// END OF TAGS.
|
|
||||||
// Datatables offset, limit.
|
|
||||||
$start = get_parameter('start', 0);
|
|
||||||
$length = get_parameter('length', $config['block_size']);
|
|
||||||
|
|
||||||
if (io_safe_output($tag_with) == '["0"]') {
|
if (io_safe_output($tag_with) == '["0"]') {
|
||||||
$tag_with = '[]';
|
$tag_with = '[]';
|
||||||
}
|
}
|
||||||
@ -277,6 +274,11 @@ if (io_safe_output($tag_without) == '["0"]') {
|
|||||||
$tag_without = '[]';
|
$tag_without = '[]';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* END OF TAGS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
// Ajax responses.
|
// Ajax responses.
|
||||||
if (is_ajax()) {
|
if (is_ajax()) {
|
||||||
$get_filter_values = get_parameter('get_filter_values', 0);
|
$get_filter_values = get_parameter('get_filter_values', 0);
|
||||||
@ -285,31 +287,36 @@ if (is_ajax()) {
|
|||||||
$get_event_filters = get_parameter('get_event_filters', 0);
|
$get_event_filters = get_parameter('get_event_filters', 0);
|
||||||
$get_events = get_parameter('get_events', 0);
|
$get_events = get_parameter('get_events', 0);
|
||||||
$filter = get_parameter('filter', []);
|
$filter = get_parameter('filter', []);
|
||||||
|
// Datatables offset, limit.
|
||||||
|
$start = get_parameter('start', 0);
|
||||||
|
$length = get_parameter('length', $config['block_size']);
|
||||||
|
|
||||||
if ($get_events) {
|
if ($get_events) {
|
||||||
$order = get_datatable_order(true);
|
$order = get_datatable_order(true);
|
||||||
|
|
||||||
$sql_post = ' AND te.utimestamp > UNIX_TIMESTAMP(now() - INTERVAL '.$event_view_hr.' hour)';
|
$events = events_get_all(
|
||||||
$events = events_get_events_grouped(
|
[
|
||||||
// Sql_post.
|
'te.*',
|
||||||
$sql_post,
|
'ta.alias as agent_name',
|
||||||
|
],
|
||||||
|
$filter,
|
||||||
// Offset.
|
// Offset.
|
||||||
$start,
|
$start,
|
||||||
// Pagination.
|
// Limit.
|
||||||
$length,
|
$length,
|
||||||
// Meta.
|
|
||||||
false,
|
|
||||||
// History.
|
|
||||||
false,
|
|
||||||
// Total.
|
|
||||||
false,
|
|
||||||
// History db.
|
|
||||||
false,
|
|
||||||
// Order.
|
// Order.
|
||||||
$order['direction'],
|
$order['direction'],
|
||||||
// Sort field.
|
// Sort field.
|
||||||
$order['field']
|
$order['field']
|
||||||
);
|
);
|
||||||
|
$count = events_get_all(
|
||||||
|
'count',
|
||||||
|
$filter
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($count !== false) {
|
||||||
|
$count = $count['0']['nitems'];
|
||||||
|
}
|
||||||
|
|
||||||
if ($events) {
|
if ($events) {
|
||||||
$data = array_reduce(
|
$data = array_reduce(
|
||||||
@ -321,21 +328,6 @@ if (is_ajax()) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$count = events_get_events_grouped(
|
|
||||||
// Sql_post.
|
|
||||||
$sql_post,
|
|
||||||
// Offset.
|
|
||||||
$start,
|
|
||||||
// Pagination.
|
|
||||||
$length,
|
|
||||||
// Meta.
|
|
||||||
false,
|
|
||||||
// History.
|
|
||||||
false,
|
|
||||||
// Total.
|
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
// RecordsTotal && recordsfiltered resultados totales.
|
// RecordsTotal && recordsfiltered resultados totales.
|
||||||
echo json_encode(
|
echo json_encode(
|
||||||
[
|
[
|
||||||
@ -652,9 +644,9 @@ $inputs[] = $in;
|
|||||||
// Duplicates group { events | agents }.
|
// Duplicates group { events | agents }.
|
||||||
$data = html_print_select(
|
$data = html_print_select(
|
||||||
[
|
[
|
||||||
__('All events'),
|
0 => __('All events'),
|
||||||
__('Group events'),
|
1 => __('Group events'),
|
||||||
__('Group agents'),
|
2 => __('Group agents'),
|
||||||
],
|
],
|
||||||
'group_rep',
|
'group_rep',
|
||||||
$group_rep,
|
$group_rep,
|
||||||
@ -1115,8 +1107,6 @@ try {
|
|||||||
item.event_type = \'<div class="criticity" style="background: \';
|
item.event_type = \'<div class="criticity" style="background: \';
|
||||||
item.event_type += color + \'">\' + text + "</div>";
|
item.event_type += color + \'">\' + text + "</div>";
|
||||||
|
|
||||||
console.log(item);
|
|
||||||
|
|
||||||
if (item.id_agente > 0) {
|
if (item.id_agente > 0) {
|
||||||
item.agent_name = \'<a href="'.ui_get_full_url('index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=').'\'+item.id_agente+\'">\' + item.agent_name + \'</a>\';
|
item.agent_name = \'<a href="'.ui_get_full_url('index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=').'\'+item.id_agente+\'">\' + item.agent_name + \'</a>\';
|
||||||
}
|
}
|
||||||
@ -1140,8 +1130,736 @@ ui_require_jquery_file(
|
|||||||
'ui.datepicker-'.get_user_language(),
|
'ui.datepicker-'.get_user_language(),
|
||||||
'include/javascript/i18n/'
|
'include/javascript/i18n/'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// End. Load required JS.
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
var select_with_tag_empty = <?php echo (int) $remove_with_tag_disabled; ?>;
|
||||||
|
var select_without_tag_empty = <?php echo (int) $remove_without_tag_disabled; ?>;
|
||||||
|
var origin_select_with_tag_empty = <?php echo (int) $add_with_tag_disabled; ?>;
|
||||||
|
var origin_select_without_tag_empty = <?php echo (int) $add_without_tag_disabled; ?>;
|
||||||
|
|
||||||
|
var val_none = 0;
|
||||||
|
var text_none = "<?php echo __('None'); ?>";
|
||||||
|
var group_agents_id = false;
|
||||||
|
|
||||||
|
$(document).ready( function() {
|
||||||
|
id_select_destiny = "#tag_with_temp";
|
||||||
|
id_hidden = "#hidden-tag_with";
|
||||||
|
|
||||||
|
value_store = [];
|
||||||
|
|
||||||
|
jQuery.each($(id_select_destiny + " option"), function(key, element) {
|
||||||
|
val = $(element).val();
|
||||||
|
|
||||||
|
value_store.push(val);
|
||||||
|
});
|
||||||
|
|
||||||
|
$(id_hidden).val(Base64.encode(JSON.stringify(value_store)));
|
||||||
|
|
||||||
|
id_select_destiny2 = "#tag_without_temp";
|
||||||
|
id_hidden2 = "#hidden-tag_without";
|
||||||
|
|
||||||
|
value_store2 = [];
|
||||||
|
|
||||||
|
jQuery.each($(id_select_destiny2 + " option"), function(key, element) {
|
||||||
|
val = $(element).val();
|
||||||
|
|
||||||
|
value_store2.push(val);
|
||||||
|
});
|
||||||
|
|
||||||
|
$(id_hidden2).val(Base64.encode(JSON.stringify(value_store2)));
|
||||||
|
|
||||||
|
$("#text-date_from, #text-date_to").datepicker(
|
||||||
|
{dateFormat: "<?php echo DATE_FORMAT_JS; ?>"});
|
||||||
|
|
||||||
|
// Don't collapse filter if update button has been pushed
|
||||||
|
if ($("#hidden-open_filter").val() == 'true') {
|
||||||
|
$("#event_control").toggle();
|
||||||
|
}
|
||||||
|
|
||||||
|
// If selected is not 'none' show filter name.
|
||||||
|
if ( $("#filter_id").val() != 0 ) {
|
||||||
|
$("#row_name").css('visibility', '');
|
||||||
|
$("#submit-update_filter").css('visibility', '');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($("#hidden-id_name").val() == ''){
|
||||||
|
if($("#hidden-filterid").val() != ''){
|
||||||
|
$('#row_name').css('visibility', '');
|
||||||
|
$("#submit-update_filter").css('visibility', '');
|
||||||
|
jQuery.post ("<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||||
|
{"page" : "operation/events/events_list",
|
||||||
|
"get_filter_values" : 1,
|
||||||
|
"id" : $('#hidden-filterid').val()
|
||||||
|
},
|
||||||
|
function (data) {
|
||||||
|
jQuery.each (data, function (i, val) {
|
||||||
|
if (i == 'id_name')
|
||||||
|
$("#hidden-id_name").val(val);
|
||||||
|
if (i == 'id_group')
|
||||||
|
$("#id_group").val(val);
|
||||||
|
if (i == 'event_type')
|
||||||
|
$("#event_type").val(val);
|
||||||
|
if (i == 'severity')
|
||||||
|
$("#severity").val(val);
|
||||||
|
if (i == 'status')
|
||||||
|
$("#status").val(val);
|
||||||
|
if (i == 'search')
|
||||||
|
$("#text-search").val(val);
|
||||||
|
if (i == 'text_agent')
|
||||||
|
$("#text_id_agent").val(val);
|
||||||
|
if (i == 'id_agent')
|
||||||
|
$('input:hidden[name=id_agent]').val(val);
|
||||||
|
if (i == 'id_agent_module')
|
||||||
|
$('input:hidden[name=module_search_hidden]').val(val);
|
||||||
|
if (i == 'pagination')
|
||||||
|
$("#pagination").val(val);
|
||||||
|
if (i == 'event_view_hr')
|
||||||
|
$("#text-event_view_hr").val(val);
|
||||||
|
if (i == 'id_user_ack')
|
||||||
|
$("#id_user_ack").val(val);
|
||||||
|
if (i == 'group_rep')
|
||||||
|
$("#group_rep").val(val);
|
||||||
|
if (i == 'tag_with')
|
||||||
|
$("#hidden-tag_with").val(val);
|
||||||
|
if (i == 'tag_without')
|
||||||
|
$("#hidden-tag_without").val(val);
|
||||||
|
if (i == 'filter_only_alert')
|
||||||
|
$("#filter_only_alert").val(val);
|
||||||
|
if (i == 'id_group_filter')
|
||||||
|
$("#id_group_filter").val(val);
|
||||||
|
if (i == 'source')
|
||||||
|
$("#text-source").val(val);
|
||||||
|
if (i == 'id_extra')
|
||||||
|
$("#text-id_extra").val(val);
|
||||||
|
if (i == 'user_comment')
|
||||||
|
$("#text-user_comment").val(val);
|
||||||
|
});
|
||||||
|
reorder_tags_inputs();
|
||||||
|
// Update the info with the loaded filter
|
||||||
|
$('#filter_loaded_span').html($('#filter_loaded_text').html() + ': ' + $("#hidden-id_name").val());
|
||||||
|
|
||||||
|
},
|
||||||
|
"json"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#submit-load_filter").click(function () {
|
||||||
|
// If selected 'none' flush filter
|
||||||
|
if ( $("#filter_id").val() == 0 ) {
|
||||||
|
$("#hidden-id_name").val('');
|
||||||
|
$("#id_group").val(0);
|
||||||
|
$("#event_type").val('');
|
||||||
|
$("#severity").val(-1);
|
||||||
|
$("#status").val(3);
|
||||||
|
$("#text-search").val('');
|
||||||
|
$('input:hidden[name=id_agent]').val("");
|
||||||
|
$('input:hidden[name=module_search_hidden]').val();
|
||||||
|
$("#pagination").val(25);
|
||||||
|
$("#text-event_view_hr").val(8);
|
||||||
|
$("#id_user_ack").val(0);
|
||||||
|
$("#group_rep").val(1);
|
||||||
|
$("#tag").val('');
|
||||||
|
$("#filter_only_alert").val(-1);
|
||||||
|
$("#row_name").css('visibility', 'hidden');
|
||||||
|
$("#submit-update_filter").css('visibility', 'hidden');
|
||||||
|
$("#id_group").val(0);
|
||||||
|
$("#text-date_from").val('');
|
||||||
|
$("#text-date_to").val('');
|
||||||
|
$("#pagination").val(20);
|
||||||
|
$("#update_from_filter_table").val(1);
|
||||||
|
$("#text_id_agent").val("");
|
||||||
|
$("#text-source").val('');
|
||||||
|
$("#text-id_extra").val('');
|
||||||
|
$("#text-user_comment").val('');
|
||||||
|
|
||||||
|
clear_tags_inputs();
|
||||||
|
|
||||||
|
// Update the view of filter load with no loaded filters message
|
||||||
|
$('#filter_loaded_span').html($('#not_filter_loaded_text').html());
|
||||||
|
|
||||||
|
// Update the view with the loaded filter
|
||||||
|
$('#submit-update').trigger('click');
|
||||||
|
}
|
||||||
|
// If filter selected then load filter
|
||||||
|
else {
|
||||||
|
$('#row_name').css('visibility', '');
|
||||||
|
$("#submit-update_filter").css('visibility', '');
|
||||||
|
jQuery.post ("<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||||
|
{"page" : "operation/events/events_list",
|
||||||
|
"get_filter_values" : 1,
|
||||||
|
"id" : $('#filter_id').val()
|
||||||
|
},
|
||||||
|
function (data) {
|
||||||
|
jQuery.each (data, function (i, val) {
|
||||||
|
if (i == 'id_name')
|
||||||
|
$("#hidden-id_name").val(val);
|
||||||
|
if (i == 'id_group')
|
||||||
|
$("#id_group").val(val);
|
||||||
|
if (i == 'event_type')
|
||||||
|
$("#event_type").val(val);
|
||||||
|
if (i == 'severity')
|
||||||
|
$("#severity").val(val);
|
||||||
|
if (i == 'status')
|
||||||
|
$("#status").val(val);
|
||||||
|
if (i == 'search')
|
||||||
|
$("#text-search").val(val);
|
||||||
|
if (i == 'text_agent')
|
||||||
|
$("#text_id_agent").val(val);
|
||||||
|
if (i == 'id_agent')
|
||||||
|
$('input:hidden[name=id_agent]').val(val);
|
||||||
|
if (i == 'id_agent_module')
|
||||||
|
$('input:hidden[name=module_search_hidden]').val(val);
|
||||||
|
if (i == 'pagination')
|
||||||
|
$("#pagination").val(val);
|
||||||
|
if (i == 'event_view_hr')
|
||||||
|
$("#text-event_view_hr").val(val);
|
||||||
|
if (i == 'id_user_ack')
|
||||||
|
$("#id_user_ack").val(val);
|
||||||
|
if (i == 'group_rep')
|
||||||
|
$("#group_rep").val(val);
|
||||||
|
if (i == 'tag_with')
|
||||||
|
$("#hidden-tag_with").val(val);
|
||||||
|
if (i == 'tag_without')
|
||||||
|
$("#hidden-tag_without").val(val);
|
||||||
|
if (i == 'filter_only_alert')
|
||||||
|
$("#filter_only_alert").val(val);
|
||||||
|
if (i == 'id_group_filter')
|
||||||
|
$("#id_group_filter").val(val);
|
||||||
|
if (i == 'date_from'){
|
||||||
|
if((val == '0000-00-00') || (val == null)) {
|
||||||
|
$("#text-date_from").val('');
|
||||||
|
} else {
|
||||||
|
$("#text-date_from").val(val.replace(/\-/g,"/"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (i == 'date_to'){
|
||||||
|
if((val == '0000-00-00') || (val == null)) {
|
||||||
|
$("#text-date_to").val('');
|
||||||
|
} else {
|
||||||
|
$("#text-date_to").val(val.replace(/\-/g,"/"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (i == 'source')
|
||||||
|
$("#text-source").val(val);
|
||||||
|
if (i == 'id_extra')
|
||||||
|
$("#text-id_extra").val(val);
|
||||||
|
if (i == 'user_comment')
|
||||||
|
$("#text-user_comment").val(val);
|
||||||
|
});
|
||||||
|
reorder_tags_inputs();
|
||||||
|
// Update the info with the loaded filter
|
||||||
|
$('#filter_loaded_span').html($('#filter_loaded_text').html() + ': ' + $("#hidden-id_name").val());
|
||||||
|
|
||||||
|
// Update the view with the loaded filter
|
||||||
|
$('#submit-update').trigger('click');
|
||||||
|
},
|
||||||
|
"json"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close dialog
|
||||||
|
$('.ui-dialog-titlebar-close').trigger('click');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Filter save mode selector
|
||||||
|
$("[name='filter_mode']").click(function() {
|
||||||
|
if ($(this).val() == 'new') {
|
||||||
|
$('#save_filter_row1').show();
|
||||||
|
$('#save_filter_row2').show();
|
||||||
|
$('#update_filter_row1').hide();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$('#save_filter_row1').hide();
|
||||||
|
$('#save_filter_row2').hide();
|
||||||
|
$('#update_filter_row1').show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// This saves an event filter
|
||||||
|
$("#submit-save_filter").click(function () {
|
||||||
|
// If the filter name is blank show error
|
||||||
|
if ($('#text-id_name').val() == '') {
|
||||||
|
$('#show_filter_error').html("<h3 class='error'><?php echo __('Filter name cannot be left blank'); ?></h3>");
|
||||||
|
|
||||||
|
// Close dialog
|
||||||
|
$('.ui-dialog-titlebar-close').trigger('click');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var id_filter_save;
|
||||||
|
|
||||||
|
jQuery.post ("<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||||
|
{
|
||||||
|
"page" : "operation/events/events_list",
|
||||||
|
"save_event_filter" : 1,
|
||||||
|
"id_name" : $("#text-id_name").val(),
|
||||||
|
"id_group" : $("select#id_group").val(),
|
||||||
|
"event_type" : $("#event_type").val(),
|
||||||
|
"severity" : $("#severity").val(),
|
||||||
|
"status" : $("#status").val(),
|
||||||
|
"search" : $("#text-search").val(),
|
||||||
|
"text_agent" : $("#text_id_agent").val(),
|
||||||
|
"id_agent" : $('input:hidden[name=id_agent]').val(),
|
||||||
|
"id_agent_module" : $('input:hidden[name=module_search_hidden]').val(),
|
||||||
|
"pagination" : $("#pagination").val(),
|
||||||
|
"event_view_hr" : $("#text-event_view_hr").val(),
|
||||||
|
"id_user_ack" : $("#id_user_ack").val(),
|
||||||
|
"group_rep" : $("#group_rep").val(),
|
||||||
|
"tag_with": Base64.decode($("#hidden-tag_with").val()),
|
||||||
|
"tag_without": Base64.decode($("#hidden-tag_without").val()),
|
||||||
|
"filter_only_alert" : $("#filter_only_alert").val(),
|
||||||
|
"id_group_filter": $("#id_group_filter").val(),
|
||||||
|
"date_from": $("#text-date_from").val(),
|
||||||
|
"date_to": $("#text-date_to").val(),
|
||||||
|
"source": $("#text-source").val(),
|
||||||
|
"id_extra": $("#text-id_extra").val(),
|
||||||
|
"user_comment": $("#text-user_comment").val()
|
||||||
|
},
|
||||||
|
function (data) {
|
||||||
|
$(".info_box").hide();
|
||||||
|
if (data == 'error') {
|
||||||
|
$(".info_box").filter(function(i, item) {
|
||||||
|
if ($(item).data('type_info_box') == "error_create_filter") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}).show();
|
||||||
|
}
|
||||||
|
else if (data == 'duplicate') {
|
||||||
|
$(".info_box").filter(function(i, item) {
|
||||||
|
if ($(item).data('type_info_box') == "duplicate_create_filter") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}).show();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
id_filter_save = data;
|
||||||
|
|
||||||
|
$(".info_box").filter(function(i, item) {
|
||||||
|
if ($(item).data('type_info_box') == "success_create_filter") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// First remove all options of filters select
|
||||||
|
$('#filter_id').find('option').remove().end();
|
||||||
|
// Add 'none' option the first
|
||||||
|
$('#filter_id').append ($('<option></option>').html ( <?php echo "'".__('none')."'"; ?> ).attr ("value", 0));
|
||||||
|
// Reload filters select
|
||||||
|
jQuery.post ("<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||||
|
{
|
||||||
|
"page" : "operation/events/events_list",
|
||||||
|
"get_event_filters" : 1
|
||||||
|
},
|
||||||
|
function (data) {
|
||||||
|
jQuery.each (data, function (i, val) {
|
||||||
|
s = js_html_entity_decode(val);
|
||||||
|
|
||||||
|
if (i == id_filter_save) {
|
||||||
|
$('#filter_id').append ($('<option selected="selected"></option>').html (s).attr ("value", i));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$('#filter_id').append ($('<option></option>').html (s).attr ("value", i));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
"json"
|
||||||
|
);
|
||||||
|
$("#submit-update_filter").css('visibility', '');
|
||||||
|
|
||||||
|
// Close dialog
|
||||||
|
$('.ui-dialog-titlebar-close').trigger('click');
|
||||||
|
|
||||||
|
// Update the info with the loaded filter
|
||||||
|
$("#hidden-id_name").val($('#text-id_name').val());
|
||||||
|
$('#filter_loaded_span').html($('#filter_loaded_text').html() + ': ' + $('#text-id_name').val());
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
// This updates an event filter
|
||||||
|
$("#submit-update_filter").click(function () {
|
||||||
|
var id_filter_update = $("#overwrite_filter").val();
|
||||||
|
var name_filter_update = $("#overwrite_filter option[value='"+id_filter_update+"']").text();
|
||||||
|
|
||||||
|
jQuery.post ("<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||||
|
{"page" : "operation/events/events_list",
|
||||||
|
"update_event_filter" : 1,
|
||||||
|
"id" : $("#overwrite_filter").val(),
|
||||||
|
"id_group" : $("select#id_group").val(),
|
||||||
|
"event_type" : $("#event_type").val(),
|
||||||
|
"severity" : $("#severity").val(),
|
||||||
|
"status" : $("#status").val(),
|
||||||
|
"search" : $("#text-search").val(),
|
||||||
|
"text_agent" : $("#text_id_agent").val(),
|
||||||
|
"id_agent" : $('input:hidden[name=id_agent]').val(),
|
||||||
|
"id_agent_module" : $('input:hidden[name=module_search_hidden]').val(),
|
||||||
|
"pagination" : $("#pagination").val(),
|
||||||
|
"event_view_hr" : $("#text-event_view_hr").val(),
|
||||||
|
"id_user_ack" : $("#id_user_ack").val(),
|
||||||
|
"group_rep" : $("#group_rep").val(),
|
||||||
|
"tag_with" : Base64.decode($("#hidden-tag_with").val()),
|
||||||
|
"tag_without" : Base64.decode($("#hidden-tag_without").val()),
|
||||||
|
"filter_only_alert" : $("#filter_only_alert").val(),
|
||||||
|
"id_group_filter": $("#id_group_filter").val(),
|
||||||
|
"date_from": $("#text-date_from").val(),
|
||||||
|
"date_to": $("#text-date_to").val(),
|
||||||
|
"source": $("#text-source").val(),
|
||||||
|
"id_extra": $("#text-id_extra").val(),
|
||||||
|
"user_comment": $("#text-user_comment").val()
|
||||||
|
},
|
||||||
|
function (data) {
|
||||||
|
$(".info_box").hide();
|
||||||
|
if (data == 'ok') {
|
||||||
|
$(".info_box").filter(function(i, item) {
|
||||||
|
if ($(item).data('type_info_box') == "success_update_filter") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}).show();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$(".info_box").filter(function(i, item) {
|
||||||
|
if ($(item).data('type_info_box') == "error_create_filter") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// First remove all options of filters select
|
||||||
|
$('#filter_id').find('option').remove().end();
|
||||||
|
// Add 'none' option the first
|
||||||
|
$('#filter_id').append ($('<option></option>').html ( <?php echo "'".__('none')."'"; ?> ).attr ("value", 0));
|
||||||
|
// Reload filters select
|
||||||
|
jQuery.post ("<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||||
|
{"page" : "operation/events/events_list",
|
||||||
|
"get_event_filters" : 1
|
||||||
|
},
|
||||||
|
function (data) {
|
||||||
|
jQuery.each (data, function (i, val) {
|
||||||
|
s = js_html_entity_decode(val);
|
||||||
|
if (i == id_filter_update) {
|
||||||
|
$('#filter_id').append ($('<option selected="selected"></option>').html (s).attr ("value", i));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$('#filter_id').append ($('<option></option>').html (s).attr ("value", i));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
"json"
|
||||||
|
);
|
||||||
|
|
||||||
|
// Close dialog
|
||||||
|
$('.ui-dialog-titlebar-close').trigger('click');
|
||||||
|
|
||||||
|
// Update the info with the loaded filter
|
||||||
|
$("#hidden-id_name").val($('#text-id_name').val());
|
||||||
|
$('#filter_loaded_span').html($('#filter_loaded_text').html() + ': ' + name_filter_update);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Change toggle arrow when it's clicked
|
||||||
|
$("#tgl_event_control").click(function() {
|
||||||
|
if ($("#toggle_arrow").attr("src").match(/[^\.]+down\.png/) == null) {
|
||||||
|
var params = [];
|
||||||
|
params.push("get_image_path=1");
|
||||||
|
params.push("img_src=images/down.png");
|
||||||
|
params.push("page=include/ajax/skins.ajax");
|
||||||
|
params.push("only_src=1");
|
||||||
|
jQuery.ajax ({
|
||||||
|
data: params.join ("&"),
|
||||||
|
type: 'POST',
|
||||||
|
url: action="<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||||
|
success: function (data) {
|
||||||
|
$("#toggle_arrow").attr('src', data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var params = [];
|
||||||
|
params.push("get_image_path=1");
|
||||||
|
params.push("img_src=images/go.png");
|
||||||
|
params.push("page=include/ajax/skins.ajax");
|
||||||
|
params.push("only_src=1");
|
||||||
|
jQuery.ajax ({
|
||||||
|
data: params.join ("&"),
|
||||||
|
type: 'POST',
|
||||||
|
url: action="<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||||
|
success: function (data) {
|
||||||
|
$("#toggle_arrow").attr('src', data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#button-add_with").click(function() {
|
||||||
|
click_button_add_tag("with");
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#button-add_without").click(function() {
|
||||||
|
click_button_add_tag("without");
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#button-remove_with").click(function() {
|
||||||
|
click_button_remove_tag("with");
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#button-remove_without").click(function() {
|
||||||
|
click_button_remove_tag("without");
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
function click_button_remove_tag(what_button) {
|
||||||
|
if (what_button == "with") {
|
||||||
|
id_select_origin = "#select_with";
|
||||||
|
id_select_destiny = "#tag_with_temp";
|
||||||
|
id_button_remove = "#button-remove_with";
|
||||||
|
id_button_add = "#button-add_with";
|
||||||
|
|
||||||
|
select_origin_empty = origin_select_with_tag_empty;
|
||||||
|
}
|
||||||
|
else { //without
|
||||||
|
id_select_origin = "#select_without";
|
||||||
|
id_select_destiny = "#tag_without_temp";
|
||||||
|
id_button_remove = "#button-remove_without";
|
||||||
|
id_button_add = "#button-add_without";
|
||||||
|
|
||||||
|
select_origin_empty = origin_select_without_tag_empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($(id_select_destiny + " option:selected").length == 0) {
|
||||||
|
return; //Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
if (select_origin_empty) {
|
||||||
|
$(id_select_origin + " option").remove();
|
||||||
|
|
||||||
|
if (what_button == "with") {
|
||||||
|
origin_select_with_tag_empty = false;
|
||||||
|
}
|
||||||
|
else { //without
|
||||||
|
origin_select_without_tag_empty = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$(id_button_add).removeAttr('disabled');
|
||||||
|
}
|
||||||
|
|
||||||
|
//Foreach because maybe the user select several items in
|
||||||
|
//the select.
|
||||||
|
jQuery.each($(id_select_destiny + " option:selected"), function(key, element) {
|
||||||
|
val = $(element).val();
|
||||||
|
text = $(element).text();
|
||||||
|
|
||||||
|
$(id_select_origin).append($("<option value='" + val + "'>" + text + "</option>"));
|
||||||
|
});
|
||||||
|
|
||||||
|
$(id_select_destiny + " option:selected").remove();
|
||||||
|
|
||||||
|
if ($(id_select_destiny + " option").length == 0) {
|
||||||
|
$(id_select_destiny).append($("<option value='" + val_none + "'>" + text_none + "</option>"));
|
||||||
|
$(id_button_remove).attr('disabled', 'true');
|
||||||
|
|
||||||
|
if (what_button == 'with') {
|
||||||
|
select_with_tag_empty = true;
|
||||||
|
}
|
||||||
|
else { //without
|
||||||
|
select_without_tag_empty = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
replace_hidden_tags(what_button);
|
||||||
|
}
|
||||||
|
|
||||||
|
function click_button_add_tag(what_button) {
|
||||||
|
if (what_button == 'with') {
|
||||||
|
id_select_origin = "#select_with";
|
||||||
|
id_select_destiny = "#tag_with_temp";
|
||||||
|
id_button_remove = "#button-remove_with";
|
||||||
|
id_button_add = "#button-add_with";
|
||||||
|
}
|
||||||
|
else { //without
|
||||||
|
id_select_origin = "#select_without";
|
||||||
|
id_select_destiny = "#tag_without_temp";
|
||||||
|
id_button_remove = "#button-remove_without";
|
||||||
|
id_button_add = "#button-add_without";
|
||||||
|
}
|
||||||
|
|
||||||
|
$(id_select_origin + " option:selected").each(function() {
|
||||||
|
if (what_button == 'with') {
|
||||||
|
select_destiny_empty = select_with_tag_empty;
|
||||||
|
}
|
||||||
|
else { //without
|
||||||
|
select_destiny_empty = select_without_tag_empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
without_val = $(this).val();
|
||||||
|
if(without_val == null) {
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
without_text = $(this).text();
|
||||||
|
|
||||||
|
if (select_destiny_empty) {
|
||||||
|
$(id_select_destiny).empty();
|
||||||
|
|
||||||
|
if (what_button == 'with') {
|
||||||
|
select_with_tag_empty = false;
|
||||||
|
}
|
||||||
|
else { //without
|
||||||
|
select_without_tag_empty = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$(id_select_destiny).append($("<option value='" + without_val + "'>" + without_text + "</option>"));
|
||||||
|
$(id_select_origin + " option:selected").remove();
|
||||||
|
$(id_button_remove).removeAttr('disabled');
|
||||||
|
|
||||||
|
if ($(id_select_origin + " option").length == 0) {
|
||||||
|
$(id_select_origin).append($("<option value='" + val_none + "'>" + text_none + "</option>"));
|
||||||
|
$(id_button_add).attr('disabled', 'true');
|
||||||
|
|
||||||
|
if (what_button == 'with') {
|
||||||
|
origin_select_with_tag_empty = true;
|
||||||
|
}
|
||||||
|
else { //without
|
||||||
|
origin_select_without_tag_empty = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
replace_hidden_tags(what_button);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function replace_hidden_tags(what_button) {
|
||||||
|
if (what_button == 'with') {
|
||||||
|
id_select_destiny = "#tag_with_temp";
|
||||||
|
id_hidden = "#hidden-tag_with";
|
||||||
|
}
|
||||||
|
else { //without
|
||||||
|
id_select_destiny = "#tag_without_temp";
|
||||||
|
id_hidden = "#hidden-tag_without";
|
||||||
|
}
|
||||||
|
|
||||||
|
value_store = [];
|
||||||
|
|
||||||
|
jQuery.each($(id_select_destiny + " option"), function(key, element) {
|
||||||
|
val = $(element).val();
|
||||||
|
|
||||||
|
value_store.push(val);
|
||||||
|
});
|
||||||
|
|
||||||
|
$(id_hidden).val(Base64.encode(JSON.stringify(value_store)));
|
||||||
|
}
|
||||||
|
|
||||||
|
function clear_tags_inputs() {
|
||||||
|
$("#hidden-tag_with").val(Base64.encode(JSON.stringify([])));
|
||||||
|
$("#hidden-tag_without").val(Base64.encode(JSON.stringify([])));
|
||||||
|
reorder_tags_inputs();
|
||||||
|
}
|
||||||
|
|
||||||
|
function reorder_tags_inputs() {
|
||||||
|
$('#select_with option[value="' + val_none + '"]').remove();
|
||||||
|
jQuery.each($("#tag_with_temp option"), function(key, element) {
|
||||||
|
val = $(element).val();
|
||||||
|
text = $(element).text();
|
||||||
|
|
||||||
|
if (val == val_none)
|
||||||
|
return;
|
||||||
|
|
||||||
|
$("#select_with").append($("<option value='" + val + "'>" + text + "</option>"));
|
||||||
|
});
|
||||||
|
$("#tag_with_temp option").remove();
|
||||||
|
|
||||||
|
|
||||||
|
$('#select_without option[value="' + val_none + '"]').remove();
|
||||||
|
jQuery.each($("#tag_without_temp option"), function(key, element) {
|
||||||
|
val = $(element).val();
|
||||||
|
text = $(element).text();
|
||||||
|
|
||||||
|
if (val == val_none)
|
||||||
|
return;
|
||||||
|
|
||||||
|
$("#select_without").append($("<option value='" + val + "'>" + text + "</option>"));
|
||||||
|
});
|
||||||
|
$("#tag_without_temp option").remove();
|
||||||
|
|
||||||
|
|
||||||
|
tags_base64 = $("#hidden-tag_with").val();
|
||||||
|
tags = jQuery.parseJSON(Base64.decode(tags_base64));
|
||||||
|
jQuery.each(tags, function(key, element) {
|
||||||
|
if ($("#select_with option[value='" + element + "']").length == 1) {
|
||||||
|
text = $("#select_with option[value='" + element + "']").text();
|
||||||
|
val = $("#select_with option[value='" + element + "']").val();
|
||||||
|
$("#tag_with_temp").append($("<option value='" + val + "'>" + text + "</option>"));
|
||||||
|
$("#select_with option[value='" + element + "']").remove();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if ($("#select_with option").length == 0) {
|
||||||
|
origin_select_with_tag_empty = true;
|
||||||
|
$("#button-add_with").attr('disabled', 'true');
|
||||||
|
$("#select_with").append($("<option value='" + val_none + "'>" + text_none + "</option>"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
origin_select_with_tag_empty = false;
|
||||||
|
$("#button-add_with").removeAttr('disabled');
|
||||||
|
}
|
||||||
|
if ($("#tag_with_temp option").length == 0) {
|
||||||
|
select_with_tag_empty = true;
|
||||||
|
$("#button-remove_with").attr('disabled', 'true');
|
||||||
|
$("#tag_with_temp").append($("<option value='" + val_none + "'>" + text_none + "</option>"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
select_with_tag_empty = false;
|
||||||
|
$("#button-remove_with").removeAttr('disabled');
|
||||||
|
}
|
||||||
|
|
||||||
|
tags_base64 = $("#hidden-tag_without").val();
|
||||||
|
tags = jQuery.parseJSON(Base64.decode(tags_base64));
|
||||||
|
jQuery.each(tags, function(key, element) {
|
||||||
|
if ($("#select_without option[value='" + element + "']").length == 1) {
|
||||||
|
text = $("#select_without option[value='" + element + "']").text();
|
||||||
|
val = $("#select_without option[value='" + element + "']").val();
|
||||||
|
$("#tag_without_temp").append($("<option value='" + val + "'>" + text + "</option>"));
|
||||||
|
$("#select_without option[value='" + element + "']").remove();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if ($("#select_without option").length == 0) {
|
||||||
|
origin_select_without_tag_empty = true;
|
||||||
|
$("#button-add_without").attr('disabled', 'true');
|
||||||
|
$("#select_without").append($("<option value='" + val_none + "'>" + text_none + "</option>"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
origin_select_without_tag_empty = false;
|
||||||
|
$("#button-add_without").removeAttr('disabled');
|
||||||
|
}
|
||||||
|
if ($("#tag_without_temp option").length == 0) {
|
||||||
|
select_without_tag_empty = true;
|
||||||
|
$("#button-remove_without").attr('disabled', 'true');
|
||||||
|
$("#tag_without_temp").append($("<option value='" + val_none + "'>" + text_none + "</option>"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
select_without_tag_empty = false;
|
||||||
|
$("#button-remove_without").removeAttr('disabled');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function datetime_picker_callback() {
|
function datetime_picker_callback() {
|
||||||
$("#text-time_from, #text-time_to").timepicker({
|
$("#text-time_from, #text-time_to").timepicker({
|
||||||
showSecond: true,
|
showSecond: true,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user