src/Controller/IndexController.php line 337

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