$empresa = parametro("empresa", SYS_TODAS);
$out = parametro("out", SYS_DEFAULT);
$persona = parametro("persona", DEFAULT_SOCIO, MQL_INT);
$persona = parametro("socio", $persona, MQL_INT);
$persona = parametro("idsocio", $persona, MQL_INT);
$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()" : "";
$senders = getEmails($_REQUEST);
$titulo = "";
$archivo = "";
$xRPT = new cReportes($titulo);
$xRPT->setFile($archivo);
$xRPT->setOut($out);
//$xRPT->setSQL($sql);
$xRPT->setTitle($xHP->getTitle());
//============ Reporte
$xSoc = new cSocio($persona);
$xSoc->init();
$body = $xRPT->getEncabezado($xHP->getTitle(), $FechaInicial, $FechaFinal);
$xRPT->setBodyMail($body);
$xRPT->addContent($body);
$xRPT->addContent($xSoc->getFicha(true));
//Bajo revision
$xAl = new cAml_alerts();
$xlistas = new cSQLListas();
$sql = $xlistas->getListadoDeAlertas(false, false, false, $persona, " AND `estado_en_sistema` =" . SYS_UNO);
$xL = new cSQLListas();
$xF = new cFecha();
$ql = new MQL();
$fecha_inicial = parametro("on", $xF->getDiaInicial(), MQL_DATE);
$fecha_final = parametro("off", $xF->getDiaFinal(), MQL_DATE);
$cuenta_inicial = parametro("for", 0, MQL_INT);
$cuenta_final = parametro("to", 0, MQL_INT);
$out = parametro("out", SYS_DEFAULT, MQL_RAW);
//---------------- Valuar Tipo de Cuenta ----------------
$tipo_cuentas = parametro("tipo", SYS_TODAS, MQL_RAW);
$nivel_cuentas = parametro("nivel", SYS_TODAS, MQL_RAW);
$incluir_cuentas = parametro("estado", SYS_TODAS, MQL_RAW);
$netoCargoRpt = 0;
$netoAbonoRpt = 0;
$ByCuentas = "";
$xRPT = new cReportes($xHP->getTitle());
$xRPT->addContent($xRPT->getEncabezado($xHP->getTitle(), $fecha_inicial, $fecha_final));
$InitRecords = parametro("init", 0, MQL_INT);
$xRPT->setOut($out);
//=================================================================================================================
//$xRPT->setToPagination($InitRecords);
/**
 * Paginacion
 * I.- Parte
 */
$rowLimit = 900;
//4Paginas aprox
//marca el Final de los Registros
$EndRecords = $InitRecords + $rowLimit;
//=================================================================================================================
/**
//=====================================================================================================
$xHP = new cHPage("TR.Operaciones de Empresa ", HP_REPORT);
$xF = new cFecha();
$periodo = isset($_GET["periodo"]) ? $_GET["periodo"] : SYS_TODAS;
$empresa = isset($_GET["empresa"]) ? $_GET["empresa"] : SYS_TODAS;
$periocidad = isset($_GET["periocidad"]) ? $_GET["periocidad"] : SYS_TODAS;
//$estado		= (isset($_GET["estado"])) ? $_GET["estado"]: "todas";
$fecha_inicial = parametro("idfecha-0", false);
$fecha_inicial = parametro("on", $fecha_inicial);
$fecha_final = parametro("idfecha-1", false);
$fecha_final = parametro("off", $fecha_final);
echo $xHP->getHeader();
echo $xHP->setBodyinit("initComponents();");
$ByFecha = ($fecha_final == false or $fecha_inicial == false) ? "" : " AND\t(`empresas_operaciones`.`fecha_de_operacion` >='" . $xF->getFechaISO($fecha_inicial) . "') AND\t(`empresas_operaciones`.`fecha_de_operacion` <='" . $xF->getFechaISO($fecha_final) . "') ";
$ByPeriodo = $periodo == SYS_TODAS ? "" : "AND ( `periodo_marcado` = {$periodo}) ";
$xRPT = new cReportes();
echo $xRPT->getHInicial("TR.Estado de cuenta de Empresas", $fecha_inicial, $fecha_final);
//TODO: Acabar
$lt = new cSQLListas();
$sql = $lt->getListadoDeOperacionesDeEmpresas($empresa, $periocidad, $ByFecha . $ByPeriodo);
$xT = new cTabla($sql);
$xEmp = new cEmpresas($empresa);
echo $xEmp->getFicha();
$xT->getFieldsSum("monto");
$xT->setTdClassByType();
$xT->setFootSum(array(6 => "envios", 7 => "cobros"));
echo $xT->Show();
echo getRawFooter();
echo $xHP->setBodyEnd();
?>
<script>
$xHP->setTitle($xHP->lang("catalogo de", "documentacion"));
$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;
$fechaInicial = isset($_GET["on"]) ? $xF->getFechaISO($_GET["on"]) : FECHA_INICIO_OPERACIONES_SISTEMA;
$fechaFinal = isset($_GET["off"]) ? $xF->getFechaISO($_GET["off"]) : fechasys();
echo $xHP->getHeader();
echo $xHP->setBodyinit("initComponents();");
echo getRawHeader();
$xRPT = new cReportes();
echo $xRPT->getEncabezado($xHP->getTitle());
$sql = "SELECT * FROM personas_documentacion_tipos";
$xTBL = new cTabla($sql);
echo $xTBL->Show();
echo getRawFooter();
echo $xHP->setBodyEnd();
?>
<script>
<?php 
?>
function initComponents(){
	window.print();
}
</script>
<?php 
    header("location:../404.php?i=999");
}
$_SESSION["current_file"] = addslashes($theFile);
//<=====	FIN_H
$iduser = $_SESSION["log_id"];
//=====================================================================================================
$xHP = new cHPage("TR.Recibos de Cobranza", HP_REPORT);
$xL = new cSQLListas();
$xF = new cFecha();
$empresa = isset($_GET["r"]) ? $_GET["r"] : 0;
$periocidad = isset($_GET["p"]) ? $_GET["p"] : "todos";
$variacion = isset($_GET["v"]) ? $_GET["v"] : 0;
$ByPeriodo = $periocidad == "todos" ? "" : " AND creditos_solicitud.periocidad_de_pago = {$periocidad} ";
$periodo = isset($_GET["periodo"]) ? $_GET["periodo"] : 0;
$out = parametro("out", OUT_HTML);
$xRPT = new cReportes($xHP->getTitle());
$fecha_filtro = fechasys();
$ByMinistracion = "";
//$periodo		= $periodo + $variacion;
$fechaInicial = parametro("on", false);
$fechaFinal = parametro("off", false);
$fechaFinal = $xF->getFechaISO($fechaFinal);
$fechaInicial = $xF->getFechaISO($fechaInicial);
$idnomina = parametro("nomina", 0, MQL_INT);
//$xHP->addJsFile("../js/jquery/jquery.js");
//$xHP->addJsFile("../js/general.js");
//$xHP->addJsFile("../js/jquery/jquery.qtip.min.js");
$xEmp = new cEmpresas($empresa);
$xEmp->init();
$xTPer = new cPeriocidadDePago($periocidad);
$xTPer->init();
//=====================================================================================================
//=====>	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
//=====================================================================================================
$xHP = new cHPage("TR.Acumulado de Creditos por producto", HP_REPORT);
$xRPT = new cReportes();
$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);
$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);
/*		<!-- <tr>
		<td colspan='4'> 
		<hr />
		</td>
	  			<tr>
	  				<th class='izq'>[$counter]Monto Ministrado</th>
	  				<td class='mny'>" .  getFMoney($sumCAP) . "</td>
	  				<th class='izq'>Saldo Actual</th>
	  				<td class='mny'>" .  getFMoney($sumSDO) . "</td>
  				</tr>		
		</tr> -->
		</tr>*/
$sql = $setSql;
$titulo = "";
$archivo = "";
$xRPT = new cReportes($titulo);
$xRPT->setFile($archivo);
$xRPT->setOut($out);
$xRPT->setSQL($sql);
$xRPT->setTitle($xHP->getTitle());
//============ Reporte
$xT = new cTabla($sql, 2);
$xT->setTipoSalida($out);
$body = $xRPT->getEncabezado($xHP->getTitle(), $fecha_inicial, $fecha_final);
$xRPT->setBodyMail($body);
$xRPT->addContent($body);
//$xT->setEventKey("jsGoPanel");
//$xT->setKeyField("creditos_solicitud");
//$xRPT->addContent( $xT->Show( $xHP->getTitle() ) );
//============ Agregar HTML
//$xRPT->addContent( $xHP->init($jsEvent) );
if ($sucursal != SYS_TODAS) {
    $BySuc = " AND creditos.`sucursal` = '{$sucursal}' ";
}
if ($fecha_inicial && $fecha_final) {
    $si_es_por_fecha = " AND operaciones_mvtos.fecha_operacion>='{$fecha_inicial}' AND operaciones_mvtos.fecha_operacion<='{$fecha_final}' ";
}
$senders = getEmails($_REQUEST);
$tipo_operacion = parametro("f711", SYS_TODAS, MQL_INT);
$tipo_operacion = parametro("operacion", $tipo_operacion, MQL_INT);
$out = parametro("out", SYS_DEFAULT);
$def_type = 110;
$sql = "SELECT creditos.convenio AS 'tipo', \n\t\t\tCOUNT(operaciones_mvtos.idoperaciones_mvtos) AS 'numero',\n\n\t\t\t\n\t\t\tSUM(operaciones_mvtos.afectacion_real) AS 'monto',\n\n\t\t\t/*SUM(creditos.monto_autorizado) AS 'monto_original',*/\n\t\t\t(SUM(operaciones_mvtos.afectacion_real) - SUM(creditos.saldo_actual)) AS 'cobros',\n\t\t\tSUM(creditos.saldo_actual) AS 'saldo_de_credito'\n\t\t\t \nFROM\n\t`operaciones_mvtos` `operaciones_mvtos` \n\t\tINNER JOIN `operaciones_recibos` `operaciones_recibos` \n\t\tON `operaciones_mvtos`.`recibo_afectado` = `operaciones_recibos`.\n\t\t`idoperaciones_recibos` \n\t\t\tINNER JOIN `creditos` `creditos` \n\t\t\tON `operaciones_mvtos`.`docto_afectado` = `creditos`.`solicitud` \nWHERE\n\t(`operaciones_recibos`.`tipo_pago` !='" . TESORERIA_COBRO_NINGUNO . "')\n\tAND (operaciones_mvtos.tipo_operacion={$def_type})\n\t{$BySuc}\n\t{$si_es_por_fecha}\nGROUP BY creditos.convenio";
$xHP->setTitle("TR.Reporte de Colocacion");
$titulo = $xHP->getTitle();
$archivo = "{$titulo}.pdf";
$xRPT = new cReportes($titulo);
$xRPT->setFile($archivo);
$xRPT->setOut($out);
$xRPT->setSQL($sql);
$xRPT->setTitle($xHP->getTitle());
//============ Reporte
$xT = new cTabla($sql, 2);
$xT->setTipoSalida($out);
$xT->setFootSum(array(1 => "numero", 2 => "monto", 3 => "cobros", 4 => "saldo_de_credito"));
$body = $xRPT->getEncabezado($xHP->getTitle(), $fecha_inicial, $fecha_final);
$xRPT->setBodyMail($body);
$xRPT->addContent($body);
$xRPT->addContent("<h1>" . $sucursal . "</h1>");
//$xT->setEventKey("jsGoPanel");
//$xT->setKeyField("creditos_solicitud");
$xRPT->addContent($xT->Show($xHP->getTitle()));
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_REPORT);
$xQL = new MQL();
$xF = new cFecha();
$oficial = elusuario($iduser);
$xHP->init();
$xRPT = new cReportes();
$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);
$fecha_final = parametro("off", $xF->getFechaMaximaOperativa());
$output = parametro("out", SYS_DEFAULT);
$es_por_fechas = "";
$xCuenta = new cCuentaALaVista($idcuenta);
$xCuenta->init();
//Datos de la Cuenta
$rwc = $xCuenta->getDatosInArray();
// datos generales del socio
$idsocio = $rwc["numero_socio"];
// Numero de Socio
$cuenta = parametro("idcuenta", $cuenta, MQL_INT);
$cuenta = parametro("docto", $cuenta, MQL_INT);
$idcuenta = $cuenta;
//parametro("docto", false, MQL_INT);
$AppByFechas = parametro("v73", false, MQL_BOOL);
//Boolean por fechas
$fecha_inicial = $_GET["on"];
$fecha_final = $_GET["off"];
$out = parametro("out", SYS_DEFAULT);
$es_por_fechas = "";
$xHT = new cHTabla();
//ini_set("display_errors", "on");
$xCuenta = new cCuentaInversionPlazoFijo($cuenta);
$xCuenta->init();
$saldo = $xCuenta->getSaldoActual();
$xRPT = new cReportes();
$persona = $xCuenta->getClaveDePersona();
$xSoc = new cSocio($persona);
$xSoc->init();
$xRPT->setTitle($xHP->getTitle(), true);
$xRPT->addContent($xSoc->getFicha());
$xRPT->addContent($xCuenta->getFicha(true, "", true));
//Datos de la Cuenta
$sqlMvtos = "SELECT\n\t\t\t`operaciones_mvtos`.*,\n\t\t\t\t(`operaciones_mvtos`.`afectacion_real` *\n\t\t\t\t`eacp_config_bases_de_integracion_miembros`.`afectacion`) AS 'monto',\n\t\t\t\t`eacp_config_bases_de_integracion_miembros`.`afectacion`\n\t\t\tFROM\n\t\t\t`operaciones_mvtos` `operaciones_mvtos`\n\t\t\t\tINNER JOIN `eacp_config_bases_de_integracion_miembros`\n\t\t\t\t`eacp_config_bases_de_integracion_miembros`\n\t\t\t\tON `operaciones_mvtos`.`tipo_operacion` =\n\t\t\t\t`eacp_config_bases_de_integracion_miembros`.`miembro`\n\t\t\tWHERE\n\t\t\t(`operaciones_mvtos`.`docto_afectado` =" . $cuenta . ") AND\n\t\t\t(`eacp_config_bases_de_integracion_miembros`.`codigo_de_base` = 3200)\n\n\t\t\tORDER BY\n\t\t\t\t`eacp_config_bases_de_integracion_miembros`.`codigo_de_base`,\n\t\t\t\t`operaciones_mvtos`.`fecha_afectacion`,\n\t\t\t\t`eacp_config_bases_de_integracion_miembros`.`afectacion` DESC\n\t\t\t";
$xHT->initRow();
$xHT->addTH("TR.Fecha");
$xHT->addTH("TR.Recibo");
$xHT->addTH("TR.Operacion");
$xHT->addTH("TR.Deposito");
$xHT->addTH("TR.Retiro");
$xHT->addTH("TR.Inversion");
    $fecha_final = $xF->getFechaISO($_REQUEST["fechaMX"]);
}
if (count($mails) <= 0) {
    if (MODULO_CAJA_ACTIVADO == true) {
        if ($xF->getInt($fecha_final) > $xF->getInt(fechasys())) {
            if ($xCaja->getEstatus() == TESORERIA_CAJA_ABIERTA) {
                $xHP->goToPageError(70102);
            }
        }
    }
}
$xUsr = new cSystemUser($cajero);
$xUsr->init();
$nombre = $xUsr->getNombreCompleto();
$ByDependencia = (isset($_GET["dependencia"]) and $_GET["dependencia"] != SYS_TODAS) ? " AND `socios`.`iddependencia`=" . $_GET["dependencia"] : "";
$xRPT = new cReportes();
$title = $xHP->getTitle();
$xRPT->setTitle($title);
$xRPT->setOut($out);
$xRPT->setSenders($mails);
$bheader = $xRPT->getHInicial($xHP->getTitle(), $fecha_inicial, $fecha_final, $nombre);
$xRPT->addContent($bheader);
$xRPT->setBodyMail($bheader);
$xRPT->setResponse();
$xRPT->addContent($xCaja->getResumenDeCaja());
//setlog( $xCaja->getMessages() );
if (count($mails) > 0) {
    if ($xCaja->getSumaDeRecibos() <= 0) {
        $xRPT->setSenders(array());
        //no enviar
    }
$nivel_cuentas = parametro("nivel", SYS_TODAS, MQL_RAW);
$incluir_cuentas = parametro("estado", SYS_TODAS, MQL_RAW);
$ByCuentas = "";
$ByCuentasSaldos = "";
if ($cuenta_inicial > 0 and $cuenta_final > 0) {
    $xCtaInit = new cCuentaContableEsquema($cuenta_inicial);
    $cuenta_inicial = $xCtaInit->CUENTA;
    $ByCuentas .= " AND (`contable_catalogo`.`numero`>={$cuenta_inicial}) ";
    $xCtaFin = new cCuentaContableEsquema($cuenta_final);
    $cuenta_final = $xCtaFin->CUENTA;
    $ByCuentas .= " AND (`contable_catalogo`.`numero`<={$cuenta_final}) ";
    $ByCuentasSaldos = "  AND (`contable_saldos`.`cuenta` >= {$cuenta_inicial}) AND  (`contable_saldos`.`cuenta` <= {$cuenta_final}) ";
}
$FechaInicial = $xF->getDiaInicial("{$ejercicio}-{$periodo}-01");
$FechaFinal = $xF->getDiaFinal("{$ejercicio}-{$periodo}-01");
$xRPT = new cReportes($xHP->getTitle());
$xRPT->addContent($xRPT->getEncabezado($xHP->getTitle(), $FechaInicial, $FechaFinal));
$InitRecords = parametro("init", 0, MQL_INT);
$xRPT->addCSSFiles("../css/flags.css");
$xRPT->setOut($out);
//=================================================================================================================
//$xRPT->setToPagination($InitRecords);
/**
 * Paginacion
 * I.- Parte
 */
$rowLimit = 1500;
//4Paginas aprox
//marca el Final de los Registros
$EndRecords = $InitRecords + $rowLimit;
//captura el URI para manipularlo
$_SESSION["current_file"] = addslashes($theFile);
//=====================================================================================================
$xHP = new cHPage("TR.Estado de pocision financiera ", HP_REPORT);
$xL = new cSQLListas();
$xF = new cFecha();
$query = new MQL();
$out = parametro("out", SYS_DEFAULT);
$senders = getEmails($_REQUEST);
$ejercicio = parametro("ejercicio", 0, MQL_INT);
$periodo = parametro("periodo", 0, MQL_INT);
$moneda = parametro("moneda", AML_CLAVE_MONEDA_LOCAL);
$fecha = $xF->getDiaFinal("{$ejercicio}-{$periodo}-01");
$sql = "";
$titulo = "";
$archivo = "";
$xRPT = new cReportes($titulo);
$xRPT->setFile($archivo);
$xRPT->setOut($out);
$xRPT->setSQL($sql);
$xRPT->setTitle($xHP->getTitle());
$activo = 1;
$xHP->init();
$xFormat = new cFormato(501);
//============ Reporte
$xSec = new cCuentasPorSector(1, $fecha);
$xSec->init(false);
$activo = $xSec->render();
$suma_activo = $xSec->getSumaTitulo();
$xSec = new cCuentasPorSector(2, $fecha);
$xSec->init(false);
$pasivo = $xSec->render();
    $fecha_inicial = $xF->getFechaISO($_REQUEST["fechaMX"]);
    $fecha_final = $xF->getFechaISO($_REQUEST["fechaMX"]);
}
$ByDependencia = $empresa == SYS_TODAS ? "" : " AND `socios`.`iddependencia`=" . $empresa;
$ByUsuario = $cajero == SYS_TODAS ? "" : " AND operaciones_recibos.idusuario={$cajero} ";
$ByFecha = " AND (operaciones_recibos.fecha_operacion>='{$fecha_inicial}' AND operaciones_recibos.fecha_operacion<='{$fecha_final}') ";
$nombre_empresa = "";
if ($empresa != SYS_TODAS) {
    $xEmp = new cEmpresas($empresa);
    $xEmp->init();
    $nombre_empresa = $xEmp->getNombreCorto();
}
//XXX: Hacer un UNION para captacion
$setSql = "\nSELECT\n\t`operaciones_recibos`.`idoperaciones_recibos`,\n\t`operaciones_recibos`.`fecha_operacion`,\n\t`operaciones_recibos`.`docto_afectado`,\n\t`operaciones_recibos`.`numero_socio`,\n\t`socios`.`nombre`,\n\t\n\t(CASE WHEN (`creditos_solicitud`.`persona_asociada` = " . DEFAULT_EMPRESA . ")\n\tTHEN ''\n\tELSE `socios`.`dependencia` END) AS 'dependencia',\n\t\n\t`operaciones_recibos`.`tipo_docto`,\n\t`operaciones_recibostipo`.`descripcion_recibostipo` AS `tipo_de_recibo`,\n\t`operaciones_recibos`.`tipo_pago`,\n\t`operaciones_recibos`.`recibo_fiscal`,\t\n\t\n\t`operaciones_recibos`.`total_operacion`,\n\t`operaciones_recibos`.`observacion_recibo`,\n\n\t\n\t`operaciones_recibos`.`idusuario`\n\t\n\t\n\tFROM\n\t`operaciones_recibos` `operaciones_recibos` \n\t\tLEFT OUTER JOIN `creditos_solicitud` `creditos_solicitud` \n\t\tON `operaciones_recibos`.`docto_afectado` = `creditos_solicitud`.\n\t\t`numero_solicitud` \n\t\t\tINNER JOIN `operaciones_recibostipo` `operaciones_recibostipo` \n\t\t\tON `operaciones_recibos`.`tipo_docto` = `operaciones_recibostipo`.\n\t\t\t`idoperaciones_recibostipo` \n\t\t\t\tINNER JOIN `socios` `socios` \n\t\t\t\tON `operaciones_recibos`.`numero_socio` = `socios`.`codigo`\n\t\t\t\t\n\tWHERE operaciones_recibostipo.mostrar_en_corte!='0'\n\t\t\t{$ByFecha}\n\t\t\t{$ByUsuario}\n\t\t\t{$ByDependencia}\n\t\tORDER BY\n\t\t\t`operaciones_recibos`.`tipo_pago`,\n\t\t\t`operaciones_recibos`.`fecha_operacion`,\n\t\t\t`operaciones_recibos`.`tipo_docto`,\n\t\t\t`socios`.`dependencia`,\n\t\t\t`operaciones_recibos`.`idoperaciones_recibos`\n\t";
$output = $output == SYS_DEFAULT ? OUT_RXML : $output;
$xRPT = new cReportes($xHP->getTitle() . "-{$nombre_empresa}");
$xRPT->setSenders($senders);
$xRPT->setFile("report38");
$xRPT->setOut($output);
$xRPT->setSQL($setSql);
echo $xRPT->render(true);
//exit( $setSql);
/*if ($input!=OUT_EXCEL) {
	$oRpt = new PHPReportMaker();
	$oRpt->setDatabase(MY_DB_IN);
	$oRpt->setUser(RPT_USR_DB);
	$oRpt->setPassword(RPT_PWD_DB);
	$oRpt->setSQL($setSql);
	$oRpt->setXML("../repository/report38.xml");
	$oOut = $oRpt->createOutputPlugin($input);
	$oRpt->setOutputPlugin($oOut);
$xLi = new cSQLListas();
//=====================================================================================================
$periocidad = parametro("f1", SYS_TODAS);
$periocidad = parametro("periocidad", $periocidad);
$periocidad = parametro("frecuencia", $periocidad);
$estado = parametro("estado", SYS_TODAS);
$estado = parametro("estatus", $estado);
$producto = parametro("convenio", SYS_TODAS);
$producto = parametro("producto", $producto);
$fechaInicial = parametro("on", EACP_FECHA_DE_CONSTITUCION);
$fechaFinal = parametro("off", fechasys());
$fechaInicial = $xF->getFechaISO($fechaInicial);
$fechaFinal = $xF->getFechaISO($fechaFinal);
$formato = parametro("out", SYS_DEFAULT, MQL_RAW);
$sucursal = parametro("sucursal", SYS_TODAS, MQL_RAW);
$xRPT = new cReportes($xHP->getTitle());
$ByProducto = setNoMenorQueCero($producto) > 0 ? " AND (`creditos_solicitud`.`tipo_convenio`={$producto}) " : "";
$BySucursal = ($sucursal == SYS_TODAS or $sucursal == "") ? "" : " AND (`creditos_solicitud`.`sucursal` = '{$sucursal}') ";
/*	`creditos_solicitud`.`numero_solicitud`,
	`creditos_solicitud`.`fecha_solicitud`,
	`creditos_solicitud`.`fecha_autorizacion`,
	`creditos_solicitud`.`monto_solicitado`,
	`creditos_solicitud`.`monto_autorizado`,
	`creditos_solicitud`.`numero_socio`,
	`creditos_solicitud`.`docto_autorizacion`,
	`creditos_solicitud`.`plazo_en_dias`,
	`creditos_solicitud`.`numero_pagos`,
	`creditos_solicitud`.`tasa_interes`,
	`creditos_solicitud`.`periocidad_de_pago`,
	`creditos_solicitud`.`tipo_credito`,
	`creditos_solicitud`.`estatus_actual`,
             $adr .= $xDom->getFicha();
         }
         //$xTbl->addTH();
         //$xTbl->addTD($adr);
         $xTbl->addRaw("<tr><td colspan='3'><h1>" . $xLng->getT("TR.Direcciones") . "<h1><hr />{$adr}</td></tr>");
         //$xTbl->endRow()
         $xFld = new cHFieldset($flTitle);
         $xFld->addHElem($xTbl->get());
         $txtLst .= $xFld->get();
     }
 }
 if ($getPDF == true) {
     //base64_encode($sql)
     $xFMT = new cFormato(8801);
     $xFMT->setProcesarVars(array("variable_listado_de_cedulas" => $txtLst, "variable_item_buscado" => "{$nombre} / {$apaterno} / {$amaterno}", "variable_cadena_consulta" => ""));
     $xRPT = new cReportes($xHP->getTitle());
     $xRPT->getEncabezado($xHP->getTitle());
     if ($ret == true) {
         $xRPT->setOut(OUT_HTML);
         $xRPT->setFile("ofacs_list_");
         $xRPT->addContent($xFMT->get());
         $xRPT->render(true);
         $dompdf = new DOMPDF();
         $dompdf->load_html($xRPT->render(true));
         $dompdf->set_paper("letter", "portrait");
         $dompdf->render();
         $json["pdf"] = base64_encode($dompdf->output());
     } else {
         $xRPT->setSenders($mails);
         $xRPT->setOut(OUT_PDF);
         $xRPT->setFile("ofacs_list_");
$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()" : "";
$senders = getEmails($_REQUEST);
$credito = parametro("x", $credito, MQL_INT);
$credito = parametro("pb", $credito, MQL_INT);
//compatible
$ByFecha = "";
$sql = "SELECT\n\t\t\t\n\t\t\t\t/* `operaciones_mvtos`.`socio_afectado`,\n\t\t\t\t`operaciones_mvtos`.`docto_afectado`, */\n\t\t\t\t`operaciones_mvtos`.`recibo_afectado`,\n\t\t\t\n\t\t\t\t`operaciones_mvtos`.`fecha_operacion` AS 'fecha_de_operacion',\n\t\t\t\t`operaciones_tipos`.`descripcion_operacion` AS 'tipo_de_operacion',\n\t\t\t\n\t\t\t\t(`operaciones_mvtos`.`afectacion_real` *\n\t\t\t\t`eacp_config_bases_de_integracion_miembros`.`afectacion`) AS 'monto'\n\t\t\t\n\t\t\t\n\t\t\tFROM\n\t\t\t\n\t\t\t\n\t\t\t\t`operaciones_mvtos` `operaciones_mvtos`\n\t\t\t\t\tINNER JOIN `eacp_config_bases_de_integracion_miembros`\n\t\t\t\t\t`eacp_config_bases_de_integracion_miembros`\n\t\t\t\t\tON `operaciones_mvtos`.`tipo_operacion` =\n\t\t\t\t\t`eacp_config_bases_de_integracion_miembros`.`miembro`\n\t\t\t\t\t\tINNER JOIN `operaciones_tipos` `operaciones_tipos`\n\t\t\t\t\t\tON `operaciones_mvtos`.`tipo_operacion` = `operaciones_tipos`.\n\t\t\t\t\t\t`idoperaciones_tipos`\n\t\t\tWHERE\n\t\t\t\t(`operaciones_mvtos`.`docto_afectado` = {$credito})\n\t\t\t\tAND\n\t\t\t\t(`eacp_config_bases_de_integracion_miembros`.`codigo_de_base` =2000)\n\t\t\t\t{$ByFecha}\n\t\t\tORDER BY\n\t\t\t\t`eacp_config_bases_de_integracion_miembros`.`codigo_de_base`,\n\t\t\t\t`operaciones_mvtos`.`fecha_operacion`";
$titulo = "";
$archivo = "";
$xRPT = new cReportes($titulo);
$xRPT->setFile($archivo);
$xRPT->setOut($out);
$xRPT->setSQL($sql);
$xRPT->setTitle($xHP->getTitle());
//Ficha
$xCred = new cCredito($credito);
$xCred->init();
$xRPT->addContent($xCred->getFicha(true, "", true, true));
//============ Reporte
//$xT		= new cTabla($sql, 2);
//$xT->setTipoSalida($out);
$body = $xRPT->getEncabezado($xHP->getTitle(), $FechaInicial, $FechaFinal);
$xRPT->setBodyMail($body);
$xRPT->addContent($body);
$rs = $query->getDataRecord($sql);
$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()" : "";
$senders = getEmails($_REQUEST);
$xEmp = new cEmpresas($empresa);
$xEmp->init();
$nombre_empresa = $xEmp->getNombre();
$sql = $xL->getListadoDeIncidenciasAhorro($empresa);
$titulo = "";
$archivo = "";
$xRPT = new cReportes($titulo);
$xRPT->setFile($archivo);
$xRPT->setOut($out);
$xRPT->setSQL($sql);
//$xRPT->setTitle($nombre_empresa. "-". $xHP->getTitle());
//============ Reporte
$xT = new cTabla($sql, 2);
$xT->setTipoSalida($out);
$body = $xRPT->getEncabezado($nombre_empresa . "<br/>" . $xHP->getTitle());
$xRPT->setBodyMail($body);
$xRPT->addContent($body);
//$xT->setEventKey("jsGoPanel");
//$xT->setKeyField("creditos_solicitud");
$xRPT->addContent($xT->Show());
//============ Agregar HTML
//$xRPT->addContent( $xHP->init($jsEvent) );
//encapsula el patrom
$patron = "/init=\\d*/";
if ($InitRecords > 0) {
    $mURI = preg_replace($patron, "init={$EndRecords}", $mURI);
} else {
    $mURI .= "&init={$EndRecords}";
}
//==================================================================================
/*if($unica_cuenta == 1){
	$dcta 			= getInfoCatalogo($esa_cuenta);
	$nivel 			= $dcta["digitoagrupador"];
	$dicat 			= explode("@", CAT_LEN);
	$largo 			= $dicat[$nivel];
	$pcta 			= getCuentaCompleta($esa_cuenta);
	$pcta 			= substr($pcta, 0, $largo);
	$sqlWHERE 		.= " AND `contable_catalogo`.`numero` LIKE '$pcta%' ";
}*/
$setSql = $xLi->getListadoDeCuentasContables($Cuenta, $niveles, $tipo_cuentas, $afectables, 0, $InitRecords, $EndRecords);
//setLog($setSql);
$xRPT = new cReportes();
$xRPT->setTitle($xHP->getTitle());
$xRPT->addCSSFiles("../css/catalogo.flags.css");
$xRPT->setOut($out);
$cTbl = new cTabla($setSql);
//$xRPT->addContent($xHP->init());
$xRPT->addContent($cTbl->Show("", true, "idcatalogocontable"));
$xRPT->addContent($xHP->fin());
if ($mostrarTodo == false) {
    $xRPT->setToPagination($EndRecords);
}
echo $xRPT->render(true);
$out = parametro("out", SYS_DEFAULT);
$persona = parametro("persona", DEFAULT_SOCIO, MQL_INT);
$persona = parametro("socio", $persona, MQL_INT);
$persona = parametro("idsocio", $persona, MQL_INT);
$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()" : "";
$senders = getEmails($_REQUEST);
$sql = "SELECT\r\n\t`operaciones_recibos`.`numero_socio`                      AS `persona`,\r\n\t`operaciones_recibos`.`fecha_operacion`                   AS `fecha`,\r\n\t`operaciones_recibostipo`.`descripcion_recibostipo`       AS `tipo`,\r\n\t`operaciones_recibos`.`docto_afectado`                   AS `documento`,\r\n\t`personas_perfil_transaccional_tipos`.`nombre_del_perfil` AS `origen`,\r\n\t`operaciones_recibos`.`idoperaciones_recibos`\t          AS `recibo`,\r\n\t`operaciones_recibos`.`total_operacion`                   AS `monto`,\r\n\t\r\n\t`operaciones_recibos`.`idusuario`                         AS `usuario`,\r\n\t`operaciones_recibos`.`observacion_recibo`                AS `observaciones`,\r\n\t`operaciones_recibos`.`tipo_pago`                         AS `forma_de_pago`,\r\n\t`operaciones_recibos`.`clave_de_moneda`                   AS `moneda`,\r\n\t`operaciones_recibos`.`unidades_en_moneda`                AS `unidades`,\r\n\tIF(UPPER(`operaciones_recibos`.`clave_de_moneda`) != getMonedaLocal(), getEquivalenciaDeMonedas(`operaciones_recibos`.`unidades_en_moneda`, `operaciones_recibos`.`clave_de_moneda`),\r\n\t`operaciones_recibos`.`total_operacion`)\r\n\t                AS `equivalencia`\r\nFROM\r\n\t`operaciones_recibos` `operaciones_recibos` \r\n\t\tINNER JOIN `operaciones_recibostipo` `operaciones_recibostipo` \r\n\t\tON `operaciones_recibos`.`tipo_docto` = `operaciones_recibostipo`.\r\n\t\t`idoperaciones_recibostipo` \r\n\t\t\tINNER JOIN `personas_perfil_transaccional_tipos` \r\n\t\t\t`personas_perfil_transaccional_tipos` \r\n\t\t\tON `operaciones_recibos`.`origen_aml` = \r\n\t\t\t`personas_perfil_transaccional_tipos`.\r\n\t\t\t`idpersonas_perfil_transaccional_tipos` \r\nWHERE\r\n\t(`operaciones_recibos`.`numero_socio` ={$persona})";
$titulo = "";
$archivo = "";
$xRPT = new cReportes($titulo);
$xRPT->setFile($archivo);
$xRPT->setOut($out);
$xRPT->setSQL($sql);
$xRPT->setTitle($xHP->getTitle());
//============ Reporte
$xSoc = new cSocio($persona);
$xSoc->init();
$xT = new cTabla($sql, 2);
$xT->setTipoSalida($out);
$xT->setFootSum(array(4 => "monto", 9 => "unidades", 10 => "equivalencia"));
$body = $xRPT->getEncabezado($xHP->getTitle(), $FechaInicial, $FechaFinal);
$xRPT->setBodyMail($body);
$xRPT->addContent($body);
$xRPT->addContent($xSoc->getFicha(true));
//$xT->setEventKey("jsGoPanel");
$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 = "SELECT\r\n\t`personas_actividad_economica_tipos`.`clave_interna`,\r\n\t`personas_actividad_economica_tipos`.`clave_de_actividad`,\r\n\t`personas_actividad_economica_tipos`.`nombre_de_la_actividad`,\r\n\t`personas_actividad_economica_tipos`.`clasificacion`,\r\n\t`aml_risk_levels`.`nombre_del_nivel` AS `riesgo` \r\nFROM\r\n\t`aml_risk_levels` `aml_risk_levels` \r\n\t\tINNER JOIN `personas_actividad_economica_tipos` \r\n\t\t`personas_actividad_economica_tipos` \r\n\t\tON `aml_risk_levels`.`clave_de_control` = \r\n\t\t`personas_actividad_economica_tipos`.`nivel_de_riesgo` \r\n\tORDER BY\r\n\t\t`personas_actividad_economica_tipos`.`clave_de_actividad`";
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 
    ?>
	function initComponents(){ window.print();	}
	</script>
	<?php 
}
echo $xHP->setBodyEnd();
$xHP->end();
    $fecha_inicial = $xF->getFechaISO($fecha_inicial);
}
//http://localhost/rptotros/rpt_mvtos_x_tipo_segun_fechas.php
//estado=todas
//out=default
//empresa=todas
//convenio=todas
//tipodepago=transferenci
//usuario=todas
$BySucursal = $sucursal == SYS_TODAS ? "" : "  AND operaciones_mvtos.sucursal = '{$sucursal}'  ";
$xmlFile = "report73.nomina";
$ByPersona = $persona == SYS_NINGUNO ? "" : " AND operaciones_mvtos.socio_afectado={$persona} ";
$ByOperacion = $operacion == SYS_TODAS ? "" : " AND `operaciones_mvtos`.`tipo_operacion` = {$operacion} ";
$ByPago = $forma_de_pago == SYS_TODAS ? "" : " AND operaciones_recibos.tipo_pago ='{$forma_de_pago}' ";
$tipo = $operacion;
if ($ByOperacion != "") {
    $cMov = new cOperaciones_tipos();
    $cMov->setData($cMov->query()->initByID($tipo));
    $tipo = $cMov->descripcion_operacion()->v();
}
$setSql = " SELECT\n\t\t\t\toperaciones_mvtos.sucursal,\n\t\t\t\toperaciones_recibos.tipo_pago \t\t\t\tAS 'tipo_de_pago',\n\t\t\t\toperaciones_mvtos.socio_afectado \t\t\tAS 'numero_de_socio',\n\t\t\t\t\n\t\t\t\t`socios`.`nombre` AS `nombre_completo`,\n\t\t\t\t`socios`.`alias_dependencia` AS `empresa`,\n\t\t\t\t\n\t\t\t\toperaciones_tipos.descripcion_operacion \tAS 'tipo_de_operacion',\n\t\t\t\toperaciones_mvtos.fecha_afectacion \t\t\tAS 'fecha',\n\t\t\t\t`operaciones_mvtos`.`idoperaciones_mvtos`\tAS `operacion`,\n\t\t\t\t`operaciones_mvtos`.`recibo_afectado`   \tAS `recibo`,\n\t\t\t\t`operaciones_recibos`.`recibo_fiscal`   \tAS `fiscal`,\n\t\t\t\toperaciones_mvtos.docto_afectado \t\t\tAS 'documento',\n\t\t\t\toperaciones_mvtos.afectacion_real\t\t\tAS 'monto',\n\t\t\t\toperaciones_mvtos.detalles \t\t\t\t\tAS 'observaciones'\n\t\t\t\tFROM\n\t\t\t\t`operaciones_mvtos` `operaciones_mvtos` \n\t\t\t\t\tINNER JOIN `operaciones_tipos` `operaciones_tipos` \n\t\t\t\t\tON `operaciones_mvtos`.`tipo_operacion` = `operaciones_tipos`.\n\t\t\t\t\t`idoperaciones_tipos` \n\t\t\t\t\t\tINNER JOIN `socios` `socios` \n\t\t\t\t\t\tON `socios`.`codigo` = `operaciones_mvtos`.`socio_afectado` \n\t\t\t\t\t\t\tINNER JOIN `operaciones_recibos` `operaciones_recibos` \n\t\t\t\t\t\t\tON `operaciones_mvtos`.`recibo_afectado` = `operaciones_recibos`\n\t\t\t\t\t\t\t.`idoperaciones_recibos`\n\t\t\t\t\t\t\n\t\t\t\tWHERE\n\t\t\t\toperaciones_mvtos.fecha_afectacion>='{$fecha_inicial}'\n\t\t\t\tAND\n\t\t\t\toperaciones_mvtos.fecha_afectacion<='{$fecha_final}'\n\t\t\t\t\t{$ByPersona}\n\t\t\t\t\t{$BySucursal}\n\t\t\t\t\t{$ByOperacion}\n\t\t\t\t\t{$ByPago}\n\t\t\tORDER BY\n\t\t\t\t`operaciones_mvtos`.`sucursal`,\n\t\t\t\t`operaciones_recibos`.`fecha_operacion`,\n\t\t\t\t`operaciones_recibos`.`idoperaciones_recibos`,\n\t\t\t\t`operaciones_mvtos`.`idoperaciones_mvtos` ";
//exit($setSql);
$xRPT = new cReportes("TR.Reporte de operaciones - {$tipo}");
$output = $output == SYS_DEFAULT ? OUT_RXML : $output;
$xRPT->setOut($output);
$xRPT->setSenders($senders);
$body = $xRPT->getEncabezado("", $fecha_inicial, $fecha_final);
$xRPT->setBodyMail($body);
$xRPT->setFile($xmlFile);
$xRPT->setSQL($setSql);
$xRPT->render(true);
$xF = new cFecha();
$Fenv = new cFecha();
$xL = new cSQLListas();
$empresa = isset($_GET["r"]) ? $_GET["r"] : 0;
$periocidad = isset($_GET["p"]) ? $_GET["p"] : SYS_TODAS;
$variacion = isset($_GET["v"]) ? $_GET["v"] : 0;
$out = parametro("out", OUT_HTML);
$periodo = isset($_GET["periodo"]) ? $_GET["periodo"] : 0;
$fechaInicial = parametro("on", false);
$fechaFinal = parametro("off", false);
$fechaFinal = $xF->getFechaISO($fechaFinal);
$fechaInicial = $xF->getFechaISO($fechaInicial);
$idnomina = parametro("nomina", 0, MQL_INT);
$mails = getEmails($_REQUEST);
$FAnt = new cFecha();
$xRPT = new cReportes("");
if ($periocidad == SYS_TODAS) {
    $xPerNom = new cEmpresas_operaciones();
    $xPerNom->setData($xPerNom->query()->initByID($idnomina));
    $empresa = $xPerNom->clave_de_empresa()->v();
    $periocidad = $xPerNom->periocidad()->v();
    $periodo = $xPerNom->periodo_marcado()->v();
}
$ByMinistracion = "";
//$periodo		= $periodo + $variacion;
$observaciones = isset($_GET["o"]) ? $_GET["o"] : 0;
$xLoc = new cLocal();
$xHP->addJsFile("../js/jquery/jquery.js");
$xHP->addJsFile("../js/general.js");
$xEmp = new cEmpresas($empresa);
$xEmp->init();
$output = !isset($_GET["out"]) ? "default" : $_GET["out"];
$idsolicitud = $_GET["pb"];
//Numero de Solicitud
$id = !isset($_GET["pa"]) ? false : $_GET["pa"];
//Numero de Socio
$f15 = !isset($_GET["f15"]) ? false : $_GET["f15"];
$f14 = !isset($_GET["f14"]) ? false : $_GET["f14"];
$f16 = !isset($_GET["f16"]) ? false : $_GET["f16"];
$f18 = !isset($_GET["f18"]) ? false : $_GET["f18"];
//Mostrar Movimiento Especifico
$TOperacion = !isset($_GET["f19"]) ? false : $_GET["f19"];
//Codigo de Tipo de Operacion.- Mvto Especifico
$fecha_inicial = $_GET["on"];
$fecha_final = $_GET["off"];
$xHP->init("initComponents()");
$xRPT = new cReportes($xHP->getTitle());
echo $xHP->getEncabezado();
echo $xRPT->getEncabezado();
$cCred = new cCredito($idsolicitud);
$cCred->init();
//TODO: Modificar
echo $cCred->getFicha(true, "", true, true);
$sql = "SELECT\n\t`creditos_sdpm_historico`.`idcreditos_sdpm_historico` AS `control`,\n\t`creditos_sdpm_historico`.`numero_de_socio`,\n\t`creditos_sdpm_historico`.`numero_de_credito`,\n\t`creditos_sdpm_historico`.`fecha_anterior`,\n\t`creditos_sdpm_historico`.`fecha_actual`,\n\t`creditos_sdpm_historico`.`dias_transcurridos`,\n\t`creditos_sdpm_historico`.`monto_calculado`,\n\t`creditos_sdpm_historico`.`saldo`,\n\t`creditos_sdpm_historico`.`estatus`,\n\t`creditos_sdpm_historico`.`interes_normal`\nFROM\n\t`creditos_sdpm_historico` `creditos_sdpm_historico` \nWHERE\n\t(`creditos_sdpm_historico`.`numero_de_credito` ={$idsolicitud})\nORDER BY\n\t`creditos_sdpm_historico`.`fecha_anterior` ASC\n\t/*`creditos_sdpm_historico`.`fecha_actual` DESC */";
$cTbl = new cTabla($sql);
$cTbl->setTdClassByType();
$cTbl->setWidth();
$cTbl->Show("", false);
$TSum = $cTbl->getFieldsSum();
echo " <table width='100%'>\n\t\t<tr>\n\t\t<td />\n\t\t<td />\n\t\t<td />\n\t\t<td />\n\t\t\n\t\t<th class='mny'>" . getFMoney($TSum["dias_transcurridos"]) . "</th>\n\t\t<th class='mny'>" . getFMoney($TSum["monto_calculado"]) . "</th>\n\t\t<th class='mny'>" . getFMoney($TSum["saldo"]) . "</th>\n\t\t<td />\n\t\t<th class='mny'>" . getFMoney($TSum["interes_normal"]) . "</th>\n\t\t</tr>\n\t\t</table ";
echo $xHP->getPieDePagina();
?>
     $archivo = $xLayout->getClave() . $xT->cSerial(6, $casfin) . $FechaTitulo . "." . $xT->cSerial(3, $supervisor);
     //header("Content-type: text/x-csv");
     header("Content-type: text/plain");
     //header("Content-type: application/csv");
     header("Content-Disposition: attachment; filename={$archivo}");
     echo $rpt;
     if ($definitivo == true) {
         //Guardar
         $sqlUpdate = " UPDATE `aml_risk_register` SET `estado_de_envio` = 1, `fecha_de_envio`= " . $xF->getInt() . "\n\t\t\tWHERE (SELECT `tipo_de_riesgo` FROM `aml_risk_catalog` WHERE\n\t\t\t(`clave_de_control`= `aml_risk_register`.`tipo_de_riesgo`= " . AML_CLAVE_OPERACIONES_INTERNAS . "\n\t\t\t\tOR\n\t\t\t`clave_de_control`= `aml_risk_register`.`tipo_de_riesgo`= " . AML_CLAVE_OPERACIONES_INUSUALES . ")\n\t\t\tAND (getFechaByInt(`aml_risk_register`.`fecha_de_reporte`) <='{$FechaFinal}')\n\t\t\tAND (`aml_risk_register`.`estado_de_envio` =0)\n\t\t\tAND (`aml_risk_register`.`reporte_inmediato` =1)\t\t\t\n\t\t\t";
         $query->setRawQuery($sqlUpdate);
         //enviar por mail al administrador
         $xMail = new cNotificaciones();
         $xMail->sendMail($archivo, $rpt, ADMIN_MAIL);
     }
 } else {
     $xRPT = new cReportes();
     $xRPT->setOut(OUT_HTML);
     $xRPT->addContent($xRPT->getHInicial($xHP->getTitle(), $FechaInicial, $FechaFinal));
     $arrTitulos = array();
     foreach ($Estructura as $indice => $propiedades) {
         $xCampo = new cReportes_LayoutTipos($propiedades);
         $arrTitulos[] = $xCampo->getNombre();
     }
     $xHTable->addTitles($arrTitulos);
     if ($msg != "") {
         $xRPT->addFooterBar("<h3>El reporte contiene los siguientes errores</h3>" . $msg);
     }
     $xRPT->addContent($xHTable->get());
     $xRPT->setToPrint();
     echo $xRPT->render(true);
 }
$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}) ";
$ByFecha = "";
echo $xHP->getHeader();
echo $xHP->setBodyinit("initComponents();");
echo getRawHeader();
$xRpt = new cReportes();
echo $xRpt->getEncabezado($xHP->getTitle(), $fechaInicial, $fechaFinal, $oficial);
$sql = "SELECT * FROM listado_de_ingresos WHERE (`listado_de_ingresos`.`fecha` >='{$fechaInicial}')\r\nAND (`listado_de_ingresos`.`fecha` <='{$fechaFinal}') {$ByConvenio} {$ByEmpresa}\r\nAND tipo_de_pago !='" . TESORERIA_COBRO_NINGUNO . "'\r\n";
//echo $sql;
$xTBL = new cTabla($sql);
$xTBL->setTdClassByType();
$xTBL->setFootSum(array(9 => "capital", 10 => "interes_normal", 11 => "interes_moratorio", 12 => "iva", 13 => "otros"));
echo $xTBL->Show();
echo getRawFooter();
echo $xHP->setBodyEnd();
?>
<script language="javascript">
<?php 
?>
function initComponents(){
	window.print();
$nivel_cuentas = parametro("nivel", SYS_TODAS, MQL_RAW);
$incluir_cuentas = parametro("estado", SYS_TODAS, MQL_RAW);
$ByCuentas = "";
$ByCuentasSaldos = "";
if ($cuenta_inicial > 0 and $cuenta_final > 0) {
    $xCtaInit = new cCuentaContableEsquema($cuenta_inicial);
    $cuenta_inicial = $xCtaInit->CUENTA;
    $ByCuentas .= " AND (`contable_catalogo`.`numero`>={$cuenta_inicial}) ";
    $xCtaFin = new cCuentaContableEsquema($cuenta_final);
    $cuenta_final = $xCtaFin->CUENTA;
    $ByCuentas .= " AND (`contable_catalogo`.`numero`<={$cuenta_final}) ";
    $ByCuentasSaldos = "  AND (`contable_movimientos`.`numerocuenta` >= {$cuenta_inicial}) AND  (`contable_movimientos`.`numerocuenta` <= {$cuenta_final}) ";
}
$FechaInicial = $xF->getDiaInicial("{$ejercicio}-{$periodo}-01");
$FechaFinal = $xF->getDiaFinal("{$ejercicio}-{$periodo}-01");
$xRPT = new cReportes($xHP->getTitle());
$xRPT->addContent($xRPT->getEncabezado($xHP->getTitle(), $FechaInicial, $FechaFinal));
$InitRecords = parametro("init", 0, MQL_INT);
$xRPT->addCSSFiles("../css/flags.css");
$xRPT->setOut($out);
//=================================================================================================================
//$xRPT->setToPagination($InitRecords);
/**
 * Paginacion
 * I.- Parte
 */
$rowLimit = 1500;
//4Paginas aprox
//marca el Final de los Registros
$EndRecords = $InitRecords + $rowLimit;
//captura el URI para manipularlo
$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()" : "";
$senders = getEmails($_REQUEST);
$xODat = new cPersonasCatalogoOtrosDatos();
$sql = "SELECT\r\n\t`socios`.`codigo`,\r\n\t`socios`.`nombre`,\r\n\t`socios_otros_parametros`.`clave_del_parametro` \r\nFROM\r\n\t`socios_otros_parametros` `socios_otros_parametros` \r\n\t\tINNER JOIN `socios` `socios` \r\n\t\tON `socios_otros_parametros`.`clave_de_persona` = `socios`.`codigo` \r\nWHERE\r\n\t(`socios_otros_parametros`.`clave_del_parametro` ='" . $xODat->AML_PEP_PRINCIPAL . "')\r\n\t\t\tOR\r\n\t(`socios_otros_parametros`.`clave_del_parametro` ='" . $xODat->AML_PEP_AFINIDAD . "')\t\t\t\r\n\tOR\r\n(`socios_otros_parametros`.`clave_del_parametro` ='" . $xODat->AML_PEP_CONSANGUINIDAD . "')\t\t\t\r\n\t\tOR\r\n(`socios_otros_parametros`.`clave_del_parametro` ='" . $xODat->AML_PEP_VINCULO_ECONOM . "')\t";
$titulo = "";
$archivo = "";
$xRPT = new cReportes($titulo);
$xRPT->setFile($archivo);
$xRPT->setOut($out);
$xRPT->setSQL($sql);
$xRPT->setTitle($xHP->getTitle());
//============ Reporte
$xT = new cTabla($sql, 1);
$xT->setTipoSalida($out);
$body = $xRPT->getEncabezado($xHP->getTitle(), $FechaInicial, $FechaFinal);
$xRPT->setBodyMail($body);
$xRPT->addContent($body);
//$xT->setEventKey("jsGoPanel");
//$xT->setKeyField("creditos_solicitud");
$xRPT->addContent($xT->Show());
//============ Agregar HTML
//$xRPT->addContent( $xHP->init($jsEvent) );
$empresa = isset($_GET["empresa"]) ? $_GET["empresa"] : SYS_TODAS;
$out = isset($_GET["out"]) ? $_GET["out"] : SYS_DEFAULT;
$fechaInicial = isset($_GET["on"]) ? $xF->getFechaISO($_GET["on"]) : FECHA_INICIO_OPERACIONES_SISTEMA;
$fechaFinal = isset($_GET["off"]) ? $xF->getFechaISO($_GET["off"]) : fechasys();
$es_por_estatus = "";
$es_por_frecuencia = "";
$es_por_convenio = "";
$ByEmpresa = $empresa == SYS_TODAS ? "" : " AND socios.iddependencia = {$empresa} ";
if ($estatus != SYS_TODAS) {
    $es_por_estatus = " AND creditos_solicitud.estatus_actual={$estatus} ";
}
//
if ($frecuencia != SYS_TODAS) {
    $es_por_frecuencia = " AND creditos_solicitud.periocidad_de_pago ={$frecuencia} ";
}
//
if ($convenio != SYS_TODAS) {
    $es_por_convenio = " AND creditos_solicitud.tipo_convenio = {$convenio} ";
}
/* ******************************************************************************/
$setSql = "SELECT\r\n\t`socios`.`iddependencia`                         AS `empresa`,\r\n\t`socios`.`dependencia`                           AS `nombre`,\r\n\t`operaciones_mvtos`.`tipo_operacion`             AS `tipo`,\r\n\t`operaciones_tipos`.`descripcion_operacion`      AS `nombre`,\r\n\tCOUNT(`operaciones_mvtos`.`idoperaciones_mvtos`) AS `operaciones`,\r\n\tSUM(`operaciones_mvtos`.`afectacion_real`)       AS `monto`\r\nFROM\r\n\t`operaciones_mvtos` `operaciones_mvtos` \r\n\t\tINNER JOIN `operaciones_tipos` `operaciones_tipos` \r\n\t\tON `operaciones_mvtos`.`tipo_operacion` = `operaciones_tipos`.\r\n\t\t`idoperaciones_tipos` \r\n\t\t\tINNER JOIN `socios` `socios` \r\n\t\t\tON `operaciones_mvtos`.`socio_afectado` = `socios`.`codigo`\r\nWHERE\r\n\t(`socios`.`iddependencia` ={$empresa}) AND\r\n\t(`operaciones_mvtos`.`fecha_afectacion` >='{$fechaInicial}') AND (`operaciones_mvtos`.`fecha_afectacion` <='{$fechaFinal}')\r\nGROUP BY\r\n\t`socios`.`iddependencia`,\r\n\t`operaciones_mvtos`.`tipo_operacion`\r\n\t";
$xT = new cTabla($setSql, 0);
echo $xHP->getHeader();
echo $xHP->setBodyinit();
$xRPT = new cReportes();
echo $xRPT->getEncabezado($xHP->getTitle(), $fechaInicial, $fechaFinal);
//echo $setSql;
echo $xT->Show();
echo $xRPT->getPie();
echo $xHP->setBodyEnd();
echo $xHP->end();