<?php

if (isset($_SERVER['HTTP_ORIGIN'])) {
    header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
    header('Access-Control-Allow-Credentials: true');
    header('Access-Control-Max-Age: 86400'); // cache for 1 day
}

include 'conn.php';
//Select data from database
error_reporting(E_ERROR | E_PARSE);

include 'funciones.php';

session_start();

$_SESSION['database'] = $_GET['database'];

$montoesql = "select  *  from " . $_SESSION['database'] . ".longitud order by date asc  ";

logs($montoesql);

$qur = $connection->query($montoesql);

while ($r = mysqli_fetch_assoc($qur)) {

//$msg = array("rec_prod" => $r['rec_prod'], "rec_pers" => $r['rec_pers'],"send_vent" => $r['send_vent']);

    $jsonTempData = array();
    //   $jsonTempData['lat']         =  9.0192041;
    //  $jsonTempData['lng']         = -79.52695039999999;

    $jsonTempData['lat'] = floatval($r['latitud']);
    $jsonTempData['lng'] = floatval($r['longitud']);

    $jsonTempData['label'] = 59;

    $jsonData[] = $jsonTempData;

}

$json->neighborhoods = $jsonData;

// $json = (object)$msg;

//header('content-type: application/json');
echo json_encode($json);

$qur = null;
@mysqli_close($connection);
?>