Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit f84f043

Browse files
authored
Merge pull request #1 from itk-dev/feature/pdf-templates
Adding PDF template system
2 parents 109d580 + 8b1e9ab commit f84f043

File tree

228 files changed

+16065
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

228 files changed

+16065
-2
lines changed

README.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# OS2Forms Digital Post
2+
3+
Send Digital Post to danish citizens from a webform.
4+
5+
## Installation
6+
7+
Require it with composer:
8+
9+
```shell
10+
composer require "itk-dev/os2forms-digital-post"
11+
```
12+
13+
Enable it with drush:
14+
15+
```shell
16+
drush pm:enable os2forms_digital_post
17+
```
18+
19+
Add the following configuration:
20+
21+
```php
22+
$config['os2forms_digital_post'] = [
23+
'path_to_templates' => '',
24+
25+
'digital_post_system_id' => '',
26+
'digital_post_afsender_system' => '',
27+
28+
'digital_post_materiale_id' => '',
29+
30+
'digital_post_forsendelses_type' => '',
31+
32+
'azure_tenant_id' => '',
33+
'azure_application_id' => '',
34+
'azure_client_secret' => '',
35+
36+
'azure_key_vault_name' => '',
37+
'azure_key_vault_secret' => '',
38+
'azure_key_vault_secret_version' => '',
39+
40+
'service_agreement_uuid' => '',
41+
'user_system_uuid' => '',
42+
'user_uuid' => '',
43+
44+
'service_uuid' => 'fd885b8b-4a3f-46cb-b367-6c9dda1c78f6',
45+
'service_endpoint' => 'https://prod.serviceplatformen.dk/service/Print/Print/2',
46+
'service_contract' => dirname(DRUPAL_ROOT) . '/web/modules/contrib/os2forms-digital-post/resources/contracts/PrintService/wsdl/context/PrintService.wsdl',
47+
];
48+
49+
```
50+
51+
## Templating / Styling the PDF
52+
You'll need to provide a PDF template, that will be rendered when sending letters via digital post.
53+
The template has to be in the twig format and accessible by this module. Configure the path to your templates
54+
in the settings mentioned above.
55+
56+
The following variables is present in the twig-template:
57+
* logo - Path to the logo in your template.
58+
* recipient - Which holds information about the recipient of the letter.
59+
* elements - The elements submitted in the form.
60+
61+
### Structure of template
62+
Your template folder structure has to be as following:
63+
```shell
64+
/templates-root # Set this folder as "path_to_templates" in the settings.
65+
/name-of-template
66+
index.html.twig # The actual twig template.
67+
logo.png # Logo
68+
styles.css # The styles. Be aware that this module uses DomPDF to render the PDF, and therefore are submitted to the CSS rules defined in DomPDF.
69+
```
70+
71+
## Usage
72+
73+
This module provides functionality for sending digital post to danish citizens.
74+
A WebformHandler is provided that you can add to your webform, and if configured
75+
it will send the submitted data as digital post.
76+
77+
This module provides functionality for querying the danish CPR register and
78+
showing the result in webforms.
79+
80+
## Coding standards
81+
82+
Check coding standards (run `composer install` to install the required tools):
83+
84+
```shell
85+
composer coding-standards-check
86+
```
87+
88+
Apply coding standards:
89+
90+
```shell
91+
composer coding-standards-apply
92+
```

composer.json

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,45 @@
99
"email": "[email protected]"
1010
}
1111
],
12+
"repositories": [
13+
{
14+
"type": "composer",
15+
"url": "https://packages.drupal.org/8"
16+
}
17+
],
1218
"minimum-stability": "dev",
1319
"prefer-stable": true,
1420
"require": {
1521
"ext-soap": "*",
16-
"itk-dev/serviceplatformen": "^1.0",
22+
"itk-dev/serviceplatformen": "^1.1",
1723
"php-http/guzzle6-adapter": "^2.0.1",
1824
"http-interop/http-factory-guzzle": "^1.0.0",
19-
"symfony/property-access": "^4.4"
25+
"symfony/property-access": "^4.4",
26+
"wsdltophp/packagebase": "^5.0",
27+
"dompdf/dompdf": "~0.8.0",
28+
"os2forms/os2forms": "^2.5",
29+
"itk-dev/os2forms-cpr-lookup": "^1.2"
30+
},
31+
"autoload": {
32+
"Drupal\\os2forms_digital_post\\": "src/"
33+
},
34+
"require-dev": {
35+
"wsdltophp/packagegenerator": "^4.0",
36+
"drupal/coder": "^8.3",
37+
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.1"
38+
},
39+
"scripts": {
40+
"coding-standards-check/phpcs": [
41+
"phpcs --standard=phpcs.xml.dist"
42+
],
43+
"coding-standards-check": [
44+
"@coding-standards-check/phpcs"
45+
],
46+
"coding-standards-apply/phpcs": [
47+
"phpcbf --standard=phpcs.xml.dist"
48+
],
49+
"coding-standards-apply": [
50+
"@coding-standards-apply/phpcs"
51+
]
2052
}
2153
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ItkDev\OS2Forms_Digital_Post\PrintService;
6+
7+
/**
8+
* Class which returns the class map definition
9+
*/
10+
class ClassMap
11+
{
12+
/**
13+
* Returns the mapping between the WSDL Structs and generated Structs' classes
14+
* This array is sent to the \SoapClient when calling the WS
15+
* @return string[]
16+
*/
17+
final public static function get(): array
18+
{
19+
return [
20+
'InvocationContextType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\InvocationContextType',
21+
'AuthorityContextType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\AuthorityContextType',
22+
'CallContextType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\CallContextType',
23+
'MeddelelsesFormatObjektType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\MeddelelsesFormatObjektType',
24+
'DokumentParametreType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\DokumentParametreType',
25+
'CountryIdentificationCodeType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\CountryIdentificationCodeType',
26+
'KontaktOplysningType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\KontaktOplysningType',
27+
'ForsendelseAfsenderType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\ForsendelseAfsenderType',
28+
'KanalUafhaengigeParametreIType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\KanalUafhaengigeParametreIType',
29+
'MeddelelseFESDmetadataType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\MeddelelseFESDmetadataType',
30+
'DigitalPostParametreType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\DigitalPostParametreType',
31+
'PostParametreType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\PostParametreType',
32+
'TransaktionsParametreIType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\TransaktionsParametreIType',
33+
'PrintParametreType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\PrintParametreType',
34+
'SlutbrugerIdentitetType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\SlutbrugerIdentitetType',
35+
'ForsendelseModtagerType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\ForsendelseModtagerType',
36+
'BilagType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\BilagType',
37+
'BilagSamlingType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\BilagSamlingType',
38+
'ForsendelseIType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\ForsendelseIType',
39+
'BrevSPBodyType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\BrevSPBodyType',
40+
'TilmeldingRequestType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\TilmeldingRequestType',
41+
'PrintAfsendBrevRequestType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\PrintAfsendBrevRequestType',
42+
'PrintAfsendBrevResponseType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\PrintAfsendBrevResponseType',
43+
'PrintSpoergTilmeldingRequestType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\PrintSpoergTilmeldingRequestType',
44+
'PrintSpoergTilmeldingResponseType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\PrintSpoergTilmeldingResponseType',
45+
'FejlType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\FejlType',
46+
'ServiceplatformFaultType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\ServiceplatformFaultType',
47+
'ErrorListType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\ErrorListType',
48+
'ErrorType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\ErrorType',
49+
];
50+
}
51+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ItkDev\OS2Forms_Digital_Post\PrintService\EnumType;
6+
7+
use WsdlToPhp\PackageBase\AbstractStructEnumBase;
8+
9+
/**
10+
* This class stands for FarveSHKodeType EnumType
11+
* @subpackage Enumerations
12+
*/
13+
class FarveSHKodeType extends AbstractStructEnumBase
14+
{
15+
/**
16+
* Constant for value 'SH'
17+
* @return string 'SH'
18+
*/
19+
const VALUE_SH = 'SH';
20+
/**
21+
* Constant for value 'Farve'
22+
* @return string 'Farve'
23+
*/
24+
const VALUE_FARVE = 'Farve';
25+
/**
26+
* Return allowed values
27+
* @uses self::VALUE_SH
28+
* @uses self::VALUE_FARVE
29+
* @return string[]
30+
*/
31+
public static function getValidValues(): array
32+
{
33+
return [
34+
self::VALUE_SH,
35+
self::VALUE_FARVE,
36+
];
37+
}
38+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ItkDev\OS2Forms_Digital_Post\PrintService\EnumType;
6+
7+
use WsdlToPhp\PackageBase\AbstractStructEnumBase;
8+
9+
/**
10+
* This class stands for KanalKodeType EnumType
11+
* @subpackage Enumerations
12+
*/
13+
class KanalKodeType extends AbstractStructEnumBase
14+
{
15+
/**
16+
* Constant for value 'Digital Post'
17+
* @return string 'Digital Post'
18+
*/
19+
const VALUE_DIGITAL_POST = 'Digital Post';
20+
/**
21+
* Constant for value 'Fysisk Post'
22+
* @return string 'Fysisk Post'
23+
*/
24+
const VALUE_FYSISK_POST = 'Fysisk Post';
25+
/**
26+
* Return allowed values
27+
* @uses self::VALUE_DIGITAL_POST
28+
* @uses self::VALUE_FYSISK_POST
29+
* @return string[]
30+
*/
31+
public static function getValidValues(): array
32+
{
33+
return [
34+
self::VALUE_DIGITAL_POST,
35+
self::VALUE_FYSISK_POST,
36+
];
37+
}
38+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ItkDev\OS2Forms_Digital_Post\PrintService\EnumType;
6+
7+
use WsdlToPhp\PackageBase\AbstractStructEnumBase;
8+
9+
/**
10+
* This class stands for KanalvalgType EnumType
11+
* @subpackage Enumerations
12+
*/
13+
class KanalvalgType extends AbstractStructEnumBase
14+
{
15+
/**
16+
* Constant for value 'A'
17+
* @return string 'A'
18+
*/
19+
const VALUE_A = 'A';
20+
/**
21+
* Constant for value 'D'
22+
* @return string 'D'
23+
*/
24+
const VALUE_D = 'D';
25+
/**
26+
* Constant for value 'S'
27+
* @return string 'S'
28+
*/
29+
const VALUE_S = 'S';
30+
/**
31+
* Constant for value 'F'
32+
* @return string 'F'
33+
*/
34+
const VALUE_F = 'F';
35+
/**
36+
* Constant for value 'P'
37+
* @return string 'P'
38+
*/
39+
const VALUE_P = 'P';
40+
/**
41+
* Return allowed values
42+
* @uses self::VALUE_A
43+
* @uses self::VALUE_D
44+
* @uses self::VALUE_S
45+
* @uses self::VALUE_F
46+
* @uses self::VALUE_P
47+
* @return string[]
48+
*/
49+
public static function getValidValues(): array
50+
{
51+
return [
52+
self::VALUE_A,
53+
self::VALUE_D,
54+
self::VALUE_S,
55+
self::VALUE_F,
56+
self::VALUE_P,
57+
];
58+
}
59+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ItkDev\OS2Forms_Digital_Post\PrintService\EnumType;
6+
7+
use WsdlToPhp\PackageBase\AbstractStructEnumBase;
8+
9+
/**
10+
* This class stands for KuvertTypeKodeType EnumType
11+
* @subpackage Enumerations
12+
*/
13+
class KuvertTypeKodeType extends AbstractStructEnumBase
14+
{
15+
/**
16+
* Constant for value 'C4'
17+
* @return string 'C4'
18+
*/
19+
const VALUE_C_4 = 'C4';
20+
/**
21+
* Constant for value 'C5'
22+
* @return string 'C5'
23+
*/
24+
const VALUE_C_5 = 'C5';
25+
/**
26+
* Constant for value 'MA'
27+
* @return string 'MA'
28+
*/
29+
const VALUE_MA = 'MA';
30+
/**
31+
* Return allowed values
32+
* @uses self::VALUE_C_4
33+
* @uses self::VALUE_C_5
34+
* @uses self::VALUE_MA
35+
* @return string[]
36+
*/
37+
public static function getValidValues(): array
38+
{
39+
return [
40+
self::VALUE_C_4,
41+
self::VALUE_C_5,
42+
self::VALUE_MA,
43+
];
44+
}
45+
}

0 commit comments

Comments
 (0)