<?php
/**
 * Created by PhpStorm.
 * User: Joseg
 * Date: 16/7/2018
 * Time: 10:37 PM
 */

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

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