<?php function obtenerArchivos($ruta) { $archivos = []; if (is_dir($ruta)) { foreach (scandir($ruta) as $archivo) { $ext = strtolower(pathinfo($archivo, PATHINFO_EXTENSION)); if ($archivo !== '.' && $archivo !== '..' && in_array($ext, ['pdf', 'docx', 'doc', 'xls', 'xlsx'])) { $archivos[] = [ 'nombre' => ucwords(str_replace(['-', '_'], ' ', pathinfo($archivo, PATHINFO_FILENAME))), 'ruta' => "$ruta/$archivo" ]; } } } return $archivos; } function generarPestanasPorAnio($basePath, $inicio, $fin) { echo "<div class='tabs'>"; for ($anio = $inicio; $anio <= $fin; $anio++) { $active = $anio === $inicio ? 'active' : ''; echo "<button class='tab-btn $active' data-tab='anio-$anio'>$anio</button>"; } echo "</div>"; for ($anio = $inicio; $anio <= $fin; $anio++) { $active = $anio === $inicio ? 'active' : ''; echo "<div class='tab-content $active' id='anio-$anio'> <table> <thead><tr><th>Documento</th><th>Enlace</th></tr></thead><tbody>"; $archivos = obtenerArchivos("$basePath/$anio"); if (count($archivos) === 0) { echo "<tr><td colspan='2'>No hay documentos disponibles.</td></tr>"; } else { foreach ($archivos as $archivo) { echo "<tr><td>" . htmlspecialchars($archivo['nombre']) . "</td><td><a href='" . $archivo['ruta'] . "' target='_blank'>Ver documento</a></td></tr>"; } } echo "</tbody></table></div>"; } } ?> <!DOCTYPE html> <html lang="es"> <head> <meta charset="UTF-8"> <title>Fracción V - Inciso i)</title> <link rel="stylesheet" href="../menu.css" /> <style> @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap'); body { font-family: 'Poppins', sans-serif; margin: 0; padding: 0; } main { padding: 90px 20px 40px; max-width: 1200px; margin: 0 auto; } h1, h2 { color: #2b3e5c; } .tabs { margin-bottom: 10px; } .tab-btn { padding: 10px 20px; margin: 5px 5px 0 0; border: none; background-color: #e0e0e0; cursor: pointer; } .tab-btn.active { background-color: #2b3e5c; color: white; font-weight: bold; } .tab-content { display: none; } .tab-content.active { display: block; } table { width: 100%; border-collapse: collapse; margin: 20px 0; } th, td { border: 1px solid #ccc; padding: 10px; text-align: left; } th { background-color: #f0f0f0; } tr:hover { background-color: #f9f9f9; } a { color: #0066cc; text-decoration: none; } a:hover { text-decoration: underline; } </style> </head> <body> <?php include("../menu.php"); ?> <main> <h1>Fracción V - Información financiera, patrimonial y administrativa</h1> <h2>Inciso i) Los estados financieros mensuales</h2> <?php generarPestanasPorAnio("../Transparencia/Fraccion5/i", 2014, 2027); ?> <h2>Histórico</h2> <table> <thead><tr><th>Documento</th><th>Enlace</th></tr></thead> <tbody> <?php $archivosHistorico = obtenerArchivos("../Transparencia/Fraccion5/i/Historico"); if (count($archivosHistorico) === 0) { echo "<tr><td colspan='2'>No hay documentos disponibles en el histórico.</td></tr>"; } else { foreach ($archivosHistorico as $archivo) { echo "<tr><td>" . htmlspecialchars($archivo['nombre']) . "</td><td><a href='" . $archivo['ruta'] . "' target='_blank'>Ver documento</a></td></tr>"; } } ?> </tbody> </table> </main> <script> const tabs = document.querySelectorAll('.tab-btn'); const contents = document.querySelectorAll('.tab-content'); tabs.forEach(btn => { btn.addEventListener('click', () => { const tabGroup = btn.dataset.tab.split('-')[1]; document.querySelectorAll('.tab-btn').forEach(el => el.classList.remove('active')); document.querySelectorAll('.tab-content').forEach(el => el.classList.remove('active')); btn.classList.add('active'); document.getElementById(btn.dataset.tab).classList.add('active'); }); }); </script> </body> </html>