mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
First version of export person - 'rfs #400
This commit is contained in:
parent
0f4e285bd7
commit
a7b807514b
@ -118,7 +118,7 @@ class PersonController extends Controller
|
||||
return $this->redirect($url);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function searchAction()
|
||||
{
|
||||
$q = $this->getRequest()->query->getAlnum('q', '');
|
||||
@ -176,6 +176,26 @@ class PersonController extends Controller
|
||||
'pattern' => $q
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a csv file with all the persons
|
||||
*
|
||||
* @return A csv file with all the persons
|
||||
*/
|
||||
public function exportAction()
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$persons = $em->getRepository('ChillPersonBundle:Person')->findAll();
|
||||
|
||||
$response = $this->render('ChillPersonBundle:Person:export.csv.twig',
|
||||
array(
|
||||
'persons' => $persons,
|
||||
'cf_group' => $this->getCFGroup()));
|
||||
$response->headers->set('Content-Type', 'text/csv');
|
||||
$response->headers->set('Content-Disposition', 'attachment; filename="export.csv"');
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function newAction()
|
||||
{
|
||||
|
@ -78,4 +78,13 @@ chill_person_admin:
|
||||
admin:
|
||||
order: 100
|
||||
label: menu.person.admin.index
|
||||
helper: menu.person.admin.helper
|
||||
helper: menu.person.admin.helper
|
||||
|
||||
chill_person_export:
|
||||
pattern: /{_locale}/person/export/
|
||||
defaults: { _controller: ChillPersonBundle:Person:export }
|
||||
options:
|
||||
menus:
|
||||
export:
|
||||
order: 200
|
||||
label: Export persons
|
60
Resources/views/Person/export.csv.twig
Normal file
60
Resources/views/Person/export.csv.twig
Normal file
@ -0,0 +1,60 @@
|
||||
"{{ '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 }}",{#
|
||||
#}{% if cf_group %}{#
|
||||
#}{% for customField in cf_group.customFields %}{#
|
||||
#}"{{ chill_custom_field_label(customField) }}"{% if not loop.last %},{% endif %}{#
|
||||
#}{% endfor %}{#
|
||||
#}{% endif %}{#
|
||||
#}
|
||||
|
||||
{% for person in persons %}{#
|
||||
#}{{ person.id }},{#
|
||||
#}"{{ person.firstName }}",{#
|
||||
#}"{{ person.lastName }}",{#
|
||||
#}"{{ person.genre }}",{#
|
||||
#}"{{ person.dateOfBirth|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 }}",{#
|
||||
#}{% if cf_group %}{#
|
||||
#}{% for customField in cf_group.customFields %}{#
|
||||
#}{% if customField.type == 'title' %}{#
|
||||
#}""{#
|
||||
#}{% else %}{#
|
||||
#}"{{ chill_custom_field_widget(report.cFData , customField, 'csv') }}"{#
|
||||
#}{% endif %}{#
|
||||
#}{% if not loop.last %},{% endif %}{#
|
||||
#}{% endfor %}{#
|
||||
#}{% endif %}
|
||||
|
||||
{% endfor %}
|
Loading…
x
Reference in New Issue
Block a user