<?php

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

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

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

if (isset($paramObj->idPedido) && isset($paramObj->idLocal) && isset($paramObj->token) && $paramObj->token == TOKEN_BRODEVO && isset($paramObj->status)) {
   if($paramObj->status == DEVUELTO_STATUS){
    $pm = new PedidosManager();
    
    $response['error'] = ($pm->setDevuelto($paramObj->idPedido, $paramObj->idLocal))?0:-3;
   } else {
     $response['error'] = -2;  
   }
} else {
    $response['error'] = -1;
}

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