<?php
include_once '../config/header.php';
include_once '../config/helper.php';
include_once '../config/database.php';
include_once '../objects/alertas.php';
include_once '../token/validatetoken.php';

$database = new Database();
$db = $database->getConnection();

$alertas = new Alertas($db);

$alertas->id = isset($_GET['id']) ? $_GET['id'] : die();
$alertas->readOne();
 
if($alertas->id!=null){
    $alertas_arr = array(
        
"id" => $alertas->id,
"usuario_id" => $alertas->usuario_id,
"tipo_alerta" => $alertas->tipo_alerta,
"estado" => $alertas->estado,
"fecha_creacion" => $alertas->fecha_creacion,
"fecha_resolucion" => $alertas->fecha_resolucion,
"latitud" => $alertas->latitud,
"longitud" => $alertas->longitud
    );
    http_response_code(200);
   echo json_encode(array("status" => "success", "code" => 1,"message"=> "alertas found","document"=> $alertas_arr));
}
else{
    http_response_code(404);
	echo json_encode(array("status" => "error", "code" => 0,"message"=> "alertas does not exist.","document"=> ""));
}
?>
