<?php
namespace App\Controller;
use App\Business\Equipment;
use App\Business\EventCategoryProvider;
use App\Business\Feedback;
use App\Business\WorkOrderEditContainer;
use App\Entity\Callback;
use App\Entity\UserPreference;
use App\Extern\XrmService;
use App\Form\EquipmentType;
use App\Form\FeedbackType;
use App\Form\MyPreferencesType;
use App\Form\WorkOrderEditContainerType;
use App\Form\Type\BusinessUserType;
use App\Security\OauthAuthenticator;
use App\Security\TokenAuthenticator;
use App\Services\BookingService;
use App\Services\CallbackService;
use App\Services\CompanyRegistrationService;
use App\Services\CustomerOrderService;
use App\Services\DashboardService;
use App\Services\DomainService;
use App\Services\EquipmentService;
use App\Services\EventFollowerService;
use App\Services\EventService;
use App\Services\FreelancerPortalService;
use App\Services\NewslettersService;
use App\Services\NotificationSenderHelperService;
use App\Services\ProviderService;
use App\Services\UserService;
use App\Utils\Helper;
use App\Utils\JsonResponseHelper;
use App\Utils\OperationResult;
use App\Enum\FlashType;
use App\Services\ActionLoggerService;
use Exception;
use FOS\RestBundle\Controller\Annotations\Get;
use Knp\Snappy\Pdf;
use Psr\Log\LoggerInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Security as SecurityInterface;
use Throwable;
class MyEurovisionController extends AbstractController
{
/** @var EventFollowerService $eventFollowerService */
protected $eventFollowerService;
/** @var UserService $userService */
protected $userService;
/** @var XrmService $xrmService */
protected $xrmService;
/** @var EquipmentService $equipmentService */
protected $equipmentService;
/** @var SecurityInterface security */
private $security;
/** @var NewslettersService $newslettersService */
private $newslettersService;
/** @var BookingService $bookingService */
private $bookingService;
/** @var CustomerOrderService $customerOrderService */
private $customerOrderService;
/** @var DomainService $domainService */
private $domainService;
/** @var CallbackService $callbackService */
private $callbackService;
/** @var DashboardService $dashboardService */
private $dashboardService;
/** @var EventService $eventService */
private $eventService;
/** @var NotificationSenderHelperService $notificationSenderHelperService */
protected $notificationSenderHelperService;
protected OauthAuthenticator $authenticator;
protected TokenAuthenticator $tokenManager;
private ActionLoggerService $actionLoggerService;
/**
* MyEurovisionController constructor.
*
* @param SecurityInterface $security
* @param NewslettersService $newslettersService
* @param EventFollowerService $eventFollowerService
* @param UserService $userService
* @param BookingService $bookingService
* @param CustomerOrderService $eventRhsBookingService
* @param DomainService $domainService
* @param CallbackService $callbackService
* @param DashboardService $dashboardService
* @param EquipmentService $equipmentService
* @param EventService $eventService
* @param NotificationSenderHelperService $notificationSenderHelperService
* @param OAuthAuthenticator $authenticator
* @param TokenAuthenticator $tokenManager
* @param ActionLoggerService $actionLoggerService
*/
public function __construct(
SecurityInterface $security,
NewslettersService $newslettersService,
EventFollowerService $eventFollowerService,
UserService $userService,
BookingService $bookingService,
CustomerOrderService $eventRhsBookingService,
DomainService $domainService,
CallbackService $callbackService,
DashboardService $dashboardService,
XrmService $xrmService,
EquipmentService $equipmentService,
EventService $eventService,
NotificationSenderHelperService $notificationSenderHelperService,
OAuthAuthenticator $authenticator,
TokenAuthenticator $tokenManager,
ActionLoggerService $actionLoggerService
)
{
$this->security = $security;
$this->newslettersService = $newslettersService;
$this->eventFollowerService = $eventFollowerService;
$this->userService = $userService;
$this->bookingService = $bookingService;
$this->customerOrderService = $eventRhsBookingService;
$this->domainService = $domainService;
$this->callbackService = $callbackService;
$this->dashboardService = $dashboardService;
$this->xrmService = $xrmService;
$this->equipmentService = $equipmentService;
$this->eventService = $eventService;
$this->notificationSenderHelperService = $notificationSenderHelperService;
$this->authenticator = $authenticator;
$this->tokenManager = $tokenManager;
$this->actionLoggerService = $actionLoggerService;
}
/**
* @Route("/myeurovision/test-upload-sharepoint", name="test_upload_sharepoint", options={"expose" = true })
*/
public function testUploadSharepointAction(Request $request){
$this->xrmService->uploadDocumentToSharePoint("tochange", '/var/www/html', 'testupload.txt',); #TODO TEST AND REMOVE
}
/**
* @Route("/myeurovision/profile", name="my_profile", options={"expose" = true })
* @Security("is_granted('ROLE_USER')")
*/
public function myProfileAction(Request $request)
{
//$user = $this->getUser();
$user = $this->userService->getUserMainInformation($this->getUser()->getUid());
$user->companyCityComplete = $user->companyCity;
if (empty($user->companyCityComplete)) {
$userOrganization = $this->domainService->getOrganizationDetailsCurrentUser();
if (!empty($userOrganization)) {
$city = $this->domainService->getCity($userOrganization->cityCode);
if ($city != null && $city->getName() != null) {
$user->companyCityComplete = $city->getName();
}
}
}
$userPreference = $this->dashboardService->getUserPreference($user->getUid());
if (!$userPreference) {
$userPreference = new UserPreference();
}
$userPreferenceForm = $this->createForm(MyPreferencesType::class, $userPreference);
$userPreferenceForm->handleRequest($request);
$userInformationsForm = $this->createForm(BusinessUserType::class, $user);
$userInformationsForm->handleRequest($request);
// Get user company from XRM
if ($user->getCompanyCodeOps()) {
$xrmCompany = $this->xrmService->getOrganization($user->getcompanyCodeOps());
}
$parts = explode('@', $user->getEmail());
$domain = array_pop($parts);
$emailDomainOrganizations = $this->xrmService->getOrganizationsRelatedToSpecificEmailDomainOrCodeOps($domain, $user->getCompanyCodeOps());
$this->userService->clearCache($user->getUid());
return $this->render(
'my_eurovision/my_profile.html.twig',
[
'user' => $user,
'company' => (isset($xrmCompany) ? $xrmCompany : null),
'emailDomainOrganizations' => $emailDomainOrganizations,
'preferenceForm' => $userPreferenceForm->createView(),
'userInformationsForm' => $userInformationsForm->createView(),
'location' => 'My Profile'
]
);
}
/**
* @Route("/myeurovision/profile/revoke/password", name="my_profile_revoke_password", options={"expose" = true })
* @Security("is_granted('ROLE_USER')")
* @param Request $request
* @return JsonResponse
*/
public function revokePassword(Request $request)
{
$result = $this->userService->revokeSelfUserPassword();
if ($result["status"] === "success") {
return new JsonResponse($result);
} else {
return new JsonResponse($result, Response::HTTP_INTERNAL_SERVER_ERROR);
}
}
/**
* @Route("/myeurovision/profile/revoke/session", name="my_profile_revoke_session", options={"expose" = true })
* @Security("is_granted('ROLE_USER')")
* @param Request $request
* @return JsonResponse
*/
public function revokeSession(Request $request)
{
$result = $this->userService->revokeSelfUserSession();
$this->tokenManager->refreshToken($this->getUser());
return new JsonResponse($result);
}
/**
* @Route("/myeurovision/profile/check/session", name="my_profile_check_session", options={"expose" = true })
* @Security("is_granted('ROLE_USER')")
* @param Request $request
* @return JsonResponse
*/
public function checkSession(Request $request)
{
$result = $this->authenticator->canChangeEmail($this->getUser());
return new JsonResponse($result);
}
/**
* @Route("/myeurovision/profile/change/email", name="my_profile_change_email", options={"expose" = true },methods={"POST"})
* @Security("is_granted('ROLE_USER')")
* @param Request $request
* @return JsonResponse
*/
public function changeEmail(Request $request)
{
$email = $request->get('email');
if(!$this->authenticator->canChangeEmail($this->getUser())){
return new JsonResponse(['status' => 'error', 'message' => 'You can not change your email'], JsonResponse::HTTP_FORBIDDEN);
}
$result = $this->userService->changeUserEmail($email);
if($result->getStatus() === 'success'){
$this->userService->clearCache($this->getUser()->getUid());
return new JsonResponse($result->getData());
} else {
return new JsonResponse($result->getMessage(), JsonResponse::HTTP_INTERNAL_SERVER_ERROR);
}
return new JsonResponse($result);
}
/**
* @Route("/myeurovision/profile/edit", name="my_profile_edit", options={"expose" = true })
* @Security("is_granted('ROLE_USER')")
*/
public function editProfile(Request $request)
{
$user = $this->getUser();
$userInformationsForm = $this->createForm(BusinessUserType::class, $user);
$userInformationsForm->handleRequest($request);
if ($userInformationsForm->isSubmitted() && $userInformationsForm->isValid()) {
$response = $this->userService->updateUser($user);
$this->userService->clearCache($user->getUid());
// Wait 5 seconds to be sure MS is refreshed
sleep(5);
$data = [
"user" => [
'firstName' => $user->getFirstName(),
'lastName' => $user->getLastName(),
'email' => $user->getEmail(),
'businessMobilePhone' => $user->getBusinessMobilePhone(),
'businessOfficePhone' => $user->getBusinessOfficePhone(),
'faxPhone' => $user->getFaxPhone(),
'jobTitle' => $user->getJobTitle(),
'department' => $user->getDepartment(),
'address' => $user->getAddress(),
'postalCode' => $user->getPostalCode(),
'country' => $user->getCountry(),
]
];
if ($response["status"] === "success") {
$data["message"] = "User updated successfully";
return new JsonResponse($data);
} else {
$data["message"] = "Error in updating user: " . $response["message"];
return new JsonResponse($data["message"], JsonResponse::HTTP_INTERNAL_SERVER_ERROR);
}
} else if ($userInformationsForm->isSubmitted()) {
$errors = Helper::getErrorMessagesFlat($userInformationsForm, true);
$data['message'] = "Please, check errors in the user form";
$data['errors'] = $errors;
$jsonResponse = $this->json($data, JsonResponse::HTTP_BAD_REQUEST);
return $jsonResponse;
}
return new JsonResponse('Error', Response::HTTP_INTERNAL_SERVER_ERROR);
}
/**
* @Route("/myeurovision", name="my_eurovision")
* @Route("/myeurovision/", name="my_eurovision_slash")
* @Security("is_granted('ROLE_USER')")
*/
public function myEurovisionHomepageAction(Request $request)
{
$errorMessage = $request->get('errorMessage');
$user = $this->getUser();
$upcomingEvents = $this->eventService->getUpcomingEvents(5, null);
$userEvents = $this->eventFollowerService->getEventsFollowedByCurrentUser();
$events = $this->eventService->getEventsByType("ALL", ['date' => 'year'], null);
$userSubs = $this->newslettersService->getCurrentUserInterests();
$newslettersCategories = $this->newslettersService->getAllNewslettersEventCategories();
$nbNewsletters = 0;
foreach ($newslettersCategories as $nlCateg) {
$nbNewsletters = $nbNewsletters + count($nlCateg->getGroups() ?? []);
}
$arrayNbSubs = [];
foreach ($newslettersCategories as $nlCateg) {
$currentCptGroup = 0;
foreach ($nlCateg->getGroups() as $group) {
if (in_array($group->getExternGroupId(), $userSubs)) {
$currentCptGroup++;
}
}
$arrayNbSubs[$nlCateg->getExternGroupId()]['externId'] = $nlCateg->getExternGroupId();
$arrayNbSubs[$nlCateg->getExternGroupId()]['title'] = $nlCateg->getTitle();
$arrayNbSubs[$nlCateg->getExternGroupId()]['hint'] = $currentCptGroup . " OF " . count($nlCateg->getGroups() ?? []) . " SUBSCRIBED";
}
$res = $this->customerOrderService->getCustomersOrders(null);
$customerOrders = $res->getData();
$lastCustomerOrders = array_slice($customerOrders, 0, 6);
return $this->render(
'my_eurovision/my_eurovision_homepage.html.twig',
[
'errorMessage' => $errorMessage,
'location' => 'My Orders',
'user' => $user,
'newslettersCategories' => $newslettersCategories,
'userSubs' => $userSubs,
'arrayNbSubs' => $arrayNbSubs,
'upcomingEvents' => $upcomingEvents,
'nbUserEvents' => count($userEvents ?? []),
'nbEvents' => count($events ?? []),
'nbUserSubscriptions' => count($userSubs ?? []),
'nbNewsletters' => $nbNewsletters,
'customerOrdersDetails' => $lastCustomerOrders
]
);
}
/**
* @Route("/myeurovision/orders", name="my_orders", options={"expose" = true })
* @Security("is_granted('ROLE_USER')")
*/
public function myBookingsAction(Request $request)
{
$errorMessage = $request->get('errorMessage');
$view = (!empty($request->get('view'))) ? $request->get('view') : 'thumbnail';
$period = (!empty($request->get('period'))) ? $request->get('period') : 'month';
$res = $this->customerOrderService->getCustomersOrdersByPeriod($period);
$totalOrders = count($res->getData() ?? []);
return $this->render(
'my_eurovision/my_bookings.html.twig',
[
'user' => $this->getUser(),
'errorMessage' => $errorMessage,
'location' => 'My Orders',
'view' => $view,
'period' => $period,
'totalOrders' => $totalOrders
]
);
}
/**
* @Security("is_granted('ROLE_USER')")
* @Route("/intern/myeurovision/preferences/submit", name="my_preferences_submit", options={"expose" = true})
* @param Request $request
* @return Response
*/
public function submitMyPreferences(Request $request)
{
try {
$uid = $this->getUser()->getUid();
$userPreference = $this->dashboardService->getUserPreference($uid);
if (!$userPreference) {
$userPreference = new UserPreference();
}
$userPreferenceForm = $this->createForm(MyPreferencesType::class, $userPreference);
$userPreferenceForm->handleRequest($request);
$result = $this->dashboardService->saveAllUserPreference($uid, $userPreference);
return new JsonResponse($result);
} catch (Throwable $ex) {
return $this->json($ex->getMessage(), JsonResponse::HTTP_INTERNAL_SERVER_ERROR);
}
}
/**
* @Route("/myeurovision/callbacks", name="my_callbacks", options={"expose" = true })
* @Security("is_granted('ROLE_USER')")
*/
public function myCallbacksAction(Request $request)
{
$userInformation = $this->getUser();
if (empty($userInformation->getCompanyCodeOps())) {
return $this->redirectToRoute('eurovision_no_booking_authorized');
}
$callbackNotification = $this->callbackService->getCallbackByOrganizationCode($userInformation->getCompanyCodeOps());
$synopsisNotifications = $this->callbackService->getCallbackByOrganizationCodeByType($userInformation->getCompanyCodeOps(), Callback::SYNOPSIS);
$requestNotifications = $this->callbackService->getCallbackByOrganizationCodeByType($userInformation->getCompanyCodeOps(), Callback::REQUEST);
return $this->render(
'my_eurovision/my_callbacks.html.twig',
[
'location' => 'My Callbacks',
'user' => $userInformation,
'organizationCode' => $userInformation->getCompanyCodeOps(),
'callbackNotifications' => $callbackNotification,
'synopsisNotifications' => $synopsisNotifications,
'requestNotifications' => $requestNotifications
]
);
}
/**
* Save callback url
* @Route("/intern/callback/url/new", name="callback_add_new_url", options={"expose"=true})
*
* @param Request $request
* @return JsonResponse
*/
public function saveCallbackAction(Request $request)
{
$res = $this->callbackService->addNewCallbackUrl($request->request->all());
return new JsonResponse([
'message' => $res->getMessage(),
'status' => $res->getStatus(),
'data' => $res->getData(),
]);
}
/**
* update callback url
* @Route("/intern/callback/url/update/{callbackId}", name="callback_update_url", options={"expose"=true})
*
* @param Request $request
* @param string $callbackId
* @return JsonResponse
*/
public function updateCallbackUrl(Request $request, string $callbackId)
{
$res = $this->callbackService->updateCallbackUrl($callbackId, $request->request->all());
return new JsonResponse([
'message' => $res->getMessage(),
'status' => $res->getStatus(),
'data' => $res->getData(),
]);
}
/**
* delete callback url
* @Route("/intern/callback/delete/{callbackId}", name="delete_notification", options={"expose"=true})
*
* @param Request $request
* @param string $callbackId
* @return JsonResponse
*/
public function deleteCallbackAction(Request $request, string $callbackId)
{
$res = $this->callbackService->deleteCallbackUrl($callbackId);
return new JsonResponse([
'message' => $res->getMessage(),
'status' => $res->getStatus(),
'data' => $res->getData(),
]);
}
/**
* @Route("/myeurovision/myevents", name="my_events", options={"expose" = true })
* @Security("is_granted('ROLE_USER')")
* @return Response
*/
public function myEventsAction(Request $request)
{
$byEmail = (!empty($request->get('byEmail'))) ? $request->get('byEmail') : false;
$userEvents = $this->eventFollowerService->getEventsFollowedByCurrentUser();
return $this->render(
'my_eurovision/my_events.html.twig',
[
'user' => $this->getUser(),
'byEmail' => $byEmail,
'location' => 'My Events',
'userEvents' => $userEvents
]
);
}
/**
* @Route("/myeurovision/subscriptions", name="my_subscriptions", options={"expose" = true })
* @Security("is_granted('ROLE_USER')")
* @return Response
*/
public function newslettersAction(Request $request)
{
$newslettersCategories = $this->newslettersService->getAllNewslettersEventCategories();
$isRegistered = $this->newslettersService->isUserRegistered($this->getUser()->getUid());
$memberDetails = $this->newslettersService->getMemberDetails($this->getUser()->getUid());
$subscribeUrl = '';
if (empty($memberDetails) || $memberDetails['status'] == 404) {
$isRegistered = true;
} else {
$subscribeUrl = $this->newslettersService->getSubscribeUrlList($memberDetails);
}
$userSubs = $this->newslettersService->getCurrentUserInterests();
$userEvents = $this->eventFollowerService->getEventsFollowedByCurrentUser();
return $this->render(
'my_eurovision/my_subscriptions.html.twig',
[
'user' => $this->getUser(),
'isRegistered' => $isRegistered,
'subscribeUrl' => $subscribeUrl,
'newslettersCategories' => $newslettersCategories,
'userSubs' => $userSubs,
'location' => 'My Subscriptions',
'userEvents' => $userEvents
]
);
}
/**
* @Route("/intern/newsletters/group/add/{interestsId}", name="add_interest_user", options={"expose"=true}, methods={"GET"})
* @Security("is_granted('ROLE_USER')")
* @param $interestsId
* @return JsonResponse
*/
public function addUserInterest($interestsId)
{
try {
$interestArray = [$interestsId];
$success = $this->newslettersService->addUserInterestForCurrentUser($interestArray);
if ($success) {
return JsonResponseHelper::buildSuccessJson("Subscription Added");
}
return JsonResponseHelper::buildErrorJsonData("Error in adding Subscription !");
} catch (Exception $e) {
return JsonResponseHelper::buildErrorJson("Error to add subscription : " . $e->getMessage());
}
}
/**
* @Route("/intern/newsletters/group/remove/{interestsId}", name="remove_interest_user", options={"expose"=true}, methods={"GET"})
* @Security("is_granted('ROLE_USER')")
* @param $interestsId
* @return JsonResponse
*/
public function removeUserInterest($interestsId)
{
try {
$interestArray = [$interestsId];
$this->newslettersService->removeUserInterestForCurrentUser($interestArray);
return new JsonResponse(
[
'success' => true,
'code' => 200,
'message' => "Subscription Removed"
]
);
} catch (Exception $e) {
return new JsonResponse(
[
'success' => false,
'code' => 200,
'message' => "Error to remove subscription : " . $e->getMessage()
]
);
}
}
/**
* @Route("/intern/newsletters/group/removeall", name="remove_all_interests", options={"expose"=true}, methods={"GET"})
* @Security("is_granted('ROLE_USER')")
* @return JsonResponse
*/
public function removeUserAllInterests()
{
try {
$this->newslettersService->removeUserAllInterests($this->getUser()->getUid());
return new JsonResponse(
[
'success' => true,
'code' => 200,
'message' => "All Subscriptions Removed"
]
);
} catch (Exception $e) {
return new JsonResponse(
[
'success' => false,
'code' => 200,
'message' => "Error to remove subscriptions : " . $e->getMessage()
]
);
}
}
/**
* @param Request $request
* @return Response
* @Get("/intern/all-customer-orders-view", name="get_all_customers_orders_view", options={"expose" = true })
*/
public function getAllCustomerOrderViewAction(Request $request)
{
$period = (!empty($request->get('period'))) ? $request->get('period') : 'month';
$res = $this->customerOrderService->getCustomersOrdersByPeriod($period);
$customerOrders = $res->getData();
$status = $res->getStatus();
$message = $res->getMessage();
return $this->render(
'customer_orders/myordersview.html.twig',
[
'isOperationSuccess' => $status === OperationResult::SUCCESS,
'message' => $message,
'customerOrdersDetails' => $customerOrders
]
);
}
/**
* @param Request $request
* @return Response
* @Get("/intern/get-booking-type-customer-order", name="get_booking_type_customer_order", options={"expose" = true })
*/
public function getGlobalBookingTypeForCustomerORderAction(Request $request)
{
$customerOrderNo = (!empty($request->get('customerOrderNo'))) ? $request->get('customerOrderNo') : null;
if (empty($customerOrderNo)) {
return null;
}
$res = $this->customerOrderService->getWorkOrdersJson($customerOrderNo);
$allBookings = json_decode($res, true);
$bookingType = '';
if (!empty($allBookings)) {
foreach ($allBookings as $booking) {
$bookingType = $booking['product']['code'];
}
}
return $this->render(
'customer_orders/customer-order-booking-type-image.html.twig',
[
'bookingType' => $bookingType
]
);
}
/**
* @return Response
* @Get("/intern/get-nb-customer-orders", name="get_nb_customers_orders", options={"expose" = true })
* @return JsonResponse
*/
public function getNbCustomerOrderAction(Request $request)
{
$customerOrders = $this->customerOrderService->getCustomersOrders(null);
$nbBookings = count($customerOrders->getData() ?? []);
return $this->json($nbBookings);
}
/**
* @return Response
* @Get("/intern/last-customer-orders-view", name="get_last_customers_orders_view", options={"expose" = true })
* @return Response
*/
public function getLastCustomerOrderViewAction(Request $request)
{
$nbCustomerOrderToDisplay = (!empty($request->get('nbCustomerOrder'))) ? $request->get('nbCustomerOrder') : 4;
$res = $this->customerOrderService->getCustomersOrders(null);
$customerOrders = $res->getData();
$lastCustomerOrders = array_slice($customerOrders, 0, $nbCustomerOrderToDisplay);
$status = $res->getStatus();
$message = $res->getMessage();
return $this->render(
'customer_orders/mylastordersview.html.twig',
[
'isOperationSuccess' => $status === OperationResult::SUCCESS,
'message' => $message,
'customerOrdersDetails' => $lastCustomerOrders
]
);
}
/**
* @Route("/myeurovision/orders/{customerOrderNo}/details", name="my_orders_details_work_order", options={"expose" = true })
* @Security("is_granted('ROLE_USER')")
* @param $customerOrderNo
* @return Response
*/
public function getAllworkOrderViewAction($customerOrderNo)
{
$customerWorkOrdersDetails = $this->customerOrderService->getWorkOrders($customerOrderNo, "default");
$editable = $this->customerOrderService->createEditContainer($customerWorkOrdersDetails)->isEditable();
$eventNo = $customerWorkOrdersDetails->getCustomerOrder()->getEventNo();
if (!empty($eventNo)) {
$event = $this->eventService->getEventByNo($eventNo);
if (!empty($event) && !$event->isBookable()) {
$editable = $event->isBookable();
}
}
$isEventOffer = !empty($eventNo) ? $customerWorkOrdersDetails->hasMultiWorkOrder() : false;
return $this->render(
'my_eurovision/my_bookings_details.html.twig',
[
'user' => $this->getUser(),
'location' => 'Work-orders',
'editable' => $editable,
'isEventOffer' => $isEventOffer,
'eventNo' => $eventNo,
'customerWorkOrdersDetails' => $customerWorkOrdersDetails,
]
);
}
/**
* @Route("/myeurovision/orders/{customerOrderNo}/edit", name="my_orders_edit_work_order")
* @Security("is_granted('ROLE_USER')")
* @param Request $request
* @param null|string $customerOrderNo
* @return Response
*/
public function editWorkOrdersAction(Request $request, ?string $customerOrderNo)
{
$customerWorkOrdersDetails = $this->customerOrderService->getWorkOrders($customerOrderNo, "default");
$workOrderEditContainer = $this->customerOrderService->loadWorkOrdersForEdition($customerOrderNo);
$form = $this->createForm(WorkOrderEditContainerType::class, $workOrderEditContainer);
$form->handleRequest($request);
return $this->render('my_eurovision/my_bookings_edit.html.twig',
[
'user' => $this->getUser(),
'location' => 'Work-orders',
'workOrderEditContainer' => $workOrderEditContainer,
'customerWorkOrdersDetails' => $customerWorkOrdersDetails,
'form' => $form->createView()
]);
}
/**
* It will redirect to the correct work-order
* @Route("/myeurovision/work-order/{workOrderId}/edit", name="my_orders_edit_one_work_order")
* @Security("is_granted('ROLE_USER')")
*
* @param Request $request
* @param null|string $workOrderId
* @return Response
*/
public function editOneWorkOrdesAction(Request $request, ?string $workOrderId)
{
$customerOrderNo = $this->customerOrderService->getCustomerOrderNoFromWorkOrder($workOrderId);
if (!empty($customerOrderNo)) {
return $this->redirectToRoute('my_orders_edit_work_order', ['customerOrderNo' => $customerOrderNo]);
}
return $this->redirectToRoute('my_orders');
}
/**
* @Security("is_granted('ROLE_USER')")
* @Route("/intern/work-order-edition/submit", name="work-order-edition-submit", options={"expose" = true})
* @param Request $request
* @param LoggerInterface $logger
* @return Response
*/
public function submitWorkOrderEditionAction(Request $request, LoggerInterface $logger)
{
try {
$workOrderEditContainer = new WorkOrderEditContainer();
$form = $this->createForm(WorkOrderEditContainerType::class, $workOrderEditContainer, []);
$form->handleRequest($request);
if (!$form->isValid()) {
$jsonResponse = $this->buildJsonResponseForModificationsNotValid($form);
return $jsonResponse;
}
$result = $this->bookingService->editBookings($workOrderEditContainer);
if ($result->isError()) {
$errorToDisplay = $this->render("booking_cart/booking_error.html.twig", ["operationResult" => $result])->getContent();
return $this->json($errorToDisplay, JsonResponse::HTTP_INTERNAL_SERVER_ERROR);
}
return $this->json('ok');
} catch (Exception $ex) {
$logger->alert("error in work-order edition" . $ex->getMessage(), ["exception" => $ex]);
return $this->json($ex->getMessage(), JsonResponse::HTTP_INTERNAL_SERVER_ERROR);
}
}
/**
* @param $form
* @return JsonResponse
*/
private function buildJsonResponseForModificationsNotValid($form): JsonResponse
{
$data = [];
$errors = Helper::getErrorMessagesFlat($form, true);
$data['message'] = "Please, check your modifications";
$data['errors'] = $errors;
//warn: the javascript is waiting for this response in case of unvalide data
//our javascript use the code to differentiate validation errors to internal errors.
$jsonResponse = $this->json($data, JsonResponse::HTTP_BAD_REQUEST);
return $jsonResponse;
}
/**
* @Route("/myeurovision/incident-tickets", name="incident_tickets", options={"expose" = true })
* @Security("is_granted('ROLE_USER')")
*/
public function incidentTicketsAction(Request $request)
{
// Check if user belongs to a company
$codeOps = $this->userService->getCurrentUserCodeOps();
if (empty($codeOps)) {
return $this->redirectToRoute('myeurovision_not_authorized', ['email' => 'websupport@eurovisionservices.com']);
}
$feedback = new Feedback();
$form = $this->createForm(FeedbackType::class, $feedback, ['is_incident_ticket' => true]);
$form->handleRequest($request);
return $this->render(
'my_eurovision/incident_tickets.html.twig',
[
'user' => $this->getUser(),
'location' => 'Incident tickets',
'form' => $form->createView()
]
);
}
/**
* @Route("/myeurovision/maintenance", name="maintenance", options={"expose" = true })
* @Security("is_granted('ROLE_USER')")
*/
public function maintenanceAction(Request $request)
{
// Check if user belongs to a company
$codeOps = $this->userService->getCurrentUserCodeOps();
if (empty($codeOps)) {
return $this->redirectToRoute('myeurovision_not_authorized', ['email' => 'websupport@eurovisionservices.com']);
}
return $this->render(
'my_eurovision/maintenance_tickets.html.twig',
[
'user' => $this->getUser(),
'location' => 'Maintenance'
]
);
}
/**
* @Route("/myeurovision/flex-portal", name="flex_portal", options={"expose" = true })
* @Security("is_granted('ROLE_USER')")
*/
public function flexPortalAction(Request $request)
{
// Check if user belongs to a company
$codeOps = $this->userService->getCurrentUserCodeOps();
if (empty($codeOps)) {
return $this->redirectToRoute('myeurovision_not_authorized', ['email' => 'websupport@eurovisionservices.com']);
}
return $this->render(
'my_eurovision/flex_portal.html.twig',
[
'user' => $this->getUser(),
'location' => 'Flex portal'
]
);
}
/**
* @Route("/intern/incident/list", name="incident_tickets_list", options={"expose" = true })
* @Security("is_granted('ROLE_USER')")
*/
public function getIncidentTicketsListAction(Request $request)
{
// Check if user belongs to a company
$codeOps = $this->userService->getCurrentUserCodeOps();
if (empty($codeOps)) {
return $this->redirectToRoute('myeurovision_not_authorized', ['email' => 'websupport@eurovisionservices.com']);
}
$user = $this->getUser();
$isMaintenance = (!empty($request->get('isMaintenance'))) ? true : false;
$incidents = $this->xrmService->getIncidents($user->getCompanyCodeOps(), $isMaintenance);
return $this->render(
'my_eurovision/incident_tickets_list.html.twig',
[
'incidents' => $incidents,
'nbIncidents' => count($incidents ?? [])
]
);
}
/**
* @Route("/intern/incident/{id}/details", name="incident_ticket_details", options={"expose" = true})
* @Security("is_granted('ROLE_USER')")
*/
public function incidentDetailsAction(Request $request, ?string $id)
{
// Check if user belongs to a company
$codeOps = $this->userService->getCurrentUserCodeOps();
if (empty($codeOps)) {
return $this->redirectToRoute('myeurovision_not_authorized', ['email' => 'websupport@eurovisionservices.com']);
}
$incident = $this->xrmService->getIncidentById($id);
return $this->render(
'my_eurovision/incident_details.html.twig',
[
'incident' => $incident
]
);
}
/**
* @Route("/intern/incident/{id}/updates", name="incident_ticket_updates", options={"expose" = true})
* @Security("is_granted('ROLE_USER')")
*/
public function incidentUpdatesAction(Request $request, ?string $id)
{
// Check if user belongs to a company
$codeOps = $this->userService->getCurrentUserCodeOps();
if (empty($codeOps)) {
return $this->redirectToRoute('myeurovision_not_authorized', ['email' => 'websupport@eurovisionservices.com']);
}
$incident = $this->xrmService->getIncidentById($id);
return $this->render(
'my_eurovision/incident_updates.html.twig',
[
'incident' => $incident
]
);
}
/**
* @Route("/myeurovision/incident/pdf/{reference}", name="incident_details_get_pdf_by_reference", options={"expose" = true})
* @Security("is_granted('ROLE_USER')")
* @param string $id
* @return Response
*/
public function getIncidentDetailsPDFByReference(string $reference, Request $request, Pdf $pdf)
{
// Check if user belongs to a company
$codeOps = $this->userService->getCurrentUserCodeOps();
if (empty($codeOps)) {
return $this->redirectToRoute('myeurovision_not_authorized', ['email' => 'websupport@eurovisionservices.com']);
}
$filename = 'incident_' . $reference . '_details';
$incident = $this->xrmService->getIncidentByReference($reference);
$html = $this->renderView('my_eurovision/incident_ticket_pdf_content.html.twig', [
'incident' => $incident,
'incidentTitle' => 'Service Interruption Report',
'base_dir' => $this->getParameter('kernel.project_dir') . '/../web' . $request->getBasePath()
]);
$header = $this->renderView('my_eurovision/incident_ticket_pdf_header.html.twig');
$footer = $this->renderView('my_eurovision/incident_ticket_pdf_footer.html.twig');
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/incident/details/pdf/{id}", name="incident_details_get_pdf", options={"expose" = true})
* @Security("is_granted('ROLE_USER')")
* @param string $id
* @return Response
*/
public function getIncidentDetailsPDF(string $id, Request $request, Pdf $pdf)
{
// Check if user belongs to a company
$codeOps = $this->userService->getCurrentUserCodeOps();
if (empty($codeOps)) {
return $this->redirectToRoute('myeurovision_not_authorized', ['email' => 'websupport@eurovisionservices.com']);
}
$filename = 'incident_' . $id . '_details';
$incident = $this->xrmService->getIncidentById($id);
$html = $this->renderView('my_eurovision/incident_ticket_pdf_content.html.twig', [
'incident' => $incident,
'incidentTitle' => 'Service Interruption Report',
'base_dir' => $this->getParameter('kernel.project_dir') . '/../web' . $request->getBasePath()
]);
$header = $this->renderView('my_eurovision/incident_ticket_pdf_header.html.twig');
$footer = $this->renderView('my_eurovision/incident_ticket_pdf_footer.html.twig');
return new Response(
$pdf->getOutputFromHtml($html, [
'header-html' => $header,
'footer-html' => $footer,
]), 200, [
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="' . $filename . '.pdf"'
]
);
}
/**
* @Security("is_granted('ROLE_USER')")
* @Route("/intern/incident/{caseId}/{action}/{source}", name="incident_accept_reject_sir", options={"expose" = true})
* @param Request $request
* @param string $caseId
* @param string $action
* @return Response
*/
public function incidentAcceptSirAction(Request $request, string $caseId, string $action, string $source)
{
// Check if user belongs to a company
$codeOps = $this->userService->getCurrentUserCodeOps();
if (empty($codeOps)) {
return $this->redirectToRoute('myeurovision_not_authorized', ['email' => 'websupport@eurovisionservices.com']);
}
try {
$comments = (!empty($request->get('comments'))) ? $request->get('comments') : '';
$user = $this->userService->getCurrentUserFullname();
$this->xrmService->changeStatusCase($caseId, $action, XrmService::XRM_STATUS_REJECTED_CODE, $comments, $user, $source);
return $this->json("ok");
} catch (Exception $ex) {
return $this->json($ex->getMessage(), JsonResponse::HTTP_INTERNAL_SERVER_ERROR);
}
}
/**
* @Security("is_granted('ROLE_USER')")
* @Route("/myeurovision/company/equipment", name="myeurovision_equipment", options={"expose" = true})
* @param Request|null $request
* @return Response
*/
public function equipmentAction(Request $request = null)
{
// Check if user belongs to a company
$codeOps = $this->userService->getCurrentUserCodeOps();
if (empty($codeOps)) {
return $this->redirectToRoute('myeurovision_not_authorized');
}
// Build the form
$equipment = new Equipment();
$surveyEquipmentModelList = $this->equipmentService->getSurveyEquipmentModelList();
$surveyTypeList = $this->equipmentService->getSurveyTypeList();
krsort($surveyTypeList);
// Generate uniqId for attachments
$uniqIdForm = uniqid();
$form = $this->createForm(EquipmentType::class, $equipment, ['surveyEquipmentModelList' => $surveyEquipmentModelList, 'surveyTypeList' => $surveyTypeList, 'uniqIdForm' => $uniqIdForm]);
$form->handleRequest($request);
$user = $this->getUser();
return $this->render(
'my_eurovision/equipment.html.twig',
[
'user' => $user,
'uniqIdForm' => $uniqIdForm,
'surveyTypeList' => $surveyTypeList,
'newEquipmentId' => array_key_first($surveyTypeList),
'form' => $form->createView()
]
);
}
/**
* @Route("/intern/myeurovision/company/equipment/{userCodeops}", name="myeurovision_equipment_list", options={"expose" = true }, methods={"GET"})
* @param Request $request
* @param string $userEmail
* @return Response
*/
public function getEquipmentsByCodeops(Request $request, string $userCodeops)
{
$jiraIssues = [];
try {
$codeops = [];
// Get user codeops family
$companies = $this->domainService->getListUserOrganizationAndOrganizationFamilies();
if (!empty($companies)) {
foreach ($companies as $company) {
$codeops[] = $company->code;
}
}
$jiraIssues = $this->equipmentService->getJiraTicketByCodeops($codeops);
} catch (Exception $ex) {
$this->actionLoggerService->getLogger()->error("cant get jira tickets", ["exception" => $ex]);
}
return $this->render(
'my_eurovision/equipment_jira_list_table.html.twig', [
'jiraIssues' => $jiraIssues
]);
}
/**
* @Route("/intern/myeurovision/company/equipment/{userCodeops}/by-serial-number/{serialNumber}", name="myeurovision_equipment_by_serial_number", options={"expose" = true }, methods={"GET"})
* @param Request $request
* @param string $userCodeops
* @param string $serialNumber
* @return Response
*/
public function getEquipmentsBySerialNumber(Request $request, string $userCodeops, string $serialNumber)
{
return $this->json($this->equipmentService->checkEquipmentsBySerialNumber($userCodeops, $serialNumber));
}
/**
* @Security("is_granted('ROLE_USER')")
* @Route("/intern/myeurovision/company/equipment/submit", name="myeurovision_equipment_submit", options={"expose" = true})
* @param Request $request
* @param LoggerInterface $logger
* @return Response
*/
public function submitEquipmentAction(Request $request, LoggerInterface $logger)
{
try {
$equipment = new Equipment();
$surveyEquipmentModelList = $this->equipmentService->getSurveyEquipmentModelList();
$surveyTypeList = $this->equipmentService->getSurveyTypeList();
$form = $this->createForm(EquipmentType::class, $equipment, ['surveyEquipmentModelList' => $surveyEquipmentModelList, 'surveyTypeList' => $surveyTypeList]);
$form->handleRequest($request);
//not valid...
if (!$form->isValid()) {
$errors = Helper::getErrorMessagesFlat($form, true);
$data['message'] = "Please, check errors in your equipment";
$data['errors'] = $errors;
$jsonResponse = $this->json($data, JsonResponse::HTTP_BAD_REQUEST);
return $jsonResponse;
}
$user = $this->getUser();
// Create/Edit ticket in JIRA
$result = $this->equipmentService->createEditEquipmentJiraTicket($equipment, $user);
$this->equipmentService->changeStatusJiraTicketAndSendMail($result['key']);
// Add user in Mailchimp mailing list
$subscriptionResult = $this->equipmentService->addUserSubscription($equipment, $user);
if (empty($result)) {
return $this->json($result, JsonResponse::HTTP_INTERNAL_SERVER_ERROR);
}
return $this->json($result);
} catch (Exception $ex) {
$logger->alert("error in submit equipment" . $ex->getMessage(), ["exception" => $ex]);
return $this->json($ex->getMessage(), JsonResponse::HTTP_INTERNAL_SERVER_ERROR);
}
}
/**
* @Security("is_granted('ROLE_USER')")
* @Route("/intern/myeurovision/company/equipment/add-comment", name="myeurovision_equipment_add_comment", options={"expose" = true})
* @param Request $request
* @param LoggerInterface $logger
* @return Response
*/
public function addJiraCommentAction(Request $request, LoggerInterface $logger)
{
try {
$jiraKey = (!empty($request->get('jiraKey'))) ? $request->get('jiraKey') : null;
$uniqIdForm = (!empty($request->get('uniqIdForm'))) ? $request->get('uniqIdForm') : null;
$comment = (!empty($request->get('comment'))) ? $request->get('comment') : null;
$result = $this->equipmentService->addJiraComment($jiraKey, $uniqIdForm, $comment);
return $this->json($result);
} catch (Exception $ex) {
$logger->alert("error in submitting comment" . $ex->getMessage(), ["exception" => $ex]);
return $this->json($ex->getMessage(), JsonResponse::HTTP_INTERNAL_SERVER_ERROR);
}
}
/**
* @Security("is_granted('ROLE_USER')")
* @Route("/intern/myeurovision/company/equipment/add-decoder-public-key", name="myeurovision_equipment_add_decoder_public_key", options={"expose" = true})
* @param Request $request
* @param LoggerInterface $logger
* @return Response
*/
public function addDecoderPublicKeyAction(Request $request, LoggerInterface $logger)
{
try {
$jiraKey = (!empty($request->get('jiraKey'))) ? $request->get('jiraKey') : null;
$uniqIdForm = (!empty($request->get('uniqIdForm'))) ? $request->get('uniqIdForm') : null;
$result = $this->equipmentService->addDecoderPublicKey($jiraKey, $uniqIdForm);
return $this->json($result);
} catch (Exception $ex) {
$logger->alert("error in submitting decoder public key" . $ex->getMessage(), ["exception" => $ex]);
return $this->json($ex->getMessage(), JsonResponse::HTTP_INTERNAL_SERVER_ERROR);
}
}
/**
* @Route("/intern/myeurovision/company/equipment/{reference}/details", name="myeurovision_equipment_details", options={"expose" = true }, methods={"GET"})
* @param Request $request
* @param string $reference
* @return Response
*/
public function getEquipmentDetails(Request $request, string $reference)
{
try {
$detailsHtml = '';
$attachmentsHtml = '';
$jiraIssue = $this->equipmentService->getJiraTicketDetails($reference);
$issue = $this->equipmentService->parseJiraTicketDetailsBSResponse($jiraIssue);
$detailsHtml = $this->renderView(
'my_eurovision/equipment_details.html.twig',
[
'equipment' => $issue
]
);
if (!empty($issue->attachment)) {
$attachmentsHtml = $this->renderView(
'my_eurovision/equipment_attachments.html.twig',
[
'attachments' => $issue->attachment
]
);
}
} catch (Exception $ex) {
$this->actionLoggerService->getLogger()->error("cant get jira ticket", ["exception" => $ex]);
}
return $this->json(
[
'details' => $issue,
'detailsHtml' => $detailsHtml,
'attachmentsHtml' => $attachmentsHtml
]
);
}
/**
* @Route("/intern/myeurovision/company/equipment/attachment/{attachmentId}/delete", name="myeurovision_equipment_delete_attachment", options={"expose" = true }, methods={"GET"})
* @param Request $request
* @param string $attachmentId
* @return Response
*/
public function deleteEquipmentAttachment(Request $request, string $attachmentId)
{
try {
$result = $this->equipmentService->deleteAttachmentJiraTicket($attachmentId);
} catch (Exception $ex) {
$this->actionLoggerService->getLogger()->error("cant delete attachment", ["exception" => $ex]);
}
return $this->json($result->getData());
}
/**
* @Route("/intern/myeurovision/dropzone/upload", name="myeurovision_dropzone_upload", options={"expose" = true}, methods={"GET", "POST"})
* @param Request $request
*/
public function dropzoneUploadAction(Request $request)
{
/** @var UploadedFile $media */
$media = $request->files->get('file');
$type = (!empty($request->get('type'))) ? $request->get('type') : null;
$uniqIdForm = (!empty($request->get('uniqIdForm'))) ? $request->get('uniqIdForm') : null;
$directory = null;
if ($type == 'freelancer-portal') {
$directory = FreelancerPortalService::UPLOADED_FOLDER;
} elseif ($type == 'equipment') {
$directory = EquipmentService::UPLOADED_FOLDER;
} elseif ($type == 'providers') {
$directory = ProviderService::UPLOADED_FOLDER;
} elseif ($type == 'company-registration') {
$directory = CompanyRegistrationService::UPLOADED_FOLDER;
}
$uniqDirectory = $directory . "/" . $uniqIdForm;
if (!is_dir($directory)) {
mkdir($directory);
}
if (!is_dir($uniqDirectory)) {
mkdir($uniqDirectory);
}
move_uploaded_file($media->getPathName(), $media->getPath() . '/' . $type . '/' . $uniqIdForm . '/' . $media->getClientOriginalName());
return new JsonResponse(['success' => true, 'data' => $media]);
}
/**
* @Route("/intern/myeurovision/dropzone/upload/cancel", name="myeurovision_dropzone_upload_cancel", options={"expose" = true}, methods={"GET", "POST"})
* @param Request $request
*/
public function dropzoneUploadCancelAction(Request $request)
{
$type = (!empty($request->get('type'))) ? $request->get('type') : null;
$uniqIdForm = (!empty($request->get('uniqIdForm'))) ? $request->get('uniqIdForm') : null;
$filename = (!empty($request->get('filename'))) ? $request->get('filename') : null;
$directory = null;
if ($type == 'freelancer-portal') {
$directory = FreelancerPortalService::UPLOADED_FOLDER;
} elseif ($type == 'equipment') {
$directory = EquipmentService::UPLOADED_FOLDER;
} elseif ($type == 'providers') {
$directory = ProviderService::UPLOADED_FOLDER;
} elseif ($type == 'company-registration') {
$directory = CompanyRegistrationService::UPLOADED_FOLDER;
}
$filePath = $directory . "/" . $uniqIdForm . "/" . $filename;
if (file_exists($filePath)) {
unlink($filePath);
}
return new JsonResponse(['success' => true, 'data' => 'ok']);
}
/**
* @Route("/myeurovision/not-authorized", name="myeurovision_not_authorized")
*/
public function notAuthorizedAction(Request $request)
{
$message = $request->get("message");
if ($message === null) {
$message = "";
}
$supportEmail = $request->get("email");
if ($supportEmail === null) {
$supportEmail = "p2p_cps@eurovisionservices.com";
}
return $this->render(
'my_eurovision/not-authorized.html.twig',
[
'user' => $this->getUser(),
'message' => $message,
'supportEmail' => $supportEmail
]
);
}
/**
* @Route("/myeurovision/profile/change-user-codeops/{codeops}", name="change_user_codeops", options={"expose" = true })
* @param string $codeops
* @Security("is_granted('ROLE_USER')")
*/
public function changeUserCodeopsAction(Request $request, string $codeops)
{
$res = $this->userService->updateUserCompanyName($this->getUser(), $codeops);
// Wait 5 seconds to be sure MS is refreshed
sleep(5);
return new JsonResponse([
'message' => $res->getMessage(),
'status' => $res->getStatus(),
'data' => $res->getData(),
]);
}
/**
* @Route("/myeurovision/profile/regenerate-api-keys", name="regenerate_api_keys", options={"expose" = true })
* @Security("is_granted('ROLE_USER')")
*/
public function regenerateApiKeysAction(Request $request)
{
$res = $this->userService->regenerateApiKeys($this->getUser());
if (!empty($res) && $res->getStatus() === 'success') {
$this->notificationSenderHelperService->sendRegenerateAuthenticationKeysEmail($this->getUser());
}
return new JsonResponse([
'message' => $res->getMessage(),
'status' => $res->getStatus(),
'data' => $res->getData(),
]);
}
/**
* @Route("/intern/check-first-login", name="check_first_login", options={"expose" = true}, methods={"GET"})
* @param Request|null $request
* @return JsonResponse|Response
*/
public function getFirstLoginAction(Request $request = null)
{
// Get user preference to know if it is the first login on new website
$firstLogin = false;
$redirectToRoute = null;
$user = $this->getUser();
if ($user) {
$userPreference = $this->dashboardService->getUserPreference($user->getId());
if (!empty($userPreference) && !empty($userPreference->getFirstLogin())) {
$firstLogin = false;
} else {
$this->dashboardService->saveUserPreference($user->getId(), UserPreference::TABLE);
$firstLogin = true;
// Check domain mapping
// If only one organisation associated to user email domain - auto associate user to the organisation
// If several organisations associated to user email domain - redirect user to my profile (with Flash message)
if (empty($user->getCompanyCodeOps())) {
$parts = explode('@', $user->getEmail());
$domain = array_pop($parts);
$emailDomainOrganizations = $this->xrmService->getOrganizationsRelatedToSpecificEmailDomain($domain);
$nbOrganisations = count($emailDomainOrganizations ?? []);
if ($nbOrganisations === 1) {
$user->setCompanyCodeOps($emailDomainOrganizations[0]['ava_opscode']);
} elseif ($nbOrganisations > 1) {
$this->addFlash(FlashType::INFO, [
'title' => 'Please select an organisation',
'message' => 'Your email domain is matching several organisations in our system. Please select your organisation.'
]);
$redirectToRoute = $this->generateUrl('my_profile');
}
}
// Update "displayName" in Microsoft Entra ID - (Full name of the user connected) + associate account to a company (it depends of the email domain mapping)
$this->userService->updateUser($user);
}
}
return new JsonResponse([
'firstLogin' => $firstLogin,
'redirectUrl' => $redirectToRoute
]);
}
}