107 lines
4.5 KiB
PHP
107 lines
4.5 KiB
PHP
<?php
|
|
$adminSection = 'qrs';
|
|
$pageTitle = 'Códigos QR';
|
|
$pageHeading = 'Códigos QR';
|
|
|
|
$outputDir = dirname(__DIR__) . '/output';
|
|
$qrCount = 0;
|
|
$sampleFile = null;
|
|
|
|
if (is_dir($outputDir)) {
|
|
$files = array_values(array_filter(scandir($outputDir), fn($f) => str_ends_with($f, '.png')));
|
|
$qrCount = count($files);
|
|
if ($qrCount > 0) {
|
|
sort($files);
|
|
$sampleFile = $files[0];
|
|
}
|
|
}
|
|
|
|
$topbarActions = '
|
|
<a href="export_qr.php" class="btn btn-outline-primary btn-sm me-2">
|
|
<span class="material-symbols-outlined align-middle" style="font-size:18px">download</span> Exportar CSV
|
|
</a>
|
|
<form method="post" action="generate_qrs.php" class="d-inline" onsubmit="return confirm(\'¿Generar todos los QR? Puede tardar varios minutos.\');">
|
|
<button type="submit" class="btn btn-primary btn-sm">
|
|
<span class="material-symbols-outlined align-middle" style="font-size:18px">qr_code_2</span> Generar QR
|
|
</button>
|
|
</form>
|
|
';
|
|
|
|
require_once __DIR__ . '/../includes/admin_header.php';
|
|
require_once __DIR__ . '/../config/database.php';
|
|
|
|
$db = getDB();
|
|
$totalUbicaciones = (int) $db->query('SELECT COUNT(*) FROM ubicaciones WHERE activo = 1')->fetchColumn();
|
|
$qrDataExists = file_exists(dirname(__DIR__) . '/qr_data.csv');
|
|
$logoExists = file_exists(dirname(__DIR__) . '/NEM.png');
|
|
$flash = getFlash();
|
|
?>
|
|
|
|
<?php if ($flash): ?>
|
|
<div class="alert alert-<?= h($flash['type']) ?> alert-dismissible fade show">
|
|
<?= h($flash['message']) ?>
|
|
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<div class="row g-4">
|
|
<div class="col-lg-5">
|
|
<div class="card h-100">
|
|
<div class="card-header">Vista previa</div>
|
|
<div class="card-body">
|
|
<div class="qr-preview-box">
|
|
<?php if ($sampleFile): ?>
|
|
<img src="<?= h(BASE_URL) ?>/output/<?= h(rawurlencode($sampleFile)) ?>" alt="QR ejemplo">
|
|
<p class="text-muted small mt-3 mb-0"><?= h($sampleFile) ?></p>
|
|
<?php else: ?>
|
|
<span class="material-symbols-outlined text-muted" style="font-size:64px">qr_code_2</span>
|
|
<p class="text-muted mt-3">Aún no hay QR generados.<br>Use el botón <strong>Generar QR</strong>.</p>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-lg-7">
|
|
<div class="card mb-4">
|
|
<div class="card-header">Estado</div>
|
|
<ul class="list-group list-group-flush">
|
|
<li class="list-group-item d-flex justify-content-between">
|
|
<span>Ubicaciones activas</span>
|
|
<strong><?= number_format($totalUbicaciones) ?></strong>
|
|
</li>
|
|
<li class="list-group-item d-flex justify-content-between">
|
|
<span>QR en carpeta output/</span>
|
|
<strong class="<?= $qrCount >= $totalUbicaciones ? 'text-success' : 'text-warning' ?>"><?= number_format($qrCount) ?></strong>
|
|
</li>
|
|
<li class="list-group-item d-flex justify-content-between">
|
|
<span>Archivo qr_data.csv</span>
|
|
<?= $qrDataExists ? '<span class="badge bg-success">Listo</span>' : '<span class="badge bg-danger">Falta</span>' ?>
|
|
</li>
|
|
<li class="list-group-item d-flex justify-content-between">
|
|
<span>Logo NEM.png</span>
|
|
<?= $logoExists ? '<span class="badge bg-success">Presente</span>' : '<span class="badge bg-warning">No encontrado</span>' ?>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="card-header">Formato de impresión</div>
|
|
<div class="card-body">
|
|
<p class="mb-2">Los QR mantienen el mismo estilo que los anteriores:</p>
|
|
<ul class="mb-3">
|
|
<li>Color azul campamento <code>#132A7C</code></li>
|
|
<li>Logo <strong>NEM.png</strong> centrado en el código</li>
|
|
<li>Pie de imagen: <em>Módulo | Habitación</em></li>
|
|
<li>URL interna: <code>formulario.php?u=UB-XXXXX</code></li>
|
|
</ul>
|
|
<p class="text-muted small mb-0">
|
|
También puede generar desde terminal:
|
|
<code>python3 generate_qrs.py</code>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php require_once __DIR__ . '/../includes/admin_footer.php'; ?>
|