mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +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 Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\FormFactoryInterface;
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
|
||||
|
||||
/**
|
||||
@ -71,22 +72,30 @@ class EventController extends Controller
|
||||
*/
|
||||
protected $formFactoryInterface;
|
||||
|
||||
/**
|
||||
* @var TranslatorInterface
|
||||
*/
|
||||
protected $translator;
|
||||
|
||||
/**
|
||||
* EventController constructor.
|
||||
*
|
||||
* @param EventDispatcherInterface $eventDispatcher
|
||||
* @param AuthorizationHelper $authorizationHelper
|
||||
* @param FormFactoryInterface $formFactoryInterface
|
||||
* @param TranslatorInterface $translator
|
||||
*/
|
||||
public function __construct(
|
||||
EventDispatcherInterface $eventDispatcher,
|
||||
AuthorizationHelper $authorizationHelper,
|
||||
FormFactoryInterface $formFactoryInterface
|
||||
FormFactoryInterface $formFactoryInterface,
|
||||
TranslatorInterface $translator
|
||||
)
|
||||
{
|
||||
$this->eventDispatcher = $eventDispatcher;
|
||||
$this->authorizationHelper = $authorizationHelper;
|
||||
$this->formFactoryInterface = $formFactoryInterface;
|
||||
$this->translator = $translator;
|
||||
}
|
||||
|
||||
|
||||
@ -539,6 +548,8 @@ class EventController extends Controller
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
$trans = $this->translator->getLocale();
|
||||
|
||||
$headerValues = [
|
||||
'A1' => 'Event',
|
||||
'B1' => $event->getId(),
|
||||
@ -547,17 +558,17 @@ class EventController extends Controller
|
||||
'A3' => 'Name',
|
||||
'B3' => $event->getName(),
|
||||
'A4' => 'Type',
|
||||
'B4' => $event->getType()->getName()['fr'], // TODO
|
||||
'B4' => $event->getType()->getName()[$trans],
|
||||
'A5' => 'Circle',
|
||||
'B5' => $event->getCircle()->getName()['fr'], // TODO
|
||||
'B5' => $event->getCircle()->getName()[$trans],
|
||||
'A6' => 'Moderator',
|
||||
'B6' => $event->getModerator(),
|
||||
'B6' => $event->getModerator() ? $event->getModerator()->getUsernameCanonical() : null,
|
||||
];
|
||||
foreach ($headerValues as $k => $value) {
|
||||
$sheet->setCellValue($k, $value);
|
||||
}
|
||||
|
||||
$columnNames = [ 'id', 'firstname', 'lastname', 'email' ];
|
||||
$columnNames = [ 'id', 'firstname', 'lastname', 'role', 'status', 'email', 'phone', 'mobile' ];
|
||||
$columnLetter = 'A';
|
||||
foreach ($columnNames as $columnName) {
|
||||
$sheet->setCellValue($columnLetter.'8', $columnName);
|
||||
@ -565,12 +576,18 @@ class EventController extends Controller
|
||||
}
|
||||
|
||||
$columnValues = [];
|
||||
foreach ($event->getParticipations() as $participation) {
|
||||
foreach ($event->getParticipations() as $participation)
|
||||
{
|
||||
/** @var Participation $participation */
|
||||
$columnValues[] = [
|
||||
$participation->getPerson()->getId(),
|
||||
$participation->getPerson()->getFirstname(),
|
||||
$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;
|
||||
}
|
||||
|
||||
|
||||
// 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'
|
||||
$authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper'
|
||||
$formFactoryInterface: '@Symfony\Component\Form\FormFactoryInterface'
|
||||
$translator: '@Symfony\Component\Translation\TranslatorInterface'
|
||||
tags: ['controller.service_arguments']
|
||||
|
Loading…
x
Reference in New Issue
Block a user