From 951160982d27a06a8f72d1fc1f22f7454cd6780d Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 17 Jun 2021 10:43:57 +0200 Subject: [PATCH] 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)