$value) {
$url .= '&' . safe_url_extraclean($key) . '=' . safe_url_extraclean($value);
}
echo "
";
/* Map with the current position */
echo "";
if (!gis_get_agent_map($id_agente, "500px", "98%", true, true, $period)) {
ui_print_error_message(__("There is no default map. Please go to the setup for to set a default map."));
echo "";
}
switch ($config["dbtype"]) {
case "mysql":
$timestampLastOperation = db_get_value_sql(
"SELECT UNIX_TIMESTAMP()");
break;
case "postgresql":
$timestampLastOperation = db_get_value_sql(
"SELECT ceil(date_part('epoch', CURRENT_TIMESTAMP))");
break;
case "oracle":
$timestampLastOperation = db_get_value_sql(
"SELECT ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (" . SECONDS_1DAY . ")) from dual");
break;
}
gis_activate_ajax_refresh(null, $timestampLastOperation);
gis_activate_select_control();
if ($agentData === false) {
echo "" .
__("There is no GIS data for this agent, so it's positioned in default position of map.") .
"
";
}
echo "
";
$dataLastPosition = gis_get_data_last_position_agent($agentId);
if ($dataLastPosition !== false) {
echo "" . __("Last position in ") .
$dataLastPosition['start_timestamp'] . ": " .
$dataLastPosition['stored_longitude'] . ", " . $dataLastPosition['stored_latitude'] . ", " . $dataLastPosition['stored_altitude'];
}
echo "
";
echo "";
echo "" . __("Positional data from the last") . " " . human_time_description_raw ($period) ."
";
/* Get the total number of Elements for the pagination */
$sqlCount = sprintf ("SELECT COUNT(*)
FROM tgis_data_history
WHERE tagente_id_agente = %d AND end_timestamp > FROM_UNIXTIME(%d)
ORDER BY end_timestamp DESC", $agentId, get_system_time () - $period);
$countData = db_get_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
FROM tgis_data_history
WHERE tagente_id_agente = %d AND end_timestamp > FROM_UNIXTIME(%d)
ORDER BY end_timestamp DESC
LIMIT %d OFFSET %d", $agentId, get_system_time () - $period, $config['block_size'], (int)get_parameter ('offset'));
$result = db_get_all_rows_sql ($sql, true);
if ($result === false) {
echo "" .
__('This agent doesn\'t have any GIS data.') . "
";
}
else {
ui_pagination ($countData, false) ;
$table->data = array();
foreach ($result as $key => $row) {
$distance = 0;
if (isset($result[$key - 1])) {
$distance = gis_calculate_distance($row['latitude'],
$row['longitude'], $result[$key - 1]['latitude'],
$result[$key - 1]['longitude']);
}
else {
$dataLastPosition = gis_get_data_last_position_agent($agentId);
if ($dataLastPosition !== false) {
$distance = gis_calculate_distance($row['latitude'],
$row['longitude'], $dataLastPosition['stored_latitude'],
$dataLastPosition['stored_longitude']);
}
}
$rowdata = array(
$row['longitude'],
$row['latitude'],
$row['altitude'],
$row['start_timestamp'],
$row['end_timestamp'],
$row['description'],
sprintf(__('%s Km'), $distance),
$row['number_of_packages'],
$row['manual_placement']);
array_push($table->data, $rowdata);
}
$table->head = array(
__("Longitude"),
__("Latitude"),
__("Altitude"),
__("From"),
__("To"),
__("Description"),
__('Distance'),
__("# of Packages"),
__("Manual placement"));
$table->class = 'position_data_table';
$table->id = $agent_name.'_position_data_table';
$table->title = $agent_name_original . " " . __("positional data");
$table->titlestyle = "background-color:#799E48;";
html_print_table($table); unset($table);
ui_pagination ($countData, false) ;
echo "" . __('Total') . ' ' . $countData . ' ' . __('Data') . "
";
}
?>