diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonController.php b/src/Bundle/ChillPersonBundle/Controller/PersonController.php index 747299e59..f33e9cce8 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonController.php @@ -252,18 +252,6 @@ final class PersonController extends AbstractController */ $person = $form->getData(); - $periods = $person->getAccompanyingPeriodsOrdered(); - $period = $periods[0]; - $period->setOpeningDate($form['creation_date']->getData()); -// $person = new Person($form['creation_date']->getData()); -// -// $person->setFirstName($form['firstName']->getData()) -// ->setLastName($form['lastName']->getData()) -// ->setGender($form['gender']->getData()) -// ->setBirthdate($form['birthdate']->getData()) -// ->setCenter($form['center']->getData()) -// ; - return $person; } @@ -364,7 +352,6 @@ final class PersonController extends AbstractController 'lastName' => $form['lastName']->getData(), 'birthdate' => $form['birthdate']->getData(), 'gender' => $form['gender']->getData(), - 'creation_date' => $form['creation_date']->getData(), 'form' => $form->createView())); } diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php index e8697ff28..556d832c1 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php @@ -183,6 +183,14 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con private function addAPerson(array $person, ObjectManager $manager) { $p = new Person(); + $p->addAccompanyingPeriod( + new AccompanyingPeriod( + (new \DateTime()) + ->sub( + new \DateInterval('P'.\random_int(0, 180).'D') + ) + ) + ); foreach ($person as $key => $value) { switch ($key) { diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php index 7f9805f52..695970bfa 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person.php @@ -379,12 +379,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI */ private Collection $householdAddresses; - /** - * Person constructor. - * - * @param \DateTime|null $opening - */ - public function __construct(\DateTime $opening = null) + public function __construct() { $this->accompanyingPeriodParticipations = new ArrayCollection(); $this->spokenLanguages = new ArrayCollection(); @@ -393,12 +388,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI $this->otherPhoneNumbers = new ArrayCollection(); $this->householdParticipations = new ArrayCollection(); $this->householdAddresses = new ArrayCollection(); - - if ($opening === null) { - $opening = new \DateTime(); - } - - $this->open(new AccompanyingPeriod($opening)); $this->genderComment = new CommentEmbeddable(); $this->maritalStatusComment = new CommentEmbeddable(); } diff --git a/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php b/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php index e3583071f..c001185ca 100644 --- a/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php +++ b/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php @@ -26,7 +26,7 @@ use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer; use Symfony\Component\Form\Extension\Core\Type\HiddenType; -use Symfony\Component\Form\Extension\Core\Type\DateType; +use Chill\MainBundle\Form\Type\ChillDateType; use Chill\MainBundle\Form\Type\CenterType; use Chill\PersonBundle\Form\Type\GenderType; use Chill\MainBundle\Form\Type\DataTransformer\CenterTransformer; @@ -80,9 +80,6 @@ final class CreationPersonType extends AbstractType 'property_path' => 'birthdate' )) ->add('gender', HiddenType::class) - ->add('creation_date', HiddenType::class, array( - 'mapped' => false - )) ->add('form_status', HiddenType::class, array( 'mapped' => false, 'data' => $options['form_status'] @@ -99,25 +96,18 @@ final class CreationPersonType extends AbstractType $builder->get('birthdate') ->addModelTransformer($dateToStringTransformer); - $builder->get('creation_date') - ->addModelTransformer($dateToStringTransformer); $builder->get('center') ->addModelTransformer($this->centerTransformer); } else { $builder ->add('firstName') ->add('lastName') - ->add('birthdate', DateType::class, array('required' => false, - 'widget' => 'single_text', 'format' => 'dd-MM-yyyy')) + ->add('birthdate', ChillDateType::class, [ + 'required' => false, + ]) ->add('gender', GenderType::class, array( 'required' => true, 'placeholder' => null )) - ->add('creation_date', DateType::class, array( - 'required' => true, - 'widget' => 'single_text', - 'format' => 'dd-MM-yyyy', - 'mapped' => false, - 'data' => new \DateTime())) ->add('form_status', HiddenType::class, array( 'data' => $options['form_status'], 'mapped' => false diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Person/create.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Person/create.html.twig index 9d17cba9d..e7a6fb4a6 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Person/create.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Person/create.html.twig @@ -1,7 +1,6 @@ {# * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, - * - * This program is free software: you can redistribute it and/or modify + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. @@ -38,8 +37,6 @@ {{ form_row(form.birthdate, { 'label' : 'Date of birth'|trans }) }} {{ form_row(form.gender, { 'label' : 'Gender'|trans }) }} - - {{ form_row(form.creation_date, { 'label' : 'Creation date'|trans }) }} {{ form_rest(form) }} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Person/create_review.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Person/create_review.html.twig index 8c5b6eb35..cd32c180c 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Person/create_review.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Person/create_review.html.twig @@ -71,14 +71,15 @@
{{ person|chill_entity_render_string }}
{{ 'Date of birth'|trans }}
-
{{ birthdate|format_date('long')|default( 'Unknown date of birth'|trans ) }}
+ {% if birthdate is empty %} +
{{ 'Unknown date of birth'|trans }}
+ {% else %} +
{{ birthdate|format_date('long') }}
+ {% endif %}
{{ 'Gender'|trans }}
{{ gender|trans }}
-
{{ 'Creation date'|trans }}
-
{{ creation_date|format_date('long') }}
- {% if form.altNames is defined %} {# mark as rendered #} {{ form_widget(form.altNames) }} @@ -86,10 +87,13 @@ {{ form_rest(form) }} - + {{ form_end(form) }} -