Added agent description to search and agent detail

This commit is contained in:
Luis Calvo 2020-03-31 20:02:28 +02:00
parent aee22eaf35
commit e575f65b6a
3 changed files with 48 additions and 16 deletions

View File

@ -521,7 +521,9 @@ if ($search != '') {
$search_sql .= ')';
} else {
$search_sql = ' AND ( nombre '.$order_collation."
COLLATE utf8_general_ci LIKE '%$search%' OR alias ".$order_collation." COLLATE utf8_general_ci LIKE '%$search%') ";
COLLATE utf8_general_ci LIKE '%$search%'
OR comentarios ".$order_collation." COLLATE utf8_general_ci LIKE '%$search%'
OR alias ".$order_collation." COLLATE utf8_general_ci LIKE '%$search%') ";
}
}

View File

@ -20,6 +20,8 @@ $searchAgents = check_acl($config['id_user'], 0, 'AR');
$selectNameUp = '';
$selectNameDown = '';
$selectDescriptionUp = '';
$selectDescriptionDown = '';
$selectOsUp = '';
$selectOsDown = '';
$selectIntervalUp = '';
@ -50,6 +52,26 @@ switch ($sortField) {
}
break;
case 'comentarios':
switch ($sort) {
case 'up':
$selectDescriptionUp = $selected;
$order = [
'field' => 'comentarios',
'order' => 'ASC',
];
break;
case 'down':
$selectDescriptionDown = $selected;
$order = [
'field' => 'comentarios',
'order' => 'DESC',
];
break;
}
break;
case 'os':
switch ($sort) {
case 'up':
@ -133,6 +155,8 @@ switch ($sortField) {
default:
$selectNameUp = $selected;
$selectNameDown = '';
$selectDescriptionUp = '';
$selectDescriptionDown = '';
$selectOsUp = '';
$selectOsDown = '';
$selectIntervalUp = '';
@ -165,7 +189,8 @@ if ($searchAgents) {
$aux = $id[0]['id_agent'];
$search_sql = " t1.nombre COLLATE utf8_general_ci LIKE '%%cd ".$stringSearchSQL."%%' OR
t2.nombre COLLATE utf8_general_ci LIKE '%%".$stringSearchSQL."%%' OR
t1.alias COLLATE utf8_general_ci LIKE '%%".$stringSearchSQL."%%' OR
t1.alias COLLATE utf8_general_ci LIKE '%%".$stringSearchSQL."%%' OR
t1.comentarios COLLATE utf8_general_ci LIKE '%%".$stringSearchSQL."%%' OR
t1.id_agente = $aux";
if (count($id) >= 2) {
@ -177,7 +202,8 @@ if ($searchAgents) {
} else {
$search_sql = " t1.nombre COLLATE utf8_general_ci LIKE '%%".$stringSearchSQL."%%' OR
t2.nombre COLLATE utf8_general_ci LIKE '%%".$stringSearchSQL."%%' OR
t1.direccion COLLATE utf8_general_ci LIKE '%%".$stringSearchSQL."%%' OR
t1.direccion COLLATE utf8_general_ci LIKE '%%".$stringSearchSQL."%%' OR
t1.comentarios COLLATE utf8_general_ci LIKE '%%".$stringSearchSQL."%%' OR
t1.alias COLLATE utf8_general_ci LIKE '%%".$stringSearchSQL."%%'";
}
@ -211,7 +237,7 @@ if ($searchAgents) {
)
';
$select = 'SELECT DISTINCT(t1.id_agente), t1.ultimo_contacto, t1.nombre, t1.id_os, t1.intervalo, t1.id_grupo, t1.disabled, t1.alias, t1.quiet';
$select = 'SELECT DISTINCT(t1.id_agente), t1.ultimo_contacto, t1.nombre, t1.comentarios, t1.id_os, t1.intervalo, t1.id_grupo, t1.disabled, t1.alias, t1.quiet';
if ($only_count) {
$limit = ' ORDER BY '.$order['field'].' '.$order['order'].' LIMIT '.$config['block_size'].' OFFSET 0';
} else {

View File

@ -39,21 +39,23 @@ if (!$agents || !$searchAgents) {
$table->head = [];
if ($only_count) {
$table->head[0] = __('Agent');
$table->head[1] = __('OS');
$table->head[2] = __('Interval');
$table->head[3] = __('Group');
$table->head[1] = __('Description');
$table->head[2] = __('OS');
$table->head[3] = __('Interval');
$table->head[4] = __('Group');
} else {
$table->head[0] = __('Agent').' '.'<a href="index.php?search_category=agents&keywords='.$config['search_keywords'].'&head_search_keywords=abc&offset='.$offset.'&sort_field=name&sort=up">'.html_print_image('images/sort_up.png', true, ['style' => $selectNameUp]).'</a>'.'<a href="index.php?search_category=agents&keywords='.$config['search_keywords'].'&head_search_keywords=abc&offset='.$offset.'&sort_field=name&sort=down">'.html_print_image('images/sort_down.png', true, ['style' => $selectNameDown]).'</a>';
$table->head[1] = __('OS').' '.'<a href="index.php?search_category=agents&keywords='.$config['search_keywords'].'&head_search_keywords=abc&offset='.$offset.'&sort_field=os&sort=up">'.html_print_image('images/sort_up.png', true, ['style' => $selectOsUp]).'</a>'.'<a href="index.php?search_category=agents&keywords='.$config['search_keywords'].'&head_search_keywords=abc&offset='.$offset.'&sort_field=os&sort=down">'.html_print_image('images/sort_down.png', true, ['style' => $selectOsDown]).'</a>';
$table->head[2] = __('Interval').' '.'<a href="index.php?search_category=agents&keywords='.$config['search_keywords'].'&head_search_keywords=abc&offset='.$offset.'&sort_field=interval&sort=up">'.html_print_image('images/sort_up.png', true, ['style' => $selectIntervalUp]).'</a>'.'<a href="index.php?search_category=agents&keywords='.$config['search_keywords'].'&head_search_keywords=abc&offset='.$offset.'&sort_field=interval&sort=down">'.html_print_image('images/sort_down.png', true, ['style' => $selectIntervalDown]).'</a>';
$table->head[3] = __('Group').' '.'<a href="index.php?search_category=agents&keywords='.$config['search_keywords'].'&head_search_keywords=abc&offset='.$offset.'&sort_field=group&sort=up">'.html_print_image('images/sort_up.png', true, ['style' => $selectGroupUp]).'</a>'.'<a href="index.php?search_category=agents&keywords='.$config['search_keywords'].'&head_search_keywords=abc&offset='.$offset.'&sort_field=group&sort=down">'.html_print_image('images/sort_down.png', true, ['style' => $selectGroupDown]).'</a>';
$table->head[1] = __('Description').' '.'<a href="index.php?search_category=agents&keywords='.$config['search_keywords'].'&head_search_keywords=abc&offset='.$offset.'&sort_field=comentarios&sort=up">'.html_print_image('images/sort_up.png', true, ['style' => $selectDescriptionUp]).'</a>'.'<a href="index.php?search_category=agents&keywords='.$config['search_keywords'].'&head_search_keywords=abc&offset='.$offset.'&sort_field=comentarios&sort=down">'.html_print_image('images/sort_down.png', true, ['style' => $selectDescriptionDown]).'</a>';
$table->head[2] = __('OS').' '.'<a href="index.php?search_category=agents&keywords='.$config['search_keywords'].'&head_search_keywords=abc&offset='.$offset.'&sort_field=os&sort=up">'.html_print_image('images/sort_up.png', true, ['style' => $selectOsUp]).'</a>'.'<a href="index.php?search_category=agents&keywords='.$config['search_keywords'].'&head_search_keywords=abc&offset='.$offset.'&sort_field=os&sort=down">'.html_print_image('images/sort_down.png', true, ['style' => $selectOsDown]).'</a>';
$table->head[3] = __('Interval').' '.'<a href="index.php?search_category=agents&keywords='.$config['search_keywords'].'&head_search_keywords=abc&offset='.$offset.'&sort_field=interval&sort=up">'.html_print_image('images/sort_up.png', true, ['style' => $selectIntervalUp]).'</a>'.'<a href="index.php?search_category=agents&keywords='.$config['search_keywords'].'&head_search_keywords=abc&offset='.$offset.'&sort_field=interval&sort=down">'.html_print_image('images/sort_down.png', true, ['style' => $selectIntervalDown]).'</a>';
$table->head[4] = __('Group').' '.'<a href="index.php?search_category=agents&keywords='.$config['search_keywords'].'&head_search_keywords=abc&offset='.$offset.'&sort_field=group&sort=up">'.html_print_image('images/sort_up.png', true, ['style' => $selectGroupUp]).'</a>'.'<a href="index.php?search_category=agents&keywords='.$config['search_keywords'].'&head_search_keywords=abc&offset='.$offset.'&sort_field=group&sort=down">'.html_print_image('images/sort_down.png', true, ['style' => $selectGroupDown]).'</a>';
}
$table->head[4] = __('Modules');
$table->head[5] = __('Status');
$table->head[6] = __('Alerts');
$table->head[7] = __('Last contact').' '.'<a href="index.php?search_category=agents&keywords='.$config['search_keywords'].'&head_search_keywords=abc&offset='.$offset.'&sort_field=last_contact&sort=up">'.html_print_image('images/sort_up.png', true, ['style' => $selectLastContactUp]).'</a>'.'<a href="index.php?search_category=agents&keywords='.$config['search_keywords'].'&head_search_keywords=abc&offset='.$offset.'&sort_field=last_contact&sort=down">'.html_print_image('images/sort_down.png', true, ['style' => $selectLastContactDown]).'</a>';
$table->head[8] = '';
$table->head[5] = __('Modules');
$table->head[6] = __('Status');
$table->head[7] = __('Alerts');
$table->head[8] = __('Last contact').' '.'<a href="index.php?search_category=agents&keywords='.$config['search_keywords'].'&head_search_keywords=abc&offset='.$offset.'&sort_field=last_contact&sort=up">'.html_print_image('images/sort_up.png', true, ['style' => $selectLastContactUp]).'</a>'.'<a href="index.php?search_category=agents&keywords='.$config['search_keywords'].'&head_search_keywords=abc&offset='.$offset.'&sort_field=last_contact&sort=down">'.html_print_image('images/sort_down.png', true, ['style' => $selectLastContactDown]).'</a>';
$table->head[9] = '';
$table->align = [];
$table->align[0] = 'left';
@ -64,7 +66,8 @@ if (!$agents || !$searchAgents) {
$table->align[5] = 'left';
$table->align[6] = 'left';
$table->align[7] = 'left';
$table->align[8] = 'center';
$table->align[8] = 'left';
$table->align[9] = 'center';
$table->data = [];
@ -116,6 +119,7 @@ if (!$agents || !$searchAgents) {
$table->data,
[
$cellName,
ui_print_truncate_text($agent['comentarios'], 'comentarios', false, true, true, '[&hellip;]'),
ui_print_os_icon($agent['id_os'], false, true),
human_time_description_raw($agent['intervalo'], false, 'tiny'),
ui_print_group_icon($agent['id_grupo'], true),