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();
}
$ByType = "";
echo $xHP->setBodyinit();
if ($persona != DEFAULT_SOCIO) {
    $xSoc = new cSocio($persona);
    $xSoc->init();
    $ByType = $xSoc->getEsPersonaFisica() == true ? BASE_DOCTOS_PERSONAS_FISICAS : BASE_DOCTOS_PERSONAS_MORALES;
}
$xFRM = new cHForm("frmfirmas", "personas_documentos.frm.php?action=" . SYS_UNO . "&persona={$persona}");
$xFRM->setEnc("multipart/form-data");
$xFRM->setTitle($xHP->getTitle());
$xBtn = new cHButton();
$xTxt = new cHText();
$xTxt2 = new cHText();
$xTxtF = new cHText();
$xSel = new cHSelect();
$xImg = new cHImg();
if ($action == SYS_CERO) {
    $xTxtF->setDivClass("");
    //$xTxtF->setProperty("class", "")
    $xFRM->OFile("idnuevoarchivo", "", "TR.Cargar Documento");
    $xFRM->OText("iddocumento", "", "TR.Nombre del Archivo", true, $xImg->get24("common/search.png", " onclick='jsGetDocto()' "));
    $xFRM->addHElem($xSel->getTiposDeDoctosPersonales("", $ByType)->get(true));
    $xFRM->addHElem($xTxt2->getDeMoneda("idnumeropagina", "TR.Numero de Pagina"));
    $xFRM->addObservaciones();
    $xFRM->addSubmit();
} else {
    $xFRM->addCerrar();
    $doc1 = parametro("iddocumento", "", MQL_RAW);
    $observaciones = isset($DDATA["idobservaciones"]) ? $DDATA["idobservaciones"] : "";
    $tipodedocto = isset($DDATA["idtipodedocto"]) ? $DDATA["idtipodedocto"] : "";
    $pagina = isset($DDATA["idnumeropagina"]) ? $DDATA["idnumeropagina"] : "";
 function getDeSocio($id = "", $SinBoton = false, $persona = false, $blurEvents = "", $titulo = "")
 {
     $this->mArrProp["type"] = "number";
     $this->mArrProp["class"] = "mny";
     $this->mArrProp["name"] = "idsocio{$id}";
     $persona = setNoMenorQueCero($persona) < 0 ? getPersonaEnSession() : $persona;
     $this->mValue = $persona;
     $this->mArrProp["maxlength"] = "18";
     $xLn = new cLang();
     //$titulo			= $xLn->get("clave de persona");//($titulo == "") ? $xLn->get("clave de persona") : $xLn->getT($titulo);
     $titulo2 = $titulo == "" ? $xLn->get("nombre completo") : $xLn->getT($titulo);
     //$this->addEvent("envsoc()", "onchange");
     $this->addEvent("var xPG = new PersGen();xPG.getNombre(this.value, 'nombresocio{$id}');{$blurEvents}", "onblur");
     $this->mIncLabel = true;
     if ($SinBoton == false) {
         $xBtn = new cHImg();
         $this->setClearHTML();
         $this->addHTMLCode($xBtn->get16("common/search.png", " onclick=\"var xPG = new PersGen();xPG.getFormaBusqueda('idsocio{$id}');\" "));
     }
     $xhNSocio = new cHInput("nombresocio{$id}", "", $titulo2);
     $xhNSocio->setIncludeLabel(false);
     $xhNSocio->setProperty("name", "nombresocio{$id}");
     $xhNSocio->setProperty("disabled", "true");
     $this->setDivClass("tx14");
     $xhNSocio->setDivClass("tx34");
     return "<div class='tx1'> " . $this->get("idsocio{$id}", $persona, $xLn->get("clave de persona")) . $xhNSocio->get("nombresocio{$id}") . "</div>";
 }
 function getListadoDeCobranza($empresa, $periocidad, $variacion, $periodo, $fechaInicial = false, $fechaFinal = false, $uso = false)
 {
     $ByPeriodo = $periocidad == "todos" ? "" : " AND creditos_solicitud.periocidad_de_pago = {$periocidad} ";
     $xF = new cFecha();
     $fechaFinal = $xF->getFechaISO($fechaFinal);
     $fechaInicial = $xF->getFechaISO($fechaInicial);
     $xQl = new MQL();
     $xEmp = new cEmpresas($empresa);
     $creditoON = array();
     $DDias = $xEmp->getDiasDeAviso();
     $sqletras = "SELECT\t`creditos_solicitud`.`persona_asociada`, `letras`.* \n\t\t\t\t\t\tFROM\t`creditos_solicitud` `creditos_solicitud`\t\tINNER JOIN `letras` `letras`\tON `creditos_solicitud`.`numero_solicitud` = `letras`.`docto_afectado` \n    \t\t\t\t\tWHERE\t(`creditos_solicitud`.`persona_asociada` ={$empresa}) ";
     //setLog($sqletras);
     $rsCal = $xQl->getDataRecord($sqletras);
     $DCal = array();
     foreach ($rsCal as $dscal) {
         $ixcredito = $dscal["docto_afectado"];
         $ixperiodo = $dscal["periodo_socio"];
         $DCal["{$ixcredito}-{$ixperiodo}"] = $dscal["letra"];
     }
     $ByMinistracion = "";
     $periodo = $periodo + $variacion;
     //filtrar domicilio -> socio -> credito -> letra
     $sql = "SELECT\n    creditos_solicitud.numero_socio AS 'persona',\n    CONCAT(\n    (CASE WHEN (socios_general.dependencia != creditos_solicitud.persona_asociada) THEN '(*)' ELSE '' END ), \n    socios_general.nombrecompleto, ' ',\n    socios_general.apellidopaterno, ' ',\n    socios_general.apellidomaterno \n\t) AS 'nombre', \n\n    creditos_solicitud.numero_solicitud AS 'credito',\n    \n\tgetParcialidadPorFecha(ultimo_periodo_afectado, {$variacion}, '{$fechaFinal}', `primeras_letras`.`fecha_de_pago`, fecha_ministracion) AS 'letra',\n   `creditos_solicitud`.`pagos_autorizados`  AS 'pagos',\n   \n    creditos_solicitud.monto_parcialidad AS 'monto'\n\tFROM\n\t\t`creditos_solicitud` `creditos_solicitud` \n\t\t\tINNER JOIN `creditos_periocidadpagos` `creditos_periocidadpagos` \n\t\t\tON `creditos_solicitud`.`periocidad_de_pago` = \n\t\t\t`creditos_periocidadpagos`.`idcreditos_periocidadpagos` \n\t\t\t\tINNER JOIN `primeras_letras` `primeras_letras` \n\t\t\t\tON `creditos_solicitud`.`numero_solicitud` = `primeras_letras`.\n\t\t\t\t`docto_afectado` \n\t\t\t\t\tINNER JOIN `socios_general` `socios_general` \n\t\t\t\t\tON `creditos_solicitud`.`numero_socio` = `socios_general`.\n\t\t\t\t\t`codigo`\n    \n    WHERE \n    `creditos_solicitud`.persona_asociada\t= {$empresa}\n    AND saldo_actual > " . TOLERANCIA_SALDOS . "\n    AND (`primeras_letras`.`fecha_de_pago` <= '{$fechaFinal}'  OR creditos_solicitud.ultimo_periodo_afectado >= 2)\n    {$ByPeriodo}\n    AND (creditos_solicitud.ultimo_periodo_afectado+(1+({$variacion}))) > 0\n    AND (creditos_solicitud.ultimo_periodo_afectado+(1+({$variacion}))) <= creditos_solicitud.pagos_autorizados\n    ORDER BY ultimo_periodo_afectado DESC, fecha_ministracion,\n\tsocios_general.nombrecompleto\n    ";
     //setLog($sql);
     $dato = $xQl->getDataRecord($sql);
     $tr = "";
     $xBt = new cHImg();
     $ixx = 1;
     $numero = 0;
     $suma = 0;
     $xT = new cTipos();
     foreach ($dato as $rw) {
         $credito = $rw["credito"];
         $creditoON[$credito] = $credito;
         $letra = $rw["letra"];
         $lmonto = $xT->cFloat($rw["monto"], 2);
         $numero++;
         $suma += $lmonto;
         $cssN = "";
         $notas = "";
         $cls = $ixx == 2 ? " class='trOdd' " : "";
         $dif = 0;
         if (isset($DCal["{$credito}-{$letra}"])) {
             $dlmonto = round($DCal["{$credito}-{$letra}"], 2);
             $dif = round($dlmonto - $lmonto, 2);
             if ($dif != 0) {
                 if ($dif > 0.01 or $dif < -0.01) {
                     $notas = "Diferencia por {$dif} en la Parcialidad {$letra}, Plan de Pagos : " . $dlmonto . " Monto de Parcialidad : " . $lmonto;
                     $cls = " class='warn' ";
                 } else {
                     //+01 -01
                     $lmonto = round($dlmonto, 2);
                     $cls = " class='warn' ";
                 }
             }
         }
         $td = "<tr{$cls} id='tr-{$credito}'>";
         $td .= "<th>" . $rw["persona"] . "</th>";
         $td .= "<td>" . $rw["nombre"] . "</td>";
         $td .= "<td>" . $rw["credito"] . "</td>";
         $td .= "<td><input type=\"number\" id=\"periodo-{$credito}\" value=\"" . $rw["letra"] . "\" /></td>";
         $td .= "<th>" . $rw["pagos"] . "</th>";
         $td .= "<td><input type=\"number\" id=\"monto-{$credito}\" value=\"" . $lmonto . "\" /></td>";
         $td .= "<td><input type=\"text\" id=\"notas-{$credito}\" value=\"" . "" . "\"/></td>";
         //$td		.= "<td><input type=\"number\" id=\"saldo-$credito\" value=\"" . $rw["monto"] . "\" /></td>";
         $td .= "<td class='toolbar-24' id=\"options-{$credito}\">";
         $td .= $xBt->get24("calendar.png", " onclick=\"getPlanDePagos(" . $rw["credito"] . ")\" ");
         $td .= $xBt->get24("day.png", " onclick=\"generarPlanDePagos(" . $rw["credito"] . ")\" ");
         $td .= $xBt->get24("order.png", " onclick=\"getEstadoDeCuenta(" . $rw["credito"] . ")\" ");
         $td .= $xBt->get24("link.png", " onclick=\"desvincular(" . $rw["credito"] . ")\" ");
         $td .= "<div class='coolCheck'><input type='checkbox' id='chk_{$credito}' onclick='jsSetAlimentarEnvio(this, " . $rw["credito"] . ")' /><label for='chk_{$credito}'></label></div>";
         if ($dif == 0) {
             $td .= $xBt->get24("view.png", " onclick=\"setOcultar(" . $rw["credito"] . ")\" ");
         }
         $td .= "</td>";
         $td .= "</tr>";
         $ixx = $ixx >= 2 ? 1 : $ixx + 1;
         if ($notas != "") {
             $td .= "<tr><td class='aviso' colspan='8'>{$notas}</td></tr>";
         }
         $tr .= $td;
     }
     //filtrar domicilio -> socio -> credito -> letra
     $sql = "SELECT\n    creditos_solicitud.numero_socio AS 'persona',\n    CONCAT(\n    (CASE WHEN (socios_general.dependencia != creditos_solicitud.persona_asociada) THEN '(*)' ELSE '' END ),\n    socios_general.nombrecompleto, ' ',\n    socios_general.apellidopaterno, ' ',\n    socios_general.apellidomaterno\n    ) AS 'nombre',\n    \n    creditos_solicitud.numero_solicitud AS 'credito',\n    \n    getParcialidadPorFecha(ultimo_periodo_afectado, {$variacion}, '{$fechaFinal}', `primeras_letras`.`fecha_de_pago`, fecha_ministracion) AS 'letra',\n    `creditos_solicitud`.`pagos_autorizados`  AS 'pagos',\n     \n    creditos_solicitud.monto_parcialidad AS 'monto'\n    FROM\n    `creditos_solicitud` `creditos_solicitud`\n    INNER JOIN `creditos_periocidadpagos` `creditos_periocidadpagos`\n    ON `creditos_solicitud`.`periocidad_de_pago` =\n    `creditos_periocidadpagos`.`idcreditos_periocidadpagos`\n    INNER JOIN `primeras_letras` `primeras_letras`\n    ON `creditos_solicitud`.`numero_solicitud` = `primeras_letras`.\n    `docto_afectado`\n    INNER JOIN `socios_general` `socios_general`\n    ON `creditos_solicitud`.`numero_socio` = `socios_general`.\n    `codigo`\n    \n    WHERE `creditos_solicitud`.persona_asociada\t= {$empresa}\n    \n    ORDER BY ultimo_periodo_afectado DESC, fecha_ministracion,\n    socios_general.nombrecompleto\n    ";
     //setLog($sql);
     $dato = $xQl->getDataRecord($sql);
     $xT = new cTipos();
     foreach ($dato as $rw) {
         if (!isset($creditoON[$credito])) {
             $credito = $rw["credito"];
             $letra = $rw["letra"];
             $lmonto = $xT->cFloat($rw["monto"], 2);
             $cssN = "";
             $notas = "";
             $cls = $ixx == 2 ? " class='trOdd' " : "";
             $td = "<tr{$cls} id='tr-{$credito}'>";
             $td .= "<th>" . $rw["persona"] . "</th>";
             $td .= "<td>" . $rw["nombre"] . "</td>";
             $td .= "<td>" . $rw["credito"] . "</td>";
             $td .= "<td>" . $rw["letra"] . "</td>";
             $td .= "<th>" . $rw["pagos"] . "</th>";
             $td .= "<td>" . $lmonto . "</td>";
             $td .= "<td>" . $notas . "</td>";
             $td .= "<td class='toolbar-24' id=\"options-{$credito}\">";
             $td .= "</td>";
             $td .= "</tr>";
             $tr .= $td;
         }
     }
     //$xT			= new cHTabla();
     $tfoot = "<tr><th colspan='3'>TOTALES</td><th><input id=\"idconteo\" value=\"0\" type=\"number\"></th>";
     $tfoot .= "<td /><th><input id=\"idsuma\" value=\"0\" type=\"number\"></th><td colspan='2'><input type='text' id='idenletras' disabled='true' /></td></tr>";
     return "<table class='listado'>{$tr} {$tfoot}</table>";
 }
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;
}