<?php
namespace App\Controller;
use App\Admin\EventAdmin;
use App\Business\BookingOrigin;
use App\Business\EventCategoryProvider;
use App\Entity\Event;
use App\Services\ActionLoggerService;
use App\Services\ContactService;
use App\Services\DashboardService;
use App\Services\Elastic\ElasticNeosService;
use App\Services\EventArticleService;
use App\Services\EventFollowerService;
use App\Services\EventRightAccessService;
use App\Services\EventService;
use App\Services\NewslettersService;
use App\Services\BookingCatalogService;
use App\Services\SplunkService;
use App\Services\UserService;
use App\Services\CustomerOrderService;
use App\Utils\JsonResponseHelper;
use Exception;
use Knp\Snappy\Pdf;
use Symfony\Component\Routing\Annotation\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Security\Core\Security as SecurityInterface;
class EventController extends BaseController
{
/** @var ActionLoggerService $actionLoggerService */
protected $actionLoggerService;
/** @var ElasticNeosService $elasticNeosService */
protected $elasticNeosService;
/** @var EventService $eventService */
protected $eventService;
/** @var ContactService $contactService */
protected $contactService;
/** @var EventFollowerService $eventFollowerService */
protected $eventFollowerService;
/** @var EventRightAccessService $eventRightAccessService */
protected $eventRightAccessService;
/** @var EventUpdatesLinksController $eventUpdatesLinksController */
protected $eventUpdatesLinksController;
/** @var UserService $userService */
protected $userService;
/** @var DashboardService $dashboardService */
protected $dashboardService;
/** @var NewslettersService $newslettersService */
protected $newslettersService;
/** @var SplunkService $splunkService */
private $splunkService;
/** @var BookingCatalogService $bookingCatalogService */
private $bookingCatalogService;
/** @var CustomerOrderService $customerOrderService */
private $customerOrderService;
/** @var SecurityInterface $security */
protected SecurityInterface $security;
/**
* EventController constructor.
*
* @param EventService $eventService
* @param ElasticNeosService $elasticNeosService
* @param ContactService $contactService
* @param ActionLoggerService $actionLoggerService
* @param EventRightAccessService $eventRightAccessService
* @param EventFollowerService $eventFollowerService
* @param EventUpdatesLinksController $eventUpdatesLinksController
* @param UserService $userService
* @param DashboardService $dashboardService
* @param SplunkService $splunkService
* @param NewslettersService $newslettersService
*/
public function __construct(
EventService $eventService,
ElasticNeosService $elasticNeosService,
ContactService $contactService,
ActionLoggerService $actionLoggerService,
EventRightAccessService $eventRightAccessService,
EventFollowerService $eventFollowerService,
EventUpdatesLinksController $eventUpdatesLinksController,
UserService $userService,
DashboardService $dashboardService,
SplunkService $splunkService,
NewslettersService $newslettersService,
BookingCatalogService $bookingCatalogService,
CustomerOrderService $customerOrderService,
SecurityInterface $security
)
{
parent::__construct($security);
$this->eventService = $eventService;
$this->eventRightAccessService = $eventRightAccessService;
$this->elasticNeosService = $elasticNeosService;
$this->contactService = $contactService;
$this->actionLoggerService = $actionLoggerService;
$this->eventFollowerService = $eventFollowerService;
$this->eventUpdatesLinksController = $eventUpdatesLinksController;
$this->userService = $userService;
$this->dashboardService = $dashboardService;
$this->splunkService = $splunkService;
$this->newslettersService = $newslettersService;
$this->bookingCatalogService = $bookingCatalogService;
$this->customerOrderService = $customerOrderService;
}
/**
* @Route("/events/all", name="events_all_home", options={"expose" = true }, methods={"GET", "POST"})
* @Route("/events/all/", name="events_all_home_slash", methods={"GET", "POST"})
* @Route("/events", name="events_home", methods={"GET", "POST"})
* @Route("/events/", name="events_home_slash", methods={"GET", "POST"})
* @Route("/events/all/{category}", name="events_home_with_category", methods={"GET", "POST"})
* @Route("/events/all/{category}/", name="events_home_with_category_slash", methods={"GET", "POST"})
* @param Request|null $request
* @return Response
*/
public function eventsHomeAction(?Request $request)
{
$filter = $this->getFilterFromRequest($request, true);
$adminUrl = $this->getAdminUrl();
return $this->render(
'event/events.html.twig',
[
'location' => 'all',
'pageTitle' => 'All Events',
'tabTitle' => '',
'filter' => $filter,
BaseController::PARAM_ADMIN_URL => $adminUrl,
'view' => $filter['view']
]
);
}
public function getFilterFromRequest(Request $request = null, bool $defaultIsYear = false)
{
$search = $request->query->has('search') ? $request->query->get('search') : null;
$date = $request->query->has('date') ? $request->query->get('date') : ($defaultIsYear ? 'year' : 'week');
$category = $request->attributes->has('category') ? $request->get('category') : null;
$sortedBy = $request->query->has('sorted') ? $request->query->get('sorted') : null;
$view = $request->query->has('view') ? $request->query->get('view') : 'xsmall';
$worldfeed = $request->query->has('worldfeed') ? $request->query->get('worldfeed') : false;
$isRadio = $request->query->has('isRadio') ? $request->query->get('isRadio') : false;
$specials_urls = ["sports", "news", "culture-and-entertainment"];
if (in_array($category, $specials_urls)) {
$category = null;
}
$filter = [
'search' => $search,
'date' => $date,
'category' => $category != "all" ? $category : null,
'worldfeed' => $worldfeed,
'isRadio' => $isRadio,
'sorted' => $sortedBy,
'view' => $view
];
return $filter;
}
/**
* @return null|string the admin url if the current user can access to it.
*/
private function getAdminUrl()
{
$adminUrl = null;
if ($this->security->isGranted("ROLE_ADMIN_EVENTS_ADMINISTRATOR")) {
/** @noinspection PhpRouteMissingInspection */
$adminUrl = $this->generateUrl('admin_app_event_list');
}
return $adminUrl;
}
/**
* @Route("/events/sports", name="events_sports", options={"expose" = true }, methods={"GET", "POST"})
* @Route("/events/sports/", name="events_sports_slash", methods={"GET", "POST"})
* @Route("/events/sports/{category}", name="events_sports_category", methods={"GET", "POST"})
* @Route("/events/sports/{category}/", name="events_sports_slash_with_category", methods={"GET", "POST"})
* @param Request|null $request
* @return Response
*/
public function eventsSportsAction(Request $request = null)
{
$filter = $this->getFilterFromRequest($request, true);
$adminUrl = $this->getAdminUrl();
return $this->render(
'event/events.html.twig', [
'location' => 'sports',
'pageTitle' => EventCategoryProvider::CAT_SPORTS_TITLE,
'tabTitle' => EventCategoryProvider::CAT_SPORTS_NAME,
'filter' => $filter,
BaseController::PARAM_ADMIN_URL => $adminUrl,
'view' => $filter['view']
]
);
}
/**
* @Route("/events/culture-and-entertainment", name="events_culture-and-entertainment", options={"expose" = true }, methods={"GET", "POST"})
* @Route("/events/culture-and-entertainment/", name="events_culture-and-entertainment_slash", methods={"GET", "POST"})
* @Route("/events/culture-and-entertainment/{category}", name="events_culture-and-entertainment_with_category", methods={"GET", "POST"})
* @Route("/events/culture-and-entertainment/{category}/", name="events_culture-and-entertainment_slash_with_category", methods={"GET", "POST"})
* @param Request|null $request
* @return Response
*/
public function eventsCultureAndReligionAction(Request $request = null)
{
$filter = $this->getFilterFromRequest($request, true);
$adminUrl = $this->getAdminUrl();
return $this->render(
'event/events.html.twig', [
'location' => 'culture-and-entertainment',
'pageTitle' => EventCategoryProvider::CAT_CULTURE_TITLE,
'tabTitle' => EventCategoryProvider::CAT_CULTURE_NAME,
'filter' => $filter,
BaseController::PARAM_ADMIN_URL => $adminUrl,
'view' => $filter['view']
]
);
}
/**
* @Route("/intern/events/list", name="events_list", options={"expose" = true }, methods={"GET", "POST"})
* @param $filter
* @return Response
*/
public function eventsListAction(Request $request)
{
$eventType = $request->query->has('type') ? $request->query->get('type') : 'all';
$filter = $this->getFilterFromRequest($request, true);
$events = $this->eventService->getEventsByType($eventType, $filter, null);
foreach ($events as $event) {
$event->currentUserIsFollower = $this->getFollowStatus($event->getId());
}
return $this->render(
'event/events_list.html.twig', [
'events' => $events,
'eventType' => $eventType
]
);
}
public function getFollowStatus($eventId)
{
$followStatus = $this->eventFollowerService->isUserFollowEvent($eventId);
return $followStatus;
}
/**
* @Route("/events/{eventType}/{category}/{eventNo}/details", name="events_details", options={"expose" = true}, methods={"GET", "POST"})
* @param SessionInterface $session
* @param string $category
* @param string $eventNo
* @return Response
* @internal param Event $event
*/
public function eventsDetailsAction(SessionInterface $session, string $category, string $eventNo, string $eventType)
{
$event = $this->eventService->getEventByNo($eventNo);
// Get programme and timings list
if ($event == null) {
if ($eventType == 'sports') {
return $this->redirectToRoute('events_sports');
} else if ($eventType == 'culture') {
return $this->redirectToRoute('events_home');
} else {
return $this->redirectToRoute('events_home');
}
}
if ($event->getStatus() != 'PUBLISHED' && $event->getStatus() != 'PUBLISHED_NO_BOOKINGS') {
return $this->redirectToRoute('events_home');
}
if ($event->isSport()) {
$redirect = $this->redirectToCorrectCategory($event, EventCategoryProvider::CAT_SPORTS, $category);
} else if ($event->isNews()) {
$redirect = $this->redirectToCorrectCategory($event, EventCategoryProvider::CAT_NEWS, $category);
} else {
$redirect = $this->redirectToCorrectCategory($event, EventCategoryProvider::CAT_CULTURE, $category);
}
if ($redirect != null) {
return $redirect;
}
$bookingUrl = $this->generateBookingUrl($event, 'newbooking-with-input');
$isRhsBookingAllowed = $event->getRhsBookingAllowed();
$isParticipationAllowed = $this->elasticNeosService->hasParticipationsInTheFuture($eventNo);
$isUnilateralAllowed = $this->bookingCatalogService->checkIfEventHasUnilateral($event);
$rhsActivatedForEvent = $this->eventRightAccessService->isRhsEventAccessDefined($event->getId());
$isWorkspaceBookingAllowed = $this->customerOrderService->checkIfEventHasWorkspace($event, $rhsActivatedForEvent);
$adminUrl = null;
if ($this->security->isGranted("ROLE_ADMIN_EVENTS_ADMINISTRATOR")) {
$adminUrl = $this->generateUrl(EventAdmin::PATH_ADMIN_APP_EVENT_EDIT, ['id' => $event->getId()]);
}
$userCompanyStatus = (!empty($this->userService->getCurrentUserMainInformation()->memberCompanyStatus)) ? $this->userService->getCurrentUserMainInformation()->memberCompanyStatus : null;
return $this->render(
'event/events_details.html.twig', [
'key' => $this->getParameter('google_maps_key'),
'event' => $event,
'hasRelatedEvents' => $event->hasRelatedEvents(),
'hasTransmissions' => $this->elasticNeosService->hasTransmissions($eventNo),
'isRhsBookingAllowed' => $isRhsBookingAllowed,
'isParticipationAllowed' => $isParticipationAllowed,
'isWorkspaceBookingAllowed' => $isWorkspaceBookingAllowed,
'isUnilateralAllowed' => $isUnilateralAllowed,
'currentPage' => 1,
'nbUpdatesPages' => $this->getUser() ? $this->eventUpdatesLinksController->getNbUpdatesPages($this->getUser(), $session, $event): null,
'bookingUrl' => $bookingUrl,
BaseController::PARAM_ADMIN_URL => $adminUrl,
'follow' => $this->getFollowStatus($event->getId()),
'userCompanyStatus' => $userCompanyStatus
]);
}
/**
* @param Event $event
* @param string $initType
* @param string $iniCategory
* @return null|RedirectResponse the redirection to the correct type
*/
private function redirectToCorrectCategory(Event $event, string $initType = null, string $iniCategory = null)
{
$mainCat = EventCategoryProvider::getMainCategory($event);
$category = $event->getCategoryUrl();
if ($mainCat != $initType || $iniCategory != $category) {
$generateEventNoArray = self::generateEventNoArray($event);
$generateEventNoArray['category'] = $category;
if ($mainCat == EventCategoryProvider::CAT_NEWS) {
$generateEventNoArray['eventType'] = 'news';
}
if ($mainCat == EventCategoryProvider::CAT_CULTURE) {
$generateEventNoArray['eventType'] = 'culture-and-entertainment';
} else {
$generateEventNoArray['eventType'] = 'sports';
}
return $this->redirectToRoute('events_details',
$generateEventNoArray);
}
return null;
}
/**
* @param Event $event
* @return array
*/
private static function generateEventNoArray(Event $event): array
{
return [Event::PROP_EVENT_NO => $event->getEventNo()];
}
private function generateBookingUrl(Event $event, string $route): ?string
{
if (!$event->isBookable()) {
return null;
}
if (empty($route)) {
$route = 'newbooking-with-input';
}
return $this->generateUrl($route,
['type' => strtolower(BookingOrigin::TYPE_EVENT), 'code' => $event->getEventNo()]);
}
/**
* @Route("/events/{eventType}/{category}/{eventNo}/worldfeed/{transmissionNo}", name="events_details_worldfeed", methods={"GET", "POST"})
* @param Request $request
* @param string $eventType
* @param string $category
* @param string $eventNo
* @param string $transmissionNo
* @return Response
*/
public function eventsDetailsWorldfeedAction(Request $request, string $eventType, string $category, string $eventNo, string $transmissionNo)
{
// Add worldfeed details log for the splunk dashboard
$worldFeed = $this->eventService->getWorldfeedByNo($transmissionNo);
$this->dashboardService->addCustomLog($worldFeed, 'GET_WORLDFEED_DETAILS', $this->generateUrl('events_details_worldfeed', ['eventType' => $eventType, 'category' => $category, 'eventNo' => $eventNo, 'transmissionNo' => $transmissionNo]));
return $this->renderWorldFeed($eventNo, $transmissionNo, $request);
}
/**
* @param string $eventNo
* @param string $transmissionNo
* @param bool $directAccessTechnicalDetails
* @param Request $request
* @return Response
*/
public function renderWorldFeed(string $eventNo, string $transmissionNo, Request $request): Response
{
$worldFeed = $this->eventService->getWorldfeedByNo($transmissionNo);
$event = $this->eventService->getEventByNo($eventNo);
if (empty($worldFeed) || empty($event)) {
return $this->redirectToRoute('events_all_home');
}
$adminUrl = null;
if ($this->security->isGranted("ROLE_ADMIN_EVENTS_ADMINISTRATOR")) {
$adminUrl = $this->generateUrl(EventAdmin::PATH_ADMIN_APP_EVENT_EDIT, ['id' => $event->getId()]);
}
$synopsis = $this->dashboardService->getSynopsisTextDetails($transmissionNo, "f049c00d5f8368fad9a7b8b2a55ee6efabd87399");
return $this->render(
'event/events_worldfeed_details.html.twig', [
'event' => $event,
'user' => $this->getUser(),
'worldfeed' => $worldFeed,
'synopsis' => $synopsis,
'city' => $this->eventService->getLocationCityCountry($worldFeed),
'source' => $this->eventService->getSourceName($worldFeed),
'directAccessTechnicalDetails' => $request->get('directAccessTechnicalDetails'),
BaseController::PARAM_ADMIN_URL => $adminUrl,
'follow' => $this->getFollowStatus($event->getId())
]);
}
/**
* warning: the route name is used in EventAdmin in a constant.
* @Route("/events/from-id/{id}", name="events_from_id_details", options={"expose" = true }, methods={"GET", "POST"})
* @Security("is_granted('ROLE_USER')")
* @param string $id
* @return Response* @internal param Event $event
*/
public function eventsFromIdDetailsAction(
string $id
)
{
$event = $this->eventService->getEventById($id);
if ($event != null) {
$redirect = $this->redirectToCorrectCategory($event, null, null);
if ($redirect != null) {
return $redirect;
}
}
return $this->redirectToRoute('events_home');
}
/**
* warning: the route name is used in EventAdmin in a constant.
* @Route("/events/from-no/{eventNo}", name="events_from_no_details", options={"expose" = true }, methods={"GET", "POST"})
* @Security("is_granted('ROLE_USER')")
* @param string $eventNo
* @return Response* @internal param Event $event
*/
public
function eventsFromNoDetailsAction(
string $eventNo
)
{
$event = $this->eventService->getEventByNo($eventNo);
if ($event != null) {
$redirect = $this->redirectToCorrectCategory($event, null, null);
if ($redirect != null) {
return $redirect;
}
}
return $this->redirectToRoute('events_home');
}
/**
* @Route("/intern/events/follow/{eventId}", name="event_follow", options={"expose" = true }, methods={"GET", "POST"})
* @Security("is_granted('ROLE_USER')")
* @param $eventId
* @return Response
*/
public function eventFollowAction(string $eventId)
{
$event = $this->eventService->getEventById($eventId);
if ($event == null) {
$event = $this->eventService->getEventByNo($eventId);
if ($event == null) {
return JsonResponseHelper::buildErrorJson("Error to unfollow unknown event");
}
}
if ($this->getFollowStatus($event->getId())) {
try {
$this->eventFollowerService->unFollowEventForCurrentUser($event->getId());
$this->actionLoggerService->getLogger()
->info("user unfollow event " . $event->getEventNo() . " with success");
return JsonResponseHelper::buildSuccessJson("Unfollow Event with success", 'text', 'UNFOLLOW');
} catch (Exception $e) {
return JsonResponseHelper::buildErrorJson("Error to unfollow event : " . $e->getMessage());
}
} else {
try {
$this->eventFollowerService->followEventForCurrentUser($event);
$this->actionLoggerService->getLogger()
->info("user follow event " . $event->getEventNo() . " with success");
return JsonResponseHelper::buildSuccessJson("Follow Event with success", 'text', 'FOLLOW');
} catch (Exception $e) {
return JsonResponseHelper::buildErrorJson("Error to follow event : " . $e->getMessage());
}
}
}
/**
* @Route("/events/follow/{eventId}/by-email", name="event_follow_by_email", options={"expose" = true }, methods={"GET", "POST"})
* @Security("is_granted('ROLE_USER')")
* @param Request $request
* @param $eventId
* @return Response
*/
public function eventFollowByEmailAction(Request $request, string $eventId)
{
$event = $this->eventService->getEventById($eventId);
if ($event == null) {
$event = $this->eventService->getEventByNo($eventId);
}
if (!empty($event) && !$this->getFollowStatus($event->getId())) {
$this->eventFollowerService->followEventForCurrentUser($event);
$this->actionLoggerService->getLogger()
->info("user follow event " . $event->getEventNo() . " with success");
}
return $this->redirectToRoute('my_events', ['byEmail' => true]);
}
/**
* @Route("/intern/events/is-follower/{eventId}", name="is_event_follower", options={"expose" = true }, methods={"GET", "POST"})
* @Security("is_granted('ROLE_USER')")
* @param $eventId
* @return Response
*/
public function isEventFollowerAction(string $eventId)
{
$event = $this->eventService->getEventById($eventId);
if ($event == null) {
$event = $this->eventService->getEventByNo($eventId);
if ($event == null) {
return JsonResponseHelper::buildErrorJson("Error to unfollow unknown event");
}
}
if ($this->getFollowStatus($event->getId())) {
return $this->json(["isFollower" => true]);
} else {
return $this->json(["isFollower" => false]);
}
}
/**
* @Route("/intern/events/is-similar-event-subscriber/{eventId}", name="is_similar_event_subscriber", options={"expose" = true }, methods={"GET", "POST"})
* @Security("is_granted('ROLE_USER')")
* @param $eventId
* @return Response
*/
public function isSimilarEventSubscriberAction(string $eventId)
{
$event = $this->eventService->getEventById($eventId);
if ($event == null) {
$event = $this->eventService->getEventByNo($eventId);
if ($event == null) {
return JsonResponseHelper::buildErrorJson("Error to unfollow unknown event");
}
}
$sonataClassificationService = $this->newslettersService->getSonataClassificationService();
$context = $sonataClassificationService->getContext($event->getContextId());
//we retrieve the real category of the event to add the group of interests:
if ($context != null) {
$eventRealCategory = $sonataClassificationService->getCategory($context, $event->getContextMainCategoryId(), $event->getContextCategoryId());
$isAlreadyRegisteredSimilarEvent = $this->newslettersService->isUserRegisteredInCategory($this->getUser()->getUid(), $eventRealCategory, false);
$newsletterGroupId = $newsletterGroupId = $this->newslettersService->getInterestGroupInterestId($eventRealCategory, false);
if ($isAlreadyRegisteredSimilarEvent) {
return $this->json(["isSubscriber" => true, "newsletterGroupId" => $newsletterGroupId]);
} else {
return $this->json(["isSubscriber" => false, "newsletterGroupId" => $newsletterGroupId]);
}
}
return $this->json(["isSubscriber" => true, "newsletterGroupId" => ""]);
}
/**
* @Route("/intern/events/unfollow/all", name="event_unfollow_all", options={"expose" = true }, methods={"GET", "POST"})
* @Security("is_granted('ROLE_USER')")
* @return Response
*/
public function unfollowAllEvents()
{
try {
$this->eventFollowerService->unfollowAllEventsForCurrentUser();
$this->actionLoggerService->getLogger()->info("User unfollow all events with success");
return JsonResponseHelper::buildSuccessJson('You unfollow all events');
} catch (Exception $e) {
return JsonResponseHelper::buildErrorJson("Error to unfollow all events : " . $e->getMessage());
}
}
/**
* @Route("/intern/event/participations/{eventNo}", name="event_transmissions_participations", options={"expose" = true }, methods={"GET", "POST"})
* @param Request $request
* @param string $eventNo
* @return Response
*/
public function getTransmissionParticipations(Request $request, string $eventNo)
{
$includePastTransmission = (!empty($request->get('includePastTransmission')) && $request->get('includePastTransmission') == 'true') ? true : false;
$transmissions = [];
$atLeastOneGroup = false;
$atLeastOneMdsChannel = false;
try {
$event = $this->eventService->getEventByNo($eventNo);
$transmissions = $this->elasticNeosService->getTransmissionByEventNo($eventNo, $event->getShowUnisInTransmissions(), $includePastTransmission, 'asc');
if (!empty($transmissions)) {
foreach ($transmissions as $transmission) {
if (!empty($transmission['transmissionGroup'])) {
$atLeastOneGroup = true;
}
if (!empty($transmission['mdsChannel'])) {
$atLeastOneMdsChannel = true;
}
}
}
} catch (Exception $ex) {
$this->actionLoggerService->getLogger()->error("cant get transmission", ["exception" => $ex]);
}
return $this->render(
'event/event_programme_list_table.html.twig', [
'transmissions' => $transmissions,
'atLeastOneGroup' => $atLeastOneGroup,
'atLeastOneMdsChannel' => $atLeastOneMdsChannel,
'event' => $this->eventService->getEventByNo($eventNo)
]);
}
/**
* @Route("/intern/events/{eventNo}/timeline", name="event_timeline", options={"expose" = true })
* @param $eventNo
* @return Response
*/
public function getEventTimelineAction(string $eventNo)
{
$event = $this->eventService->getEventByNo($eventNo);
$transmissions = $this->elasticNeosService->getTransmissionByEventNo($eventNo, $event->getShowUnisInTransmissions(), true, 'asc');
// Group transmissions by mdsChannel / path
$groups = [];
$groupType = 'channel';
foreach ($transmissions as $transmission) {
if (!empty($transmission['mdsChannel']) && !in_array($transmission['mdsChannel'], $groups)) {
array_push($groups, $transmission['mdsChannel']);
} else {
if (empty($transmission['mdsChannel']) && !in_array("No Channel", $groups)) {
array_push($groups, "No Channel");
}
}
}
sort($groups);
if (count($groups ?? []) === 0 || count($groups ?? []) === 1) {
$groups = [];
$groupType = 'path';
foreach ($transmissions as $transmission) {
if (!empty($transmission['path']) && !in_array($transmission['path'], $groups)) {
array_push($groups, $transmission['path']);
} else {
if (empty($transmission['path']) && !in_array("No Channel", $groups)) {
array_push($groups, "No Channel");
}
}
}
usort($groups, function ($a, $b) {
if ($a == "No Channel" || $b == "No Channel") {
return 1;
}
return strcmp($a, $b);
});
}
return $this->render(
'event/event_timeline.html.twig', [
'transmissions' => $transmissions,
'groups' => $groups,
'groupType' => $groupType,
'organizationCode' => $this->userService->getCurrentUserCodeOps()
]
);
}
/**
* @Route("/intern/events/getupcoming", name="event_upcoming", options={"expose" = true }, methods={"GET", "POST"})
* @return Response
*/
public function getUpcomingEventsAction()
{
$events = $this->eventService->getUpcomingEvents(4, null);
return $this->render(
'dashboard/upcoming_events.html.twig', [
'events' => $events
]);
}
/**
* @Route("/intern/event/details/pdf/{eventNo}", name="event_details_get_pdf", options={"expose" = true})
* @Security("is_granted('ROLE_USER')")
* @param string $eventNo
* @return Response
*/
public function getEventDetailsPDF(
string $eventNo,
Request $request,
EventAccessController $accessController,
SessionInterface $session,
EventArticleService $eventArticleService,
Pdf $pdf
)
{
$event = $this->eventService->getEventByNo($eventNo);
$transmissions = [];
try {
$transmissions = $this->elasticNeosService->getTransmissionByEventNo($eventNo, $event->getShowUnisInTransmissions(), true, 'asc');
} catch (Exception $ex) {
$this->actionLoggerService->getLogger()->error("cant get transmission", ["exception" => $ex]);
}
$includeInactive = $this->includeInactive($session);
$result = $eventArticleService->getUpdates($accessController->getCurrentUserUid(), $event, 1, 100, $includeInactive);
$neosDocuments = $this->eventService->getEventAttachments($eventNo);
$eventMainCategory = $event->getContextMainCategoryId();
$eventCategory = $event->getCategoryUrl();
$html = $this->renderView('event/event_details_pdf.html.twig', [
'event' => $event,
'transmissions' => $transmissions,
'eventArticles' => $result['collection'],
'neosDocuments' => $neosDocuments,
'eventMainCategory' => $eventMainCategory,
'eventCategory' => $eventCategory
]);
$header = $this->renderView('event/event_details_pdf_header.html.twig');
$footer = $this->renderView('event/event_details_pdf_footer.html.twig');
$filename = 'event_' . $eventNo . '_details';
return new Response(
$pdf->getOutputFromHtml($html, [
'header-html' => $header,
'footer-html' => $footer,
]), 200, [
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="' . $filename . '.pdf"'
]
);
}
/**
* @Route("/intern/event/worldfeed/stats/{transmissionNo}", name="event_worldfeed_stats", options={"expose" = true})
* @Security("is_granted('ROLE_USER')")
* @param string $transmissionNo
* @return Response
*/
public function getWorldfeedStatsLocal(string $transmissionNo, Request $request)
{
$response = $this->eventService->searchSpecificStatsWorldFeedInLocalDb($transmissionNo, $this->getUser()->getEmail());
return $this->json("Email sent!");
}
/**
* @param $event
* @return string
*/
private function generateRhsBookingUrl(Event $event = null): ?string
{
if ($event != null && $this->getUser() != null) {
return $this->generateUrl('rhs_myorders', self::generateEventNoArray($event));
}
return null;
}
/**
* @Route("/intern/events/banner/view/list-event/{eventNo}", name="list_banner_event", options={"expose" = true })
* @param string $eventNo
* @return mixed
*/
public function getEventBannersVisibleAndNotReadAction(string $eventNo)
{
$uid = null;
if ($this->getUser() != null) {
$uid = $this->getUser()->getUid();
}
$event = $this->eventService->getEventByNo($eventNo);
$filteredAlerts = $this->eventService->getVisibleAndNotReadEventBanners($event->getId(), $event->getCategoryCode(), $uid);
if ($filteredAlerts == null) {
$filteredAlerts = [];
}
return $this->render(
'block/alert.html.twig',
[
'alerts' => $filteredAlerts,
'isEvent' => true
]
);
}
/**
* @Route("/intern/events/banner/view/save/{idBanner}", name="banner_view_save", options={"expose" = true }, methods={"GET"})
* @param string|null $idBanner
* @return JsonResponse
*/
public function saveBannerView(string $idBanner = null): JsonResponse
{
if ($this->getUser() == null || $idBanner === null) {
return JsonResponseHelper::buildErrorJson("Not saved as user is not logged in");
}
try {
$this->eventService->setBannerReadByCurrentUser($this->getUser()->getUid(), $idBanner);
return JsonResponseHelper::buildSuccessJson("Banner view saved");
} catch (Exception $e) {
return JsonResponseHelper::buildErrorJson("Error to save banner view : " . $e->getMessage());
}
}
/**
* @Route("/intern/events/default-image-info/{eventNo}", name="events_default_image", options={"expose" = true})
* @Security("is_granted('ROLE_USER')")
* @param string $eventNo
* @return Response
*/
public function getEventDefaultImageAction(string $eventNo)
{
$event = $this->eventService->getEventByNo($eventNo);
return $this->render(
'event/event_default_image.html.twig',
[
'event' => $event
]
);
}
}