2010-01-25 16:29:33 +01:00
< ? php
/**
* Pandora FMS - http :// pandorafms . com
* ==================================================
2010-05-14 14:55:16 +02:00
* Copyright ( c ) 2005 - 2010 Artica Soluciones Tecnologicas
2010-01-25 16:29:33 +01:00
*
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*/
// Load global vars
2010-03-02 20:25:51 +01:00
global $config ;
2010-01-25 16:29:33 +01:00
check_login ();
if ( ! give_acl ( $config [ 'id_user' ], 0 , " PM " ) && ! is_user_admin ( $config [ 'id_user' ])) {
2010-03-09 13:34:09 +01:00
audit_db ( $config [ 'id_user' ], $_SERVER [ 'REMOTE_ADDR' ], " ACL Violation " , " Trying to access Visual Setup Management " );
2010-01-25 16:29:33 +01:00
require ( " general/noaccess.php " );
return ;
}
require_once ( 'include/functions_gis.php' );
2010-01-27 13:50:28 +01:00
require_once ( 'include/functions_html.php' );
2010-01-25 16:29:33 +01:00
2010-02-09 18:06:25 +01:00
require_javascript_file ( 'openlayers.pandora' );
2010-01-27 13:50:28 +01:00
/* Get the parameters */
$period = get_parameter ( " period " , 86400 );
$agentId = get_parameter ( 'id_agente' );
$agent_name = get_agent_name ( $agentId );
2010-02-18 17:54:24 +01:00
$agentData = getDataLastPositionAgent ( $id_agente );
2010-01-27 13:50:28 +01:00
2010-03-05 12:16:20 +01:00
echo " <div style='margin-bottom: 30px;'></div> " ;
2010-01-27 13:50:28 +01:00
/* Map with the current position */
2010-05-14 14:55:16 +02:00
echo " <div id= \" " . $agent_name . " _agent_map \" style= \" border:1px solid black; width:98%; height: 39em; \" ></div> " ;
2010-03-01 12:17:27 +01:00
if ( ! getAgentMap ( $agentId , " 500px " , " 98% " , true , true , $period )) {
echo " <br /><div class='nf'> " . __ ( " There is no default map. " ) . " </div> " ;
}
2010-01-27 13:50:28 +01:00
2010-02-23 13:12:41 +01:00
$timestampLastOperation = get_db_value_sql ( " SELECT UNIX_TIMESTAMP() " );
activateAjaxRefresh ( null , $timestampLastOperation );
activateSelectControl ();
2010-02-18 17:54:24 +01:00
if ( $agentData === false ) {
echo " <p> " . __ ( " There is no GIS data for this agent, so it's positioned in default position of map. " ) . " </p> " ;
}
2010-02-25 17:32:07 +01:00
$intervals = array ();
$intervals [ 30 ] = human_time_description_raw ( 30 );
$intervals [ 60 ] = human_time_description_raw ( 60 );
$intervals [ 300 ] = human_time_description_raw ( 300 );
$intervals [ 600 ] = human_time_description_raw ( 600 );
$intervals [ 1200 ] = human_time_description_raw ( 1200 );
$intervals [ 1800 ] = human_time_description_raw ( 1800 );
$intervals [ 3600 ] = human_time_description_raw ( 3600 );
$intervals [ 7200 ] = human_time_description_raw ( 7200 );
$intervals [ 86400 ] = human_time_description_raw ( 86400 );
$intervals [ 172800 ] = human_time_description_raw ( 172800 );
$intervals [ 604800 ] = human_time_description_raw ( 604800 );
2010-03-05 12:16:20 +01:00
echo " <br /> " ;
$dataLastPosition = getDataLastPositionAgent ( $agentId );
if ( $dataLastPosition !== false ) {
echo " <b> " . __ ( " Last position in " ) . $dataLastPosition [ 'start_timestamp' ] . " :</b> " .
$dataLastPosition [ 'stored_longitude' ] . " , " . $dataLastPosition [ 'stored_latitude' ] . " , " . $dataLastPosition [ 'stored_altitude' ];
}
2010-02-25 17:32:07 +01:00
echo " <br /> " ;
echo " <form action='index.php? " . $_SERVER [ 'QUERY_STRING' ] . " ' method='POST'> " ;
echo __ ( " Period to show data as path " ) . " : " ;
print_extended_select_for_time ( $intervals , 'period' , $period , '' , '' , '0' , 10 );
2010-05-14 14:55:16 +02:00
echo __ ( " seconds. " ) . " " ;
2010-03-05 12:16:20 +01:00
print_submit_button ( __ ( 'Refresh path' ), 'refresh' , false , 'class = "sub upd"' );
2010-02-25 17:32:07 +01:00
echo " </form> " ;
2010-01-27 13:50:28 +01:00
echo " <h3> " . __ ( " Positional data from the last " ) . " " . human_time_description ( $period ) . " </h3> " ;
/* Get the total number of Elements for the pagination */
2010-02-18 17:54:24 +01:00
$sqlCount = sprintf ( " SELECT COUNT(*) FROM tgis_data_history WHERE tagente_id_agente = %d AND end_timestamp > %d ORDER BY end_timestamp DESC " , $agentId , get_system_time () - $period );
2010-01-27 13:50:28 +01:00
$countData = get_db_value_sql ( $sqlCount );
/* Get the elements to present in this page */
$sql = sprintf ( " SELECT longitude, latitude, altitude, start_timestamp, end_timestamp, description, number_of_packages, manual_placement
2010-05-14 14:55:16 +02:00
FROM tgis_data_history
WHERE tagente_id_agente = % d AND end_timestamp > % d
ORDER BY end_timestamp DESC
LIMIT % d OFFSET % d " , $agentId , get_system_time () - $period , $config['block_size'] , get_parameter ('offset'));
2010-02-19 13:26:54 +01:00
2010-01-27 13:50:28 +01:00
$result = get_db_all_rows_sql ( $sql , true );
if ( $result === false ) {
2010-02-25 14:30:42 +01:00
echo " <div class='nf'> " . __ ( 'This agent doesn\'t have any GIS data' ) . " </div> " ;
2010-01-27 13:50:28 +01:00
}
else {
2010-05-14 14:55:16 +02:00
pagination ( $countData , false ) ;
2010-01-27 13:50:28 +01:00
$table -> data = array ();
foreach ( $result as $row ) {
$rowdata = array ( $row [ 'longitude' ], $row [ 'latitude' ], $row [ 'altitude' ], $row [ 'start_timestamp' ], $row [ 'end_timestamp' ], $row [ 'description' ], $row [ 'number_of_packages' ], $row [ 'manual_placement' ]);
2010-05-14 14:55:16 +02:00
array_push ( $table -> data , $rowdata );
2010-01-27 13:50:28 +01:00
}
$table -> head = array ( __ ( " Longitude " ), __ ( " Latitude " ), __ ( " Altitude " ), __ ( " From " ), __ ( " To " ), __ ( " Description " ), '# ' . __ ( " of Packages " ), __ ( " Manual placement " ));
$table -> class = 'position_data_table' ;
$table -> id = $agent_name . '_position_data_table' ;
$table -> title = $agent_name . " " . __ ( " positional data " );
2010-05-14 14:55:16 +02:00
$table -> titlestyle = " background-color:#799E48; " ;
2010-03-03 10:22:44 +01:00
print_table ( $table ); unset ( $table );
2010-01-27 13:50:28 +01:00
pagination ( $countData , false ) ;
echo " <h3> " . __ ( 'Total' ) . ' ' . $countData . ' ' . __ ( 'Data' ) . " </h3> " ;
}
?>