<?php

/*
 * ROMAN DIGITAL - Autor: Américo Patetta
 */

set_include_path("../../");
include_once("server/class/PedidosManager.php");
include_once("server/class/GeoUtils.php");

//$jsonParams = file_get_contents('php://input');
//$paramObj = json_decode($jsonParams);
$idPedido = filter_input(INPUT_GET, 'idPedido', FILTER_VALIDATE_INT);
$idLocal = filter_input(INPUT_GET, 'idLocal', FILTER_VALIDATE_INT);
$token = htmlspecialchars($_GET['token'], ENT_QUOTES);

//if (isset($paramObj->idPedido) && isset($paramObj->token) && $paramObj->token == TOKEN_WEB) {
if (isset($idPedido)  && isset($idLocal) && isset($token) && $token == TOKEN_WEB) {
    $status = PedidosManager::getPedidoPosition($idPedido,$idLocal);
    $response['status'] = ($status) ? $status : "N/D";
    $response['error'] = ($status) ? 0 : -2;
} else {
    $response['error'] = -1;
    $response['status'] = "N/D";
}

//header('Content-Type: application/json; charset=utf-8');
//echo json_encode($response);
?>

<html>

<head>
    <link href="../../lib/js/Leaflet/leaflet.css" rel="stylesheet" type="text/css" />
    <style>
        body {
            overflow: hidden;
        }

        #inicioMap {
            position: absolute;
            width: 100%;
            left: 0px;
            top: 0px;
            bottom: 0px;
            z-index: 0;
            overflow: hidden;
        }
    </style>

</head>

<body>
    <div id="inicioMap"></div>
</body>

<script src="../../lib/js/Leaflet/leaflet.js" type="text/javascript"></script>
<script src="../../lib/js/Leaflet/leaflet-geoman.min.js" type="text/javascript"></script>
<script src="../../js/apiMapPosition.js" type="text/javascript"></script>
<script>
    makeIframe(<?php echo json_encode($response); ?>);
</script>

</html>