Person attibutes name and surname become firstname and lastname

This commit is contained in:
Marc Ducobu 2014-11-18 16:15:47 +01:00
parent 24b126c5c3
commit 4c2a3c3624
13 changed files with 120 additions and 85 deletions

View File

@ -142,11 +142,11 @@ class PersonController extends Controller
$dql = 'SELECT p FROM ChillPersonBundle:Person p' $dql = 'SELECT p FROM ChillPersonBundle:Person p'
. ' WHERE' . ' WHERE'
. ' LOWER(p.name) like LOWER(:q)' . ' LOWER(p.firstName) like LOWER(:q)'
. ' OR LOWER(p.surname) like LOWER(:q)'; . ' OR LOWER(p.lastName) like LOWER(:q)';
if ($this->container->getParameter('cl_chill_person.search.use_double_metaphone')) { 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(); $date_of_birth = new \DateTime();
$person->setName($form['name']->getData()) $person->setFirstName($form['firstName']->getData())
->setSurname($form['surname']->getData()) ->setLastName($form['lastName']->getData())
->setGenre($form['genre']->getData()) ->setGenre($form['genre']->getData())
->setDateOfBirth($form['dateOfBirth']->getData()) ->setDateOfBirth($form['dateOfBirth']->getData())
; ;
@ -288,15 +288,15 @@ class PersonController extends Controller
$query = $em->createQuery(); $query = $em->createQuery();
$dql = 'SELECT p from ChillPersonBundle:Person p WHERE ' $dql = 'SELECT p from ChillPersonBundle:Person p WHERE '
. 'LOWER(p.name) LIKE LOWER(:name)' . 'LOWER(p.firstName) LIKE LOWER(:firstName)'
. ' OR LOWER(p.surname) LIKE LOWER(:surname)'; . ' OR LOWER(p.lastName) LIKE LOWER(:lastName)';
$query->setParameter('name', $form['name']->getData()) $query->setParameter('firstName', $form['firstName']->getData())
->setParameter('surname', $form['surname']->getData()); ->setParameter('lastName', $form['lastName']->getData());
if ($this->container if ($this->container
->getParameter('cl_chill_person.search.use_double_metaphone')) { ->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); $query->setDql($dql);
@ -315,8 +315,8 @@ class PersonController extends Controller
return $this->render('ChillPersonBundle:Person:create_review.html.twig', return $this->render('ChillPersonBundle:Person:create_review.html.twig',
array('alternatePersons' => $alternatePersons, array('alternatePersons' => $alternatePersons,
'name' => $form['name']->getData(), 'firstName' => $form['firstName']->getData(),
'surname' => $form['surname']->getData(), 'lastName' => $form['lastName']->getData(),
'dateOfBirth' => $form['dateOfBirth']->getData(), 'dateOfBirth' => $form['dateOfBirth']->getData(),
'genre' => $form['genre']->getData(), 'genre' => $form['genre']->getData(),
'creation_date' => $form['creation_date']->getData(), 'creation_date' => $form['creation_date']->getData(),

View File

@ -1,5 +1,24 @@
<?php <?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; namespace Chill\PersonBundle\DataFixtures\ORM;
use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\AbstractFixture;
@ -11,10 +30,12 @@ use Chill\PersonBundle\Entity\Person;
* Load people into database * Load people into database
* *
* @author Julien Fastré <julien arobase fastre point info> * @author Julien Fastré <julien arobase fastre point info>
* @author Marc Ducobu <marc@champs-libres.coop>
*/ */
class LoadPeople extends AbstractFixture implements OrderedFixtureInterface { class LoadPeople extends AbstractFixture implements OrderedFixtureInterface
{
public function prepare() { public function prepare()
{
//prepare days, month, years //prepare days, month, years
$y = 1950; $y = 1950;
do { do {
@ -22,7 +43,6 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface {
$y = $y +1; $y = $y +1;
} while ($y >= 1990); } while ($y >= 1990);
$m = 1; $m = 1;
do { do {
$this->month[] = $m; $this->month[] = $m;
@ -36,17 +56,18 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface {
} while ($d <= 28); } while ($d <= 28);
} }
public function getOrder() { public function getOrder()
{
return 10000; return 10000;
} }
public function load(ObjectManager $manager) { public function load(ObjectManager $manager)
{
echo "loading people...\n"; echo "loading people...\n";
$this->prepare(); $this->prepare();
$choose_name_or_tri = array('tri', 'tri', 'name', 'tri'); $chooseLastNameOrTri = array('tri', 'tri', 'name', 'tri');
$i = 0; $i = 0;
@ -55,28 +76,26 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface {
$sex = $this->genres[array_rand($this->genres)]; $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); $length = rand(2, 3);
$name = ''; $lastName = '';
for ($j = 0; $j <= $length; $j++) { 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 { } else {
$name = $this->names[array_rand($this->names)]; $lastName = $this->lastNames[array_rand($this->lastNames)];
} }
if ($sex === Person::GENRE_MAN) { if ($sex === Person::GENRE_MAN) {
$surname = $this->surnames_male[array_rand($this->surnames_male)]; $firstName = $this->firstNamesMale[array_rand($this->firstNamesMale)];
} else { } else {
$surname = $this->surnames_female[array_rand($this->surnames_female)]; $firstName = $this->firstNamesFemale[array_rand($this->firstNamesFemale)];
} }
$person = array( $person = array(
'Name' => $name, 'FirstName' => $firstName,
'Surname' => $surname, 'LastName' => $lastName,
'DateOfBirth' => "1960-10-12", 'DateOfBirth' => "1960-10-12",
'PlaceOfBirth' => "Ottignies Louvain-La-Neuve", 'PlaceOfBirth' => "Ottignies Louvain-La-Neuve",
'Genre' => $sex, 'Genre' => $sex,
@ -111,17 +130,17 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface {
$manager->flush(); $manager->flush();
} }
private $surnames_male = array("Jean", "Mohamed", "Alfred", "Robert", private $firstNamesMale = array("Jean", "Mohamed", "Alfred", "Robert",
"Compère", "Jean-de-Dieu", "Compère", "Jean-de-Dieu",
"Charles", "Pierre", "Luc", "Mathieu", "Alain", "Etienne", "Eric", "Charles", "Pierre", "Luc", "Mathieu", "Alain", "Etienne", "Eric",
"Corentin", "Gaston", "Spirou", "Fantasio", "Mahmadou", "Mohamidou", "Corentin", "Gaston", "Spirou", "Fantasio", "Mahmadou", "Mohamidou",
"Vursuv" ); "Vursuv" );
private $surnames_female = array("Svedana", "Sevlatina","Irène", "Marcelle", private $firstNamesFemale = array("Svedana", "Sevlatina","Irène", "Marcelle",
"Corentine", "Alfonsine","Caroline","Solange","Gostine", "Fatoumata", "Corentine", "Alfonsine","Caroline","Solange","Gostine", "Fatoumata",
"Groseille", "Chana", "Oxana", "Ivana"); "Groseille", "Chana", "Oxana", "Ivana");
private $names = array("Diallo", "Bah", "Gaillot"); private $lastNames = array("Diallo", "Bah", "Gaillot");
private $names_trigrams = array("fas", "tré", "hu", 'blart', 'van', 'der', 'lin', 'den', private $lastNamesTrigrams = array("fas", "tré", "hu", 'blart', 'van', 'der', 'lin', 'den',
'ta', 'mi', 'gna', 'bol', 'sac', 'ré', 'jo', 'du', 'pont', 'cas', 'tor', 'rob', 'al', 'ta', 'mi', 'gna', 'bol', 'sac', 'ré', 'jo', 'du', 'pont', 'cas', 'tor', 'rob', 'al',
'ma', 'gone', 'car',"fu", "ka", "lot", "no", "va", "du", "bu", "su", 'ma', 'gone', 'car',"fu", "ka", "lot", "no", "va", "du", "bu", "su",
"lo", 'to', "cho", "car", 'mo','zu', 'qi', 'mu'); "lo", 'to', "cho", "car", 'mo','zu', 'qi', 'mu');
@ -136,8 +155,8 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface {
private $peoples = array( private $peoples = array(
array( array(
'Name' => "Depardieu", 'FirstName' => "Depardieu",
'Surname' => "Jean", 'LastName' => "Jean",
'DateOfBirth' => "1960-10-12", 'DateOfBirth' => "1960-10-12",
'PlaceOfBirth' => "Ottignies Louvain-La-Neuve", 'PlaceOfBirth' => "Ottignies Louvain-La-Neuve",
'Genre' => Person::GENRE_MAN, 'Genre' => Person::GENRE_MAN,

View File

@ -36,12 +36,12 @@ class Person {
/** /**
* @var string * @var string
*/ */
private $name; private $firstName;
/** /**
* @var string * @var string
*/ */
private $surname; private $lastName;
/** /**
* @var \DateTime * @var \DateTime
@ -238,49 +238,49 @@ class Person {
} }
/** /**
* Set name * Set firstName
* *
* @param string $name * @param string $firstName
* @return Person * @return Person
*/ */
public function setName($name) public function setFirstName($firstName)
{ {
$this->name = $name; $this->firstName = $firstName;
return $this; return $this;
} }
/** /**
* Get name * Get firstName
* *
* @return string * @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 * @return Person
*/ */
public function setSurname($surname) public function setLastName($lastName)
{ {
$this->surname = $surname; $this->lastName = $lastName;
return $this; return $this;
} }
/** /**
* Get surname * Get lastName
* *
* @return string * @return string
*/ */
public function getSurname() public function getLastName()
{ {
return $this->surname; return $this->lastName;
} }
/** /**
@ -476,7 +476,7 @@ class Person {
} }
public function getLabel() { public function getLabel() {
return $this->getSurname()." ".$this->getName(); return $this->getFirstName()." ".$this->getLastName();
} }
/** /**

View File

@ -1,5 +1,24 @@
<?php <?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; namespace Chill\PersonBundle\Form;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
@ -15,7 +34,7 @@ class CreationPersonType extends AbstractType
private $form_status; private $form_status;
const NAME = 'cl_chill_personbundle_person_creation'; const NAME = 'chill_personbundle_person_creation';
const FORM_NOT_REVIEWED = 'not_reviewed'; const FORM_NOT_REVIEWED = 'not_reviewed';
const FORM_REVIEWED = 'reviewed' ; const FORM_REVIEWED = 'reviewed' ;
@ -37,8 +56,8 @@ class CreationPersonType extends AbstractType
null, null, 'dd-MM-yyyy', true); null, null, 'dd-MM-yyyy', true);
$builder->add('name', 'hidden') $builder->add('firstName', 'hidden')
->add('surname', 'hidden') ->add('lastName', 'hidden')
->add( $builder->create('dateOfBirth', 'hidden') ->add( $builder->create('dateOfBirth', 'hidden')
->addModelTransformer($dateToStringTransformer) ->addModelTransformer($dateToStringTransformer)
) )
@ -50,8 +69,8 @@ class CreationPersonType extends AbstractType
; ;
} else { } else {
$builder $builder
->add('name') ->add('firstName')
->add('surname') ->add('lastName')
->add('dateOfBirth', 'date', array('required' => false, ->add('dateOfBirth', 'date', array('required' => false,
'widget' => 'single_text', 'format' => 'dd-MM-yyyy')) 'widget' => 'single_text', 'format' => 'dd-MM-yyyy'))
->add('genre', new GenderType(), array( ->add('genre', new GenderType(), array(

View File

@ -37,8 +37,8 @@ class PersonType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
{ {
$builder $builder
->add('name') ->add('firstName')
->add('surname') ->add('lastName')
->add('dateOfBirth', 'date', array('required' => false, 'widget' => 'single_text', 'format' => 'dd-MM-yyyy')) ->add('dateOfBirth', 'date', array('required' => false, 'widget' => 'single_text', 'format' => 'dd-MM-yyyy'))
->add('placeOfBirth', 'text', array('required' => false)) ->add('placeOfBirth', 'text', array('required' => false))
->add('genre', new GenderType(), array( ->add('genre', new GenderType(), array(

View File

@ -8,10 +8,10 @@ Chill\PersonBundle\Entity\Person:
id: true id: true
generator: generator:
strategy: AUTO strategy: AUTO
name: firstName:
type: string type: string
length: 255 length: 255
surname: lastName:
type: string type: string
length: 255 length: 255
dateOfBirth: dateOfBirth:

View File

@ -1,6 +1,6 @@
Chill\PersonBundle\Entity\Person: Chill\PersonBundle\Entity\Person:
properties: properties:
name: firstName:
- NotBlank: - NotBlank:
groups: [general, creation] groups: [general, creation]
- Length: - Length:
@ -9,8 +9,7 @@ Chill\PersonBundle\Entity\Person:
minMessage: validation.Person.constraint.name_min minMessage: validation.Person.constraint.name_min
maxMessage: validation.Person.constraint.name_max maxMessage: validation.Person.constraint.name_max
groups: [general, creation] groups: [general, creation]
lastName:
surname:
- NotBlank: - NotBlank:
groups: [general, creation] groups: [general, creation]
- Length: - Length:
@ -30,8 +29,6 @@ Chill\PersonBundle\Entity\Person:
- Callback: - Callback:
methods: [isHistoryValid] methods: [isHistoryValid]
groups: [history_consistent] groups: [history_consistent]
Chill\PersonBundle\Entity\PersonHistoryFile: Chill\PersonBundle\Entity\PersonHistoryFile:
properties: properties:

View File

@ -25,9 +25,9 @@
<h1>{{ 'views.Person.creation.open'|trans }}</h1> <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 }) }} {{ form_row(form.dateOfBirth, { 'label' : 'views.Person.view.dateOfBirth'|trans }) }}

View File

@ -65,11 +65,11 @@
<h2>{{ 'views.Person.review.you_will_create_this_person'|trans }}</h2> <h2>{{ 'views.Person.review.you_will_create_this_person'|trans }}</h2>
<dl> <dl>
<dt>{{ 'views.Person.view.name'|trans }}</dt> <dt>{{ 'First name'|trans }}</dt>
<dd>{{ name }}</dd> <dd>{{ firstName }}</dd>
<dt>{{ 'views.Person.view.surname'|trans }}</dt> <dt>{{ 'Last name'|trans }}</dt>
<dd>{{ surname }}</dd> <dd>{{ lastName }}</dd>
<dt>{{ 'views.Person.view.dateOfBirth'|trans }}</dt> <dt>{{ 'views.Person.view.dateOfBirth'|trans }}</dt>
<dd>{{ dateOfBirth|date(date_format)|default( 'person.without_date_of_birth'|trans ) }}</dd> <dd>{{ dateOfBirth|date(date_format)|default( 'person.without_date_of_birth'|trans ) }}</dd>

View File

@ -28,8 +28,8 @@
<fieldset> <fieldset>
<legend><h2>{{ 'views.Person.view.general'|trans }}</h2></legend> <legend><h2>{{ 'views.Person.view.general'|trans }}</h2></legend>
{{ form_row(form.surname, {'label' : 'views.Person.view.surname'}) }} {{ form_row(form.firstName, {'label' : 'First name'}) }}
{{ form_row(form.name, {'label' : 'views.Person.view.name'}) }} {{ form_row(form.lastName, {'label' : 'Last name'}) }}
{{ form_row(form.genre, {'label' : 'views.Person.view.gender'}) }} {{ form_row(form.genre, {'label' : 'views.Person.view.gender'}) }}
</fieldset> </fieldset>

View File

@ -21,7 +21,7 @@
<table class="striped rounded"> <table class="striped rounded">
<thead> <thead>
<tr> <tr>
<th>{% trans %}person.name{% endtrans %}</th> <th>{% trans %}Name{% endtrans %}</th>
<th>{% trans %}person.dateOfBirth{% endtrans %}</th> <th>{% trans %}person.dateOfBirth{% endtrans %}</th>
<th>{% trans %}person.nationality{% endtrans %}</th> <th>{% trans %}person.nationality{% endtrans %}</th>
</tr> </tr>
@ -31,8 +31,7 @@
<tr> <tr>
<td> <td>
<a href="{{ path('chill_person_view', {person_id : person.getId}) }}"> <a href="{{ path('chill_person_view', {person_id : person.getId}) }}">
<span class="personSurname">{{person.surname}}</span> {{person.firstName}} {{person.lastName}}
<span class="personName">{{person.name}}</span>
{% spaceless %} {% spaceless %}
{% if person.isOpen == false %} {% if person.isOpen == false %}
<i class="icon-lock"></i> <i class="icon-lock"></i>

View File

@ -42,11 +42,11 @@ This view should receive those arguments:
<h2>{{ 'views.Person.view.general'|trans }}</h2> <h2>{{ 'views.Person.view.general'|trans }}</h2>
<dl> <dl>
<dt class="inline">{{ 'views.Person.view.surname'|trans }}</dt> <dt class="inline">{{ 'First name'|trans }}</dt>
<dd>{{ person.surname }}</dd> <dd>{{ person.firstName }}</dd>
<dt class="inline">{{ 'views.Person.view.name'|trans }}</dt> <dt class="inline">{{ 'Last name'|trans }}</dt>
<dd>{{ person.name }}</dd> <dd>{{ person.lastName }}</dd>
<dt class="inline">{{ 'views.Person.view.gender'|trans }}</dt> <dt class="inline">{{ 'views.Person.view.gender'|trans }}</dt>
<dd>{{ ( 'person.gender.' ~ person.genre|default('undefined'))|trans }}</dd> <dd>{{ ( 'person.gender.' ~ person.genre|default('undefined'))|trans }}</dd>

View File

@ -25,6 +25,7 @@
{% endblock %} {% endblock %}
{% block layout_content %} {% block layout_content %}
<div class="container"> <div class="container">
<div id="person_wrapper"> <div id="person_wrapper">
<div id="general" class="parent"> <div id="general" class="parent">
@ -35,7 +36,7 @@
{% else %} {% else %}
<i class="fa fa-male"></i> <i class="fa fa-male"></i>
{% endif %} {% endif %}
{{ person.surname }} {{ person.name }} {% spaceless %} {{ person.firstName }} {{ person.lastName }} {% spaceless %}
{% if not person.isOpen %} {% if not person.isOpen %}
<i class="fa fa-lock"></i> <i class="fa fa-lock"></i>
{% endif %} {% endif %}