mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
person: add more fields on Person + migration
This commit is contained in:
parent
1b9d8fab61
commit
951160982d
@ -25,11 +25,13 @@ namespace Chill\PersonBundle\Entity;
|
|||||||
use ArrayIterator;
|
use ArrayIterator;
|
||||||
use Chill\MainBundle\Entity\Center;
|
use Chill\MainBundle\Entity\Center;
|
||||||
use Chill\MainBundle\Entity\Country;
|
use Chill\MainBundle\Entity\Country;
|
||||||
|
use Chill\MainBundle\Entity\Language;
|
||||||
use Chill\PersonBundle\Entity\Household\Household;
|
use Chill\PersonBundle\Entity\Household\Household;
|
||||||
use Chill\PersonBundle\Entity\MaritalStatus;
|
use Chill\PersonBundle\Entity\MaritalStatus;
|
||||||
use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
||||||
use Chill\MainBundle\Entity\HasCenterInterface;
|
use Chill\MainBundle\Entity\HasCenterInterface;
|
||||||
use Chill\MainBundle\Entity\Address;
|
use Chill\MainBundle\Entity\Address;
|
||||||
|
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
@ -99,6 +101,14 @@ class Person implements HasCenterInterface
|
|||||||
*/
|
*/
|
||||||
private $birthdate; //to change in birthdate
|
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
|
* The person's place of birth
|
||||||
* @var string
|
* @var string
|
||||||
@ -142,6 +152,14 @@ class Person implements HasCenterInterface
|
|||||||
const MALE_GENDER = 'man';
|
const MALE_GENDER = 'man';
|
||||||
const FEMALE_GENDER = 'woman';
|
const FEMALE_GENDER = 'woman';
|
||||||
const BOTH_GENDER = 'both';
|
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
|
* The marital status of the person
|
||||||
@ -152,6 +170,21 @@ class Person implements HasCenterInterface
|
|||||||
*/
|
*/
|
||||||
private $maritalStatus;
|
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
|
* Contact information for contacting the person
|
||||||
* @var string
|
* @var string
|
||||||
@ -239,6 +272,31 @@ class Person implements HasCenterInterface
|
|||||||
*/
|
*/
|
||||||
private $memo = ''; // TO-CHANGE in remark
|
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
|
* @var boolean
|
||||||
* @deprecated
|
* @deprecated
|
||||||
@ -306,8 +364,10 @@ class Person implements HasCenterInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->open(new AccompanyingPeriod($opening));
|
$this->open(new AccompanyingPeriod($opening));
|
||||||
|
$this->genderComment = new CommentEmbeddable();
|
||||||
|
$this->maritalStatusComment = new CommentEmbeddable();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This private function scan accompanyingPeriodParticipations Collection,
|
* This private function scan accompanyingPeriodParticipations Collection,
|
||||||
* searching for a given AccompanyingPeriod
|
* searching for a given AccompanyingPeriod
|
||||||
@ -319,10 +379,10 @@ class Person implements HasCenterInterface
|
|||||||
if ($accompanyingPeriod === $participation->getAccompanyingPeriod()) {
|
if ($accompanyingPeriod === $participation->getAccompanyingPeriod()) {
|
||||||
return $participation;
|
return $participation;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This public function is the same but return only true or false
|
* 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;
|
return ($this->participationsContainAccompanyingPeriod($accompanyingPeriod)) ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add AccompanyingPeriodParticipation
|
* Add AccompanyingPeriodParticipation
|
||||||
*
|
*
|
||||||
@ -340,7 +400,7 @@ class Person implements HasCenterInterface
|
|||||||
{
|
{
|
||||||
$participation = new AccompanyingPeriodParticipation($accompanyingPeriod, $this);
|
$participation = new AccompanyingPeriodParticipation($accompanyingPeriod, $this);
|
||||||
$this->accompanyingPeriodParticipations->add($participation);
|
$this->accompanyingPeriodParticipations->add($participation);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -350,7 +410,7 @@ class Person implements HasCenterInterface
|
|||||||
public function removeAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod) : void
|
public function removeAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod) : void
|
||||||
{
|
{
|
||||||
$participation = $this->participationsContainAccompanyingPeriod($accompanyingPeriod);
|
$participation = $this->participationsContainAccompanyingPeriod($accompanyingPeriod);
|
||||||
|
|
||||||
if (! null === $participation) {
|
if (! null === $participation) {
|
||||||
$participation->setEndDate(\DateTimeImmutable::class);
|
$participation->setEndDate(\DateTimeImmutable::class);
|
||||||
$this->accompanyingPeriodParticipations->removeElement($participation);
|
$this->accompanyingPeriodParticipations->removeElement($participation);
|
||||||
@ -428,7 +488,7 @@ class Person implements HasCenterInterface
|
|||||||
}
|
}
|
||||||
return $accompanyingPeriods;
|
return $accompanyingPeriods;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get AccompanyingPeriodParticipations Collection
|
* Get AccompanyingPeriodParticipations Collection
|
||||||
*/
|
*/
|
||||||
@ -437,7 +497,7 @@ class Person implements HasCenterInterface
|
|||||||
return $this->accompanyingPeriodParticipations;
|
return $this->accompanyingPeriodParticipations;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a collection of participation, where the participation
|
* Return a collection of participation, where the participation
|
||||||
* is still opened, not a draft, and the period is still opened
|
* is still opened, not a draft, and the period is still opened
|
||||||
*/
|
*/
|
||||||
@ -455,9 +515,9 @@ class Person implements HasCenterInterface
|
|||||||
->filter(function (AccompanyingPeriodParticipation $app) {
|
->filter(function (AccompanyingPeriodParticipation $app) {
|
||||||
$period = $app->getAccompanyingPeriod();
|
$period = $app->getAccompanyingPeriod();
|
||||||
return (
|
return (
|
||||||
NULL === $period->getClosingDate()
|
NULL === $period->getClosingDate()
|
||||||
|| new \DateTime('now') < $period->getClosingDate()
|
|| new \DateTime('now') < $period->getClosingDate()
|
||||||
)
|
)
|
||||||
&& AccompanyingPeriod::STEP_DRAFT !== $period->getStep();
|
&& AccompanyingPeriod::STEP_DRAFT !== $period->getStep();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1185,12 +1245,12 @@ class Person implements HasCenterInterface
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFullnameCanonical() : string
|
public function getFullnameCanonical() : string
|
||||||
{
|
{
|
||||||
return $this->fullnameCanonical;
|
return $this->fullnameCanonical;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setFullnameCanonical($fullnameCanonical) : Person
|
public function setFullnameCanonical($fullnameCanonical) : Person
|
||||||
{
|
{
|
||||||
$this->fullnameCanonical = $fullnameCanonical;
|
$this->fullnameCanonical = $fullnameCanonical;
|
||||||
@ -1247,4 +1307,89 @@ class Person implements HasCenterInterface
|
|||||||
{
|
{
|
||||||
return NULL !== $this->getCurrentHousehold($at);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,8 @@ class GenderType extends AbstractType {
|
|||||||
$a = array(
|
$a = array(
|
||||||
Person::MALE_GENDER => Person::MALE_GENDER,
|
Person::MALE_GENDER => Person::MALE_GENDER,
|
||||||
Person::FEMALE_GENDER => Person::FEMALE_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(
|
$resolver->setDefaults(array(
|
||||||
|
@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\Migrations\Person;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add new fields to Person entity
|
||||||
|
*/
|
||||||
|
final class Version20210617073504 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return 'Add new fields to Person entity';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->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');
|
||||||
|
}
|
||||||
|
}
|
@ -56,6 +56,8 @@ Man: Homme
|
|||||||
Woman: Femme
|
Woman: Femme
|
||||||
both: Indéterminé
|
both: Indéterminé
|
||||||
Both: Indéterminé
|
Both: Indéterminé
|
||||||
|
unknown: Aucune information
|
||||||
|
Unknown: Aucune information
|
||||||
Divorced: Divorcé(e)
|
Divorced: Divorcé(e)
|
||||||
Separated: Séparé(e)
|
Separated: Séparé(e)
|
||||||
Widow: Veuf(ve)
|
Widow: Veuf(ve)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user