Merge branch 'ent-3913-gis-data-refresh-bug' into 'develop'

Added current gis location to agent gis view list

See merge request artica/pandorafms!2772
This commit is contained in:
Alejandro Fraguas 2019-10-14 15:57:27 +02:00
commit 8407d7fe9a
2 changed files with 22 additions and 27 deletions

View File

@ -765,7 +765,7 @@ $table_adv_agent_icon .= html_print_select(
).'</div>'; ).'</div>';
if ($config['activate_gis']) { if ($config['activate_gis']) {
$table_adv_gis = '<div class="label_select_simple label_simple_one_item"><p class="input_label input_label_simple">'.__('Ignore new GIS data:').'</p>'; $table_adv_gis = '<div class="label_select_simple label_simple_one_item"><p class="input_label input_label_simple">'.__('Update new GIS data:').'</p>';
if ($new_agent) { if ($new_agent) {
$update_gis_data = true; $update_gis_data = true;
} }

View File

@ -97,17 +97,6 @@ echo '<td>';
html_print_submit_button(__('Refresh path'), 'refresh', false, 'class = "sub upd" style="margin-top:0px"'); html_print_submit_button(__('Refresh path'), 'refresh', false, 'class = "sub upd" style="margin-top:0px"');
echo '</table></form>'; echo '</table></form>';
// 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 = (int) db_get_value_sql($sqlCount);
// Get the elements to present in this page // Get the elements to present in this page
switch ($config['dbtype']) { switch ($config['dbtype']) {
case 'mysql': case 'mysql':
@ -147,33 +136,39 @@ switch ($config['dbtype']) {
$result = db_get_all_rows_sql($sql, true); $result = db_get_all_rows_sql($sql, true);
if ($result === false) { $sql2 = sprintf(
$sql2 = sprintf( '
' SELECT current_longitude AS longitude, current_latitude AS latitude, current_altitude AS altitude,
SELECT current_longitude AS longitude, current_latitude AS latitude, current_altitude AS altitude, start_timestamp, description, number_of_packages, manual_placement
start_timestamp, description, number_of_packages, manual_placement FROM tgis_data_status
FROM tgis_data_status WHERE tagente_id_agente = %d
WHERE tagente_id_agente = %d ORDER BY start_timestamp DESC
ORDER BY start_timestamp DESC LIMIT %d OFFSET %d',
LIMIT %d OFFSET %d', $agentId,
$agentId, $config['block_size'],
$config['block_size'], (int) get_parameter('offset')
(int) get_parameter('offset') );
);
$result2 = db_get_all_rows_sql($sql2, true); $result2 = db_get_all_rows_sql($sql2, true);
if ($result2 === false) { if ($result === false && $result2 === false) {
ui_print_empty_data(__('This agent doesn\'t have any GIS data.')); ui_print_empty_data(__('This agent doesn\'t have any GIS data.'));
} else {
if ($result === false) {
$result = $result2;
} else { } else {
$result2[0]['end_timestamp'] = date('Y-m-d H:i:s'); $result2[0]['end_timestamp'] = date('Y-m-d H:i:s');
$result = $result2; array_unshift($result, $result2[0]);
} }
} }
if ($result !== false) { if ($result !== false) {
echo '<h4>'.__('Positional data from the last').' '.human_time_description_raw($period).'</h4>'; echo '<h4>'.__('Positional data from the last').' '.human_time_description_raw($period).'</h4>';
// Get the total elements for UI pagination
$countData = count($result);
if ($countData > 0) { if ($countData > 0) {
ui_pagination($countData, false); ui_pagination($countData, false);
} }