$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) ); //$xRPT->addContent( $xHP->end() ); $xRPT->setResponse(); $xRPT->setSenders($senders); echo $xRPT->render(true);
$estadisticos = parametro("estadisticos", false, MQL_BOOL); if ($estadisticos == true) { $ByTipoDePago .= " AND tipo_de_pago !='" . TESORERIA_COBRO_NINGUNO . "' "; } if ($ByTipoDePago == "") { $GByTipoPago = ", `listado_de_ingresos`.`tipo_de_pago`"; } $xRPT->setOut($out); //============ Reporte $body = $xRPT->getEncabezado($xHP->getTitle(), $FechaInicial, $FechaFinal); $xRPT->setBodyMail($body); //============ Agregar HTML //$xRPT->addContent( $xHP->init($jsEvent) ); $xRPT->addContent($body); //$xT->setEventKey("jsGoPanel"); //$xT->setKeyField("creditos_solicitud"); $xRPT->setTitle($xHP->getTitle()); $sql = "\r\nSELECT\r\n\t{$mrkEmpresa}\r\n\t`listado_de_ingresos`.`codigo`,\r\n\t`listado_de_ingresos`.`nombre`,\r\n\t`listado_de_ingresos`.`fecha`,\r\n\tSUM(`listado_de_ingresos`.`capital`) AS `capital`,\r\n\tSUM(`listado_de_ingresos`.`interes_normal`) \tAS `interes`,\r\n\tSUM(`listado_de_ingresos`.`interes_moratorio`) \tAS `moratorios`,\r\n\tSUM(`listado_de_ingresos`.`iva`) \tAS `iva`,\r\n\tSUM(`listado_de_ingresos`.`otros`) \tAS `otros` ,\r\n\tSUM(`capital`+ `interes_normal`+`interes_moratorio`+`iva`+`otros`) AS 'total',\r\n\tMAX(`listado_de_ingresos`.`parcialidad`) \tAS `parcialidad`,\r\n\tMAX(`listado_de_ingresos`.`periocidad`)\t\t\tAS `periocidad`,\r\n\tMAX(`listado_de_ingresos`.`banco`)\t\t\t\tAS `banco`\r\n\t{$CampoTipoPago}\r\nFROM\r\n\t`listado_de_ingresos` `listado_de_ingresos`\r\nWHERE\r\n\t(`listado_de_ingresos`.`fecha` >='{$FechaInicial}') AND (`listado_de_ingresos`.`fecha` <='{$FechaFinal}') {$ByConvenio} {$ByEmpresa} {$ByBanco} {$ByTipoDePago}\r\nGROUP BY\r\n\t`listado_de_ingresos`.`clave_empresa`,\r\n\t`listado_de_ingresos`.`codigo`,\r\n\t`listado_de_ingresos`.`fecha`,\r\n\t`listado_de_ingresos`.`banco`\r\n\t{$GByTipoPago}\r\nORDER BY\r\n\t`listado_de_ingresos`.`fecha`,\r\n\t`listado_de_ingresos`.`clave_empresa`,\r\n\t`listado_de_ingresos`.`periocidad`,\r\n\t`listado_de_ingresos`.`nombre`\r\n\t"; //exit( $sql); $xTBL = new cTabla($sql); $xTBL->setEventKey("jsGoEstadoDeCuentaDeCreditosPorPersona"); $xTBL->setKeyField("codigo"); $xTBL->setTdClassByType(); $xTBL->setTipoSalida($out); $arrCSumas = $empresa != DEFAULT_EMPRESA ? array(5 => "capital", 6 => "interes", 7 => "moratorios", 8 => "iva", 9 => "otros", 10 => "total") : array(3 => "capital", 4 => "interes", 5 => "moratorios", 6 => "iva", 7 => "otros", 8 => "total"); $xTBL->setFootSum($arrCSumas); $xRPT->setSQL($sql); $xRPT->addContent($xTBL->Show()); $xRPT->setResponse(); $xRPT->setSenders($senders); echo $xRPT->render(true);
function convertTable($sql, $titulo = "", $ret = false) { $iduser = getUsuarioActual(); $filename = $titulo == "" ? strtolower($_SERVER['SCRIPT_NAME']) : $titulo; $arrPurga = array("rpt_", "-", "rpt", ".php", "php", "."); $filename = str_replace($arrPurga, "", $filename); $filename = trim($filename); $arrPurga2 = array(" ", " ", "__", "___"); $filename = str_replace($arrPurga2, "_", $filename); //$filename = ( substr($filename, 0,1) == "_") ? substr($filename,1) : $filename; $filename = $filename . "-" . date("Y_m_d_Hi") . "-" . $iduser . ".xls"; header("Content-type: application/vnd.ms-excel"); header("Content-Disposition: attachment; filename={$filename}"); header("Pragma: no-cache"); header("Expires: 0"); $cTbl = new cTabla($sql); $cTbl->setTipoSalida(OUT_EXCEL); $excel = "<html xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:x=\"urn:schemas-microsoft-com:office:excel\" xmlns=\"http://www.w3.org/TR/REC-html40\">"; $excel .= "\r\n<head>\r\n"; $excel .= "<!--[if gte mso 9]>\r\n"; $excel .= "<xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{$filename}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml>"; $excel .= "\r\n<![endif]-->\r\n"; $excel .= "</head>\r\n"; $excel .= "<body>\r\n"; $excel .= $this->mContent; $excel .= $cTbl->Show(); $excel .= "\r\n</body>\r\n</html>\r\n"; /*$excel = "<html xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:x=\"urn:schemas-microsoft-com:office:excel\" xmlns=\"http://www.w3.org/TR/REC-html40\">"; $excel .= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"; $excel .= "<html><head><meta http-equiv=\"Content-type\" content=\"text/html;charset=\"iso-8859-1\" />"; $excel .= "<style id=\"Classeur1_16681_Styles\"> </style> </head><body><div id=\"Classeur1_16681\" align=center x:publishsource=\"Excel\"> "; $excel .= $cTbl->Show(); $excel .= "</div></body></html>";*/ if ($ret == true) { return utf8_encode($excel); } else { echo utf8_encode($excel); } }
`creditos_solicitud`.`fuente_de_fondeo`, `creditos_solicitud`.`fecha_de_primer_pago`, COUNT(`operaciones_mvtos`.`tipo_operacion`) AS `operaciones`, MAX(`operaciones_mvtos`.`fecha_afectacion`) AS `fecha`, SUM( IF(`operaciones_mvtos`.`tipo_operacion` = 120, `operaciones_mvtos`.`afectacion_real`, 0 ) ) AS `abonos` FROM `operaciones_mvtos` `operaciones_mvtos` RIGHT OUTER JOIN `creditos_solicitud` `creditos_solicitud` ON `operaciones_mvtos`.`docto_afectado` = `creditos_solicitud`. `numero_solicitud` INNER JOIN `operaciones_recibos` `operaciones_recibos` ON `operaciones_mvtos`.`recibo_afectado` = `operaciones_recibos`. `idoperaciones_recibos` */ $sql = "\nSELECT\n\t`creditos_solicitud`.`numero_solicitud` AS `contrato`,\n\t`creditos_tipoconvenio`.`descripcion_tipoconvenio` AS `producto`,\n\t`socios`.`codigo` AS `persona`,\n\t`socios`.`nombre` AS `nombre`,\n\t`socios`.`alias_dependencia` AS `empresa`,\n\t`creditos_solicitud`.`monto_autorizado` AS `monto_original`\n\t,\n\t`creditos_solicitud`.`plazo_en_dias`,\n\t`creditos_solicitud`.`fecha_ministracion` AS \n\t`fecha_de_desembolso`,\n\t`creditos_solicitud`.`tasa_interes` AS \n\t`tasa_de_interes`,\n\t`creditos_solicitud`.`pagos_autorizados` AS \n\t`numero_de_pagos`,\n\tIF(`creditos_solicitud`.`periocidad_de_pago` = " . CREDITO_TIPO_PERIOCIDAD_FINAL_DE_PLAZO . ", 0,`creditos_solicitud`.`monto_parcialidad`) AS \n\t`monto_de_amortizacion`,\n\t'?' AS `tipo`,\n\t`creditos_solicitud`.`fecha_de_primer_pago`,\n\t`creditos_periocidadpagos`.`descripcion_periocidadpagos` AS `frecuencia`,\n\t`creditos_solicitud`.`ultimo_periodo_afectado` AS \n\t`ultima_parcialidad` ,\n\tCOUNT(`operaciones_mvtos`.`tipo_operacion`) AS `operaciones`,\n\tMAX(`operaciones_mvtos`.`fecha_afectacion`) AS `fecha`,\n\tSUM(\n\tIF(`operaciones_mvtos`.`tipo_operacion` = 120,\t`operaciones_mvtos`.`afectacion_real`, 0\t)\n\t) AS `abonos`,\n\t(`creditos_solicitud`.`monto_autorizado` - \tSUM(\n\tIF(`operaciones_mvtos`.`tipo_operacion` = 120,\t`operaciones_mvtos`.`afectacion_real`, 0\t)\n\t)) AS 'saldo',\n\t`creditos_solicitud`.`saldo_actual` AS 'saldo_sistema' \nFROM\n\t`creditos_solicitud` `creditos_solicitud` \n\t\tINNER JOIN `creditos_periocidadpagos` `creditos_periocidadpagos` \n\t\tON `creditos_solicitud`.`periocidad_de_pago` = \n\t\t`creditos_periocidadpagos`.`idcreditos_periocidadpagos` \n\t\t\tINNER JOIN `creditos_tipoconvenio` `creditos_tipoconvenio` \n\t\t\tON `creditos_solicitud`.`tipo_convenio` = `creditos_tipoconvenio`.\n\t\t\t`idcreditos_tipoconvenio` \n\t\t\t\tINNER JOIN `socios` `socios` \n\t\t\t\tON `creditos_solicitud`.`numero_socio` = `socios`.`codigo` \n\t\t\t\t\tRIGHT OUTER JOIN `operaciones_mvtos` `operaciones_mvtos` \n\t\t\t\t\tON `operaciones_mvtos`.`docto_afectado` = \n\t\t\t\t\t`creditos_solicitud`.`numero_solicitud`\n\t\t\t\nWHERE\n\t(\n\t(`operaciones_mvtos`.`tipo_operacion` =120) \n\tOR\n\t(`operaciones_mvtos`.`tipo_operacion` =110))\n\tAND\n\t(`operaciones_mvtos`.`fecha_afectacion` <= '{$fechaFinal}') \n\t{$ByProducto} {$BySucursal}\nGROUP BY\n\t`operaciones_mvtos`.`docto_afectado`\n\t\nHAVING saldo > 0\n\nORDER BY `creditos_solicitud`.`fecha_ministracion`\n \n"; //$sql = "CALL sp_saldos_al_cierre('$fechaFinal')"; //exit($sql); $xTbl = new cTabla($sql); $xTbl->setFootSum(array(5 => "monto_original", 17 => "abonos", 18 => "saldo")); /*$xTbl->setFootSum(array( 3 => "monto_autorizado", 52 => "abonos", 53 => "saldo" ));*/ $xRPT->setSQL($xTbl->getSQL()); $xTbl->setTipoSalida($formato); $xRPT->setOut($formato); $xRPT->addContent($xTbl->Show()); //$xRPT->setResponse(); echo $xRPT->render(true);
$DPagos[$credito][] = $dpags; //var_dump($dpags); } if ($out == OUT_CSV) { header("Content-type: text/x-csv"); //header("Content-type: text/csv"); //header("Content-type: application/csv"); header("Content-Disposition: attachment; filename=reporte_buro_de_credito-" . date("Ymd") . ".csv"); } else { if ($out == OUT_EXCEL) { header("Content-type: application/vnd.ms-excel"); header("Content-Disposition: attachment; filename=Buro_de_Credito.xls"); header("Pragma: no-cache"); header("Expires: 0"); $cTbl = new cTabla($sql); $cTbl->setTipoSalida(OUT_EXCEL); $excel = "<html xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:x=\"urn:schemas-microsoft-com:office:excel\" xmlns=\"http://www.w3.org/TR/REC-html40\">"; $excel .= "\r\n<head>\r\n"; $excel .= "<!--[if gte mso 9]>\r\n"; $excel .= "<xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>Buro de Credito</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml>"; $excel .= "\r\n<![endif]-->\r\n"; $excel .= "</head>\r\n"; $excel .= "<body>\r\n"; echo $excel; } else { echo $xHP->getHeader(); echo $xHP->setBodyinit(); } echo "<table>"; } //" AND (`creditos_solicitud`.`saldo_actual` >= " . TOLERANCIA_SALDOS . ") "