Skip to content

Commit

Permalink
Ref #214: add new fields to forms and detail page
Browse files Browse the repository at this point in the history
  • Loading branch information
LucileDT committed Dec 25, 2020
1 parent f13dc5b commit 4d34a7e
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/Controller/MembershipController.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ public function createAction(Request $request, TranslatorInterface $translator)
if ($payment->getType()->isBankneeded())
{
$payment->setBank($updateMembershipFDO->getBank());
$payment->setCheckIssuer($updateMembershipFDO->getCheckIssuer());
$payment->setCheckNumber($updateMembershipFDO->getCheckNumber());
}
else
{
Expand Down Expand Up @@ -251,6 +253,8 @@ public function editAction(Membership $membership, Request $request, TranslatorI
if ($payment->getType()->isBankneeded())
{
$payment->setBank($updateMembershipFDO->getBank());
$payment->setCheckIssuer($updateMembershipFDO->getCheckIssuer());
$payment->setCheckNumber($updateMembershipFDO->getCheckNumber());
}
else
{
Expand Down
9 changes: 9 additions & 0 deletions src/Form/MembershipFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Contracts\Translation\TranslatorInterface;

class MembershipFormType extends AbstractType
Expand Down Expand Up @@ -188,6 +189,14 @@ public function buildForm(FormBuilderInterface $builder, array $options)
],
'placeholder' => $this->translator->trans('Sélectionnez une banque'),
]);

$builder->add('check_number', TextType::class, [
'label' => $this->translator->trans('Numéro du chèque'),
]);

$builder->add('check_issuer', TextType::class, [
'label' => $this->translator->trans('Signataire'),
]);
}

/**
Expand Down
28 changes: 28 additions & 0 deletions src/FormDataObject/UpdateMembershipFDO.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ class UpdateMembershipFDO

private $bank;

private $checkNumber;

private $checkIssuer;

public function __construct(Membership $membership = null)
{
if ($membership !== null)
Expand All @@ -63,6 +67,8 @@ public function __construct(Membership $membership = null)
$this->paymentDate_cashed = $payment->getDateCashed();
$this->payer = $payment->getPayer();
$this->bank = $payment->getBank();
$this->checkNumber = $payment->getCheckNumber();
$this->checkIssuer = $payment->getCheckIssuer();

$donation = $payment->getDonation();

Expand Down Expand Up @@ -345,4 +351,26 @@ function setBank(?Bank $bank): self

return $this;
}

function getCheckNumber(): ?string
{
return $this->checkNumber;
}

function getCheckIssuer(): ?string
{
return $this->checkIssuer;
}

function setCheckNumber($checkNumber): self
{
$this->checkNumber = $checkNumber;
return $this;
}

function setCheckIssuer($checkIssuer): self
{
$this->checkIssuer = $checkIssuer;
return $this;
}
}
4 changes: 3 additions & 1 deletion templates/Membership/edit.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@
</div>
{{ form_row(membership_edit_form.payer)}}
{{ form_row(membership_edit_form.paymentType)}}
<div id="payment-bank" class="form-group d-none">
<div id="payment-bank" class="form-group">
{{ form_row(membership_edit_form.bank)}}
{{ form_row(membership_edit_form.check_issuer)}}
{{ form_row(membership_edit_form.check_number)}}
</div>
{{ form_row(membership_edit_form.paymentDate_received)}}
</div>
Expand Down
2 changes: 2 additions & 0 deletions templates/Membership/new.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@
</div>
<div id="payment-bank" class="form-group">
{{ form_row(membership_creation_form.bank)}}
{{ form_row(membership_creation_form.check_issuer)}}
{{ form_row(membership_creation_form.check_number)}}
</div>
<div id="payment-date-received-group" class="form-group">
{{ form_label(membership_creation_form.paymentDate_received)}} *
Expand Down
10 changes: 7 additions & 3 deletions templates/Membership/show.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@
{% trans %}Payée via{% endtrans %}&nbsp;:
<small>
{{ membership.payment.type.label }}
{% if (membership.payment.bank is not null) %}
({{ membership.payment.bank.name }})
{% if (membership.payment.type.isBankNeeded is not null) %}
({{ membership.payment.bank.name }})<br>
<small>
Numéro du chèque : {{ membership.payment.checkNumber }}<br>
Signataire du chèque : {{ membership.payment.checkIssuer }}
</small>
{% endif %}
</small>
</h4>
Expand All @@ -80,7 +84,7 @@
<br>
</div>
<div class="col">
<h4>{% trans %}Par{% endtrans %}&nbsp;:
<h4>{% trans %}Réglé par{% endtrans %}&nbsp;:
{% set payer = membership.payment.payer %}
<div class="card payer-card">
<div class="card-body p-2">
Expand Down

0 comments on commit 4d34a7e

Please sign in to comment.