= '$start_date'
AND timestamp <= '$end_date'";
if (($resq1 = mysql_query($query1)) AND ($row=mysql_fetch_array($resq1)))
return $row[0];
else
return 0;
}
function generate_average_table ($id_de_mi_agente, $id_agente_modulo, $fecha_inicio, $fecha_fin){
// Genera una tabla con los promedios de los datos de un módulo no-string
require ("include/config.php");
$dias_de_la_semana = array (__('Sunday'),__('Monday'), __('Tuesday'), __('Wednesday'), __('Thurdsday'), __('Friday'), __('Saturday'));
$nombre_modulo = get_agentmodule_name ($id_agente_modulo);
// Table header
echo "
";
echo "
".__('One hour')." | ";
echo "".__('day')." |
";
echo "";
for ($dia=0;$dia<7;++$dia)
echo "".$dias_de_la_semana[$dia]." | ";
echo "
";
$color = 0;
for ($hora=0;$hora<24;++$hora){
if ($color == 1){
$tdcolor = "datos";
$color = 0;
} else {
$tdcolor = "datos2";
$color = 1;
}
echo " $hora ".__('Hr')." | ";
for ($dia=0; $dia<7; ++$dia){
echo "";
echo format_numeric (give_average_from_module ($id_de_mi_agente, $id_agente_modulo, $hora, $dia, $fecha_inicio, $fecha_fin));
echo " | ";
}
echo "
";
}
echo "
";
}
if ((isset($_POST["export"])) AND (! isset($_POST["update_agent"]))){
if (isset($_POST["export_type"]))
$export_type = $_POST["export_type"];
else
$export_type = 3; // Standard table;
// Header
echo "".__('Pandora Agents')." > ";
echo __('Database export results')."
";
if ($export_type == 1) { // CSV
if (isset ($_POST["origen_modulo"])){
$origen = $_POST["origen"];
if (! give_acl ($config['id_user'], dame_id_grupo ($origen), "AR")) {
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation",
"Trying to access Agent Export Data");
require ("general/noaccess.php");
}
$origen_modulo = $_POST["origen_modulo"];
$id_agentemodulo = $origen_modulo[0];
$start_date =$_POST["start_date"];
$end_date=$_POST["end_date"];
$start_time =$_POST["start_time"];
$end_time=$_POST["end_time"];
$from_date = $start_date." ".$start_time;
$to_date = $end_date." ".$end_time;
$agentmodule_name = get_agentmodule_name ($origen_modulo[0]);
echo __('Data from agent '). "" . get_agent_name($origen). "- $agentmodule_name ". __('from'). " ". $from_date. " ". __('to'). " ". $to_date. "
";
echo " ".__('Download file')." pandora_export_$agentmodule_name.txt";
} else
echo "".__('No module has been selected')."";
}
if ($export_type == 2){ // Avarage day/hour matrix
if (isset ($_POST["origen_modulo"])){
$origen = $_POST["origen"];
$origen_modulo = $_POST["origen_modulo"];
$start_date =$_POST["start_date"];
$end_date=$_POST["end_date"];
$start_time =$_POST["start_time"];
$end_time=$_POST["end_time"];
$agentmodule_name = get_agentmodule_name ($origen_modulo[0]);
$from_date = $start_date." ".$start_time;
$to_date = $end_date." ".$end_time;
echo __('Data from agent '). "" . get_agent_name ($origen). "- $agentmodule_name ". __('from'). " ". $from_date. " ". __('to'). " ". $to_date. "
";
echo "
";
// For each module
for ($a=0;$a ". generate_average_table ($origen,$id_modulo,$from_date,$to_date);
}
}
}
if ($export_type == 3) { // Standard table
if (isset ($_POST["origen_modulo"])){
$origen = $_POST["origen"];
if (! give_acl ($config['id_user'], dame_id_grupo ($origen), "AR")) {
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation",
"Trying to access Agent Export Data");
require ("general/noaccess.php");
}
$origen_modulo = $_POST["origen_modulo"];
$agentmodule_name = get_agentmodule_name ($origen_modulo[0]);
$start_date =$_POST["start_date"];
$end_date=$_POST["end_date"];
$start_time =$_POST["start_time"];
$end_time=$_POST["end_time"];
$from_date = $start_date." ".$start_time;
$to_date = $end_date." ".$end_time;
echo __('Data from agent '). "" . get_agent_name($origen). "- $agentmodule_name". __(' from '). "". $from_date. "". __(' to '). "". $to_date. "
";
echo "
";
echo "
".__('Module')." |
".__('Data')." |
Timestamp | ";
// Begin the render !
for ($a=0; $a "'.$from_date.'" AND timestamp < "'.$to_date.'" AND id_agente_modulo ='.$id_modulo.' ORDER BY timestamp DESC';
else
$sql1 = 'SELECT * FROM tagente_datos WHERE timestamp > "'.$from_date.'" AND timestamp < "'.$to_date.'" AND id_agente_modulo ='.$id_modulo.' ORDER BY timestamp DESC';
$result1 = get_db_all_rows_sql ($sql1);
$color=1;
foreach ($result1 as $row){
if ($color == 1){
$tdcolor = "datos";
$color = 0;
} else {
$tdcolor = "datos2";
$color = 1;
}
echo "";
echo $agentmodule_name;
echo " | ";
echo $row["datos"];
echo " | ";
echo $row["timestamp"];
echo " |
";
}
}
echo "
";
} else
echo "".__('No module has been selected')."";
}
} else {
// Option B: Print Form
// Form view
$ahora=date("Y/m/d H:i:s");
$ahora_s = date("U");
$ayer = date ("Y/m/d H:i:s", $ahora_s - 86400);
if (isset($_GET["date_from"]))
$date_from=$_GET["date_from"];
else
if (isset($_POST["from_date"]))
$date_from = $_POST["from_date"];
else
$date_from = $ayer;
if (isset($_GET["date_to"]))
$date_to = $_GET["date_to"];
else
if (isset($_POST["to_date"]))
$date_to = $_POST["to_date"];
else
$date_to = $ahora;
$config['js'][] = 'calendar';
echo "".__('Pandora Agents')." > ";
echo __('Export data')."
";
echo '";
}
?>