diff --git a/admin.php b/admin.php index c1a472e..00aeeea 100644 --- a/admin.php +++ b/admin.php @@ -276,10 +276,10 @@ $notificationConfig = diagnostic_admin_is_authenticated() ? diagnostic_admin_not -
-
+
+
Szczegóły próby #
-

+

Rozpoczęto:

diff --git a/app/diagnostic_functions.php b/app/diagnostic_functions.php index 05da766..7188ce0 100644 --- a/app/diagnostic_functions.php +++ b/app/diagnostic_functions.php @@ -554,7 +554,7 @@ function diagnostic_default_report_copy(array $attempt): array 'strengths' => diagnostic_report_list($strengths), 'priorities' => diagnostic_report_list($priorities), 'next_steps' => diagnostic_report_list($nextSteps), - 'closing' => 'Wróć do podsumowania diagnozy, aby omówić wynik z zespołem lub zaplanować kolejny krok wdrożeniowy.', + 'closing' => '', ]; } @@ -658,9 +658,6 @@ function diagnostic_generate_ai_report_copy(array $attempt): array function diagnostic_build_report_html(array $attempt, array $copy): string { $result = $attempt['result'] ?? []; - $host = $_SERVER['HTTP_HOST'] ?? 'localhost'; - $scheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http'; - $resultUrl = $scheme . '://' . $host . '/diagnostic.php?view=result'; $strengthsHtml = diagnostic_email_list($copy['strengths'] ?? []); $prioritiesHtml = diagnostic_email_list($copy['priorities'] ?? []); @@ -686,12 +683,7 @@ function diagnostic_build_report_html(array $attempt, array $copy): string . '

Priorytety na teraz

' . $prioritiesHtml . '

Rekomendowane kolejne kroki

' - . $nextStepsHtml - . '
' - . '
' . diagnostic_email_escape((string)($copy['closing'] ?? '')) . '
' - . '
W podsumowaniu online zobaczysz pełen wynik i możesz od razu zostawić numer do kontaktu.
' - . 'Otwórz podsumowanie diagnozy' - . '
'; + . $nextStepsHtml; return diagnostic_email_document( (string)($copy['subject'] ?? 'Raport z diagnozy dojrzałości procesowej'), @@ -728,9 +720,35 @@ function diagnostic_build_report_text(array $attempt, array $copy): string foreach (($copy['next_steps'] ?? []) as $item) { $lines[] = '- ' . $item; } - $lines[] = ''; - $lines[] = (string)($copy['closing'] ?? ''); - return diagnostic_report_limit(implode("\n", $lines), 10000); + return diagnostic_report_limit(rtrim(implode("\n", $lines)), 10000); +} + +function diagnostic_strip_legacy_report_cta(array $package): array +{ + $subject = diagnostic_report_limit((string)($package['subject'] ?? ''), 255); + $html = (string)($package['html'] ?? ''); + $text = (string)($package['text'] ?? ''); + + if ($html !== '') { + $html = preg_replace( + '~
.*?Otwórz podsumowanie diagnozy
~su', + '', + $html + ) ?? $html; + } + + if ($text !== '') { + $text = preg_replace('/^.*omówić wynik z zespołem.*$/miu', '', $text) ?? $text; + $text = preg_replace('/ +{3,}/', "\n\n", $text) ?? $text; + $text = trim($text); + } + + return [ + 'subject' => $subject, + 'html' => $html, + 'text' => $text, + ]; } function diagnostic_store_report_content(int $attemptId, array $package): void @@ -754,14 +772,32 @@ function diagnostic_store_report_content(int $attemptId, array $package): void function diagnostic_cached_report_content(array $attempt): ?array { - $subject = diagnostic_report_limit((string)($attempt['report_subject'] ?? ''), 255); - $html = (string)($attempt['report_html'] ?? ''); - $text = (string)($attempt['report_text'] ?? ''); + $package = diagnostic_strip_legacy_report_cta([ + 'subject' => (string)($attempt['report_subject'] ?? ''), + 'html' => (string)($attempt['report_html'] ?? ''), + 'text' => (string)($attempt['report_text'] ?? ''), + ]); + + $subject = $package['subject']; + $html = $package['html']; + $text = $package['text']; if ($subject === '' || $html === '' || $text === '') { return null; } + if (!empty($attempt['id']) && ( + $subject !== (string)($attempt['report_subject'] ?? '') + || $html !== (string)($attempt['report_html'] ?? '') + || $text !== (string)($attempt['report_text'] ?? '') + )) { + diagnostic_store_report_content((int)$attempt['id'], [ + 'subject' => $subject, + 'html' => $html, + 'text' => $text, + ]); + } + return [ 'success' => true, 'subject' => $subject, diff --git a/assets/css/custom.css b/assets/css/custom.css index da9638f..b0aa3bb 100644 --- a/assets/css/custom.css +++ b/assets/css/custom.css @@ -214,6 +214,25 @@ h6 { line-height: 1; } +.attempt-header { + min-width: 0; +} + +.attempt-identity { + flex: 1 1 18rem; + min-width: 0; +} + +.attempt-email { + overflow-wrap: anywhere; + word-break: break-word; +} + +.score-chip { + flex: 0 0 auto; + max-width: 100%; +} + .form-control, .form-check-input, .answer-card,