src/DcSiteBundle/Controller/Opel/ServiceController.php line 136

Open in your IDE?
  1. <?php
  2. namespace DcSiteBundle\Controller\Opel;
  3. use CoreBundle\Component\CoreFormFactory;
  4. use CoreBundle\Component\FormManager;
  5. use CoreBundle\Entity\Model;
  6. use CoreBundle\Factory\Vehicle as VehicleFactory;
  7. use CoreBundle\Model\Api\OnlineService\ApiServer1C;
  8. use CoreBundle\Model\Vehicles\Repository;
  9. use CoreBundle\Services\MediaExtensionVidi;
  10. use DcSiteBundle\Entity\Part;
  11. use DcSiteBundle\Services\VehicleService;
  12. use Doctrine\ORM\EntityManagerInterface;
  13. use PortalBundle\Model\SeoMetaTag;
  14. use Symfony\Component\Filesystem\Filesystem;
  15. use Symfony\Component\HttpFoundation\JsonResponse;
  16. use Symfony\Component\HttpFoundation\RedirectResponse;
  17. use Symfony\Component\HttpFoundation\Request;
  18. use Symfony\Component\HttpFoundation\RequestStack;
  19. use Symfony\Component\HttpFoundation\Response;
  20. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  21. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  22. use Symfony\Component\Routing\RouterInterface;
  23. use Twig\Environment;
  24. class ServiceController extends BaseController
  25. {
  26.     public function __construct(CoreFormFactory $coreFormFactorySeoMetaTag $seoMetaTagRequestStack $requestStackRouterInterface $routerFormManager $formManagerEntityManagerInterface $emApiServer1C $apiServer1CSessionInterface $sessionFilesystem $filesystemMediaExtensionVidi $mediaExtensionVidiRepository $vehicleRepositoryVehicleFactory $vehicleFactoryEnvironment $twig)
  27.     {
  28.         parent::__construct($coreFormFactory$seoMetaTag$requestStack$router$formManager$em$apiServer1C$session$filesystem$mediaExtensionVidi$vehicleRepository$vehicleFactory$twig);
  29.     }
  30.     public function orderTo(): ?Response
  31.     {
  32.         return $this->baseOpelRender('@DcSite/Opel/Service/order-to.html.twig', [
  33.             'serviceForm' => $this->CoreFormFactory()->serviceForm()->createView(),
  34.             'dealerName' => $this->getDealer()->getBrand()->getName()
  35.         ]);
  36.     }
  37.     public function accessories(): RedirectResponse
  38.     {
  39.         return $this->redirect('https://shop.opel-vidi.com.ua/'Response::HTTP_MOVED_PERMANENTLY);
  40.     }
  41.     public function spareParts(): ?Response
  42.     {
  43.         return $this->baseOpelRender('@DcSite/Opel/Service/spare-parts.html.twig', [
  44.             'buyPartsForm' => $this->CoreFormFactory()->buyPartsForm($this->getDealer())->createView()
  45.         ]);
  46.     }
  47.     public function searchParts(Request $request): JsonResponse
  48.     {
  49.         $query $request->request->get('query');
  50.         // check if opel has relation with ServiceWork
  51.         if ($this->getDealer()->getId() == 38) {
  52.             $part $this->em->getRepository(Part::class)->findOneWithJoinServiceTxn($this->getDealer(), $query);
  53.         } else {
  54.             $part $this->em->getRepository(Part::class)->findOneBy(['dealer' => $this->getDealer(), 'number' => $query]);
  55.         }
  56.         if (!$part) {
  57.             return new JsonResponse(['success' => false]);
  58.         }
  59.         return new JsonResponse([
  60.             'success' => true,
  61.             'data' => [
  62.                 'price' => $part->getPrice(),
  63.                 'id' => $part->getId(),
  64.                 'title' => $part->getNameByLocale($request->getLocale()),
  65.                 'art' => $part->getNumber(),
  66.             ]
  67.         ]);
  68.     }
  69.     public function bodyRepair(): ?Response
  70.     {
  71.         $repairPhotoForm $this->CoreFormFactory()->repairPhotoForm();
  72.         return $this->baseOpelRender('@DcSite/Opel/Service/body-repair.html.twig', [
  73.             'repairPhotoForm' => $repairPhotoForm->createView(),
  74.         ]);
  75.     }
  76.     public function regulationsTo(VehicleService $vehicleService): ?Response
  77.     {
  78.         $models $vehicleService->getModelsForRegulationsTo($this->getDealer());
  79.         return $this->baseOpelRender('@DcSite/Opel/Service/regulations-to.html.twig', [
  80.             'models' => $models,
  81.         ]);
  82.     }
  83.     public function regulationsToModel($model): ?Response
  84.     {
  85.         $model $this->em->getRepository(Model::class)->findOneBy(['url' => $model]);
  86.         if (!$model) {
  87.             throw new NotFoundHttpException();
  88.         }
  89.         return $this->baseOpelRender('@DcSite/Opel/Service/regulations-to-model.html.twig', [
  90.             'model' => $model->getId(),
  91.             'modelTitle' => $model->getTitle(),
  92.         ]);
  93.     }
  94.     public function tiresHotel(): ?Response
  95.     {
  96.         return $this->baseOpelRender('@DcSite/Opel/Service/tires-hotel.html.twig',[
  97.             'servicesForm' => $this->CoreFormFactory()->fbDefQuestionForm('Интересует Шинний готель'null,null$this->getDealer())->createView(),
  98.         ]);
  99.     }
  100.     public function multiConsultationEnter(): ?Response
  101.     {
  102.         return $this->baseOpelRender('@DcSite/Opel/Service/consultation.html.twig');
  103.     }
  104.     public function multiConsultationForm(): ?Response
  105.     {
  106.         return $this->baseOpelRender('@DcSite/Opel/Service/consultation-form.html.twig');
  107.     }
  108.     public function multiConsultationFormOnline(): ?Response
  109.     {
  110.         return $this->baseOpelRender('@DcSite/Opel/Service/consultation-form-online.html.twig');
  111.     }
  112.     public function multiConsultationTestdriveForm(): ?Response
  113.     {
  114.         return $this->baseOpelRender('@DcSite/Opel/Service/consultation-testdrive-form.html.twig');
  115.     }
  116.     public function opelAssistance(): ?Response
  117.     {
  118.         return $this->baseOpelRender('@DcSite/Opel/Service/opel-assistance.html.twig');
  119.     }
  120.     public function contractsOpel(Request $request): ?Response
  121.     {
  122.         return $this->baseOpelRender('@DcSite/Opel/Service/servicing-contracts.html.twig');
  123.     }
  124.     public function instructionsOpel(Request $request): ?Response
  125.     {
  126.         return $this->baseOpelRender('@DcSite/Opel/Service/instructions-opel.html.twig');
  127.     }
  128. //new section for corporate clients
  129.     public function conversionProgram(Request $request): ?Response
  130.     {
  131.         return $this->baseOpelRender('@DcSite/Opel/Service/conversion-program.html.twig');
  132.     }
  133.     public function fleetManagement(Request $request): ?Response
  134.     {
  135.         return $this->baseOpelRender('@DcSite/Opel/Service/fleet-management.html.twig');
  136.     }
  137.     public function programForEmployees(Request $request): ?Response
  138.     {
  139.         return $this->baseOpelRender('@DcSite/Opel/Service/program-for-employees.html.twig');
  140.     }
  141.     public function buyBack(Request $request): ?Response
  142.     {
  143.         return $this->baseOpelRender('@DcSite/Opel/Service/buy-back.html.twig');
  144.     }
  145.     public function nightServiceAgreement(): ?Response
  146.     {
  147.         return $this->baseOpelRender('@DcSite/Opel/Service/night-service-agreement.html.twig', [
  148.             'dealer' => $this->getDealer()
  149.         ]);
  150.     }
  151. }