mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
Improve Event export: add fields + translator
This commit is contained in:
parent
8275715b56
commit
d2d85a3527
@ -48,6 +48,7 @@ use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
|||||||
use Chill\MainBundle\Entity\Center;
|
use Chill\MainBundle\Entity\Center;
|
||||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
use Symfony\Component\Form\FormFactoryInterface;
|
use Symfony\Component\Form\FormFactoryInterface;
|
||||||
|
use Symfony\Component\Translation\TranslatorInterface;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -71,22 +72,30 @@ class EventController extends Controller
|
|||||||
*/
|
*/
|
||||||
protected $formFactoryInterface;
|
protected $formFactoryInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var TranslatorInterface
|
||||||
|
*/
|
||||||
|
protected $translator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EventController constructor.
|
* EventController constructor.
|
||||||
*
|
*
|
||||||
* @param EventDispatcherInterface $eventDispatcher
|
* @param EventDispatcherInterface $eventDispatcher
|
||||||
* @param AuthorizationHelper $authorizationHelper
|
* @param AuthorizationHelper $authorizationHelper
|
||||||
* @param FormFactoryInterface $formFactoryInterface
|
* @param FormFactoryInterface $formFactoryInterface
|
||||||
|
* @param TranslatorInterface $translator
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
EventDispatcherInterface $eventDispatcher,
|
EventDispatcherInterface $eventDispatcher,
|
||||||
AuthorizationHelper $authorizationHelper,
|
AuthorizationHelper $authorizationHelper,
|
||||||
FormFactoryInterface $formFactoryInterface
|
FormFactoryInterface $formFactoryInterface,
|
||||||
|
TranslatorInterface $translator
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
$this->eventDispatcher = $eventDispatcher;
|
$this->eventDispatcher = $eventDispatcher;
|
||||||
$this->authorizationHelper = $authorizationHelper;
|
$this->authorizationHelper = $authorizationHelper;
|
||||||
$this->formFactoryInterface = $formFactoryInterface;
|
$this->formFactoryInterface = $formFactoryInterface;
|
||||||
|
$this->translator = $translator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -539,6 +548,8 @@ class EventController extends Controller
|
|||||||
$spreadsheet = new Spreadsheet();
|
$spreadsheet = new Spreadsheet();
|
||||||
$sheet = $spreadsheet->getActiveSheet();
|
$sheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
$trans = $this->translator->getLocale();
|
||||||
|
|
||||||
$headerValues = [
|
$headerValues = [
|
||||||
'A1' => 'Event',
|
'A1' => 'Event',
|
||||||
'B1' => $event->getId(),
|
'B1' => $event->getId(),
|
||||||
@ -547,17 +558,17 @@ class EventController extends Controller
|
|||||||
'A3' => 'Name',
|
'A3' => 'Name',
|
||||||
'B3' => $event->getName(),
|
'B3' => $event->getName(),
|
||||||
'A4' => 'Type',
|
'A4' => 'Type',
|
||||||
'B4' => $event->getType()->getName()['fr'], // TODO
|
'B4' => $event->getType()->getName()[$trans],
|
||||||
'A5' => 'Circle',
|
'A5' => 'Circle',
|
||||||
'B5' => $event->getCircle()->getName()['fr'], // TODO
|
'B5' => $event->getCircle()->getName()[$trans],
|
||||||
'A6' => 'Moderator',
|
'A6' => 'Moderator',
|
||||||
'B6' => $event->getModerator(),
|
'B6' => $event->getModerator() ? $event->getModerator()->getUsernameCanonical() : null,
|
||||||
];
|
];
|
||||||
foreach ($headerValues as $k => $value) {
|
foreach ($headerValues as $k => $value) {
|
||||||
$sheet->setCellValue($k, $value);
|
$sheet->setCellValue($k, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
$columnNames = [ 'id', 'firstname', 'lastname', 'email' ];
|
$columnNames = [ 'id', 'firstname', 'lastname', 'role', 'status', 'email', 'phone', 'mobile' ];
|
||||||
$columnLetter = 'A';
|
$columnLetter = 'A';
|
||||||
foreach ($columnNames as $columnName) {
|
foreach ($columnNames as $columnName) {
|
||||||
$sheet->setCellValue($columnLetter.'8', $columnName);
|
$sheet->setCellValue($columnLetter.'8', $columnName);
|
||||||
@ -565,12 +576,18 @@ class EventController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$columnValues = [];
|
$columnValues = [];
|
||||||
foreach ($event->getParticipations() as $participation) {
|
foreach ($event->getParticipations() as $participation)
|
||||||
|
{
|
||||||
|
/** @var Participation $participation */
|
||||||
$columnValues[] = [
|
$columnValues[] = [
|
||||||
$participation->getPerson()->getId(),
|
$participation->getPerson()->getId(),
|
||||||
$participation->getPerson()->getFirstname(),
|
$participation->getPerson()->getFirstname(),
|
||||||
$participation->getPerson()->getLastname(),
|
$participation->getPerson()->getLastname(),
|
||||||
$participation->getPerson()->getEmail()
|
$participation->getRole()->getName()[$trans],
|
||||||
|
$participation->getStatus()->getName()[$trans],
|
||||||
|
$participation->getPerson()->getEmail(),
|
||||||
|
$participation->getPerson()->getPhoneNumber(),
|
||||||
|
$participation->getPerson()->getMobileNumber(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -587,8 +604,4 @@ class EventController extends Controller
|
|||||||
return $spreadsheet;
|
return $spreadsheet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// pour aller plus loin
|
|
||||||
// TODO ?? inclure le type d'événement et la date dans les résultats de recherche (ex: on tape 'vis' --> il affiche les visites )
|
|
||||||
// TODO ?? exclure des résultats les événement déjà sélectionnés pour une personne. empêcher d'inscrire 2x une personne !
|
|
||||||
}
|
}
|
||||||
|
@ -4,4 +4,5 @@ services:
|
|||||||
$eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'
|
$eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'
|
||||||
$authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper'
|
$authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper'
|
||||||
$formFactoryInterface: '@Symfony\Component\Form\FormFactoryInterface'
|
$formFactoryInterface: '@Symfony\Component\Form\FormFactoryInterface'
|
||||||
|
$translator: '@Symfony\Component\Translation\TranslatorInterface'
|
||||||
tags: ['controller.service_arguments']
|
tags: ['controller.service_arguments']
|
||||||
|
Loading…
x
Reference in New Issue
Block a user