This commit is contained in:
2026-03-27 00:08:34 +01:00
parent 51ea2030e4
commit 3f072c5906
13 changed files with 232 additions and 101 deletions

View File

@@ -119,4 +119,24 @@ final class EmailTemplateRepository
);
$statement->execute(['id' => $id]);
}
public function duplicate(int $id): void
{
$source = $this->findById($id);
if ($source === null) {
throw new \RuntimeException('Szablon nie istnieje');
}
$statement = $this->pdo->prepare(
'INSERT INTO email_templates (name, subject, body_html, mailbox_id, attachment_1, is_active)
VALUES (:name, :subject, :body_html, :mailbox_id, :attachment_1, 0)'
);
$statement->execute([
'name' => 'Kopia — ' . $source['name'],
'subject' => $source['subject'],
'body_html' => $source['body_html'],
'mailbox_id' => $source['mailbox_id'],
'attachment_1' => $source['attachment_1'],
]);
}
}