Merge branch '3044-Visualización-rara-en-agent-view' into 'develop'

Changed ORDER BY in SQL query - #3044

See merge request artica/pandorafms!1938
This commit is contained in:
vgilc 2018-11-30 11:02:14 +01:00
commit 3cbb75b551
1 changed files with 24 additions and 10 deletions

View File

@ -472,16 +472,17 @@ if ($list_modules) {
$sort = get_parameter('sort', 'none');
$selected = 'border: 1px solid black;';
$order[] = array('field' => 'tmodule_group.name', 'order' => 'ASC');
switch ($sortField) {
case 'type':
switch ($sort) {
case 'up':
$selectTypeUp = $selected;
$order = array('field' => 'tagente_modulo.id_modulo', 'order' => 'ASC');
$order[] = array('field' => 'tagente_modulo.id_modulo', 'order' => 'ASC');
break;
case 'down':
$selectTypeDown = $selected;
$order = array('field' => 'tagente_modulo.id_modulo', 'order' => 'DESC');
$order[] = array('field' => 'tagente_modulo.id_modulo', 'order' => 'DESC');
break;
}
break;
@ -489,11 +490,11 @@ if ($list_modules) {
switch ($sort) {
case 'up':
$selectNameUp = $selected;
$order = array('field' => 'tagente_modulo.nombre', 'order' => 'ASC');
$order[] = array('field' => 'tagente_modulo.nombre', 'order' => 'ASC');
break;
case 'down':
$selectNameDown = $selected;
$order = array('field' => 'tagente_modulo.nombre', 'order' => 'DESC');
$order[] = array('field' => 'tagente_modulo.nombre', 'order' => 'DESC');
break;
}
break;
@ -501,11 +502,11 @@ if ($list_modules) {
switch ($sort) {
case 'up':
$selectStatusUp = $selected;
$order = array('field' => 'tagente_estado.estado=0 DESC,tagente_estado.estado=3 DESC,tagente_estado.estado=2 DESC,tagente_estado.estado=1 DESC', 'order' => '');
$order[] = array('field' => 'tagente_estado.estado=0 DESC,tagente_estado.estado=3 DESC,tagente_estado.estado=2 DESC,tagente_estado.estado=1 DESC', 'order' => '');
break;
case 'down':
$selectStatusDown = $selected;
$order = array('field' => 'tagente_estado.estado=1 DESC,tagente_estado.estado=2 DESC,tagente_estado.estado=3 DESC,tagente_estado.estado=0 DESC', 'order' => '');
$order[] = array('field' => 'tagente_estado.estado=1 DESC,tagente_estado.estado=2 DESC,tagente_estado.estado=3 DESC,tagente_estado.estado=0 DESC', 'order' => '');
break;
}
break;
@ -513,11 +514,11 @@ if ($list_modules) {
switch ($sort) {
case 'up':
$selectLastContactUp = $selected;
$order = array('field' => 'tagente_estado.utimestamp', 'order' => 'ASC');
$order[] = array('field' => 'tagente_estado.utimestamp', 'order' => 'ASC');
break;
case 'down':
$selectLastContactDown = $selected;
$order = array('field' => 'tagente_estado.utimestamp', 'order' => 'DESC');
$order[] = array('field' => 'tagente_estado.utimestamp', 'order' => 'DESC');
break;
}
break;
@ -533,7 +534,7 @@ if ($list_modules) {
$selectLastContactUp = '';
$selectLastContactDown = '';
$order = array('field' => 'tagente_modulo.nombre', 'order' => 'ASC');
$order[] = array('field' => 'tagente_modulo.nombre', 'order' => 'ASC');
break;
}
@ -588,7 +589,20 @@ if ($list_modules) {
}
//Count monitors/modules
$order_sql = $order['field'] . " " . $order['order'];
// Build the order sql
$first = true;
foreach ($order as $ord) {
if ($first) {
$first = false;
}
else {
$order_sql .= ',';
}
$order_sql .= $ord['field'].' '.$ord['order'];
}
$sql_condition = "FROM tagente_modulo
$tags_join
INNER JOIN tagente_estado