function jsaGetListadoDeAvisos($tipo, $fecha_inicial, $fecha_final)
{
    $tipo = $tipo == SYS_TODAS ? false : $tipo;
    $xF = new cFecha();
    $xAl = new cAml_alerts();
    $xlistas = new cSQLListas();
    $xBtn = new cHButton();
    $xImg = new cHImg();
    $fecha_inicial = $xF->getFechaISO($fecha_inicial);
    $fecha_final = $xF->getFechaISO($fecha_final);
    $sql = $xlistas->getListadoDeRiesgosConfirmados($fecha_inicial, $fecha_final, $tipo);
    // getListadoDeAlertas($tipo, $fecha_inicial, $fecha_final, false, " AND `estado_en_sistema`= " . SYS_UNO);
    $xT = new cTabla($sql);
    $xT->addEspTool($xImg->get24("check", " onclick=\"jsConfirmRiesgo(_REPLACE_ID_)\" "));
    $xT->addEspTool($xImg->get24("delete", " onclick=\"jsDescartarRiesgo(_REPLACE_ID_)\" "));
    $xT->setKeyField($xAl->getKey());
    $xT->setKeyTable($xAl->get());
    return $xT->Show();
}
function jsaGetListadoDeAvisos($tipo, $fecha_inicial, $fecha_final, $todas)
{
    $tipo = $tipo == SYS_TODAS ? false : $tipo;
    $xT = new cTipos();
    $xF = new cFecha();
    $xAl = new cAml_alerts();
    $xlistas = new cSQLListas();
    $xBtn = new cHButton();
    $xImg = new cHImg();
    //
    $ByEstado = $xT->cBool($todas) == true ? "" : " AND `estado_en_sistema`= " . SYS_UNO;
    $ByEstado .= setNoMenorQueCero($tipo) <= 0 ? "" : "  AND (`aml_risk_catalog`.`tipo_de_riesgo` ={$tipo}) ";
    $fecha_inicial = $xF->getFechaISO($fecha_inicial);
    $fecha_final = $xF->getFechaISO($fecha_final);
    $sql = $xlistas->getListadoDeAlertas(false, false, false, false, $ByEstado);
    $xT = new cTabla($sql);
    $xT->setWithMetaData();
    $xT->OButton("TR.Dictaminar", "jsModificarEstatus(_REPLACE_ID_)", $xT->ODicIcons()->REPORTE);
    $xT->OButton("TR.Panel", "jsToPanel(_REPLACE_ID_)", $xT->ODicIcons()->EJECUTAR);
    $xT->setKeyField($xAl->getKey());
    $xT->setKeyTable($xAl->get());
    return $xT->Show();
}
 function sendAlerts($PersonaDeOrigen, $PersonaDeDestino, $TipoDeAlerta, $mensaje = "", $documento = false, $fecha = false, $hora = false, $valorDeterminado = 0, $tipo_de_docto = false, $tercero_relacionado = DEFAULT_SOCIO)
 {
     $hora = setNoMenorQueCero($hora) <= 0 ? date("Hi") : $hora;
     $fecha = $fecha == false ? fechasys() : $fecha;
     $documento = $documento == false ? DEFAULT_RECIBO : $documento;
     $tipo_de_docto = $tipo_de_docto == false ? $this->mTipoDeDocto : $tipo_de_docto;
     $this->mTipoDeDocto = $tipo_de_docto;
     $resultado = true;
     $xRsk = new cAml_risk_catalog();
     $xSuc = new cSucursal();
     $xSuc->init();
     $idnumerico = $xSuc->getClaveNumerica();
     $xRsk->setData($xRsk->query()->initByID($TipoDeAlerta));
     $riesgo = $xRsk->valor_ponderado()->v();
     $nombreRies = $xRsk->descripcion()->v();
     $claseRies = $xRsk->tipo_de_riesgo()->v();
     $valorDeterminado = $valorDeterminado == 0 ? $xRsk->valor_ponderado()->v() : $valorDeterminado;
     $xF = new cFecha();
     $fecha = $xF->getInt($fecha);
     $xAl = new cAml_alerts();
     $xAl->estado_en_sistema(SYS_UNO);
     $xAl->fecha_de_checking(SYS_CERO);
     $xAl->fecha_de_origen($fecha);
     $xAl->fecha_de_registro($xF->getInt(fechasys()));
     $xAl->hora_de_proceso($hora);
     $xAl->documento_relacionado($documento);
     $xAl->medio_de_envio(AML_ALERT_MAIL);
     $xAl->mensaje($mensaje);
     $xAl->riesgo_calificado($valorDeterminado);
     $xAl->tipo_de_aviso($TipoDeAlerta);
     $xAl->sucursal($idnumerico);
     //Verificar
     $xAl->entidad(EACP_CLAVE_CASFIN);
     //Actualizar
     $xAl->usuario(getUsuarioActual());
     $xAl->persona_de_destino($PersonaDeDestino);
     $xAl->persona_de_origen($PersonaDeOrigen);
     $xAl->tipo_de_documento($tipo_de_docto);
     $xAl->tercero_relacionado($tercero_relacionado);
     $id_de_alerta = $xAl->query()->getLastID();
     $xAl->clave_de_control($id_de_alerta);
     $ql = $xAl->query()->insert();
     $res = $ql->save();
     if (setNoMenorQueCero($res) <= 0) {
         $this->mMessages .= "ERROR\tAl guardar registro ({$idnumerico})\r\n";
         if (MODO_DEBUG == true) {
             $this->mMessages .= $ql->getMessages(OUT_TXT);
         }
         $resultado = false;
     }
     //$xCatRiesgo				= new cAml_risk_catalog();
     //$xCatRiesgo->setData( $xCatRiesgo->query()->initByID($TipoDeAlerta) );
     //
     $xCatRiesgos = new cAml_risk_catalog();
     $xCatRiesgos->setData($xCatRiesgos->query()->initByID($TipoDeAlerta));
     $nombre_riesgo = $xCatRiesgos->descripcion()->v();
     //Enviar SMS
     $xMail = new cNotificaciones();
     //obtener los datos del usuario
     $xVUser = new cVistaUsuarios();
     $xD = $xVUser->query()->initByID($PersonaDeDestino);
     $xVUser->setData($xD);
     $userP = $xVUser->codigo_de_persona()->v();
     $mailD = false;
     $telD = false;
     $xSoc = new cSocio($userP);
     if ($xSoc->existe($userP) == true) {
         $xSoc->init();
         $mailD = $xSoc->getCorreoElectronico();
         $telD = $xSoc->getTelefonoPrincipal();
     } else {
         $this->mMessages .= "ERROR\tNo existe la persona de envio {$userP}\r\n";
     }
     //Array de valores
     $arrV = array();
     $fechacorta = $xF->getFechaCorta($xF->getFechaByInt($fecha));
     $arrV["variable_documento_codigo"] = $documento;
     $arrV["variable_docto_fecha"] = $fechacorta;
     $arrV["variable_docto_hora"] = $hora;
     $arrV["variable_nivel_de_riesgo"] = $riesgo;
     $arrV["variable_tipo_de_riesgo"] = $nombreRies;
     $arrV["variable_clasificacion_de_riesgo"] = $claseRies;
     $arrV["variable_codigo_de_alerta"] = $id_de_alerta;
     $arrV["variable_mensaje_de_alerta"] = $mensaje;
     $arrV["variable_url_del_sistema"] = SAFE_HOST_URL;
     //Enviar Mail
     $xFmt = new cFormato(800);
     $xFmt->setUsuario($PersonaDeDestino);
     $xFmt->setPersona($PersonaDeOrigen);
     $xFmt->setProcesarVars($arrV);
     $txtMail = $xFmt->get();
     if ($valorDeterminado > 51 or $this->mForceAvisos == true) {
         $xMail->setTitulo(AML_TITULO_DE_ALERTA);
         $this->mMessages .= $xMail->send($txtMail, $mailD, $telD, $PersonaDeDestino, "{$fechacorta}-{$claseRies}-{$mensaje}", "aml.{$mailD}");
         if ($this->mForceRegRiesgo == true) {
             //Agregar el riesgo
             $xAlert = new cAMLAlertas($id_de_alerta);
             $regFecha = $xF->getFechaByInt($fecha);
             $xAlert->setConfirmaAlerta($mensaje, $regFecha);
             $this->mMessages .= $xAlert->getMessages();
             //$xPAML		= new cAMLPersonas($PersonaDeOrigen);
             //$xPAML->setAgregarPerfilDeRiesgo($TipoDeAlerta, $fecha, $valorDeterminado, $documento, $tipo_de_docto, $PersonaDeDestino, $hora, $tercero_relacionado, $mensaje );
             //$this->mMessages	.= $xPAML->getMessages();
         }
     }
     return $resultado;
 }
function jsaCumplimiento($idsocio)
{
    $xAl = new cAml_alerts();
    $xlistas = new cSQLListas();
    $sql = $xlistas->getListadoDeAlertas(false, false, false, $idsocio);
    $xT = new cTabla($sql);
    $xT->setKeyField($xAl->getKey());
    $xT->setKeyTable($xAl->get());
    return $xT->Show();
}
    if ($xUsr->getNivel() >= USUARIO_TIPO_OFICIAL_CRED or MODO_DEBUG == true or OPERACION_LIBERAR_ACCIONES == true) {
        $xFRM->addToolbar($xBtn->getBasic("TR.Letras Creditos Simples", "jsaGetLetrasAVencer()", "reporte", "idletrav", false));
        $xFRM->addToolbar($xBtn->getBasic("TR.Letras Pendientes", "jsaGetLetrasAVencerTodas()", "reporte", "idletrave", false));
        $xFRM->addToolbar($xBtn->getBasic("TR.Creditos Simples", "jsaGetCreditosSimplesMinistrados()", "lista", "idsimplev", false));
        $xFRM->addToolbar($xBtn->getBasic("TR.Creditos Por Autorizar", "jsaGetCreditosPorAutorizar()", "lista", "idcredaut", false));
        $xFRM->addToolbar($xBtn->getBasic("TR.Creditos Por Ministrar", "jsaGetCreditosPorMinistrar()", "lista", "idcrednpoaut", false));
        $xFRM->OButton("TR.Recibos Emitidos", "jsaGetRecibosEmitidos()", $xBtn->ic()->REPORTE);
    }
    if ($xUsr->getNivel() >= USUARIO_TIPO_GERENTE or OPERACION_LIBERAR_ACCIONES == true) {
        $xFRM->addToolbar($xBtn->getBasic("TR.Ingresos del Dia", "jsGetChart()", "grafico", "idcharts", false));
        $xFRM->addToolbar($xBtn->getBasic("TR.Ingresos del Mes", "jsGetIngresosMensuales()", "grafico", "idimes", false));
        $xFRM->addToolbar($xBtn->getBasic("TR.Ingresos por Empresa", "jsGetIngresosMensualesEmpresas()", "grafico", "idimesemp", false));
    }
} else {
    $xF = new cFecha();
    $xAl = new cAml_alerts();
    $xlistas = new cSQLListas();
    $xBtn = new cHButton();
    $xImg = new cHImg();
    //
    $ByEstado = " AND `estado_en_sistema`= " . SYS_UNO;
    $fecha_inicial = $xF->getDiaInicial();
    $fecha_final = $xF->getDiaFinal();
    $sql = $xlistas->getListadoDeAlertas(false, $fecha_inicial, $fecha_final, false, $ByEstado);
    $xT = new cTabla($sql);
    $xT->setWithMetaData();
    $xT->setKeyField($xAl->getKey());
    $xT->setKeyTable($xAl->get());
    $alerts .= $xT->Show("TR.Alertas");
}
if (MODO_DEBUG == true) {
 function obj()
 {
     $mObj = null;
     switch ($this->mTabla) {
         case TPERSONAS_RELACIONES:
             $mObj = new cSocios_relaciones();
             break;
         case TBANCOS_CUENTAS:
             $mObj = new cBancos_cuentas();
             break;
         case TOPERACIONES_RECIBOS:
             $mObj = new cOperaciones_recibos();
             break;
         case TOPERACIONES_MVTOS:
             $mObj = new cOperaciones_mvtos();
             break;
         case TBANCOS_OPERACIONES:
             $mObj = new cBancos_operaciones();
             break;
         case TBANCOS_CUENTAS:
             $mObj = new cBancos_cuentas();
             break;
         case TCREDITOS_REGISTRO:
             $mObj = new cCreditos_solicitud();
             break;
         case TTESORERIA_MVTOS:
             $mObj = new cTesoreria_cajas_movimientos();
             break;
         case TCATALOGOS_EMPRESAS:
             $mObj = new cSocios_aeconomica_dependencias();
             $this->mCampoDesc = $mObj->nombre_corto()->v();
             break;
         case TCATALOGOS_RELACIONES:
             $mObj = new cSocios_relacionestipos();
             $this->mCampoDesc = $mObj->descripcion_relacionestipos()->get();
             break;
         case TCATALOGOS_ACTIVIDADES_ECONOMICAS:
             $mObj = new cPersonas_actividad_economica_tipos();
             $this->mCampoDesc = $mObj->nombre_de_la_actividad()->get();
             break;
         case TCATALOGOS_LOCALIDADES:
             $mObj = new cCatalogos_localidades();
             $this->mCampoDesc = $mObj->nombre_de_la_localidad()->get();
             break;
         case TCAPTACION_CUENTAS:
             $mObj = new cCaptacion_cuentas();
             break;
         case TCATALOGOS_PAISES:
             $mObj = new cPersonas_domicilios_paises();
             $this->mCampoDesc = $mObj->nombre_oficial()->get();
             break;
         case TPERSONAS_DIRECCIONES:
             $mObj = new cSocios_vivienda();
             break;
         case TPERSONAS_GENERALES:
             $mObj = new cSocios_general();
             break;
         case TPERSONAS_MEMOS:
             $mObj = new cSocios_memo();
             break;
         case TPERSONAS_PERFIL_TRANSACCIONAL:
             $mObj = new cPersonas_perfil_transaccional();
             break;
         case TSEGUMIENTO_LLAMADAS:
             $mObj = new cSeguimiento_llamadas();
             break;
         case TSYSTEM_LOG:
             $mObj = new cGeneral_log();
             break;
         case TCREDITOS_PRODUCTOS_OTROS_PARAMETROS:
             $mObj = new cCreditos_productos_otros_parametros();
             break;
         case TPERSONAS_ACTIVIDAD_ECONOMICA:
             $mObj = new cSocios_aeconomica();
             break;
         case TUSUARIOS_NOTAS:
             $mObj = new cUsuarios_web_notas();
             break;
         case TAML_PERFIL_RIESGO:
             $mObj = new cAml_riesgo_perfiles();
             break;
         case TCATALOGOS_GRADO_RIESGO:
             $mObj = new cAml_risk_levels();
             $this->mCampoDesc = $mObj->nombre_del_nivel()->get();
             break;
         case TAML_REGISTRO_DE_RIESGOS:
             $mObj = new cAml_risk_register();
             $this->mCampoDesc = $mObj->mensajes_del_sistema()->get();
             break;
         case TAML_REGISTRO_DE_RIESGOS:
             $mObj = new cAml_alerts();
             $this->mCampoDesc = $mObj->mensaje()->get();
             break;
         default:
             $mObj = null;
             break;
     }
     if ($mObj != null) {
         $this->mClavePrincipal = $mObj->getKey();
     }
     return $mObj;
 }