Added security check report field and variable
This commit is contained in:
@@ -32,10 +32,13 @@ final class SecurityCheckProcess
|
||||
public const FIELD_TEXTAREA = 'textarea';
|
||||
public const FIELD_DATETIME = 'datetime';
|
||||
|
||||
/** Field key of the official, customer-facing report written on the final step. */
|
||||
public const FIELD_CUSTOMER_REPORT = 'customer_report';
|
||||
|
||||
/**
|
||||
* Ordered fixed process steps.
|
||||
*
|
||||
* @return list<array{key: string, label: string, description: string, kind: string, fields?: list<array{key: string, label: string, type: string, required: bool}>}>
|
||||
* @return list<array{key: string, label: string, description: string, kind: string, fields?: list<array{key: string, label: string, type: string, required: bool, rows?: int}>}>
|
||||
*/
|
||||
public function steps(): array
|
||||
{
|
||||
@@ -86,10 +89,13 @@ final class SecurityCheckProcess
|
||||
'kind' => self::KIND_TECH_CHECKLIST,
|
||||
],
|
||||
[
|
||||
'key' => 'report',
|
||||
'key' => self::STEP_REPORT,
|
||||
'label' => 'Create report & notify customer',
|
||||
'description' => 'Create the report for the customer and notify them.',
|
||||
'kind' => self::KIND_STEP,
|
||||
'fields' => [
|
||||
['key' => self::FIELD_CUSTOMER_REPORT, 'label' => 'Official customer report', 'type' => self::FIELD_TEXTAREA, 'required' => true, 'rows' => 12],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
@@ -114,7 +120,7 @@ final class SecurityCheckProcess
|
||||
/**
|
||||
* Structured fields captured on a given step (info textareas, datetimes, …).
|
||||
*
|
||||
* @return list<array{key: string, label: string, type: string, required: bool}>
|
||||
* @return list<array{key: string, label: string, type: string, required: bool, rows?: int}>
|
||||
*/
|
||||
public function stepFields(string $stepKey): array
|
||||
{
|
||||
|
||||
@@ -106,8 +106,14 @@ final class SecurityReportPdfService
|
||||
$progress = is_array($check['progress'] ?? null) ? $check['progress'] : [];
|
||||
$status = (string) ($check['status'] ?? SecurityCheckProcess::STATUS_OPEN);
|
||||
|
||||
// The owner-authored, customer-facing report text captured on the final step.
|
||||
$reportFields = is_array($processState[SecurityCheckProcess::STEP_REPORT]['fields'] ?? null)
|
||||
? $processState[SecurityCheckProcess::STEP_REPORT]['fields']
|
||||
: [];
|
||||
|
||||
return [
|
||||
'title' => t('Security check report'),
|
||||
'customer_report' => trim((string) ($reportFields[SecurityCheckProcess::FIELD_CUSTOMER_REPORT] ?? '')),
|
||||
'customer_name' => (string) ($check['debitor_name'] ?? ''),
|
||||
'customer_no' => (string) ($check['debitor_no'] ?? ''),
|
||||
'domain' => (string) ($check['domain_url'] ?? ($check['domain_no'] ?? '')),
|
||||
|
||||
@@ -43,6 +43,7 @@ final class SecurityReportTemplateService
|
||||
public function availableVariables(): array
|
||||
{
|
||||
return [
|
||||
'customer_report' => t('Official customer report text (written by the owner on the report step)'),
|
||||
'logo_src' => t('Logo image source (data URI) — use in <img src="{{logo_src}}">'),
|
||||
'title' => t('Report title'),
|
||||
'customer_name' => t('Customer name'),
|
||||
@@ -93,6 +94,9 @@ final class SecurityReportTemplateService
|
||||
$map['{{' . $key . '}}'] = $this->esc($value);
|
||||
}
|
||||
|
||||
// Owner-authored prose: escape, then keep the author's line breaks.
|
||||
$map['{{customer_report}}'] = nl2br($this->esc((string) ($context['customer_report'] ?? '')));
|
||||
|
||||
$map['{{checklist}}'] = $this->buildChecklistHtml(
|
||||
is_array($context['tech_sections'] ?? null) ? $context['tech_sections'] : []
|
||||
);
|
||||
@@ -214,6 +218,9 @@ final class SecurityReportTemplateService
|
||||
<div class="summary">{{checks_done}} / {{checks_total}} ({{percent}}%)</div>
|
||||
<div class="bar"><div class="bar-fill" style="width: {{percent}}%;"></div></div>
|
||||
|
||||
<h2>Report</h2>
|
||||
<div class="customer-report">{{customer_report}}</div>
|
||||
|
||||
<h2>Technical checklist</h2>
|
||||
{{checklist}}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user