Configuración de horario para resumen diario

This commit is contained in:
2025-05-28 08:10:10 -06:00
parent aa793813e8
commit 79c75ef011
3 changed files with 200 additions and 6 deletions

View File

@@ -188,7 +188,7 @@ include __DIR__ . '/../partials/sidebar_configuracion.php';
<!-- Tipos de notificaciones -->
<div id="tipos-notificaciones" class="fade-transition"
<?= !$notificaciones['notificaciones'] ? 'style="display:none; opacity:0;"' : 'style="opacity:1;"' ?>>
<?= !$notificaciones['notificaciones'] ? 'style="display:none; opacity:0;"' : 'style="opacity:1;"' ?>>
<div class="section-divider">
<h6 class="mb-3">📋 Tipos de Notificaciones</h6>
@@ -197,14 +197,50 @@ include __DIR__ . '/../partials/sidebar_configuracion.php';
<div class="col-md-6 mb-3">
<div class="form-check form-switch">
<input class="form-check-input tipo-notificacion" type="checkbox"
name="<?= $clave ?>" id="<?= $clave ?>"
data-tipo="tipo_notificacion" data-nombre="<?= $clave ?>"
<?= ($preferencias[$clave] ?? 0) ? 'checked' : '' ?>>
name="<?= $clave ?>" id="<?= $clave ?>"
data-tipo="tipo_notificacion" data-nombre="<?= $clave ?>"
<?= ($preferencias[$clave] ?? 0) ? 'checked' : '' ?>>
<label class="form-check-label" for="<?= $clave ?>">
<strong><?= ucwords(str_replace('_', ' ', $clave)) ?></strong>
<div class="form-text"><?= htmlspecialchars($descripcion) ?></div>
</label>
</div>
<!-- Configuración específica para resumen diario -->
<?php if ($clave === 'resumen_diario'): ?>
<div id="resumen-diario-config" class="mt-3 ps-4 fade-transition"
style="<?= ($preferencias['resumen_diario'] ?? 0) ? 'display:block; opacity:1;' : 'display:none; opacity:0;' ?>">
<div class="card border-0 bg-light p-3">
<h6 class="mb-3 text-primary">⚙️ Configuración de Horario</h6>
<div class="row">
<div class="col-md-6 mb-2">
<label for="resumen_hora" class="form-label small fw-bold">🕐 Hora de envío</label>
<input type="time" class="form-control form-control-sm"
id="resumen_hora" name="resumen_hora"
value="<?= date('H:i', strtotime($preferencias['resumen_diario_hora'] ?? '08:00:00')) ?>">
</div>
<div class="col-md-6 mb-2">
<label for="resumen_dias" class="form-label small fw-bold">📅 Días de envío</label>
<select class="form-select form-select-sm" id="resumen_dias" name="resumen_dias">
<option value="L-V" <?= ($preferencias['resumen_diario_dias'] ?? 'L-V') === 'L-V' ? 'selected' : '' ?>>
Lunes a Viernes
</option>
<option value="L-S" <?= ($preferencias['resumen_diario_dias'] ?? 'L-V') === 'L-S' ? 'selected' : '' ?>>
Lunes a Sábado
</option>
<option value="TODOS" <?= ($preferencias['resumen_diario_dias'] ?? 'L-V') === 'TODOS' ? 'selected' : '' ?>>
Todos los días
</option>
</select>
</div>
</div>
<div class="form-text mt-2">
<i class="fas fa-info-circle text-info"></i>
Recibirás un resumen con las actividades del día anterior
</div>
</div>
</div>
<?php endif; ?>
</div>
<?php endforeach; ?>
</div>
@@ -465,6 +501,80 @@ include __DIR__ . '/../partials/sidebar_configuracion.php';
return e.returnValue;
}
});
// Event listener específico para el switch de resumen diario
document.getElementById('resumen_diario').addEventListener('change', function() {
const isChecked = this.checked;
const configSection = document.getElementById('resumen-diario-config');
// Mostrar/ocultar configuración de horario con animación
if (isChecked) {
configSection.style.display = 'block';
setTimeout(() => {
configSection.style.opacity = '1';
}, 10);
} else {
configSection.style.opacity = '0';
setTimeout(() => {
configSection.style.display = 'none';
}, 300);
}
});
// Event listeners para los controles de horario
document.getElementById('resumen_hora').addEventListener('change', function() {
const hora = this.value;
const dias = document.getElementById('resumen_dias').value;
// Validar que resumen_diario esté activado
const resumenDiarioCheckbox = document.getElementById('resumen_diario');
if (!resumenDiarioCheckbox.checked) {
showSaveIndicator('error', 'El resumen diario debe estar activado');
return;
}
// Deshabilitar controles temporalmente
const horaInput = this;
const diasSelect = document.getElementById('resumen_dias');
horaInput.disabled = true;
diasSelect.disabled = true;
// Guardar configuración
autoSave('resumen_diario_config', {
hora: hora,
dias: dias
}).finally(() => {
horaInput.disabled = false;
diasSelect.disabled = false;
});
});
document.getElementById('resumen_dias').addEventListener('change', function() {
const hora = document.getElementById('resumen_hora').value;
const dias = this.value;
// Validar que resumen_diario esté activado
const resumenDiarioCheckbox = document.getElementById('resumen_diario');
if (!resumenDiarioCheckbox.checked) {
showSaveIndicator('error', 'El resumen diario debe estar activado');
return;
}
// Deshabilitar controles temporalmente
const horaInput = document.getElementById('resumen_hora');
const diasSelect = this;
horaInput.disabled = true;
diasSelect.disabled = true;
// Guardar configuración
autoSave('resumen_diario_config', {
hora: hora,
dias: dias
}).finally(() => {
horaInput.disabled = false;
diasSelect.disabled = false;
});
});
</script>
</body>