$xTabla->setData($xTabla->query()->initByID($clave));
            $xTabla->setData($_REQUEST);
            $xTabla->query()->update()->save($clave);
            $xFRM->addAvisoRegistroOK();
        }
    }
}
$xHP->init();
$msg = "";
$xAlert = new cAMLAlertas($codigo);
$xAlert->init();
$xFRM->addAviso($xAlert->getDescripcion());
$xFRM->OTextArea("razones_de_reporte", $xTabla->razones_de_reporte()->v(), "TR.AML_TEXTO_A");
$xFRM->OTextArea("acciones_tomadas", $xTabla->acciones_tomadas()->v(), "TR.AML_TEXTO_B");
$xFRM->OTextArea("notas_de_checking", $xTabla->notas_de_checking()->v(), "TR.Observaciones de la operacion");
$xFRM->OHidden("clave_de_riesgo", $xTabla->clave_de_riesgo()->v(), "");
$xFRM->OHidden("fecha_de_checking", $xF->getInt(), "");
echo $xFRM->get();
?>
<script>
var xG		= new Gen();
//function jsDescartaRiesgo(){ xG.confirmar({ msg : "Desea Descartar la Alerta como Riesgo?", callback : "jsaDescartaRiesgo()", evaluador : jsRazonNoVacia(), alert : "La observacion no puede quedar vacia"}); }
//function jsConfirmaRiesgo(){ xG.confirmar({ msg : "Desea Confirmar la Alerta como Riesgo?", callback : "jsaConfirmaRiesgo()", evaluador : jsRazonNoVacia(), alert : "La observacion no puede quedar vacia" }); }
function jsRazonNoVacia(){
	var valid	= new ValidGen();
	return valid.NoVacio( $("#notas_de_checking").val() );
}

//function jsSalir(){ xG.close(); }
</script>
<?php 
 function add($persona, $tipo, $fecha, $valor, $documento, $tipo_de_documento = false, $usuario = false, $hora = false, $instrumento = false, $tipo_de_operacion = false, $tercero_relacionado = DEFAULT_SOCIO, $mensajes = "", $inmediato = false)
 {
     $hora = $hora == false ? date("Hi") : $hora;
     $usuario = $usuario == false ? getUsuarioActual() : $usuario;
     $tipo_de_documento = $tipo_de_documento == false ? iDE_RECIBO : $tipo_de_documento;
     $instrumento = setNoMenorQueCero($instrumento);
     if ($instrumento <= 0 or setNoMenorQueCero($tipo_de_operacion) <= 0) {
         switch ($tipo_de_documento) {
             case iDE_RECIBO:
                 $EqOps = new cSistemaEquivalencias(TOPERACIONES_RECIBOSTIPOS);
                 $EqTes = new cSistemaEquivalencias(TTESORERIA_TIPOS_DE_PAGO);
                 $xRec = new cReciboDeOperacion(false, false, $documento);
                 $instrumento = $EqTes->get($xRec->getTipoDePago());
                 $tipo_de_operacion = $EqOps->get($xRec->getTipoDeRecibo());
                 if ($xRec->isDivisaExtranjera() == true) {
                     $instrumento = AML_OPERACIONES_CLAVE_DIVISA;
                 }
                 if ($tipo_de_operacion == null) {
                     $tipo_de_operacion = "01";
                 }
                 break;
         }
     }
     if ($inmediato == true) {
         $inmediato = 1;
     }
     $inmediato = setNoMenorQueCero($inmediato);
     $xPR = new cAml_risk_register();
     $xPR->clave_de_riesgo($xPR->query()->getLastID());
     $xPR->escore($valor);
     $xPR->fecha_de_reporte($fecha);
     $xPR->hora_de_reporte($hora);
     $xPR->persona_relacionada($persona);
     $xPR->tipo_de_riesgo($tipo);
     $xPR->usuario_de_origen($usuario);
     $xPR->tipo_de_documento($tipo_de_documento);
     $xPR->documento_relacionado($documento);
     $xPR->estado_de_envio(SYS_UNO);
     $xPR->fecha_de_envio(0);
     $xPR->estado_de_envio(0);
     $xPR->fecha_de_checking(0);
     $xPR->oficial_de_checking(AML_OFICIAL_DE_CUMPLIMIENTO);
     $xPR->monto_total_relacionado(0);
     //cargar datos del recibo
     $xPR->instrumento_financiero($instrumento);
     //mejorar segun catalogo CNBV
     $xPR->tipo_de_operacion($tipo_de_operacion);
     $xPR->tercero_relacionado($tercero_relacionado);
     $xPR->mensajes_del_sistema($mensajes);
     $xPR->reporte_inmediato($inmediato);
     $ql = $xPR->query()->insert();
     $ql->save();
     $this->mMessages .= $ql->getMessages(OUT_TXT);
 }
$xHP->init();
$xTxt = new cHText();
$xSel = new cHSelect();
/* ===========		FORMULARIO		============*/
$clave = parametro("clave_de_riesgo", null, MQL_INT);
$xTabla = new cAml_risk_register();
if ($clave != null) {
    $xTabla->setData($xTabla->query()->initByID($clave));
}
$xTabla->setData($_REQUEST);
$clave = parametro("id", null, MQL_INT);
$xSel = new cHSelect();
if ($clave == null) {
    $step = MQL_ADD;
    $clave = $xTabla->query()->getLastID() + 1;
    $xTabla->clave_de_riesgo($clave);
} else {
    $step = MQL_MOD;
    if ($clave != null) {
        $xTabla->setData($xTabla->query()->initByID($clave));
    }
}
$xFRM = new cHForm("frmaml_risk_register", "riesgo.editar.frm.php?action={$step}");
if ($step == MQL_MOD) {
    $xFRM->addGuardar();
} else {
    $xFRM->addSubmit();
}
$clave = parametro($xTabla->getKey(), null, MQL_INT);
if (($action == MQL_ADD or $action == MQL_MOD) and $clave != null) {
    $xTabla->setData($xTabla->query()->initByID($clave));