- <?php
- namespace DcSiteBundle\Controller\Suzuki;
- use CoreBundle\Component\CoreFormFactory;
- use CoreBundle\Component\FormManager;
- use CoreBundle\Entity\Model;
- use CoreBundle\Factory\Vehicle as VehicleFactory;
- use CoreBundle\Model\Api\OnlineService\ApiServer1C;
- use CoreBundle\Model\Vehicles\Repository;
- use CoreBundle\Model\ViDiDepartmentModel;
- use CoreBundle\Services\MediaExtensionVidi;
- use DcSiteBundle\Entity\Part;
- use DcSiteBundle\Model\Form\ServiceForm;
- use DcSiteBundle\Services\VehicleService;
- use Doctrine\ORM\EntityManagerInterface;
- use PortalBundle\Model\SeoMetaTag;
- use Symfony\Component\Filesystem\Filesystem;
- use Symfony\Component\HttpFoundation\JsonResponse;
- use Symfony\Component\HttpFoundation\RedirectResponse;
- use Symfony\Component\HttpFoundation\Request;
- use Symfony\Component\HttpFoundation\RequestStack;
- use Symfony\Component\HttpFoundation\Response;
- use Symfony\Component\HttpFoundation\Session\SessionInterface;
- use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
- use Symfony\Component\Routing\RouterInterface;
- use Twig\Environment;
- class ServiceController extends BaseController
- {
-     public function __construct(CoreFormFactory $coreFormFactory, SeoMetaTag $seoMetaTag, RequestStack $requestStack, RouterInterface $router, FormManager $formManager, EntityManagerInterface $em, ApiServer1C $apiServer1C, SessionInterface $session, Filesystem $filesystem, MediaExtensionVidi $mediaExtensionVidi, Repository $vehicleRepository, VehicleFactory $vehicleFactory, Environment $twig)
-     {
-         parent::__construct($coreFormFactory, $seoMetaTag, $requestStack, $router, $formManager, $em, $apiServer1C, $session, $filesystem, $mediaExtensionVidi, $vehicleRepository, $vehicleFactory, $twig);
-     }
-     public function accessories(): RedirectResponse
-     {
-         return $this->redirect('https://shop.suzuki-vidi.com.ua/', Response::HTTP_MOVED_PERMANENTLY);
-     }
-     public function bodyRepair(): ?Response
-     {
-         $repairPhotoForm = $this->CoreFormFactory()->repairPhotoForm();
-         return $this->baseSuzukiRender('@DcSite/Suzuki/Service/body-repair.html.twig', [
-             'repairPhotoForm' => $repairPhotoForm->createView(),
-         ]);
-     }
-     public function orderTo(): ?Response
-     {
-         return $this->baseSuzukiRender('@DcSite/Suzuki/Service/order-to.html.twig', [
-             'serviceForm' => $this->CoreFormFactory()->serviceForm()->createView(),
-             'dealerName' => $this->getDealer()->getBrand()->getName()
-         ]);
-     }
-     public function regulationsTo(VehicleService $vehicleService): ?Response
-     {
-         $models = $vehicleService->getModelsForRegulationsTo($this->getDealer());
-         return $this->baseSuzukiRender('@DcSite/Suzuki/Service/regulations-to.html.twig', [
-             'models' => $models,
-         ]);
-     }
-     public function regulationsToModel($model): ?Response
-     {
-         $model = $this->em->getRepository(Model::class)->findOneBy(['url' => $model]);
-         if (!$model) {
-             throw new NotFoundHttpException();
-         }
-         return $this->baseSuzukiRender('@DcSite/Suzuki/Service/regulations-to-model.html.twig', [
-             'model' => $model->getId(),
-             'modelTitle' => $model->getTitle(),
-         ]);
-     }
-     public function parts(): ?Response
-     {
-         return $this->baseSuzukiRender('@DcSite/Suzuki/Service/parts.html.twig', [
-             'findPartForm' => $this->CoreFormFactory()->findPartForm($this->getDealer())->createView(),
-             'buyPartsForm' => $this->CoreFormFactory()->buyPartsForm($this->getDealer())->createView(),
-             'sparesForm' => $this->CoreFormFactory()->fbDefQuestionForm('Консультация по запасным частям', ViDiDepartmentModel::DEPARTMENT_TYPE_PARTS, null, $this->getDealer())->createView(),
-         ]);
-     }
-     public function searchParts(Request $request): JsonResponse
-     {
-         $query = $request->request->get('query');
-         $part = $this->em->getRepository(Part::class)->findOneBy(['dealer' => $this->getDealer(), 'number' => $query]);
-         if (!$part) {
-             return new JsonResponse(['success' => false]);
-         }
-         return new JsonResponse([
-             'success' => true,
-             'data' => [
-                 'price' => $part->getPrice(),
-                 'id' => $part->getId(),
-                 'title' => $part->getNameByLocale($request->getLocale()),
-                 'art' => $part->getNumber(),
-                 'count' => $part->getCount(),
-             ]
-         ]);
-     }
-     public function warranty(): ?Response
-     {
-         return $this->baseSuzukiRender('@DcSite/Suzuki/Service/warranty.html.twig');
-     }
-     public function tiresHotel(): ?Response
-     {
-         return $this->baseSuzukiRender('@DcSite/Suzuki/Service/tires-hotel.html.twig', [
-             'servicesForm' => $this->CoreFormFactory()->fbDefQuestionForm('Интересует Шинний готель', null, null, $this->getDealer())->createView(),
-         ]);
-     }
-     public function holderProgram(): ?Response
-     {
-         return $this->baseSuzukiRender('@DcSite/Suzuki/Service/holder-program.html.twig');
-     }
-     public function extendedWarranty(): ?Response
-     {
-         return $this->baseSuzukiRender('@DcSite/Suzuki/Service/extended-warranty.html.twig', [
-             'servicesForm' => $this->CoreFormFactory()->fbDefQuestionForm('Интересует Продленная гарантия', null, null, $this->getDealer())->createView(),
-         ]);
-     }
-     public function multiConsultationEnter(): ?Response
-     {
-         return $this->baseSuzukiRender('@DcSite/Suzuki/Service/consultation.html.twig');
-     }
-     public function multiConsultationForm(): ?Response
-     {
-         return $this->baseSuzukiRender('@DcSite/Suzuki/Service/consultation-form.html.twig');
-     }
-     public function multiConsultationFormOnline(): ?Response
-     {
-         return $this->baseSuzukiRender('@DcSite/Suzuki/Service/consultation-form-online.html.twig');
-     }
-     public function multiConsultationTestdriveForm(): ?Response
-     {
-         return $this->baseSuzukiRender('@DcSite/Suzuki/Service/consultation-testdrive-form.html.twig');
-     }
-     public function motoService(): ?Response
-     {
-         return $this->baseSuzukiRender('@DcSite/Suzuki/Service/moto-service.html.twig', [
-             'serviceForm' => $this->CoreFormFactory()->serviceForm(null, null, ServiceForm::MOTO_SERVICE_TYPE, 1)->createView(),
-         ]);
-     }
-     public function nightServiceAgreement(): ?Response
-     {
-         return $this->baseSuzukiRender('@DcSite/Suzuki/Service/night-service-agreement.html.twig', [
-             'dealer' => $this->getDealer()
-         ]);
-     }
- }
-