Skip to content

Commit

Permalink
Create a pdf base template to support local url's
Browse files Browse the repository at this point in the history
In order to be able to view pdf's in production a template with only
local urls' had to be created.

(cherry picked from commit 49e009b)
  • Loading branch information
pablothedude authored and MKodde committed Feb 25, 2019
1 parent fce6dfd commit 9c0d421
Show file tree
Hide file tree
Showing 6 changed files with 204 additions and 123 deletions.
58 changes: 58 additions & 0 deletions app/Resources/views/pdf.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{% extends 'MopaBootstrapBundle::base.html.twig' %}

{% block title %}
{% if block('page_title') is not empty %}{{ block('page_title') }} — {% endif %}
{{ 'app.name'|trans }}
{% endblock title %}

{% block head_style %}

<style type="text/css">
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.registration-print-options {
display: none !important;
}
.pull-right {
float: right;
}
.clearfix {
float: none;
}
.page-header {
height: 100px;
}
.page-header h1 {
padding-top: 14px;
}
</style>

{% endblock head_style %}
{% block head_bottom %}
{% endblock head_bottom %}

{% block navbar %}
{% endblock navbar %}

{% block header %}
{% endblock header %}

{% block page_header %}
<div class="page-header clearfix">
<img src="file://{{ root_path }}/../web/images/header-logo.png" class="pull-right logo" alt="OpenConext Stepup" style="width:55mm;">
<h1>{{ 'app.name'|trans }}</h1>
</div>
{% endblock page_header %}

{% block content_row %}
{% block content %}
{% endblock content %}
{% endblock content_row %}

{% block footer %}
{% endblock footer %}

{% block foot_script %}

{% endblock foot_script %}
1 change: 1 addition & 0 deletions app/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ twig:
exception_controller: SurfnetStepupSelfServiceSelfServiceBundle:Exception:show
globals:
global_view_parameters: "@self_service.service.global_view_parameters"
root_path: "%kernel.root_dir%"

# Assetic Configuration
assetic:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,36 +126,7 @@ public function verifyEmailAction(Request $request)
*/
public function registrationEmailSentAction($secondFactorId)
{
$identity = $this->getIdentity();

/** @var \Surfnet\StepupMiddlewareClientBundle\Identity\Dto\VerifiedSecondFactor $secondFactor */
$secondFactor = $this->get('surfnet_stepup_self_service_self_service.service.second_factor')
->findOneVerified($secondFactorId);

$parameters = [
'email' => $identity->email,
'secondFactorId' => $secondFactor->id,
'registrationCode' => $secondFactor->registrationCode,
'expirationDate' => $secondFactor->registrationRequestedAt->add(
new DateInterval('P14D')
),
'locale' => $identity->preferredLocale,
'verifyEmail' => $this->emailVerificationIsRequired(),
];

$raService = $this->get('self_service.service.ra');
$raLocationService = $this->get('self_service.service.ra_location');

$institutionConfigurationOptions = $this->get('self_service.service.institution_configuration_options')
->getInstitutionConfigurationOptionsFor($identity->institution);

if ($institutionConfigurationOptions->useRaLocations) {
$parameters['raLocations'] = $raLocationService->listRaLocationsFor($identity->institution);
} elseif (!$institutionConfigurationOptions->showRaaContactInformation) {
$parameters['ras'] = $raService->listRasWithoutRaas($identity->institution);
} else {
$parameters['ras'] = $raService->listRas($identity->institution);
}
$parameters = $this->buildRegistrationActionParameters($secondFactorId);

return $this->render(
'SurfnetStepupSelfServiceSelfServiceBundle:Registration:registrationEmailSent.html.twig',
Expand All @@ -169,8 +140,14 @@ public function registrationEmailSentAction($secondFactorId)
*/
public function registrationPdfAction($secondFactorId)
{
$content = $this->registrationEmailSentAction($secondFactorId)
->getContent();
$parameters = $this->buildRegistrationActionParameters($secondFactorId);

$response = $this->render(
'SurfnetStepupSelfServiceSelfServiceBundle:Registration:registrationEmailSentPdf.html.twig',
$parameters
);
$content = $response->getContent();


$mpdf = new Mpdf(
array(
Expand Down Expand Up @@ -199,4 +176,41 @@ public function registrationPdfAction($secondFactorId)

return $response;
}


private function buildRegistrationActionParameters($secondFactorId)
{
$identity = $this->getIdentity();

/** @var \Surfnet\StepupMiddlewareClientBundle\Identity\Dto\VerifiedSecondFactor $secondFactor */
$secondFactor = $this->get('surfnet_stepup_self_service_self_service.service.second_factor')
->findOneVerified($secondFactorId);

$parameters = [
'email' => $identity->email,
'secondFactorId' => $secondFactor->id,
'registrationCode' => $secondFactor->registrationCode,
'expirationDate' => $secondFactor->registrationRequestedAt->add(
new DateInterval('P14D')
),
'locale' => $identity->preferredLocale,
'verifyEmail' => $this->emailVerificationIsRequired(),
];

$raService = $this->get('self_service.service.ra');
$raLocationService = $this->get('self_service.service.ra_location');

$institutionConfigurationOptions = $this->get('self_service.service.institution_configuration_options')
->getInstitutionConfigurationOptionsFor($identity->institution);

if ($institutionConfigurationOptions->useRaLocations) {
$parameters['raLocations'] = $raLocationService->listRaLocationsFor($identity->institution);
} elseif (!$institutionConfigurationOptions->showRaaContactInformation) {
$parameters['ras'] = $raService->listRasWithoutRaas($identity->institution);
} else {
$parameters['ras'] = $raService->listRas($identity->institution);
}

return $parameters;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<p>{{ 'ss.registration.registration_email_sent.text.thank_you_for_registration'|trans }}</p>

<p>{{ 'ss.registration.registration_email_sent.text.activation_instructions'|trans }}</p>

<ul>
<li>{{ 'ss.registration.registration_email_sent.text.activation_instructions_item_1'|trans }}</li>
<li>{{ 'ss.registration.registration_email_sent.text.activation_instructions_item_2'|trans }}</li>
<li>{{ 'ss.registration.registration_email_sent.text.activation_instructions_item_3'|trans }}</li>
</ul>

<br />

<p>
{{ 'ss.registration.registration_email_sent.label.expiration_date'
|trans({'%expirationDate%': expirationDate|localizeddate('full', 'none', locale)}) }}
</p>

<div class="row">
<div class="col-xs-12 col-sm-6 col-md-6">
<table class="table table-bordered table-hover table-responsive">
<tbody>
<tr>
<th scope="row">{{ 'ss.registration.registration_email_sent.label.registration_code'|trans }}</th>
<td>{{ registrationCode }}</td>
</tr>
</tbody>
</table>
</div>
</div>

<br />

<p>{{ 'ss.registration.registration_email_sent.text.registration_code_has_been_sent'|trans({'%email%': email}) }}</p>

<div class="registration-print-options">
{% if not verifyEmail %}
<p>{{ 'ss.registration.registration_email_sent.text.registration_code_has_been_sent_no_email'|trans }}</p>
{% endif %}

<br />

<a href="#" class="registration-print">
<i class="fa fa-print fa-2x"></i>
{{ 'ss.registration.registration_email_sent.text.registration_code_has_been_sent_print'|trans }}
</a>
<a href="{{ path('ss_registration_registration_pdf', {'secondFactorId': secondFactorId}) }}" class="registration-pdf">
<i class="fa fa-download fa-2x"></i>
{{ 'ss.registration.registration_email_sent.text.registration_code_has_been_sent_pdf'|trans }}
</a>
</div>

<hr>

{% if raLocations is defined %}
<h3>{{ 'ss.registration.registration_email_sent.title.list_of_ra_locations'|trans }}</h3>

{% if raLocations.elements is empty %}
<p>{{ 'ss.registration.registration_email_sent.text.no_ra_locations_for_your_institution'|trans }}</p>
{% else %}
<ul class="list-ras">
{% for raLocation in raLocations.elements %}
<li>
<address>
<strong>{{ raLocation.name }}</strong><br>
{{ raLocation.location }}<br>
{{ raLocation.contactInformation }}
</address>
</li>
{% endfor %}
</ul>
{% endif %}
{% else %}
<h3>{{ 'ss.registration.registration_email_sent.title.list_of_ras'|trans }}</h3>

{% if ras.elements is empty %}
<p>{{ 'ss.registration.registration_email_sent.text.no_ras_for_your_institution'|trans }}</p>
{% else %}
<ul class="list-ras">
{% for ra in ras.elements %}
<li>
<address>
<strong>{{ ra.commonName }}</strong><br>
{{ ra.location }}<br>
{{ ra.contactInformation }}
</address>
</li>
{% endfor %}
</ul>
{% endif %}
{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -14,97 +14,7 @@

{% block content %}
<h2>{{ block('page_title') }}</h2>

<p>{{ 'ss.registration.registration_email_sent.text.thank_you_for_registration'|trans }}</p>

<p>{{ 'ss.registration.registration_email_sent.text.activation_instructions'|trans }}</p>

<ul>
<li>{{ 'ss.registration.registration_email_sent.text.activation_instructions_item_1'|trans }}</li>
<li>{{ 'ss.registration.registration_email_sent.text.activation_instructions_item_2'|trans }}</li>
<li>{{ 'ss.registration.registration_email_sent.text.activation_instructions_item_3'|trans }}</li>
</ul>

<br />

<p>
{{ 'ss.registration.registration_email_sent.label.expiration_date'
|trans({'%expirationDate%': expirationDate|localizeddate('full', 'none', locale)}) }}
</p>

<div class="row">
<div class="col-xs-12 col-sm-6 col-md-6">
<table class="table table-bordered table-hover table-responsive">
<tbody>
<tr>
<th scope="row">{{ 'ss.registration.registration_email_sent.label.registration_code'|trans }}</th>
<td>{{ registrationCode }}</td>
</tr>
</tbody>
</table>
</div>
</div>

<br />

<p>{{ 'ss.registration.registration_email_sent.text.registration_code_has_been_sent'|trans({'%email%': email}) }}</p>

<div class="registration-print-options">
{% if not verifyEmail %}
<p>{{ 'ss.registration.registration_email_sent.text.registration_code_has_been_sent_no_email'|trans }}</p>
{% endif %}

<br />

<a href="#" class="registration-print">
<i class="fa fa-print fa-2x"></i>
{{ 'ss.registration.registration_email_sent.text.registration_code_has_been_sent_print'|trans }}
</a>
<a href="{{ path('ss_registration_registration_pdf', {'secondFactorId': secondFactorId}) }}" class="registration-pdf">
<i class="fa fa-download fa-2x"></i>
{{ 'ss.registration.registration_email_sent.text.registration_code_has_been_sent_pdf'|trans }}
</a>
</div>

<hr>

{% if raLocations is defined %}
<h3>{{ 'ss.registration.registration_email_sent.title.list_of_ra_locations'|trans }}</h3>

{% if raLocations.elements is empty %}
<p>{{ 'ss.registration.registration_email_sent.text.no_ra_locations_for_your_institution'|trans }}</p>
{% else %}
<ul class="list-ras">
{% for raLocation in raLocations.elements %}
<li>
<address>
<strong>{{ raLocation.name }}</strong><br>
{{ raLocation.location }}<br>
{{ raLocation.contactInformation }}
</address>
</li>
{% endfor %}
</ul>
{% endif %}
{% else %}
<h3>{{ 'ss.registration.registration_email_sent.title.list_of_ras'|trans }}</h3>

{% if ras.elements is empty %}
<p>{{ 'ss.registration.registration_email_sent.text.no_ras_for_your_institution'|trans }}</p>
{% else %}
<ul class="list-ras">
{% for ra in ras.elements %}
<li>
<address>
<strong>{{ ra.commonName }}</strong><br>
{{ ra.location }}<br>
{{ ra.contactInformation }}
</address>
</li>
{% endfor %}
</ul>
{% endif %}
{% endif %}
{% include 'SurfnetStepupSelfServiceSelfServiceBundle:Registration/partial:registrationEmailSent.html.twig' %}
{% endblock %}

{% block body_end %}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% extends "::pdf.html.twig" %}

{% block page_title %}{{ 'ss.registration.registration_email_sent.title'|trans }}{% endblock %}

{% block content %}
<h2>{{ block('page_title') }}</h2>
{% include 'SurfnetStepupSelfServiceSelfServiceBundle:Registration/partial:registrationEmailSent.html.twig' %}
{% endblock %}

0 comments on commit 9c0d421

Please sign in to comment.