diff --git a/DependencyInjection/ChillPersonExtension.php b/DependencyInjection/ChillPersonExtension.php index 5fecfa9d7..42ac8bd4d 100644 --- a/DependencyInjection/ChillPersonExtension.php +++ b/DependencyInjection/ChillPersonExtension.php @@ -113,7 +113,8 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac 'chill_person' => array( 'fields' => $config['person_fields'] ) - ) + ), + 'form_themes' => array('ChillPersonBundle:Export:ListPersonFormFields.html.twig') ); $container->prependExtensionConfig('twig', $twigConfig); diff --git a/Export/Export/ListPerson.php b/Export/Export/ListPerson.php index 1804a4895..39e305a2c 100644 --- a/Export/Export/ListPerson.php +++ b/Export/Export/ListPerson.php @@ -19,6 +19,7 @@ use Chill\PersonBundle\Entity\Person; use Chill\CustomFieldsBundle\Entity\CustomField; use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\CustomFieldsBundle\Service\CustomFieldProvider; +use Symfony\Component\Form\Extension\Core\Type\DateType; /** * Render a list of peoples @@ -87,13 +88,21 @@ class ListPerson implements ListInterface $cf->getSlug(); } - + // Add a checkbox to select fields $builder->add('fields', ChoiceType::class, array( 'multiple' => true, 'expanded' => true, 'choices' => $choices, 'choices_as_values' => true, 'label' => 'Fields to include in export', + 'choice_attr' => function($val, $key, $index) { + // add a 'data-display-target' for address fields + if (substr($val, 0, 8) === 'address_') { + return ['data-display-target' => 'address_date']; + } else { + return []; + } + }, 'constraints' => [new Callback(array( 'callback' => function($selected, ExecutionContextInterface $context) { if (count($selected) === 0) { @@ -104,7 +113,17 @@ class ListPerson implements ListInterface } ))] )); - + + // add a date field for addresses + $builder->add('address_date', DateType::class, array( + 'label' => "Address valid at this date", + 'data' => new \DateTime(), + 'attr' => array( 'class' => 'datepicker'), + 'widget'=> 'single_text', + 'format' => 'dd-MM-yyyy', + 'required' => false, + 'block_name' => 'list_export_form_address_date' + )); } /** @@ -346,7 +365,7 @@ class ListPerson implements ListInterface // get the part after address_ strtoupper(substr($f, 8)), $f)); - $qb->setParameter('address_date', new \DateTime()); + $qb->setParameter('address_date', $data['address_date']); break; default: $qb->addSelect(sprintf('person.%s as %s', $f, $f)); diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index 8bba8f4a8..c24eefb1b 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -155,6 +155,7 @@ Count peoples: Nombre de personnes List peoples: Liste des personnes Create a list of people according to various filters.: Crée une liste des personnes selon différents filtres. Fields to include in export: Champs à inclure dans l'export +Address valid at this date: Addresse valide à cette date ## filters Filter by person gender: Filtrer par genre de la personne diff --git a/Resources/views/Export/ListPersonFormFields.html.twig b/Resources/views/Export/ListPersonFormFields.html.twig new file mode 100644 index 000000000..f314355b6 --- /dev/null +++ b/Resources/views/Export/ListPersonFormFields.html.twig @@ -0,0 +1,5 @@ +{% block _export_export_list_export_form_address_date_row %} +