fixed errors select all agent where module common

This commit is contained in:
daniel 2018-03-02 12:55:03 +01:00
parent d5dc8c04e7
commit 78bb12f015
1 changed files with 63 additions and 51 deletions

View File

@ -490,13 +490,26 @@ if (is_ajax ()) {
asort($result);
}
else {
if(implode(',', $idAgents) < 0) {
$sql = 'SELECT DISTINCT nombre, id_agente_modulo FROM tagente_modulo
WHERE nombre IN (
SELECT nombre
if($idAgents[0] < 0){
if($selection_mode == 'common'){
$sql_agent_total = 'SELECT count(*) FROM tagente WHERE disabled=0';
$agent_total = db_get_value_sql($sql_agent_total);
$sql = "SELECT tam.nombre, tam.id_agente_modulo
FROM tagente_modulo tam
JOIN (
SELECT COUNT(*) AS num_names, nombre
FROM tagente_modulo
WHERE disabled=0
AND delete_pending=0
GROUP BY nombre
HAVING count(nombre) = (SELECT count(nombre) FROM tagente_modulo))';
) AS tj
ON tj.num_names = $agent_total
AND tj.nombre = tam.nombre ";
}
else{
$sql = 'SELECT nombre, id_agente_modulo
FROM tagente_modulo';
}
}
else {
$sql = 'SELECT DISTINCT nombre, id_agente_modulo
@ -517,10 +530,9 @@ if (is_ajax ()) {
$sql .= 'AND t1.id_agente_modulo IN (SELECT id_agente_modulo FROM tagente_estado where estado = 3 OR estado = 4)';
}
}
$sql .= ' ORDER BY nombre';
$nameModules = db_get_all_rows_sql($sql);
if ($tags != null) {
if ((count($tags) >= 1) && ($tags[0] != "") && ($tags[0] != -1)) {
$implode_tags = implode(",", $tags);