diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 8b4c43f7c..860a8b703 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -12,7 +12,7 @@ use Symfony\Component\Config\Definition\ConfigurationInterface; */ class Configuration implements ConfigurationInterface { - + private $validationBirthdateNotAfterInfos = "The period before today during which" . " any birthdate is not allowed. The birthdate is expressed as ISO8601 : " . "https://en.wikipedia.org/wiki/ISO_8601#Durations"; @@ -23,7 +23,7 @@ class Configuration implements ConfigurationInterface { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('cl_chill_person'); - + $rootNode ->canBeDisabled() ->children() @@ -50,14 +50,14 @@ class Configuration implements ConfigurationInterface $interval = new \DateInterval($period); } catch (\Exception $ex) { return true; - } + } return false; }) ->thenInvalid('Invalid period for birthdate validation : "%s" ' . 'The parameter should match duration as defined by ISO8601 : ' . 'https://en.wikipedia.org/wiki/ISO_8601#Durations') ->end() // birthdate_not_after, parent = children of validation - + ->end() // children for 'validation', parent = validation ->end() //validation, parent = children of root ->end() // children of root, parent = root @@ -67,6 +67,8 @@ class Configuration implements ConfigurationInterface ->append($this->addFieldNode('place_of_birth')) ->append($this->addFieldNode('email')) ->append($this->addFieldNode('phonenumber')) + ->append($this->addFieldNode('mobilenumber')) + ->append($this->addFieldNode('contact_info')) ->append($this->addFieldNode('nationality')) ->append($this->addFieldNode('country_of_birth')) ->append($this->addFieldNode('marital_status')) @@ -76,22 +78,22 @@ class Configuration implements ConfigurationInterface ->end() // person_fields, parent = children of root ->end() // children of 'root', parent = root ; - + return $treeBuilder; } - + private function addFieldNode($key) { $tree = new TreeBuilder(); $node = $tree->root($key, 'enum'); - + $node ->values(array('hidden', 'visible')) ->defaultValue('visible') ->info("If the field $key must be shown") ->end(); - + return $node; } } diff --git a/Entity/Person.php b/Entity/Person.php index 27ae1aac5..0c8fb9151 100644 --- a/Entity/Person.php +++ b/Entity/Person.php @@ -66,6 +66,9 @@ class Person implements HasCenterInterface { //TO-ADD : address + /** @var string Contact information for contacting the person */ + private $contactInfo = ''; + /** @var string The person's email */ private $email = ''; @@ -456,6 +459,32 @@ class Person implements HasCenterInterface { return $this->maritalStatus; } + /** + * Set contactInfo + * + * @param string $contactInfo + * @return Person + */ + public function setcontactInfo($contactInfo) + { + if ($contactInfo === null) { + $contactInfo = ''; + } + + $this->contactInfo = $contactInfo; + + return $this; + } + + /** + * Get contactInfo + * + * @return string + */ + public function getcontactInfo() + { + return $this->contactInfo; + } /** * Set email diff --git a/Form/PersonType.php b/Form/PersonType.php index 7f7615d4b..1e9d5258d 100644 --- a/Form/PersonType.php +++ b/Form/PersonType.php @@ -76,9 +76,17 @@ class PersonType extends AbstractType $builder->add('placeOfBirth', TextType::class, array('required' => false)); } + if ($this->config['contact_info'] === 'visible') { + $builder->add('contactInfo', TextareaType::class, array('required' => false)); + } + if ($this->config['phonenumber'] === 'visible') { $builder->add('phonenumber', TextareaType::class, array('required' => false)); } + + if ($this->config['mobilenumber'] === 'visible') { + $builder->add('mobilenumber', TextareaType::class, array('required' => false)); + } if ($this->config['email'] === 'visible') { $builder->add('email', EmailType::class, array('required' => false)); diff --git a/Resources/config/doctrine/Person.orm.yml b/Resources/config/doctrine/Person.orm.yml index 505ac7032..19d4abb07 100644 --- a/Resources/config/doctrine/Person.orm.yml +++ b/Resources/config/doctrine/Person.orm.yml @@ -31,8 +31,12 @@ Chill\PersonBundle\Entity\Person: memo: type: text default: '' + contactInfo: + type: text + nullable: true email: type: text + nullable: true proxyAccompanyingPeriodOpenState: type: boolean name: proxy_open @@ -41,6 +45,11 @@ Chill\PersonBundle\Entity\Person: phonenumber: type: text nullable: true + length: 40 + mobilenumber: + type: text + nullable: true + length: 40 manyToOne: countryOfBirth: targetEntity: Chill\MainBundle\Entity\Country diff --git a/Resources/config/validation.yml b/Resources/config/validation.yml index 246e39f8c..aaf85c9e9 100644 --- a/Resources/config/validation.yml +++ b/Resources/config/validation.yml @@ -34,11 +34,12 @@ Chill\PersonBundle\Entity\Person: - Email: groups: [general, creation] message: 'The email "{{ value }}" is not a valid email.' + checkMX: true phonenumber: - Regex: - pattern: '/^([\+{1}]|[0])([0-9\s*]{4,20})$/' + pattern: '/^([\+{1}])([0-9\s*]{4,20})$/' groups: [general, creation] - message: 'Invalid phone number: it should begin with "0" or "+", hold only digits and be smaller than 20 characters ' + message: 'Invalid phone number: it should begin with the international prefix starting with "+", hold only digits and be smaller than 20 characters. Ex: +33123456789 ' constraints: diff --git a/Resources/migrations/Version201805181442210.php b/Resources/migrations/Version201805181442210.php new file mode 100644 index 000000000..74d9c64c3 --- /dev/null +++ b/Resources/migrations/Version201805181442210.php @@ -0,0 +1,32 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('ALTER TABLE chill_person_person ADD contactInfo TEXT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_person_person ADD mobilenumber TEXT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_person_person ALTER email DROP NOT NULL'); + } + + public function down(Schema $schema) : void + { + // this down() migration is auto-generated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('ALTER TABLE chill_person_person DROP contactInfo'); + $this->addSql('ALTER TABLE chill_person_person DROP mobilenumber'); + $this->addSql('ALTER TABLE chill_person_person ALTER email SET NOT NULL'); + } +} diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index ec2ffc9e1..3e087ace6 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -38,6 +38,10 @@ 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 +'Contact information: remarks': 'Remarques' +'Remarks': 'Remarques' '{0} Born the %date% | {1} Born the %date%': '{0} Né le %date% | {1} Née le %date%' 'Spoken languages': 'Langues parlées' 'Unknown spoken languages': 'Langues parlées inconnues' @@ -194,4 +198,3 @@ Aggregate by age: Aggréger par âge Calculate age in relation to this date: Calculer l'âge par rapport à cette date Group people by country of birth: Aggréger les personnes par pays de naissance - \ No newline at end of file diff --git a/Resources/views/Person/edit.html.twig b/Resources/views/Person/edit.html.twig index 89bc4b44c..a2eb8363c 100644 --- a/Resources/views/Person/edit.html.twig +++ b/Resources/views/Person/edit.html.twig @@ -21,7 +21,7 @@ {% block title %}{{ 'Update details for %name%'|trans({ '%name%': person.firstName|capitalize ~ ' ' ~ person.lastName } )|capitalize }}{% endblock %} {% block personcontent %} - +

{{ 'Update details for %name%'|trans({ '%name%': person.firstName|capitalize ~ ' ' ~ person.lastName|capitalize } ) }}

{% form_theme form 'ChillMainBundle:Form:fields.html.twig' %} @@ -66,7 +66,7 @@ {%- endif -%} -{%- if form.email is defined or form.phonenumber is defined -%} +{%- if form.email is defined or form.phonenumber is defined or form.mobilenumber is defined or form.contact_info is defined-%}

{{ 'Contact information'|trans }}

{%- if form.email is defined -%} @@ -75,6 +75,12 @@ {%- if form.phonenumber is defined -%} {{ form_row(form.phonenumber, {'label': 'Phonenumber'}) }} {%- endif -%} + {%- if form.mobilenumber is defined -%} + {{ form_row(form.mobilenumber, {'label': 'Mobilenumber'}) }} + {%- endif -%} + {%- if form.contact_info is defined -%} + {{ form_row(form.contact_info, {'label': 'Contact information: remarks'}) }} + {%- endif -%}
{%- endif -%} @@ -93,4 +99,4 @@ {{ form_end(form) }} -{% endblock personcontent %} \ No newline at end of file +{% endblock personcontent %} diff --git a/Resources/views/Person/view.html.twig b/Resources/views/Person/view.html.twig index 3b7f53aab..0172f7e90 100644 --- a/Resources/views/Person/view.html.twig +++ b/Resources/views/Person/view.html.twig @@ -173,7 +173,7 @@ This view should receive those arguments:
{%- if person.lastAddress is not empty -%} {{ address._render(person.lastAddress) }} - +