diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 6c1339d84b..38c8085210 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,9 @@ +2009-10-06 Miguel de Dios + + * include/functions_agents.php: add the function "getNextAgentContact" + that return the percentage of time for next contanct of agent (pass as + id_agent). + 2009-10-06 Miguel de Dios * include/fgraph.php: lost in the last commit this file, fix the path for diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index d7e130378f..d487ce38e1 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -397,4 +397,26 @@ function process_manage_config ($source_id_agent, $destiny_id_agents, $copy_modu } process_sql ('SET AUTOCOMMIT = 1'); } + +function getNextAgentContact($idAgent, $maxModules = false) { + + $agent = get_db_row_sql("SELECT * FROM tagente WHERE id_agente = " . $idAgent); + + + $difference = get_system_time () - strtotime ($agent["ultimo_contacto"]); + + + $max = $agent["intervalo"]; + if ($maxModules) { + $sql = sprintf ("SELECT MAX(module_interval) FROM tagente_modulo WHERE id_agente = %d", $id_agente); + $maxModules = (int) get_db_sql ($sql); + if ($maxModules > 0) + $max = $maxModules; + } + + if ($max > 0) + return round ($difference / (($max * 2) / 100)); + else + return false; +} ?>