<?php

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

set_include_path("../../");
include_once("server/class/Delivery.php");
include_once("server/class/CoordsManager.php");
@session_start();

$jsonParams = file_get_contents('php://input');
$paramObj = json_decode($jsonParams);


//vas a recibir:
//$paramObj->token
//$paramObj->newPass



// if (isset($paramObj->lat) && isset($paramObj->lng) && isset($paramObj->timestamp) && isset($paramObj->token)) {
//     $delivery = new Delivery(-1);
//     $deliveryId = $delivery->getIdDeliveryFromToken($paramObj->token);
//     if (!($deliveryId === -1)) {
//         $coordsManager = new CoordsManager();
//         $speed = (isset($paramObj->speed)) ? $paramObj->speed : -1;
//         $azimuth = (isset($paramObj->azimuth)) ? $paramObj->speed : -1;
//         $coordsManager->addPosition($deliveryId, $paramObj->lat, $paramObj->lng, $paramObj->timestamp, $speed, $azimuth);
//         $delivery->setCurrentPosition($paramObj->lat, $paramObj->lng, $paramObj->timestamp);
//         $ack['error'] = 0;
//     } else {
//         $ack['error'] = -2;
//     }

//     try {
//     } catch (Exception $ex) {
//     }
// } else {
//     $ack['error'] = -1;
// }

$ack['error'] = 0;


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