function jsaGetDatos($solicitud)
{
    if ($solicitud != 0 and $solicitud != '') {
        $xCred = new cCreditos_solicitud();
        $xCred->setData($xCred->query()->getRow("numero_solicitud={$solicitud}"));
        $pagos = $xCred->numero_pagos()->v();
        $monto = $xCred->monto_solicitado()->v();
        $periocidad = $xCred->periocidad_de_pago()->v();
        $tasa = $xCred->tasa_interes()->v();
        $xF = new cFecha();
        $xT = new cTipos();
        $tab = new TinyAjaxBehavior();
        $tab->add(TabSetvalue::getBehavior('idpagos', $pagos));
        $tab->add(TabSetvalue::getBehavior('idmonto', $monto));
        $tab->add(TabSetvalue::getBehavior('idtasa', $tasa * 100));
        $tab->add(TabSetvalue::getBehavior('idperiocidad', $periocidad));
        $tab->add(TabSetvalue::getBehavior('idtipodepago', $xCred->tipo_de_pago()->v()));
        //Fechas de ministracion
        $tab->add(TabSetvalue::getBehavior('idfecha1', $xF->getFechaMX($xCred->fecha_autorizacion()->v(), "-")));
        $tab->add(TabSetvalue::getBehavior('idfecha2', $xF->getFechaMX($xCred->fecha_ministracion()->v(), "-")));
        $tab->add(TabSetvalue::getBehavior('idautorizacion', $xCred->docto_autorizacion()->v()));
        $tab->add(TabSetvalue::getBehavior('idtipodeautorizacion', $xCred->tipo_autorizacion()->v()));
        return $tab->getString();
    }
}
function jsaGuardarPolizas($fecha, $tipo, $centrocosto, $concepto)
{
    $xF = new cFecha();
    $fecha = $xF->getFechaISO($fecha);
    $xPol = new cPoliza($tipo);
    $xPol->add($concepto, $fecha, false, 0, 0, false, $centrocosto);
    return $xPol->getMessages();
}
function jsaSetPago($Recibo, $cuentabancaria, $monto1, $diferencia, $fecha, $transaccion, $bancodeorigen)
{
    $xF = new cFecha();
    $fecha = $xF->getFechaISO($fecha);
    $xCaja = new cCaja();
    $op = $xCaja->setCobroTransferencia($Recibo, $cuentabancaria, $monto1, $diferencia, $fecha, "", false, false, $transaccion, $bancodeorigen);
    if (MODO_DEBUG == true) {
        setLog($xCaja->getMessages());
    }
}
function jsaGuardarVerificacion($fecha, $oficial, $tipo, $id, $notas, $socio)
{
    $xF = new cFecha();
    $fecha = $xF->getFechaISO($fecha);
    $tipo = $tipo == "d" ? TPERSONAS_DIRECCIONES : TPERSONAS_ACTIVIDAD_ECONOMICA;
    $xSoc = new cSocio($socio);
    $xSoc->init();
    $xSoc->setVerificacion($tipo, $id, $fecha, $notas, $oficial);
    return $xSoc->getMessages(OUT_HTML);
}
function jsaSetPago($Recibo, $cuentabancaria, $monto, $fecha, $referencia)
{
    $xF = new cFecha();
    $fecha = $xF->getFechaISO($fecha);
    $xCta = new cCuentaBancaria($cuentabancaria);
    $msg = "";
    if ($xCta->init() == true) {
        $xCta->setNuevoRetiro($referencia, $Recibo, "", $monto, $fecha);
        $xRec = new cReciboDeOperacion(false, false, $Recibo);
        $xRec->setDatosDePago(AML_CLAVE_MONEDA_LOCAL, $monto, $referencia, TESORERIA_PAGO_TRANSFERENCIA);
    }
}
function jsaGetPolizas($fecha, $tipo)
{
    $xF = new cFecha();
    $fecha = $xF->getFechaISO($fecha);
    $xQL = new cSQLListas();
    $xT = new cTabla($xQL->getListadoDePolizasContables($fecha, $tipo), 7);
    $xBtn = new cHImg();
    $xT->setKeyField("codigo");
    $xT->OButton("TR.Modificar", "jsAgregarMovimientos('" . HP_REPLACE_ID . "')\"", $xT->ODicIcons()->AGREGAR);
    $xT->OButton("TR.Imprimir", "jsImprimirPoliza('" . HP_REPLACE_ID . "')\"", $xT->ODicIcons()->IMPRIMIR);
    $xT->OButton("TR.Eliminar", "jsEliminarPoliza('" . HP_REPLACE_ID . "')\"", $xT->ODicIcons()->ELIMINAR);
    return $xT->Show();
}
function jsaSetPago($Recibo, $cuentabancaria, $monto, $fecha, $cheque)
{
    $xF = new cFecha();
    $fecha = $xF->getFechaISO($fecha);
    $xCta = new cCuentaBancaria($cuentabancaria);
    $msg = "";
    if ($xCta->init() == true) {
        $xCta->setNuevoCheque($cheque, $cuentabancaria, $Recibo, "", $monto, $fecha);
        $xRec = new cReciboDeOperacion(false, false, $Recibo);
        $xRec->setDatosDePago(AML_CLAVE_MONEDA_LOCAL, $monto, $cheque, TESORERIA_PAGO_CHEQUE);
    }
    //if(MODO_DEBUG == true){ setLog($xCta->getMessages()); }
}
function jsaSetPagarCredito($credito, $fecha, $observaciones)
{
    $msg = "";
    $xLng = new cLang();
    $xCred = new cCredito($credito);
    $xCred->init();
    $xdat = new cFecha(0);
    $fecha = $xdat->getFechaISO($fecha);
    //$xCred->setResetPersonaAsociada($fecha, $observaciones);
    //return $xLng->get(MSG_READY_SAVE);
    $xCred->setAbonoCapital($xCred->getSaldoActual(), $xCred->getPeriodoActual(), DEFAULT_CHEQUE, TESORERIA_COBRO_NINGUNO, DEFAULT_RECIBO_FISCAL, $observaciones, DEFAULT_GRUPO, $fecha);
    return $xCred->getMessages(OUT_HTML);
}
function jsaSetFecha($recibo, $fecha, $nuevoperiodo)
{
    $xRec = new cReciboDeOperacion(false, true, $recibo);
    $xF = new cFecha();
    $fecha = $xF->getFechaISO($fecha);
    $xRec->init();
    if ($xF->getInt($fecha) != $xF->getInt($xRec->getFechaDeRecibo())) {
        $xRec->setFecha($fecha, true);
    }
    if ($xRec->getPeriodo() != $nuevoperiodo) {
        $xRec->setPeriodo($nuevoperiodo, true);
    }
    return $xRec->getMessages(OUT_HTML);
}
function jsaGetLetras($idcredito, $idfecha)
{
    $xCred = new cCredito($idcredito);
    $xCred->init();
    //$xPlas	= $xCred->getPlanDePago();
    $xF = new cFecha();
    $idfecha = $xF->getFechaISO($idfecha);
    $xQL = new MQL();
    //$xQL->setRawQuery("SET @fecha_de_corte:='$idfecha';");
    my_query("SET @fecha_de_corte:='{$idfecha}';");
    $sql = "SELECT\r\n\t`letras`.`socio_afectado` AS `persona`,\r\n\t`letras`.`docto_afectado` AS `credito`,\r\n\t`letras`.`periodo_socio`  AS `parcialidad`,\r\n\t`letras`.`fecha_de_pago`,\r\n\r\n\t`letras`.`capital`,\r\n\t`letras`.`interes`,\r\n\t`letras`.`iva`,\r\n\t`letras`.`ahorro`,\r\n\t`letras`.`otros`,\r\n\t`letras`.`letra`,\t\r\n\t\r\n\t(`creditos_solicitud`.`tasa_moratorio`*100) AS `tasa_de_mora`,\r\n\t(`creditos_solicitud`.`tasa_interes`*100)   AS `tasa_de_interes` ,\r\n\tDATEDIFF(getFechaDeCorte(), fecha_de_pago) AS 'dias',\r\n\t ((letras.capital * DATEDIFF(getFechaDeCorte(), fecha_de_pago) * (`creditos_solicitud`.`tasa_moratorio` + `creditos_solicitud`.`tasa_interes`))/getDivisorDeInteres()) AS 'mora'\r\n\tFROM\r\n\t\t`creditos_solicitud` `creditos_solicitud` \r\n\t\t\tINNER JOIN `letras` `letras` \r\n\t\t\tON `creditos_solicitud`.`numero_solicitud` = `letras`.`docto_afectado`\r\n\t\r\n\t WHERE capital >0 AND docto_afectado={$idcredito} AND fecha_de_pago <= getFechaDeCorte()";
    $xT = new cTabla($sql);
    $xT->setFootSum(array(4 => "capital", 5 => "interes", 6 => "iva", 7 => "ahorro", 8 => "otros", 9 => "letra", 13 => "mora"));
    return $xT->Show();
}
function jsaGetCallsToToday($fecha, $efectuadas, $vencidas, $canceladas, $mark)
{
    $xF = new cFecha();
    $fecha = $xF->getFechaISO($fecha);
    $cCalls = new cLlamada();
    $cCalls->setLimitRecords();
    if ($vencidas == "on") {
        $cCalls->setIncludeVencidas();
    }
    if ($canceladas == "on") {
        $cCalls->setIncludeCanceladas();
    }
    if ($efectuadas == "on") {
        $cCalls->setIncludeEfectuadas();
    }
    return $cCalls->getLlamadas($fecha, $fecha, $mark);
}
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 b_week($ignium)
{
    if (!$ignium) {
        $mesa = date("m");
        $annoa = date("Y");
        //$fecha = date("Y-m-d", strtotime("$annoa-$mesa-01"));
    } else {
        $mesa = date("m", strtotime($ignium)) - 1;
        $annoa = date("Y", strtotime($ignium));
        if ($mesa < 1) {
            $mesa = 12;
            $annoa = $annoa - 1;
        }
    }
    $xF = new cFecha(0, "{$annoa}-{$mesa}-01");
    $fecha = $xF->get();
    $dias_mes = $xF->getDiasDelMes();
    $idm = $xF->mes();
    $month = $xF->getMesNombre();
    //Valores Iniciales
    $tdweek = "";
    $colorweek = "#FFDFC6";
    $nsemana = 1;
    $tcal = "";
    for ($i = 1; $i <= $dias_mes; $i++) {
        $nowdate = "{$annoa}-{$idm}-{$i}";
        $nday = date("l", strtotime($nowdate));
        if ($nday == "Monday") {
            $dia = dia_semana($nowdate);
            $cnowdate = fecha_corta($nowdate);
            if ($tcal == "cal_2") {
                $tcal = "cal_1";
                $tdweek = $tdweek . "<td class='{$tcal}' onclick='show_week(\"{$nowdate}\")'>SEMANA: {$nsemana} <br /> {$cnowdate}</td>";
            } else {
                $tcal = "cal_2";
                $tdweek = $tdweek . "<td class='{$tcal}' onclick='show_week(\"{$nowdate}\")'>SEMANA: {$nsemana} <br /> {$cnowdate}</td>";
            }
            $nsemana++;
        }
    }
    return "<hr />\n\t<center>\n\t<table class='calendar_week'\n\tcellpadding='2' cellspacing='2' border='2'>\n\t\t<tr>\n\t\t\t<td class='{$tcal}'><img src='../images/common/query_back_down.png' onclick='back_week(\"{$nowdate}\");' /></td>\n\t\t\t{$tdweek}\n\t\t\t<td class='{$tcal}'><img src='../images/common/query_next_down.png' onclick='next_week(\"{$nowdate}\");' /></td>\n\t\t</tr>\n\t</table>\n\t</center>\n\t<hr />";
}
function jsaGetListadoDeAvisos($tipo, $fecha_inicial, $fecha_final)
{
    $tipo = $tipo == SYS_TODAS ? false : $tipo;
    $xF = new cFecha();
    $xAl = new cAml_risk_register();
    $xlistas = new cSQLListas();
    $xBtn = new cHButton();
    $xImg = new cHImg();
    $fecha_inicial = $xF->getFechaISO($fecha_inicial);
    $fecha_final = $xF->getFechaISO($fecha_final);
    $sql = $xlistas->getListadoDeRiesgosConfirmados(false, false, false, $tipo, false, " AND (`aml_risk_register`.`estado_de_envio` =0) AND (`aml_risk_register`.`fecha_de_checking` =0) ");
    $xT = new cTabla($sql);
    //setLog($sql);
    $xT->OButton("TR.Dictaminar", "jsModificarEstatus(_REPLACE_ID_)", $xT->ODicIcons()->REPORTE);
    $xT->OButton("TR.Modificar", "jsEditarRiesgo(_REPLACE_ID_)", $xT->ODicIcons()->EDITAR);
    //$xT->addTool(1);
    $xT->setKeyField($xAl->getKey());
    $xT->setKeyTable($xAl->get());
    return $xT->Show();
}
 function getIDEPagado($socio, $fecha = false)
 {
     if ($fecha == false) {
         $fecha = fechasys();
     }
     $xF = new cFecha(0, $fecha);
     $dia_inicial = $xF->getDiaInicial();
     $dia_final = $xF->getDiaFinal();
     $mvto_ide = 235;
     $idePagado = 0;
     if (!isset($this->mIDEPagado) or $this->mIDEPagado <= 0) {
         $sqlIDE = "SELECT\r\n\t\t\t\t\t\t`operaciones_mvtos`.`tipo_operacion`,\r\n\t\t\t\t\t\t`operaciones_mvtos`.`socio_afectado`,\r\n\t\t\t\t\t\tCOUNT(`operaciones_mvtos`.`idoperaciones_mvtos`) AS 'numero',\r\n\t\t\t\t\t\tSUM(`operaciones_mvtos`.`afectacion_real`) AS 'monto',\r\n\t\t\t\t\t\t`operaciones_mvtos`.`fecha_operacion`\r\n\t\t\t\t\tFROM\r\n\t\t\t\t\t\t`operaciones_mvtos` `operaciones_mvtos`\r\n\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t(`operaciones_mvtos`.`tipo_operacion` = {$mvto_ide})\r\n\t\t\t\t\t\tAND\r\n\t\t\t\t\t\t(`operaciones_mvtos`.`socio_afectado` =" . $socio . ")\r\n\t\t\t\t\t\tAND\r\n\t\t\t\t\t\t(`operaciones_mvtos`.`fecha_operacion` >='{$dia_inicial}')\r\n\t\t\t\t\t\tAND\r\n\t\t\t\t\t\t(`operaciones_mvtos`.`fecha_operacion` <='{$dia_final}')\r\n\t\t\t\t\tGROUP BY\r\n\t\t\t\t\t\t`operaciones_mvtos`.`tipo_operacion`,\r\n\t\t\t\t\t\t`operaciones_mvtos`.`socio_afectado`";
         $MD = obten_filas($sqlIDE);
         $idePagado = $MD["monto"];
         if (!isset($idePagado)) {
             $idePagado = 0;
         }
         $this->mIDEPagado = $idePagado;
         unset($MD);
     }
     return $this->mIDEPagado;
 }
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 jsaGetEmpresa($empresa, $periocidad)
{
    $xEmp = new cEmpresas($empresa);
    $xEmp->init();
    $periodo = 0;
    $dias = 24 * 60;
    $xEmp->init();
    $ctrl = "<label for=\"idperiodo\">Periodo</label><input type=\"number\" id=\"idperiodo\" onchange=\"jsaGetMontoDelPeriodo()\" onblur=\"jsaGetMontoDelPeriodo()\" />";
    $xF = new cFecha(0);
    //$observaciones	.= " -- $periodo";
    $xEmp = new cEmpresas($empresa);
    $xEmp->init();
    $periodo = intval($xEmp->getPeriodo()) == 0 ? $periodo : intval($xEmp->getPeriodo());
    //$observaciones	.= "$fecha";
    switch ($periocidad) {
        case CREDITO_TIPO_PERIOCIDAD_SEMANAL:
            //buscar lunes
            $xSel = $xF->getSelectSemanas("idPeriodo", $periodo);
            $xSel->addEvent("jsaGetMontoDelPeriodo()", "onchange");
            $xSel->addEvent("jsaGetMontoDelPeriodo()", "onblur");
            $xSel->setEnclose(false);
            $ctrl = $xSel->get("idPeriodo", "Periodo", $periodo);
            break;
        case CREDITO_TIPO_PERIOCIDAD_QUINCENAL:
            $xSel = $xF->getSelectQuincenas("idPeriodo", $periodo);
            $xSel->addEvent("jsaGetMontoDelPeriodo()", "onchange");
            $xSel->addEvent("jsaGetMontoDelPeriodo()", "onblur");
            $xSel->setEnclose(false);
            $ctrl = $xSel->get("idPeriodo", "Periodo", $periodo);
            break;
        case CREDITO_TIPO_PERIOCIDAD_CATORCENAL:
            break;
        case CREDITO_TIPO_PERIOCIDAD_DECENAL:
            break;
    }
    return $ctrl;
}
function jsaGetListadoCierres($fecha)
{
    $xLi = new cSQLListas();
    $xF = new cFecha();
    $fecha = $xF->getFechaISO($fecha);
    $sqlList = $xLi->getListadoDeRecibos(12, "", "", $fecha);
    $xTab = new cTabla($sqlList);
    $xTab->OButton("TR.Reporte", "var xR = new RecGen(); xR.reporte(" . HP_REPLACE_ID . ")", $xTab->ODicIcons()->REPORTE);
    $xTab->OButton("TR.Panel", "var xR = new RecGen(); xR.panel(" . HP_REPLACE_ID . ")", $xTab->ODicIcons()->CONTROL);
    $xBtn = new cHButton();
    $xSel = new cHSelect();
    $xCA = $xSel->getListaDeCajasAbiertas();
    $T2 = new cTabla($xCA->getSQL() . " AND `tesoreria_cajas`.`fecha_inicio` = '{$fecha}' ");
    $T2->addEspTool($xBtn->getBasic("", "jsToCerrarCorte('{$fecha}')", "bloquear", "idcerrar", true));
    $html = $xTab->Show("TR.LISTADO DE CIERRES");
    if (MODULO_CAJA_ACTIVADO == true) {
        $html .= $T2->Show("TR.Cajas Abiertas");
        $itemsAbier = $T2->getRowCount();
        $html .= "<input type='hidden' id='idabiertas' value='{$itemsAbier}' />";
    } else {
        $html .= "<input type='hidden' id='idabiertas' value='0' />";
    }
    return $html;
}
//$xT->setTipoSalida($out);
$body = $xRPT->getEncabezado($xHP->getTitle(), $FechaInicial, $FechaFinal);
$xRPT->setBodyMail($body);
$xRPT->addContent($body);
$xCats = new cCatalogoDeDatos("");
$DActividades = $xCats->get("clave_interna", "nombre_de_la_actividad", "personas_actividad_economica_tipos");
$DGenero = $xCats->get("idsocios_genero", "descripcion_genero", "socios_genero");
$DPaises = $xCats->initPorTabla(TCATALOGOS_PAISES);
$DRiesgo = $xCats->initPorTabla(TCATALOGOS_GRADO_RIESGO);
//$xT->setEventKey("jsGoPanel");
//$xT->setKeyField("creditos_solicitud");
$sql = $xL->getInicialDePersonas() . " WHERE (`personalidad_juridica` = 2 OR `personalidad_juridica` = 5)";
$rs = $query->getDataRecord($sql);
$xTa = new cHTabla();
$xDSoc = new cSocios_general();
$xF = new cFecha();
$xTa->initRow();
$xTa->addTH("Sucursal");
$xTa->addTH("Nombre");
$xTa->addTH("Fecha de Constitucion");
$xTa->addTH("Nacionalidad");
$xTa->addTH("RFC");
$xTa->addTH("Actividad economica");
//$xTa->addTH("Puesto o Ocupacion");
$xTa->addTH("Direccion");
$xTa->addTH("Telefono Principal");
$xTa->addTH("Apoderado");
$xTa->addTH("Es PEP");
$xTa->addTH("Lista Negra");
$xTa->addTH("Grado de Riesgo");
$xTa->addTH("Servicios");
//=====>	INICIO_H
include_once "../core/go.login.inc.php";
include_once "../core/core.error.inc.php";
include_once "../core/core.html.inc.php";
include_once "../core/core.init.inc.php";
$theFile = __FILE__;
$permiso = getSIPAKALPermissions($theFile);
if ($permiso === false) {
    header("location:../404.php?i=999");
}
$_SESSION["current_file"] = addslashes($theFile);
//<=====	FIN_H
$iduser = $_SESSION["log_id"];
//=====================================================================================================
$xHP = new cHPage("TR.Depositos cuentas_de_inversion");
$xF = new cFecha();
$xT = new cTipos();
$iddocto = parametro("idcuenta", DEFAULT_CUENTA_CORRIENTE);
$recibo = parametro("idrecibo");
$reciboIDE = 0;
//
$actload = "";
$Fecha = parametro("idfecha-0", false);
$Fecha = $Fecha == false ? fechasys() : $xF->getFechaISO($Fecha);
$idsocio = parametro("idsocio", false, MQL_INT);
//$xT->cInt($_POST["idsocio"]);
$detalles = parametro("idobservaciones", "");
$monto = parametro("idmonto", 0, MQL_FLOAT);
$cheque = parametro("cheque", DEFAULT_CHEQUE);
$comopago = parametro("ctipo_pago", DEFAULT_TIPO_PAGO, MQL_RAW);
$folio_fiscal = parametro("foliofiscal", DEFAULT_RECIBO_FISCAL);
$theFile = __FILE__;
//$permiso					= getSIPAKALPermissions($theFile);
//if($permiso === false){		header ("location:../404.php?i=999");	}
$_SESSION["current_file"] = addslashes($theFile);
//<=====	FIN_H
//=====================================================================================================
$xP = new cHPage("Pruebas de Fechas", HP_FORM);
$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 = parametro("fecha", fechasys());
$xF = new cFecha(0, $miFecha);
//$xHFrm->addHElem( $txt );
$xHFrm->addHElem($xF->show(true));
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Inicio se semana==" . $xF->getFechaDeInicioDeSemana() . "</p>");
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Inicio se nombre semana==" . $xF->getDayName($xF->getFechaDeInicioDeSemana()) . "</p>");
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Dias del Mes==" . $xF->getDiasDelMes() . "</p>");
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}, En Fecha Corta==" . $xF->getFechaCorta() . "</p>");
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Fecha Larga==" . $xF->getFechaLarga() . "</p>");
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}, En Fecha Mediana==" . $xF->getFechaMediana() . "</p>");
//$xHFrm->addHElem(  );
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Fecha Operativa Maxima==" . $xF->getFechaMaximaOperativa() . "</p>");
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}, El Mes Anterior==" . $xF->getFechaMesAnterior() . "</p>");
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}, dos meses atras==" . $xF->getFechaMesAnterior(false, 2) . "</p>");
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}  - 30 Dias==" . $xF->setRestarDias(30) . "</p>");
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}  + 30 Dias==" . $xF->setSumarDias(30) . "</p>");
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}  + 2 meses==" . $xF->setSumarMeses(2) . "</p>");
$action = isset($_GET["a"]) ? $_GET["a"] : false;
$jsb = new jsBasicForm("frmRegistroDeIde");
$jsb->show();
if ($action == false) {
    //$jxc ->drawJavaScript(false, true);
    ?>
<body>
<form name="frmRegistroDeIde" method="POST" action="./ide_registro_de_pago.frm.php?a=ok">
<fieldset>
	<legend><script> document.write(document.title); </script></legend>
	<table border='0'   >
		<tbody>
		<tr>
			<td>Fecha de Pago</td>
			<td><?php 
    $xF1 = new cFecha(0);
    echo $xF1->show();
    ?>
</td>
		</tr>		
		<tr>
			<td>Banco</td>
			<td><?php 
    $gssql = "SELECT idbancos_cuentas, descripcion_cuenta FROM bancos_cuentas";
    $cBc = new cSelect("cBanco", "id-banco", $gssql);
    //$cFJ->addEvent("onchange", "getCambiosFigura");
    $cBc->setEsSql();
    $cBc->show(false);
    ?>
</td>
		</tr>
function getNombre_FechaDeMinistracion($dia, $mes, $anno)
{
    $d = date("Y-m-d", strtotime($anno . "-" . $mes . "-" . $dia));
    $xFec = new cFecha(0, $d);
    return $xFec->getDayName();
}
 function setDescartaAlerta($notas = "", $fecha = false)
 {
     $fecha = $fecha == false ? fechasys() : $fecha;
     $xF = new cFecha();
     $fecha = $xF->getInt($fecha);
     $clave = $this->mCodigo;
     //Actualizar la alerta
     $sql = "UPDATE aml_alerts SET fecha_de_checking={$fecha}, estado_en_sistema=" . SYS_CERO . ", notas_de_checking=\"{$notas}\" WHERE clave_de_control={$clave}";
     my_query($sql);
     $this->mMessages .= "WARN\tAlerta # {$clave} descartada\r\n";
 }
 function calcular($fecha_inicial = false, $PrimerPago = false, $SegundoPago = false, $TercerPago = false)
 {
     $xCred = new cCredito($this->mClaveDeCredito);
     $xCred->init();
     $xF = new cFecha();
     $msg = "";
     $FORMA_DE_PAGO = $xCred->getFormaDePago();
     $PAGOS_AUTORIZADOS = $xCred->getPagosAutorizados();
     $PERIOCIDAD_DE_PAGO = $xCred->getPeriocidadDePago();
     $MONTO_AUTORIZADO = $xCred->getMontoAutorizado();
     $SALDO_ACTUAL = $xCred->getSaldoActual();
     $INTERES_PAGADO = $xCred->getInteresNormalPagado();
     $MORA_PAGADO = $xCred->getInteresMoratorioPagado();
     $xCred->initPagosEfectuados();
     $CAPITAL_PAGADO = setNoMenorQueCero($MONTO_AUTORIZADO - $SALDO_ACTUAL);
     $SALDO_DE_PLAN = $xCred->getMontoAutorizado();
     $TASA_NORMAL = $xCred->getTasaDeInteres();
     $TASA_MORA = $xCred->getTasaDeMora();
     $TASA_IVA = $xCred->getTasaIVA();
     $DIVISOR_DE_INTS = EACP_DIAS_INTERES;
     $FECHA_DE_PAGO = $xCred->getFechaPrimeraParc();
     $FECHA_INICIAL = $xCred->getFechaDeMinistracion();
     $opciondia_1 = $PrimerPago;
     $opciondia_2 = $SegundoPago;
     $opciondia_3 = $TercerPago;
     //sanitiza la fecha de pago
     if ($FECHA_DE_PAGO == false) {
         $FECHA_DE_PAGO = $xF->setSumarDias($PERIOCIDAD_DE_PAGO, $FECHA_INICIAL);
     }
     if (($PERIOCIDAD_DE_PAGO > CREDITO_TIPO_PERIOCIDAD_CATORCENAL or $PERIOCIDAD_DE_PAGO == CREDITO_TIPO_PERIOCIDAD_CATORCENAL) and ($opciondia_1 == false or $opciondia_2 == false or $opciondia_3 == false)) {
         if ($PERIOCIDAD_DE_PAGO == CREDITO_TIPO_PERIOCIDAD_QUINCENAL) {
             $opciondia_1 = $opciondia_1 == false ? PQ_DIA_PRIMERA_QUINCENA : $opciondia_1;
             $opciondia_2 = $opciondia_2 == false ? PQ_DIA_SEGUNDA_QUINCENA : $opciondia_2;
         } elseif ($PERIOCIDAD_DE_PAGO == CREDITO_TIPO_PERIOCIDAD_DECENAL) {
             $opciondia_1 = $opciondia_1 == false ? 10 : $opciondia_1;
             $opciondia_2 = $opciondia_2 == false ? 20 : $opciondia_2;
             $opciondia_3 = $opciondia_3 == false ? 30 : $opciondia_3;
         } else {
             $opciondia_1 = $opciondia_1 == false ? PM_DIA_DE_PAGO : $opciondia_1;
         }
     }
     //pagos decenales entre el mes
     $arrPagos = array();
     //obtener los dias de pago en el mes por tipo de pago
     $dia_de_pago = $xCred->getFechaDeMinistracion();
     for ($i = 1; $i <= $PAGOS_AUTORIZADOS; $i++) {
         $letra = $i;
         switch ($PERIOCIDAD_DE_PAGO) {
             case CREDITO_TIPO_PERIOCIDAD_DIARIO:
                 $dia_de_pago = $xF->getDiaHabil($xF->setSumarDias(1, $dia_de_pago));
                 $arrPagos[$letra][SYS_FECHA] = $dia_de_pago;
                 $msg .= "OK\t{$letra}\tDIARIO\tFecha de pago a {$dia_de_pago}\r\n";
                 break;
             case CREDITO_TIPO_PERIOCIDAD_SEMANAL:
                 break;
             case CREDITO_TIPO_PERIOCIDAD_DECENAL:
                 break;
             case CREDITO_TIPO_PERIOCIDAD_CATORCENAL:
                 //dias naturales, cada dos semanas?
                 break;
             case CREDITO_TIPO_PERIOCIDAD_QUINCENAL:
                 $dia_de_pago = $xF->setSumarDias(CREDITO_TIPO_PERIOCIDAD_QUINCENAL, $dia_de_pago);
                 $dia_de_pago = $xF->getDiaAbonoQuincenal($opciondia_1, $opciondia_2, $dia_de_pago);
                 $arrPagos[$letra][SYS_FECHA] = $dia_de_pago;
                 $msg .= "OK\t{$letra}\tQUINCENAL\tFecha de pago a {$dia_de_pago}, opcion {$opciondia_1}, {$opciondia_2}\r\n";
                 break;
             case CREDITO_TIPO_PERIOCIDAD_MENSUAL:
                 $dia_de_pago = date("Y-m-", $xF->getInt($dia_de_pago)) . $opciondia_1;
                 $dia_de_pago = $xF->setSumarMeses(1, $dia_de_pago);
                 $dia_de_pago = $xF->getDiaHabil($dia_de_pago);
                 $arrPagos[$letra][SYS_FECHA] = $dia_de_pago;
                 $msg .= "OK\t{$letra}\tMENSUAL\tFecha de pago a {$dia_de_pago}, opcion {$opciondia_1}\r\n";
                 break;
             case CREDITO_TIPO_PERIOCIDAD_BIMESTRAL:
                 break;
             case CREDITO_TIPO_PERIOCIDAD_TRIMESTRAL:
                 break;
         }
     }
     //$FORMULA_INT			= new cFormula("interes_normal");
     //dias de pago
     //si es empresa, tomar la fecha de la empresa semanal, quincenal, mensual, decenal
     //Iniciar los Pagos Actuales
     //$this->initParcsPendientes();
     $DatosDePagados = $xCred->getListadoDePagos();
     /* interes capital impuestos */
     switch ($FORMA_DE_PAGO) {
         case CREDITO_TIPO_PAGO_PERIODICO:
             //parcialidad interes + capital
             break;
         case CREDITO_TIPO_PAGO_FLAT_PARCIAL:
             for ($i = 1; $i <= $PAGOS_AUTORIZADOS; $i++) {
                 $letra = $i;
                 $letraAnterior = setNoMenorQueCero($letra - 1);
                 $PagoAnterior = isset($DatosDePagados[$letra]) ? $DatosDePagados[$letra] : array();
                 $capital_pagado = isset($DPago[SYS_CAPITAL]) ? $DPago[SYS_CAPITAL] : 0;
                 $SALDO_DE_PLAN = $SALDO_DE_PLAN - $capital_pagado;
                 $interes_normal = $MONTO_AUTORIZADO * $PERIOCIDAD_DE_PAGO * $TASA_NORMAL / $DIVISOR_DE_INTS;
                 $capital = $MONTO_AUTORIZADO / $PAGOS_AUTORIZADOS;
                 $capital = setNoMenorQueCero($capital - $capital_pagado);
                 $interes_pagado = isset($DPago[SYS_INTERES_NORMAL]) ? $DPago[SYS_INTERES_NORMAL] : 0;
                 $interes_normal = setNoMenorQueCero($interes_normal - $interes_pagado);
                 $arrPagos[$letra][SYS_INTERES_NORMAL] = $interes_normal;
                 if ($letra == $PAGOS_AUTORIZADOS) {
                     if ($SALDO_DE_PLAN > 0) {
                         $arrPagos[$letra][SYS_CAPITAL] = $SALDO_DE_PLAN;
                         $msg .= "WARN\t{$letra}\tCapital a ultimo pago {$SALDO_DE_PLAN} \r\n";
                     }
                 }
                 //determinar proxima fecha de pago
                 $msg .= "OK\t{$letra}\tInteres Normal en {$interes_normal}, Pagado {$interes_pagado} \r\n";
             }
             break;
         case CREDITO_TIPO_PAGO_INTERES_PERIODICO:
             for ($i = 1; $i <= $PAGOS_AUTORIZADOS; $i++) {
                 $letra = $i;
                 $letraAnterior = setNoMenorQueCero($letra - 1);
                 $DAnterior = isset($DatosDePagados[$letraAnterior]) ? $DatosDePagados[$letraAnterior] : array();
                 $capital_pagado = isset($DAnterior[SYS_CAPITAL]) ? $DAnterior[SYS_CAPITAL] : 0;
                 $SALDO_DE_PLAN = $SALDO_DE_PLAN - $capital_pagado;
                 $DPago = isset($DatosDePagados[$letra]) ? $DatosDePagados[$letra] : array();
                 $interes_pagado = isset($DPago[SYS_INTERES_NORMAL]) ? $DPago[SYS_INTERES_NORMAL] : 0;
                 //datos del pago anterior
                 $DLetraAnterior = isset($arrPagos[$letraAnterior]) ? $arrPagos[$letraAnterior] : array();
                 $DLetra = isset($arrPagos[$letra]) ? $arrPagos[$letra] : array();
                 $FechaAnterior = isset($DLetraAnterior[SYS_FECHA]) ? $DLetraAnterior[SYS_FECHA] : $xCred->getFechaDeMinistracion();
                 $FechaActual = isset($DLetra[SYS_FECHA]) ? $DLetra[SYS_FECHA] : false;
                 $DIAS_TRANSCURRIDOS = $xF->setRestarFechas($FechaActual, $FechaAnterior);
                 //INTERES NORMAL
                 $interes_normal = $SALDO_DE_PLAN * $DIAS_TRANSCURRIDOS * $TASA_NORMAL / $DIVISOR_DE_INTS;
                 $interes_normal = setNoMenorQueCero($interes_normal - $interes_pagado);
                 $arrPagos[$letra][SYS_INTERES_NORMAL] = $interes_normal;
                 if ($capital_pagado > 0) {
                     $msg .= "WARN\t{$letra}\tCapital en pago {$letraAnterior} de {$capital_pagado} \r\n";
                 }
                 if ($letra == $PAGOS_AUTORIZADOS) {
                     if ($SALDO_DE_PLAN > 0) {
                         $arrPagos[$letra][SYS_CAPITAL] = $SALDO_DE_PLAN;
                         $msg .= "WARN\t{$letra}\tCapital a ultimo pago {$SALDO_DE_PLAN} \r\n";
                     }
                 }
                 $msg .= "OK\t{$letra}\tInteres Normal en {$interes_normal}, Pagado {$interes_pagado}, Dias {$DIAS_TRANSCURRIDOS},Fecha : Actual {$FechaActual} Anterior {$FechaAnterior}\r\n";
             }
             break;
         case CREDITO_TIPO_PAGO_INTERES_COMERCIAL:
             for ($i = 1; $i <= $PAGOS_AUTORIZADOS; $i++) {
                 $letra = $i;
                 $letraAnterior = setNoMenorQueCero($letra - 1);
                 $DAnterior = isset($DatosDePagados[$letraAnterior]) ? $DatosDePagados[$letraAnterior] : array();
                 $capital_pagado = isset($DAnterior[SYS_CAPITAL]) ? $DAnterior[SYS_CAPITAL] : 0;
                 $SALDO_DE_PLAN = $SALDO_DE_PLAN - $capital_pagado;
                 $DPago = isset($DatosDePagados[$letra]) ? $DatosDePagados[$letra] : array();
                 $interes_pagado = isset($DPago[SYS_INTERES_NORMAL]) ? $DPago[SYS_INTERES_NORMAL] : 0;
                 //INTERES NORMAL
                 $interes_normal = $SALDO_DE_PLAN * $PERIOCIDAD_DE_PAGO * $TASA_NORMAL / $DIVISOR_DE_INTS;
                 $interes_normal = setNoMenorQueCero($interes_normal - $interes_pagado);
                 $arrPagos[$letra][SYS_INTERES_NORMAL] = $interes_normal;
                 if ($capital_pagado > 0) {
                     $msg .= "WARN\t{$letra}\tCapital en pago {$letraAnterior} de {$capital_pagado} \r\n";
                 }
                 if ($letra == $PAGOS_AUTORIZADOS) {
                     if ($SALDO_DE_PLAN > 0) {
                         $arrPagos[$letra][SYS_CAPITAL] = $SALDO_DE_PLAN;
                         $msg .= "WARN\t{$letra}\tCapital a ultimo pago {$SALDO_DE_PLAN} \r\n";
                     }
                 }
                 $msg .= "OK\t{$letra}\tInteres Normal en {$interes_normal}, Pagado {$interes_pagado} \r\n";
             }
             break;
     }
     $NumeroPlan = $this->mNumeroDePlan;
     //$this->setEliminar();
     //eliminar plan de pagos
     foreach ($arrPagos as $periodo) {
     }
     $this->mMessages .= $msg;
     return $msg;
 }
include_once "../core/core.error.inc.php";
include_once "../core/core.html.inc.php";
include_once "../core/core.init.inc.php";
include_once "../core/core.db.inc.php";
$theFile = __FILE__;
$permiso = getSIPAKALPermissions($theFile);
if ($permiso === false) {
    header("location:../404.php?i=999");
}
$_SESSION["current_file"] = addslashes($theFile);
//=====================================================================================================
$xHP = new cHPage("REPORTE DE OPERACIONES DETALLADAS POR PERSONA ", HP_REPORT);
$oficial = elusuario($iduser);
/**
 */
$xF = new cFecha();
$estatus = isset($_GET["estado"]) ? $_GET["estado"] : SYS_TODAS;
$frecuencia = isset($_GET["periocidad"]) ? $_GET["periocidad"] : SYS_TODAS;
$convenio = isset($_GET["convenio"]) ? $_GET["convenio"] : SYS_TODAS;
$empresa = isset($_GET["empresa"]) ? $_GET["empresa"] : SYS_TODAS;
$out = isset($_GET["out"]) ? $_GET["out"] : SYS_DEFAULT;
$mx = isset($_GET["mx"]) ? true : false;
if ($mx == true) {
    $fechaInicial = isset($_GET["on"]) ? $xF->getFechaISO($_GET["on"]) : FECHA_INICIO_OPERACIONES_SISTEMA;
    $fechaFinal = isset($_GET["off"]) ? $xF->getFechaISO($_GET["off"]) : fechasys();
} else {
    $fechaInicial = isset($_GET["on"]) ? $_GET["on"] : FECHA_INICIO_OPERACIONES_SISTEMA;
    $fechaFinal = isset($_GET["off"]) ? $_GET["off"] : fechasys();
}
$ByConvenio = $convenio == SYS_TODAS ? "" : " AND\t(`listado_de_ingresos`.`producto` ={$convenio}) ";
$ByEmpresa = $empresa == SYS_TODAS ? "" : " AND (`listado_de_ingresos`.`clave_empresa` = {$empresa}) ";
 function getDescripcion()
 {
     $xF = new cFecha(0);
     if ($this->mReciboIniciado == false) {
         $this->init();
     }
     $xSoc = new cSocio($this->mSocio);
     $xSoc->init();
     $desc = $this->mCodigoDeRecibo . "|" . $xF->getFechaCorta($this->mFechaDeOperacion) . "|" . $xSoc->getNombreCompleto();
     return $desc;
 }
//=====================================================================================================
include_once "../core/go.login.inc.php";
include_once "../core/core.error.inc.php";
include_once "../core/core.html.inc.php";
include_once "../core/core.init.inc.php";
include_once "../core/core.db.inc.php";
$theFile = __FILE__;
$permiso = getSIPAKALPermissions($theFile);
if ($permiso === false) {
    header("location:../404.php?i=999");
}
$_SESSION["current_file"] = addslashes($theFile);
//=====================================================================================================
$xHP = new cHPage("TR.REPORTE DE PERSONAS CLASIFICADAS COMO PEPS", HP_REPORT);
$xL = new cSQLListas();
$xF = new cFecha();
$query = new MQL();
$estatus = parametro("estado", SYS_TODAS);
$frecuencia = parametro("periocidad", SYS_TODAS);
$producto = parametro("convenio", SYS_TODAS);
$producto = parametro("producto", $producto);
$empresa = parametro("empresa", SYS_TODAS);
$sucursal = parametro("sucursal", SYS_TODAS, MQL_RAW);
$out = parametro("out", SYS_DEFAULT);
$FechaInicial = parametro("on", false);
$FechaInicial = parametro("fecha-0", $FechaInicial);
$FechaInicial = $FechaInicial == false ? FECHA_INICIO_OPERACIONES_SISTEMA : $xF->getFechaISO($FechaInicial);
$FechaFinal = parametro("off", false);
$FechaFinal = parametro("fecha-1", $FechaFinal);
$FechaFinal = $FechaFinal == false ? fechasys() : $xF->getFechaISO($FechaFinal);
$jsEvent = $out != OUT_EXCEL ? "initComponents()" : "";
include_once "../core/core.riesgo.inc.php";
include_once "../core/core.seguimiento.inc.php";
include_once "../core/core.creditos.inc.php";
include_once "../core/core.creditos.utils.inc.php";
include_once "../core/core.operaciones.inc.php";
include_once "../core/core.common.inc.php";
include_once "../core/core.html.inc.php";
ini_set("display_errors", "off");
ini_set("max_execution_time", 1600);
$key = isset($_GET["k"]) ? true : false;
$parser = !isset($_GET["s"]) ? false : $_GET["s"];
//Obtiene la llave del
//if ($key == MY_KEY) {
$messages = "";
$fechaop = parametro("f", fechasys());
$xF = new cFecha(0, $fechaop);
/**
 * Generar el Archivo HTMl del LOG
 * eventos-del-cierre + fecha_de_cierre + .html
 *
 */
$aliasFil = getSucursal() . "-eventos-al-cierre-de-colocacion-del-dia-{$fechaop}";
$xLog = new cFileLog($aliasFil);
$ql = new MQL();
$xRec = new cReciboDeOperacion(12);
$xRec->setGenerarPoliza();
$xRec->setForceUpdateSaldos();
$idrecibo = $xRec->setNuevoRecibo(DEFAULT_SOCIO, DEFAULT_CREDITO, $fechaop, 1, 12, "CIERRE_DE_COLOCACION_{$fechaop}", DEFAULT_CHEQUE, DEFAULT_TIPO_PAGO, DEFAULT_RECIBO_FISCAL, DEFAULT_GRUPO);
$xRec->setNumeroDeRecibo($idrecibo);
$messages .= "=======================================================================================\r\n";
$messages .= "=========================\t\t" . EACP_NAME . " \r\n";
include_once "../core/go.login.inc.php";
include_once "../core/core.error.inc.php";
include_once "../core/core.html.inc.php";
include_once "../core/core.init.inc.php";
$theFile = __FILE__;
$permiso = getSIPAKALPermissions($theFile);
if ($permiso === false) {
    header("location:../404.php?i=999");
}
$_SESSION["current_file"] = addslashes($theFile);
//<=====	FIN_H
$iduser = $_SESSION["log_id"];
//=====================================================================================================
$xHP = new cHPage("TR.Estado de Cuenta de Depositos a la Vista", HP_RPTXML);
$xQL = new MQL();
$xF = new cFecha();
$oficial = elusuario($iduser);
//=====================================================================================================
$idcuenta = parametro("f100", false, MQL_INT);
$idcuenta = parametro("cuenta", $idcuenta, MQL_INT);
$AppByFechas = parametro("f73");
//Boolean por fechas
$fecha_inicial = parametro("on", EACP_FECHA_DE_CONSTITUCION, MQL_DATE);
$fecha_final = parametro("off", $xF->getFechaMaximaOperativa(), MQL_DATE);
$output = parametro("out", SYS_DEFAULT);
$setSql = "SELECT\n\t`socios`.`codigo`,\n\t`socios`.`nombre`,\n\t`captacion_cuentas`.`numero_cuenta`                 AS `numero_de_cuenta`,\n\t`captacion_cuentastipos`.`descripcion_cuentastipos` AS `tipo`,\n\t`captacion_subproductos`.`descripcion_subproductos` AS `producto`,\n\t`captacion_cuentas`.`tasa_otorgada`,\n\t`captacion_cuentas`.`dias_invertidos`,\n\t`captacion_cuentas`.`saldo_cuenta`,\n\t`captacion_cuentas`.`sucursal`,\n\t`captacion_sdpm_historico`.`ejercicio`,\n\t`captacion_sdpm_historico`.`periodo`,\n\t`captacion_sdpm_historico`.`fecha`,\n\t`captacion_sdpm_historico`.`recibo`,\n\t`captacion_sdpm_historico`.`dias`,\n\t`captacion_sdpm_historico`.`tasa`,\n\t`captacion_sdpm_historico`.`monto`\nFROM\n\t`captacion_cuentas` `captacion_cuentas`\n\t\tINNER JOIN `captacion_sdpm_historico` `captacion_sdpm_historico`\n\t\tON `captacion_cuentas`.`numero_cuenta` = `captacion_sdpm_historico`.\n\t\t`cuenta`\n\t\t\tINNER JOIN `captacion_cuentastipos` `captacion_cuentastipos`\n\t\t\tON `captacion_cuentas`.`tipo_cuenta` = `captacion_cuentastipos`.\n\t\t\t`idcaptacion_cuentastipos`\n\t\t\t\tINNER JOIN `socios` `socios`\n\t\t\t\tON `socios`.`codigo` = `captacion_cuentas`.`numero_socio`\n\t\t\t\t\tINNER JOIN `captacion_subproductos` `captacion_subproductos`\n\t\t\t\t\tON `captacion_cuentas`.`tipo_subproducto` =\n\t\t\t\t\t`captacion_subproductos`.`idcaptacion_subproductos`\nWHERE\n\t(`captacion_cuentas`.`numero_cuenta` ={$idcuenta})\n\tAND\n\t(`captacion_sdpm_historico`.`fecha`>='{$fecha_inicial}')\n\tAND\n\t(`captacion_sdpm_historico`.`fecha`<='{$fecha_final}')\nORDER BY\n\t`socios`.`codigo`,\n\t`captacion_cuentas`.`numero_cuenta`,\n\t`captacion_sdpm_historico`.`ejercicio` ASC,\n\t`captacion_sdpm_historico`.`periodo` ASC,\t\n\t`captacion_sdpm_historico`.`fecha` ASC";
//exit($setSql);
if ($output != OUT_EXCEL) {
    $oRpt = new PHPReportMaker();
    $oRpt->setDatabase(MY_DB_IN);
    $oRpt->setUser(RPT_USR_DB);