function getValidacion($out = OUT_TXT, $corregir = false)
 {
     $txt = "";
     $cTipo = new cTipos();
     $ready = true;
     $xLog = new cCoreLog();
     $EsOperable = true;
     $xLoc = new cLocal();
     if ($this->mSocioIniciado == false) {
         $this->init();
     }
     //Validar GrupoSolidario
     if ($this->getClaveDeGrupo() > DEFAULT_GRUPO) {
         $xGrupo = new cGrupo($this->getClaveDeGrupo());
         if ($xGrupo->init() == false) {
             $ready = false;
             $xLog->add("ERROR\t" . $this->mCodigo . "\tGRUPO\tEl Grupo " . $this->mGrupoAsociado . " No Existe \r\n");
             if ($corregir == true) {
                 $xGrupo->add("_GRUPO_NO_EXISTENTE_", "_GRUPO_EN_ALTA_POR_CORRECION_SOCIO_" . $this->mCodigo, $this->mCodigo, DEFAULT_SOCIO, 10, 1, $this->mGrupoAsociado);
                 $xLog->add("WARN\t" . $this->mCodigo . "\tGRUPO\tEl Grupo " . $this->mGrupoAsociado . " Ha sido AGREGADO \r\n");
                 $xLog->add($xGrupo->getMessages(), $xLog->DEVELOPER);
             }
         }
     }
     //Validar Caja Local
     if (SISTEMA_CAJASLOCALES_ACTIVA == true) {
         $xCL = new cCajaLocal();
         if ($xCL->init() == false) {
             $xLog->add("ERROR\t" . $this->mCodigo . "\tCAJALOCAL\tLa Caja Local " . $this->mCajaLocal . " No Existe \r\n");
             $ready = false;
         }
     }
     //Validar Dependencias
     if ($this->getClaveDeEmpresa() != DEFAULT_EMPRESA) {
         $xEmp = new cEmpresas($this->getClaveDeEmpresa());
         if ($xEmp->init() == false) {
             $xLog->add("ERROR\t" . $this->mCodigo . "\tDEPENDENCIA_E\tLa Dependencia " . $this->mDependencia . " No Existe \r\n");
             $xLog->add($xEmp->getMessages(), $xLog->DEVELOPER);
             $ready = false;
         }
     }
     //Validar propietario
     if ($this->getClaveDeUsuario() != DEFAULT_USER) {
         $xUsr = new cSystemUser($this->getClaveDeUsuario());
         if ($xUsr->init() == false) {
             $xLog->add("ERROR\t" . $this->mCodigo . "\tPROPIETARIO\tEl Propietario # " . $this->mPropietario . " NO EXISTE \r\n");
             if ($corregir == true) {
                 $xUsr->add("usr" . $this->mPropietario, "", 2, "USUARIO", "AGREGADO", "EN_VERIFICACION", "", false, "baja", "", false, $this->mPropietario);
             }
             $xLog->add($xUsr->getMessages(), $xLog->DEVELOPER);
         }
     }
     //Validar persona Moral
     if ($this->getEsPersonaFisica() == false) {
         if ($this->getORepresentanteLegal() == null) {
             $xLog->add("ERROR\t" . $this->mCodigo . "\tREP_LEGAL\tEl representante legal NO EXISTE \r\n");
             $ready = false;
             $EsOperable = false;
         }
     }
     //Validar Tipo de Ingreso
     $xT = new cPersonasTipoDeIngreso($this->mTipoDeIngreso);
     if ($xT->init() == false) {
         $txt .= "ERROR\t" . $this->mCodigo . "\tTIPO_INGRESO\tLa Dependencia " . $this->mTipoDeIngreso . " No Existe \r\n";
         $ready = false;
     }
     //Validar Actividad Economica
     if ($this->getOActividadEconomica() == null) {
         $ready = false;
         $EsOperable = false;
         $xLog->add("ERROR\t" . $this->mCodigo . "\tACTIVIDAD\tEL Socio NO tiene Registrado alguna ACTIVIDAD ECONOMICA \r\n");
     }
     //Validar Vivienda
     if ($this->getODomicilio() == null) {
         $ready = false;
         $EsOperable = false;
         $xLog->add("ERROR\t" . $this->mCodigo . "\tVIVIENDA\tEL Socio NO tiene Registrado algun DOMICILIO Valido \r\n");
         if ($corregir == true) {
             $codigo_postal = $xLoc->DomicilioCodigoPostal();
             $this->addVivienda("DESCONOCIDO", "POR_REGISTRAR", $codigo_postal);
         }
     } else {
         //TODO: 2014/01/12 Terminar Validacion de codigo postal y busqueda por domicilio aternativo
     }
     //Valida el codigo postal
     /*$sqlDV		= "SELECT idsocios_vivienda, socio_numero, tipo_regimen, calle, numero_exterior, numero_interior, colonia, localidad, estado, municipio, telefono_residencial, telefono_movil, tiempo_residencia, referencia, idusuario, principal, tipo_domicilio, codigo_postal, fecha_alta, codigo, sucursal, eacp, coordenadas_gps
     					    FROM socios_vivienda
     						WHERE socio_numero = " . $this->mCodigo . " ";
     		$rsV		= mysql_query($sqlDV, cnnGeneral() );
     		if($corregir == true){
     			while($rwV	= mysql_fetch_array($rsV) ){
     				$cpostal	= $cTipo->cInt($rwV["codigo_postal"]);
     				$clave		= $rwV["idsocios_vivienda"];
     				if ( strlen($cpostal) < DIGITOS_DE_CODIGO_POSTAL ){
     					$xCl		= new cCajaLocal( $this->mCajaLocal );
     					$xCl->init();
     					$DCL		= $xCl->getDatosInArray();
     					$codigo_postal	= $DCL["codigo_postal"];
     					$sqlUV = "UPDATE socios_vivienda
     						    SET codigo_postal='$codigo_postal'
     						    WHERE idsocios_vivienda=$clave";
     					my_query($sqlUV);
     					$txt	.= "WARN\tCORREC_VIVIENDA\tSe Actualiza el Codigo postal de [$cpostal] a [$codigo_postal] \r\n";
     				}
     			}
     		}*/
     //validar fecha de Ingreso
     /*$mDA		= date("Y", strtotime($this->mFechaDeIngreso) );
     		$mMA		= date("m", strtotime($this->mFechaDeIngreso) );
     		$mAA		= date("d", strtotime($this->mFechaDeIngreso) );
     		$mFValida	= checkdate($mMA, $mAA, $mDA  );
     		if ( $mFValida == false ){
     			$mFSustituta	= EACP_FECHA_DE_CONSTITUCION;
     			$sqlNFI		= "UPDATE socios_general
     							    SET fechaalta=(SELECT fecha_operacion FROM operaciones_recibos WHERE numero_socio = " . $this->mCodigo . " LIMIT 0,1)
     							    WHERE  codigo= " . $this->mCodigo . " ";
     			my_query($sqlNFI);
     			$txt	.= "ERROR\t" . $this->mCodigo . "\tFINGRESO\tLa fecha de Alta no es valida, se Actualiza a la Primera Operacion\r\n";
     
     		}*/
     //Validar modulo de AML
     if (MODULO_AML_ACTIVADO == true) {
         $xAml = new cAMLPersonas($this->getCodigo());
         $xAml->init($this->getCodigo(), $this->getDatosInArray());
         $NRiesgo = $xAml->setAnalizarNivelDeRiesgo();
         if ($this->getNivelDeRiesgo() != $NRiesgo) {
             $ready = false;
             $EsOperable = false;
             $xLog->add("ERROR\t" . $this->mCodigo . "\tRiesgo\tEl riesgo({$NRiesgo}) es diferente al actual(" . $this->getNivelDeRiesgo() . ") \r\n");
             if ($corregir == true) {
                 $this->setActualizarNivelDeRiesgo($NRiesgo, $xAml->getMessages());
             }
         }
         $xLog->add($xAml->getMessages(), $xLog->DEVELOPER);
         //Perfil Transaccional
         $xTrans = new cAMLPersonas_PerfilTransaccional($this->getCodigo());
         if ($xTrans->getNumeroEntradas() <= 0) {
             $ready = false;
             $EsOperable = false;
             $xLog->add("ERROR\t" . $this->mCodigo . "\tPerfilT\tNo existe perfil transaccional \r\n");
         }
     }
     return $xLog->getMessages($out);
 }
 function setAnalizarNivelDeRiesgo()
 {
     if ($this->mOSocio == null) {
         $this->getOPersona();
     }
     $riesgo = 1;
     $factores = 0;
     $this->mMessages .= "====\tPersona: " . $this->mClaveDePersona . "\t====\r\n";
     //revisar matrices
     //revisar si es extranjero
     //Trabajar en localidades riesgosas, paises riesgosas
     if ($this->mOSocio->getEsExtranjero() == true) {
         $factores++;
         $riesgo += 50;
         //riesgo medio
         $this->mMessages .= "WARN\tRiesgo a {$riesgo} por ser Extranjero (Medio)\r\n";
     }
     //si es persona moral, obetener datos del representante
     if ($this->mOSocio->getEsPersonaFisica() == false) {
         $xRels = $this->mOSocio->getORepresentanteLegal();
         if ($xRels == null) {
             $factores++;
             $riesgo += 50;
             $this->mMessages .= "WARN\tRiesgo a {$riesgo}  por no tener Representante Legal\r\n";
         }
     }
     //validar perfil transaccional
     $xPer = new cAMLPersonas_PerfilTransaccional($this->mOSocio->getCodigo());
     if ($xPer->getNumeroEntradas() <= 0) {
         $factores++;
         $riesgo += SYS_RIESGO_MEDIO;
         $this->mMessages .= "WARN\tRiesgo a {$riesgo}  por no tener perfil trasaccional\r\n";
     }
     //revisar su actividad economica
     $OAE = $this->mOSocio->getOActividadEconomica();
     if ($OAE == null) {
         $factores++;
         $riesgo += 50;
         //riesgo medio por no tener info
         $this->mMessages .= "WARN\tRiesgo a {$riesgo}  por no tener Actividad Economica (Medio)\r\n";
     } else {
         $factores++;
         $riesgo += $OAE->getEsRiesgosa() == true ? $OAE->getRiesgoAMLAsociado() : 10;
         $this->mMessages .= "WARN\tRiesgo a {$riesgo}  en Actividad Economica\r\n";
         $this->mMessages .= $OAE->getMessages();
         //checar si su domicilio no esta en paises
         //100% de actividades Riesgosas
         if ($OAE->getRiesgoAMLAsociado() >= SYS_RIESGO_ALTO) {
             $factores = 1;
             $riesgo = SYS_RIESGO_ALTO;
         }
         //actualiza el riesgo de la persona por pep
         if ($OAE->getGeneraPEP() == true) {
             $xOCat = new cPersonasCatalogoOtrosDatos();
             $this->mOSocio->addOtrosParametros($xOCat->AML_PEP_PRINCIPAL, 1);
         }
     }
     //revisar su actividad economica idlocalidad o domicilio
     $ODom = $this->mOSocio->getODomicilio();
     if ($ODom == null) {
         $factores++;
         $riesgo += 50;
         //riesgo medio por no tener info
         $this->mMessages .= "WARN\tRiesgo a {$riesgo} por no tener domicilio (Medio)\r\n";
     } else {
         $factores++;
         //es pais riesgoso
         $pais = $ODom->getClaveDePais();
         if ($pais != EACP_CLAVE_DE_PAIS) {
             $xPais = new cDomiciliosPaises($pais);
             $xPais->init();
             $riesgoPais = $xPais->getRiesgoAMLAsociado();
             $riesgo += $riesgoPais;
             if ($riesgoPais == SYS_RIESGO_ALTO) {
                 $riesgo = $riesgoPais;
                 $factores = 1;
             }
             $this->mMessages .= "WARN\tRiesgo a {$riesgo} agregado {$riesgoPais} del pais {$pais}\r\n";
         } else {
             $riesgo += SYS_RIESGO_BAJO;
             $this->mMessages .= "WARN\tRiesgo a {$riesgo} agregado del pais {$pais}\r\n";
         }
     }
     $riesgo = $riesgo / $factores;
     if ($riesgo > 10 and $riesgo <= 50) {
         $this->mMessages .= "WARN\tRiesgo a MEDIO por {$riesgo} con Factores {$factores} \r\n";
         $riesgo = SYS_RIESGO_MEDIO;
     } else {
         if ($riesgo >= 51) {
             $this->mMessages .= "WARN\tRiesgo a ALTO por {$riesgo} con Factores {$factores} \r\n";
             $riesgo = SYS_RIESGO_ALTO;
         } else {
             $this->mMessages .= "WARN\tRiesgo a BAJO por {$riesgo} con Factores {$factores} \r\n";
             $riesgo = SYS_RIESGO_BAJO;
         }
     }
     //$this->mMessages	.= "WARN\tRiesgo a $riesgo con Factores $factores \r\n";
     //revisar los productos con riesgo
     return $riesgo;
 }
$xP = new cHPage("Pruebas del modulo de lavado de dinero", HP_FORM);
include_once "../core/core.riesgo.reports.php";
$xP->setIncludes();
echo $xP->getHeader();
echo $xP->setBodyinit();
//Crear formularios
$xHFrm = new cHForm("frmTest", "./test.php");
$xHTxt = new cHText("");
//$txt 	= $xHTxt->getDeMoneda("id", "Moneda de Prueba",  100);
$miFecha = fechasys();
$xF = new cFecha(0, $miFecha);
$runTest = isset($_GET["run"]) ? true : false;
$persona_de_pruebas = parametro("persona", 99999, MQL_INT);
$credito_de_pruebas = 29000201;
$xAML = new cAMLPersonas($persona_de_pruebas);
$x2AML = new cAMLPersonas_PerfilTransaccional($persona_de_pruebas);
if ($runTest == true) {
    $xCred = new cCredito($credito_de_pruebas);
    $init = true;
    $xCred->init();
    //Ministrar
    if ($xCred->getEsAfectable() == false) {
        $xCred->setForceMinistracion();
        $xCred->setMinistrar("", DEFAULT_CHEQUE, 0, DEFAULT_CUENTA_BANCARIA, 0, 0, "", '2014-01-01');
        $init = $xCred->init();
    }
    if ($init == true) {
        $xRec = new cReciboDeOperacion(RECIBOS_TIPO_PAGO_CREDITO, true);
        $xRec->setDocumento($xCred->getNumeroDeCredito());
        $xRec->setSocio($xCred->getClaveDePersona());
        $idrec = $xRec->setNuevoRecibo($xCred->getClaveDePersona(), $xCred->getNumeroDeCredito(), fechasys(), 1);