Skip to content

Commit 2771f3a

Browse files
author
Raphael
committed
feature/move-inscription-page-to-sf : WIP
1 parent e055880 commit 2771f3a

File tree

5 files changed

+506
-0
lines changed

5 files changed

+506
-0
lines changed

app/config/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ parameters:
128128
forum_inscriptions:
129129
nom: 'Inscriptions'
130130
niveau: 'ROLE_FORUM'
131+
url: '/admin/event/inscription'
132+
extra_routes:
133+
- admin_event_inscription_list
131134
forum_pending_bankwires:
132135
nom: 'Virements en attente'
133136
niveau: 'ROLE_ADMIN'

app/config/routing/admin_event.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,7 @@ admin_event_restore:
105105
admin_event_votes:
106106
path: /votes
107107
defaults: {_controller: AppBundle\Controller\Admin\Event\VotesListeAction}
108+
109+
admin_event_inscription_list:
110+
path: /inscription
111+
defaults: { _controller: AppBundle\Controller\Admin\Event\Inscription\ListAction}
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
<?php
2+
3+
namespace AppBundle\Controller\Admin\Event\Inscription;
4+
5+
use AppBundle\Controller\Event\EventActionHelper;
6+
use AppBundle\Event\Form\EventSelectType;
7+
use AppBundle\Event\Model\Repository\EventRepository;
8+
use AppBundle\Event\Model\Repository\EventStatsRepository;
9+
use AppBundle\Event\Model\Repository\TicketEventTypeRepository;
10+
use AppBundle\Event\Model\Repository\TicketRepository;
11+
use AppBundle\Event\Ticket\TicketTypeAvailability;
12+
use DateTime;
13+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
14+
use Symfony\Component\HttpFoundation\Request;
15+
use Symfony\Component\HttpFoundation\Response;
16+
17+
class ListAction extends AbstractController
18+
{
19+
public function __invoke(
20+
Request $request,
21+
EventActionHelper $eventActionHelper,
22+
EventRepository $eventRepository,
23+
TicketEventTypeRepository $ticketEventTypeRepository,
24+
TicketTypeAvailability $ticketTypeAvailability,
25+
EventStatsRepository $eventStatsRepository,
26+
TicketRepository $ticketRepository,
27+
): Response
28+
{
29+
$id = $request->query->get('id');
30+
$direction = $request->query->get('direction');
31+
$sort = $request->query->get('sort');
32+
$filter = $request->query->get('filter');
33+
34+
$event = $id ? $eventActionHelper->getEventById($id) : $eventRepository->getLastEvent();
35+
36+
$membersTicket = [];
37+
38+
$restantes = $this->updateGlobalsForTarif($eventRepository, $ticketEventTypeRepository, $ticketTypeAvailability, $event->getId(), $membersTicket)['restantes'];
39+
40+
$stats = $eventStatsRepository->getStats($event->getId());
41+
42+
return $this->render('event/inscription/list.html.twig', [
43+
'filter' => $filter,
44+
'direction' => $direction,
45+
'sort' => $sort,
46+
'forumTarifsMembers' => $membersTicket,
47+
'now' => new DateTime(),
48+
'inscriptions' => $ticketRepository->getTicketsForList($event, $filter, $sort, $direction),
49+
'restantes' => $restantes,
50+
'statistiques' => [
51+
'premier_jour' => [
52+
'inscrits' => $stats->firstDay->registered,
53+
'confirmes' => $stats->firstDay->confirmed,
54+
'en_attente_de_reglement' => $stats->firstDay->pending,
55+
],
56+
'second_jour' => [
57+
'inscrits' => $stats->secondDay->registered,
58+
'confirmes' => $stats->secondDay->confirmed,
59+
'en_attente_de_reglement' => $stats->secondDay->pending,
60+
],
61+
'types_inscriptions' => [
62+
'confirmes' => $stats->ticketType->confirmed,
63+
'inscrits' => $stats->ticketType->registered,
64+
'payants' => $stats->ticketType->paying,
65+
],
66+
],
67+
'forumTarifsLib' => [
68+
AFUP_FORUM_INVITATION => 'Invitation',
69+
AFUP_FORUM_ORGANISATION => 'Organisation',
70+
AFUP_FORUM_PROJET => 'Projet PHP',
71+
AFUP_FORUM_SPONSOR => 'Sponsor',
72+
AFUP_FORUM_PRESSE => 'Presse',
73+
AFUP_FORUM_PROF => 'Enseignement supérieur',
74+
AFUP_FORUM_CONFERENCIER => 'Conferencier',
75+
AFUP_FORUM_PREMIERE_JOURNEE => 'Jour 1 ',
76+
AFUP_FORUM_DEUXIEME_JOURNEE => 'Jour 2',
77+
AFUP_FORUM_2_JOURNEES => '2 Jours',
78+
AFUP_FORUM_2_JOURNEES_AFUP => '2 Jours AFUP',
79+
AFUP_FORUM_PREMIERE_JOURNEE_AFUP => 'Jour 1 AFUP',
80+
AFUP_FORUM_DEUXIEME_JOURNEE_AFUP => 'Jour 2 AFUP',
81+
AFUP_FORUM_2_JOURNEES_ETUDIANT => '2 Jours Etudiant',
82+
AFUP_FORUM_PREMIERE_JOURNEE_ETUDIANT => 'Jour 1 Etudiant',
83+
AFUP_FORUM_DEUXIEME_JOURNEE_ETUDIANT => 'Jour 2 Etudiant',
84+
AFUP_FORUM_2_JOURNEES_PREVENTE => '2 Jours prévente',
85+
AFUP_FORUM_2_JOURNEES_AFUP_PREVENTE => '2 Jours AFUP prévente',
86+
AFUP_FORUM_2_JOURNEES_PREVENTE_ADHESION => '2 Jours prévente + adhésion',
87+
AFUP_FORUM_2_JOURNEES_ETUDIANT_PREVENTE => '2 Jours Etudiant prévente',
88+
AFUP_FORUM_2_JOURNEES_COUPON => '2 Jours avec coupon de réduction',
89+
AFUP_FORUM_2_JOURNEES_SPONSOR => '2 Jours par Sponsor',
90+
AFUP_FORUM_PREMIERE_JOURNEE_ETUDIANT_PREVENTE => '',
91+
AFUP_FORUM_DEUXIEME_JOURNEE_ETUDIANT_PREVENTE => '',
92+
AFUP_FORUM_SPECIAL_PRICE => 'Tarif Spécial',
93+
],
94+
'forumTarifs' => [
95+
AFUP_FORUM_INVITATION => 0,
96+
AFUP_FORUM_ORGANISATION => 0,
97+
AFUP_FORUM_SPONSOR => 0,
98+
AFUP_FORUM_PRESSE => 0,
99+
AFUP_FORUM_CONFERENCIER => 0,
100+
AFUP_FORUM_PROJET => 0,
101+
AFUP_FORUM_PROF => 0,
102+
AFUP_FORUM_PREMIERE_JOURNEE => 150,
103+
AFUP_FORUM_DEUXIEME_JOURNEE => 150,
104+
AFUP_FORUM_2_JOURNEES => 250,
105+
AFUP_FORUM_2_JOURNEES_AFUP => 150,
106+
AFUP_FORUM_PREMIERE_JOURNEE_AFUP => 100,
107+
AFUP_FORUM_DEUXIEME_JOURNEE_AFUP => 100,
108+
AFUP_FORUM_2_JOURNEES_ETUDIANT => 150,
109+
AFUP_FORUM_PREMIERE_JOURNEE_ETUDIANT => 100,
110+
AFUP_FORUM_DEUXIEME_JOURNEE_ETUDIANT => 100,
111+
AFUP_FORUM_2_JOURNEES_PREVENTE => 150,
112+
AFUP_FORUM_2_JOURNEES_AFUP_PREVENTE => 150,
113+
AFUP_FORUM_2_JOURNEES_PREVENTE_ADHESION => 150,
114+
AFUP_FORUM_PREMIERE_JOURNEE_ETUDIANT_PREVENTE => 100,
115+
AFUP_FORUM_DEUXIEME_JOURNEE_ETUDIANT_PREVENTE => 100,
116+
AFUP_FORUM_2_JOURNEES_ETUDIANT_PREVENTE => 150,
117+
AFUP_FORUM_2_JOURNEES_COUPON => 200,
118+
AFUP_FORUM_2_JOURNEES_SPONSOR => 200,
119+
AFUP_FORUM_SPECIAL_PRICE => 0,
120+
],
121+
'event' => $event,
122+
'event_select_form' => $this->createForm(EventSelectType::class, $event)->createView(),
123+
]);
124+
}
125+
126+
private function updateGlobalsForTarif(
127+
EventRepository $eventRepository,
128+
TicketEventTypeRepository $ticketEventTypeRepository,
129+
TicketTypeAvailability $ticketTypeAvailability,
130+
$forumId,
131+
&$membersTickets = []
132+
): array {
133+
global $AFUP_Tarifs_Forum, $AFUP_Tarifs_Forum_Lib;
134+
$event = $eventRepository->get($forumId);
135+
$ticketTypes = $ticketEventTypeRepository->getTicketsByEvent($event, false);
136+
$AFUP_Tarifs_Forum_Restantes = [];
137+
138+
foreach ($ticketTypes as $ticketType) {
139+
/**
140+
* @var $ticketType \AppBundle\Event\Model\TicketEventType
141+
*/
142+
$AFUP_Tarifs_Forum[$ticketType->getTicketTypeId()] = $ticketType->getPrice();
143+
$AFUP_Tarifs_Forum_Lib[$ticketType->getTicketTypeId()] = $ticketType->getTicketType()->getPrettyName();
144+
$AFUP_Tarifs_Forum_Restantes[$ticketType->getTicketTypeId()] = $ticketTypeAvailability->getStock($ticketType, $event);
145+
146+
if ($ticketType->getTicketType()->getIsRestrictedToMembers()) {
147+
$membersTickets[] = $ticketType->getTicketTypeId();
148+
}
149+
}
150+
151+
return ['restantes' => $AFUP_Tarifs_Forum_Restantes];
152+
}
153+
}

sources/AppBundle/Event/Model/Repository/TicketRepository.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,65 @@ public function getAllTicketsForExport()
214214
->query($this->getCollection(new HydratorSingleObject()));
215215
}
216216

217+
public function getTicketsForList(Event $event, ?string $filter, ?string $sort, ?string $direction): CollectionInterface
218+
{
219+
$availableSorts = [
220+
'date' => 'i.date',
221+
'name' => 'i.nom',
222+
'societe' => 'f.societe',
223+
'type' => 'i.type_inscription',
224+
'etat' => 'i.etat',
225+
];
226+
227+
$params = [
228+
'eventId' => $event->getId()
229+
];
230+
231+
$sql = <<<SQL
232+
SELECT i.id,
233+
i.date,
234+
i.nom,
235+
i.prenom,
236+
i.email,
237+
f.societe,
238+
i.etat,
239+
i.coupon,
240+
i.type_inscription,
241+
f.type_reglement,
242+
i.presence_day1,
243+
i.presence_day2,
244+
CASE
245+
WHEN i.id_member IS NOT NULL
246+
THEN (SELECT MAX(ac.date_fin) AS lastsubcription FROM afup_cotisations ac WHERE ac.type_personne = i.member_type AND ac.id_personne = i.id_member)
247+
ELSE (SELECT MAX(ac.date_fin) AS lastsubcription
248+
FROM afup_personnes_physiques app
249+
LEFT JOIN afup_personnes_morales apm ON apm.id = app.id_personne_morale
250+
LEFT JOIN afup_cotisations ac ON ac.type_personne = IF(apm.id IS NULL, 0, 1) AND ac.id_personne = IFNULL(apm.id, app.id)
251+
WHERE app.email = i.email
252+
GROUP BY app.`id`)
253+
END AS lastsubscription
254+
FROM afup_inscription_forum i
255+
LEFT JOIN afup_facturation_forum f ON i.reference = f.reference
256+
257+
WHERE 1 = 1
258+
AND i.id_forum = :eventId
259+
SQL;
260+
261+
if ($filter) {
262+
$sql .= ' AND CONCAT(i.nom, i.prenom) LIKE :filter OR f.societe LIKE :filter';
263+
$params['filter'] = "%$filter%";
264+
}
265+
if (isset($availableSorts[$sort])) {
266+
$sql .= ' ORDER BY ' . $availableSorts[$sort] . ' ' . $direction;
267+
}
268+
269+
return $this
270+
->getPreparedQuery($sql)
271+
->setParams($params)
272+
->query($this->getCollection(new HydratorArray()))
273+
;
274+
}
275+
217276
/**
218277
* @inheritDoc
219278
*/

0 commit comments

Comments
 (0)