mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-24 08:33:49 +00:00
add ListPerson
Add / complete list of person. Some SQL function are added to allow to get the last address at a given date.
This commit is contained in:
@@ -92,15 +92,6 @@ chill_person_address_update:
|
||||
path: /{_locale}/person/{person_id}/address/{address_id}/update
|
||||
defaults: { _controller: ChillPersonBundle:PersonAddress:update }
|
||||
|
||||
chill_person_export:
|
||||
path: /{_locale}/person/export/
|
||||
defaults: { _controller: ChillPersonBundle:Person:export }
|
||||
options:
|
||||
menus:
|
||||
export:
|
||||
order: 200
|
||||
label: Export persons
|
||||
|
||||
chill_person_timeline:
|
||||
path: /{_locale}/person/{person_id}/timeline
|
||||
defaults: { _controller: ChillPersonBundle:TimelinePerson:person }
|
||||
|
@@ -12,6 +12,7 @@ services:
|
||||
- "@doctrine.orm.entity_manager"
|
||||
- "@translator"
|
||||
- "@chill.main.helper.translatable_string"
|
||||
- "@chill.custom_field.provider"
|
||||
tags:
|
||||
- { name: chill.export, alias: list_person }
|
||||
|
||||
|
123
Resources/migrations/Version20170117131924.php
Normal file
123
Resources/migrations/Version20170117131924.php
Normal file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
namespace Application\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
||||
/**
|
||||
* Add postgresql functions to compute last address on person.
|
||||
*/
|
||||
class Version20170117131924 extends AbstractMigration
|
||||
{
|
||||
|
||||
public $fields = array(
|
||||
'address_id' => 'integer',
|
||||
'streetaddress1' => 'varchar(255)',
|
||||
'streetaddress2' => 'varchar(255)',
|
||||
'validfrom' => 'date',
|
||||
'postcode_label' => 'varchar(255)',
|
||||
'postcode_code' => 'varchar(100)',
|
||||
'postcode_id' => 'integer',
|
||||
'country_name' => 'json',
|
||||
'country_code' => 'varchar(3)',
|
||||
'country_id' => 'integer'
|
||||
);
|
||||
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function up(Schema $schema)
|
||||
{
|
||||
$this->addSql(<<<'SQL'
|
||||
CREATE OR REPLACE FUNCTION public.get_last_address (
|
||||
pid integer,
|
||||
before_date date)
|
||||
RETURNS TABLE(
|
||||
person_id integer,
|
||||
address_id integer,
|
||||
streetaddress1 varchar(255),
|
||||
streetaddress2 varchar(255),
|
||||
validfrom date,
|
||||
postcode_label varchar(255),
|
||||
postcode_code varchar(100),
|
||||
postcode_id integer,
|
||||
country_name json,
|
||||
country_code varchar(3),
|
||||
country_id integer)
|
||||
AS
|
||||
$BODY$
|
||||
SELECT
|
||||
pid AS person_id,
|
||||
chill_main_address.id AS address_id,
|
||||
chill_main_address.streetaddress1,
|
||||
chill_main_address.streetaddress2,
|
||||
chill_main_address.validfrom,
|
||||
chill_main_postal_code.label,
|
||||
chill_main_postal_code.code,
|
||||
chill_main_postal_code.id AS postal_code_id,
|
||||
country.name,
|
||||
country.countrycode,
|
||||
country.id AS country_id
|
||||
FROM chill_main_address
|
||||
JOIN (
|
||||
SELECT
|
||||
chill_main_address.id AS address_id,
|
||||
validfrom,
|
||||
rank() OVER (PARTITION BY person_id ORDER BY validfrom DESC) as pos
|
||||
FROM chill_person_persons_to_addresses
|
||||
JOIN chill_main_address ON chill_person_persons_to_addresses.address_id = chill_main_address.id
|
||||
WHERE person_id = pid
|
||||
AND chill_main_address.validfrom <= before_date
|
||||
) AS ranking ON ranking.address_id = chill_main_address.id
|
||||
JOIN chill_main_postal_code ON chill_main_address.postcode_id = chill_main_postal_code.id
|
||||
JOIN country ON chill_main_postal_code.country_id = country.id
|
||||
WHERE ranking.pos = 1
|
||||
$BODY$
|
||||
LANGUAGE sql VOLATILE
|
||||
COST 100;
|
||||
SQL
|
||||
);
|
||||
|
||||
// create function to get part of address
|
||||
foreach ($this->fields as $var => $type) {
|
||||
$this->addSql(sprintf(<<<'SQL'
|
||||
CREATE OR REPLACE FUNCTION get_last_address_%s (
|
||||
pid integer,
|
||||
before_date date)
|
||||
RETURNS %s AS
|
||||
$BODY$
|
||||
SELECT %s FROM get_last_address(pid, before_date)
|
||||
$BODY$
|
||||
LANGUAGE sql volatile
|
||||
COST 100;
|
||||
SQL
|
||||
, $var, $type, $var));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function down(Schema $schema)
|
||||
{
|
||||
// drop function to get parts of address
|
||||
foreach ($this->fields as $var => $type) {
|
||||
$this->addSql(<<<SQL
|
||||
|
||||
DROP FUNCTION get_last_address_$var (
|
||||
pid integer,
|
||||
before_date date)
|
||||
SQL
|
||||
);
|
||||
}
|
||||
|
||||
$this->addSQL(<<<SQL
|
||||
DROP FUNCTION public.get_last_address (
|
||||
pid integer,
|
||||
before_date date)
|
||||
SQL
|
||||
);
|
||||
|
||||
}
|
||||
}
|
@@ -14,6 +14,7 @@ dateOfBirth: date de naissance
|
||||
dateofbirth: date de naissance
|
||||
'Unknown date of birth': 'Date de naissance inconnue'
|
||||
Nationality: Nationalité
|
||||
nationality: nationalité
|
||||
'Without nationality': 'Sans nationalité'
|
||||
Gender: Genre
|
||||
gender: genre
|
||||
@@ -22,6 +23,7 @@ gender: genre
|
||||
'Place of birth': 'Lieu de naissance'
|
||||
placeOfBirth: lieu de naissance
|
||||
'Country of birth': 'Pays de naissance'
|
||||
countryOfBirth: 'Pays de naissance'
|
||||
'Unknown country of birth': 'Pays inconnu'
|
||||
'Marital status': 'État civil'
|
||||
'Number of children': 'Nombre d''enfants'
|
||||
@@ -53,6 +55,17 @@ Married: Marié(e)
|
||||
'Family information': Famille
|
||||
'Contact information': 'Informations de contact'
|
||||
'Administrative information': Administratif
|
||||
|
||||
# addresses part
|
||||
address_street_address_1: Adresse ligne 1
|
||||
address_street_address_2: Adresse ligne 2
|
||||
address_valid_from: Date de début de validité de l'adresse
|
||||
address_postcode_label: Commune
|
||||
address_postcode_code: Code postal
|
||||
address_country_name: Pays
|
||||
address_country_code: Code pays
|
||||
|
||||
|
||||
'Alreay existing person': 'Dossiers déjà encodés'
|
||||
'Add the person': 'Ajouter la personne'
|
||||
'Confirm the creation': 'Confirmer la création'
|
||||
|
@@ -1,71 +0,0 @@
|
||||
"{{ 'Person id'|trans }}",{#
|
||||
#}"{{ 'First name'|trans }}",{#
|
||||
#}"{{ 'Last name'|trans }}",{#
|
||||
#}"{{ 'Gender'|trans }}",{#
|
||||
#}"{{ 'Date of birth'|trans }}",{#
|
||||
#}"{{ 'Place of birth'|trans }}",{#
|
||||
#}"{{ 'Nationality'|trans }}",{#
|
||||
#}"{{ 'Spoken languages'|trans }}",{#
|
||||
#}"{{ 'Email'|trans }}",{#
|
||||
#}"{{ 'Phonenumber'|trans }}",{#
|
||||
#}"{{ 'Marital Status'|trans }}",{#
|
||||
#}"{{ 'Center'|trans }}",{#
|
||||
#}{% if cf_group %}{#
|
||||
#}{% for customField in cf_group.customFields %}{#
|
||||
#}"{{ chill_custom_field_label(customField) }}"{% if not loop.last %},{% endif %}{#
|
||||
#}{% endfor %}{#
|
||||
#}{% endif %}{#
|
||||
|
||||
#}{{ '\r\n'|raw }}{#
|
||||
#}{% for person in persons %}{#
|
||||
#}{{ person.id }},{#
|
||||
#}"{{ person.firstName|csv_cell }}",{#
|
||||
#}"{{ person.lastName|csv_cell }}",{#
|
||||
#}"{{ person.gender|csv_cell }}",{#
|
||||
#}"{{ person.birthdate|localizeddate('short', 'none') }}",{#
|
||||
#}"{# countryOfBirth
|
||||
#}{% if person.countryOfBirth is not null %}{#
|
||||
#}{{ person.countryOfBirth.name|localize_translatable_string }}{#
|
||||
#}{% else %}{#
|
||||
#}{{ 'Unknown country of birth'|trans }}{#
|
||||
#}{% endif %}{#
|
||||
#}",{#
|
||||
#}"{# nationality
|
||||
#}{% if person.nationality is not null %}{#
|
||||
#}{{ person.nationality.name|localize_translatable_string }}{#
|
||||
#}{% else %}{#
|
||||
#}{{ 'Without nationality'|trans }}{#
|
||||
#}{% endif %}{#
|
||||
#}",{#
|
||||
#}"{# spokenLanguages
|
||||
#}{% if person.spokenLanguages|length == 0 %}{#
|
||||
#}{{ 'Unknown spoken languages'|trans }}{#
|
||||
#}{% else %}{#
|
||||
#}{% for lang in person.spokenLanguages %}{#
|
||||
#}{{ lang.name|localize_translatable_string }}{% if not loop.last %},{% endif %}{#
|
||||
#}{% endfor %}{#
|
||||
#}{% endif %}{#
|
||||
#}",{#
|
||||
#}"{{ person.email|csv_cell }}",{#
|
||||
#}"{{ person.phonenumber|csv_cell }}",{#
|
||||
#}"{# maritalStatus
|
||||
#}{% if person.maritalStatus is not null %}{#
|
||||
#}{{ person.maritalStatus.name|localize_translatable_string}}{#
|
||||
#}{% else %}{#
|
||||
#}{{ 'Unknown marital status'|trans }}{#
|
||||
#}{% endif %}{#
|
||||
#}",{#
|
||||
#}"{{ person.center|csv_cell }}",{#
|
||||
#}{% if cf_group %}{#
|
||||
#}{% for customField in cf_group.customFields %}{#
|
||||
#}{% if customField.type == 'title' %}{#
|
||||
#}""{#
|
||||
#}{% else %}{#
|
||||
#}"{{ chill_custom_field_widget(person.cFData , customField, 'csv') }}"{#
|
||||
#}{% endif %}{#
|
||||
#}{% if not loop.last %},{% endif %}{#
|
||||
#}{% endfor %}{#
|
||||
#}{% endif %}{#
|
||||
#}{{ '\r\n'|raw }}{#
|
||||
|
||||
#}{% endfor %}
|
Reference in New Issue
Block a user