fix performance issue
This commit is contained in:
parent
e5bdceee78
commit
08ab924160
|
@ -1786,46 +1786,10 @@ $class = 'databox filters';
|
|||
<td class="bolder"><?php echo __('Agents'); ?></td>
|
||||
<td>
|
||||
<?php
|
||||
if ($source) {
|
||||
$sql_log_report = 'SELECT id_agente, alias
|
||||
FROM tagente, tagent_module_log
|
||||
WHERE tagente.id_agente = tagent_module_log.id_agent
|
||||
AND tagente.disabled = 0
|
||||
AND tagent_module_log.source like "'.$source.'"';
|
||||
} else {
|
||||
$sql_log_report = 'SELECT id_agente, alias
|
||||
FROM tagente, tagent_module_log
|
||||
WHERE tagente.id_agente = tagent_module_log.id_agent
|
||||
AND tagente.disabled = 0';
|
||||
}
|
||||
|
||||
$all_agent_log = db_get_all_rows_sql($sql_log_report);
|
||||
|
||||
if (isset($all_agent_log) && is_array($all_agent_log)) {
|
||||
foreach ($all_agent_log as $key => $value) {
|
||||
$agents2[$value['id_agente']] = $value['alias'];
|
||||
}
|
||||
}
|
||||
|
||||
if ((empty($agents2)) || $agents2 == -1) {
|
||||
$agents = [];
|
||||
}
|
||||
|
||||
$agents_select = [];
|
||||
if (is_array($id_agents) || is_object($id_agents)) {
|
||||
foreach ($id_agents as $id) {
|
||||
foreach ($agents2 as $key => $a) {
|
||||
if ($key == (int) $id) {
|
||||
$agents_select[$key] = $key;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
html_print_select(
|
||||
$agents2,
|
||||
[],
|
||||
'id_agents3[]',
|
||||
$agents_select,
|
||||
'',
|
||||
$script = '',
|
||||
'',
|
||||
0,
|
||||
|
@ -6110,6 +6074,58 @@ function addGeneralRow() {
|
|||
}
|
||||
}
|
||||
|
||||
function loadLogAgents() {
|
||||
var params = [];
|
||||
|
||||
params.push("get_log_agents=1");
|
||||
params.push("source=<?php echo $source; ?>");
|
||||
params.push('id_agents=<?php echo json_encode($id_agents); ?>');
|
||||
params.push("page=include/ajax/reporting.ajax");
|
||||
|
||||
$('#id_agents3')
|
||||
.find('option')
|
||||
.remove();
|
||||
|
||||
$('#id_agents3')
|
||||
.append('<option>Loading agents...</option>');
|
||||
|
||||
jQuery.ajax ({
|
||||
data: params.join ("&"),
|
||||
type: 'POST',
|
||||
url: action=
|
||||
<?php
|
||||
echo '"'.ui_get_full_url(
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
).'"';
|
||||
?>
|
||||
+ "/ajax.php",
|
||||
timeout: 300000,
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
if (data['correct']) {
|
||||
$('#id_agents3')
|
||||
.find('option')
|
||||
.remove();
|
||||
|
||||
var selectElements = [];
|
||||
var selectedStr = 'selected="selected"'
|
||||
data['select_agents'].forEach(function(agentAlias, agentID) {
|
||||
var optionAttr = '';
|
||||
if (typeof data['agents_selected'][agentID] !== 'undefined') {
|
||||
optionAttr = ' selected="selected"';
|
||||
}
|
||||
|
||||
$('#id_agents3')
|
||||
.append('<option value="'+agentID+'" '+optionAttr+'>'+agentAlias+'</option>');
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function chooseType() {
|
||||
var meta = '<?php echo (is_metaconsole() === true) ? 1 : 0; ?>';
|
||||
type = $("#type").val();
|
||||
|
@ -6278,6 +6294,9 @@ function chooseType() {
|
|||
$("#agents_row").show();
|
||||
$("#row_source").show();
|
||||
$("#row_historical_db_check").hide();
|
||||
|
||||
loadLogAgents();
|
||||
|
||||
break;
|
||||
|
||||
case 'increment':
|
||||
|
|
|
@ -25,6 +25,9 @@ if (! check_acl($config['id_user'], 0, 'RW')) {
|
|||
exit;
|
||||
}
|
||||
|
||||
$get_log_agents = (bool) get_parameter('get_log_agents', 0);
|
||||
$agents_id = get_parameter('id_agents', []);
|
||||
$agents_id = get_parameter('source', 0);
|
||||
$delete_sla_item = get_parameter('delete_sla_item', 0);
|
||||
$delete_general_item = get_parameter('delete_general_item', 0);
|
||||
$get_custom_sql = get_parameter('get_custom_sql', 0);
|
||||
|
@ -244,3 +247,60 @@ if ($change_custom_fields_macros_report === true) {
|
|||
echo $custom_field_draw;
|
||||
return;
|
||||
}
|
||||
|
||||
if ($get_log_agents === true) {
|
||||
try {
|
||||
$agents_id = json_decode($agents_id, true);
|
||||
} catch (Exception $e) {
|
||||
$data['correct'] = 0;
|
||||
echo json_encode($data);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($source) {
|
||||
$sql_log_report = 'SELECT id_agente, alias
|
||||
FROM tagente, tagent_module_log
|
||||
WHERE tagente.id_agente = tagent_module_log.id_agent
|
||||
AND tagente.disabled = 0
|
||||
AND tagent_module_log.source like "'.$source.'"';
|
||||
} else {
|
||||
$sql_log_report = 'SELECT id_agente, alias
|
||||
FROM tagente, tagent_module_log
|
||||
WHERE tagente.id_agente = tagent_module_log.id_agent
|
||||
AND tagente.disabled = 0';
|
||||
}
|
||||
|
||||
$all_agent_log = db_get_all_rows_sql($sql_log_report);
|
||||
|
||||
if (isset($all_agent_log) && is_array($all_agent_log)) {
|
||||
foreach ($all_agent_log as $key => $value) {
|
||||
$select_agents[$value['id_agente']] = $value['alias'];
|
||||
}
|
||||
}
|
||||
|
||||
if ((empty($select_agents)) || $select_agents == -1) {
|
||||
$agents = [];
|
||||
}
|
||||
|
||||
$agents_selected = [];
|
||||
if (is_array($agents_id) === true || is_object($agents_id) === true) {
|
||||
foreach ($select_agents as $key => $a) {
|
||||
if (in_array((string) $key, $agents_id)) {
|
||||
$agents_selected[$key] = $key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$data['select_agents'] = $select_agents;
|
||||
$data['agents_selected'] = $agents_selected;
|
||||
|
||||
$data['correct'] = 1;
|
||||
|
||||
if ($result === false) {
|
||||
$data['correct'] = 0;
|
||||
}
|
||||
|
||||
echo json_encode($data);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue