Cambiar nombres de archivos PDF/CSV de reportes a español
This commit is contained in:
@@ -333,7 +333,20 @@ switch ($page) {
|
||||
$html = ob_get_clean();
|
||||
|
||||
$pdf->writeHTML($html, true, false, true, false, '');
|
||||
$pdf->Output('reporte_pagos_' . $year . '.pdf', 'D');
|
||||
|
||||
$monthCount = count($months);
|
||||
$allMonths = ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'];
|
||||
|
||||
if ($monthCount == 12) {
|
||||
$filename = 'Pagos_IBIZA_' . $year . '.pdf';
|
||||
} elseif ($monthCount == 1) {
|
||||
$filename = 'Pagos_IBIZA_' . $months[0] . '_' . $year . '.pdf';
|
||||
} else {
|
||||
$monthNames = implode('_', $months);
|
||||
$filename = 'Pagos_IBIZA_' . $monthNames . '_' . $year . '.pdf';
|
||||
}
|
||||
|
||||
$pdf->Output($filename, 'D');
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -630,7 +643,16 @@ switch ($page) {
|
||||
// Lógica para exportar PDF
|
||||
$reportType = $_GET['type'] ?? 'general';
|
||||
$year = $_GET['year'] ?? date('Y');
|
||||
|
||||
|
||||
// Mapeo de tipos de reporte a nombres en español
|
||||
$reportNames = [
|
||||
'balance' => 'Balance_General',
|
||||
'expenses' => 'Gastos_por_Categoria',
|
||||
'water-debtors' => 'Deudores_de_Agua',
|
||||
'concept-debtors' => 'Deudores_de_Conceptos'
|
||||
];
|
||||
$reportName = $reportNames[$reportType] ?? ucfirst($reportType);
|
||||
|
||||
// Incluir TCPDF
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
require_once __DIR__ . '/vendor/tecnickcom/tcpdf/tcpdf.php';
|
||||
@@ -638,9 +660,9 @@ switch ($page) {
|
||||
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
|
||||
$pdf->SetCreator(PDF_CREATOR);
|
||||
$pdf->SetAuthor('Ibiza Condominium');
|
||||
$pdf->SetTitle("Condominio IBIZA-Cto Sierra Morena 152 - Reporte de " . ucfirst($reportType) . " " . $year);
|
||||
$pdf->SetSubject("Reporte de " . ucfirst($reportType));
|
||||
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, 'Condominio IBIZA-Cto Sierra Morena 152 - Reporte de ' . ucfirst($reportType) . ' ' . $year, 'Generado el ' . date('d/m/Y H:i'));
|
||||
$pdf->SetTitle("Condominio IBIZA-Cto Sierra Morena 152 - " . $reportName . " " . $year);
|
||||
$pdf->SetSubject($reportName);
|
||||
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, 'Condominio IBIZA-Cto Sierra Morena 152 - ' . $reportName . ' ' . $year, 'Generado el ' . date('d/m/Y H:i'));
|
||||
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
|
||||
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
|
||||
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
|
||||
@@ -697,13 +719,13 @@ switch ($page) {
|
||||
}
|
||||
$html = ob_get_clean();
|
||||
$pdf->writeHTML($html, true, false, true, false, '');
|
||||
$pdf->Output('reporte_' . $reportType . '_' . $year . '.pdf', 'D');
|
||||
$pdf->Output($reportName . '_IBIZA_' . $year . '.pdf', 'D');
|
||||
exit;
|
||||
|
||||
case 'export_csv_balance':
|
||||
// Lógica para exportar CSV de balance
|
||||
header('Content-Type: text/csv');
|
||||
header('Content-Disposition: attachment; filename="Condominio IBIZA-Cto Sierra Morena 152 - balance_general_' . date('Y') . '.csv"');
|
||||
header('Content-Disposition: attachment; filename="Balance_General_IBIZA_' . date('Y') . '.csv"');
|
||||
fputs(fopen('php://output', 'w'), $bom = (chr(0xEF) . chr(0xBB) . chr(0xBF))); // BOM for UTF-8 in Excel
|
||||
|
||||
// Requerimos el modelo Report
|
||||
@@ -726,7 +748,7 @@ switch ($page) {
|
||||
case 'export_csv_expenses':
|
||||
// Lógica para exportar CSV de gastos
|
||||
header('Content-Type: text/csv');
|
||||
header('Content-Disposition: attachment; filename="Condominio IBIZA-Cto Sierra Morena 152 - gastos_' . date('Y') . '.csv"');
|
||||
header('Content-Disposition: attachment; filename="Gastos_por_Categoria_IBIZA_' . date('Y') . '.csv"');
|
||||
fputs(fopen('php://output', 'w'), $bom = (chr(0xEF) . chr(0xBB) . chr(0xBF))); // BOM for UTF-8 in Excel
|
||||
|
||||
// Requerimos el modelo Expense
|
||||
|
||||
Reference in New Issue
Block a user