setFlashdata('success', 'Pedido apagado — fica na lixeira 30 dias.') : session()->setFlashdata('error', 'Pedido não encontrado neste ginásio.'); } elseif (isset($_POST['save'])) { $id = (int) $_POST['save']; db_trial_lead_update($pdo, $id, $gymId, (string) ($_POST['status'][$id] ?? ''), trim((string) ($_POST['notes'][$id] ?? ''))); session()->setFlashdata('success', 'Pedido atualizado.'); } header('Location: ' . $self); exit; } $leads = db_trial_leads_list($pdo, $gymId, $filter); // CSV do filtro atual (Excel: BOM UTF-8 + ';'). Dados pessoais — fica no audit. if (isset($_GET['csv'])) { audit('export.trial_leads', [ 'target_type' => 'trial_lead', 'target_label' => 'CSV (' . count($leads) . ' registos)', 'summary' => 'Exportação CSV de pedidos de aula experimental' . ($filter !== '' ? ' — estado: ' . $filter : ''), ]); header('Content-Type: text/csv; charset=utf-8'); header('Content-Disposition: attachment; filename="aulas-experimentais-' . date('Y-m-d') . '.csv"'); $out = fopen('php://output', 'w'); fwrite($out, "\xEF\xBB\xBF"); fputcsv($out, ['Data do pedido', 'Nome', 'Telemóvel', 'E-mail', 'Dia preferido', 'Período', 'Mensagem', 'Estado', 'Notas', 'Consentimento'], ';', '"', ''); foreach ($leads as $l) { fputcsv($out, [ date('d/m/Y H:i', strtotime($l['created_at'])), $l['name'], $l['phone'], $l['email'], $l['preferred_date'] ? date('d/m/Y', strtotime($l['preferred_date'])) : '', $l['period'], (string) $l['message'], $statuses[$l['status']] ?? $l['status'], (string) $l['admin_notes'], $l['consent'] ? 'sim' : 'não', ], ';', '"', ''); } exit; } $badge = ['novo' => 'bg-danger', 'contactado' => 'bg-info text-dark', 'marcado' => 'bg-success', 'descartado' => 'bg-secondary']; $page_title = 'Aulas experimentais'; include __DIR__ . '/../../../includes/header.php'; ?>
Pedidos feitos no botão «Marca a tua aula experimental». Ficam guardados aqui mesmo que o email de aviso não chegue.