src/Controller/IndexController.php line 481

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Bitrix\CRest;
  4. use App\Entity\Chart;
  5. use App\Entity\ContactSendUserData;
  6. use App\Entity\DocumentGroup;
  7. use App\Entity\Gallery;
  8. use App\Entity\Itog;
  9. use App\Entity\JukIcon;
  10. use App\Entity\JukSmi;
  11. use App\Entity\LocalProject;
  12. use App\Entity\Page;
  13. use App\Entity\PageBlock;
  14. use App\Entity\PagePageBlock;
  15. use App\Entity\Partner;
  16. use App\Entity\Person;
  17. use App\Entity\PersonCategory;
  18. use App\Entity\PresentationSendUserData;
  19. use App\Entity\PriceIndex;
  20. use App\Entity\PriceIndexItem;
  21. use App\Entity\ProjectItem;
  22. use App\Entity\Publication;
  23. use App\Entity\Project;
  24. use App\Entity\PublicationCategory;
  25. use App\Entity\Review;
  26. use App\Entity\Smi;
  27. use App\Entity\Subscribtion;
  28. use App\Entity\UserOrder;
  29. use Doctrine\ORM\EntityManagerInterface;
  30. use Doctrine\Persistence\ManagerRegistry;
  31. use Knp\Component\Pager\PaginatorInterface;
  32. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  33. use Symfony\Component\HttpFoundation\JsonResponse;
  34. use Symfony\Component\HttpFoundation\RedirectResponse;
  35. use Symfony\Component\HttpFoundation\Request;
  36. use Symfony\Component\HttpFoundation\Response;
  37. use Symfony\Component\Routing\Annotation\Route;
  38. use Symfony\Component\Validator\Validator\ValidatorInterface;
  39. use Vich\UploaderBundle\Templating\Helper\UploaderHelper;
  40. use Vich\UploaderBundle\Templating\Helper\UploaderHelperInterface;
  41. class IndexController extends AbstractController
  42. {
  43.     protected $blocks = [];
  44.     public function __construct(EntityManagerInterface $manager)
  45.     {
  46.         $blocks $manager->getRepository(PageBlock::class)->findAll();
  47.         foreach ($blocks as $block){
  48.             $this->blocks[$block->getName()] = $block;
  49.         }
  50.     }
  51.     
  52.     #[Route('/for-the-investor/parks')]
  53.     public function red1(): Response
  54.     {
  55.         return $this->redirectToRoute('app_index');
  56.     }
  57.     #[Route('/medias/newscorp/{all}'defaults: ["all"=>null])]
  58.     public function redNews($all null): Response
  59.     {
  60.         return $this->redirectToRoute('app_publications', ['type'=> 'journal' ]);
  61.     }
  62.     #[Route('/upload/for-the-investor/ip_esipovo_mo.pdf')]
  63.     public function red2(): Response
  64.     {
  65.         return $this->redirectToRoute('app_project');
  66.     }
  67.     #[Route('/parks/')]
  68.     public function red3(): Response
  69.     {
  70.         return $this->redirectToRoute('app_project');
  71.     }
  72.     #[Route('/parks')]
  73.     public function red4(): Response
  74.     {
  75.         return $this->redirectToRoute('app_project');
  76.     }
  77.     #[Route('/for-the-investor/parks')]
  78.     public function red5(): Response
  79.     {
  80.         return $this->redirectToRoute('app_project');
  81.     }
  82.     #[Route('/'name'app_index')]
  83.     public function index(ManagerRegistry $doctrine$oderNumber false): Response
  84.     {
  85. //        $charts = $doctrine->getRepository(Chart::class)->findBy(['enabled' => true]);
  86.         $itogs $doctrine->getRepository(Itog::class)->findBy([],['title'=>'DESC']);
  87.         $news $doctrine->getRepository(Publication::class)->findBy(['enabled' => true],['created'=>'DESC']);
  88.         $projects $doctrine->getRepository(project::class)->findBy(['enabled' => true]);
  89.         $localProjects $doctrine->getRepository(LocalProject::class)->filter(['page'=>0]);
  90.         $localProjectsCount ceil(count($doctrine->getRepository(LocalProject::class)->findBy(['enabled'=>true]))/4);
  91.         $partners $doctrine->getRepository(Partner::class)->findBy(['enabled' => true]);
  92.         $publicationCategory $doctrine->getRepository(PublicationCategory::class)->find(1);
  93.         $publicationCategoryVideo $doctrine->getRepository(PublicationCategory::class)->find(2);
  94.         $publicationCategorySmi $doctrine->getRepository(PublicationCategory::class)->find(3);
  95.         $publicationCategoryJournal $doctrine->getRepository(PublicationCategory::class)->find(4);
  96.         $categories $doctrine->getRepository(PublicationCategory::class)->findBy(['enabled'=>true]);
  97.         $publications $doctrine->getRepository(Publication::class)->findBy(['enabled' => true'category' => $publicationCategory], ['created'=>'DESC'], 6);
  98.         $publicationVideo $doctrine->getRepository(Publication::class)->findBy(['enabled' => true'isMain'=> true'category' => $publicationCategoryVideo], ['created'=>'DESC'], 6);
  99.         $publicationSmi $doctrine->getRepository(Publication::class)->findBy(['enabled' => true'isMain'=> true'category' => $publicationCategorySmi], ['created'=>'DESC'], 6);
  100.         $publicationJournal $doctrine->getRepository(Publication::class)->findBy(['enabled' => true'isMain'=> true'category' => $publicationCategoryJournal], ['created'=>'DESC'], 6);
  101.         $reviews $doctrine->getRepository(Review::class)->findAll();
  102.         shuffle($reviews);
  103.         $page $doctrine->getRepository(Page::class)->findOneBy(['slug' => 'main']);
  104.         $pageBlocks $doctrine->getRepository(PagePageBlock::class)->findBy(['Page'=>$page],['sort'=>'ASC']);
  105.         $indexPriceHome $doctrine->getRepository(PriceIndex::class)->findBy(['type'=>'home'], ['id'=>'DESC']);
  106.         $tmpData = [];
  107.         /** @var PriceIndex $elems */
  108.         foreach ($indexPriceHome as $elems){
  109.             /** @var PriceIndexItem $tmpItem*/
  110.             foreach ($elems->getItems() as $tmpItem ){
  111.                 if ($tmpItem->getDate()->format('Y') == 2024){
  112.                     if (isset($tmpData['prices'][$tmpItem->getDate()->format('m')])){
  113.                         $tmpData['prices'][$tmpItem->getDate()->format('m')] += $tmpItem->getPrice();
  114.                         $tmpData['counts'][$tmpItem->getDate()->format('m')] += 1;
  115.                     }else{
  116.                         $tmpData['prices'][$tmpItem->getDate()->format('m')] = $tmpItem->getPrice();
  117.                         $tmpData['counts'][$tmpItem->getDate()->format('m')] = 1;
  118.                     }
  119.                 }
  120.             }
  121.         }
  122.         $indexPriceHome $tmpData;
  123.         $indexPriceArea $doctrine->getRepository(PriceIndex::class)->findBy(['type'=>'area'], ['id'=>'DESC']);
  124.         $tmpData = [];
  125.         /** @var PriceIndex $elems */
  126.         foreach ($indexPriceArea as $elems){
  127.             /** @var PriceIndexItem $tmpItem*/
  128.             foreach ($elems->getItems() as $tmpItem ){
  129.                 if ($tmpItem->getDate()->format('Y') == 2024){
  130.                     if (isset($tmpData['prices'][$tmpItem->getDate()->format('m')])){
  131.                         $tmpData['prices'][$tmpItem->getDate()->format('m')] += $tmpItem->getPrice();
  132.                         $tmpData['counts'][$tmpItem->getDate()->format('m')] += 1;
  133.                     }else{
  134.                         $tmpData['prices'][$tmpItem->getDate()->format('m')] = $tmpItem->getPrice();
  135.                         $tmpData['counts'][$tmpItem->getDate()->format('m')] = 1;
  136.                     }
  137.                 }
  138.             }
  139.         }
  140.         $indexPriceArea $tmpData;
  141.         $indexPriceHomeElems $doctrine->getRepository(PriceIndexItem::class)->filter('home');
  142.         $tmpData = [];
  143.         foreach ($indexPriceHomeElems as $tmp){
  144.             $tmpData[] = $tmp['price'];
  145.         }
  146.         $indexPriceHomeElems $tmpData;
  147.         $indexPriceAreaElems $doctrine->getRepository(PriceIndexItem::class)->filter('area');
  148.         $tmpData = [];
  149.         foreach ($indexPriceAreaElems as $tmp){
  150.             $tmpData[] = $tmp['price'];
  151.         }
  152.         $indexPriceAreaElems $tmpData;
  153.         return $this->render('new/index/index.html.twig', [
  154.             'indexPriceHomeElems' => $indexPriceHomeElems,
  155.             'indexPriceAreaElems' => $indexPriceAreaElems,
  156.             'indexPriceHome' => $indexPriceHome,
  157.             'indexPriceArea' => $indexPriceArea,
  158.             'partners' => $partners,
  159. //            'charts' => $charts,
  160.             'news' => $news,
  161.             'projects' => $projects,
  162.             'localProjects' => $localProjects,
  163.             'localProjectsCount' => $localProjectsCount,
  164.             'oderNumber' => $oderNumber,
  165.             'publications' => $publications,
  166.             'publicationVideos' => $publicationVideo,
  167.             'publicationSmi' => $publicationSmi,
  168.             'publicationJournal' => $publicationJournal,
  169.             'categories' => $categories,
  170.             'blocks' => $this->blocks,
  171.             'reviews' => $reviews,
  172.             'action'=> 'index',
  173.             'itogs'=> $itogs,
  174.             'page'=> $page,
  175.             'pageBlocks'=> $pageBlocks,
  176.         ]);
  177.     }
  178.     #[Route('/pnorama'name'app_iframe')]
  179.     public function iframe(){
  180.         return $this->render('new/iframe.html.twig', ['blocks' => $this->blocks]);
  181.     }
  182.     
  183.     #[Route('/test-ps'name'app_test_ps')]
  184.     public function testPs(){
  185.         return $this->render('_test/index.html.twig');
  186.     }
  187.     
  188.     #[Route('/.well-known/acme-challenge/mgA7s-0tGAUQoi4x0RunYQdubFbLbK5qduzB6ZMl_b0'name'app_hello')]
  189.     public function hello(): Response
  190.     {
  191.         // Принудительно очищаем системный кэш через код
  192.         $cacheDir $this->getParameter('kernel.cache_dir');
  193.         
  194.         return new Response('mgA7s-0tGAUQoi4x0RunYQdubFbLbK5qduzB6ZMl_b0.eAhR_HhmleA4zOdOioJjXrelMNMQAUZoIHQEAN4ULX4');
  195.     }
  196.     
  197.     #[Route('/ps/ps-page'name'app_ps_page')]
  198.     public function newPage(ManagerRegistry $doctrine$oderNumber false): Response
  199.     {
  200.         $itogs $doctrine->getRepository(Itog::class)->findBy([],['title'=>'DESC']);
  201.         $news $doctrine->getRepository(Publication::class)->findBy(['enabled' => true],['created'=>'DESC']);
  202.         $projects $doctrine->getRepository(project::class)->findBy(['enabled' => true]);
  203.         $localProjects $doctrine->getRepository(LocalProject::class)->filter(['page'=>0]);
  204.         $localProjectsCount ceil(count($doctrine->getRepository(LocalProject::class)->findBy(['enabled'=>true]))/4);
  205.         $partners $doctrine->getRepository(Partner::class)->findBy(['enabled' => true]);
  206.         $publicationCategory $doctrine->getRepository(PublicationCategory::class)->find(1);
  207.         $publicationCategoryVideo $doctrine->getRepository(PublicationCategory::class)->find(2);
  208.         $publicationCategorySmi $doctrine->getRepository(PublicationCategory::class)->find(3);
  209.         $publicationCategoryJournal $doctrine->getRepository(PublicationCategory::class)->find(4);
  210.         $categories $doctrine->getRepository(PublicationCategory::class)->findBy(['enabled'=>true]);
  211.         $publications $doctrine->getRepository(Publication::class)->findBy(['enabled' => true'category' => $publicationCategory], ['created'=>'DESC'], 6);
  212.         $publicationVideo $doctrine->getRepository(Publication::class)->findBy(['enabled' => true'isMain'=> true'category' => $publicationCategoryVideo], ['created'=>'DESC'], 6);
  213.         $publicationSmi $doctrine->getRepository(Publication::class)->findBy(['enabled' => true'isMain'=> true'category' => $publicationCategorySmi], ['created'=>'DESC'], 6);
  214.         $publicationJournal $doctrine->getRepository(Publication::class)->findBy(['enabled' => true'isMain'=> true'category' => $publicationCategoryJournal], ['created'=>'DESC'], 6);
  215.         $reviews $doctrine->getRepository(Review::class)->findAll();
  216.         shuffle($reviews);
  217.         $page $doctrine->getRepository(Page::class)->findOneBy(['slug' => 'main']);
  218.         $pageBlocks $doctrine->getRepository(PagePageBlock::class)->findBy(['Page'=>$page],['sort'=>'ASC']);
  219.         $indexPriceHome $doctrine->getRepository(PriceIndex::class)->findBy(['type'=>'home'], ['id'=>'DESC']);
  220.         $tmpData = [];
  221.         /** @var PriceIndex $elems */
  222.         foreach ($indexPriceHome as $elems){
  223.             /** @var PriceIndexItem $tmpItem*/
  224.             foreach ($elems->getItems() as $tmpItem ){
  225.                 if ($tmpItem->getDate()->format('Y') == 2024){
  226.                     if (isset($tmpData['prices'][$tmpItem->getDate()->format('m')])){
  227.                         $tmpData['prices'][$tmpItem->getDate()->format('m')] += $tmpItem->getPrice();
  228.                         $tmpData['counts'][$tmpItem->getDate()->format('m')] += 1;
  229.                     }else{
  230.                         $tmpData['prices'][$tmpItem->getDate()->format('m')] = $tmpItem->getPrice();
  231.                         $tmpData['counts'][$tmpItem->getDate()->format('m')] = 1;
  232.                     }
  233.                 }
  234.             }
  235.         }
  236.         $indexPriceHome $tmpData;
  237.         $indexPriceArea $doctrine->getRepository(PriceIndex::class)->findBy(['type'=>'area'], ['id'=>'DESC']);
  238.         $tmpData = [];
  239.         /** @var PriceIndex $elems */
  240.         foreach ($indexPriceArea as $elems){
  241.             /** @var PriceIndexItem $tmpItem*/
  242.             foreach ($elems->getItems() as $tmpItem ){
  243.                 if ($tmpItem->getDate()->format('Y') == 2024){
  244.                     if (isset($tmpData['prices'][$tmpItem->getDate()->format('m')])){
  245.                         $tmpData['prices'][$tmpItem->getDate()->format('m')] += $tmpItem->getPrice();
  246.                         $tmpData['counts'][$tmpItem->getDate()->format('m')] += 1;
  247.                     }else{
  248.                         $tmpData['prices'][$tmpItem->getDate()->format('m')] = $tmpItem->getPrice();
  249.                         $tmpData['counts'][$tmpItem->getDate()->format('m')] = 1;
  250.                     }
  251.                 }
  252.             }
  253.         }
  254.         $indexPriceArea $tmpData;
  255.         $indexPriceHomeElems $doctrine->getRepository(PriceIndexItem::class)->filter('home');
  256.         $tmpData = [];
  257.         foreach ($indexPriceHomeElems as $tmp){
  258.             $tmpData[] = $tmp['price'];
  259.         }
  260.         $indexPriceHomeElems $tmpData;
  261.         $indexPriceAreaElems $doctrine->getRepository(PriceIndexItem::class)->filter('area');
  262.         $tmpData = [];
  263.         foreach ($indexPriceAreaElems as $tmp){
  264.             $tmpData[] = $tmp['price'];
  265.         }
  266.         $indexPriceAreaElems $tmpData;
  267.         
  268.         return $this->render('ps_page.html.twig', [
  269.             'indexPriceHomeElems' => $indexPriceHomeElems,
  270.             'indexPriceAreaElems' => $indexPriceAreaElems,
  271.             'indexPriceHome' => $indexPriceHome,
  272.             'indexPriceArea' => $indexPriceArea,
  273.             'partners' => $partners,
  274. //            'charts' => $charts,
  275.             'news' => $news,
  276.             'projects' => $projects,
  277.             'localProjects' => $localProjects,
  278.             'localProjectsCount' => $localProjectsCount,
  279.             'oderNumber' => $oderNumber,
  280.             'publications' => $publications,
  281.             'publicationVideos' => $publicationVideo,
  282.             'publicationSmi' => $publicationSmi,
  283.             'publicationJournal' => $publicationJournal,
  284.             'categories' => $categories,
  285.             'blocks' => $this->blocks,
  286.             'reviews' => $reviews,
  287.             'action'=> 'index',
  288.             'itogs'=> $itogs,
  289.             'page'=> $page,
  290.             'pageBlocks'=> $pageBlocks,
  291.         ]);
  292.     }
  293.     #[Route('/rss'name'app_rss'defaults: ["_format" => "xml"])]
  294.     public function rss(ManagerRegistry $doctrinePaginatorInterface $paginatorRequest $request): Response
  295.     {
  296.         $category $doctrine->getRepository(PublicationCategory::class)->findOneBy(['slug' => 'news']);
  297.         $publications $doctrine->getRepository(Publication::class)->findBy(['enabled'=>true'category' => $category],['created'=>'DESC']);
  298.         return  $this->render('rss.html.twig', ['publications'=>$publications]);
  299.     }
  300.     #[Route('/publications/{type}'name'app_publications'defaults: ['type' => 'news'])]
  301.     public function publications(ManagerRegistry $doctrinePaginatorInterface $paginatorRequest $request$type 'news'): Response
  302.     {
  303.         $category $doctrine->getRepository(PublicationCategory::class)->findOneBy(['slug' => $type]);
  304.         $categories $doctrine->getRepository(PublicationCategory::class)->findBy(['enabled' => true]);
  305.         if ($request->query->get('newId')){
  306.             $publications $doctrine->getRepository(Publication::class)->findBy(['enabled'=>true'category' => $category'parent' => $request->query->get('newId')],['created'=>'DESC']);
  307.         }else{
  308.             $publications $doctrine->getRepository(Publication::class)->findBy(['enabled'=>true'category' => $category],['created'=>'DESC']);
  309.         }
  310.         $videosCategory $doctrine->getRepository(PublicationCategory::class)->find(2);
  311.         $videos $doctrine->getRepository(Publication::class)->findBy(['enabled'=>true'category' => $videosCategory ],['created'=>'DESC'], 3);
  312.         $pagination $paginator->paginate(
  313.             $publications,
  314.             $request->query->getInt('page'1), /*page number*/
  315.             /*limit per page*/
  316.         );
  317.         return $this->render('new/index/publications.html.twig', [
  318.             'publications' => $pagination,
  319.             'category' => $category,
  320.             'videos' => $videos,
  321.             'categories' => $categories,
  322.             'action'=> 'publications',
  323.         ]);
  324.     }
  325.     #[Route('/partners'name'app_partners')]
  326.     public function partners(ManagerRegistry $doctrine): Response
  327.     {
  328.         $partners $doctrine->getRepository(Partner::class)->findBy(['enabled' => true]);
  329.         return $this->render('index/partners.html.twig', [
  330.             'partners' => $partners
  331.         ]);
  332.     }
  333.     #[Route('/404'name'app_error')]
  334.     public function error(ManagerRegistry $doctrine): Response
  335.     {
  336.         return $this->render('new/index/error.html.twig', [
  337.         ]);
  338.     }
  339.     #[Route('/contacts'name'app_contacts')]
  340.     public function contacts(
  341.         ManagerRegistry $doctrine,
  342.         Request $request,
  343.         \Swift_Mailer $mailer,
  344.         ValidatorInterface $validator,
  345.     ): Response
  346.     {
  347. //        Ключ сайта 6LeZ0HooAAAAAJqqEP7jAsh8o1kIN1yKLw19ATo6
  348. //        Секретный ключ 6LeZ0HooAAAAAL7a8xNrwIWes5rPE09FfX6nH8FW
  349.         $personCategories $doctrine->getRepository(PersonCategory::class)->findBy(['inContact' => true]);
  350.         $page $doctrine->getRepository(Page::class)->findOneBy(['slug' => 'contacts']);
  351.         $pageBlocks $doctrine->getRepository(PagePageBlock::class)->findBy(['Page'=>$page],['sort'=>'ASC']);
  352.         if ($request->getMethod() == 'POST'){
  353.             if(isset($_POST['g-recaptcha-response'])){
  354.                 $captcha=$_POST['g-recaptcha-response'];
  355.                 if ( !$captcha ) {
  356. //                    $form->addError(new FormError('Не верна заполнена капча'));
  357. //                    return $this->render('@App/Modal/register_modal_element.html.twig', ['form' => $form->createView()]);
  358.                     return  $this->redirectToRoute('app_contacts');
  359.                 }
  360.                 $secretKey "6LeZ0HooAAAAAL7a8xNrwIWes5rPE09FfX6nH8FW";
  361.                 $url 'https://www.google.com/recaptcha/api/siteverify?secret=' urlencode($secretKey) .  '&response=' urlencode($captcha);
  362.                 $response file_get_contents($url);
  363.                 $responseKeys json_decode($response,true);
  364.                 if($responseKeys["success"] || true) {
  365.                     $contactSendUserData = new ContactSendUserData(
  366.                         trim($request->request->get('phone')),
  367.                         trim($request->request->get('email')),
  368.                         trim($request->request->get('name')),
  369.                         trim($request->request->get('comment')),
  370.                     );
  371.                     $errors $validator->validate($contactSendUserData);
  372.                     if (count($errors) === 0) {
  373.                         $order = [
  374.                             'name' => $request->request->get('name'),
  375.                             'email' => $request->request->get('email'),
  376.                             'phone' => $request->request->get('phone'),
  377.                             'comment' => $request->request->get('comment'),
  378.                         ];
  379.                         $mailhtml $this->renderView('mail/contacts.html.twig', ['order'=>$order]);
  380.                         $message = (new \Swift_Message('Новый запрос из формы контактов'))
  381.                             ->setFrom('marketing@mosregco.ru''marketing@mosregco.ru')
  382.                             ->setTo(['marketing@mosregco.ru'])
  383.                             ->setBody(
  384.                                 $mailhtml
  385.                                 ,
  386.                                 'text/html'
  387.                             );
  388. //            $logger = new \Swift_Plugins_Loggers_EchoLogger();
  389. //            $mailer->registerPlugin(new \Swift_Plugins_LoggerPlugin($logger));
  390.                         $mailer->send($message);
  391.                         $this->addFlash('modal''emailSuccess');
  392.                     } else {
  393.                         $this->addFlash('modal''emailError');
  394.                     }
  395.                 }
  396.             }
  397.             return $this->render('new/index/contacts.html.twig', [
  398.                 'personCategories' => $personCategories,
  399.                 'blocks' => $this->blocks,
  400.                 'post' => true,
  401.                 'action'=> 'contacts',
  402.                 'page'=> $page,
  403.                 'pageBlocks'=> $pageBlocks,
  404.             ]);
  405.         }
  406.         return $this->render('new/index/contacts.html.twig', [
  407.             'blocks' => $this->blocks,
  408.             'personCategories' => $personCategories,
  409.             'action'=> 'contacts',
  410.             'page'=> $page,
  411.             'pageBlocks'=> $pageBlocks,
  412.         ]);
  413.     }
  414.     #[Route('/about'name'app_about')]
  415.     public function about(ManagerRegistry $doctrine): Response
  416.     {
  417.         $personCategories $doctrine->getRepository(PersonCategory::class)->findBy([], ['sort'=>'ASC']);
  418.         $persons $doctrine->getRepository(Person::class)->findBy(['category' => $personCategories[0], 'enabled'=>true],['priority'=>'ASC']);
  419.         $personsAll $doctrine->getRepository(Person::class)->findBy(['enabled'=>true],['priority'=>'ASC']);
  420.         $localProjects $doctrine->getRepository(LocalProject::class)->findBy(['enabled'=>true]);
  421.         $page_1 $doctrine->getRepository(Page::class)->findOneBy(['slug'=> 'about_1']);
  422.         $page_2 $doctrine->getRepository(Page::class)->findOneBy(['slug'=> 'about_2']);
  423.         $page_3 $doctrine->getRepository(Page::class)->findOneBy(['slug'=> 'about_3']);
  424.         $gallery $doctrine->getRepository(Gallery::class)->findBy(['enabled'=> true]);
  425.         $page $doctrine->getRepository(Page::class)->findOneBy(['slug' => 'about']);
  426.         $pageBlocks $doctrine->getRepository(PagePageBlock::class)->findBy(['Page'=>$page],['sort'=>'ASC']);
  427.         $docsGroups $doctrine->getRepository(DocumentGroup::class)->findAll();
  428.         return $this->render('new/index/about.html.twig', [
  429.             'docsGroups' => $docsGroups,
  430.             'personCategories' => $personCategories,
  431.             'persons' => $persons,
  432.             'personsAll' => $personsAll,
  433.             'localProjects' => $localProjects,
  434.             'page_1' => $page_1,
  435.             'page_2' => $page_2,
  436.             'page_3' => $page_3,
  437.             'gallery' => $gallery,
  438.             'blocks' => $this->blocks,
  439.             'action'=> 'about',
  440.             'page'=> $page,
  441.             'pageBlocks'=> $pageBlocks,
  442.         ]);
  443.     }
  444.     #[Route('/o-regione'name'app_region')]
  445.     public function oregione(ManagerRegistry $doctrine): Response
  446.     {
  447.         $page $doctrine->getRepository(Page::class)->findOneBy(['slug' => 'o-regione']);
  448.         $pageBlocks $doctrine->getRepository(PagePageBlock::class)->findBy(['Page'=>$page],['sort'=>'ASC']);
  449.         return $this->render('new/index/region.html.twig', [
  450.             'blocks' => $this->blocks,
  451.             'action'=> 'o-regione',
  452.             'page'=> $page,
  453.             'pageBlocks'=> $pageBlocks,
  454.         ]);
  455.     }
  456.     #[Route('/invest'name'app_invest')]
  457.     public function invest(ManagerRegistry $doctrine): Response
  458.     {
  459.         $localProjects $doctrine->getRepository(LocalProject::class)->findBy(['enabled' => true]);
  460.         return $this->render('index/invest.html.twig', [
  461.             'localProjects' =>$localProjects
  462.         ]);
  463.     }
  464.     #[Route('/calc'name'app_calc')]
  465.     public function calc(ManagerRegistry $doctrine): Response
  466.     {
  467.         return $this->render('index/calc.html.twig');
  468.     }
  469.     #[Route('/policy'name'app_policy')]
  470.     public function policy(ManagerRegistry $doctrine): Response
  471.     {
  472.         $page $doctrine->getRepository(Page::class)->findOneBy(['slug'=>'policy']);
  473.         return $this->render('new/index/page.html.twig',['page' => $page]);
  474.     }
  475.     #[Route('/publication/{slug}'name'app_publication_show'defaults: ['id'=>null])]
  476.     public function publication(ManagerRegistry $doctrine$slug null): Response
  477.     {
  478.         $publication $doctrine->getRepository(Publication::class)->findOneBy(['slug'=>$slug'enabled'=>true]);
  479.         if (!$publication){
  480.             throw $this->createNotFoundException();
  481.         }
  482.         $categories $doctrine->getRepository(PublicationCategory::class)->findBy(['enabled'=>true]);
  483.         $publications $doctrine->getRepository(Publication::class)->findBy(['enabled'=>true],['created'=>'DESC'], 20);
  484.         $videosCategory $doctrine->getRepository(PublicationCategory::class)->find(2);
  485.         $videos $doctrine->getRepository(Publication::class)->findBy(['enabled'=>true'category' => $videosCategory ],['created'=>'DESC'], 3);
  486.         $smiCategory $doctrine->getRepository(PublicationCategory::class)->find(3);
  487.         $smi $doctrine->getRepository(Publication::class)->findBy(['enabled'=>true'category' => $smiCategory ],['created'=>'DESC'], 3);
  488.         return $this->render('new/index/publication.html.twig', [
  489.             'categories' => $categories,
  490.             'videosCategory' => $videosCategory,
  491.             'videos' => $videos,
  492.             'news' => $publications,
  493.             'publication' => $publication,
  494.             'action'=> 'publications',
  495.             'smi'=> $smi,
  496.         ]);
  497.     }
  498.     #[Route('/publications/smi'name'app_publications_smi')]
  499.     public function publicationsSmi(ManagerRegistry $doctrinePaginatorInterface $paginatorRequest $request): Response
  500.     {
  501.         $publications $doctrine->getRepository(Smi::class)->findBy([],['created'=>'DESC']);
  502.         $pagination $paginator->paginate(
  503.             $publications,
  504.             $request->query->getInt('page'1), /*page number*/
  505.             10 /*limit per page*/
  506.         );
  507.         return $this->render('index/publications_smi.html.twig', [
  508.             'publications' => $pagination,
  509.             'action'=> 'publications',
  510.         ]);
  511.     }
  512.     #[Route('/search'name'app_search'options: ['expose' => true])]
  513.     public function search(ManagerRegistry $doctrinePaginatorInterface $paginatorRequest $request): Response
  514.     {
  515.         if ($request->isXmlHttpRequest()){
  516.             if ($request->query->get('search')){
  517.                 $news $doctrine->getRepository(Publication::class)->filter(['text'=>$request->query->get('search'),
  518.                     'category' => 1], 4);
  519.             }else{
  520.                 $news = [];
  521.             }
  522.             $json = [];
  523.             /** @var Publication $n */
  524.             foreach ($news as $n){
  525.                 $json[$n->getId()] = [
  526.                     'title' => $n->getTitle(),
  527.                     'url' => $this->generateUrl('app_publication_show', ['slug' => $n->getSlug()]),
  528.                 ];
  529.             }
  530.             return new JsonResponse($json);
  531.         }else{
  532.             if ($request->query->get('search')){
  533.                 $news $doctrine->getRepository(Publication::class)->filter(['text'=>$request->query->get('search'),
  534.                     'category' => 1], -1);
  535.             }else{
  536.                 $news = [];
  537.             }
  538.             $pagination $paginator->paginate(
  539.                 $news,
  540.                 $request->query->getInt('page'1), /*page number*/
  541.                 10 /*limit per page*/
  542.             );
  543.             return $this->render('new/index/search.html.twig', [
  544.                 'publications' => $pagination,
  545.                 'action'=> 'search',
  546.             ]);
  547.         }
  548.     }
  549.     #[Route('/person/json'name'app_person'options: ['expose' => true])]
  550.     public function personByCategory(ManagerRegistry $doctrineRequest $requestUploaderHelper $helper): Response
  551.     {
  552.         if ($request->query->get('categoryId')){
  553.             $personCategories $doctrine->getRepository(PersonCategory::class)->findBy(['id'=>$request->query->get('categoryId')], ['sort'=>'ASC']);
  554.             $persons $doctrine->getRepository(Person::class)->findBy(['category' => $personCategories[0]],['priority'=>'ASC']);
  555.         }else{
  556.             $persons = [];
  557.         }
  558.         $json = [];
  559.         /** @var Person $p */
  560.         foreach ($persons as $p){
  561.             $json[$p->getId()] = [
  562.                 'title' => $p->getName(),
  563.                 'postwork' => $p->getPost(),
  564.                 'phone' => $p->getPhone(),
  565.                 'email' => $p->getEmail(),
  566.                 'image' => $helper->asset($p,'imageFile'),
  567.                 'preview' => $helper->asset($p,'previewFile'),
  568.             ];
  569.         }
  570.         return new JsonResponse($json);
  571.     }
  572.     #[Route('/project/korolev'name'app_project_korolev')]
  573.     public function projectKorolev(ManagerRegistry $doctrineRequest $request\Swift_Mailer $mailer): Response
  574.     {
  575.         $id 2;
  576.         $project $doctrine->getRepository(Project::class)->findOneBy(['id'=> $id'enabled'=>true]);
  577.         $projectItems0 $doctrine->getRepository(ProjectItem::class)->findBy(['project' => $project'type' => '0']);
  578.         $projectItems0Count count($doctrine->getRepository(ProjectItem::class)->findBy(['project' => $project'type' => '0']));
  579.         $projectItems0Count ceil($projectItems0Count/8);
  580.         $projectItems1 $doctrine->getRepository(ProjectItem::class)->findBy(['project' => $project'type' => '1']);
  581.         $projectItems1Count count($doctrine->getRepository(ProjectItem::class)->findBy(['project' => $project'type' => '1']));
  582.         $projectItems1Count ceil($projectItems1Count/8);
  583.         $page $doctrine->getRepository(Page::class)->findOneBy(['slug' => 'korolev']);
  584.         $pageBlocks $doctrine->getRepository(PagePageBlock::class)->findBy(['Page'=>$page],['sort'=>'ASC']);
  585.         if ($request->getMethod() == 'POST' && $request->request->get('name') && $request->request->get('email')) {
  586.             $order = [
  587.                 'name' => $request->request->get('name'),
  588.                 'email' => $request->request->get('email'),
  589.                 'phone' => $request->request->get('phone'),
  590.                 'comment' => $request->request->get('comment'),
  591.             ];
  592.             $mailhtml $this->renderView('mail/contacts_2.html.twig', ['order' => $order]);
  593.             $message = (new \Swift_Message('Новый запрос из формы земельных участков'))
  594.                 ->setFrom('marketing@mosregco.ru''marketing@mosregco.ru')
  595.                 ->setTo(['marketing@mosregco.ru'])
  596.                 ->setBody(
  597.                     $mailhtml
  598.                     ,
  599.                     'text/html'
  600.                 );
  601. //            $logger = new \Swift_Plugins_Loggers_EchoLogger();
  602. //            $mailer->registerPlugin(new \Swift_Plugins_LoggerPlugin($logger));
  603.             $mailer->send($message);
  604.             $this->addFlash('modal''formSuccess');
  605.             return $this->render('new/index/project_korolev.html.twig', [
  606.                 'project'=>$project,
  607.                 'projectItems0' => $projectItems0,
  608.                 'projectItems1'=>$projectItems1,
  609.                 'post' => true,
  610.                 'projectItems0Count' => $projectItems0Count,
  611.                 'projectItems1Count' => $projectItems1Count,
  612.                 'blocks' => $this->blocks,
  613.                 'action'=> 'korolev',
  614.                 'page'=> $page,
  615.                 'pageBlocks'=> $pageBlocks,
  616.             ]);
  617.         }
  618.         return $this->render('new/index/project_korolev.html.twig', [
  619.             'project'=>$project,
  620.             'projectItems0' => $projectItems0,
  621.             'projectItems1'=>$projectItems1,
  622.             'projectItems0Count' => $projectItems0Count,
  623.             'projectItems1Count' => $projectItems1Count,
  624.             'blocks' => $this->blocks,
  625.             'action'=> 'korolev',
  626.             'page'=> $page,
  627.             'pageBlocks'=> $pageBlocks,
  628.         ]);
  629.     }
  630.     #[Route('/project/jukovskii'name'app_project_jukovskii')]
  631.     public function projectJukovskii(EntityManagerInterface $managerRequest $request\Swift_Mailer $mailer): Response
  632.     {
  633.         return new Response('');
  634.         if ($request->getMethod() == 'POST'){
  635.             $order = [
  636.                 'name' => $request->request->get('name'),
  637.                 'phone' => $request->request->get('phone'),
  638.             ];
  639.             $client CRest::call(
  640.                 'crm.contact.add',
  641.                 ['FIELDS' => [
  642.                     'NAME' => $request->request->get('name') ,
  643.                     'PHONE' => ['0' => ['VALUE' => $request->request->get('phone'), 'VALUE_TYPE' => 'WORK' ]],
  644.                 ]
  645.                 ]
  646.             );
  647.             $fields = [
  648.                 'CLIENT_ID' => $client['result'],
  649.                 'TITLE' => 'Новая заявка Жуковский (главная страница)'
  650.             ];
  651.             $result CRest::call(
  652.                 'crm.deal.add',
  653.                 ['FIELDS' => $fields]
  654.             );
  655.             $mailhtml $this->renderView('mail/jukovskii_contact_form.html.twig', ['order' => $order]);
  656.             $message = (new \Swift_Message('Запрос со страницы Жуковский '))
  657.                 ->setFrom('marketing@mosregco.ru''marketing@mosregco.ru')
  658.                 ->setTo(['marketing@mosregco.ru'])
  659.                 ->setBody(
  660.                     $mailhtml
  661.                     ,
  662.                     'text/html'
  663.                 );
  664. //            $logger = new \Swift_Plugins_Loggers_EchoLogger();
  665. //            $mailer->registerPlugin(new \Swift_Plugins_LoggerPlugin($logger));
  666.             $mailer->send($message);
  667.         }
  668.         $data1 = [
  669.             [
  670.                 'title' => 'Пищевая промышленность',
  671.                 'desc' => 'Производство пищевых продуктов, мясо, молочные продукты, хлеб и др.',
  672.                 'img' => 'ic_10.svg',
  673.             ],
  674.             [
  675.                 'title' => 'Легкая промышленность',
  676.                 'desc' => 'Текстильные изделия, одежда, кожаные изделия, обувь и др.',
  677.                 'img' => 'ic_9.svg',
  678.             ],
  679.             [
  680.                 'title' => 'Медицинское производство',
  681.                 'desc' => 'Производство лекарственных средств и медицинской техники',
  682.                 'img' => 'ic_8.svg',
  683.             ],
  684.             [
  685.                 'title' => 'Химическое производство',
  686.                 'desc' => 'Производство химических веществ , резиновых и пластмассовых изделий',
  687.                 'img' => 'ic_7.svg',
  688.             ],
  689.             [
  690.                 'title' => 'Строительная промышленность',
  691.                 'desc' => 'Материалы для строительства, кроме размещения АБЗ',
  692.                 'img' => 'ic_7.svg',
  693.             ],
  694.             [
  695.                 'title' => 'Машиностроение',
  696.                 'desc' => 'производство транспортных средств, прицепов, полуприцепов и так далее, ремонт и монтаж',
  697.                 'img' => 'ic_6.svg',
  698.             ],
  699.             [
  700.                 'title' => 'Полиграфия',
  701.                 'desc' => 'Производство бумаги и бумажных изделий, полиграфии',
  702.                 'img' => 'ic_5.svg',
  703.             ],
  704.             [
  705.                 'title' => 'Электроника',
  706.                 'desc' => 'Компьютеры, электронные и оптические изделия, электрическое оборудование',
  707.                 'img' => 'ic_4.svg',
  708.             ],
  709.             [
  710.                 'title' => 'Станкостроение',
  711.                 'desc' => 'производство оборудования и станков',
  712.                 'img' => 'ic_3.svg',
  713.             ],
  714.             [
  715.                 'title' => 'Деревообработка',
  716.                 'desc' => 'Производство мебели из дерева, изделий из дерева и др.',
  717.                 'img' => 'ic_2.svg',
  718.             ],
  719.             [
  720.                 'title' => 'Металлообработка',
  721.                 'desc' => 'Производство крупномасштабных конструкций, изделий из металла и др.',
  722.                 'img' => 'ic_1.svg',
  723.             ],
  724.         ];
  725.         $page $manager->getRepository(Page::class)->findOneBy(['slug' => 'jukovskii']);
  726.         $pageBlocks $manager->getRepository(PagePageBlock::class)->findBy(['Page'=>$page],['sort'=>'ASC']);
  727.         $project $manager->getRepository(Project::class)->find(3);
  728.         $jukSmi  $manager->getRepository(JukSmi::class)->findAll();
  729.         $jukIcons  $manager->getRepository(JukIcon::class)->findAll();
  730.         $gallery  $manager->getRepository(Gallery::class)->find(3);
  731.         return $this->render('new/index/jukovskii.html.twig', [
  732.             'action'=> 'project',
  733.             'datas'=> $data1,
  734.             'page'=> $page,
  735.             'blocks' => $this->blocks,
  736.             'pageBlocks'=> $pageBlocks,
  737.             'project' => $project,
  738.             'jukSmi' => $jukSmi,
  739.             'jukIcons' => $jukIcons,
  740.             'gallery' => $gallery,
  741.         ]);
  742.     }
  743.     #[Route('/priceindex/{type}'name'app_priceindex'defaults: ["type"=>'area'])]
  744.     public function priceindex(EntityManagerInterface $managerRequest $request\Swift_Mailer $mailer$type 'area'): Response
  745.     {
  746.         if ($type == 'area'){
  747.             $indexes $manager->getRepository(PriceIndex::class)->findBy(['type'=>'area'], ['id'=>'DESC']);
  748.         }elseif ($type == 'home'){
  749.             $indexes $manager->getRepository(PriceIndex::class)->findBy(['type'=>'home'], ['id'=>'DESC']);
  750.         }
  751.         $page $manager->getRepository(Page::class)->findOneBy(['slug' => 'priceindex']);
  752.         $pageBlocks $manager->getRepository(PagePageBlock::class)->findBy(['Page'=>$page],['sort'=>'ASC']);
  753.         $indexPriceHome $manager->getRepository(PriceIndex::class)->findBy(['type'=>'home'], ['id'=>'DESC']);
  754.         $tmpData = [];
  755.         /** @var PriceIndex $elems */
  756.         foreach ($indexPriceHome as $elems){
  757.             /** @var PriceIndexItem $tmpItem*/
  758.             foreach ($elems->getItems() as $tmpItem ){
  759.                 if ($tmpItem->getDate()->format('Y') == 2024){
  760.                     if (isset($tmpData['prices'][$tmpItem->getDate()->format('m')])){
  761.                         $tmpData['prices'][$tmpItem->getDate()->format('m')] += $tmpItem->getPrice();
  762.                         $tmpData['counts'][$tmpItem->getDate()->format('m')] += 1;
  763.                     }else{
  764.                         $tmpData['prices'][$tmpItem->getDate()->format('m')] = $tmpItem->getPrice();
  765.                         $tmpData['counts'][$tmpItem->getDate()->format('m')] = 1;
  766.                     }
  767.                 }
  768.             }
  769.         }
  770.         $indexPriceHome $tmpData;
  771.         $indexPriceArea $manager->getRepository(PriceIndex::class)->findBy(['type'=>'area'], ['id'=>'DESC']);
  772.         $tmpData = [];
  773.         /** @var PriceIndex $elems */
  774.         foreach ($indexPriceArea as $elems){
  775.             /** @var PriceIndexItem $tmpItem*/
  776.             foreach ($elems->getItems() as $tmpItem ){
  777.                 if ($tmpItem->getDate()->format('Y') == 2024){
  778.                     if (isset($tmpData['prices'][$tmpItem->getDate()->format('m')])){
  779.                         $tmpData['prices'][$tmpItem->getDate()->format('m')] += $tmpItem->getPrice();
  780.                         $tmpData['counts'][$tmpItem->getDate()->format('m')] += 1;
  781.                     }else{
  782.                         $tmpData['prices'][$tmpItem->getDate()->format('m')] = $tmpItem->getPrice();
  783.                         $tmpData['counts'][$tmpItem->getDate()->format('m')] = 1;
  784.                     }
  785.                 }
  786.             }
  787.         }
  788.         $indexPriceArea $tmpData;
  789.         $indexPriceHomeElems $manager->getRepository(PriceIndexItem::class)->filter('home');
  790.         $tmpData = [];
  791.         foreach ($indexPriceHomeElems as $tmp){
  792.             $tmpData[] = $tmp['price'];
  793.         }
  794.         $indexPriceHomeElems $tmpData;
  795.         $indexPriceAreaElems $manager->getRepository(PriceIndexItem::class)->filter('area');
  796.         $tmpData = [];
  797.         foreach ($indexPriceAreaElems as $tmp){
  798.             $tmpData[] = $tmp['price'];
  799.         }
  800.         $indexPriceAreaElems $tmpData;
  801.         return $this->render('new/index/price_index.html.twig', [
  802.             'blocks' => $this->blocks,
  803.             'type'=>$type,
  804.             'page'=>$page,
  805.             'indexes'=>$indexes,
  806.             'pageBlocks'=>$pageBlocks,
  807.             'indexPriceHome' => $indexPriceHome,
  808.             'indexPriceArea' => $indexPriceArea,
  809.             'indexPriceHomeElems' => $indexPriceHomeElems,
  810.             'indexPriceAreaElems' => $indexPriceAreaElems,
  811.         ]);
  812.     }
  813.     #[Route('/project'name'app_project')]
  814.     public function project(ManagerRegistry $doctrineRequest $request\Swift_Mailer $mailer): Response
  815.     {
  816.         $id 1;
  817.         $project $doctrine->getRepository(Project::class)->findOneBy(['id'=> $id'enabled'=>true]);
  818.         $projectItems0 $doctrine->getRepository(ProjectItem::class)->findBy(['project' => $project'type' => '0']);
  819.         $projectItems0Count count($doctrine->getRepository(ProjectItem::class)->findBy(['project' => $project'type' => '0']));
  820.         $projectItems0Count ceil($projectItems0Count/8);
  821.         $projectItems1 $doctrine->getRepository(ProjectItem::class)->findBy(['project' => $project'type' => '1']);
  822.         $projectItems1Count count($doctrine->getRepository(ProjectItem::class)->findBy(['project' => $project'type' => '1']));
  823.         $projectItems1Count ceil($projectItems1Count/8);
  824.         $page $doctrine->getRepository(Page::class)->findOneBy(['slug' => 'project']);
  825.         $pageBlocks $doctrine->getRepository(PagePageBlock::class)->findBy(['Page'=>$page],['sort'=>'ASC']);
  826.         if ($request->getMethod() == 'POST') {
  827.             $order = [
  828.                 'name' => $request->request->get('name'),
  829.                 'email' => $request->request->get('email'),
  830.                 'phone' => $request->request->get('phone'),
  831.                 'comment' => $request->request->get('comment'),
  832.             ];
  833.             $mailhtml $this->renderView('mail/contacts_2.html.twig', ['order' => $order]);
  834.             $message = (new \Swift_Message('Новый запрос из формы земельных участков'))
  835.                 ->setFrom('marketing@mosregco.ru''marketing@mosregco.ru')
  836.                 ->setTo(['marketing@mosregco.ru'])
  837.                 ->setBody(
  838.                     $mailhtml
  839.                     ,
  840.                     'text/html'
  841.                 );
  842. //            $logger = new \Swift_Plugins_Loggers_EchoLogger();
  843. //            $mailer->registerPlugin(new \Swift_Plugins_LoggerPlugin($logger));
  844.             $mailer->send($message);
  845.             $this->addFlash('modal''formSuccess');
  846.             return $this->render('new/index/project.html.twig', [
  847.                 'project'=>$project,
  848.                 'projectItems0' => $projectItems0,
  849.                 'projectItems1'=>$projectItems1,
  850.                 'post' => true,
  851.                 'projectItems0Count' => $projectItems0Count,
  852.                 'projectItems1Count' => $projectItems1Count,
  853.                 'blocks' => $this->blocks,
  854.                 'action'=> 'project',
  855.                 'page'=> $page,
  856.                 'pageBlocks'=> $pageBlocks,
  857.             ]);
  858.         }
  859.         return $this->render('new/index/project.html.twig', [
  860.             'project'=>$project,
  861.             'projectItems0' => $projectItems0,
  862.             'projectItems1'=>$projectItems1,
  863.             'projectItems0Count' => $projectItems0Count,
  864.             'projectItems1Count' => $projectItems1Count,
  865.             'blocks' => $this->blocks,
  866.             'action'=> 'project',
  867.             'page'=> $page,
  868.             'pageBlocks'=> $pageBlocks,
  869.         ]);
  870.     }
  871.     #[Route('/localproject/list'name'app_localproject_list')]
  872.     public function localprojectList(ManagerRegistry $doctrine): Response
  873.     {
  874.         $localProjects $doctrine->getRepository(LocalProject::class)->findBy(['enabled' => true]);
  875.         return $this->render('new/index/local_project_list.html.twig', ['projects'=>$localProjects]);
  876.     }
  877.     #[Route('/localproject/{id}'name'app_localproject')]
  878.     public function localproject(ManagerRegistry $doctrine$id): Response
  879.     {
  880.         $localProjects $doctrine->getRepository(LocalProject::class)->otherProjects(['page'=>0'notId'=>$id]);
  881.         $localProjectsCount ceil(count($doctrine->getRepository(LocalProject::class)->findBy(['enabled'=>true]))/4);
  882.         $project $doctrine->getRepository(LocalProject::class)->findOneBy(['id'=> $id'enabled'=>true]);
  883.         return $this->render('new/index/local_project.html.twig', [
  884.             'localProjects'=>$localProjects,
  885.             'localProjectsCount'=>$localProjectsCount,
  886.             'project'=>$project,
  887.         ]);
  888.     }
  889.     #[Route('/projectitem'name'app_project_item')]
  890.     public function projectitem(ManagerRegistry $doctrineRequest $request,UploaderHelper $helper): Response
  891.     {
  892.         $id $request->query->get('id');
  893.         $project $doctrine->getRepository(ProjectItem::class)->findOneBy(['id'=> $id]);
  894.         return $this->render('new/modals/project_item_content.html.twig', ['project'=>$project]);
  895.     }
  896.     #[Route('/project-item/{id}'name'app_iframe_project_item')]
  897.     public function projectitemByIframe(ManagerRegistry $doctrineRequest $request$id): Response
  898.     {
  899.         $project $doctrine->getRepository(ProjectItem::class)->findOneBy(['id'=> $id]);
  900.         return $this->render('new/project_item_iframe.html.twig', ['project'=>$project]);
  901.     }
  902.     #[Route('/projectitem-json'name'app_project_item_json')]
  903.     public function projectitemJson(ManagerRegistry $doctrineRequest $request,UploaderHelper $helper): Response
  904.     {
  905.         $id $request->query->get('id');
  906.         $project $doctrine->getRepository(ProjectItem::class)->findOneBy(['id'=> $id]);
  907.         $json = [
  908.             'area' => $project->getArea(),
  909.             'image' => $helper->asset($project'mapFile'),
  910.             'content' => $project->getContent()
  911.         ];
  912.         return new JsonResponse($json);
  913.     }
  914.     #[Route('/order/area/send'name'app_order_area_send')]
  915.     public function orderAreaSend(ManagerRegistry $doctrineRequest $request\Swift_Mailer $mailer): Response
  916.     {
  917.         if ($request->getMethod() != 'POST'){
  918.             return  $this->redirectToRoute('app_index');
  919.         }
  920.         if (!is_array($request->get('areaType', []))){
  921.             $areaType = [$request->get('areaType')];
  922.         }else{
  923.             $areaType $request->get('areaType', []);
  924.         }
  925.         if (!is_array($request->get('payType', []))){
  926.             $payType = [$request->get('payType')];
  927.         }else{
  928.             $payType $request->get('payType');
  929.         }
  930.         $userOrder = new UserOrder();
  931.         $userOrder->setCreated(new \DateTime());
  932.         if ($areaType){
  933.             $userOrder->setTypeArea(implode(' '$areaType));
  934.         }
  935.         if ($payType){
  936.             $userOrder->setTypePrice(implode(' '$payType));
  937.         }
  938.         $userOrder->setName($request->get('name'));
  939. //        $userOrder->setEmail($request->get('email'));
  940.         $userOrder->setPhone($request->get('phone'));
  941.         $doctrine->getManager()->persist($userOrder);
  942.         $doctrine->getManager()->flush();
  943.         $doctrine->getManager()->refresh($userOrder);
  944.         $fip explode(' '$_POST['name']);
  945. //        $client = CRest::call(
  946. //            'crm.contact.add',
  947. //            ['FIELDS' => [
  948. //                'LAST_NAME' => (isset($fip[0]) ? $fip[0] : '') ,
  949. //                'NAME' => (isset($fip[1]) ? $fip[1] : '') ,
  950. //                'SECOND_NAME' => (isset($fip[2]) ? $fip[2] : '') ,
  951. //                'PHONE' => ['0' => ['VALUE' => $_POST['phone'], 'VALUE_TYPE' => 'WORK' ]],
  952. //            ]
  953. //            ]
  954. //        );
  955. //
  956. //        $fields = [
  957. //            'TITLE' => 'Заявка из модального окна',
  958. //            'CLIENT_ID' => $client['result'],
  959. //            'UF_CRM_1675845053079' => $this->zeml($client['areaType']),
  960. //            'UF_CRM_1679571797939' => $client['payType'],
  961. //
  962. //            ];
  963. //
  964. //        $result = CRest::call(
  965. //            'crm.deal.add',
  966. //            ['FIELDS' => $fields]
  967. //        );
  968. //
  969. //
  970. //        $addcon = CRest::call(
  971. //            'crm.deal.contact.add',
  972. //            [
  973. //                'ID' => $result['result'],
  974. //                'FIELDS'=> [
  975. //                    'CONTACT_ID'=>$client['result'],
  976. //                    'SORT'=>0,
  977. //                    'PRIMARY'=>true,
  978. //                ]
  979. //            ]
  980. //        );
  981.         if ($request->request->get('pr') == 1){
  982.             $mailTitle 'Подбор площадки. Королев.';
  983.         }else{
  984.             $mailTitle 'Новый запрос на подбор участка';
  985.         }
  986. //        formType
  987.         $formType $request->request->get('formType'null);
  988.         $mailhtml $this->renderView('mail/order.html.twig', ['order'=>$userOrder'formType' => $formType]);
  989.         $message = (new \Swift_Message($mailTitle))
  990.             ->setFrom('marketing@mosregco.ru''marketing@mosregco.ru')
  991.             ->setTo(['marketing@mosregco.ru'])
  992.             ->setBody(
  993.                 $mailhtml
  994.                 ,
  995.                 'text/html'
  996.             );
  997.         $mailer->send($message);
  998.         $str1 $userOrder->getTypeArea();
  999.         $str2 $userOrder->getTypePrice();
  1000.         $result CRest::call(
  1001.             'crm.lead.add',
  1002.             ['FIELDS' => [
  1003.                 'TITLE' => $mailTitle,
  1004.                 'NAME' => $userOrder->getName(),
  1005.                 'LAST_NAME' => '',
  1006.                 'EMAIL' => ['0' => ['VALUE' => '''VALUE_TYPE' => 'WORK', ], ],
  1007.                 'PHONE' => ['0' => ['VALUE' => $userOrder->getPhone(), 'VALUE_TYPE' => 'WORK', ], ],
  1008.                 'SOURCE_ID' => 'STORE',
  1009.                 'COMMENTS' => '',
  1010.                 'UF_CRM_1674208325432' => $str1.' '.$str2 ],
  1011.             ]
  1012.         );
  1013.         if ($request->isXmlHttpRequest()){
  1014.             return new JsonResponse(['status'=> 'success''data' => $result]);
  1015.         }else{
  1016.             $this->addFlash('modal''formSuccess');
  1017.             $referer $request->headers->get('referer');
  1018.             return $this->redirect($referer);
  1019.         }
  1020.     }
  1021.     #[Route('/subscription/news'name'app_subscription')]
  1022.     public function subscription(ManagerRegistry $doctrineRequest $request\Swift_Mailer $mailer): Response
  1023.     {
  1024.         $email $request->request->get('email');
  1025.         $user $doctrine->getRepository(Subscribtion::class)->findOneBy(['email' => $email]);
  1026.         if ($user){
  1027.             if ($user->isCancel() == false){
  1028.                 $user->setCancel(true);
  1029.                 $doctrine->getManager()->flush();
  1030.                 if ($request->isXmlHttpRequest()){
  1031.                     return new JsonResponse(['status'=>'cancel''email'=>$email]);
  1032.                 }else{
  1033.                     $this->addFlash('modal''emailSuccess');
  1034.                     $referer $request->headers->get('referer');
  1035.                     return $this->redirect($referer);
  1036.                 }
  1037.             }else{
  1038.                 $user->setCancel(true);
  1039.                 $user->setCreated(new \DateTime());
  1040.                 $doctrine->getManager()->flush();
  1041.                 if ($request->isXmlHttpRequest()){
  1042.                     return new JsonResponse(['status'=>'success''email'=>$email]);
  1043.                 }else{
  1044.                     $this->addFlash('modal''subscriberSuccess');
  1045.                     $referer $request->headers->get('referer');
  1046.                     return $this->redirect($referer);
  1047.                 }
  1048.             }
  1049.         }else{
  1050.             $user = new Subscribtion();
  1051.             $user->setEmail($email);
  1052.             $doctrine->getManager()->persist($user);
  1053.             $doctrine->getManager()->flush();
  1054.             if ($request->isXmlHttpRequest()){
  1055.                 return new JsonResponse(['status'=>'success''email'=>$email]);
  1056.             }else{
  1057.                 $this->addFlash('modal''subscriberSuccess');
  1058.                 $referer $request->headers->get('referer');
  1059.                 return $this->redirect($referer);
  1060.             }
  1061.         }
  1062.     }
  1063.     #[Route('/presentation/send'name'send_presentation'options: ['expose' => true] )]
  1064.     public function sendPresentation(
  1065.         ManagerRegistry $doctrine,
  1066.         Request $request,
  1067.         \Swift_Mailer $mailer,
  1068.         UploaderHelper $helper,
  1069.         ValidatorInterface $validator,
  1070.     ): Response
  1071.     {
  1072.         $presentationSendUserData = new PresentationSendUserData(
  1073.             trim($request->request->get('phone')),
  1074.             trim($request->request->get('email')),
  1075.         );
  1076.         $errors $validator->validate($presentationSendUserData);
  1077.         $url $request->headers->get('referer');
  1078.         if (count($errors) > 0) {
  1079.             $this->addFlash('modal''emailError');
  1080.             return $this->redirect($url ?? '/');
  1081.         }
  1082.         if ($request->query->get('type') == 'jukovskii'){
  1083.             $park $doctrine->getRepository(Project::class)->find(3);
  1084.         }else{
  1085.             $park $doctrine->getRepository(Project::class)->find(1);
  1086.         }
  1087.         $mailhtml $this->renderView('mail/present.html.twig', [
  1088.             'email'=>$presentationSendUserData->getEmail(),
  1089.             'phone'=> $presentationSendUserData->getPhone(),
  1090.             'url' => $url
  1091.         ]);
  1092.         $message = (new \Swift_Message('Пользователь скачал презентацию'))
  1093.             ->setFrom('marketing@mosregco.ru''marketing@mosregco.ru')
  1094.             ->setTo(['marketing@mosregco.ru'])
  1095.             ->setBody(
  1096.                 $mailhtml
  1097.                 ,
  1098.                 'text/html'
  1099.             );
  1100. //            $logger = new \Swift_Plugins_Loggers_EchoLogger();
  1101. //            $mailer->registerPlugin(new \Swift_Plugins_LoggerPlugin($logger));
  1102.         $result CRest::call(
  1103.             'crm.lead.add',
  1104.             ['FIELDS' => [
  1105.                 'TITLE' => 'Скачивание презентации'.($request->query->get('type') == 'jukovskii' ' Жуковский' ''),
  1106.                 'EMAIL' => ['0' => ['VALUE' => $request->request->get('email'), 'VALUE_TYPE' => 'WORK', ], ],
  1107.                 'PHONE' => ['0' => ['VALUE' => $request->request->get('phone'), 'VALUE_TYPE' => 'WORK', ], ],
  1108.                 'SOURCE_ID' => 'SITE',
  1109.                 'COMMENTS' => '',
  1110.             ],
  1111.             ]
  1112.         );
  1113.         $mailer->send($message);
  1114.         $this->addFlash('modal''emailSuccess');
  1115.         if ($request->query->get('type') == 'jukovskii'){
  1116.             return $this->redirect'https://mosregco.ru' $helper->asset($park,'presentationFile') );
  1117.         }else{
  1118.             return new Response$helper->asset($park,'presentationFile') );
  1119.         }
  1120.     }
  1121.     #[Route('/p/{slug}'name'app_index_page')]
  1122.     public function page(EntityManagerInterface $manager$slug){
  1123.         $page $manager->getRepository(Page::class)->findOneBy(['slug'=>$slug'enabled'=>true]);
  1124.         return $this->render('new/index/page.html.twig', ['page'=>$page]);
  1125. //        55.803479, 37.390514
  1126.     }
  1127.     #[Route('/sitemap.xml'defaults:['_format'=>'xml'])]
  1128.     public function xml(EntityManagerInterface $manager){
  1129.         $localprojects $manager->getRepository(LocalProject::class)->findBy(['enabled'=>true]);
  1130.         $publications $manager->getRepository(Publication::class)->findBy(['enabled'=>true],['id'=>'DESC']);
  1131.         return $this->render('new/xml.xml.twig', ['localprojects'=>$localprojects'publications' => $publications]);
  1132. //        55.803479, 37.390514
  1133.     }
  1134.     private function zeml($post)
  1135.     {
  1136.         if (in_array('Участок',$post) && in_array('Помещение',$post)){
  1137.             return 1788;
  1138.         }elseif(in_array('Участок',$post)){
  1139.             return 1786;
  1140.         }elseif(in_array('Помещение',$post)){
  1141.             return 1787;
  1142.         }
  1143.         return null;
  1144.     }
  1145.     #[Route('/testtesttest')]
  1146.     public function testest1c(\Swift_Mailer $mailer){
  1147.         $message = (new \Swift_Message('тест тест 2024'))
  1148.             ->setFrom('marketing@mosregco.ru''marketing@mosregco.ru')
  1149.             ->setTo(['bhd.m@ya.ru'])
  1150.             ->setBody(
  1151.                 '<div>TEST</div>'
  1152.                 ,
  1153.                 'text/html'
  1154.             );
  1155.         $result $mailer->send($message);
  1156.         dump($result);
  1157.         return $this->render('new/index/null.html.twig');
  1158.     }
  1159. }