"; } else { echo "
"; } echo ""; echo ""; echo "
".__('Group').""; print_select_groups(false, "AR", true, "ag_group", $ag_group, 'this.form.submit();', '', 0); echo " "; echo __('Free text for search (*)'); echo ""; // Show group selector if (isset($_POST["ag_group"])) { $group_mod = "&ag_group_refresh=".get_parameter_post ("ag_group"); } else { $group_mod =""; } echo "
"; echo ""; echo "
"; echo ""; echo ""; echo ""; echo '
'; print_input_hidden ('new_agent', 1); print_submit_button (__('Create agent'), 'crt', false, 'class="sub next"'); echo "
"; echo "
"; $selected = 'border: 1px solid black;'; $selectNameUp = ''; $selectNameDown = ''; $selectOsUp = ''; $selectOsDown = ''; $selectGroupUp = ''; $selectGroupDown = ''; switch ($sortField) { case 'name': switch ($sort) { case 'up': $selectNameUp = $selected; $order = array('field' => 'nombre', 'order' => 'ASC'); break; case 'down': $selectNameDown = $selected; $order = array('field' => 'nombre', 'order' => 'DESC'); break; } break; case 'os': switch ($sort) { case 'up': $selectOsUp = $selected; $order = array('field' => 'id_os', 'order' => 'ASC'); break; case 'down': $selectOsDown = $selected; $order = array('field' => 'id_os', 'order' => 'DESC'); break; } break; case 'group': switch ($sort) { case 'up': $selectGroupUp = $selected; $order = array('field' => 'id_grupo', 'order' => 'ASC'); break; case 'down': $selectGroupDown = $selected; $order = array('field' => 'id_grupo', 'order' => 'DESC'); break; } break; default: $selectNameUp = $selected; $selectNameDown = ''; $selectOsUp = ''; $selectOsDown = ''; $selectGroupUp = ''; $selectGroupDown = ''; $order = array('field' => 'nombre', 'order' => 'ASC'); break; } $search_sql = ''; if ($search != ""){ $search_sql = " AND ( nombre COLLATE utf8_general_ci LIKE '%$search%' OR direccion LIKE '%$search%') "; } // Show only selected groups if ($ag_group > 0) { $sql = sprintf ('SELECT COUNT(*) FROM tagente WHERE id_grupo = %d %s', $ag_group, $search_sql); $total_agents = get_db_sql ($sql); $sql = sprintf ('SELECT * FROM tagente WHERE id_grupo = %d %s ORDER BY %s %s LIMIT %d, %d', $ag_group, $search_sql, $order['field'], $order['order'], $offset, $config["block_size"]); } else { // Admin user get ANY group, even if they doesnt exist if (check_acl ($config['id_user'], 0, "PM")){ $sql = sprintf ('SELECT COUNT(*) FROM tagente WHERE 1=1 %s', $search_sql); $total_agents = get_db_sql ($sql); $sql = sprintf ('SELECT * FROM tagente WHERE 1=1 %s ORDER BY %s %s LIMIT %d, %d', $search_sql, $order['field'], $order['order'], $offset, $config["block_size"]); } else { $sql = sprintf ('SELECT COUNT(*) FROM tagente WHERE id_grupo IN (%s) %s', implode (',', array_keys (get_user_groups ())), $search_sql); $total_agents = get_db_sql ($sql); $sql = sprintf ('SELECT * FROM tagente WHERE id_grupo IN (%s) %s ORDER BY %s %s LIMIT %d, %d', implode (',', array_keys (get_user_groups ())), $search_sql, $order['field'], $order['order'], $offset, $config["block_size"]); } } $agents = get_db_all_rows_sql ($sql); // Prepare pagination pagination ($total_agents, "index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id=$ag_group&search=$search&sort_field=$sortField&sort=$sort", $offset); echo "
"; if ($agents !== false) { echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; $color=1; $rowPair = true; $iterator = 0; foreach ($agents as $agent) { $id_grupo = $agent["id_grupo"]; if (! check_acl ($config["id_user"], $id_grupo, "AW")) continue; if ($color == 1) { $tdcolor = "datos"; $color = 0; } else { $tdcolor = "datos2"; $color = 1; } if ($rowPair) $rowclass = 'rowPair'; else $rowclass = 'rowOdd'; $rowPair = !$rowPair; $iterator++; // Agent name echo ""; echo ""; // Operating System icon echo ""; // Group icon and name echo ""; // Description echo ""; // Action //When there is only one element in page it's necesary go back page. if ((count($agents) == 1) && ($offset >= $config["block_size"])) $offsetArg = $offset - $config["block_size"]; else $offsetArg = $offset; echo ""; } echo "
".__('Agent name') . ' ' . '' . print_image("images/sort_up.png", true, array("style" => $selectNameUp)) . '' . '' . print_image("images/sort_down.png", true, array("style" => $selectNameDown)) . ''; echo "".__('R')."".__('OS'). ' ' . '' . print_image("images/sort_up.png", true, array("style" => $selectOsUp)) . '' . '' . print_image("images/sort_down.png", true, array("style" => $selectOsDown)) . ''; echo "".__('Group'). ' ' . '' . print_image("images/sort_up.png", true, array("style" => $selectGroupUp)) . '' . '' . print_image("images/sort_down.png", true, array("style" => $selectGroupDown)) . ''; echo "".__('Description')."".__('Delete')."
"; if ($agent["disabled"]) { echo ""; } echo ''; echo "".printTruncateText($agent["nombre"], 30, true).""; if ($agent["disabled"]) { print_help_tip(__('Disabled')); echo ""; } echo ''; echo ""; // Has remote configuration ? $agent_md5 = md5 ($agent["nombre"], false); if (file_exists ($config["remote_config"]."/md5/".$agent_md5.".md5")) { echo ""; echo print_image("images/application_edit.png", true, array("align" => 'middle', "title" => __('Edit remote config'))); echo ""; } echo ""; print_os_icon ($agent["id_os"], false); echo "".print_group_icon ($id_grupo, true)."".$agent["comentarios"]."'; echo print_image('images/cross.png', true, array("border" => '0')) . "
"; pagination ($total_agents, "index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id=$ag_group&search=$search&sort_field=$sortField&sort=$sort", $offset); echo "
"; } else { echo "
".__('There are no defined agents')."
"; echo " 
"; } // Create agent button echo ''; echo '
'; print_input_hidden ('new_agent', 1); print_submit_button (__('Create agent'), 'crt', false, 'class="sub next"'); echo "
"; ?>