<?php
namespace DcSiteBundle\Controller\Citroen;
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\Services\VehicleService;
use Doctrine\ORM\EntityManagerInterface;
use PortalBundle\Model\SeoMetaTag;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpFoundation\JsonResponse;
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 tiresHotel(): ?Response
{
return $this->baseCitroenRender('@DcSite/Citroen/Service/tires-hotel.html.twig',[
'servicesForm' => $this->CoreFormFactory()->fbDefQuestionForm('Интересует Шинный отель', null,null, $this->getDealer())->createView(),
]);
}
public function paintingTires(): ?Response
{
return $this->baseCitroenRender('@DcSite/Citroen/Service/painting-tires.html.twig',[
'servicesForm' => $this->CoreFormFactory()->fbDefQuestionForm('Интересует Покраска дисков', null,null, $this->getDealer())->createView(),
]);
}
public function bodyRepair(): ?Response
{
$repairPhotoForm = $this->CoreFormFactory()->repairPhotoForm();
return $this->baseCitroenRender('@DcSite/Citroen/Service/body-repair.html.twig',[
'repairPhotoForm' => $repairPhotoForm->createView(),
]);
}
public function parts(): ?Response
{
return $this->baseCitroenRender('@DcSite/Citroen/Service/parts.html.twig', [
'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, 'state' => 1]);
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->baseCitroenRender('@DcSite/Citroen/Service/warranty.html.twig');
}
public function orderTo(): ?Response
{
return $this->baseCitroenRender('@DcSite/Citroen/Service/order-to.html.twig', [
'serviceForm' => $this->CoreFormFactory()->serviceForm()->createView(),
'dealerName' => $this->getDealer()->getBrand()->getName(),
]);
}
public function fixedСostTo(): ?Response
{
return $this->baseCitroenRender('@DcSite/Citroen/Service/fixed-сost-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->baseCitroenRender('@DcSite/Citroen/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->baseCitroenRender( '@DcSite/Citroen/Service/regulations-to-model.html.twig',[
'model' => $model->getId(),
'modelTitle' => $model->getTitle(),
]);
}
public function extendedWarranty(): ?Response
{
return $this->baseCitroenRender('@DcSite/Citroen/ServiceAgreements/extended-warranty.html.twig',[
'servicesForm' => $this->CoreFormFactory()->fbDefQuestionForm('Розширена гарантія', null,null, $this->getDealer())->createView(),
]);
}
public function extendedWarrantyReplacementParts(): ?Response
{
return $this->baseCitroenRender('@DcSite/Citroen/ServiceAgreements/extended-warranty-replacement-parts.html.twig',[
'servicesForm' => $this->CoreFormFactory()->fbDefQuestionForm('Розширена гарантія + заміна деталей природного зносу', null,null, $this->getDealer())->createView(),
]);
}
public function extendedWarrantyTo(): ?Response
{
return $this->baseCitroenRender('@DcSite/Citroen/ServiceAgreements/extended-warranty-to.html.twig',[
'servicesForm' => $this->CoreFormFactory()->fbDefQuestionForm('Розширена гарантія + заміна деталей природного зносу + то', null,null, $this->getDealer())->createView(),
]);
}
public function extendedWarrantyCitroen(): ?Response
{
return $this->baseCitroenRender('@DcSite/Citroen/Service/extended-warranty.html.twig', [
'servicesForm' => $this->CoreFormFactory()->extendedWarrantyForm()->createView(),
]);
}
public function modernizationCampaigns(): ?Response
{
return $this->baseCitroenRender('@DcSite/Citroen/Service/modernization-campaigns.html.twig');
}
public function washingCleaning(): ?Response
{
return $this->baseCitroenRender('@DcSite/Citroen/Service/washing-and-dry-cleaning.html.twig');
}
public function citroenInstructions(): ?Response
{
return $this->baseCitroenRender('@DcSite/Citroen/Service/citroen-instructions.html.twig');
}
public function multiConsultationEnter(): ?Response
{
return $this->baseCitroenRender('@DcSite/Citroen/Service/consultation.html.twig');
}
public function multiConsultationForm(): ?Response
{
return $this->baseCitroenRender('@DcSite/Citroen/Service/consultation-form.html.twig');
}
public function multiConsultationFormOnline(): ?Response
{
return $this->baseCitroenRender('@DcSite/Citroen/Service/consultation-form-online.html.twig');
}
public function multiConsultationTestdriveForm(): ?Response
{
return $this->baseCitroenRender('@DcSite/Citroen/Service/consultation-testdrive-form.html.twig');
}
public function nightServiceAgreement(): ?Response
{
return $this->baseCitroenRender('@DcSite/Citroen/Service/night-service-agreement.html.twig', [
'dealer' => $this->getDealer()
]);
}
}