';
foreach ($custom_fields as $custom_field) {
$custom_field_value = '';
if (empty($ag_custom_fields) === false) {
$custom_field_value = $ag_custom_fields[$custom_field['id_field']];
if (empty($custom_field_value) === true) {
$custom_field_value = '';
}
}
$div_custom_fields .= '
';
$div_custom_fields .= '
';
$div_custom_fields .= ''.$custom_field['name'].'';
$div_custom_fields .= '
';
$div_custom_fields .= '
';
$div_custom_fields .= html_print_input_text(
'ag_custom_fields['.$custom_field['id_field'].']',
$custom_field_value,
'',
0,
300,
true,
false,
false,
'',
'div-input'
);
$div_custom_fields .= '
';
}
$table->colspan[2][0] = 2;
$table->data[2][0] = ui_toggle(
$div_custom_fields,
__('Agent custom fields'),
'',
'',
true,
true,
'',
'white-box-content',
'white_table_graph'
);
$buttons = html_print_submit_button(
__('Filter'),
'srcbutton',
false,
[
'icon' => 'search',
'mode' => 'mini',
],
true
);
$buttons .= html_print_button(
__('Load filter'),
'load-filter',
false,
'',
[
'icon' => 'load',
'mode' => 'mini secondary',
],
true
);
$buttons .= html_print_button(
__('Manage filter'),
'save-filter',
false,
'',
[
'icon' => 'wand',
'mode' => 'mini secondary',
],
true
);
$searchForm .= html_print_table($table, true);
$searchForm .= html_print_div(
[
'class' => 'action-buttons',
'content' => $buttons,
],
true
);
$searchForm .= '';
ui_toggle(
$searchForm,
'',
'filter_form',
'',
true,
false,
'',
'white-box-content',
'box-flat white_table_graph fixed_filter_bar'
);
if (empty($search) === false) {
$filter = ['string' => '%'.$search.'%'];
} else {
$filter = [];
}
$sortField = get_parameter('sort_field');
$sort = get_parameter('sort', 'none');
$selected = true;
$selectNameUp = false;
$selectNameDown = false;
$selectOsUp = false;
$selectOsDown = false;
$selectIntervalUp = false;
$selectIntervalDown = false;
$selectGroupUp = false;
$selectGroupDown = false;
$selectDescriptionUp = false;
$selectDescriptionDown = false;
$selectLastContactUp = false;
$selectLastContactDown = false;
$selectRemoteUp = false;
$selectRemoteDown = false;
$selectLastStatusChangeUp = false;
$selectLastStatusChangeDown = false;
$order = null;
switch ($sortField) {
case 'remote':
switch ($sort) {
case 'up':
$selectRemoteUp = $selected;
$order = [
'field' => 'remote',
'field2' => 'nombre',
'order' => 'ASC',
];
break;
case 'down':
$selectRemoteDown = $selected;
$order = [
'field' => 'remote',
'field2' => 'nombre',
'order' => 'DESC',
];
break;
default:
// Default.
break;
}
break;
case 'name':
switch ($sort) {
case 'up':
$selectNameUp = $selected;
$order = [
'field' => 'alias',
'field2' => 'alias',
'order' => 'ASC',
];
break;
case 'down':
$selectNameDown = $selected;
$order = [
'field' => 'alias',
'field2' => 'alias',
'order' => 'DESC',
];
break;
default:
// Default.
break;
}
break;
case 'os':
switch ($sort) {
case 'up':
$selectOsUp = $selected;
$order = [
'field' => 'id_os',
'field2' => 'alias',
'order' => 'ASC',
];
break;
case 'down':
$selectOsDown = $selected;
$order = [
'field' => 'id_os',
'field2' => 'alias',
'order' => 'DESC',
];
break;
default:
// Default.
break;
}
break;
case 'interval':
switch ($sort) {
case 'up':
$selectIntervalUp = $selected;
$order = [
'field' => 'intervalo',
'field2' => 'alias',
'order' => 'ASC',
];
break;
case 'down':
$selectIntervalDown = $selected;
$order = [
'field' => 'intervalo',
'field2' => 'alias',
'order' => 'DESC',
];
break;
default:
// Default.
break;
}
break;
case 'group':
switch ($sort) {
case 'up':
$selectGroupUp = $selected;
$order = [
'field' => 'id_grupo',
'field2' => 'alias',
'order' => 'ASC',
];
break;
case 'down':
$selectGroupDown = $selected;
$order = [
'field' => 'id_grupo',
'field2' => 'alias',
'order' => 'DESC',
];
break;
default:
// Default.
break;
}
break;
case 'last_contact':
switch ($sort) {
case 'up':
$selectLastContactUp = $selected;
$order = [
'field' => 'ultimo_contacto',
'field2' => 'alias',
'order' => 'DESC',
];
break;
case 'down':
$selectLastContactDown = $selected;
$order = [
'field' => 'ultimo_contacto',
'field2' => 'alias',
'order' => 'ASC',
];
break;
default:
// Default.
break;
}
break;
case 'last_status_change':
switch ($sort) {
case 'up':
$selectLastStatusChangeUp = $selected;
$order = [
'field' => 'last_status_change',
'field2' => 'alias',
'order' => 'ASC',
];
break;
case 'down':
$selectLastStatusChangeDown = $selected;
$order = [
'field' => 'last_status_change',
'field2' => 'alias',
'order' => 'DESC',
];
break;
default:
// Default.
break;
}
break;
case 'description':
switch ($sort) {
case 'up':
$selectDescriptionUp = $selected;
$order = [
'field' => 'comentarios',
'field2' => 'alias',
'order' => 'DESC',
];
break;
case 'down':
$selectDescriptionDown = $selected;
$order = [
'field' => 'comentarios',
'field2' => 'alias',
'order' => 'ASC',
];
break;
default:
// Default.
break;
}
break;
default:
$selectNameUp = $selected;
$selectNameDown = false;
$selectOsUp = false;
$selectOsDown = false;
$selectIntervalUp = false;
$selectIntervalDown = false;
$selectGroupUp = false;
$selectGroupDown = false;
$selectDescriptionUp = false;
$selectDescriptionDown = false;
$selectLastContactUp = false;
$selectLastContactDown = false;
$selectLastStatusChangeUp = false;
$selectLastStatusChangeDown = false;
$order = [
'field' => 'alias',
'field2' => 'alias',
'order' => 'ASC',
];
break;
}
$search_sql = '';
if ($search != '') {
$sql = sprintf(
'SELECT DISTINCT taddress_agent.id_agent FROM taddress
INNER JOIN taddress_agent ON
taddress.id_a = taddress_agent.id_a
WHERE taddress.ip LIKE "%%%s%%"',
$search
);
$id = db_get_all_rows_sql($sql);
if (empty($id) === false) {
$aux = $id[0]['id_agent'];
$search_sql = sprintf(
' AND ( `nombre` LIKE "%%%s%%" OR tagente.id_agente = %d',
$search,
$aux
);
$nagent_count = count($id);
if ($nagent_count >= 2) {
for ($i = 1; $i < $nagent_count; $i++) {
$aux = $id[$i]['id_agent'];
$search_sql .= sprintf(
' OR tagente.id_agente = %d',
$aux
);
}
}
$search_sql .= ')';
} else {
$search_sql = sprintf(
' AND ( nombre
LIKE "%%%s%%" OR alias
LIKE "%%%s%%" OR comentarios LIKE "%%%s%%"
OR EXISTS (SELECT * FROM tagent_custom_data WHERE id_agent = id_agente AND description LIKE "%%%s%%"))',
$search,
$search,
$search,
$search
);
}
}
if (empty($search_custom) === false) {
$search_sql_custom = " AND EXISTS (SELECT * FROM tagent_custom_data
WHERE id_agent = id_agente AND description LIKE '%$search_custom%')";
} else {
$search_sql_custom = '';
}
// Filter by agent custom fields.
$sql_conditions_custom_fields = '';
if (empty($ag_custom_fields) === false) {
$cf_filter = [];
foreach ($ag_custom_fields as $field_id => $value) {
if (empty($value) === false) {
$cf_filter[] = '(tagent_custom_data.id_field = '.$field_id.' AND tagent_custom_data.description LIKE \'%'.$value.'%\')';
}
}
if (empty($cf_filter) === false) {
$sql_conditions_custom_fields = ' AND tagente.id_agente IN (
SELECT tagent_custom_data.id_agent
FROM tagent_custom_data
WHERE '.implode(' AND ', $cf_filter).')';
}
}
// Show only selected groups.
if ($group_id > 0) {
$groups = [$group_id];
if ($recursion) {
$groups = groups_get_children_ids($group_id, true);
}
} else {
$groups = [];
$user_groups = users_get_groups($config['id_user'], $access);
$groups = array_keys($user_groups);
}
$all_policies = in_array(0, ($policies ?? []));
$id_os_sql = '';
$policies_sql = '';
if ($os > 0) {
$id_os_sql = ' AND id_os = '.$os;
}
if ($all_policies === false && is_array($policies) && count($policies) > 0) {
$policies_sql = ' AND tpolicy_agents.id_policy IN ('.implode(',', $policies).')';
}
if ($strict_user) {
$count_filter = [
// 'order' => 'tagente.nombre ASC',
'order' => 'tagente.nombre ASC',
'disabled' => 0,
'status' => $status,
'search' => $search,
'id_os' => $id_os_sql,
'policies' => $policies_sql,
'other_condition' => $sql_conditions_custom_fields,
];
$filter = [
// 'order' => 'tagente.nombre ASC',
'order' => 'tagente.nombre ASC',
'disabled' => 0,
'status' => $status,
'search' => $search,
'offset' => (int) get_parameter('offset'),
'limit' => (int) $config['block_size'],
'id_os' => $id_os_sql,
'policies' => $policies_sql,
'other_condition' => $sql_conditions_custom_fields,
];
if ($group_id > 0) {
$groups = [$group_id];
if ($recursion) {
$groups = groups_get_children_ids($group_id, true);
}
$filter['id_group'] = implode(',', $groups);
$count_filter['id_group'] = $filter['id_group'];
}
$fields = [
'tagente.id_agente',
'tagente.id_grupo',
'tagente.id_os',
'tagente.ultimo_contacto',
'tagente.intervalo',
'tagente.comentarios description',
'tagente.quiet',
'tagente.normal_count',
'tagente.warning_count',
'tagente.critical_count',
'tagente.unknown_count',
'tagente.notinit_count',
'tagente.total_count',
'tagente.fired_count',
'tagente.nombre',
'tagente.alias',
];
$acltags = tags_get_user_groups_and_tags($config['id_user'], $access, $strict_user);
$total_agents = tags_get_all_user_agents(false, $config['id_user'], $acltags, $count_filter, $fields, false, $strict_user, true);
$total_agents = count($total_agents);
$agents = tags_get_all_user_agents(false, $config['id_user'], $acltags, $filter, $fields, false, $strict_user, true);
} else {
$count_filter = [
'disabled' => 0,
'id_grupo' => $groups,
'search' => $search_sql,
'search_custom' => $search_sql_custom,
'status' => $status,
'id_os' => $id_os_sql,
'policies' => $policies_sql,
'other_condition' => $sql_conditions_custom_fields,
];
$filter = [
'order' => 'nombre ASC',
'id_grupo' => $groups,
'disabled' => 0,
'status' => $status,
'search_custom' => $search_sql_custom,
'search' => $search_sql,
'offset' => (int) get_parameter('offset'),
'limit' => (int) $config['block_size'],
'id_os' => $id_os_sql,
'policies' => $policies_sql,
'other_condition' => $sql_conditions_custom_fields,
];
$total_agents = agents_count_agents_filter(
$count_filter,
$access
);
$query_order = $order;
if ($order['field'] === 'last_status_change') {
$query_order = [
'field' => 'alias',
'field2' => 'alias',
'order' => 'ASC',
];
}
$agents = agents_get_agents(
$filter,
[
'id_agente',
'id_grupo',
'nombre',
'alias',
'id_os',
'ultimo_contacto',
'intervalo',
'comentarios description',
'quiet',
'normal_count',
'warning_count',
'critical_count',
'unknown_count',
'notinit_count',
'total_count',
'fired_count',
'ultimo_contacto_remoto',
'remote',
'agent_version',
],
$access,
$query_order
);
}
if (empty($agents)) {
$agents = [];
}
if ($config['language'] === 'ja'
|| $config['language'] === 'zh_CN'
|| $own_info['language'] === 'ja'
|| $own_info['language'] === 'zh_CN'
) {
// Adds a custom font size for Japanese and Chinese language.
$custom_font_size = 'custom_font_size';
} else {
$custom_font_size = '';
}
// Urls to sort the table.
$url_up_agente = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr='.$refr.'&offset='.$offset.'&group_id='.$group_id.'&recursion='.$recursion.'&search='.$search.'&status='.$status.'&sort_field=name&sort=up';
$url_down_agente = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr='.$refr.'&offset='.$offset.'&group_id='.$group_id.'&recursion='.$recursion.'&search='.$search.'&status='.$status.'&sort_field=name&sort=down';
$url_up_description = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr='.$refr.'&offset='.$offset.'&group_id='.$group_id.'&recursion='.$recursion.'&search='.$search.'&status='.$status.'&sort_field=description&sort=up';
$url_down_description = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr='.$refr.'&offset='.$offset.'&group_id='.$group_id.'&recursion='.$recursion.'&search='.$search.'&status='.$status.'&sort_field=description&sort=down';
$url_up_remote = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr='.$refr.'&offset='.$offset.'&group_id='.$group_id.'&recursion='.$recursion.'&search='.$search.'&status='.$status.'&sort_field=remote&sort=up';
$url_down_remote = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr='.$refr.'&offset='.$offset.'&group_id='.$group_id.'&recursion='.$recursion.'&search='.$search.'&status='.$status.'&sort_field=remote&sort=down';
$url_up_os = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr='.$refr.'&offset='.$offset.'&group_id='.$group_id.'&recursion='.$recursion.'&search='.$search.'&status='.$status.'&sort_field=os&sort=up';
$url_down_os = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr='.$refr.'&offset='.$offset.'&group_id='.$group_id.'&recursion='.$recursion.'&search='.$search.'&status='.$status.'&sort_field=os&sort=down';
$url_up_interval = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr='.$refr.'&offset='.$offset.'&group_id='.$group_id.'&recursion='.$recursion.'&search='.$search.'&status='.$status.'&sort_field=interval&sort=up';
$url_down_interval = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr='.$refr.'&offset='.$offset.'&group_id='.$group_id.'&recursion='.$recursion.'&search='.$search.'&status='.$status.'&sort_field=interval&sort=down';
$url_up_group = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr='.$refr.'&offset='.$offset.'&group_id='.$group_id.'&recursion='.$recursion.'&search='.$search.'&status='.$status.'&sort_field=group&sort=up';
$url_down_group = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr='.$refr.'&offset='.$offset.'&group_id='.$group_id.'&recursion='.$recursion.'&search='.$search.'&status='.$status.'&sort_field=group&sort=down';
$url_up_last = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr='.$refr.'&offset='.$offset.'&group_id='.$group_id.'&recursion='.$recursion.'&search='.$search.'&status='.$status.'&sort_field=last_contact&sort=up';
$url_down_last = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr='.$refr.'&offset='.$offset.'&group_id='.$group_id.'&recursion='.$recursion.'&search='.$search.'&status='.$status.'&sort_field=last_contact&sort=down';
$url_up_last_status_change = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr='.$refr.'&offset='.$offset.'&group_id='.$group_id.'&recursion='.$recursion.'&search='.$search.'&status='.$status.'&sort_field=last_status_change&sort=up';
$url_down_last_status_change = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr='.$refr.'&offset='.$offset.'&group_id='.$group_id.'&recursion='.$recursion.'&search='.$search.'&status='.$status.'&sort_field=last_status_change&sort=down';
// Show data.
$tableAgents = new stdClass();
$tableAgents->cellpadding = 0;
$tableAgents->cellspacing = 0;
$tableAgents->id = 'agent_list';
$tableAgents->class = 'info_table tactical_table';
$tableAgents->head = [];
$tableAgents->head[0] = '
'.__('Agent').'';
$tableAgents->head[0] .= ui_get_sorting_arrows($url_up_agente, $url_down_agente, $selectNameUp, $selectNameDown);
$tableAgents->size[0] = '10%';
$tableAgents->head[1] = '
'.__('Description').'';
$tableAgents->head[1] .= ui_get_sorting_arrows($url_up_description, $url_down_description, $selectDescriptionUp, $selectDescriptionDown);
$tableAgents->size[1] = '14%';
$tableAgents->head[2] = '
'.__('OS').'';
$tableAgents->head[2] .= ui_get_sorting_arrows($url_up_os, $url_down_os, $selectOsUp, $selectOsDown);
$tableAgents->size[2] = '5%';
$tableAgents->head[3] = '
'.__('Interval').'';
$tableAgents->head[3] .= ui_get_sorting_arrows($url_up_interval, $url_down_interval, $selectIntervalUp, $selectIntervalDown);
$tableAgents->size[3] = '7%';
$tableAgents->head[4] = '
'.__('Group').'';
$tableAgents->head[4] .= ui_get_sorting_arrows($url_up_group, $url_down_group, $selectGroupUp, $selectGroupDown);
$tableAgents->size[4] = '7%';
$tableAgents->head[5] = '
'.__('Type').'';
$tableAgents->size[5] = '7%';
$tableAgents->head[6] = '
'.__('Modules').'';
$tableAgents->size[6] = '7%';
$tableAgents->head[7] = '
'.__('Status').'';
$tableAgents->size[7] = '4%';
$tableAgents->head[8] = '
'.__('Alerts').'';
$tableAgents->size[8] = '4%';
$tableAgents->head[9] = '
'.__('Last contact').'';
$tableAgents->head[9] .= ui_get_sorting_arrows($url_up_last, $url_down_last, $selectLastContactUp, $selectLastContactDown);
$tableAgents->size[9] = '7%';
$tableAgents->head[10] = '
'.__('L.S change').'';
$tableAgents->head[10] .= ui_get_sorting_arrows($url_up_last_status_change, $url_down_last_status_change, $selectLastStatusChangeUp, $selectLastStatusChangeDown);
$tableAgents->size[10] = '8%';
$tableAgents->head[11] = '
'.__('Op').'';
$tableAgents->size[11] = '6%';
$tableAgents->align = [];
$tableAgents->align[2] = 'left';
$tableAgents->align[3] = 'left';
$tableAgents->align[4] = 'left';
$tableAgents->align[5] = 'left';
$tableAgents->align[6] = 'left';
$tableAgents->align[7] = 'left';
$tableAgents->align[8] = 'left';
$tableAgents->align[9] = 'left';
$tableAgents->align[10] = 'left';
$tableAgents->style = [];
$tableAgents->data = [];
$tableAgents->cellclass = [];
$rowPair = true;
$iterator = 0;
foreach ($agents as $agent) {
$cluster = db_get_row_sql('select id from tcluster where id_agent = '.$agent['id_agente']);
if ($rowPair) {
$tableAgents->rowclass[$iterator] = 'rowPair';
} else {
$tableAgents->rowclass[$iterator] = 'rowOdd';
}
$rowPair = !$rowPair;
$iterator++;
$alert_img = agents_tree_view_alert_img($agent['fired_count']);
$status_img = agents_tree_view_status_img(
$agent['critical_count'],
$agent['warning_count'],
$agent['unknown_count'],
$agent['total_count'],
$agent['notinit_count']
);
$in_planned_downtime = db_get_sql(
'SELECT executed FROM tplanned_downtime
INNER JOIN tplanned_downtime_agents
ON tplanned_downtime.id = tplanned_downtime_agents.id_downtime
WHERE tplanned_downtime_agents.id_agent = '.$agent['id_agente'].' AND tplanned_downtime.executed = 1'
);
$data = [];
$data[0] = '
';
if ($agent['id_os'] == CLUSTER_OS_ID) {
$cluster = PandoraFMS\Cluster::loadFromAgentId(
$agent['id_agente']
);
$url = 'index.php?sec=reporting&sec2=';
$url .= 'operation/cluster/cluster';
$url = ui_get_full_url(
$url.'&op=view&id='.$cluster->id()
);
} else {
$url = 'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent['id_agente'];
}
$data[0] .= html_print_anchor(
[
'href' => ui_get_full_url($url),
'content' => ui_print_truncate_text($agent['alias'], 'agent_medium', false, true, true),
],
true
);
if ($agent['quiet']) {
$data[0] .= ' ';
$data[0] .= html_print_image(
'images/dot_blue.png',
true,
[
'border' => '0',
'title' => __('Quiet'),
'alt' => '',
]
);
}
if ($in_planned_downtime) {
$data[0] .= ui_print_help_tip(
__('Agent in scheduled downtime'),
true,
'images/clock.svg'
);
$data[0] .= '';
}
$data[0] .= '
';
$data[1] = '
'.ui_print_truncate_text($agent['description'], 'description', false, true, true, '[…]').'';
$data[2] = '';
$data[2] = html_print_div(
[
'class' => 'invert_filter main_menu_icon',
'content' => ui_print_os_icon($agent['id_os'], false, true),
],
true
);
$data[3] = '
'.human_time_description_raw(
$agent['intervalo']
).'';
$data[4] = '
';
$data[4] .= ui_print_group_icon(
$agent['id_grupo'],
true,
'groups_small',
'',
false,
false,
false,
'invert_filter main_menu_icon'
);
$data[4] .= '';
$agent['not_init_count'] = $agent['notinit_count'];
$data[5] = ui_print_type_agent_icon(
$agent['id_os'],
$agent['ultimo_contacto_remoto'],
$agent['ultimo_contacto'],
$agent['remote'],
$agent['agent_version']
);
if (enterprise_installed()) {
enterprise_include_once('include/functions_config_agents.php');
if (enterprise_hook('config_agents_has_remote_configuration', [$agent['id_agente']])) {
$data[5] .= '
'.html_print_image(
'images/remote-configuration@svg.svg',
true,
[
'align' => 'middle',
'title' => __('Remote config'),
'class' => 'invert_filter main_menu_icon',
]
).'';
}
}
$data[6] = reporting_tiny_stats($agent, true, 'modules', ':', $strict_user);
$data[7] = $status_img;
$data[8] = $alert_img;
$data[9] = agents_get_interval_status($agent);
$last_status_change_agent = agents_get_last_status_change($agent['id_agente']);
$time_elapsed = !empty($last_status_change_agent) ? human_time_comparation($last_status_change_agent) : '
'.__('N/A').'';
$data[10] = $time_elapsed;
$agent_event_filter = [
'id_agent' => $agent['id_agente'],
'event_view_hr' => 48,
'status' => -1,
];
$fb64 = base64_encode(json_encode($agent_event_filter));
$tableAgents->cellclass[][11] = 'table_action_buttons';
$data[11] = '
'.html_print_image(
'images/event.svg',
true,
[
'align' => 'middle',
'title' => __('Agent events'),
'class' => 'main_menu_icon invert_filter',
]
).'';
if (check_acl($config['id_user'], $agent['id_grupo'], 'AW')) {
if ($agent['id_os'] == CLUSTER_OS_ID) {
$cluster = PandoraFMS\Cluster::loadFromAgentId(
$agent['id_agente']
);
$url = 'index.php?sec=reporting&sec2=';
$url .= 'operation/cluster/cluster';
$url = ui_get_full_url(
$url.'&op=update&id='.$cluster->id()
);
} else {
$url = 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$agent['id_agente'];
}
$data[11] .= '
'.html_print_image(
'images/edit.svg',
true,
[
'align' => 'middle',
'title' => __('Edit'),
'class' => 'main_menu_icon invert_filter',
]
).'';
}
array_push($tableAgents->data, $data);
}
if (empty($tableAgents->data) === false) {
if ($order['field'] === 'last_status_change') {
$order_direction = $order['order'];
usort(
$table->data,
function ($a, $b) use ($order_direction) {
if ($order_direction === 'ASC') {
return strtotime($a[10]) > strtotime($b[10]);
} else {
return strtotime($a[10]) < strtotime($b[10]);
}
}
);
}
html_print_table($tableAgents);
$tablePagination = ui_pagination(
$total_agents,
ui_get_url_refresh(
[
'group_id' => $group_id,
'search' => $search,
'sort_field' => $sortField,
'sort' => $sort,
'status' => $status,
]
),
0,
0,
true,
'offset',
false,
'dataTables_paginate paging_simple_numbers'
);
unset($table);
} else {
ui_print_info_message([ 'no_close' => true, 'message' => __('There are no defined agents') ]);
$tablePagination = '';
}
if ((bool) check_acl($config['id_user'], 0, 'AW') === true || (bool) check_acl($config['id_user'], 0, 'AM') === true) {
echo '
';
}
// Load filter div for dialog.
echo '
';
echo '
';
?>