- <?php
- namespace DcSiteBundle\Controller\Nissan;
- use CoreBundle\Component\CoreFormFactory;
- use CoreBundle\Component\FormManager;
- use CoreBundle\Entity\Forms;
- use CoreBundle\Factory\Vehicle as VehicleFactory;
- use CoreBundle\Model\Api\OnlineService\ApiServer1C;
- use CoreBundle\Model\Vehicles\Repository;
- use CoreBundle\Model\ViDiDepartmentModel;
- use CoreBundle\Model\ViDiWorkerModel;
- use CoreBundle\Services\MediaExtensionVidi;
- use DcSiteBundle\Model\Form\ServicesOrderForm;
- use DcSiteBundle\Services\Nissan\Finance\FinanceService;
- use Doctrine\ORM\EntityManagerInterface;
- use PortalBundle\Model\SeoMetaTag;
- use Symfony\Component\Filesystem\Filesystem;
- use Symfony\Component\HttpFoundation\Request;
- use Symfony\Component\HttpFoundation\RequestStack;
- use Symfony\Component\HttpFoundation\Response;
- use Symfony\Component\HttpFoundation\Session\SessionInterface;
- use Symfony\Component\Routing\RouterInterface;
- use Twig\Environment;
- class FinanceController extends BaseController
- {
-     private FinanceService $financeService;
-     public function __construct(FinanceService $financeService, 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)
-     {
-         $this->financeService = $financeService;
-         parent::__construct($coreFormFactory, $seoMetaTag, $requestStack, $router, $formManager, $em, $apiServer1C, $session, $filesystem, $mediaExtensionVidi, $vehicleRepository, $vehicleFactory, $twig);
-     }
-     public function insurance(): ?Response
-     {
-         return $this->baseNissanRender('@DcSite/Nissan/Finance/insurance.html.twig', [
-             'insuranceForm' => $this->CoreFormFactory()->fbDefQuestionForm('Запрос консультации по страхованию', ViDiDepartmentModel::DEPARTMENT_TYPE_FINANCE, null, $this->getDealer())->createView()
-         ]);
-     }
-     public function korp(): ?Response
-     {
-         return $this->baseNissanRender('@DcSite/Nissan/Finance/korp-clientam.html.twig', [
-             'serviceOrderForm' => $this->CoreFormFactory()->servicesOrderForm(ServicesOrderForm::CORPORATIVE_PROGRAM)->createView()
-         ]);
-     }
-     public function kredit(Request $request, ViDiWorkerModel $viDiWorkerModel): ?Response
-     {
-         $departments = $viDiWorkerModel->getAllByDealer($this->getDealer(), $request->getLocale());
-         $needDepartment = $request->getLocale() == 'ru' ? 'Отдел продаж' : 'Відділ продажу';
-         $team = array_filter($departments, fn($department) => $department['departmentTitle'] === $needDepartment);
-         $form = $this->CoreFormFactory()
-             ->callMeForm(new Forms(), true);
-         $form->get('dealer')->setData($this->getDealer());
-         return $this->baseNissanRender('@DcSite/Nissan/Finance/kredit.html.twig', [
-             'creditForm' => $this->CoreFormFactory()->creditForm($this->getDealer())->createView(),
-             'brandId' => $this->getDealer()->getBrand()->getId(),
-             'dealerId' => $this->getDealer()->getId(),
-             'team' => current($team),
-             'serviceOrderForm' => $this->CoreFormFactory()->servicesOrderForm(ServicesOrderForm::LOYALTY)->createView(),
-             'callMeForm' => $form->createView()
-         ]);
-     }
-     public function leasing(): ?Response
-     {
-         return $this->baseNissanRender('@DcSite/Nissan/Finance/leasing.html.twig', [
-             'leasingCalculatorForm' => $this->CoreFormFactory()->leasingForm()->createView(),
-         ]);
-     }
-     public function assistance(): ?Response
-     {
-         return $this->baseNissanRender('@DcSite/Nissan/Finance/nissan-assistance.html.twig');
-     }
-     public function nissanFinance(): ?Response
-     {
-         return $this->baseNissanRender('@DcSite/Nissan/Finance/nissan-finance.html.twig', [
-             'serviceOrderForm' => $this->CoreFormFactory()->servicesOrderForm(ServicesOrderForm::CREDIT)->createView()
-         ]);
-     }
-     public function tradeIn(): ?Response
-     {
-         return $this->baseNissanRender('@DcSite/Nissan/Finance/trade-in.html.twig', [
-             'serviceOrderForm' => $this->CoreFormFactory()->servicesOrderForm(ServicesOrderForm::CREDIT)->createView()
-         ]);
-     }
-     public function loyality(): ?Response
-     {
-         return $this->baseNissanRender('@DcSite/Nissan/Finance/loyality.html.twig', [
-             'serviceOrderForm' => $this->CoreFormFactory()->servicesOrderForm(ServicesOrderForm::LOYALTY)->createView()
-         ]);
-     }
-     public function selectPage(): ?Response
-     {
-         return $this->baseNissanRender('@DcSite/Nissan/Finance/vidi-select.html.twig');
-     }
-     //FOR BUSSINES
-     public function forBussines(): ?Response
-     {
-         return $this->baseNissanRender('@DcSite/Nissan/Finance/for-bussines.html.twig', [
-             'corpSalesForm' => $this->CoreFormFactory()->corpSalesForm($this->getDealer())->createView(),
-             'cars' => $this->financeService->getVehicles($this->getDealer())
-         ]);
-     }
-     //landing page
-     public function landingTradeIn(): ?Response
-     {
-         return $this->baseNissanRender('@DcSite/Nissan/Finance/landing-trade-in.html.twig');
-     }
-     public function landingSelectPage(): ?Response
-     {
-         return $this->baseNissanRender('@DcSite/Nissan/Finance/landing-vidi-select.html.twig');
-     }
-     // Sms landing page
-     public function SmsLandingTradeIn(Request $request): ?Response
-     {
-         if ($this->checkSend($request)) {
-             return $this->baseNissanRender('@DcSite/Nissan/Finance/sms-landing-vidi-select.html.twig');
-         }
-         $this->sendSmsLead($request);
-         return $this->baseNissanRender('@DcSite/Nissan/Finance/sms-landing-vidi-select.html.twig');
-     }
- }
-