src/DcSiteBundle/Controller/ToyotaBorispol/ServiceController.php line 85

Open in your IDE?
  1. <?php
  2. namespace DcSiteBundle\Controller\ToyotaBorispol;
  3. use AcquiringBundle\Entity\Order;
  4. use CoreBundle\Component\CoreFormFactory;
  5. use CoreBundle\Component\FormManager;
  6. use CoreBundle\Entity\Forms;
  7. use CoreBundle\Entity\Model;
  8. use CoreBundle\Entity\ServicePage;
  9. use CoreBundle\Factory\Vehicle as VehicleFactory;
  10. use CoreBundle\Model\Api\OnlineService\ApiServer1C;
  11. use CoreBundle\Model\Vehicles\Repository;
  12. use CoreBundle\Model\ViDiDepartmentModel;
  13. use CoreBundle\Model\ViDiWorkerModel;
  14. use CoreBundle\Services\MediaExtensionVidi;
  15. use DcSiteBundle\Entity\OnlineServiceBooking;
  16. use DcSiteBundle\Services\RentVehicleService;
  17. use DcSiteBundle\Services\ServicePageService;
  18. use DcSiteBundle\Services\VehicleService;
  19. use Doctrine\ORM\EntityManagerInterface;
  20. use MyBundle\Service\OrderService;
  21. use PortalBundle\Model\SeoMetaTag;
  22. use stdClass;
  23. use Symfony\Component\Filesystem\Filesystem;
  24. use Symfony\Component\HttpFoundation\JsonResponse;
  25. use Symfony\Component\HttpFoundation\Request;
  26. use Symfony\Component\HttpFoundation\RequestStack;
  27. use Symfony\Component\HttpFoundation\Response;
  28. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  29. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  30. use Symfony\Component\Routing\RouterInterface;
  31. use Twig\Environment;
  32. class ServiceController extends BaseController
  33. {
  34.     public function __construct(CoreFormFactory $coreFormFactorySeoMetaTag $seoMetaTagRequestStack $requestStackRouterInterface $routerFormManager $formManagerEntityManagerInterface $emApiServer1C $apiServer1CSessionInterface $sessionFilesystem $filesystemMediaExtensionVidi $mediaExtensionVidiRepository $vehicleRepositoryVehicleFactory $vehicleFactoryEnvironment $twig)
  35.     {
  36.         parent::__construct($coreFormFactory$seoMetaTag$requestStack$router$formManager$em$apiServer1C$session$filesystem$mediaExtensionVidi$vehicleRepository$vehicleFactory$twig);
  37.     }
  38.     public function to(ServicePageService $servicePageService): ?Response
  39.     {
  40.         $services $servicePageService->getServiceByDealer($this->getDealer());
  41.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/to.html.twig', [
  42.             'services' => $services,
  43.             'serviceForm' => $this->CoreFormFactory()->serviceForm()->createView(),
  44.             'isNight' => false
  45.         ]);
  46.     }
  47.     public function servicePage(Request $requestServicePageService $servicePageServiceViDiWorkerModel $viDiWorkerModel): ?Response
  48.     {
  49.         /** @var ServicePage $servicePage */
  50.         $servicePage $this->em->getRepository(ServicePage::class)->findOneBy(['dealer' => $this->getDealer(), 'state' => true'url' => $request->get('url')]);
  51.         if (!$servicePage) {
  52.             throw $this->createNotFoundException('service page not exists');
  53.         }
  54.         $pageServiceJobs $servicePageService->getPageServiceJobByPage($this->getDealer());
  55.         $pageNearbyService $servicePageService->getServiceByNearbyService($this->getDealer(), $servicePage);
  56.         $facilities explode(', '$this->getDealer()->getFacilities());
  57.         $workers $viDiWorkerModel->getAllByDealer($this->getDealer(), $request->getLocale());
  58.         $departmentService $workers[ViDiDepartmentModel::DEPARTMENT_TYPE_SERVICE];
  59.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/service-page.html.twig', [
  60.             'servicePage' => $servicePage,
  61.             'pageServiceJobs' => $pageServiceJobs,
  62.             'pageNearbyService' => $pageNearbyService,
  63.             'dealerFacilities' => $facilities,
  64.             'departmentService' => $departmentService,
  65.         ]);
  66.     }
  67.     public function regulationsTo(VehicleService $vehicleService): ?Response
  68.     {
  69.         $models $vehicleService->getModelsForRegulationsTo($this->getDealer());
  70.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/regulations-to.html.twig', [
  71.             'models' => $models,
  72.         ]);
  73.     }
  74.     public function regulationsToModel($model): ?Response
  75.     {
  76.         $model $this->em->getRepository(Model::class)->findOneBy(['url' => $model]);
  77.         if (!$model) {
  78.             throw new NotFoundHttpException();
  79.         }
  80.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/regulations-to-single.html.twig', [
  81.             'model' => $model,
  82.             'modelTitle' => $model->getTitle(),
  83.         ]);
  84.     }
  85.     public function bodyRepair(): ?Response
  86.     {
  87.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/body-repair.html.twig', [
  88.             'repairPhotoForm' => $this->CoreFormFactory()->repairPhotoForm()->createView(),
  89.         ]);
  90.     }
  91.     public function tuning(): ?Response
  92.     {
  93.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/tuning.html.twig', [
  94.                 'form' => $this->CoreFormFactory()->fbDefQuestionForm('Замовлення тюнінга'ViDiDepartmentModel::DEPARTMENT_TYPE_SERVICEnull$this->getDealer())->createView(),
  95.             ]
  96.         );
  97.     }
  98.     public function tireHotel(): ?Response
  99.     {
  100.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/tire-hotel.html.twig', [
  101.             'tireHotelOrder' => $this->CoreFormFactory()->serviceForm()->createView(),
  102.         ]);
  103.     }
  104.     public function creditCalc(Request $requestViDiWorkerModel $viDiWorkerModel): ?Response
  105.     {
  106.         $departments $viDiWorkerModel->getAllByDealer($this->getDealer(), $request->getLocale());
  107.         $needDepartment $request->getLocale() == 'ru' 'Отдел продаж' 'Відділ продажу';
  108.         $team array_filter($departments, fn($department) => $department['departmentTitle'] === $needDepartment);
  109.         $form $this->CoreFormFactory()
  110.             ->callMeForm(new Forms(), true);
  111.         $form->get('dealer')->setData($this->getDealer());
  112.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/credit-calc.html.twig', [
  113.             'creditForm' => $this->CoreFormFactory()->creditForm($this->getDealer())->createView(),
  114.             'brandId' => $this->getDealer()->getBrand()->getId(),
  115.             'dealerId' => $this->getDealer()->getId(),
  116.             'team' => current($team),
  117.             'callMeForm' => $form->createView(),
  118.         ]);
  119.     }
  120.     public function assistance(): ?Response
  121.     {
  122.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/assistance.html.twig');
  123.     }
  124.     public function warranty(): ?Response
  125.     {
  126.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/warranty.html.twig');
  127.     }
  128.     public function extendedWarranty(): ?Response
  129.     {
  130.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/extended-warranty.html.twig');
  131.     }
  132.     public function manuals(): ?Response
  133.     {
  134.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/manuals.html.twig');
  135.     }
  136.     public function myToyota(): ?Response
  137.     {
  138.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/my-toyota.html.twig');
  139.     }
  140.     public function accessory(): ?Response
  141.     {
  142.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/accessory.html.twig', [
  143.         ]);
  144.     }
  145.     public function part(): ?Response
  146.     {
  147.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/part.html.twig', [
  148.             'spareForm' => $this->CoreFormFactory()->buySparePartsForm($this->getDealer())->createView(),
  149.         ]);
  150.     }
  151.     public function multiConsultationFormOnline(Request $request): ?Response
  152.     {
  153.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/consultation-form-online.html.twig', [
  154.             'consultationForm' => $this->CoreFormFactory()->feedbackQuestionForm(null$this->getDealer(), false$request->getLocale())->createView(),
  155.         ]);
  156.     }
  157.     public function motorOil(): ?Response
  158.     {
  159.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/motor-oil.html.twig', [
  160.         ]);
  161.     }
  162.     public function motorOilSingle(): ?Response
  163.     {
  164.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/motor-oil-single.html.twig', [
  165.         ]);
  166.     }
  167.     //    Oil static start
  168.     public function oil5w30(): ?Response
  169.     {
  170.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/oil_static/motor-oils-5w-30.html.twig', [
  171.             'spareForm' => $this->CoreFormFactory()->buySparePartsForm($this->getDealer())->createView(),
  172.         ]);
  173.     }
  174.     public function afeOw16(): ?Response
  175.     {
  176.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/oil_static/motor-oils-afe-ow-16.html.twig');
  177.     }
  178.     public function afeOw20(): ?Response
  179.     {
  180.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/oil_static/motor-oils-afe-ow-20.html.twig');
  181.     }
  182.     public function pfeOw30(): ?Response
  183.     {
  184.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/oil_static/motor-oils-pfe-ow-30.html.twig');
  185.     }
  186.     public function fuelEconomy5w30(): ?Response
  187.     {
  188.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/oil_static/motor-oils-fuel-economy-5w-30.html.twig');
  189.     }
  190.     public function premiumFuelEconomy5w30(): ?Response
  191.     {
  192.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/oil_static/motor-oils-prem-fuel-economy-5w-30.html.twig');
  193.     }
  194.     public function sae5w40(): ?Response
  195.     {
  196.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/oil_static/motor-oils-sae-5w-40.html.twig');
  197.     }
  198.     //    Oil static end
  199.     public function transmissionOil(): ?Response
  200.     {
  201.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/transmission-oil.html.twig');
  202.     }
  203.     public function transmissionOilSingle(): ?Response
  204.     {
  205.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/transmission-oil-single.html.twig');
  206.     }
  207.     //    Oil static start
  208.     public function sae75w90gl5(): ?Response
  209.     {
  210.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/oil_static/transmission-oils-sae-75w-90-gl5.html.twig');
  211.     }
  212.     public function sae75w90gl4(): ?Response
  213.     {
  214.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/oil_static/transmission-oils-sae-75w-90-gl4.html.twig');
  215.     }
  216.     public function lsdSae85w90(): ?Response
  217.     {
  218.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/oil_static/transmission-oils-lsd-sae-85w-90.html.twig');
  219.     }
  220.     public function lt75w85Sae75w85(): ?Response
  221.     {
  222.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/oil_static/transmission-oils-lt-75w-85-sae-75w-85.html.twig');
  223.     }
  224.     public function hypoidGearLsdSae85w90(): ?Response
  225.     {
  226.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/oil_static/transmission-oils-hypoid-gear-lsd-sae-85w-90.html.twig');
  227.     }
  228.     public function lf75w(): ?Response
  229.     {
  230.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/oil_static/transmission-oils-lf-75w.html.twig');
  231.     }
  232.     public function dexron3(): ?Response
  233.     {
  234.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/oil_static/transmission-oils-dexron-3.html.twig');
  235.     }
  236.     public function t4(): ?Response
  237.     {
  238.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/oil_static/transmission-oils-t-4.html.twig');
  239.     }
  240.     public function ws(): ?Response
  241.     {
  242.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/oil_static/transmission-oils-ws.html.twig');
  243.     }
  244.     public function cvtFe(): ?Response
  245.     {
  246.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/oil_static/transmission-oils-cvt-fe.html.twig');
  247.     }
  248.     //    Oil static end
  249.     // Sms landing page
  250.     public function SmsLandingTradeIn(Request $request): ?Response
  251.     {
  252.         if ($this->checkSend($request)) {
  253.             return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Services/sms-landing-vidi-select.html.twig');
  254.         }
  255.         $this->sendSmsLead($request);
  256.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Services/sms-landing-vidi-select.html.twig');
  257.     }
  258.     public function replacementCarSingle(Request $request): Response
  259.     {
  260.         $booking null;
  261.         if ($request->get('bookingId')) {
  262.             $booking $this->em->getRepository(OnlineServiceBooking::class)->find($request->get('bookingId'));
  263.         }
  264.         if ($request->get('hash')) {
  265.             $order $this->em->getRepository(Order::class)->findOneBy(['hash' => $request->get('hash')]);
  266.         }
  267.         $form $this->CoreFormFactory()
  268.             ->callMeForm(new Forms(), true);
  269.         $form->get('dealer')->setData($this->getDealer());
  270.         return $this->baseToyotaBorispol('@DcSite/Toyota_Borispol/Service/replacement-car-single.html.twig', [
  271.             'booking' => $booking,
  272.             'dealer' => $this->getDealer(),
  273.             'order' => isset($order) ? $order->getId() : null,
  274.             'callMeFormPopUp' => $form->createView()
  275.         ]);
  276.     }
  277.     public function orderForRentCar(OrderService $orderService): JsonResponse
  278.     {
  279.         return $this->json($orderService->createOrderWithoutUserForRentCar($this->getDealer()));
  280.     }
  281.     public function getAvailableRentCar(RentVehicleService $rentVehicleService): JsonResponse
  282.     {
  283.         $result $rentVehicleService->getRentCarFrom1C($this->getDealer());
  284.         if (!$result) {
  285.             $result = new stdClass();
  286.             $result->success false;
  287.         } else {
  288.             $result->success true;
  289.         }
  290.         return new JsonResponse($result);
  291.     }
  292.     public function saveReplacementCarForm(Request $requestRentVehicleService $rentVehicleService): JsonResponse
  293.     {
  294.         $rentVehicleService->saveForm(
  295.             $this->getDealer(),
  296.             $request->request->all(),
  297.             $request->getHost());
  298.         return new JsonResponse([
  299.             'success' => true,
  300.         ]);
  301.     }
  302. }