//=====================================================================================================
$xHP = new cHPage("TR.REPORTE DE PERSONAS DE ALTO RIESGO", HP_REPORT);
$mql = new cSQLListas();
$xF = new cFecha();
$query = new MQL();
$oficial = elusuario($iduser);
$estatus = parametro("estado", SYS_TODAS);
$frecuencia = parametro("periocidad", SYS_TODAS);
$producto = parametro("convenio", SYS_TODAS);
$producto = parametro("producto", $producto);
$empresa = parametro("empresa", SYS_TODAS);
$out = parametro("out", SYS_DEFAULT);
$fechaInicial = isset($_GET["on"]) ? $xF->getFechaISO($_GET["on"]) : FECHA_INICIO_OPERACIONES_SISTEMA;
$fechaFinal = isset($_GET["off"]) ? $xF->getFechaISO($_GET["off"]) : fechasys();
echo $xHP->getHeader();
$sql = $mql->getListadoDeSocios(" (`socios_general`.`nivel_de_riesgo_aml` >= 50) ", "0,10000");
if ($out == OUT_EXCEL) {
    echo $xHP->setBodyinit();
    $xls = new cHExcel();
    $xls->convertTable($sql, $xHP->getTitle());
} else {
    echo $xHP->setBodyinit("initComponents();");
    $xRPT = new cReportes();
    $xTBL = new cTabla($sql);
    echo $xRPT->getHInicial($xHP->getTitle());
    echo $xTBL->Show();
    echo $xRPT->getPie();
    ?>
	<script>
	<?php 
    ?>
     $oFrm->OButton("TR.ARBOL_DE_RELACIONES", "jsSigmaRelaciones()", $oFrm->ic()->EXPORTAR);
     $oFrm->OButton("TR.Consulta en LISTA_NEGRA", "var xAML = new AmlGen(); xAML.getConsultaListaNegra({$idsocio})", $oFrm->ic()->REGISTROS);
     $xHTabs->addTab("TR.cumplimiento", $xDiv3->get());
     //tab6
     $jsTabs .= ",\n selected: 6\n";
     $xT = new cTabla($xql->getListadoDePerfil($idsocio));
     $xT->addTool(SYS_DOS);
     $xHTabs->addTab("TR.perfil_transaccional", $xT->Show());
     //tab6
 }
 if ($xSoc->getEsEmpresaConConvenio(true) == true) {
     $xT2 = new cHTabs("idcomoempresa");
     $idempresa = $xSoc->getOEmpresa()->getClaveDeEmpresa();
     $oFrm->addEmpresaComandos($idempresa);
     $xTCreds = new cTabla($xql->getListadoDeCreditos(false, false, false, false, " AND (`creditos_solicitud`.`persona_asociada` = {$idempresa}) ", false), 2);
     $xTPers = new cTabla($xql->getListadoDeSocios(" (`socios_general`.`dependencia` = {$idempresa})  "));
     $xTAhorro = new cTabla($xql->getListadoDeIncidenciasAhorro($idempresa));
     $xTPeriodo = new cTabla($xql->getListadoDePeriodoPorEmpresa($idempresa));
     $xTPeriodo->setTdClassByType();
     $xTPeriodo->setEventKey("var xG = new EmpGen(); xG.getOrdenDeCobranza");
     $xTCreds->setTdClassByType();
     $xTPers->setTdClassByType();
     $xTAhorro->setTdClassByType();
     $xModAhorro = "<input type=\"number\" id=\"id" . HP_REPLACE_ID . "\" onblur=\"jsModificarAhorro(this," . HP_REPLACE_ID . ")\" />";
     $xTPers->addEspTool($xModAhorro);
     $xT2->addTab("TR.Trabajadores", $xTPers->Show());
     $xTCreds->setFootSum(array(8 => "saldo"));
     $xT2->addTab("TR.Creditos por empresa", $xTCreds->Show());
     //Ahorro por Empresa
     $xT2->addTab("TR.Ahorro por empresa", $xTAhorro->Show());
     $xT2->addTab("TR.Periodos de Empresa", $xTPeriodo->Show());
function jsShowSocios($texto, $tipo_de_busqueda)
{
    $strTbls = "";
    $ByForm = false;
    $MostrarGars = true;
    $MostrarPartes = true;
    $sqlL = new cSQLListas();
    $WSoc = " `socios_general`.`codigo` != " . DEFAULT_SOCIO . "";
    $WPrel = "";
    $xIc = new cHImg();
    if ($tipo_de_busqueda == "nc") {
        $ByForm = true;
    }
    if (!isset($texto) or trim($texto) == "" or $texto == DEFAULT_SOCIO or $texto == "0") {
        $sqllike = $sqlL->getListadoDeSocios(" tipoingreso != " . TIPO_INGRESO_SDN);
        $table_s = new cTabla($sqllike);
        $table_s->setEventKey("setSocio");
        $table_s->setRowCSS("codigo", "center");
        $table_s->addEspTool("\$xS=new cSocio(_REPLACE_ID_,true);\$D=\$xS->getTotalColocacionActual();PHP::(\$D[SYS_NUMERO]>0) ? \"<div class='noticon'><i class='fa fa-credit-card fa-lg'></i><span class='noticount'>\" . \$D[SYS_NUMERO] . \"</span></div>\":\"\";");
        $strTbls .= $table_s->Show("TR.ULTIMOS REGISTROS");
    } else {
        $texto = trim($texto);
        $texto = strtoupper($texto);
        $completo = explode(" ", $texto);
        $str = fmt_string($completo[0]);
        $marked = false;
        switch ($tipo_de_busqueda) {
            //CURP
            case "c":
                $str = trim(substr($completo[0], 0, 7));
                $WSoc = " (curp LIKE '{$str}%') ";
                break;
                //NUMERO DE SOCIO
            //NUMERO DE SOCIO
            case "s":
                $str = trim(substr($completo[0], 0, 6));
                $WSoc = " (codigo LIKE '{$str}%') ";
                break;
                //NUMERO DEempresa
            //NUMERO DEempresa
            case "e":
                $WSoc = " (dependencia = {$texto}) ";
                break;
                //DEAFULT:
            //DEAFULT:
            default:
                //balam gon lui
                if (isset($completo[1])) {
                    $str = fmt_string($completo[1]);
                    $WSoc .= $str != "*" ? " AND (apellidomaterno LIKE '{$str}%') " : "";
                }
                if (isset($completo[2])) {
                    $str = fmt_string($completo[2]);
                    $WSoc .= $str != "*" ? " AND (nombrecompleto LIKE '{$str}%') " : "";
                }
                if (isset($completo[0])) {
                    $str = fmt_string($completo[0]);
                    $WSoc .= " AND ((apellidopaterno LIKE '{$str}%') OR (nombrecompleto LIKE '%{$str}%') )";
                }
                break;
        }
        if ($tipo_de_busqueda == "pp") {
            $sqllike = "SELECT\n\t\t\t\t\t`creditos_solicitud`.`numero_solicitud`        AS `credito`,\n\t\t\t\t\t`socios`.`codigo`,\n\t\t\t\t\t`socios`.`nombre`,\n\t\t\t\t\t`creditos_solicitud`.`pagos_autorizados`       AS `pagos`,\n\t\t\t\t\t(`creditos_solicitud`.`ultimo_periodo_afectado`+1) AS `periodo`,\n\t\t\t\t\t`creditos_solicitud`.`saldo_actual`            AS `saldo`,\n\t\t\t\t\t`creditos_solicitud`.`monto_parcialidad`       AS `parcialidad` \n\t\t\t\tFROM\n\t\t\t\t\t`creditos_solicitud` `creditos_solicitud` \n\t\t\t\t\t\tINNER JOIN `socios` `socios` \n\t\t\t\t\t\tON `creditos_solicitud`.`numero_socio` = `socios`.`codigo` \n\t\t\t\tWHERE\n\t\t\t\t\t(`creditos_solicitud`.`saldo_actual` >0.99)\n\t\t\t\t\tAND\n\t\t\t\t\t(`creditos_solicitud`.`tipo_convenio` ={$texto}) ORDER BY\t`socios`.`nombre` ";
            $table_s = new cTabla($sqllike);
            $table_s->setEventKey("jsGoRecibo");
            $table_s->setRowCSS("credito", "center");
            $table_s->setKeyField("credito");
            $table_s->setWithMetaData();
            $strTbls .= $table_s->Show("TR.CREDITOS");
        } else {
            $sqllike = $sqlL->getListadoDeSocios($WSoc . " AND tipoingreso != " . TIPO_INGRESO_SDN);
            $table_s = new cTabla($sqllike);
            $table_s->setEventKey("setSocio");
            $table_s->setRowCSS("codigo", "center");
            $table_s->addEspTool($xIc->get24("settings.png", "onclick='jsToPanel(_REPLACE_ID_)'"));
            //$table_s->addSubQuery("SELECT CONCAT(`creditos_solicitud`.`numero_solicitud`, '|', `creditos_solicitud`.`numero_pagos`, '|',`creditos_solicitud`.`periocidad_de_pago`,'|',`creditos_solicitud`.`saldo_actual` ) FROM creditos_solicitud WHERE numero_socio = _REPLACE_ID_", 1);
            $table_s->addEspTool("\$xS=new cSocio(_REPLACE_ID_,true);\$D=\$xS->getTotalColocacionActual();PHP::(\$D[SYS_NUMERO]>0) ? \"<div class='noticon'><i class='fa fa-credit-card fa-lg'></i><span class='noticount'>\" . \$D[SYS_NUMERO] . \"</span></div>\":\"\";");
            $strTbls .= $table_s->Show("TR.PERSONAS QUE COINCIDEN CON LA BUSQUEDA");
        }
    }
    return $strTbls;
}