function jsaGetDatos($solicitud)
{
    if ($solicitud != 0 and $solicitud != '') {
        $xCred = new cCreditos_solicitud();
        $xCred->setData($xCred->query()->getRow("numero_solicitud={$solicitud}"));
        $pagos = $xCred->numero_pagos()->v();
        $monto = $xCred->monto_solicitado()->v();
        $periocidad = $xCred->periocidad_de_pago()->v();
        $tasa = $xCred->tasa_interes()->v();
        $xF = new cFecha();
        $xT = new cTipos();
        $tab = new TinyAjaxBehavior();
        $tab->add(TabSetvalue::getBehavior('idpagos', $pagos));
        $tab->add(TabSetvalue::getBehavior('idmonto', $monto));
        $tab->add(TabSetvalue::getBehavior('idtasa', $tasa * 100));
        $tab->add(TabSetvalue::getBehavior('idperiocidad', $periocidad));
        $tab->add(TabSetvalue::getBehavior('idtipodepago', $xCred->tipo_de_pago()->v()));
        //Fechas de ministracion
        $tab->add(TabSetvalue::getBehavior('idfecha1', $xF->getFechaMX($xCred->fecha_autorizacion()->v(), "-")));
        $tab->add(TabSetvalue::getBehavior('idfecha2', $xF->getFechaMX($xCred->fecha_ministracion()->v(), "-")));
        $tab->add(TabSetvalue::getBehavior('idautorizacion', $xCred->docto_autorizacion()->v()));
        $tab->add(TabSetvalue::getBehavior('idtipodeautorizacion', $xCred->tipo_autorizacion()->v()));
        return $tab->getString();
    }
}
function jsaHeredarDatos($idcuenta)
{
    $tab = new TinyAjaxBehavior();
    $xLog = new cCoreLog();
    $xCta = new cCuentaContable($idcuenta);
    $cuenta = "";
    $nombre = "";
    $superior = "";
    $nombresupe = "";
    $tipo = "";
    $nivel = "";
    $centro = "";
    $superiorf = "";
    $operar = 0;
    $equivale = "";
    if ($xCta->init() == true) {
        $cuenta = $xCta->get();
        $nombre = $xCta->getNombre();
        $superior = $xCta->getInmediatoSuperior();
        $nivel = $xCta->getDigitoAgrupador();
        $centro = $xCta->getCentroDeCosto();
        $tipo = $xCta->getTipoDeCuenta();
        $operar = 1;
        $xLog->add("OK\tModificar la cuenta {$idcuenta} - {$operar} - {$superior}\r\n");
        $equivale = $xCta->getEquivalencia();
    } else {
        $xEsq = new cCuentaContableEsquema($idcuenta);
        $cuenta = $xEsq->CUENTA;
        $superior = $xEsq->CUENTA_SUPERIOR;
        $nivel = $xEsq->NIVEL_ACTUAL;
        $xLog->add("OK\tAgregar Nueva cuenta {$idcuenta} ({$cuenta}) - {$superior}\r\n");
    }
    $xLog->add($xCta->getMessages(), $xLog->DEVELOPER);
    //inicializar superior
    if ($nivel > 1) {
        $xSup = new cCuentaContable($superior);
        if ($xSup->init() == true) {
            $tipo = $tipo == "" ? $xSup->getTipoDeCuenta() : $tipo;
            $centro = $centro == "" ? $xSup->getCentroDeCosto() : $centro;
            $superiorf = $xSup->getCuentaCompleta($superior, true);
            $nombresupe = $xSup->getNombre();
            if ($operar == 0) {
                $equivale = $xSup->getEquivalencia();
            }
        }
        $xLog->add($xSup->getMessages(), $xLog->DEVELOPER);
    }
    $tab->add(TabSetvalue::getBehavior('idcuenta', $cuenta));
    $tab->add(TabSetvalue::getBehavior('idnombrecuenta', $nombre));
    $tab->add(TabSetvalue::getBehavior('idtipodecuentacontable', $tipo));
    $tab->add(TabSetvalue::getBehavior('idcentrodecosto', $centro));
    $tab->add(TabSetvalue::getBehavior('idcuentasuperior', $superiorf));
    $tab->add(TabSetvalue::getBehavior('idnombresuperior', $nombresupe));
    $tab->add(TabSetvalue::getBehavior('idoperacion', $operar));
    $tab->add(TabSetvalue::getBehavior('idequivalencia', $equivale));
    $tab->add(TabSetvalue::getBehavior('idmsg3', $xLog->getMessages()));
    return $tab->getString();
}
function jsaGetCuotasDeDefuncion($socio)
{
    $cuota_pagada = 0;
    $fecha_a_tolerar = restardias(fechasys(), DIAS_A_ROTAR_FONDO_DE_DEFUNCION);
    $cuota_a_pagar = 100;
    $sql = "SELECT SUM(afectacion_real) AS 'monto',\n\t\t\tMAX(fecha_operacion) AS 'fecha_pago'\n\t\t\tFROM operaciones_mvtos\n\t\t\tWHERE tipo_operacion=902\n\t\t\tAND socio_afectado={$socio}\n\t\t\tAND fecha_operacion>='{$fecha_a_tolerar}'\n\t\t";
    $cuota_pagada = mifila($sql, "monto");
    if ($cuota_pagada < 0) {
        $cuota_pagada = 0;
    }
    $cuota_a_pagar = $cuota_a_pagar - $cuota_pagada;
    //TODO: Terminar
    $tab = new TinyAjaxBehavior();
    $tab->add(TabSetvalue::getBehavior('idmonto', $cuota_a_pagar));
    return $tab->getString();
}
function jsa_getDatosDeCredito($solicitud)
{
    $xCred = new cCredito($solicitud);
    $xCred->initCredito();
    $xF = new cFecha();
    $xT = new cTipos();
    $dCreds = $xCred->getDatosDeCredito();
    $periocidad = $xCred->getPeriocidadDePago();
    $FMinistracion = $xCred->getFechaDeMinistracion();
    $contrato_corriente = $xCred->getContratoCorriente();
    $xPlanGen = new cPlanDePagosGenerador();
    $xPlanGen->initPorCredito($solicitud);
    $FPrimerAb = $xPlanGen->getFechaDePrimerPago();
    $xF = new cFecha(0, $FMinistracion);
    $FM_d = $xF->dia();
    $FM_a = $xF->anno();
    $FM_m = $xF->mes();
    $xF2 = new cFecha(1, $FPrimerAb);
    $xF2->set($FPrimerAb);
    $PA_d = $xF2->dia();
    $PA_a = $xF2->anno();
    $PA_m = $xF2->mes();
    $tab = new TinyAjaxBehavior();
    //setLog("$PA_d --- $PA_m ---- $PA_a  - - - - - $FPrimerAb");
    $tab->add(TabSetvalue::getBehavior('ideldia1', $FM_d));
    $tab->add(TabSetvalue::getBehavior('idelmes1', $FM_m));
    $tab->add(TabSetvalue::getBehavior('idelanno1', $FM_a));
    $tab->add(TabSetvalue::getBehavior('ideldia0', $PA_d));
    $tab->add(TabSetvalue::getBehavior('idelmes0', $PA_m));
    $tab->add(TabSetvalue::getBehavior('idelanno0', $PA_a));
    $tab->add(TabSetvalue::getBehavior('idDescripcionSolicitud', $xCred->getShortDescription()));
    $tab->add(TabSetvalue::getBehavior('idcuenta', $contrato_corriente));
    //$xCred->getPeriocidadDePago() != CREDITO_TIPO_PERIOCIDAD_CATORCENAL
    if ($xCred->getTipoEnSistema() == CREDITO_PRODUCTO_NOMINA) {
        $tab->add(TabSetvalue::getBehavior('idFormaDePago', $xCred->getTipoDePago()));
        //setLog("El pago es " . $xCred->getPeriocidadDePago() );
        if ($xCred->getPeriocidadDePago() != CREDITO_TIPO_PERIOCIDAD_CATORCENAL) {
            $tab->add(TabSetvalue::getBehavior('idtipo_plan_pagos', CREDITO_TIPO_DIAS_DE_PAGO_PERSONALIZADOS));
        }
    }
    return $tab->getString();
}
function jsaGetNombreDirector($persona)
{
    $xSocio = new cSocio($persona);
    $xSocio->init();
    //idelmes0 idelanno0 ideldia0
    $tab = new TinyAjaxBehavior();
    //$tab -> add(TabSetvalue::getBehavior("idNumeroSocio", $socio));
    $tab->add(TabSetvalue::getBehavior("idnombredependencia", $xSocio->getNombreCompleto()));
    //$tab -> add(TabSetvalue::getBehavior('idObservaciones', $xSoc->getMessages() ));
    return $tab->getString();
}
function JsaGetDatosHeredados($socio)
{
    $xSoc = new cSocio($socio);
    $xSoc->init();
    $sucess = true;
    $telefono = "";
    $domicilio = "";
    $telefonomovil = "";
    $nombre = "";
    $appPaterno = "";
    $appMaterno = "";
    $NDia = "";
    $NMes = "";
    $NAnno = "";
    $actividad = "";
    /**
     * Si el Numero de Socio es menor a 5 digitos
     */
    //if ( strlen($curp) >= 7){
    $DDom = $xSoc->getDatosDomicilio();
    $telefono = $DDom["telefono_residencial"];
    $telefonomovil = $DDom["telefono_movil"];
    $nombre = $xSoc->getNombre();
    $appPaterno = $xSoc->getApellidoPaterno();
    $appMaterno = $xSoc->getApellidoMaterno();
    $curp = $xSoc->getCURP();
    $FNacimiento = $xSoc->getFechaDeNacimiento();
    $NDia = date("d", strtotime($FNacimiento));
    $NMes = date("n", strtotime($FNacimiento));
    $NAnno = date("Y", strtotime($FNacimiento));
    //$num			= $DDom["Resultado"];
    $DOcup = $xSoc->getDatosActividadEconomica();
    //$domicilio		= $xSoc->getDomicilio();
    $actividad = $DOcup["puesto"];
    $socio = $xSoc->getCodigo();
    //if ($num == 1){ $sucess = true; }
    //}
    //idelmes0 idelanno0 ideldia0
    $tab = new TinyAjaxBehavior();
    if ($sucess == true) {
        $tab->add(TabSetvalue::getBehavior("idTFijo", $telefono));
        //$tab->add(TabSetvalue::getBehavior("idDomicilio", $domicilio));
        $tab->add(TabSetvalue::getBehavior("idTMovil", $telefonomovil));
        $tab->add(TabSetvalue::getBehavior("idNombres", $nombre));
        $tab->add(TabSetvalue::getBehavior("idApPaterno", $appPaterno));
        $tab->add(TabSetvalue::getBehavior("idApMaterno", $appMaterno));
        $tab->add(TabSetvalue::getBehavior('idCurp', $curp));
        $tab->add(TabSetvalue::getBehavior('ideldia0', $NDia));
        $tab->add(TabSetvalue::getBehavior('idelmes0', $NMes));
        $tab->add(TabSetvalue::getBehavior('idelanno0', $NAnno));
        $tab->add(TabSetvalue::getBehavior("idOcupacion", $actividad));
        //$tab->add(TabSetvalue::getBehavior("idNumeroSocio", $socio));
        $tab->add(TabSetvalue::getBehavior("idNumeroSocio", $socio));
        //-
        $tab->add(TabSetvalue::getBehavior("idcolonia", $DDom["colonia"]));
        $tab->add(TabSetvalue::getBehavior("idcalle", $DDom["calle"]));
        $tab->add(TabSetvalue::getBehavior("idnumero", $DDom["numero_exterior"]));
        $tab->add(TabSetvalue::getBehavior("idreferencia", $DDom["referencia"]));
        $tab->add(TabSetvalue::getBehavior("idcodigopostal", $DDom["codigo_postal"]));
    }
    //$tab -> add(TabSetvalue::getBehavior('idObservaciones', $xSoc->getMessages() ));
    return $tab->getString();
    //}
}
function jsaGetEmailsEmpresa($idEmpresa, $periocidad, $variacion, $periodo)
{
    $xEmp = new cEmpresas($idEmpresa);
    $xEmp->init();
    $tab = new TinyAjaxBehavior();
    $mails = $xEmp->getEmailsDeEnvio();
    $itms = 1;
    foreach ($mails as $clave => $mail) {
        $tab->add(TabSetvalue::getBehavior("idmail{$itms}", $mail));
        $itms++;
    }
    return $tab->getString();
}
function jsaGetDatosDePersona($persona)
{
    $xSoc = new cSocio($persona);
    $xSoc->init();
    $sucess = true;
    $telefono = "";
    $domicilio = "";
    $telefonomovil = "";
    $nombre = "";
    $appPaterno = "";
    $appMaterno = "";
    $NDia = "";
    $NMes = "";
    $NAnno = "";
    $actividad = "";
    /**
     * Si el Numero de Socio es menor a 5 digitos
     */
    $DDom = $xSoc->getDatosDomicilio();
    $telefono = $xSoc->getTelefonoPrincipal();
    $nombre = $xSoc->getNombre();
    $appPaterno = $xSoc->getApellidoPaterno();
    $appMaterno = $xSoc->getApellidoMaterno();
    $curp = $xSoc->getCURP();
    $FNacimiento = $xSoc->getFechaDeNacimiento();
    $DOcup = $xSoc->getDatosActividadEconomica();
    $actividad = $DOcup["puesto"];
    $socio = $xSoc->getCodigo();
    $tab = new TinyAjaxBehavior();
    if ($sucess == true) {
        $tab->add(TabSetvalue::getBehavior("telefono", $telefono));
        $tab->add(TabSetvalue::getBehavior("nombre", $nombre));
        $tab->add(TabSetvalue::getBehavior("paterno", $appPaterno));
        $tab->add(TabSetvalue::getBehavior("materno", $appMaterno));
        $tab->add(TabSetvalue::getBehavior('curp', $curp));
        $tab->add(TabSetvalue::getBehavior("ocupacion", $actividad));
        $tab->add(TabSetvalue::getBehavior("ingreso", $xSoc->getIngresosMensuales()));
        //$tab->add(TabSetvalue::getBehavior("personarelacionada", $persona));
        // "idnombrecolonia" "identidadesfederativas"
        if ($xSoc->getODomicilio() == null) {
        } else {
            $tab->add(TabSetvalue::getBehavior("idnombrecolonia", $DDom["colonia"]));
            $tab->add(TabSetvalue::getBehavior("idnombreacceso", $DDom["calle"]));
            $tab->add(TabSetvalue::getBehavior("idnumeroexterior", $DDom["numero_exterior"]));
            $tab->add(TabSetvalue::getBehavior("idcodigopostal", $DDom["codigo_postal"]));
            if (PERSONAS_VIVIENDA_MANUAL == true) {
                $tab->add(TabSetvalue::getBehavior("idnombrelocalidad", $DDom["localidad"]));
                $tab->add(TabSetvalue::getBehavior("idnombremunicipio", $DDom["municipio"]));
            } else {
            }
        }
    }
    //$tab -> add(TabSetvalue::getBehavior('idObservaciones', $xSoc->getMessages() ));
    return $tab->getString();
}