Skip to content

Commit

Permalink
added receipt for CEJ 2024
Browse files Browse the repository at this point in the history
  • Loading branch information
Lung committed Jan 30, 2024
1 parent a00c934 commit 555cfb6
Show file tree
Hide file tree
Showing 12 changed files with 146 additions and 24 deletions.
Binary file added public/ZNAK_Scouting_Slovakia_250.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 7 additions & 10 deletions public/stylesPdf.css
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
.header-logo {
margin: 20px;
max-height: 100px;
}

.signStamp {
max-width: 200px;
max-height: 100px;
max-width: 250px;
}

.content-left {
float: left;
text-align: left;
float: left;
text-align: left;
}

.content-right {
float: right;
text-align: right;
float: right;
text-align: right;
}

.content-center {
text-align: center;
text-align: center;
}
21 changes: 21 additions & 0 deletions src/Event/EventType/Cej/EventTypeCej.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,19 @@ public function getLanguages(): array
];
}

public function isReceiptAllowed(): bool
{
return true;
}

public function getReceiptTemplateName(Participant $participant): string
{
return match ($participant->contingent) {
self::CONTINGENT_CZECHIA => 'receipt/receiptCejCs.twig',
default => 'receipt/receiptCejSk.twig',
};
}

public function getMinimalPpCount(Event $event, Participant $participant): int
{
if (in_array(
Expand Down Expand Up @@ -232,4 +245,12 @@ public function getConstantSymbol(): string
{
return '0558'; // TODO move into DB like IBAN
}

public function getSkautLogoPath(Participant $participant): string
{
return match ($participant->contingent) {
self::CONTINGENT_CZECHIA => parent::getSkautLogoPath($participant),
default => '/ZNAK_Scouting_Slovakia_250.png',
};
}
}
36 changes: 36 additions & 0 deletions src/Event/EventType/Cej/en_cej.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,39 @@ email:
payment-info-contingents:
approved: "Congratulations, you are approved to participate at"
wait: "Please wait for payment details to be received from your contingent."
receipt:
headline: "Confirmation of payment acceptance"
number: "Receipt number"
accepter: "
Slovenský skauting, o. z.<br/>
Mokrohájska cesta 6<br/>
841 04 Bratislava<br/>
IČO: 00598721
"
acceptPaymentEvent: "We confirm the acceptance of payment for the event %eventReadableName% with date %eventDates%."
acceptPaymentParticipant: "Accepted for participant %participantFullName% with address %participantFullAddress%."
acceptPaymentMoreParticipant: "Other participants of the event for which the payment was made: %allOtherParticipants%"
acceptPaymentPayment: "
Payment was accepted in the amount of %paymentAmount% %paymentCurrency%
with variable symbol %paymentVariableSymbol%
to the account %paymentAccountTo%.
"
acceptedSign: "issued automatically on %acceptedDate%"
receiptCs:
headline: "Potvrzení o přijetí platby"
number: "Číslo dokladu"
accepter: "
Junák – český skaut, z. s.<br/>
Senovážné nám. 24<br/>
110 00 Praha 1<br/>
IČO: 00409430
"
acceptPaymentEvent: "Potvrzujeme přijetí platby na akci %eventReadableName% s datem konání %eventDates%."
acceptPaymentParticipant: "Přijato za osobu účastnící se akce %participantFullName% bydlištěm %participantFullAddress%."
acceptPaymentMoreParticipant: "Další osoby účastnící se akce, za které bylo zaplaceno: %allOtherParticipants%"
acceptPaymentPayment: "
Platba byla přijata ve výši %paymentAmount% %paymentCurrency%
pod variabilním symbolem %paymentVariableSymbol%
na účet %paymentAccountTo%.
"
acceptedSign: "vystaveno automaticky dne %acceptedDate%"
9 changes: 7 additions & 2 deletions src/Event/EventType/EventType.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ public function isReceiptAllowed(): bool
return false;
}

public function getReceiptTemplateName(): string
public function getReceiptTemplateName(Participant $participant): string
{
return '';
return 'receipt/receiptVrj.twig';
}

public function getReceiptNumber(string $eventPrefix, Participant $participant, string $paymentId): string
Expand Down Expand Up @@ -226,4 +226,9 @@ public function getConstantSymbol(): string
{
return '';
}

public function getSkautLogoPath(Participant $participant): string
{
return '/SKAUT_horizontalni_logo_250.png';
}
}
5 changes: 0 additions & 5 deletions src/Event/EventType/Obrok/EventTypeObrok.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,4 @@ public function isReceiptAllowed(): bool
{
return true;
}

public function getReceiptTemplateName(): string
{
return 'receipt/receiptVrj.twig';
}
}
2 changes: 1 addition & 1 deletion src/Participant/ParticipantController.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function downloadReceipt(Request $request, Response $response, User $user

fwrite($stream, $this->pdfGenerator->generatePdfReceipt(
$participant,
$user->event->eventType->getReceiptTemplateName(),
$user->event->eventType->getReceiptTemplateName($participant),
));
rewind($stream);

Expand Down
3 changes: 1 addition & 2 deletions src/PdfGenerator/mPdfGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@ public function generatePdfReceipt(Participant $participant, string $templateNam
$payment = $participant->getFirstPaidPayment();
$templateData = [
'event' => $event,
'skautLogo' => ImageUtils::getLocalImageInBase64('/SKAUT_horizontalni_logo_250.png'),
'skautLogo' => ImageUtils::getLocalImageInBase64($event->eventType->getSkautLogoPath($participant)),
'receiptNumber' => $event->eventType->getReceiptNumber($event->slug, $participant, (string)$payment?->id),
'eventDates' => $event->startDay->format('j. n. Y') . '' . $event->endDay->format('j. n. Y'),
'participant' => $participant,
'allOtherParticipants' => $this->getOtherParticipantsIfNeeded($participant),
'payment' => $payment,
'acceptedDate' => $participant->registrationPayDate?->format('j. n. Y'),
'signAndStamp' => ImageUtils::getLocalImageInBase64('/SkautJunakSignStamp.png'),
];

$html = $this->twig->fetch($templateName, $templateData);
Expand Down
2 changes: 1 addition & 1 deletion src/Templates/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ troopManagement-admin:
untie: "Untie participant from troop"
receipt:
headline: "Confirmation of payment acceptance"
numberEN: "Receipt number"
number: "Receipt number"
accepter: "
Junák – český skaut, z. s.<br/>
Senovážné nám. 24<br/>
Expand Down
39 changes: 39 additions & 0 deletions src/Templates/translatable/receipt/receiptCejCs.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{% extends "_layoutPdf.twig" %}

{% block content %}
<div class="header">
<img class="header-logo" src="data:image/png;base64,{{ event.getLogoInBase64 }}" alt="logo of {{ event.readableName }}">
<img class="header-logo content-right" src="data:image/png;base64,{{ skautLogo }}" alt="logo of Scout organization">
</div>
<h1 class="content-center">{{ 'receiptCs.headline' |trans }}</h1>
<p class="content-left">{{ 'receiptCs.accepter'|trans|raw }}</p>
<p class="content-right">{{ 'receiptCs.number'|trans }}: {{ receiptNumber }}</p>
<p>{{ 'receiptCs.acceptPaymentEvent'|trans({
'%eventReadableName%': event.readableName,
'%eventDates%': eventDates,
}) }}</p>
<p>{{ 'receiptCs.acceptPaymentParticipant'|trans({
'%participantFullName%': participant.getFullName,
'%participantFullAddress%': participant.permanentResidence,
}) }}</p>
{% if allOtherParticipants %}
<p>{{ 'receiptCs.acceptPaymentMoreParticipant'|trans({
'%allOtherParticipants%': allOtherParticipants,
}) }}</p>
{% endif %}

{% if participant is PatrolLeader %}
{% set price = ((participant.getPatrolParticipantsCount() + 1) * 6600) %}
{% else %}
{% set price = 4100 %}
{% endif %}
<p>{{ 'receiptCs.acceptPaymentPayment'|trans({
'%paymentAmount%': price,
'%paymentCurrency%': '',
'%paymentVariableSymbol%': '42438' ~ payment.variableSymbol[5:],
'%paymentAccountTo%': '2302084720/2010',
}) }}</p>
<p class="content-right">{{ 'receiptCs.acceptedSign'|trans({
'%acceptedDate%': participant.registrationPayDate.format('j. n. Y'),
}) }}</p>
{% endblock %}
33 changes: 33 additions & 0 deletions src/Templates/translatable/receipt/receiptCejSk.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{% extends "_layoutPdf.twig" %}

{% block content %}
<div class="header">
<img class="header-logo" src="data:image/png;base64,{{ event.getLogoInBase64 }}" alt="logo of {{ event.readableName }}">
<img class="header-logo content-right" src="data:image/png;base64,{{ skautLogo }}" alt="logo of Scout organization">
</div>
<h1 class="content-center">{{ 'receipt.headline' |trans }}</h1>
<p class="content-left">{{ 'receipt.accepter'|trans|raw }}</p>
<p class="content-right">{{ 'receipt.number'|trans }}: {{ receiptNumber }}</p>
<p>{{ 'receipt.acceptPaymentEvent'|trans({
'%eventReadableName%': event.readableName,
'%eventDates%': eventDates,
}) }}</p>
<p>{{ 'receipt.acceptPaymentParticipant'|trans({
'%participantFullName%': participant.getFullName,
'%participantFullAddress%': participant.permanentResidence,
}) }}</p>
{% if allOtherParticipants %}
<p>{{ 'receipt.acceptPaymentMoreParticipant'|trans({
'%allOtherParticipants%': allOtherParticipants,
}) }}</p>
{% endif %}
<p>{{ 'receipt.acceptPaymentPayment'|trans({
'%paymentAmount%': payment.price,
'%paymentCurrency%': payment.currency,
'%paymentVariableSymbol%': payment.variableSymbol,
'%paymentAccountTo%': payment.accountNumber,
}) }}</p>
<p class="content-right">{{ 'receipt.acceptedSign'|trans({
'%acceptedDate%': participant.registrationPayDate.format('j. n. Y'),
}) }}</p>
{% endblock %}
3 changes: 0 additions & 3 deletions src/Templates/translatable/receipt/receiptVrj.twig
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
'%paymentVariableSymbol%': payment.variableSymbol,
'%paymentAccountTo%': payment.accountNumber,
}) }}</p>
{#<div>
<img class="signStamp content-right" src="data:image/png;base64,{{ signAndStamp }}" alt="sign and stamp">
</div>#}
<p class="content-right">{{ 'receipt.acceptedSign'|trans({
'%acceptedDate%': participant.registrationPayDate.format('j. n. Y'),
}) }}</p>
Expand Down

0 comments on commit 555cfb6

Please sign in to comment.