mirror of
				https://gitlab.com/Chill-Projet/chill-bundles.git
				synced 2025-10-31 09:18:24 +00:00 
			
		
		
		
	Person attibutes name and surname become firstname and lastname
This commit is contained in:
		| @@ -142,11 +142,11 @@ class PersonController extends Controller | ||||
|          | ||||
|         $dql = 'SELECT p FROM ChillPersonBundle:Person p' | ||||
|                 . ' WHERE' | ||||
|                 . ' LOWER(p.name) like LOWER(:q)' | ||||
|                 . ' OR LOWER(p.surname)  like LOWER(:q)'; | ||||
|                 . ' LOWER(p.firstName) like LOWER(:q)' | ||||
|                 . ' OR LOWER(p.lastName)  like LOWER(:q)'; | ||||
|          | ||||
|         if ($this->container->getParameter('cl_chill_person.search.use_double_metaphone')) { | ||||
|             $dql .= ' OR DOUBLEMETAPHONE(p.name) = DOUBLEMETAPHONE(:qabsolute)'; | ||||
|             $dql .= ' OR DOUBLEMETAPHONE(p.lastName) = DOUBLEMETAPHONE(:qabsolute)'; | ||||
|         } | ||||
|  | ||||
|          | ||||
| @@ -209,8 +209,8 @@ class PersonController extends Controller | ||||
|          | ||||
|         $date_of_birth = new \DateTime(); | ||||
|                  | ||||
|         $person->setName($form['name']->getData()) | ||||
|                 ->setSurname($form['surname']->getData()) | ||||
|         $person->setFirstName($form['firstName']->getData()) | ||||
|                 ->setLastName($form['lastName']->getData()) | ||||
|                 ->setGenre($form['genre']->getData()) | ||||
|                 ->setDateOfBirth($form['dateOfBirth']->getData()) | ||||
|                 ; | ||||
| @@ -288,15 +288,15 @@ class PersonController extends Controller | ||||
|         $query = $em->createQuery(); | ||||
|                  | ||||
|         $dql = 'SELECT p from ChillPersonBundle:Person p WHERE ' | ||||
|                 . 'LOWER(p.name) LIKE LOWER(:name)' | ||||
|                 . ' OR LOWER(p.surname) LIKE LOWER(:surname)'; | ||||
|                 . 'LOWER(p.firstName) LIKE LOWER(:firstName)' | ||||
|                 . ' OR LOWER(p.lastName) LIKE LOWER(:lastName)'; | ||||
|  | ||||
|         $query->setParameter('name', $form['name']->getData()) | ||||
|                 ->setParameter('surname', $form['surname']->getData()); | ||||
|         $query->setParameter('firstName', $form['firstName']->getData()) | ||||
|                 ->setParameter('lastName', $form['lastName']->getData()); | ||||
|  | ||||
|         if ($this->container | ||||
|                 ->getParameter('cl_chill_person.search.use_double_metaphone')) { | ||||
|             $dql .= ' OR DOUBLEMETAPHONE(p.name) LIKE DOUBLEMETAPHONE(:name)'; | ||||
|             $dql .= ' OR DOUBLEMETAPHONE(p.lastName) LIKE DOUBLEMETAPHONE(:lastName)'; | ||||
|         } | ||||
|  | ||||
|         $query->setDql($dql); | ||||
| @@ -315,8 +315,8 @@ class PersonController extends Controller | ||||
|          | ||||
|         return $this->render('ChillPersonBundle:Person:create_review.html.twig', | ||||
|             array('alternatePersons' => $alternatePersons, | ||||
|                 'name' => $form['name']->getData(), | ||||
|                 'surname' => $form['surname']->getData(), | ||||
|                 'firstName' => $form['firstName']->getData(), | ||||
|                 'lastName' => $form['lastName']->getData(), | ||||
|                 'dateOfBirth' => $form['dateOfBirth']->getData(), | ||||
|                 'genre' => $form['genre']->getData(), | ||||
|                 'creation_date' => $form['creation_date']->getData(), | ||||
|   | ||||
| @@ -1,5 +1,24 @@ | ||||
| <?php | ||||
|  | ||||
| /* | ||||
|  * Chill is a software for social workers | ||||
|  * | ||||
|  * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop> | ||||
|  * | ||||
|  * 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. | ||||
|  * | ||||
|  * This program is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  * GNU Affero General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Affero General Public License | ||||
|  * along with this program.  If not, see <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| namespace Chill\PersonBundle\DataFixtures\ORM; | ||||
|  | ||||
| use Doctrine\Common\DataFixtures\AbstractFixture; | ||||
| @@ -11,10 +30,12 @@ use Chill\PersonBundle\Entity\Person; | ||||
|  * Load people into database | ||||
|  * | ||||
|  * @author Julien Fastré <julien arobase fastre point info> | ||||
|  * @author Marc Ducobu <marc@champs-libres.coop> | ||||
|  */ | ||||
| class LoadPeople extends AbstractFixture implements OrderedFixtureInterface { | ||||
|      | ||||
|     public function prepare() { | ||||
| class LoadPeople extends AbstractFixture implements OrderedFixtureInterface | ||||
| {     | ||||
|     public function prepare() | ||||
|     { | ||||
|         //prepare days, month, years | ||||
|         $y = 1950; | ||||
|         do { | ||||
| @@ -22,7 +43,6 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface { | ||||
|             $y = $y +1; | ||||
|         } while ($y >= 1990); | ||||
|          | ||||
|          | ||||
|         $m = 1; | ||||
|         do { | ||||
|             $this->month[] = $m; | ||||
| @@ -36,17 +56,18 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface { | ||||
|         } while ($d <= 28); | ||||
|     } | ||||
|      | ||||
|     public function getOrder() { | ||||
|     public function getOrder() | ||||
|     { | ||||
|         return 10000; | ||||
|     } | ||||
|      | ||||
|     public function load(ObjectManager $manager) { | ||||
|          | ||||
|     public function load(ObjectManager $manager) | ||||
|     { | ||||
|         echo "loading people...\n"; | ||||
|          | ||||
|         $this->prepare(); | ||||
|          | ||||
|         $choose_name_or_tri = array('tri', 'tri', 'name', 'tri'); | ||||
|         $chooseLastNameOrTri = array('tri', 'tri', 'name', 'tri'); | ||||
|          | ||||
|         $i = 0; | ||||
|          | ||||
| @@ -55,28 +76,26 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface { | ||||
|              | ||||
|             $sex = $this->genres[array_rand($this->genres)]; | ||||
|              | ||||
|             if ($choose_name_or_tri[array_rand($choose_name_or_tri)] === 'tri' ) { | ||||
|             if ($chooseLastNameOrTri[array_rand($chooseLastNameOrTri)] === 'tri' ) { | ||||
|                 $length = rand(2, 3); | ||||
|                 $name = ''; | ||||
|                 $lastName = ''; | ||||
|                 for ($j = 0; $j <= $length; $j++) { | ||||
|                     $name .= $this->names_trigrams[array_rand($this->names_trigrams)]; | ||||
|                     $lastName .= $this->lastNamesTrigrams[array_rand($this->lastNamesTrigrams)]; | ||||
|                 } | ||||
|                 $name = ucfirst($name); | ||||
|                  | ||||
|                 $lastName = ucfirst($lastName); | ||||
|             } else { | ||||
|                 $name = $this->names[array_rand($this->names)]; | ||||
|                 $lastName = $this->lastNames[array_rand($this->lastNames)]; | ||||
|             } | ||||
|              | ||||
|             if ($sex === Person::GENRE_MAN) { | ||||
|                 $surname = $this->surnames_male[array_rand($this->surnames_male)]; | ||||
|                 $firstName = $this->firstNamesMale[array_rand($this->firstNamesMale)]; | ||||
|             } else { | ||||
|                 $surname = $this->surnames_female[array_rand($this->surnames_female)]; | ||||
|                 $firstName = $this->firstNamesFemale[array_rand($this->firstNamesFemale)]; | ||||
|             } | ||||
|              | ||||
|              | ||||
|             $person = array( | ||||
|                 'Name' => $name, | ||||
|                 'Surname' => $surname, | ||||
|                 'FirstName' => $firstName, | ||||
|                 'LastName' => $lastName, | ||||
|                 'DateOfBirth' => "1960-10-12", | ||||
|                 'PlaceOfBirth' => "Ottignies Louvain-La-Neuve", | ||||
|                 'Genre' => $sex, | ||||
| @@ -111,17 +130,17 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface { | ||||
|         $manager->flush(); | ||||
|     } | ||||
|      | ||||
|     private $surnames_male = array("Jean", "Mohamed", "Alfred", "Robert",  | ||||
|          "Compère", "Jean-de-Dieu",  | ||||
|     private $firstNamesMale = array("Jean", "Mohamed", "Alfred", "Robert", | ||||
|          "Compère", "Jean-de-Dieu", | ||||
|          "Charles", "Pierre", "Luc", "Mathieu", "Alain", "Etienne", "Eric", | ||||
|          "Corentin", "Gaston", "Spirou", "Fantasio", "Mahmadou", "Mohamidou", | ||||
|         "Vursuv" ); | ||||
|     private $surnames_female = array("Svedana", "Sevlatina","Irène", "Marcelle", | ||||
|     private $firstNamesFemale = array("Svedana", "Sevlatina","Irène", "Marcelle", | ||||
|         "Corentine", "Alfonsine","Caroline","Solange","Gostine", "Fatoumata", | ||||
|         "Groseille", "Chana", "Oxana", "Ivana"); | ||||
|      | ||||
|     private $names = array("Diallo", "Bah", "Gaillot"); | ||||
|     private $names_trigrams = array("fas", "tré", "hu", 'blart', 'van', 'der', 'lin', 'den', | ||||
|     private $lastNames = array("Diallo", "Bah", "Gaillot"); | ||||
|     private $lastNamesTrigrams = array("fas", "tré", "hu", 'blart', 'van', 'der', 'lin', 'den', | ||||
|         'ta', 'mi', 'gna', 'bol', 'sac', 'ré', 'jo', 'du', 'pont', 'cas', 'tor', 'rob', 'al', | ||||
|         'ma', 'gone', 'car',"fu", "ka", "lot", "no", "va", "du", "bu", "su", | ||||
|         "lo", 'to', "cho", "car", 'mo','zu', 'qi', 'mu'); | ||||
| @@ -136,8 +155,8 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface { | ||||
|      | ||||
|     private $peoples = array( | ||||
|         array( | ||||
|             'Name' => "Depardieu", | ||||
|             'Surname' => "Jean", | ||||
|             'FirstName' => "Depardieu", | ||||
|             'LastName' => "Jean", | ||||
|             'DateOfBirth' => "1960-10-12", | ||||
|             'PlaceOfBirth' => "Ottignies Louvain-La-Neuve", | ||||
|             'Genre' => Person::GENRE_MAN, | ||||
|   | ||||
| @@ -36,12 +36,12 @@ class Person { | ||||
|     /** | ||||
|      * @var string | ||||
|      */ | ||||
|     private $name; | ||||
|     private $firstName; | ||||
|  | ||||
|     /** | ||||
|      * @var string | ||||
|      */ | ||||
|     private $surname; | ||||
|     private $lastName; | ||||
|  | ||||
|     /** | ||||
|      * @var \DateTime | ||||
| @@ -238,49 +238,49 @@ class Person { | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Set name | ||||
|      * Set firstName | ||||
|      * | ||||
|      * @param string $name | ||||
|      * @param string $firstName | ||||
|      * @return Person | ||||
|      */ | ||||
|     public function setName($name) | ||||
|     public function setFirstName($firstName) | ||||
|     { | ||||
|         $this->name = $name; | ||||
|         $this->firstName = $firstName; | ||||
|          | ||||
|         return $this; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Get name | ||||
|      * Get firstName | ||||
|      * | ||||
|      * @return string  | ||||
|      */ | ||||
|     public function getName() | ||||
|     public function getFirstName() | ||||
|     { | ||||
|         return $this->name; | ||||
|         return $this->firstName; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Set surname | ||||
|      * Set lastName | ||||
|      * | ||||
|      * @param string $surname | ||||
|      * @param string $lastName | ||||
|      * @return Person | ||||
|      */ | ||||
|     public function setSurname($surname) | ||||
|     public function setLastName($lastName) | ||||
|     { | ||||
|         $this->surname = $surname; | ||||
|         $this->lastName = $lastName; | ||||
|      | ||||
|         return $this; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Get surname | ||||
|      * Get lastName | ||||
|      * | ||||
|      * @return string  | ||||
|      */ | ||||
|     public function getSurname() | ||||
|     public function getLastName() | ||||
|     { | ||||
|         return $this->surname; | ||||
|         return $this->lastName; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
| @@ -476,7 +476,7 @@ class Person { | ||||
|     } | ||||
|      | ||||
|     public function getLabel() { | ||||
|         return $this->getSurname()." ".$this->getName(); | ||||
|         return $this->getFirstName()." ".$this->getLastName(); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|   | ||||
| @@ -1,5 +1,24 @@ | ||||
| <?php | ||||
|  | ||||
| /* | ||||
|  * Chill is a software for social workers | ||||
|  * | ||||
|  * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop> | ||||
|  * | ||||
|  * 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. | ||||
|  * | ||||
|  * This program is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  * GNU Affero General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Affero General Public License | ||||
|  * along with this program.  If not, see <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| namespace Chill\PersonBundle\Form; | ||||
|  | ||||
| use Symfony\Component\Form\AbstractType; | ||||
| @@ -15,7 +34,7 @@ class CreationPersonType extends AbstractType | ||||
|      | ||||
|     private $form_status; | ||||
|      | ||||
|     const NAME = 'cl_chill_personbundle_person_creation'; | ||||
|     const NAME = 'chill_personbundle_person_creation'; | ||||
|      | ||||
|     const FORM_NOT_REVIEWED = 'not_reviewed'; | ||||
|     const FORM_REVIEWED = 'reviewed' ; | ||||
| @@ -37,8 +56,8 @@ class CreationPersonType extends AbstractType | ||||
|                     null, null, 'dd-MM-yyyy', true); | ||||
|              | ||||
|              | ||||
|             $builder->add('name', 'hidden') | ||||
|                     ->add('surname', 'hidden') | ||||
|             $builder->add('firstName', 'hidden') | ||||
|                     ->add('lastName', 'hidden') | ||||
|                     ->add( $builder->create('dateOfBirth', 'hidden') | ||||
|                             ->addModelTransformer($dateToStringTransformer) | ||||
|                           ) | ||||
| @@ -50,8 +69,8 @@ class CreationPersonType extends AbstractType | ||||
|                     ; | ||||
|         } else { | ||||
|             $builder | ||||
|                 ->add('name') | ||||
|                 ->add('surname') | ||||
|                 ->add('firstName') | ||||
|                 ->add('lastName') | ||||
|                 ->add('dateOfBirth', 'date', array('required' => false,  | ||||
|                     'widget' => 'single_text', 'format' => 'dd-MM-yyyy')) | ||||
|                 ->add('genre', new GenderType(), array( | ||||
|   | ||||
| @@ -37,8 +37,8 @@ class PersonType extends AbstractType | ||||
|     public function buildForm(FormBuilderInterface $builder, array $options) | ||||
|     { | ||||
|         $builder | ||||
|             ->add('name') | ||||
|             ->add('surname') | ||||
|             ->add('firstName') | ||||
|             ->add('lastName') | ||||
|             ->add('dateOfBirth', 'date', array('required' => false, 'widget' => 'single_text', 'format' => 'dd-MM-yyyy')) | ||||
|             ->add('placeOfBirth', 'text', array('required' => false)) | ||||
|             ->add('genre', new GenderType(), array( | ||||
|   | ||||
| @@ -8,10 +8,10 @@ Chill\PersonBundle\Entity\Person: | ||||
|             id: true | ||||
|             generator: | ||||
|                 strategy: AUTO | ||||
|         name: | ||||
|         firstName: | ||||
|             type: string | ||||
|             length: 255 | ||||
|         surname: | ||||
|         lastName: | ||||
|             type: string | ||||
|             length: 255 | ||||
|         dateOfBirth: | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| Chill\PersonBundle\Entity\Person: | ||||
|     properties: | ||||
|         name: | ||||
|         firstName: | ||||
|               - NotBlank:  | ||||
|                   groups: [general, creation] | ||||
|               - Length:  | ||||
| @@ -9,8 +9,7 @@ Chill\PersonBundle\Entity\Person: | ||||
|                   minMessage: validation.Person.constraint.name_min | ||||
|                   maxMessage: validation.Person.constraint.name_max | ||||
|                   groups: [general, creation] | ||||
|                    | ||||
|         surname: | ||||
|         lastName: | ||||
|               - NotBlank: | ||||
|                   groups: [general, creation] | ||||
|               - Length:  | ||||
| @@ -30,8 +29,6 @@ Chill\PersonBundle\Entity\Person: | ||||
|           - Callback: | ||||
|               methods: [isHistoryValid] | ||||
|               groups: [history_consistent] | ||||
|                    | ||||
|                    | ||||
|  | ||||
| Chill\PersonBundle\Entity\PersonHistoryFile: | ||||
|     properties: | ||||
|   | ||||
| @@ -25,9 +25,9 @@ | ||||
|              | ||||
|                 <h1>{{ 'views.Person.creation.open'|trans }}</h1> | ||||
|              | ||||
|                 {{ form_row(form.name, { 'label' : 'views.Person.view.name'|trans }) }}   | ||||
|                 {{ form_row(form.firstName, { 'label' : 'First name'|trans }) }}   | ||||
|                              | ||||
|                 {{ form_row(form.surname, { 'label' : 'views.Person.view.surname'|trans }) }} | ||||
|                 {{ form_row(form.lastName, { 'label' : 'Last name'|trans }) }} | ||||
|                              | ||||
|                 {{ form_row(form.dateOfBirth, { 'label' : 'views.Person.view.dateOfBirth'|trans }) }} | ||||
|                              | ||||
|   | ||||
| @@ -65,11 +65,11 @@ | ||||
|             <h2>{{ 'views.Person.review.you_will_create_this_person'|trans }}</h2> | ||||
|              | ||||
|             <dl> | ||||
|                 <dt>{{ 'views.Person.view.name'|trans }}</dt> | ||||
|                 <dd>{{ name }}</dd> | ||||
|                 <dt>{{ 'First name'|trans }}</dt> | ||||
|                 <dd>{{ firstName }}</dd> | ||||
|                  | ||||
|                 <dt>{{ 'views.Person.view.surname'|trans }}</dt> | ||||
|                 <dd>{{ surname }}</dd> | ||||
|                 <dt>{{ 'Last name'|trans }}</dt> | ||||
|                 <dd>{{ lastName }}</dd> | ||||
|                  | ||||
|                 <dt>{{ 'views.Person.view.dateOfBirth'|trans }}</dt> | ||||
|                 <dd>{{ dateOfBirth|date(date_format)|default( 'person.without_date_of_birth'|trans ) }}</dd> | ||||
|   | ||||
| @@ -28,8 +28,8 @@ | ||||
|  | ||||
| <fieldset> | ||||
|     <legend><h2>{{ 'views.Person.view.general'|trans }}</h2></legend> | ||||
|     {{ form_row(form.surname, {'label' : 'views.Person.view.surname'}) }} | ||||
|     {{ form_row(form.name, {'label' : 'views.Person.view.name'}) }} | ||||
|     {{ form_row(form.firstName, {'label' : 'First name'}) }} | ||||
|     {{ form_row(form.lastName, {'label' : 'Last name'}) }} | ||||
|     {{ form_row(form.genre, {'label' : 'views.Person.view.gender'}) }} | ||||
| </fieldset> | ||||
|  | ||||
|   | ||||
| @@ -21,7 +21,7 @@ | ||||
|     <table class="striped rounded"> | ||||
|         <thead> | ||||
|             <tr> | ||||
|                 <th>{% trans %}person.name{% endtrans %}</th> | ||||
|                 <th>{% trans %}Name{% endtrans %}</th> | ||||
|                 <th>{% trans %}person.dateOfBirth{% endtrans %}</th> | ||||
|                 <th>{% trans %}person.nationality{% endtrans %}</th> | ||||
|             </tr> | ||||
| @@ -31,8 +31,7 @@ | ||||
|                 <tr> | ||||
|                     <td> | ||||
|                         <a href="{{ path('chill_person_view', {person_id : person.getId}) }}"> | ||||
|                             <span class="personSurname">{{person.surname}}</span> | ||||
|                             <span class="personName">{{person.name}}</span> | ||||
|                             {{person.firstName}} {{person.lastName}} | ||||
|                             {% spaceless %} | ||||
|                                 {% if person.isOpen == false %} | ||||
|                                     <i class="icon-lock"></i> | ||||
|   | ||||
| @@ -42,11 +42,11 @@ This view should receive those arguments: | ||||
|     <h2>{{ 'views.Person.view.general'|trans }}</h2> | ||||
|      | ||||
|     <dl> | ||||
|         <dt class="inline">{{ 'views.Person.view.surname'|trans }}</dt> | ||||
|         <dd>{{ person.surname }}</dd> | ||||
|         <dt class="inline">{{ 'First name'|trans }}</dt> | ||||
|         <dd>{{ person.firstName }}</dd> | ||||
|          | ||||
|         <dt class="inline">{{ 'views.Person.view.name'|trans }}</dt> | ||||
|         <dd>{{ person.name }}</dd> | ||||
|         <dt class="inline">{{ 'Last name'|trans }}</dt> | ||||
|         <dd>{{ person.lastName }}</dd> | ||||
|          | ||||
|         <dt class="inline">{{ 'views.Person.view.gender'|trans }}</dt> | ||||
|         <dd>{{ ( 'person.gender.' ~ person.genre|default('undefined'))|trans }}</dd> | ||||
|   | ||||
| @@ -25,6 +25,7 @@ | ||||
| {% endblock %} | ||||
|  | ||||
| {% block layout_content %} | ||||
|  | ||||
| <div class="container"> | ||||
|     <div id="person_wrapper"> | ||||
|         <div id="general" class="parent"> | ||||
| @@ -35,7 +36,7 @@ | ||||
|                     {%  else %} | ||||
|                         <i class="fa fa-male"></i> | ||||
|                     {% endif %} | ||||
|                     {{  person.surname }} {{ person.name }} {% spaceless %} | ||||
|                     {{  person.firstName }} {{ person.lastName }} {% spaceless %} | ||||
|                         {% if not person.isOpen %} | ||||
|                             <i class="fa fa-lock"></i>       | ||||
|                         {% endif %} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user