<?php
/**
 * Created by PhpStorm.
 * User: Joseg
 * Date: 16/7/2018
 * Time: 7:11 PM
 */
include '../comun/validarSesion.php';

if (isset($_REQUEST['token'])) {
    $Valido = new validator();
    if (isset($_REQUEST['token']) && isset($_REQUEST['id_direccion'])) {
        if ($Valido->checkToken($_REQUEST['token'])) {
            $creadoPor = $Valido->retornarIdToken($_REQUEST['token']);
            $condominioData = $Valido->retornarDatos($creadoPor);
            $contactoId = $_REQUEST['id_direccion'];
            $contacto = R::findOne('directoriocontacto', 'id = ?', [$contactoId]);
            include '../comun/mensajeOk.php';
            if ($contacto) {
                print_r(json_encode($contacto));
            } else {
                include '../comun/mensajeNoHayDatosParaMostrar.php';
            }
        }
    }else{
        include '../comun/mensajeFaltanCampos.php';
    }
}else{
    include '../comun/mensajeSesionInvalida.php';
}