Poprawki w mailu - dodanie AI
This commit is contained in:
parent
33e26aa4f9
commit
829053bf46
@ -789,6 +789,29 @@ function diagnostic_generate_ai_report_copy(array $attempt): array
|
||||
];
|
||||
}
|
||||
|
||||
function diagnostic_build_report_result_overview_html(string $overview): string
|
||||
{
|
||||
$overview = diagnostic_report_limit(trim($overview), 1000);
|
||||
if ($overview === '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
return '<div style="margin:0 0 24px;padding:20px 22px;border-radius:18px;background:linear-gradient(135deg,#eff6ff 0%,#f8fbff 100%);border:1px solid #bfdbfe;">'
|
||||
. '<div style="font-size:12px;letter-spacing:0.08em;text-transform:uppercase;color:#2563eb;margin-bottom:8px;">Co ten wynik mówi o Twojej organizacji</div>'
|
||||
. '<div style="font-size:15px;line-height:1.75;color:#1f2937;">' . diagnostic_email_escape($overview) . '</div>'
|
||||
. '</div>';
|
||||
}
|
||||
|
||||
function diagnostic_build_report_result_overview_text(string $overview): string
|
||||
{
|
||||
$overview = diagnostic_report_limit(trim($overview), 1000);
|
||||
if ($overview === '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
return "Co ten wynik mówi o Twojej organizacji:\n" . $overview;
|
||||
}
|
||||
|
||||
function diagnostic_build_report_html(array $attempt, array $copy): string
|
||||
{
|
||||
$result = $attempt['result'] ?? [];
|
||||
@ -796,6 +819,7 @@ function diagnostic_build_report_html(array $attempt, array $copy): string
|
||||
$strengthsHtml = diagnostic_email_list($copy['strengths'] ?? []);
|
||||
$prioritiesHtml = diagnostic_email_list($copy['priorities'] ?? []);
|
||||
$nextStepsHtml = diagnostic_email_list($copy['next_steps'] ?? []);
|
||||
$resultOverviewHtml = diagnostic_build_report_result_overview_html((string)($copy['result_overview'] ?? ''));
|
||||
|
||||
$content = '<p style="margin:0 0 18px;font-size:16px;line-height:1.7;color:#374151;">' . diagnostic_email_escape((string)($copy['intro'] ?? '')) . '</p>'
|
||||
. '<table role="presentation" width="100%" cellspacing="0" cellpadding="0" style="width:100%;border-collapse:collapse;margin:0 0 24px;">'
|
||||
@ -808,6 +832,7 @@ function diagnostic_build_report_html(array $attempt, array $copy): string
|
||||
. '</td>'
|
||||
. '</tr>'
|
||||
. '</table>'
|
||||
. $resultOverviewHtml
|
||||
. '<div style="margin:0 0 24px;padding:18px 20px;border:1px solid #e5e7eb;border-radius:16px;background:#ffffff;">'
|
||||
. '<div style="font-size:12px;letter-spacing:0.08em;text-transform:uppercase;color:#6b7280;margin-bottom:8px;">Co ten wynik oznacza</div>'
|
||||
. '<div style="font-size:15px;line-height:1.7;color:#374151;">' . diagnostic_email_escape((string)($copy['what_it_means'] ?? '')) . '</div>'
|
||||
@ -829,6 +854,7 @@ function diagnostic_build_report_html(array $attempt, array $copy): string
|
||||
function diagnostic_build_report_text(array $attempt, array $copy): string
|
||||
{
|
||||
$result = $attempt['result'] ?? [];
|
||||
$resultOverviewText = diagnostic_build_report_result_overview_text((string)($copy['result_overview'] ?? ''));
|
||||
$lines = [];
|
||||
$lines[] = 'DoktorBiznes.pl';
|
||||
$lines[] = diagnostic_brand_home_url();
|
||||
@ -839,6 +865,10 @@ function diagnostic_build_report_text(array $attempt, array $copy): string
|
||||
$lines[] = (string)($copy['intro'] ?? '');
|
||||
$lines[] = '';
|
||||
$lines[] = (string)($copy['executive_summary'] ?? '');
|
||||
if ($resultOverviewText !== '') {
|
||||
$lines[] = '';
|
||||
$lines[] = $resultOverviewText;
|
||||
}
|
||||
$lines[] = '';
|
||||
$lines[] = 'Co ten wynik oznacza:';
|
||||
$lines[] = (string)($copy['what_it_means'] ?? '');
|
||||
@ -979,11 +1009,37 @@ function diagnostic_cached_report_content(array $attempt): ?array
|
||||
$subject = $package['subject'];
|
||||
$html = $package['html'];
|
||||
$text = $package['text'];
|
||||
$resultOverview = diagnostic_report_limit((string)($attempt['ai_summary_text'] ?? ''), 1000);
|
||||
|
||||
if ($subject === '' || $html === '' || $text === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($resultOverview === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
$overviewHtml = diagnostic_build_report_result_overview_html($resultOverview);
|
||||
$overviewText = diagnostic_build_report_result_overview_text($resultOverview);
|
||||
|
||||
if ($overviewHtml !== '' && strpos($html, 'Co ten wynik mówi o Twojej organizacji') === false) {
|
||||
$needle = '<div style="margin:0 0 24px;padding:18px 20px;border:1px solid #e5e7eb;border-radius:16px;background:#ffffff;">';
|
||||
if (strpos($html, $needle) !== false) {
|
||||
$html = str_replace($needle, $overviewHtml . $needle, $html);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if ($overviewText !== '' && strpos($text, 'Co ten wynik mówi o Twojej organizacji:') === false) {
|
||||
$needle = "\n\nCo ten wynik oznacza:\n";
|
||||
if (strpos($text, $needle) !== false) {
|
||||
$text = str_replace($needle, "\n\n" . $overviewText . $needle, $text);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($attempt['id']) && (
|
||||
$subject !== (string)($attempt['report_subject'] ?? '')
|
||||
|| $html !== (string)($attempt['report_html'] ?? '')
|
||||
@ -993,6 +1049,7 @@ function diagnostic_cached_report_content(array $attempt): ?array
|
||||
'subject' => $subject,
|
||||
'html' => $html,
|
||||
'text' => $text,
|
||||
'result_overview' => $resultOverview,
|
||||
]);
|
||||
}
|
||||
|
||||
@ -1001,7 +1058,7 @@ function diagnostic_cached_report_content(array $attempt): ?array
|
||||
'subject' => $subject,
|
||||
'html' => $html,
|
||||
'text' => $text,
|
||||
'result_overview' => diagnostic_report_limit((string)($attempt['ai_summary_text'] ?? ''), 1000),
|
||||
'result_overview' => $resultOverview,
|
||||
'source' => 'cache',
|
||||
];
|
||||
}
|
||||
|
||||
@ -335,7 +335,6 @@ $resultOverview = ($view === 'result' && $attempt && ($attempt['status'] ?? '')
|
||||
|
||||
<?php if ($resultOverview !== ''): ?>
|
||||
<section class="surface-card p-4 p-lg-5 mb-4">
|
||||
<div class="eyebrow mb-3">Opis wygenerowany przez AI</div>
|
||||
<h2 class="section-title mb-3">Co ten wynik mówi o Twojej organizacji</h2>
|
||||
<p class="text-secondary mb-0"><?= nl2br(htmlspecialchars($resultOverview)) ?></p>
|
||||
</section>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user