@@ -31,6 +32,7 @@ $variableGroups = is_array($variableGroups ?? null) ? $variableGroups : [];
| Nazwa |
Temat |
Skrzynka |
+ Zalacznik |
Status |
Akcje |
@@ -41,6 +43,7 @@ $variableGroups = is_array($variableGroups ?? null) ? $variableGroups : [];
= $e((string) ($tpl['name'] ?? '')) ?> |
= $e((string) ($tpl['subject'] ?? '')) ?> |
= $e((string) ($tpl['mailbox_name'] ?? '—')) ?> |
+ = isset($tpl['attachment_1'], $attachmentTypes[$tpl['attachment_1']]) ? $e($attachmentTypes[$tpl['attachment_1']]) : '—' ?> |
Aktywny
@@ -110,6 +113,19 @@ $variableGroups = is_array($variableGroups ?? null) ? $variableGroups : [];
+
+
Tresc wiadomosci *
diff --git a/src/Modules/Settings/EmailTemplateController.php b/src/Modules/Settings/EmailTemplateController.php
index 27601ff..847bfcc 100644
--- a/src/Modules/Settings/EmailTemplateController.php
+++ b/src/Modules/Settings/EmailTemplateController.php
@@ -54,6 +54,10 @@ final class EmailTemplateController
],
];
+ private const ATTACHMENT_TYPES = [
+ 'receipt' => 'Paragon',
+ ];
+
private const SAMPLE_DATA = [
'zamowienie.numer' => 'OP000001234',
'zamowienie.numer_zewnetrzny' => 'ALG-98765432',
@@ -104,6 +108,7 @@ final class EmailTemplateController
'mailboxes' => $mailboxes,
'editTemplate' => $editTemplate,
'variableGroups' => self::VARIABLE_GROUPS,
+ 'attachmentTypes' => self::ATTACHMENT_TYPES,
'successMessage' => Flash::get('settings.email_templates.success', ''),
'errorMessage' => Flash::get('settings.email_templates.error', ''),
], 'layouts/app');
@@ -127,6 +132,9 @@ final class EmailTemplateController
return Response::redirect('/settings/email-templates');
}
+ $attachment1Raw = trim((string) $request->input('attachment_1', ''));
+ $attachment1 = isset(self::ATTACHMENT_TYPES[$attachment1Raw]) ? $attachment1Raw : '';
+
try {
$this->repository->save([
'id' => $request->input('id', ''),
@@ -134,6 +142,7 @@ final class EmailTemplateController
'subject' => $subject,
'body_html' => $bodyHtml,
'mailbox_id' => $request->input('mailbox_id', ''),
+ 'attachment_1' => $attachment1,
'is_active' => $request->input('is_active', null),
]);
diff --git a/src/Modules/Settings/EmailTemplateRepository.php b/src/Modules/Settings/EmailTemplateRepository.php
index f2d02f8..3dd29f2 100644
--- a/src/Modules/Settings/EmailTemplateRepository.php
+++ b/src/Modules/Settings/EmailTemplateRepository.php
@@ -19,7 +19,7 @@ final class EmailTemplateRepository
public function listAll(): array
{
$statement = $this->pdo->prepare(
- 'SELECT t.id, t.name, t.subject, t.mailbox_id, t.is_active, t.created_at, t.updated_at,
+ 'SELECT t.id, t.name, t.subject, t.mailbox_id, t.attachment_1, t.is_active, t.created_at, t.updated_at,
m.name AS mailbox_name
FROM email_templates t
LEFT JOIN email_mailboxes m ON m.id = t.mailbox_id
@@ -37,7 +37,7 @@ final class EmailTemplateRepository
public function findById(int $id): ?array
{
$statement = $this->pdo->prepare(
- 'SELECT id, name, subject, body_html, mailbox_id, is_active, created_at, updated_at
+ 'SELECT id, name, subject, body_html, mailbox_id, attachment_1, is_active, created_at, updated_at
FROM email_templates
WHERE id = :id'
);
@@ -53,7 +53,7 @@ final class EmailTemplateRepository
public function listActive(): array
{
$statement = $this->pdo->prepare(
- 'SELECT id, name, subject, mailbox_id
+ 'SELECT id, name, subject, mailbox_id, attachment_1
FROM email_templates
WHERE is_active = 1
ORDER BY name ASC'
@@ -75,11 +75,16 @@ final class EmailTemplateRepository
? (int) $data['mailbox_id']
: null;
+ $attachment1 = isset($data['attachment_1']) && $data['attachment_1'] !== ''
+ ? (string) $data['attachment_1']
+ : null;
+
$params = [
'name' => trim((string) ($data['name'] ?? '')),
'subject' => trim((string) ($data['subject'] ?? '')),
'body_html' => (string) ($data['body_html'] ?? ''),
'mailbox_id' => $mailboxId,
+ 'attachment_1' => $attachment1,
'is_active' => isset($data['is_active']) ? 1 : 0,
];
@@ -88,13 +93,13 @@ final class EmailTemplateRepository
$statement = $this->pdo->prepare(
'UPDATE email_templates
SET name = :name, subject = :subject, body_html = :body_html,
- mailbox_id = :mailbox_id, is_active = :is_active
+ mailbox_id = :mailbox_id, attachment_1 = :attachment_1, is_active = :is_active
WHERE id = :id'
);
} else {
$statement = $this->pdo->prepare(
- 'INSERT INTO email_templates (name, subject, body_html, mailbox_id, is_active)
- VALUES (:name, :subject, :body_html, :mailbox_id, :is_active)'
+ 'INSERT INTO email_templates (name, subject, body_html, mailbox_id, attachment_1, is_active)
+ VALUES (:name, :subject, :body_html, :mailbox_id, :attachment_1, :is_active)'
);
}
|