From 951160982d27a06a8f72d1fc1f22f7454cd6780d Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 17 Jun 2021 10:43:57 +0200 Subject: [PATCH 01/10] person: add more fields on Person + migration --- .../ChillPersonBundle/Entity/Person.php | 169 ++++++++++++++++-- .../Form/Type/GenderType.php | 3 +- .../migrations/Version20210617073504.php | 49 +++++ .../translations/messages.fr.yml | 2 + 4 files changed, 210 insertions(+), 13 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/migrations/Version20210617073504.php diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php index 0ec04bf35..f44cb1c30 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person.php @@ -25,11 +25,13 @@ namespace Chill\PersonBundle\Entity; use ArrayIterator; use Chill\MainBundle\Entity\Center; use Chill\MainBundle\Entity\Country; +use Chill\MainBundle\Entity\Language; use Chill\PersonBundle\Entity\Household\Household; use Chill\PersonBundle\Entity\MaritalStatus; use Chill\PersonBundle\Entity\Household\HouseholdMember; use Chill\MainBundle\Entity\HasCenterInterface; use Chill\MainBundle\Entity\Address; +use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable; use DateTime; use Doctrine\ORM\Mapping as ORM; use Doctrine\Common\Collections\Collection; @@ -99,6 +101,14 @@ class Person implements HasCenterInterface */ private $birthdate; //to change in birthdate + /** + * The person's deathdate + * @var \DateTime + * + * @ORM\Column(type="date", nullable=true) + */ + private $deathdate; + /** * The person's place of birth * @var string @@ -142,6 +152,14 @@ class Person implements HasCenterInterface const MALE_GENDER = 'man'; const FEMALE_GENDER = 'woman'; const BOTH_GENDER = 'both'; + const NO_INFORMATION = 'unknown'; + + /** + * Comment on gender + * @var CommentEmbeddable + * @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="genderComment_") + */ + private $genderComment; /** * The marital status of the person @@ -152,6 +170,21 @@ class Person implements HasCenterInterface */ private $maritalStatus; + /** + * The date of the last marital status change of the person + * @var \DateTime + * + * @ORM\Column(type="date", nullable=true) + */ + private $maritalStatusDate; + + /** + * Comment on marital status + * @var CommentEmbeddable + * @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="maritalStatusComment_") + */ + private $maritalStatusComment; + /** * Contact information for contacting the person * @var string @@ -239,6 +272,31 @@ class Person implements HasCenterInterface */ private $memo = ''; // TO-CHANGE in remark + + /** + * Accept short text message (aka SMS) + * @var boolean + * + * @ORM\Column(type="boolean", options={"default" : false}) + */ + private $acceptSMS; + + /** + * Accept receiving email + * @var boolean + * + * @ORM\Column(type="boolean", options={"default" : false}) + */ + private $acceptEmail; + + /** + * Number of children + * @var int + * + * @ORM\Column(type="integer", options={"default" : 0}) + */ + private $numberOfChildren; + /** * @var boolean * @deprecated @@ -306,8 +364,10 @@ class Person implements HasCenterInterface } $this->open(new AccompanyingPeriod($opening)); + $this->genderComment = new CommentEmbeddable(); + $this->maritalStatusComment = new CommentEmbeddable(); } - + /** * This private function scan accompanyingPeriodParticipations Collection, * searching for a given AccompanyingPeriod @@ -319,10 +379,10 @@ class Person implements HasCenterInterface if ($accompanyingPeriod === $participation->getAccompanyingPeriod()) { return $participation; }} - + return null; } - + /** * This public function is the same but return only true or false */ @@ -330,7 +390,7 @@ class Person implements HasCenterInterface { return ($this->participationsContainAccompanyingPeriod($accompanyingPeriod)) ? false : true; } - + /** * Add AccompanyingPeriodParticipation * @@ -340,7 +400,7 @@ class Person implements HasCenterInterface { $participation = new AccompanyingPeriodParticipation($accompanyingPeriod, $this); $this->accompanyingPeriodParticipations->add($participation); - + return $this; } @@ -350,7 +410,7 @@ class Person implements HasCenterInterface public function removeAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod) : void { $participation = $this->participationsContainAccompanyingPeriod($accompanyingPeriod); - + if (! null === $participation) { $participation->setEndDate(\DateTimeImmutable::class); $this->accompanyingPeriodParticipations->removeElement($participation); @@ -428,7 +488,7 @@ class Person implements HasCenterInterface } return $accompanyingPeriods; } - + /** * Get AccompanyingPeriodParticipations Collection */ @@ -437,7 +497,7 @@ class Person implements HasCenterInterface return $this->accompanyingPeriodParticipations; } - /** + /** * Return a collection of participation, where the participation * is still opened, not a draft, and the period is still opened */ @@ -455,9 +515,9 @@ class Person implements HasCenterInterface ->filter(function (AccompanyingPeriodParticipation $app) { $period = $app->getAccompanyingPeriod(); return ( - NULL === $period->getClosingDate() + NULL === $period->getClosingDate() || new \DateTime('now') < $period->getClosingDate() - ) + ) && AccompanyingPeriod::STEP_DRAFT !== $period->getStep(); }); } @@ -1185,12 +1245,12 @@ class Person implements HasCenterInterface return true; } - + public function getFullnameCanonical() : string { return $this->fullnameCanonical; } - + public function setFullnameCanonical($fullnameCanonical) : Person { $this->fullnameCanonical = $fullnameCanonical; @@ -1247,4 +1307,89 @@ class Person implements HasCenterInterface { return NULL !== $this->getCurrentHousehold($at); } + + public function getGenderComment(): CommentEmbeddable + { + return $this->genderComment; + } + + public function setGenderComment(CommentEmbeddable $genderComment): self + { + $this->genderComment = $genderComment; + + return $this; + } + + public function getMaritalStatusComment(): CommentEmbeddable + { + return $this->maritalStatusComment; + } + + public function setMaritalStatusComment(CommentEmbeddable $maritalStatusComment): self + { + $this->maritalStatusComment = $maritalStatusComment; + + return $this; + } + + public function getDeathdate(): ?\DateTimeInterface + { + return $this->deathdate; + } + + public function setDeathdate(?\DateTimeInterface $deathdate): self + { + $this->deathdate = $deathdate; + + return $this; + } + + public function getMaritalStatusDate(): ?\DateTimeInterface + { + return $this->maritalStatusDate; + } + + public function setMaritalStatusDate(?\DateTimeInterface $maritalStatusDate): self + { + $this->maritalStatusDate = $maritalStatusDate; + + return $this; + } + + public function getAcceptSMS(): ?bool + { + return $this->acceptSMS; + } + + public function setAcceptSMS(bool $acceptSMS): self + { + $this->acceptSMS = $acceptSMS; + + return $this; + } + + public function getAcceptEmail(): ?bool + { + return $this->acceptEmail; + } + + public function setAcceptEmail(bool $acceptEmail): self + { + $this->acceptEmail = $acceptEmail; + + return $this; + } + + public function getNumberOfChildren(): ?int + { + return $this->numberOfChildren; + } + + public function setNumberOfChildren(int $numberOfChildren): self + { + $this->numberOfChildren = $numberOfChildren; + + return $this; + } + } diff --git a/src/Bundle/ChillPersonBundle/Form/Type/GenderType.php b/src/Bundle/ChillPersonBundle/Form/Type/GenderType.php index bdd31e899..232c838bb 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/GenderType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/GenderType.php @@ -24,7 +24,8 @@ class GenderType extends AbstractType { $a = array( Person::MALE_GENDER => Person::MALE_GENDER, Person::FEMALE_GENDER => Person::FEMALE_GENDER, - Person::BOTH_GENDER => Person::BOTH_GENDER + Person::BOTH_GENDER => Person::BOTH_GENDER, + Person::NO_INFORMATION => Person::NO_INFORMATION ); $resolver->setDefaults(array( diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20210617073504.php b/src/Bundle/ChillPersonBundle/migrations/Version20210617073504.php new file mode 100644 index 000000000..3a936e287 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/migrations/Version20210617073504.php @@ -0,0 +1,49 @@ +addSql('ALTER TABLE chill_person_person ADD deathdate DATE DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_person_person ADD maritalStatusDate DATE DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_person_person ADD acceptSMS BOOLEAN DEFAULT false NOT NULL'); + $this->addSql('ALTER TABLE chill_person_person ADD acceptEmail BOOLEAN DEFAULT false NOT NULL'); + $this->addSql('ALTER TABLE chill_person_person ADD numberOfChildren INT DEFAULT 0 NOT NULL'); + $this->addSql('ALTER TABLE chill_person_person ADD genderComment_comment TEXT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_person_person ADD genderComment_userId INT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_person_person ADD genderComment_date TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_person_person ADD maritalStatusComment_comment TEXT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_person_person ADD maritalStatusComment_userId INT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_person_person ADD maritalStatusComment_date TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_person_person DROP deathdate'); + $this->addSql('ALTER TABLE chill_person_person DROP maritalStatusDate'); + $this->addSql('ALTER TABLE chill_person_person DROP acceptSMS'); + $this->addSql('ALTER TABLE chill_person_person DROP acceptEmail'); + $this->addSql('ALTER TABLE chill_person_person DROP numberOfChildren'); + $this->addSql('ALTER TABLE chill_person_person DROP genderComment_comment'); + $this->addSql('ALTER TABLE chill_person_person DROP genderComment_userId'); + $this->addSql('ALTER TABLE chill_person_person DROP genderComment_date'); + $this->addSql('ALTER TABLE chill_person_person DROP maritalStatusComment_comment'); + $this->addSql('ALTER TABLE chill_person_person DROP maritalStatusComment_userId'); + $this->addSql('ALTER TABLE chill_person_person DROP maritalStatusComment_date'); + } +} diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index df1ef996f..cd65950a0 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -56,6 +56,8 @@ Man: Homme Woman: Femme both: Indéterminé Both: Indéterminé +unknown: Aucune information +Unknown: Aucune information Divorced: Divorcé(e) Separated: Séparé(e) Widow: Veuf(ve) From 901ae47ce6062754bc2d94b43e5dfacd25c6e6bd Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 17 Jun 2021 11:12:40 +0200 Subject: [PATCH 02/10] person: correct migration + entity --- src/Bundle/ChillPersonBundle/Entity/Person.php | 2 +- .../ChillPersonBundle/migrations/Version20210617073504.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php index f44cb1c30..f812739c4 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person.php @@ -293,7 +293,7 @@ class Person implements HasCenterInterface * Number of children * @var int * - * @ORM\Column(type="integer", options={"default" : 0}) + * @ORM\Column(type="integer", nullable=true) */ private $numberOfChildren; diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20210617073504.php b/src/Bundle/ChillPersonBundle/migrations/Version20210617073504.php index 3a936e287..f9e96697d 100644 --- a/src/Bundle/ChillPersonBundle/migrations/Version20210617073504.php +++ b/src/Bundle/ChillPersonBundle/migrations/Version20210617073504.php @@ -23,7 +23,7 @@ final class Version20210617073504 extends AbstractMigration $this->addSql('ALTER TABLE chill_person_person ADD maritalStatusDate DATE DEFAULT NULL'); $this->addSql('ALTER TABLE chill_person_person ADD acceptSMS BOOLEAN DEFAULT false NOT NULL'); $this->addSql('ALTER TABLE chill_person_person ADD acceptEmail BOOLEAN DEFAULT false NOT NULL'); - $this->addSql('ALTER TABLE chill_person_person ADD numberOfChildren INT DEFAULT 0 NOT NULL'); + $this->addSql('ALTER TABLE chill_person_person ADD numberOfChildren INT DEFAULT NULL'); $this->addSql('ALTER TABLE chill_person_person ADD genderComment_comment TEXT DEFAULT NULL'); $this->addSql('ALTER TABLE chill_person_person ADD genderComment_userId INT DEFAULT NULL'); $this->addSql('ALTER TABLE chill_person_person ADD genderComment_date TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL'); From 8406c30c8e9f7883a05f4dc7f5c7c38e5952b158 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 17 Jun 2021 12:27:47 +0200 Subject: [PATCH 03/10] person: Person FormType + edit twig --- .../ChillPersonBundle/Form/PersonType.php | 36 ++++++++++++++++--- .../Resources/views/Person/edit.html.twig | 9 +++++ .../translations/messages.fr.yml | 6 ++++ 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Form/PersonType.php b/src/Bundle/ChillPersonBundle/Form/PersonType.php index 42c625baa..d576822a9 100644 --- a/src/Bundle/ChillPersonBundle/Form/PersonType.php +++ b/src/Bundle/ChillPersonBundle/Form/PersonType.php @@ -34,9 +34,12 @@ use Chill\PersonBundle\Entity\PersonPhone; use Chill\PersonBundle\Form\Type\Select2MaritalStatusType; use Symfony\Component\Form\AbstractType; use Chill\MainBundle\Form\Type\ChillDateType; +use Chill\MainBundle\Form\Type\CommentType; use Symfony\Component\Form\Extension\Core\Type\EmailType; use Symfony\Component\Form\Extension\Core\Type\TelType; use Symfony\Component\Form\Extension\Core\Type\TextType; +use Symfony\Component\Form\Extension\Core\Type\IntegerType; +use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -82,8 +85,17 @@ class PersonType extends AbstractType ->add('birthdate', ChillDateType::class, [ 'required' => false, ]) + ->add('deathdate', ChillDateType::class, [ + 'required' => false, + ]) ->add('gender', GenderType::class, array( 'required' => true + )) + ->add('genderComment', CommentType::class, array( + 'required' => false + )) + ->add('numberOfChildren', IntegerType::class, array( + 'required' => false )); if ($this->configAltNamesHelper->hasAltNames()) { @@ -111,7 +123,12 @@ class PersonType extends AbstractType } if ($this->config['mobilenumber'] === 'visible') { - $builder->add('mobilenumber', TelType::class, array('required' => false)); + $builder + ->add('mobilenumber', TelType::class, array('required' => false)) + ->add('acceptSMS', CheckboxType::class, array( + 'value' => false, + 'required' => true //TODO required only if mobilenumber is filled + )); } $builder->add('otherPhoneNumbers', ChillCollectionType::class, [ @@ -130,7 +147,9 @@ class PersonType extends AbstractType ]); if ($this->config['email'] === 'visible') { - $builder->add('email', EmailType::class, array('required' => false)); + $builder + ->add('email', EmailType::class, array('required' => false)) + ->add('acceptEmail', CheckboxType::class, array('required' => false));//TODO visible only if email is filled } if ($this->config['country_of_birth'] === 'visible') { @@ -153,9 +172,16 @@ class PersonType extends AbstractType } if ($this->config['marital_status'] === 'visible'){ - $builder->add('maritalStatus', Select2MaritalStatusType::class, array( - 'required' => false - )); + $builder + ->add('maritalStatus', Select2MaritalStatusType::class, array( + 'required' => false + )) + ->add('maritalStatusDate', ChillDateType::class, array( + 'required' => false + )) + ->add('maritalStatusComment', CommentType::class, array( + 'required' => false + )); } if($options['cFGroup']) { diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Person/edit.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Person/edit.html.twig index a69253695..66e1cb6e6 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Person/edit.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Person/edit.html.twig @@ -43,6 +43,7 @@ {{ form_widget(form.altNames, { 'label': 'Alternative names'}) }} {% endif %} {{ form_row(form.gender, {'label' : 'Gender'}) }} + {{ form_row(form.genderComment, { 'label' : 'Comment on the gender'} ) }}
@@ -54,6 +55,9 @@ {%- if form.countryOfBirth is defined -%} {{ form_row(form.countryOfBirth, { 'label' : 'Country of birth' } ) }} {%- endif -%} + {%- if form.deathdate is defined -%} + {{ form_row(form.deathdate, { 'label' : 'Date of death' } ) }} + {%- endif -%}
{%- if form.nationality is defined or form.spokenLanguages is defined or form.maritalStatus is defined -%} @@ -65,8 +69,11 @@ {%- if form.spokenLanguages is defined -%} {{ form_row(form.spokenLanguages, {'label' : 'Spoken languages'}) }} {%- endif -%} + {{ form_row(form.numberOfChildren, {'label' : 'Number of children'}) }} {%- if form.maritalStatus is defined -%} {{ form_row(form.maritalStatus, { 'label' : 'Marital status'} ) }} + {{ form_row(form.maritalStatusDate, { 'label' : 'Date of last marital status change'} ) }} + {{ form_row(form.maritalStatusComment, { 'label' : 'Comment on the marital status'} ) }} {%- endif -%} {%- endif -%} @@ -76,12 +83,14 @@

{{ 'Contact information'|trans }}

{%- if form.email is defined -%} {{ form_row(form.email, {'label': 'Email'}) }} + {{ form_row(form.acceptEmail, {'label' : 'Accept emails ?'}) }} {%- endif -%} {%- if form.phonenumber is defined -%} {{ form_row(form.phonenumber, {'label': 'Phonenumber'}) }} {%- endif -%} {%- if form.mobilenumber is defined -%} {{ form_row(form.mobilenumber, {'label': 'Mobilenumber'}) }} + {{ form_row(form.acceptSMS, {'label' : 'Accept short text message ?'}) }} {%- endif -%} {%- if form.otherPhoneNumbers is defined -%} {{ form_widget(form.otherPhoneNumbers) }} diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index cd65950a0..e6f33355c 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -10,6 +10,8 @@ First name or Last name: Prénom ou nom id: identifiant Birthdate: 'Date de naissance' birthdate: date de naissance +deathdate: date de décès +Date of death: Date de décès 'Date of birth': 'Date de naissance' dateOfBirth: date de naissance dateofbirth: date de naissance @@ -30,16 +32,20 @@ placeOfBirth: lieu de naissance countryOfBirth: 'Pays de naissance' 'Unknown country of birth': 'Pays inconnu' 'Marital status': 'État civil' +Date of last marital status change: État civil depuis le +Comment on the marital status: Commentaires sur l'état civil 'Number of children': 'Nombre d''enfants' '{0} No child|{1} One child | ]1,Inf] %nb% children': '{0} Aucun enfant|{1} Un enfant | ]1,Inf] %nb% enfants' 'National number': 'Numéro national' Email: 'Courrier électronique' +Accept emails ?: Accepte les courriels? Address: Adresse Memo: Mémo Phonenumber: 'Numéro de téléphone' phonenumber: numéro de téléphone Mobilenumber: 'Numéro de téléphone portable' mobilenumber: numéro de téléphone portable +Accept short text message ?: Accepte les SMS? Other phonenumber: Autre numéro de téléphone Description: description Add new phone: Ajouter un numéro de téléphone From 585a19e8036bdfab542066995eeeb6bcee97932d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 18 Jun 2021 07:17:32 +0000 Subject: [PATCH 04/10] Apply 7 suggestion(s) to 1 file(s) --- src/Bundle/ChillPersonBundle/Entity/Person.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php index f812739c4..056efc388 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person.php @@ -105,9 +105,9 @@ class Person implements HasCenterInterface * The person's deathdate * @var \DateTime * - * @ORM\Column(type="date", nullable=true) + * @ORM\Column(type="date_immutable", nullable=true) */ - private $deathdate; + private ?\DateTimeImmutable $deathdate; /** * The person's place of birth @@ -159,7 +159,7 @@ class Person implements HasCenterInterface * @var CommentEmbeddable * @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="genderComment_") */ - private $genderComment; + private CommentEmbeddable $genderComment; /** * The marital status of the person @@ -183,7 +183,7 @@ class Person implements HasCenterInterface * @var CommentEmbeddable * @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="maritalStatusComment_") */ - private $maritalStatusComment; + private CommentEmbeddable $maritalStatusComment; /** * Contact information for contacting the person @@ -279,7 +279,7 @@ class Person implements HasCenterInterface * * @ORM\Column(type="boolean", options={"default" : false}) */ - private $acceptSMS; + private ?bool $acceptSMS = null; /** * Accept receiving email @@ -287,7 +287,7 @@ class Person implements HasCenterInterface * * @ORM\Column(type="boolean", options={"default" : false}) */ - private $acceptEmail; + private ?bool $acceptEmail = null; /** * Number of children @@ -295,7 +295,7 @@ class Person implements HasCenterInterface * * @ORM\Column(type="integer", nullable=true) */ - private $numberOfChildren; + private ?int $numberOfChildren = null; /** * @var boolean From bccaf5ad6eb037bca19d9df04cd8c3726ae07e2b Mon Sep 17 00:00:00 2001 From: nobohan Date: Fri, 18 Jun 2021 10:15:30 +0200 Subject: [PATCH 05/10] person: add createdBY, updatedBy fields on Person + migration --- .../ChillPersonBundle/Entity/Person.php | 62 ++++++++++++++++++- .../migrations/Version20210618080702.php | 45 ++++++++++++++ 2 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/migrations/Version20210618080702.php diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php index 056efc388..1eaffa526 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person.php @@ -23,9 +23,11 @@ namespace Chill\PersonBundle\Entity; */ use ArrayIterator; +use Chill\MainBundle\Doctrine\Model\TrackCreationInterface; +use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface; use Chill\MainBundle\Entity\Center; use Chill\MainBundle\Entity\Country; -use Chill\MainBundle\Entity\Language; +use Chill\MainBundle\Entity\User; use Chill\PersonBundle\Entity\Household\Household; use Chill\PersonBundle\Entity\MaritalStatus; use Chill\PersonBundle\Entity\Household\HouseholdMember; @@ -54,7 +56,7 @@ use Symfony\Component\Serializer\Annotation\DiscriminatorMap; * "person"=Person::class * }) */ -class Person implements HasCenterInterface +class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateInterface { /** * The person's id @@ -297,6 +299,29 @@ class Person implements HasCenterInterface */ private ?int $numberOfChildren = null; + /** + * @ORM\ManyToOne(targetEntity=User::class) + * @ORM\JoinColumn(nullable=true) + */ + private $createdBy; + + /** + * @ORM\Column(type="datetime", nullable=true, options={"default": NULL}) + */ + private \DateTimeInterface $createdAt; + + /** + * @ORM\ManyToOne( + * targetEntity=User::class + * ) + */ + private User $updatedBy; + + /** + * @ORM\Column(type="datetime", nullable=true, options={"default": NULL}) + */ + private \DateTimeInterface $updatedAt; + /** * @var boolean * @deprecated @@ -1392,4 +1417,37 @@ class Person implements HasCenterInterface return $this; } + public function getCreatedBy(): ?User + { + return $this->createdBy; + } + + public function setCreatedBy(User $createdBy): self + { + $this->createdBy = $createdBy; + + return $this; + } + + public function setCreatedAt(\DateTimeInterface $datetime): self + { + $this->createdAt = $datetime; + + return $this; + } + + public function setUpdatedBy(User $user): self + { + $this->updatedBy = $user; + + return $this; + } + + public function setUpdatedAt(\DateTimeInterface $datetime): self + { + $this->updatedAt = $datetime; + + return $this; + } + } diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20210618080702.php b/src/Bundle/ChillPersonBundle/migrations/Version20210618080702.php new file mode 100644 index 000000000..93c6b8bf0 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/migrations/Version20210618080702.php @@ -0,0 +1,45 @@ +addSql('ALTER TABLE chill_person_person ADD createdAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_person_person ADD updatedAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_person_person ADD createdBy_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_person_person ADD updatedBy_id INT DEFAULT NULL'); + $this->addSql('COMMENT ON COLUMN chill_person_person.deathdate IS \'(DC2Type:date_immutable)\''); + $this->addSql('ALTER TABLE chill_person_person ADD CONSTRAINT FK_BF210A143174800F FOREIGN KEY (createdBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_person_person ADD CONSTRAINT FK_BF210A1465FF1AEC FOREIGN KEY (updatedBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('CREATE INDEX IDX_BF210A143174800F ON chill_person_person (createdBy_id)'); + $this->addSql('CREATE INDEX IDX_BF210A1465FF1AEC ON chill_person_person (updatedBy_id)'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_person_person DROP CONSTRAINT FK_BF210A143174800F'); + $this->addSql('ALTER TABLE chill_person_person DROP CONSTRAINT FK_BF210A1465FF1AEC'); + $this->addSql('DROP INDEX IDX_BF210A143174800F'); + $this->addSql('DROP INDEX IDX_BF210A1465FF1AEC'); + $this->addSql('ALTER TABLE chill_person_person DROP createdAt'); + $this->addSql('ALTER TABLE chill_person_person DROP updatedAt'); + $this->addSql('ALTER TABLE chill_person_person DROP createdBy_id'); + $this->addSql('ALTER TABLE chill_person_person DROP updatedBy_id'); + $this->addSql('COMMENT ON COLUMN chill_person_person.deathdate IS NULL'); + } +} From 3d14f00cac2e8da4d7b1f92737d4b138bef30e4e Mon Sep 17 00:00:00 2001 From: nobohan Date: Fri, 18 Jun 2021 11:28:02 +0200 Subject: [PATCH 06/10] person: add show hide on some fields + remove unknown genderType --- .../ChillPersonBundle/Form/PersonType.php | 4 +- .../Form/Type/GenderType.php | 3 +- .../Resources/public/js/person.js | 38 +++++++++++++++++++ .../Resources/views/Person/edit.html.twig | 22 +++++++++-- .../ChillPersonBundle/chill.webpack.config.js | 3 +- .../translations/messages.fr.yml | 2 - 6 files changed, 61 insertions(+), 11 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Resources/public/js/person.js diff --git a/src/Bundle/ChillPersonBundle/Form/PersonType.php b/src/Bundle/ChillPersonBundle/Form/PersonType.php index d576822a9..0e3bedce5 100644 --- a/src/Bundle/ChillPersonBundle/Form/PersonType.php +++ b/src/Bundle/ChillPersonBundle/Form/PersonType.php @@ -127,7 +127,7 @@ class PersonType extends AbstractType ->add('mobilenumber', TelType::class, array('required' => false)) ->add('acceptSMS', CheckboxType::class, array( 'value' => false, - 'required' => true //TODO required only if mobilenumber is filled + 'required' => true )); } @@ -149,7 +149,7 @@ class PersonType extends AbstractType if ($this->config['email'] === 'visible') { $builder ->add('email', EmailType::class, array('required' => false)) - ->add('acceptEmail', CheckboxType::class, array('required' => false));//TODO visible only if email is filled + ->add('acceptEmail', CheckboxType::class, array('required' => false)); } if ($this->config['country_of_birth'] === 'visible') { diff --git a/src/Bundle/ChillPersonBundle/Form/Type/GenderType.php b/src/Bundle/ChillPersonBundle/Form/Type/GenderType.php index 232c838bb..bdd31e899 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/GenderType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/GenderType.php @@ -24,8 +24,7 @@ class GenderType extends AbstractType { $a = array( Person::MALE_GENDER => Person::MALE_GENDER, Person::FEMALE_GENDER => Person::FEMALE_GENDER, - Person::BOTH_GENDER => Person::BOTH_GENDER, - Person::NO_INFORMATION => Person::NO_INFORMATION + Person::BOTH_GENDER => Person::BOTH_GENDER ); $resolver->setDefaults(array( diff --git a/src/Bundle/ChillPersonBundle/Resources/public/js/person.js b/src/Bundle/ChillPersonBundle/Resources/public/js/person.js new file mode 100644 index 000000000..6ebd8d7cc --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/public/js/person.js @@ -0,0 +1,38 @@ +import { ShowHide } from 'ShowHide/show_hide.js'; + +const personEmail = document.getElementById("personEmail"); +const personAcceptEmail = document.getElementById("personAcceptEmail"); +const personPhoneNumber = document.getElementById("personPhoneNumber"); +const personAcceptSMS = document.getElementById("personAcceptSMS"); + +new ShowHide({ + froms: [personEmail], + container: [personAcceptEmail], + test: function(froms) { + for (let f of froms.values()) { + for (let input of f.querySelectorAll('input').values()) { + if (input.value) { + return true + } + } + } + return false; + }, + event_name: 'input' +}); + +new ShowHide({ + froms: [personPhoneNumber], + container: [personAcceptSMS], + test: function(froms) { + for (let f of froms.values()) { + for (let input of f.querySelectorAll('input').values()) { + if (input.value) { + return true + } + } + } + return false; + }, + event_name: 'input' +}); diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Person/edit.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Person/edit.html.twig index 66e1cb6e6..95b4e6f62 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Person/edit.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Person/edit.html.twig @@ -82,15 +82,24 @@

{{ 'Contact information'|trans }}

{%- if form.email is defined -%} - {{ form_row(form.email, {'label': 'Email'}) }} - {{ form_row(form.acceptEmail, {'label' : 'Accept emails ?'}) }} +
+ {{ form_row(form.email, {'label': 'Email'}) }} +
+
+ {{ form_row(form.acceptEmail, {'label' : 'Accept emails ?'}) }} +
{%- endif -%} + {%- if form.phonenumber is defined -%} {{ form_row(form.phonenumber, {'label': 'Phonenumber'}) }} {%- endif -%} {%- if form.mobilenumber is defined -%} - {{ form_row(form.mobilenumber, {'label': 'Mobilenumber'}) }} - {{ form_row(form.acceptSMS, {'label' : 'Accept short text message ?'}) }} +
+ {{ form_row(form.mobilenumber, {'label': 'Mobilenumber'}) }} +
+
+ {{ form_row(form.acceptSMS, {'label' : 'Accept short text message ?'}) }} +
{%- endif -%} {%- if form.otherPhoneNumbers is defined -%} {{ form_widget(form.otherPhoneNumbers) }} @@ -123,3 +132,8 @@ {% endblock personcontent %} + + +{% block js %} + +{% endblock js %} diff --git a/src/Bundle/ChillPersonBundle/chill.webpack.config.js b/src/Bundle/ChillPersonBundle/chill.webpack.config.js index f68481083..99028ecd8 100644 --- a/src/Bundle/ChillPersonBundle/chill.webpack.config.js +++ b/src/Bundle/ChillPersonBundle/chill.webpack.config.js @@ -7,8 +7,9 @@ module.exports = function(encore, entries) encore.addAliases({ ChillPersonAssets: __dirname + '/Resources/public' }); - + encore.addEntry('accompanying_course', __dirname + '/Resources/public/vuejs/AccompanyingCourse/index.js'); encore.addEntry('household_members_editor', __dirname + '/Resources/public/vuejs/HouseholdMembersEditor/index.js'); encore.addEntry('vue_accourse', __dirname + '/Resources/public/vuejs/AccompanyingCourse/index.js'); + encore.addEntry('person', __dirname + '/Resources/public/js/person.js'); }; diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index e6f33355c..ee5812571 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -62,8 +62,6 @@ Man: Homme Woman: Femme both: Indéterminé Both: Indéterminé -unknown: Aucune information -Unknown: Aucune information Divorced: Divorcé(e) Separated: Séparé(e) Widow: Veuf(ve) From 1a204312f39fd9079cfac62dc4b81777dab27033 Mon Sep 17 00:00:00 2001 From: nobohan Date: Fri, 18 Jun 2021 13:12:27 +0200 Subject: [PATCH 07/10] person: re-enable the creation of a person --- src/Bundle/ChillPersonBundle/Entity/Person.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php index 1eaffa526..6cf4b30b5 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person.php @@ -105,7 +105,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI /** * The person's deathdate - * @var \DateTime + * @var \DateTimeImmutable * * @ORM\Column(type="date_immutable", nullable=true) */ @@ -281,7 +281,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * * @ORM\Column(type="boolean", options={"default" : false}) */ - private ?bool $acceptSMS = null; + private ?bool $acceptSMS = false; /** * Accept receiving email @@ -289,7 +289,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * * @ORM\Column(type="boolean", options={"default" : false}) */ - private ?bool $acceptEmail = null; + private ?bool $acceptEmail = false; /** * Number of children From b3792f67147daedf9ab4ca487c9ec7e4678b251e Mon Sep 17 00:00:00 2001 From: nobohan Date: Fri, 18 Jun 2021 13:46:46 +0200 Subject: [PATCH 08/10] person: update person view/show twig --- .../DependencyInjection/Configuration.php | 3 +- .../Resources/views/Person/view.html.twig | 81 +++++++++++++++---- .../translations/messages.fr.yml | 3 + 3 files changed, 69 insertions(+), 18 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php index 3ebe3ceb1..927612d5f 100644 --- a/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php @@ -78,6 +78,7 @@ class Configuration implements ConfigurationInterface ->append($this->addFieldNode('address')) ->append($this->addFieldNode('accompanying_period')) ->append($this->addFieldNode('memo')) + ->append($this->addFieldNode('number_of_children')) ->arrayNode('alt_names') ->defaultValue([]) ->arrayPrototype() @@ -130,7 +131,7 @@ class Configuration implements ConfigurationInterface { $tree = new TreeBuilder($key,'enum'); $node = $tree->getRootNode($key); - + switch($key) { case 'accompanying_period': $info = "If the accompanying periods are shown"; diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Person/view.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Person/view.html.twig index 796a7f82e..6176864a0 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Person/view.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Person/view.html.twig @@ -73,12 +73,14 @@ This view should receive those arguments:
{{ 'Gender'|trans }} :
{{ ( person.gender|default('Not given'))|trans }}
+ + {% if not person.genderComment.isEmpty %} +
{{ 'Gender comment'|trans }} :
+
{{ person.genderComment|chill_entity_render_box }}
+ {% endif %} + - - {% if is_granted('CHILL_PERSON_UPDATE', person) %} - {{ include(edit_tmp_name, edit_tmp_args) }} - {% endif %} @@ -114,11 +116,14 @@ This view should receive those arguments: {% endif %} {% endapply %} {%- endif -%} + + {% if person.deathdate is not null %} +
{{ 'Date of death'|trans }} :
+
{{ person.deathdate|format_date('long') }}
+ {% endif %} + - {% if is_granted('CHILL_PERSON_UPDATE', person) %} - {{ include(edit_tmp_name, edit_tmp_args) }} - {% endif %} @@ -155,6 +160,21 @@ This view should receive those arguments: {%- endif -%} + + + {%-if chill_person.fields.number_of_children == 'visible' -%} +
+
{{'Number of children'|trans}} :
+
+ {% if person.numberOfChildren is not null %} + {{ person.numberOfChildren }} + {% else %} + {{ 'No data given'|trans }} + {% endif %} +
+
+ {%- endif -%} + {%- if chill_person.fields.marital_status == 'visible' -%}
{{'Marital status'|trans}} :
@@ -165,12 +185,21 @@ This view should receive those arguments: {{ 'No data given'|trans }} {% endif %} +
{{'Date of last marital status change'|trans}} :
+ {% if person.maritalStatusDate is not null %} +
+ {{ person.maritalStatusDate|format_date('long') }} +
+ {% endif %} + {% if not person.maritalStatusComment.isEmpty %} +
{{'Comment on the marital status'|trans}} :
+
+ {{ person.maritalStatusComment|chill_entity_render_box }} +
+ {% endif %}
{%- endif -%} - {% if is_granted('CHILL_PERSON_UPDATE', person) %} - {{ include(edit_tmp_name, edit_tmp_args) }} - {% endif %} {%- endif -%} @@ -213,6 +242,13 @@ This view should receive those arguments:
{{ 'Email'|trans }} :
{% if person.email is not empty %}{{ person.email }}{% else %}{{ 'No data given'|trans }}{% endif %}
+ {%- if person.email is not empty and person.acceptEmail -%} +
+ + {{- 'Accept emails'|trans -}} + +
+ {%- endif -%}
{%- endif -%} {%- if chill_person.fields.phonenumber == 'visible' -%} @@ -225,6 +261,13 @@ This view should receive those arguments:
{{ 'Mobilenumber'|trans }} :
{% if person.mobilenumber is not empty %}
{{ person.mobilenumber|chill_format_phonenumber }}
{% else %}{{ 'No data given'|trans }}{% endif %}
+ {%- if person.mobilenumber is not empty and person.acceptSMS -%} +
+ + {{- 'Accept short text message'|trans -}} + +
+ {%- endif -%}
{% endif %} {% for pp in person.otherPhoneNumbers %} @@ -253,9 +296,6 @@ This view should receive those arguments: {%- endif -%} - {% if is_granted('CHILL_PERSON_UPDATE', person) %} - {{ include(edit_tmp_name, edit_tmp_args) }} - {% endif %} {%- endif -%} @@ -272,14 +312,21 @@ This view should receive those arguments:
- - {% if is_granted('CHILL_PERSON_UPDATE', person) %} - {{ include(edit_tmp_name, edit_tmp_args) }} - {% endif %}
{% endif %} +{% if is_granted('CHILL_PERSON_UPDATE', person) %} + +{% endif %} + {% endblock %} diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index ee5812571..fbfc35f82 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -23,6 +23,7 @@ nationality: nationalité 'Without nationality': 'Sans nationalité' Gender: Genre gender: genre +Gender comment: Remarque sur le genre 'Creation date': 'Date d''ouverture' 'Not given': 'Non renseigné' 'Place of birth': 'Lieu de naissance' @@ -39,6 +40,7 @@ Comment on the marital status: Commentaires sur l'état civil 'National number': 'Numéro national' Email: 'Courrier électronique' Accept emails ?: Accepte les courriels? +Accept emails: Peut être contacté par email Address: Adresse Memo: Mémo Phonenumber: 'Numéro de téléphone' @@ -46,6 +48,7 @@ phonenumber: numéro de téléphone Mobilenumber: 'Numéro de téléphone portable' mobilenumber: numéro de téléphone portable Accept short text message ?: Accepte les SMS? +Accept short text message: Accepte les SMS Other phonenumber: Autre numéro de téléphone Description: description Add new phone: Ajouter un numéro de téléphone From 504b2efacfbe43342bfd0e39c74634dbff2ab036 Mon Sep 17 00:00:00 2001 From: nobohan Date: Mon, 21 Jun 2021 13:58:14 +0200 Subject: [PATCH 09/10] person: fix death date type as date immutable --- src/Bundle/ChillPersonBundle/Form/PersonType.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Form/PersonType.php b/src/Bundle/ChillPersonBundle/Form/PersonType.php index 0e3bedce5..376310965 100644 --- a/src/Bundle/ChillPersonBundle/Form/PersonType.php +++ b/src/Bundle/ChillPersonBundle/Form/PersonType.php @@ -40,6 +40,7 @@ use Symfony\Component\Form\Extension\Core\Type\TelType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\IntegerType; use Symfony\Component\Form\Extension\Core\Type\CheckboxType; +use Symfony\Component\Form\Extension\Core\Type\DateType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -85,8 +86,10 @@ class PersonType extends AbstractType ->add('birthdate', ChillDateType::class, [ 'required' => false, ]) - ->add('deathdate', ChillDateType::class, [ + ->add('deathdate', DateType::class, [ 'required' => false, + 'input' => 'datetime_immutable', + 'widget' => 'single_text' ]) ->add('gender', GenderType::class, array( 'required' => true From c23ada3533c606d9e7b64a491986e00d400c8162 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 24 Jun 2021 08:25:55 +0200 Subject: [PATCH 10/10] person: add show/hide on marital status date --- .../Resources/public/js/person.js | 19 +++++++++++++++++++ .../Resources/views/Person/edit.html.twig | 18 ++++++++++++++---- .../Resources/views/Person/view.html.twig | 4 ++++ 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/js/person.js b/src/Bundle/ChillPersonBundle/Resources/public/js/person.js index 6ebd8d7cc..da40dddc7 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/js/person.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/js/person.js @@ -1,10 +1,29 @@ import { ShowHide } from 'ShowHide/show_hide.js'; +const maritalStatus = document.getElementById("maritalStatus"); +const maritalStatusDate = document.getElementById("maritalStatusDate"); const personEmail = document.getElementById("personEmail"); const personAcceptEmail = document.getElementById("personAcceptEmail"); const personPhoneNumber = document.getElementById("personPhoneNumber"); const personAcceptSMS = document.getElementById("personAcceptSMS"); + +new ShowHide({ + froms: [maritalStatus], + container: [maritalStatusDate], + test: function(froms) { + for (let f of froms.values()) { + for (let input of f.querySelectorAll('select').values()) { + if (input.value) { + return true + } + } + } + return false; + }, + event_name: 'change' +}); + new ShowHide({ froms: [personEmail], container: [personAcceptEmail], diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Person/edit.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Person/edit.html.twig index 95b4e6f62..549025429 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Person/edit.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Person/edit.html.twig @@ -60,7 +60,7 @@ {%- endif -%}
-{%- if form.nationality is defined or form.spokenLanguages is defined or form.maritalStatus is defined -%} +{%- if form.nationality is defined or form.spokenLanguages is defined -%}

{{ 'Administrative information'|trans }}

{%- if form.nationality is defined -%} @@ -69,11 +69,21 @@ {%- if form.spokenLanguages is defined -%} {{ form_row(form.spokenLanguages, {'label' : 'Spoken languages'}) }} {%- endif -%} +
+{%- endif -%} + +{%- if form.numberOfChildren is defined or form.maritalStatus is defined -%} +
+

{{ 'Marital status'|trans }}

{{ form_row(form.numberOfChildren, {'label' : 'Number of children'}) }} {%- if form.maritalStatus is defined -%} - {{ form_row(form.maritalStatus, { 'label' : 'Marital status'} ) }} - {{ form_row(form.maritalStatusDate, { 'label' : 'Date of last marital status change'} ) }} - {{ form_row(form.maritalStatusComment, { 'label' : 'Comment on the marital status'} ) }} +
+ {{ form_row(form.maritalStatus, { 'label' : 'Marital status'} ) }} +
+
+ {{ form_row(form.maritalStatusDate, { 'label' : 'Date of last marital status change'} ) }} + {{ form_row(form.maritalStatusComment, { 'label' : 'Comment on the marital status'} ) }} +
{%- endif -%}
{%- endif -%} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Person/view.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Person/view.html.twig index 6176864a0..76c6437d5 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Person/view.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Person/view.html.twig @@ -185,12 +185,16 @@ This view should receive those arguments: {{ 'No data given'|trans }} {% endif %} + +
{{'Date of last marital status change'|trans}} :
{% if person.maritalStatusDate is not null %}
{{ person.maritalStatusDate|format_date('long') }}
{% endif %} +
+
{% if not person.maritalStatusComment.isEmpty %}
{{'Comment on the marital status'|trans}} :