mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 16:24:54 +02:00
Merge branch '378-Exception_in_get_module_data_api' into 'pandora_6.0'
Fixed exception in datetime object. Functions api get_module_data. Ticket #378 See merge request !206
This commit is contained in:
commit
2ccfedf9a5
@ -5885,6 +5885,8 @@ function api_get_module_data($id, $thrash1, $other, $returnType) {
|
||||
$tstart = $data[2];
|
||||
$tend = $data[3];
|
||||
|
||||
if (($tstart != "") && ($tend != "")) {
|
||||
try {
|
||||
$dateStart = explode("T", $tstart);
|
||||
$dateYearStart = substr($dateStart[0], 0, 4);
|
||||
$dateMonthStart = substr($dateStart[0], 4, 2);
|
||||
@ -5900,8 +5902,11 @@ function api_get_module_data($id, $thrash1, $other, $returnType) {
|
||||
$date_end = $dateYearEnd . "-" . $dateMonthEnd . "-" . $dateDayEnd . " " . $dateEnd[1];
|
||||
$date_end = new DateTime($date_end);
|
||||
$date_end = $date_end->format('U');
|
||||
}
|
||||
catch (Exception $e) {
|
||||
returnError('error_query_module_data', 'Error in date format. ');
|
||||
}
|
||||
|
||||
if (($tstart != "") && ($tend != "")) {
|
||||
$sql = sprintf ("SELECT utimestamp, datos
|
||||
FROM tagente_datos
|
||||
WHERE id_agente_modulo = %d AND utimestamp > %d
|
||||
@ -5919,10 +5924,15 @@ function api_get_module_data($id, $thrash1, $other, $returnType) {
|
||||
$data['list_index'] = array('utimestamp', 'datos');
|
||||
$data['data'] = db_get_all_rows_sql($sql);
|
||||
|
||||
if ($data === false)
|
||||
if ($data === false) {
|
||||
returnError('error_query_module_data', 'Error in the query of module data.');
|
||||
else
|
||||
}
|
||||
else if ($data['data'] == "") {
|
||||
returnError('error_query_module_data', 'No data to show.');
|
||||
}
|
||||
else {
|
||||
returnData('csv', $data, $separator);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user