prepare("UPDATE eventos SET titulo=?, descripcion=?, fecha_inicio=?, fecha_fin=?, hora_inicio=?, hora_fin=? WHERE id=?"); $stmt->execute([$titulo, $descripcion, $fecha_inicio, $fecha_fin, $hora_inicio, $hora_fin, $id]); } else { $stmt = $pdo->prepare("INSERT INTO eventos (titulo, descripcion, fecha_inicio, fecha_fin, hora_inicio, hora_fin) VALUES (?, ?, ?, ?, ?, ?)"); $stmt->execute([$titulo, $descripcion, $fecha_inicio, $fecha_fin, $hora_inicio, $hora_fin]); } header('Location: panel_calendario.php'); exit; } // Eliminar evento if (isset($_GET['eliminar'])) { $id = intval($_GET['eliminar']); $pdo->prepare("DELETE FROM eventos WHERE id=?")->execute([$id]); header('Location: panel_calendario.php'); exit; } // Editar evento (cargar datos en el formulario) $evento_editado = null; if (isset($_GET['editar'])) { $id = intval($_GET['editar']); $stmt = $pdo->prepare("SELECT * FROM eventos WHERE id = ?"); $stmt->execute([$id]); $evento_editado = $stmt->fetch(); } // Obtener todos los eventos $stmt = $pdo->query("SELECT * FROM eventos ORDER BY fecha_inicio DESC, hora_inicio"); $eventos = $stmt->fetchAll(); ?>