File "sigas.php"
Full Path: C:/wamp64/www/Formaciones/Vistas/admin/sigas.php
File size: 12.24 KB
MIME-type: text/x-php
Charset: utf-8
<?php
// Vistas/admin/Sigas.php
require_once 'Vistas/plantilla/encabezado.php';
if (!function_exists('formatBytes')) {
function formatBytes($bytes, $precision = 2) {
if ($bytes <= 0) return '0 B';
$units = array('B', 'KB', 'MB', 'GB');
$bytes = max($bytes, 0);
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
$pow = min($pow, count($units) - 1);
$bytes /= pow(1024, $pow);
return round($bytes, $precision) . ' ' . $units[$pow];
}
}
if (!function_exists('h')) {
function h($string) {
return htmlspecialchars($string ?? '', ENT_QUOTES, 'UTF-8');
}
}
?>
<!-- AGREGAR SELECT2 CDN -->
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
<div class="dashboard-container">
<div style="margin-bottom: 25px;">
<h1 style="margin: 0; text-shadow: 0 2px 10px rgba(0,0,0,0.2);">
📢 Administracion de Sigas
</h1>
</div>
<?php if(isset($_SESSION['exito'])): ?>
<div style="background: #2ecc71; color: white; padding: 15px; border-radius: 8px; margin-bottom: 20px;">
<?= $_SESSION['exito']; unset($_SESSION['exito']); ?>
</div>
<?php endif; ?>
<?php if(isset($_SESSION['error'])): ?>
<div style="background: #e74c3c; color: white; padding: 15px; border-radius: 8px; margin-bottom: 20px;">
<?= $_SESSION['error']; unset($_SESSION['error']); ?>
</div>
<?php endif; ?>
<div style="display: grid; grid-template-columns: 350px 1fr; gap: 25px; align-items: start;">
<aside class="card" style="position: sticky; top: 20px;">
<h3 style="margin-top: 0; color: var(--accent-1); border-bottom: 2px solid #eee; padding-bottom: 10px;">
🆕 Registrar Sigas
</h3>
<form action="index.php?r=admin/Sigas/guardar" method="POST" enctype="multipart/form-data" style="margin-top: 20px;">
<div class="form-group">
<label>Area</label>
<select name="area" id="select_area" required class="select2" style="width: 100%;">
<option value="">Seleccione una area...</option>
<?php while($a = $areas->fetch_assoc()): ?>
<option value="<?= h($a['area']) ?>">
<?= h($a['area']) ?>
</option>
<?php endwhile; ?>
</select>
</div>
<div class="form-group">
<label>Fecha Inicial</label>
<input type="date" name="fecha_Inicial" required value="<?= date('Y-m-d') ?>">
</div>
<div class="form-group">
<label>Fecha Final</label>
<input type="date" name="fecha_Final" required value="<?= date('Y-m-d') ?>">
</div>
<div class="form-group">
<label>Responsable</label>
<input type="text" name="Responsable" required placeholder="Nombre del Responsable">
</div>
<div class="form-group">
<label>Cedula</label>
<input type="text" name="Cedula" required placeholder="Cedula del Responsable">
</div>
<div class="form-group">
<label>Cargo</label>
<input type="text" name="Cargo" required placeholder="Cargo del Responsable">
</div>
<div class="form-group">
<label>Temas</label>
<textarea name="Temas" id="Temas" rows="3" style="width:100%; border-radius:10px; border:1px solid #ddd; padding:10px;"></textarea>
</div>
<div class="form-group">
<label>Evidencia (PDF máx 10MB)</label>
<input type="file" name="evidencia" id="evidencia" accept=".pdf" required>
</div>
<button type="submit" class="btn-primary" style="width: 100%; margin-top: 10px; padding: 12px; background: #f37021; border: none; font-weight: bold;">
💾 Guardar Registro
</button>
</form>
</aside>
<main>
<div class="card" style="margin-bottom: 20px;">
<form action="index.php" method="GET" style="display: flex; gap: 10px;">
<input type="hidden" name="r" value="admin/Sigas">
<input type="text" name="busqueda" value="<?= h($busqueda) ?>"
placeholder="Buscar por Area o responsable..."
style="flex: 1; padding: 12px; border: 1px solid #ddd; border-radius: 8px;">
<button type="submit" class="btn-primary" style="background: #2c3e50;">Buscar 🔍</button>
<?php if(!empty($busqueda)): ?>
<a href="index.php?r=admin/Sigas" class="btn-primary" style="background: #95a5a6; text-decoration: none; display: flex; align-items: center;">Limpiar</a>
<?php endif; ?>
</form>
</div>
<div class="card" style="padding: 0; overflow: hidden;">
<div class="table-responsive">
<table class="table">
<thead>
<tr style="background: #f8f9fa;">
<th>Area</th>
<th>Responsable</th>
<th>Fecha Inicio</th>
<th>Fecha Final</th>
<th>Temas</th>
<th>Archivo</th>
<th>Acciones</th>
</tr>
</thead>
<tbody>
<?php if(isset($Sigases) && $Sigases->num_rows > 0): ?>
<?php while($row = $Sigases->fetch_assoc()): ?>
<tr>
<td><strong><?= h($row['nombre_sigas']) ?></strong></td>
<td>
<?= h($row['capacitador'] ?? 'N/A') ?><br>
<small style="color: #7f8c8d;"><?= h($row['cedula_usuario']) ?></small>
</td>
<td><?= date('d/m/Y', strtotime($row['fecha_Inicial'])) ?></td>
<td><?= date('d/m/Y', strtotime($row['fecha_Final'])) ?></td>
<td><small><?= h($row['temas']) ?></small></td>
<td>
<?php if(!empty($row['evidencia_datos'])): ?>
<span style="color: #27ae60;"> PDF Cargado</span>
<?php else: ?>
<span style="color: #e74c3c;"> Sin archivo</span>
<?php endif; ?>
</td>
<td>
<div style="display: flex; gap: 5px;">
<a href="index.php?r=admin/Sigas/ver-pdf&id=<?= $row['id'] ?>"
target="_blank" class="btn-primary"
style="padding: 5px 10px; background: #e67e22; text-decoration: none; font-size: 0.8rem;" title="Ver PDF">
👁️
</a>
<a href="index.php?r=admin/Sigas/descargar&id=<?= $row['id'] ?>"
class="btn-primary"
style="padding: 5px 10px; background: #27ae60; text-decoration: none; font-size: 0.8rem;" title="Descargar">
📥
</a>
<a href="index.php?r=admin/Sigas/borrar&id=<?= $row['id'] ?>"
class="btn-danger"
style="padding: 5px 10px; text-decoration: none; font-size: 0.8rem;"
onclick="return confirm('¿Estás seguro de eliminar este registro?')" title="Eliminar">
🗑️
</a>
</div>
</td>
</tr>
<?php endwhile; ?>
<?php else: ?>
<tr>
<td colspan="7" style="text-align: center; padding: 40px; color: #95a5a6;">
No se encontraron registros en el módulo SIGAS.
</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
<?php if (isset($total_paginas) && $total_paginas > 1): ?>
<div style="display: flex; justify-content: center; gap: 8px; padding: 20px; background: #fcfcfc; border-top: 1px solid #eee;">
<?php
$url_base = "index.php?r=admin/Sigas" . (!empty($busqueda) ? "&busqueda=" . urlencode($busqueda) : "");
?>
<?php if ($pagina_actual > 1): ?>
<a href="<?= $url_base ?>&p=<?= $pagina_actual - 1 ?>" class="btn-page">«</a>
<?php endif; ?>
<?php for ($i = 1; $i <= $total_paginas; $i++): ?>
<a href="<?= $url_base ?>&p=<?= $i ?>"
class="btn-page <?= $i == $pagina_actual ? 'active' : '' ?>">
<?= $i ?>
</a>
<?php endfor; ?>
<?php if ($pagina_actual < $total_paginas): ?>
<a href="<?= $url_base ?>&p=<?= $pagina_actual + 1 ?>" class="btn-page">»</a>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
</main>
</div>
</div>
<style>
.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; font-weight: bold; color: #34495e; font-size: 0.9rem; }
.form-group input, .form-group select { width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 6px; }
.btn-page {
padding: 6px 12px;
border: 1px solid #ddd;
border-radius: 4px;
text-decoration: none;
color: #333;
background: white;
font-size: 0.9rem;
}
.btn-page.active {
background: #f37021;
color: white;
border-color: #f37021;
}
.btn-page:hover:not(.active) { background: #f8f9fa; }
.table th { font-size: 0.85rem; text-transform: uppercase; color: #7f8c8d; letter-spacing: 0.5px; }
.card { background: white; padding: 20px; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,0.08); }
/* Estilos personalizados para Select2 */
.select2-container--default .select2-selection--single {
height: 42px !important;
border: 1px solid #ddd !important;
border-radius: 6px !important;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
line-height: 40px !important;
padding-left: 10px !important;
color: #34495e;
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
height: 40px !important;
}
.select2-dropdown {
border: 1px solid #ddd !important;
border-radius: 6px !important;
}
.select2-search--dropdown .select2-search__field {
border: 1px solid #ddd !important;
border-radius: 4px !important;
padding: 8px !important;
}
.select2-results__option--highlighted {
background-color: #f37021 !important;
}
</style>
<script>
$(document).ready(function() {
// Inicializar Select2 con busqueda
$('#select_area').select2({
placeholder: "Seleccione un Area...",
allowClear: true,
language: {
noResults: function() {
return "No se encontraron resultados";
},
searching: function() {
return "Buscando...";
}
}
});
});
</script>
<?php require_once 'Vistas/plantilla/pie.php'; ?>