src/Controller/Render/PanelNavbarController.php line 302

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Render;
  3. use App\Entity\Generic\User;
  4. use App\Entity\SAAS\Server\Hetzner\DataCenter;
  5. use App\Entity\SAAS\Server\Hetzner\Image;
  6. use App\Entity\SAAS\Server\Hetzner\Server;
  7. use App\Entity\SAAS\Server\Hetzner\ServerType;
  8. use App\Entity\Telegram\AgentPublicBot\Bot;
  9. use App\Repository\Generic\UserRepository;
  10. use Doctrine\ORM\EntityManagerInterface;
  11. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  12. use Symfony\Component\HttpFoundation\Response;
  13. use Symfony\Component\Security\Core\Security;
  14. class PanelNavbarController extends AbstractController
  15. {
  16.     public Security $security;
  17.     public User $user;
  18.     public array $userNavs;
  19.     public array $adminMegaNavs;
  20.     public EntityManagerInterface $entityManager;
  21.     public $currentRoute;
  22.     public function __construct(Security $securityUserRepository $userRepository EntityManagerInterface $entityManager)
  23.     {
  24.         $this->entityManager $entityManager;
  25.         /**
  26.          * @var User $user
  27.          */
  28.         $user $security->getUser();
  29.         $this->user $user;
  30.         $this->adminMegaNavs = [
  31.             [
  32.                 'isMega' => false,
  33.                 'path' => 'app_admin_dashboard',
  34.                 'icon' => '',
  35.                 'label' => 'داشبورد مدیریت',
  36.                 'subRoutes' => [
  37.                 ],
  38.             ],
  39.             [
  40.                 'isMega' => false,
  41.                 'path' => 'app_panel_admin_domains_index',
  42.                 'icon' => '',
  43.                 'label' => 'دامنه های شخصی',
  44.                 'subRoutes' => [
  45. //                    'app_panel_admin_campaign_index',
  46. //                    'app_panel_admin_campaign_new',
  47.                 ]
  48.             ],
  49.             [
  50.                 'isMega' => false,
  51.                 'path' => 'app_panel_admin_campaign_index',
  52.                 'icon' => '',
  53.                 'label' => 'کمپین تبلیغاتی',
  54.                 'subRoutes' => [
  55.                 ],
  56.             ],
  57.             [
  58.                 'isMega' => true,
  59.                 'path' => '',
  60.                 'icon' => '',
  61.                 'label' => 'تحلیل سیستم',
  62.                 'megaRoutes' => [
  63.                     [
  64.                         'label' => 'تحلیل ورودی',
  65.                         'path' => 'app_admin_analytics_income',
  66.                         'icon' => '',
  67.                     ],
  68.                     [
  69.                         'label' => 'ثبت هزینه',
  70.                         'path' => 'app_panel_admin_cost_index',
  71.                         'icon' => '',
  72.                     ],
  73.                     [
  74.                         'label' => 'تحلیل هزینه',
  75.                         'path' => 'app_admin_analytics_cost',
  76.                         'icon' => '',
  77.                     ],
  78.                     [
  79.                         'label' => 'تحلیل مصرف سرور',
  80.                         'path' => 'app_admin_analytics_server_usage',
  81.                         'icon' => '',
  82.                     ],
  83.                     [
  84.                         'label' => 'تحلیل سالانه',
  85.                         'path' => 'app_admin_analytics_annual_income',
  86.                         'icon' => '',
  87.                     ],
  88.                 ],
  89.                 'subRoutes' => [
  90.                     'app_admin_analytics_income',
  91.                     'app_admin_analytics_cost',
  92.                     'app_admin_analytics_annual_income',
  93.                 ]
  94.             ],
  95.             [
  96.                 'isMega' => true,
  97.                 'path' => '',
  98.                 'icon' => '',
  99.                 'label' => 'کاربران',
  100.                 'megaRoutes' => [
  101.                     [
  102.                         'label' => 'ثبت نماینده',
  103.                         'path' => 'app_panel_admin_users_new',
  104.                         'icon' => '',
  105.                     ],
  106.                     [
  107.                         'label' => 'مدیریت کاربر ها',
  108.                         'path' => 'app_panel_admin_users_index',
  109.                         'icon' => '',
  110.                     ],
  111.                 ],
  112.                 'subRoutes' => [
  113.                     'app_panel_admin_users_index',
  114.                     'app_panel_admin_users_new',
  115.                     'app_panel_admin_users_edit',
  116.                     'app_panel_admin_users_archive',
  117.                     'app_panel_admin_users_delete',
  118.                     'app_panel_admin_users_analytics',
  119.                     'app_panel_admin_users_charge',
  120.                     'app_admin_telegram',
  121.                 ]
  122.             ],
  123.         ];
  124.         $this->adminMegaNavs[] = [
  125.             'isMega' => false,
  126.             'path' => 'app_admin_settings',
  127.             'icon' => '',
  128.             'label' => 'تنظیمات مدیریت',
  129.             'subRoutes' => [
  130.             ]
  131.         ];
  132.         $this->adminMegaNavs[] = [
  133.             'isMega' => true,
  134.             'path' => '',
  135.             'icon' => '',
  136.             'label' => 'VPN',
  137.             'megaRoutes' => [
  138.                 [
  139.                     'label' => 'سرویس ها',
  140.                     'path' => 'app_panel_admin_vpn_service_index',
  141.                     'icon' => '',
  142.                 ],
  143.                 [
  144.                     'label' => 'V2ray',
  145.                     'path' => 'app_panel_admin_vpn_v2ray_servers_index',
  146.                     'icon' => '',
  147.                 ],
  148.                 [
  149.                     'label' => 'OC',
  150.                     'path' => 'app_panel_admin_vpn_ocserv_servers_index',
  151.                     'icon' => '',
  152.                 ],
  153.                 [
  154.                     'label' => 'Open',
  155.                     'path' => 'app_panel_admin_vpn_openvpn_servers_index',
  156.                     'icon' => '',
  157.                 ],
  158.             ],
  159.             'subRoutes' => [
  160.                 'app_khan_vpn_panel_users',
  161.                 'app_khan_vpn_panel_wallet_summary',
  162.                 'app_khan_vpn_panel_analytics'
  163.             ]
  164.         ];
  165.         $this->adminMegaNavs[] = [
  166.             'isMega' => true,
  167.             'path' => '',
  168.             'icon' => '',
  169.             'label' => 'ServerSell',
  170.             'megaRoutes' => [
  171.                 [
  172.                     'label' => 'ایمیج ها',
  173.                     'path' => 'app_panel_admin_server_hetzner_image_index',
  174.                     'icon' => '',
  175.                 ],
  176.                 [
  177.                     'label' => 'نوع سرور ها',
  178.                     'path' => 'app_panel_admin_server_hetzner_server_type_index',
  179.                     'icon' => '',
  180.                 ],
  181.                 [
  182.                     'label' => 'دیتاسنتر ها',
  183.                     'path' => 'app_panel_admin_server_hetzner_data_center_index',
  184.                     'icon' => '',
  185.                 ],
  186.                 [
  187.                     'label' => 'خرید سرور',
  188.                     'path' => 'app_panel_user_server_location',
  189.                     'icon' => '',
  190.                 ],
  191.                 [
  192.                     'label' => 'لیست سرور',
  193.                     'path' => 'app_panel_user_server_hetzner_server_index',
  194.                     'icon' => '',
  195.                 ],
  196.             ],
  197.             'subRoutes' => [
  198.             ]
  199.         ];
  200.         $this->userNavs = [
  201.             [
  202.                 'isMega' => false,
  203.                 'path' => 'app_user_dashboard',
  204.                 'label' => 'داشبورد کاربری',
  205.                 'icon' => 'custom-status-up',
  206.                 'subRoutes' => [
  207.                 ]
  208.             ],
  209.             [
  210.                 'isMega' => true,
  211.                 'path' => 'app_panel_user_vpn_service_index',
  212.                 'label' => 'خدمات',
  213.                 'icon' => 'custom-lock-outline',
  214.                 'megaRoutes' => [
  215.                     [
  216.                         'label' => 'شبکه خصوصی مجازی 
  217. <br>
  218. VPN',
  219.                         'path' => 'app_panel_user_vpn_service_index',
  220.                         'icon' => '',
  221.                     ],
  222.                     [
  223.                         'label' => 'دامنه 
  224. <br>
  225. Domain',
  226.                         'path' => 'app_user_saas_domain',
  227.                         'icon' => '',
  228.                     ],
  229.                     [
  230.                         'label' => 'سرور ابری 
  231. <br>
  232. Cloud Server',
  233.                         'path' => 'app_panel_user_server_hetzner_server_index',
  234.                         'icon' => '',
  235.                     ],
  236.                     [
  237.                         'label' => 'دیتابیس ابری 
  238. <br>
  239. Cloud DataBase',
  240.                         'path' => '#',
  241.                         'icon' => '',
  242.                         'tag' => 'بزودی'
  243.                     ],
  244.                     [
  245.                         'label' => 'شبکه توزیع محتوا 
  246. <br>
  247. CDN',
  248.                         'path' => '#',
  249.                         'icon' => '',
  250.                         'tag' => 'بزودی'
  251.                     ],
  252.                     [
  253.                         'label' => 'فضای ابری 
  254. <br>
  255. Object Storage',
  256.                         'path' => '#',
  257.                         'icon' => '',
  258.                         'tag' => 'بزودی'
  259.                     ],
  260.                     [
  261.                         'label' => 'ربات تلگرام فروش',
  262.                         'path' => 'app_user_agent_bot_index',
  263.                         'icon' => '',
  264.                     ],
  265.                     [
  266.                         'label' => 'وبسایت فروش',
  267.                         'path' => 'app_panel_user_domains_index',
  268.                         'icon' => '',
  269.                     ],
  270.                 ],
  271.                 'subRoutes' => [
  272. //                Domain
  273.                     'app_panel_user_domains_index',
  274.                     'app_panel_user_domains_new',
  275.                     'app_panel_user_domains_edit',
  276.                     'app_panel_user_domains_informations',
  277.                     'app_panel_user_domains_archive',
  278.                     'app_panel_user_domains_delete',
  279.                     'app_panel_user_domains_charge',
  280.                     'app_config_panel_settings',
  281. //                Telegram Bot
  282.                     'app_user_agent_bot_index',
  283.                     'app_user_agent_bot_edit',
  284.                     'app_user_agent_bot_price',
  285.                     'app_user_agent_bot_archive',
  286.                     'app_user_agent_bot_delete',
  287.                 ]
  288.             ],
  289.             [
  290.                 'isMega' => false,
  291.                 'path' => 'app_user_wallet_summary',
  292.                 'label' => 'حسابداری',
  293.                 'icon' => 'custom-dollar-square',
  294.                 'subRoutes' => [
  295.                 ]
  296.             ],
  297.             [
  298.                 'isMega' => false,
  299.                 'path' => 'app_user_wallet_charge_new',
  300.                 'label' => 'شارژ کیف پول',
  301.                 'icon' => 'custom-dollar-square',
  302.                 'subRoutes' => [
  303.                 ]
  304.             ]
  305.         ];
  306.     }
  307.     public function renderDesktopSideBar($routeName): Response
  308.     {
  309.         return $this->render'panel/modules/generic/_sidebar.html.twig', [
  310.             'userNavs' => $this->userNavs,
  311.             'adminMegaNavs' => $this->adminMegaNavs,
  312.             'routeName' => $routeName
  313.         ]);
  314.     }
  315.     public function renderMobileSideBar($routeName): Response
  316.     {
  317.         return $this->render'panel/modules/generic/_sidebar_mobile.html.twig', [
  318.             'userNavs' => $this->userNavs,
  319.             'adminMegaNavs' => $this->adminMegaNavs,
  320.             'routeName' => $routeName
  321.         ]);
  322.     }
  323.     public function renderTelegramManagementNavbar($routeNameBot $bot null)
  324.     {
  325.         $routes = [
  326.             [
  327.                 'name' => $bot->getDescription(),
  328.                 'path' => 'app_telegram_agent_public_bot_management_general'
  329.             ],
  330.             [
  331.                 'name' => 'ویرایش ربات',
  332.                 'path' => 'app_telegram_agent_public_bot_management_edit'
  333.             ],
  334.             [
  335.                 'name' => 'قیف فروش',
  336.                 'path' => 'app_telegram_agent_public_bot_management_marketing'
  337.             ],
  338.             [
  339.                 'name' => 'تحلیل فروش',
  340.                 'path' => 'app_telegram_agent_public_bot_management_analytics'
  341.             ],
  342.             [
  343.                 'name' => 'قیمت گذاری بسته ها برای فروش',
  344.                 'path' => 'app_telegram_agent_public_bot_management_price'
  345.             ],
  346.             [
  347.                 'name' => 'کاربران ربات',
  348.                 'path' => 'app_telegram_agent_public_bot_management_users'
  349.             ],
  350.             [
  351.                 'name' => 'پیام همگانی',
  352.                 'path' => 'app_telegram_agent_public_bot_management_notification'
  353.             ],
  354.             [
  355.                 'name' => 'کمپین های ربات',
  356.                 'path' => 'app_telegram_agent_public_bot_management_campaigns',
  357.             ],
  358.             [
  359.                 'name' => 'سرویس های ربات',
  360.                 'path' => 'app_panel_user_vpn_service_index',
  361.             ],
  362.         ];
  363.         return $this->render'panel/modules/generic/_agent_telegram_management.html.twig', [
  364.             'routeName' => $routeName,
  365.             'bot' => $bot,
  366.             'routes' => $routes
  367.         ]);
  368.     }
  369.     public function renderHetznerFormBreadCrumb($route)
  370.     {
  371.         $datacenter null;
  372.         if ($route->get('datacenter') && $this->entityManager->getRepository(DataCenter::class)->find($route->get('datacenter'))){
  373.             $datacenter $this->entityManager->getRepository(DataCenter::class)->find($route->get('datacenter'));
  374.         }
  375.         if ($route->get('datacenter') && $this->entityManager->getRepository(\App\Entity\SAAS\Server\ManageIt\DataCenter::class)->find($route->get('datacenter'))){
  376.             $datacenter $this->entityManager->getRepository(\App\Entity\SAAS\Server\ManageIt\DataCenter::class)->find($route->get('datacenter'));
  377.         }
  378.         $image null;
  379.         if ($route->get('image') && $this->entityManager->getRepository(Image::class)->find($route->get('image'))){
  380.             $image $this->entityManager->getRepository(Image::class)->find($route->get('image'));
  381.         }
  382.         if ($route->get('image') && $this->entityManager->getRepository(\App\Entity\SAAS\Server\ManageIt\Image::class)->find($route->get('image'))){
  383.             $image $this->entityManager->getRepository(\App\Entity\SAAS\Server\ManageIt\Image::class)->find($route->get('image'));
  384.         }
  385.         $serverType null;
  386.         if ($route->get('serverType') && $this->entityManager->getRepository(ServerType::class)->find($route->get('serverType'))){
  387.             $serverType $this->entityManager->getRepository(ServerType::class)->find($route->get('serverType'));
  388.         }
  389.         if ($route->get('serverType') && $this->entityManager->getRepository(\App\Entity\SAAS\Server\ManageIt\ServerType::class)->find($route->get('serverType'))){
  390.             $serverType $this->entityManager->getRepository(\App\Entity\SAAS\Server\ManageIt\ServerType::class)->find($route->get('serverType'));
  391.         }
  392.         return $this->render('panel/modules/generic/_hetzner_bread_crumb.html.twig', [
  393.             'userNavs' => $this->userNavs,
  394.             'adminMegaNavs' => $this->adminMegaNavs,
  395.             'datacenter' => $datacenter,
  396.             'image' => $image,
  397.             'serverType' => $serverType,
  398.             'routeName' => $route->get('_route')
  399.         ]);
  400.     }
  401.     public function renderManageItFormBreadCrumb($route)
  402.     {
  403.         $datacenter null;
  404.         if ($route->get('datacenter') && $this->entityManager->getRepository(DataCenter::class)->find($route->get('datacenter'))){
  405.             $datacenter $this->entityManager->getRepository(DataCenter::class)->find($route->get('datacenter'));
  406.         }
  407.         if ($route->get('datacenter') && $this->entityManager->getRepository(\App\Entity\SAAS\Server\ManageIt\DataCenter::class)->find($route->get('datacenter'))){
  408.             $datacenter $this->entityManager->getRepository(\App\Entity\SAAS\Server\ManageIt\DataCenter::class)->find($route->get('datacenter'));
  409.         }
  410.         $image null;
  411.         if ($route->get('image') && $this->entityManager->getRepository(Image::class)->find($route->get('image'))){
  412.             $image $this->entityManager->getRepository(Image::class)->find($route->get('image'));
  413.         }
  414.         if ($route->get('image') && $this->entityManager->getRepository(\App\Entity\SAAS\Server\ManageIt\Image::class)->find($route->get('image'))){
  415.             $image $this->entityManager->getRepository(\App\Entity\SAAS\Server\ManageIt\Image::class)->find($route->get('image'));
  416.         }
  417.         $serverType null;
  418.         if ($route->get('serverType') && $this->entityManager->getRepository(ServerType::class)->find($route->get('serverType'))){
  419.             $serverType $this->entityManager->getRepository(ServerType::class)->find($route->get('serverType'));
  420.         }
  421.         if ($route->get('serverType') && $this->entityManager->getRepository(\App\Entity\SAAS\Server\ManageIt\ServerType::class)->find($route->get('serverType'))){
  422.             $serverType $this->entityManager->getRepository(\App\Entity\SAAS\Server\ManageIt\ServerType::class)->find($route->get('serverType'));
  423.         }
  424.         return $this->render('panel/modules/generic/_manageit_bread_crumb.html.twig', [
  425.             'userNavs' => $this->userNavs,
  426.             'adminMegaNavs' => $this->adminMegaNavs,
  427.             'datacenter' => $datacenter,
  428.             'image' => $image,
  429.             'serverType' => $serverType,
  430.             'routeName' => $route->get('_route')
  431.         ]);
  432.     }
  433.     public function renderListServerBreadCrumb($route)
  434.     {
  435.         return $this->render('panel/modules/generic/_list_server_bread_crumb.html.twig', [
  436.             'userNavs' => $this->userNavs,
  437.             'adminMegaNavs' => $this->adminMegaNavs,
  438.             'routeName' => $route->get('_route')
  439.         ]);
  440.     }
  441.     public function renderHetznerManageBreadCrumb($route Server $server)
  442.     {
  443.         return $this->render('panel/modules/generic/_hetzner_manage_bread_crumb.html.twig', [
  444.             'server' => $server,
  445.             'routeName' => $route->get('_route')
  446.         ]);
  447.     }
  448. }