function jsaMarcarSinInfo($documento, $observaciones, $persona)
{
    $xAml = new cAMLPersonas($persona);
    $xAml->init();
    $xAml->setGuardarDocumentoValidado($documento, AML_KYC_DOCTO_NO_VERIFICADO, $observaciones);
    return $xAml->getMessages(OUT_HTML);
}
function jsaGuardarPerfil($persona, $tipo, $pais, $monto, $numero, $observaciones)
{
    $xAP = new cAMLPersonas($persona);
    $xAP->init();
    $xAP->setGuardarPerfilTransaccional($tipo, $pais, $monto, $numero, $observaciones);
    $QL = new cSQLListas();
    $xT = new cTabla($QL->getListadoDePerfil($persona));
    $xT->addTool(SYS_DOS);
    return $xT->Show() . $xAP->getMessages(OUT_HTML);
}
 function setActualizarNivelDeRiesgo($actualizar = false)
 {
     $xQL = new MQL();
     $xLi = new cSQLListas();
     $xLog = new cCoreLog();
     //$xLi->getInicialDeCuentas()
     $rs = $xQL->getDataRecord($xLi->getInicialDePersonas());
     foreach ($rs as $rows) {
         $persona = $rows["codigo"];
         $xAml = new cAMLPersonas($persona);
         $xAml->init($persona, $rows);
         $riesgo = $xAml->setAnalizarNivelDeRiesgo();
         $NivelActual = $xAml->getOPersona()->getNivelDeRiesgo();
         if ($riesgo != $NivelActual) {
             if ($riesgo >= SYS_RIESGO_MEDIO) {
                 $xLog->add($xAml->getMessages(), $xLog->DEVELOPER);
             }
             if ($actualizar == true) {
                 $xAml->getOPersona()->setActualizarNivelDeRiesgo($riesgo, $xAml->getMessages());
             }
             $xLog->add($xAml->getOPersona()->getMessages(), $xLog->DEVELOPER);
         }
     }
     return $xLog->getMessages();
 }
 /**
  * Efectua operaciones de finalizacion del recibo
  * @param boolean $UpdateSaldo Marca si Actualiza el Saldo del Credito
  */
 function setFinalizarRecibo($UpdateSaldo = false, $tesoreria_cargada = false)
 {
     //generar Poliza a demanda
     $finalizado = true;
     //tranferencia.egresos cheque
     if (MODULO_CAJA_ACTIVADO == false) {
         $tesoreria_cargada = true;
         /* Forzar AML si Tesoreria esta Desactivado */
     }
     /**
      * Modificacion de la condicion de socio por afectar al recibo en SI?
      */
     if ($UpdateSaldo == true) {
         if ($this->mSumaDeRecibo == 0 or $this->mForceUpdateSaldos == true or !isset($this->mSumaDeRecibo) or $this->mSumaDeRecibo == false or $this->mSumaDeRecibo == '') {
             $sqlSUM = "SELECT\n\t\t\t\t\t\t\t\tSUM(`operaciones_mvtos`.`afectacion_real` *  `operaciones_mvtos`.`valor_afectacion`) \tAS 'monto',\n\t\t\t\t\t\t\t\tCOUNT(`operaciones_mvtos`.`idoperaciones_mvtos`)\t\t\t\t\t\t\t\t\t\tAS 'numero',\n\t\t\t\t\t\t\t\t`operaciones_mvtos`.`recibo_afectado`,\n\t\t\t\t\t\t\t\t`operaciones_mvtos`.`socio_afectado`\n\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\t`operaciones_mvtos` `operaciones_mvtos`\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t(`operaciones_mvtos`.`recibo_afectado` =" . $this->mCodigoDeRecibo . ")\n\n\t\t\t\t\t\t\tGROUP BY\n\t\t\t\t\t\t\t\t`operaciones_mvtos`.`recibo_afectado` ";
             $TDRec = obten_filas($sqlSUM);
             $this->mSumaDeRecibo = $TDRec["monto"];
             $this->mNumeroDeMvtos = $TDRec["numero"];
             $this->mMessages .= "SUCESSACT\tMonto Actualizado a " . $this->mSumaDeRecibo . " y # Operaciones " . $this->mNumeroDeMvtos . "\r\n";
         }
         if (!isset($this->mSumaDeRecibo)) {
             $this->mSumaDeRecibo = 0;
         }
         $sql = "UPDATE operaciones_recibos SET total_operacion=" . $this->mSumaDeRecibo . "\n    \t\t\t\tWHERE\tidoperaciones_recibos= " . $this->mCodigoDeRecibo . "\t";
         $xRs = my_query($sql);
     }
     if ($this->mSetGenerarPoliza == true) {
         //PolizaPorRecibo($this->mCodigoDeRecibo, GENERAR_POLIZAS_AL_CIERRE);
     }
     $this->mTotalRecibo = $this->mSumaDeRecibo;
     //-- AML
     if (MODULO_AML_ACTIVADO == true and $this->isPagable() == true and $tesoreria_cargada == true) {
         $xAml = new cAMLPersonas($this->mSocio);
         $xAml->init();
         $xAml->setForceAlerts();
         $xAmlO = new cAMLOperaciones();
         $this->init();
         if ($xAml->getEsPersonaVigilada() == true) {
             $tipo_de_pago_aml = $this->mTipoDePago;
             if (setNoMenorQueCero($this->mTipoOrigenAML) > 0) {
                 $xRisK = new cPersonas_perfil_transaccional_tipos();
                 $xRisK->query()->initByID($this->mTipoOrigenAML);
                 $tipo_de_pago_aml = strtolower($xRisK->tipo_de_exhibicion()->v(OUT_TXT));
                 $this->mMessages .= "WARN\tCambiar el perfil de pago de " . $this->mTipoDePago . " a {$tipo_de_pago_aml} \r\n";
             }
             $res = $xAmlO->analizarOperacion($this->mSocio, 0, $this->mMoneda, $tipo_de_pago_aml, $this->getFechaDeRecibo(), $this->getCodigoDeRecibo(), $this->mTipoOrigenAML);
             if ($res == false) {
                 $this->mMessages .= "OK\tAML Normal \r\n";
                 if (MODO_DEBUG == true) {
                     $this->mMessages .= $xAmlO->getMessages(OUT_TXT);
                 }
             } else {
                 //REPORTAR
                 $xAv = new cAML();
                 if ($xAmlO->getTipoDeReporte() == AML_REPORTE_INMEDIATO) {
                     $xAv->setForceRegistroRiesgo();
                     $this->mMessages .= "WARN\tAML de Aviso Inmediato\r\n";
                 }
                 $xAv->sendAlerts($this->mSocio, AML_OFICIAL_DE_CUMPLIMIENTO, $xAmlO->getTipoDeAlerta(), $xAmlO->getMessageAlert(), $this->mCodigoDeRecibo, $this->mFechaDeOperacion);
             }
             $this->mMessages .= $xAmlO->getMessages(OUT_TXT);
             //validar perfil transaccional
             $xAml->setVerificarPerfilTransaccional();
         }
         //Validar si es person riesgosa
         $xSoc = $xAml->getOPersona();
         if ($xSoc->getEsPersonaSDN() == true) {
             //REPORTAR operaciones con alto riesgo
             $idriesgo = AML_ID_OPERACIONES_PERSONAS_ALTO_RIESGO;
             //operaciones con criminales
             $xRiesgo = new cAml_risk_catalog();
             $xRiesgo->setData($xRiesgo->query()->initByID($idriesgo));
             $xAv = new cAML();
             $xAv->setForceRegistroRiesgo();
             $xAv->sendAlerts($this->mSocio, AML_OFICIAL_DE_CUMPLIMIENTO, $idriesgo, "ERROR\tOperaciones con persona ALTAMENTE RIESGOSA Recibo " . $this->mCodigoDeRecibo, $this->mCodigoDeRecibo, $this->getFechaDeRecibo());
             $this->mMessages .= $xAv->getMessages(OUT_TXT);
         }
         if ($xSoc->getEsPersonaPoliticamenteExpuesta() == true) {
             //REPORTAR operaciones con PEPs
             $idriesgo = AML_ID_OPERACIONES_PERSONAS_PEP;
             //operaciones con criminales
             $xRiesgo = new cAml_risk_catalog();
             $xRiesgo->setData($xRiesgo->query()->initByID($idriesgo));
             $xAv = new cAML();
             $xAv->sendAlerts($this->mSocio, AML_OFICIAL_DE_CUMPLIMIENTO, $idriesgo, "ERROR\tOperaciones con PEPS Recibo " . $this->mCodigoDeRecibo, $this->mCodigoDeRecibo, $this->getFechaDeRecibo());
             $this->mMessages .= $xAv->getMessages(OUT_TXT);
         }
         if ($xSoc->getEsPersonaRiesgosa() == true) {
             //REPORTAR operaciones con PEPs
             $idriesgo = 101005;
             //operaciones con criminales
             $xRiesgo = new cAml_risk_catalog();
             $xRiesgo->setData($xRiesgo->query()->initByID($idriesgo));
             $xAv = new cAML();
             $xAv->sendAlerts($this->mSocio, AML_OFICIAL_DE_CUMPLIMIENTO, $idriesgo, "ERROR\tOperaciones con Personas de Alto Riesgo.- Recibo " . $this->mCodigoDeRecibo, $this->mCodigoDeRecibo, $this->getFechaDeRecibo());
             $this->mMessages .= $xAv->getMessages(OUT_TXT);
         }
         //Operaciones de una exhibicion 500 y USD
         if ($this->mMoneda != AML_CLAVE_MONEDA_LOCAL) {
             $idriesgo = AML_CLAVE_RIESGO_OPS_INDIVIDUALES;
             $xRiesgo = new cAml_risk_catalog();
             $xMon = new cMonedas($this->mMoneda);
             $xRiesgo->setData($xRiesgo->query()->initByID($idriesgo));
             $unidades = $xMon->getEnDolares($this->getUnidadesOriginales());
             if ($unidades >= $xRiesgo->unidades_ponderadas()->v()) {
                 $xAv = new cAML();
                 $xAv->setForceRegistroRiesgo();
                 $xAv->sendAlerts($this->mSocio, AML_OFICIAL_DE_CUMPLIMIENTO, $idriesgo, "Operaciones({$unidades}) excedidas de 500 USD en el recibo " . $this->mCodigoDeRecibo . " Moneda " . $this->mMoneda, $this->mCodigoDeRecibo, $this->getFechaDeRecibo());
                 $this->mMessages .= $xAv->getMessages(OUT_TXT);
             } else {
                 $this->mMessages .= "OK\tNo hay modificacion para la Moneda " . $this->mMoneda . " por {$unidades} \r\n";
             }
         }
         // Agregar Relevantes por 10000USD
         if ($this->isEfectivo() == true) {
             $idriesgo = AML_CLAVE_RIESGO_OPS_RELEVANTES;
             $xRiesgo = new cAml_risk_catalog();
             $xMon = new cMonedas($this->mMoneda);
             $mmonto = $this->mMoneda == AML_CLAVE_MONEDA_LOCAL ? $this->getTotal() : $this->getUnidadesOriginales();
             $xRiesgo->setData($xRiesgo->query()->initByID($idriesgo));
             $unidades = $xMon->getEnDolares($mmonto);
             if ($unidades >= $xRiesgo->unidades_ponderadas()->v()) {
                 $xAv = new cAML();
                 $xAv->setForceRegistroRiesgo();
                 $xAv->sendAlerts($this->mSocio, AML_OFICIAL_DE_CUMPLIMIENTO, $idriesgo, "Operaciones Relevantes por {$unidades} USD en el recibo " . $this->mCodigoDeRecibo . " Moneda " . $this->mMoneda, $this->mCodigoDeRecibo, $this->getFechaDeRecibo());
                 $this->mMessages .= $xAv->getMessages(OUT_TXT);
             } else {
                 $this->mMessages .= "OK\tNo hay modificacion para la Moneda " . $this->mMoneda . " por {$unidades} \r\n";
             }
         }
         if ($xAml->getEsPersonaVigilada() == true) {
             //Operaciones Internas Preocupantes por Usuario
             $xAml->setAnalizarTransaccionalidadPorNucleo($this->mCodigoDeRecibo, $this->mFechaDeOperacion, $this->mUsuario, true);
         }
         $this->mMessages .= $xAml->getMessages(OUT_TXT);
     }
     return $finalizado;
 }
$xT->setTipoSalida($out);
$xT->setFootSum(array(4 => "monto", 9 => "unidades", 10 => "equivalencia"));
$body = $xRPT->getEncabezado($xHP->getTitle(), $FechaInicial, $FechaFinal);
$xRPT->setBodyMail($body);
$xRPT->addContent($body);
$xRPT->addContent($xSoc->getFicha(true));
//$xT->setEventKey("jsGoPanel");
//$xT->setKeyField("creditos_solicitud");
$xRPT->addContent($xT->Show($xHP->getTitle()));
$xT = new cTabla($xL->getListadoDePerfil($persona));
$xRPT->addContent($xT->Show());
if (MODO_DEBUG == true) {
    $periodo_inicial = date("Ym", $xF->getInt($FechaInicial));
    $periodo_final = date("Ym", $xF->getInt($FechaFinal));
    $xT2 = new cTabla($xL->getAMLAcumuladoDeEgresos($periodo_inicial, $periodo_final, $persona));
    $xRPT->addContent($xT2->Show());
}
$xRPT->addContent("<h3>" . $xHP->lang("Mensaje") . "</h3>");
//============ Agregar HTML
//$xRPT->addContent( $xHP->init($jsEvent) );
//$xRPT->addContent( $xHP->end() );
$xAml = new cAMLPersonas($persona);
$xAml->init();
$validar = false;
//(MODO_DEBUG == true) ? true : false;
$xAml->setVerificarPerfilTransaccional(false, $validar);
$xAml->setVerificarOperacionesSemestrales();
$xRPT->addContent($xAml->getMessages(OUT_HTML));
$xRPT->setResponse();
$xRPT->setSenders($senders);
echo $xRPT->render(true);
function jsaValidarPerfilTransaccional($persona)
{
    $xAml = new cAMLPersonas($persona);
    $xAml->init();
    $validar = false;
    //(MODO_DEBUG == true) ? true : false;
    $xAml->setVerificarPerfilTransaccional(false, $validar);
    $xAml->setVerificarOperacionesSemestrales();
    return $xAml->getMessages(OUT_HTML);
}
        //$xAml->setForceAlerts();
        $xAml->setVerificarDocumentosCompletos($fechaop);
        $xAml->setVerificarDocumentosVencidos($fechaop);
        $messages .= $xAml->getMessages(OUT_TXT);
        /*$xAml	= new cAML();
        		$xAml->setForceAlerts(true);
        		$xAml->sendAlerts(getUsuarioActual(), $PersonaDeDestino, $TipoDeAlerta);*/
        //envio de informes
        //TODO: Agregar envio de informes
        //checar perfil transaccional mensual
    }
    //verificar operaciones de 6 meses excedidas de maximo permitido
    $sql2 = "SELECT\n\t`operaciones_recibos`.`fecha_operacion`              AS `fecha`,\n\t`operaciones_recibos`.`numero_socio`                 AS `persona`,\n\tCOUNT(`operaciones_recibos`.`idoperaciones_recibos`) AS `operaciones`,\n\tSUM(`operaciones_recibos`.`total_operacion`)         AS `monto`\n\tFROM\n\t`operaciones_recibos` `operaciones_recibos`\n\tWHERE\n\t(`operaciones_recibos`.`fecha_operacion` = '{$fechaop}')\n\tGROUP BY\n\t`operaciones_recibos`.`numero_socio`";
    $rs1 = $mql->getDataRecord($sql2);
    foreach ($rs1 as $rw1) {
        $xAml = new cAMLPersonas($rw1["persona"]);
        $xF = new cFecha();
        $fecha_inicial = $xF->setRestarMeses(6, $fechaop);
        $obj = $xAml->getOAcumuladoDeOperaciones($fecha_inicial, $fechaop);
    }
    //Relaciones Recursivas
    //$xUtils				= new cAMLUtils();
    $xCML = new cAML();
} else {
    $messages .= "=========================\tNO ACTIVADO\t====================\r\n";
}
$xLog->setWrite($messages);
$xLog->setClose();
if (ENVIAR_MAIL_LOGS == true) {
    $xLog->setSendToMail("TR.Eventos del Cierre de Riesgos");
}
$persona = parametro("socio", $persona, MQL_INT);
$persona = parametro("idsocio", $persona, MQL_INT);
$credito = parametro("credito", DEFAULT_CREDITO, MQL_INT);
$credito = parametro("idsolicitud", $credito, MQL_INT);
$credito = parametro("solicitud", $credito, MQL_INT);
$cuenta = parametro("cuenta", DEFAULT_CUENTA_CORRIENTE, MQL_INT);
$cuenta = parametro("idcuenta", $cuenta, MQL_INT);
$jscallback = parametro("callback");
$tiny = parametro("tiny");
$form = parametro("form");
$action = parametro("action", SYS_NINGUNO);
$xHP->init();
$xFRM = new cHForm("frm", "./");
//$xSoc		= new cSocio($persona);
//if( $xSoc->init()== true){
$xAml = new cAMLPersonas($persona);
$xAml->init();
$ln = $xAml->getBuscarEnListaNegra();
//$xFRM->addHElem("<a href=\"" . $xAml->getReporteConsultaListaNegra() . "\">CDescargar</a>" );
$xFRM->OButton("TR.Descargar Consulta", "jsGetConsulta()", $xFRM->ic()->DESCARGAR);
$xFRM->addAviso($xAml->getMessages());
//}
$msg = "";
//$xFRM->addJsBasico();
//$xFRM->addCreditBasico();
//$xFRM->addSubmit();
echo $xFRM->get();
?>
<script>
var xURL		= "<?php 
echo $xAml->getReporteConsultaListaNegra();
 function setCuandoSeActualiza()
 {
     //Actualizar Relaciones
     $xQl = new MQL();
     $rs = $xQl->getDataRecord("SELECT * FROM `socios_relaciones` WHERE `numero_socio`= " . $this->mCodigo);
     $xcRel = new cSocios_relaciones();
     foreach ($rs as $rows) {
         $xcRel->setData($rows);
         $id = $xcRel->idsocios_relaciones()->v();
         $persona = $xcRel->socio_relacionado()->v();
         $xRe = new cPersonasRelaciones($id, $persona);
         if ($xRe->init() == true) {
             $xRe->setActualizarPorPersona();
             $this->mMessages .= $xRe->getMessages();
         }
     }
     //Actualizar Empresa
     if ($this->getEsEmpresaConConvenio(true) == true) {
         $xEmp = $this->getOEmpresa();
         if ($xEmp != null) {
             $xEmp->setActualizarPorPersona();
             $this->mMessages .= $xEmp->getMessages();
         }
     }
     //Actualizar Grupo Solidario
     if ($this->getEsGrupoSolidario(true)) {
         $xGrp = $this->getOGrupoSol();
         if ($xGrp != null) {
             $xGrp->setActualizarPorPersona();
             $this->mMessages .= $xGrp->getMessages();
         }
     }
     //actualizar Sucursal
     if ($this->getEsSucursal() == true) {
         $xSuc = new cSucursal($this->mIDSucursal);
         $xSuc->setActualizarPorPersona();
         $this->mMessages .= $xSuc->getMessages();
     }
     //Actualizar Usuario
     if ($this->getEsUsuario(true)) {
         $xUsr = $this->getOUsuario();
         if ($xUsr != null) {
             $xUsr->setActualizarPorPersona();
             $this->mMessages .= $xUsr->getMessages();
         }
     }
     if (MODULO_AML_ACTIVADO == true and $this->mNoAML == false) {
         $xAML = new cAMLPersonas($this->mCodigo);
         $xAML->init($this->mCodigo, $this->getDatosInArray());
         $riesgo = $xAML->setAnalizarNivelDeRiesgo();
         if ($riesgo != $this->getNivelDeRiesgo()) {
             $this->setActualizarNivelDeRiesgo($riesgo, $xAML->getMessages());
         }
         $xAML->setActualizarRiesgoPorNucleo();
         $this->mMessages .= $xAML->getMessages();
     }
 }
$persona = parametro("idsocio", $persona, MQL_INT);
$credito = parametro("credito", DEFAULT_CREDITO, MQL_INT);
$credito = parametro("idsolicitud", $credito, MQL_INT);
$credito = parametro("solicitud", $credito, MQL_INT);
$cuenta = parametro("cuenta", DEFAULT_CUENTA_CORRIENTE, MQL_INT);
$cuenta = parametro("idcuenta", $cuenta, MQL_INT);
$jscallback = parametro("callback");
$tiny = parametro("tiny");
$form = parametro("form");
$action = parametro("action", SYS_NINGUNO);
$xF = new cFecha();
$xAml = new cAML();
$nivelcargado = SYS_RIESGO_BAJO;
$notas = "";
if ($persona > DEFAULT_SOCIO) {
    $xAml = new cAMLPersonas($persona);
    if ($xAml->init() == true) {
        $nivelcargado = $xAml->setAnalizarNivelDeRiesgo();
        $notas = $xAml->getMessages();
    }
}
//$jxc = new TinyAjax();
//$jxc ->exportFunction('datos_del_pago', array('idsolicitud', 'idparcialidad'), "#iddatos_pago");
//$jxc ->process();
$xHP->init();
//$jxc ->drawJavaScript(false, true);
$xFRM = new cHForm("frmriesgo", "registro_persona_riesgosa.frm.php?action=" . MQL_ADD);
$xBtn = new cHButton();
$xTxt = new cHText();
$xSel = new cHSelect();
$xFec = new cHDate();
//=====================================================================================================
$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());