diff --git a/admin.php b/admin.php index e98cf45..c1a472e 100644 --- a/admin.php +++ b/admin.php @@ -22,6 +22,51 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { header('Location: /admin.php'); exit; } + if ($action === 'save-notification-email') { + if (!diagnostic_admin_is_authenticated()) { + diagnostic_flash_set('warning', 'Zaloguj się jako administrator, aby zmienić adres powiadomień.'); + header('Location: /admin.php'); + exit; + } + + $notificationEmail = trim((string)($_POST['notification_email'] ?? '')); + if (!filter_var($notificationEmail, FILTER_VALIDATE_EMAIL)) { + diagnostic_flash_set('danger', 'Podaj poprawny adres e-mail administratora do powiadomień o nowych prośbach o kontakt.'); + header('Location: /admin.php'); + exit; + } + + diagnostic_admin_setting_set('admin_notification_email', $notificationEmail); + diagnostic_flash_set('success', 'Adres e-mail administratora do powiadomień został zapisany.'); + header('Location: /admin.php'); + exit; + } + if ($action === 'resend-report') { + if (!diagnostic_admin_is_authenticated()) { + diagnostic_flash_set('warning', 'Zaloguj się jako administrator, aby ponownie wysłać raport.'); + header('Location: /admin.php'); + exit; + } + + $attemptId = (int)($_POST['attempt_id'] ?? 0); + if ($attemptId <= 0) { + diagnostic_flash_set('danger', 'Nie udało się ustalić, dla której próby należy ponownie wysłać raport.'); + header('Location: /admin.php'); + exit; + } + + $result = diagnostic_admin_resend_report($attemptId); + if (!empty($result['success'])) { + $attempt = diagnostic_get_attempt($attemptId); + $recipient = $attempt['email'] ?? ''; + diagnostic_flash_set('success', 'Raport został wysłany ponownie do klienta' . ($recipient !== '' ? ' (' . $recipient . ')' : '') . '.'); + } else { + diagnostic_flash_set('danger', 'Nie udało się ponownie wysłać raportu: ' . (string)($result['error'] ?? 'Nieznany błąd.')); + } + + header('Location: /admin.php?attempt=' . $attemptId); + exit; + } } if (diagnostic_admin_is_authenticated() && ($_GET['export'] ?? '') === 'csv') { @@ -45,6 +90,7 @@ if (!$selectedAttempt && !empty($attempts)) { } $questionMap = diagnostic_question_map(); $credentials = diagnostic_admin_credentials(); +$notificationConfig = diagnostic_admin_is_authenticated() ? diagnostic_admin_notification_config() : ['configured_email' => '', 'fallback_email' => '', 'effective_email' => '', 'source' => 'none']; ?> @@ -137,6 +183,41 @@ $credentials = diagnostic_admin_credentials();
Gdy użytkownik poda numer telefonu po ukończeniu diagnozy, system wyśle powiadomienie e-mail właśnie na ten adres.
+ +MAIL_TO. Ustaw adres w panelu, aby zarządzać nim bez edycji środowiska.
+
+ Brak ustawionego adresu do powiadomień.
+ Do czasu zapisania adresu w panelu e-mail o nowej prośbie o kontakt nie zostanie wysłany.
+
+ | ' + . '' + . ' |
| ' . diagnostic_email_escape((string)$label) . ' | ' + . '' . diagnostic_email_escape((string)$value) . ' | ' + . '
Brak danych o priorytetowych obszarach do pokazania w tym raporcie.
'; } $recommendations = ''; foreach (($result['recommendations'] ?? []) as $item) { - $recommendations .= 'Dziękujemy za wypełnienie diagnozy. Obecny poziom dojrzałości operacyjnej Twojej firmy to ' . htmlspecialchars($result['segment_label'] ?? 'Diagnoza zakończona') . ' (' . (int)($result['percentage_score'] ?? 0) . '%).
' - . '' . htmlspecialchars($result['segment_summary'] ?? '') . '
' - . 'Jeśli chcesz omówić wynik i ustalić priorytety zmian, wróć do podsumowania: ' . htmlspecialchars($resultUrl) . '.
' + $content = 'Dziękujemy za wypełnienie diagnozy. Obecny poziom dojrzałości operacyjnej Twojej firmy to ' . diagnostic_email_escape($result['segment_label'] ?? 'Diagnoza zakończona') . '.
' + . '| '
+ . ' Wynik łączny '
+ . '' . (int)($result['percentage_score'] ?? 0) . '% '
+ . '' . diagnostic_email_escape($result['segment_summary'] ?? '') . ' '
+ . ' | '
+ . '
Użytkownik zakończył diagnozę i poprosił o dalszą konsultację.
' + . '