From 19384a4fec7e6e48116b26dc276d6c618f289819 Mon Sep 17 00:00:00 2001 From: jekuaitk Date: Wed, 27 Mar 2024 13:54:39 +0100 Subject: [PATCH 1/8] #1039: Added overwriteables templates for pdf --- CHANGELOG.md | 3 +- web/sites/default/settings.php | 7 + .../os2forms_selvbetjening_theme/README.md | 30 ++++ .../assets/pdf.css | 137 ++++++++++++++++++ .../os2forms_selvbetjening_theme.theme | 11 ++ ...s-attachment--webform-submission.html.twig | 28 ++++ ...ng-maestro-notification-pdf-html.html.twig | 76 ++++++++++ 7 files changed, 291 insertions(+), 1 deletion(-) create mode 100644 web/themes/custom/os2forms_selvbetjening_theme/assets/pdf.css create mode 100644 web/themes/custom/os2forms_selvbetjening_theme/templates/pdf/os2forms-attachment--webform-submission.html.twig create mode 100644 web/themes/custom/os2forms_selvbetjening_theme/templates/pdf/os2forms-selvbetjening-maestro-notification-pdf-html.html.twig diff --git a/CHANGELOG.md b/CHANGELOG.md index 82e092a8..2c40d0ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,8 +8,9 @@ Nedenfor ses dato for release og beskrivelse af opgaver som er implementeret. * Tilføjede mulighed for csv eksport af alle formular konfigurationer. * Tilføjede mulighed for ekstra tjek på email modtagere (@aarhus.dk). +* Tilføjede Maestro notifikation pdf template. -## [2.7.8] 20-24-03-08 +## [2.7.8] 2024-03-08 * Opdaterede til [OS2Forms NemLogin OpenID Connect 2.0.1](https://github.com/itk-dev/os2forms_nemlogin_openid_connect/releases/tag/2.0.1) diff --git a/web/sites/default/settings.php b/web/sites/default/settings.php index 94578784..96a73a65 100644 --- a/web/sites/default/settings.php +++ b/web/sites/default/settings.php @@ -801,6 +801,13 @@ ]; $settings['config_sync_directory'] = '../config/sync'; +/** + * Base url. + * + * Used to generate full path to stylesheets in os2forms_selvbetjening_theme. + */ +$settings['base_url'] = 'http://nginx:8080'; + /** * Load local development override configuration, if available. * diff --git a/web/themes/custom/os2forms_selvbetjening_theme/README.md b/web/themes/custom/os2forms_selvbetjening_theme/README.md index a600632f..ad3c945c 100644 --- a/web/themes/custom/os2forms_selvbetjening_theme/README.md +++ b/web/themes/custom/os2forms_selvbetjening_theme/README.md @@ -1,5 +1,35 @@ # selvbetjening.aarhuskommune.dk +## PDF templates + +To override PDF templates sent via Digital Post, we have added +`os2forms-attachment--webform-submission.html.twig` and +`os2forms-selvbetjening-maestro-notification-pdf-html.html.twig` +to overwrite os2forms attachment and maestro notification (pdf) html +respectively. + +The maestro notification pdf template should be configured on +`admin/config/system/os2forms_forloeb` as + +```sh +themes/custom/os2forms_selvbetjening_theme/templates/pdf/os2forms-selvbetjening-maestro-notification-pdf-html.html.twig +``` + +whereas the os2forms attachment template automatically should be used. + +To allow usage of a common stylesheet in the two templates you +must configure `base_url` in `settings.local.php` + +```php +$settings['base_url'] = 'http://nginx:8080'; +``` + +and disable default css in the entity print module. This is done by +unchecking `Enable Default CSS` on `admin/config/content/entityprint`. + + +## Theme usage + ```sh docker-compose run --rm node yarn --cwd /app/web/themes/custom/os2forms_selvbetjening_theme install docker-compose run --rm node yarn --cwd /app/web/themes/custom/os2forms_selvbetjening_theme build diff --git a/web/themes/custom/os2forms_selvbetjening_theme/assets/pdf.css b/web/themes/custom/os2forms_selvbetjening_theme/assets/pdf.css new file mode 100644 index 00000000..082a1b95 --- /dev/null +++ b/web/themes/custom/os2forms_selvbetjening_theme/assets/pdf.css @@ -0,0 +1,137 @@ +@page { + margin: 180px 35px 150px 35px; +} + +body { + font-family:"DejaVu Sans",Helvetica,Arial,sans-serif; + margin: 0; + color: red; +} + +header { + position: fixed; + top: -150px; + left: 25px; + right: 0px; + height: 50px; + font-size: 12px; +} + +footer { + position: fixed; + bottom: -50px; + left: 25px; + right: 0px; + height: 50px; + font-size: 12px; +} + +details { + border:1px solid #ccc; + margin-top:1em; + margin-bottom:1em; +} + +summary { + font-size: 20px !important; + font-weight:bold; + padding:.5em .5em 0 .5em; +} + +summary::marker { + display:none; +} + +legend, summary, .details-wrapper, fieldset { + padding: 0; +} + +fieldset { + margin: 0; + border: 0; +} + +.page { + padding:20px; +} + +.page img { + max-width:100%;height:auto; +} + +.page td img { + max-width:none; +} + +.details-wrapper { + padding:0 1em; +} + +.form-item { + margin-top:1em; + margin-bottom:1em; +} + +label { + display:block; + font-weight:bold; +} + +thead { + border-bottom: 1px solid black; +} + +th { + text-align: left; +} + +details, .claro-details { + border: none !important; +} + +.webform-submission-table { + width:100%; + border-collapse:collapse; + border-spacing:0; +} + +.webform-submission-table th { + width:33%; + min-width:100px; +} + +.webform-submission-table th, +.webform-submission-table td { + text-align:left; + padding:10px 12px; +} + +.webform-submission-table tr { + border-top:1px solid #ccc; + border-bottom:1px solid #ccc; + padding:0.1em 0.6em; +} + +.webform-entity-print-body { + font-size: 14px; + width: 65% !important; +} + +.webform-element { + padding: 5px 0; + margin: 5px 0; + font-size: 12px; +} + +.webform-entity-print-colophon { + font-size: 12px; + margin-top: -11px; +} + +.webform-section-title { + font-size: 14px !important; +} + +.table { + width: 100%; +} diff --git a/web/themes/custom/os2forms_selvbetjening_theme/os2forms_selvbetjening_theme.theme b/web/themes/custom/os2forms_selvbetjening_theme/os2forms_selvbetjening_theme.theme index 44cec6fb..eb40eeec 100644 --- a/web/themes/custom/os2forms_selvbetjening_theme/os2forms_selvbetjening_theme.theme +++ b/web/themes/custom/os2forms_selvbetjening_theme/os2forms_selvbetjening_theme.theme @@ -1,5 +1,7 @@ get('name'); } + +/** + * Implements hook_preprocess(). + * + * Add 'base_url' variable to be used by templates. + */ +function os2forms_selvbetjening_theme_preprocess(&$vars) { + $vars['base_url'] = Settings::get('base_url'); +} diff --git a/web/themes/custom/os2forms_selvbetjening_theme/templates/pdf/os2forms-attachment--webform-submission.html.twig b/web/themes/custom/os2forms_selvbetjening_theme/templates/pdf/os2forms-attachment--webform-submission.html.twig new file mode 100644 index 00000000..b14603e6 --- /dev/null +++ b/web/themes/custom/os2forms_selvbetjening_theme/templates/pdf/os2forms-attachment--webform-submission.html.twig @@ -0,0 +1,28 @@ + + + + + + + {{ title }} + + + +{% if header %} +
+ {{ header }} +
+{% endif %} + +{% if footer %} + +{% endif %} + +
+ {{ content }} +
+ + + diff --git a/web/themes/custom/os2forms_selvbetjening_theme/templates/pdf/os2forms-selvbetjening-maestro-notification-pdf-html.html.twig b/web/themes/custom/os2forms_selvbetjening_theme/templates/pdf/os2forms-selvbetjening-maestro-notification-pdf-html.html.twig new file mode 100644 index 00000000..9e0f427f --- /dev/null +++ b/web/themes/custom/os2forms_selvbetjening_theme/templates/pdf/os2forms-selvbetjening-maestro-notification-pdf-html.html.twig @@ -0,0 +1,76 @@ +{# + Use this to style Maestro PDF notifications. + + Set it on '/admin/config/system/os2forms_forloeb' PDF template, + i.e. 'themes/custom/os2forms_selvbetjening_theme/templates/pdf/os2forms-selvbetjening-maestro-notification-pdf-html.html.twig'. + + This is a composition of + os2forms_attachment, os2forms-attachment--webform-submission.html.twig, and + os2forms_forloeb, os2forms-forloeb-notification-message-pdf-html.html.twig. + +/** + * @file + * Template for Maestro notification PDF. + * + * Available variables: + * - message: The notification message + * - subject: the notification subject + * - content: the notification content. Must be rendered as `processed_text`, i.e.: + * @code + * {{ { + * '#type': 'processed_text', + * '#text': message.content.value, + * '#format': message.content.format, + * } }} + * @endcode + * - notification_type: The type of notification () + * - task_url: URL of the task. + * - action_label: Optional label for the task action. + */ +#} + + + + + + {{ message.subject }} + + + +
+
+

+ Aarhus Kommune Logo +
+

+
+
+ +
+
+
+

[webform_submission:completed:custom:d. F Y]

+

Aarhus Kommune
+ Rådhuspladsen 2
+ 8000 Aarhus C

+
+
+ {# @see https://api.drupal.org/api/drupal/core%21modules%21filter%21filter.module/function/check_markup/9 #} +
+ {{ { + '#type': 'processed_text', + '#text': message.content.value, + '#format': message.content.format, + } }} +
+
+
+
+ + + + From 8aafe4c941e3db74012bb02d7090b4a15dda3a50 Mon Sep 17 00:00:00 2001 From: jekuaitk Date: Wed, 27 Mar 2024 14:18:55 +0100 Subject: [PATCH 2/8] #1039: Cleanup --- CHANGELOG.md | 3 ++- .../os2forms_selvbetjening_theme/assets/pdf.css | 1 - .../os2forms_selvbetjening_theme.theme | 11 ----------- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c40d0ea..693ef5be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,8 @@ Nedenfor ses dato for release og beskrivelse af opgaver som er implementeret. * Tilføjede mulighed for csv eksport af alle formular konfigurationer. * Tilføjede mulighed for ekstra tjek på email modtagere (@aarhus.dk). -* Tilføjede Maestro notifikation pdf template. +* Tilføjede templates til `os2forms_attachment` og maestro pdf notifikationer + i `os2forms_selvbetjening_theme` temaet, som nemmere kan justeres. ## [2.7.8] 2024-03-08 diff --git a/web/themes/custom/os2forms_selvbetjening_theme/assets/pdf.css b/web/themes/custom/os2forms_selvbetjening_theme/assets/pdf.css index 082a1b95..29c16664 100644 --- a/web/themes/custom/os2forms_selvbetjening_theme/assets/pdf.css +++ b/web/themes/custom/os2forms_selvbetjening_theme/assets/pdf.css @@ -5,7 +5,6 @@ body { font-family:"DejaVu Sans",Helvetica,Arial,sans-serif; margin: 0; - color: red; } header { diff --git a/web/themes/custom/os2forms_selvbetjening_theme/os2forms_selvbetjening_theme.theme b/web/themes/custom/os2forms_selvbetjening_theme/os2forms_selvbetjening_theme.theme index eb40eeec..44cec6fb 100644 --- a/web/themes/custom/os2forms_selvbetjening_theme/os2forms_selvbetjening_theme.theme +++ b/web/themes/custom/os2forms_selvbetjening_theme/os2forms_selvbetjening_theme.theme @@ -1,7 +1,5 @@ get('name'); } - -/** - * Implements hook_preprocess(). - * - * Add 'base_url' variable to be used by templates. - */ -function os2forms_selvbetjening_theme_preprocess(&$vars) { - $vars['base_url'] = Settings::get('base_url'); -} From 2a4196bc953fcdaeb2db9cc3e949e67e66cb2815 Mon Sep 17 00:00:00 2001 From: jekuaitk Date: Wed, 27 Mar 2024 14:29:35 +0100 Subject: [PATCH 3/8] #1039: Updated CHANGELOG --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 693ef5be..5912bf47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,8 +8,8 @@ Nedenfor ses dato for release og beskrivelse af opgaver som er implementeret. * Tilføjede mulighed for csv eksport af alle formular konfigurationer. * Tilføjede mulighed for ekstra tjek på email modtagere (@aarhus.dk). -* Tilføjede templates til `os2forms_attachment` og maestro pdf notifikationer - i `os2forms_selvbetjening_theme` temaet, som nemmere kan justeres. +* Tilføjede templates til ændring af `os2forms_attachment` og maestro pdf + notifikationer i `os2forms_selvbetjening_theme` temaet. ## [2.7.8] 2024-03-08 From 2f25acc30daf24470a0c96f2c880035bfd23d716 Mon Sep 17 00:00:00 2001 From: Jeppe Kuhlmann Andersen <78410897+jekuaitk@users.noreply.github.com> Date: Wed, 27 Mar 2024 15:21:28 +0100 Subject: [PATCH 4/8] Update CHANGELOG.md Co-authored-by: Mikkel Ricky --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5912bf47..d502f484 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,8 +8,7 @@ Nedenfor ses dato for release og beskrivelse af opgaver som er implementeret. * Tilføjede mulighed for csv eksport af alle formular konfigurationer. * Tilføjede mulighed for ekstra tjek på email modtagere (@aarhus.dk). -* Tilføjede templates til ændring af `os2forms_attachment` og maestro pdf - notifikationer i `os2forms_selvbetjening_theme` temaet. +* Tilføjede templates til ændring af `os2forms_attachment` og maestro-pdf-notifikationer i `os2forms_selvbetjening_theme`-temaet. ## [2.7.8] 2024-03-08 From fee2a9c0466e53e96944bc9fb8ff775dd3e3e515 Mon Sep 17 00:00:00 2001 From: Jeppe Kuhlmann Andersen <78410897+jekuaitk@users.noreply.github.com> Date: Wed, 27 Mar 2024 15:21:58 +0100 Subject: [PATCH 5/8] Update web/themes/custom/os2forms_selvbetjening_theme/assets/pdf.css Co-authored-by: Mikkel Ricky --- web/themes/custom/os2forms_selvbetjening_theme/assets/pdf.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/themes/custom/os2forms_selvbetjening_theme/assets/pdf.css b/web/themes/custom/os2forms_selvbetjening_theme/assets/pdf.css index 29c16664..08114bb3 100644 --- a/web/themes/custom/os2forms_selvbetjening_theme/assets/pdf.css +++ b/web/themes/custom/os2forms_selvbetjening_theme/assets/pdf.css @@ -1,5 +1,6 @@ @page { - margin: 180px 35px 150px 35px; + size: A4; + margin: 180px 35px 150px 35px; } body { From 2549d141bd967bddc852f1942af21fb9f861761e Mon Sep 17 00:00:00 2001 From: jekuaitk Date: Wed, 27 Mar 2024 15:25:56 +0100 Subject: [PATCH 6/8] #1039: Update CHANGELOG --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d502f484..74e5a053 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,8 @@ Nedenfor ses dato for release og beskrivelse af opgaver som er implementeret. * Tilføjede mulighed for csv eksport af alle formular konfigurationer. * Tilføjede mulighed for ekstra tjek på email modtagere (@aarhus.dk). -* Tilføjede templates til ændring af `os2forms_attachment` og maestro-pdf-notifikationer i `os2forms_selvbetjening_theme`-temaet. +* Tilføjede templates til ændring af `os2forms_attachment` og + maestro-pdf-notifikationer i `os2forms_selvbetjening_theme`-temaet. ## [2.7.8] 2024-03-08 From 03e180fd8cfe6eb1f74f5e4ef3dee1dbdb8aaa0d Mon Sep 17 00:00:00 2001 From: jekuaitk Date: Tue, 2 Apr 2024 09:49:34 +0200 Subject: [PATCH 7/8] #1039: Use current date --- ...2forms-selvbetjening-maestro-notification-pdf-html.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/themes/custom/os2forms_selvbetjening_theme/templates/pdf/os2forms-selvbetjening-maestro-notification-pdf-html.html.twig b/web/themes/custom/os2forms_selvbetjening_theme/templates/pdf/os2forms-selvbetjening-maestro-notification-pdf-html.html.twig index 9e0f427f..3e47a26c 100644 --- a/web/themes/custom/os2forms_selvbetjening_theme/templates/pdf/os2forms-selvbetjening-maestro-notification-pdf-html.html.twig +++ b/web/themes/custom/os2forms_selvbetjening_theme/templates/pdf/os2forms-selvbetjening-maestro-notification-pdf-html.html.twig @@ -49,7 +49,7 @@
-

[webform_submission:completed:custom:d. F Y]

+

[current-date:custom:d. F Y]

Aarhus Kommune
Rådhuspladsen 2
8000 Aarhus C

From d5f85edd721675aa2f3ddd5178f61a46bcde0fe4 Mon Sep 17 00:00:00 2001 From: jekuaitk Date: Tue, 2 Apr 2024 10:32:56 +0200 Subject: [PATCH 8/8] #1039: Fix typo --- web/sites/default/settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/sites/default/settings.php b/web/sites/default/settings.php index 96a73a65..f917d817 100644 --- a/web/sites/default/settings.php +++ b/web/sites/default/settings.php @@ -804,7 +804,7 @@ /** * Base url. * - * Used to generate full path to stylesheets in os2forms_selvbetjening_theme. + * Used to generate full URL to stylesheets in os2forms_selvbetjening_theme. */ $settings['base_url'] = 'http://nginx:8080';