<?php
/**
 * Created by PhpStorm.
 * User: joseortiz
 * Date: 8/27/18
 * Time: 2:13 a.m.
 */

include '../comun/validarSesion.php';

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