src/Controller/HomeController.php line 886

Open in your IDE?
  1. <?php namespace App\Controller;
  2. use App\Entity\Clients;
  3. use App\Entity\KeywordPage;
  4. use App\Entity\TalentGroup;
  5. use App\Repository\JobCallRepository;
  6. use App\Repository\JobCallStageRepository;
  7. use App\Repository\LightboxRepository;
  8. use App\Services\ImageService;
  9. use App\Services\MailerService;
  10. use Doctrine\ORM\Tools\Pagination\Paginator;
  11. use Symfony\Component\HttpFoundation\JsonResponse;
  12. use Symfony\Component\HttpFoundation\Request;
  13. use Symfony\Component\HttpFoundation\Response;
  14. use Symfony\Component\HttpFoundation\Session\Session;
  15. use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
  16. class HomeController extends BaseController {
  17. //    /**
  18. //     * @var MailerService
  19. //     */
  20. //    private $sesmail;
  21. //
  22. //    public function __construct(MailerService $ms)
  23. //    {
  24. //        $this->sesmail =  null;//$ms;
  25. //    }
  26.     /*
  27.     |--------------------------------------------------------------------------
  28.     | Default Home Controller
  29.     |--------------------------------------------------------------------------
  30.     |
  31.     | You may wish to use controllers instead of, or in addition to, Closure
  32.     | based routes. That's great! Here is an example controller method to
  33.     | get you started. To route to this controller, just add the route:
  34.     |
  35.     |    Route::get('/', 'HomeController@showWelcome');
  36.     |
  37.     */
  38.     public function showMobileClients(Request $request$paged 0){
  39.       //  var_dump($paged);
  40.         if(isset($request->request->all()['paged'])) $paged $request->request->all()['paged'];
  41.         $clients $this->getDoctrine()->getRepository('App\Entity\Clients')->createQueryBuilder('o');
  42.         $clients2 $this->getDoctrine()->getRepository('App\Entity\Clients')->createQueryBuilder('o');
  43.         $clients2->where('o.password IS NOT NULL');
  44.         // dd($clients2);
  45.         $clients->where('o.password IS NOT NULL');
  46.         $clients->andWhere('o.incompleteProfile = :incompleteProfile');
  47.         $clients->setParameter('incompleteProfile''false');
  48.         $clients->setFirstResult$paged 30);
  49.         $clients->setMaxResults(30);
  50.         $form_params = [
  51.             'incompleteProfile''ethnicity''age''real_age''display_name''first_name''sir_name',
  52.             'languages''infobox''description_of_client''gender_two''height''accent''real_families',
  53.             'userRegistered''location','talents''area'
  54.             ,
  55.         ];
  56.         foreach($form_params as $param)
  57.         {
  58.             if(
  59.                 (isset( $_REQUEST[$param] ))
  60.                 && (!empty( $_REQUEST[$param] ))
  61.                 && ( == )
  62.                 && ( $_REQUEST[$param] != '-1' )
  63.             ) {
  64.                 $clients->andWhere("o.$param LIKE :$param");
  65.                 $clients->setParameter($param'%'.$_REQUEST[$param].'%');
  66.                 $clients2->andWhere("o.$param LIKE :$param");
  67.                 $clients2->setParameter($param'%'.$_REQUEST[$param].'%');
  68.             }
  69.         }
  70.         $clients $clients->getQuery()->getResult();
  71.         $clients2->andWhere('o.incompleteProfile = :incompleteProfile');
  72.         $clients2->setParameter('incompleteProfile''false');
  73.         $clients2->orderBy('o.userRegistered''DESC');
  74.         $clients2 $clients2->getQuery()->getResult();
  75. //        dd(count($clients2) / 30);
  76.         return $this->render('theme::views.mobile.all_clients', [
  77.             'clients' =>$clients,
  78.             'paged' => $paged,
  79.             'dataAjaxFalse' => 'data-ajax="false"' ,
  80.             'last_page' => count($clients2) / 30,
  81.             ]);
  82.         return "ddd";
  83.         $this->showClients($pagedtrue);
  84.     }
  85.     public function showClients(Request $request$page 0$isMobileView false)
  86.     {
  87. //        dump($request->request->all()['search_page_num'] ?? "no");
  88. //        die;
  89.         if(isset($request->request->all()['paged'])) $paged $request->request->all()['paged'];
  90.         $clients $this->getDoctrine()->getRepository('App\Entity\Clients')->createQueryBuilder('o');
  91.         $clients2 $this->getDoctrine()->getRepository('App\Entity\Clients')->createQueryBuilder('o');
  92.        // dd($clients2);
  93.         $clients->where('o.password IS NOT NULL');
  94.         $clients->andWhere('o.incompleteProfile = :incompleteProfile');
  95.         $clients->setParameter('incompleteProfile''false');
  96.         $clients->orderBy('o.userRegistered''DESC');
  97.         $clients2->where('o.password IS NOT NULL');
  98.         $clients2->andWhere('o.incompleteProfile = :incompleteProfile');
  99.         $clients2->setParameter('incompleteProfile''false');
  100.         $form_params = [
  101.             'incompleteProfile''ethnicity''age''real_age''display_name''first_name''sir_name',
  102.             'languages''infobox''description_of_client''gender_two''height''accent''real_families',
  103.             'userRegistered''location''area''is_beautiful''has_spotlight'
  104.             ,
  105.         ];
  106. //        $jobs = $this->getDoctrine()->getRepository('App\Entity\Jobs');
  107. //        $jobs->findAll()
  108.         foreach($form_params as $param)
  109.         {
  110.             if(
  111.                 (isset( $_REQUEST[$param] ))
  112.                 && (!empty( $_REQUEST[$param] ))
  113.                 && ( == )
  114.                 && ( $_REQUEST[$param] != '-1' )
  115.             ) {
  116.                 $clients->andWhere("o.$param LIKE :$param");
  117.                 $clients->setParameter($param'%'.$_REQUEST[$param].'%');
  118.                 $clients2->andWhere("o.$param LIKE :$param");
  119.                 $clients2->setParameter($param'%'.$_REQUEST[$param].'%');
  120.             }
  121.         }
  122.         $limit 18;
  123.         $offset $page $limit;
  124. //dump('$_REQUEST', $_REQUEST);
  125. //die;
  126.         if(  isset($request->request->all()['paged'])  )
  127.         {
  128.             $paged $request->request->all()['paged'];
  129.         }
  130.         $clients->setFirstResult($offset);
  131.         //$clients->setFirstResult( $paged );
  132.         $clients->setMaxResults($limit);
  133.         $q $clients->getQuery();
  134.         $clients $q->getResult();
  135.         $count count($clients2->getQuery()->getResult());
  136.         $paginator = new Paginator($q);
  137.         $talent_groups $this->getDoctrine()->getRepository('App\Entity\TalentGroup');
  138.         $settings $this->getDoctrine()->getRepository('App\Entity\SiteSetting')->findAll()[0];
  139.         $pagination_info = array(
  140.             'total' => (int) $count,
  141.             'current' => (int) $page,
  142.             'pages' => (int) ceil($count $limit),
  143.             'path' =>  'all-clients'
  144.         );
  145.         $talent_groups_repo $this->getDoctrine()->getRepository('App\Entity\TalentGroup');
  146.         $talent_repo $this->getDoctrine()->getRepository('App\Entity\Talent');
  147.         return
  148.             $this->render('new/clients.html.twig', [
  149.                 'paginator' => $paginator,
  150.                 'settings' => $settings,
  151.                 'talent-groups' => $talent_groups,
  152.                 'last_page' => $count 30,
  153.                 'is_search' => $request->request->all()['search_active'] ?? 'no',
  154.                 'clients' => $clients,
  155.                 'page' => $page,
  156.                 'pagi' => $pagination_info,
  157.                 'talent_groups' => $talent_groups_repo->findAll(),
  158.                 'talents' => $talent_repo->findAll(),
  159.             ]);
  160.     }
  161.     public function showExtras(Request $request$paged 0)
  162.     {
  163.         return $this->showClientsByType("","extras"$paged 0);
  164.     }
  165.     public function showClientsByTypeMobile(Request $request$slug$paged 0$group "actors")
  166.     {
  167.         if(isset($request->request->all()['paged'])) $paged $request->request->all()['paged'];
  168.         $clients2 $this->getDoctrine()->getRepository('App\Entity\Clients')->createQueryBuilder('o');
  169.         $clients2->where('o.password IS NOT NULL');
  170.         $clients2->andWhere('o.incompleteProfile = :incompleteProfile');
  171.         $clients2->setParameter('incompleteProfile''false');
  172.         $clients2->andWhere('o.talents like :talent');
  173.         $clients2->setParameter('talent'"%".$slug."%");
  174.         $clients $this->getDoctrine()->getRepository('App\Entity\Clients')->createQueryBuilder('o');
  175.         $clients->where('o.password IS NOT NULL');
  176.         $clients->andWhere('o.incompleteProfile = :incompleteProfile');
  177.         $clients->setParameter('incompleteProfile''false');
  178.         $clients->andWhere('o.talents like :talent');
  179.         $clients->setParameter('talent'"%".$slug."%");
  180.         $clients->orderBy('o.userRegistered''DESC');
  181.         $clients->setFirstResult$paged 30);
  182.         $clients->setMaxResults(30);
  183.         $form_params = [
  184.             'incompleteProfile''ethnicity''age''real_age''display_name''first_name''sir_name',
  185.             'languages''infobox''description_of_client''gender_two''height''accent''real_families',
  186.             'userRegistered''location','talents''area'
  187.             ,
  188.         ];
  189.         foreach($form_params as $param)
  190.         {
  191.             if(
  192.                 (isset( $_REQUEST[$param] ))
  193.                 && (!empty( $_REQUEST[$param] ))
  194.                 && ( == )
  195.                 && ( $_REQUEST[$param] != '-1' )
  196.             ) {
  197.                 $clients->andWhere("o.$param LIKE :$param");
  198.                 $clients->setParameter($param'%'.$_REQUEST[$param].'%');
  199.                 $clients2->andWhere("o.$param LIKE :$param");
  200.                 $clients2->setParameter($param'%'.$_REQUEST[$param].'%');
  201.             }
  202.         }
  203.         $clients $clients->getQuery()->getResult();
  204.         $clients2->orderBy('o.userRegistered''DESC');
  205.         $clients2 $clients2->getQuery()->getResult();
  206.         return
  207.             $this->render('theme::views.mobile.by_type', [
  208.                 'clients' => $clients ,
  209.                 'slug' => $slug,
  210.                 'group' => $group,
  211.                 'paged' => $paged,
  212.                 'last_page' => count($clients2) / 30]
  213.             );
  214.     }
  215.     public function showClientsByGroup(Request $request$talentGroupSlug$page 0) {
  216. //        dump('$talentGroupSlug', $talentGroupSlug);
  217. //        die;
  218.         return $this->showClientsByType($request$talentGroupSlugnull$page);
  219.     }
  220.     public function showClientsByTalent(Request $request$talentGroupSlug$talentSlug$page 0) {
  221. //        dump('$talentSlug', $talentSlug);
  222. //        die;
  223. //        die;
  224.         return $this->showClientsByType($request$talentGroupSlug$talentSlug$page);
  225.     }
  226.     public function showClientsByType(Request $request$talentGroupSlug$talentSlug ""$page 0)
  227.     {
  228. //dump('$_REQUEST', $_REQUEST);
  229. //die;
  230.         $is_search $request->request->all()['search_active'] ?? false;
  231.         if($is_search) {
  232.             $page $request->request->all()['search_page'];
  233.         }
  234. //        die;
  235.         $clients_repo $this->getDoctrine()->getRepository('App\Entity\Clients');
  236.         $talent_groups_repo $this->getDoctrine()->getRepository('App\Entity\TalentGroup');
  237.         $talent_repo $this->getDoctrine()->getRepository('App\Entity\Talent');
  238.         if(isset($request->request->all()['page'])) $page $request->request->all()['page'];
  239.         $clients2 $clients_repo->createQueryBuilder('o');
  240.         $clients2->where('o.password IS NOT NULL');
  241.         $clients2->andWhere('o.incompleteProfile = :incompleteProfile');
  242.         $clients2->setParameter('incompleteProfile''0');
  243.         $clients2->andWhere('o.talents like :talent');
  244.         $clients2->setParameter('talent'"%".$talentGroupSlug."%");
  245.         $clients $clients_repo->createQueryBuilder('o');
  246.         $clients->where('o.password IS NOT NULL');
  247.         $clients->andWhere('o.incompleteProfile = :incompleteProfile');
  248.         $clients->setParameter('incompleteProfile''0');
  249.         if($talentGroupSlug == "extras") {
  250. //            dump("extras where o.talents like %$talentGroupSlug%");
  251.             $clients->andWhere('o.talents like :talent');
  252.             $clients->setParameter('talent'"%".$talentGroupSlug."%");
  253.             $talentSlug $talentGroupSlug;
  254.         } else if($talentGroupSlug == "disabilities") {
  255. //            dump("where o.talents like %$talentSlug%");
  256.             $clients->andWhere('o.talents like :talent');
  257.             $clients->setParameter('talent'"%".$talentGroupSlug."%");
  258.             $talentSlug $talentGroupSlug;
  259.         } else if($talentGroupSlug == "athletes") {
  260. //            dump("where o.talents like %$talentSlug%");
  261.             $clients->andWhere('o.talents like :talent');
  262.             $clients->setParameter('talent'"%".$talentGroupSlug."%");
  263.             $talentSlug $talentGroupSlug;
  264.         } else if($talentGroupSlug == "musicians") {
  265. //            dump("where o.talents like %$talentSlug%");
  266.             $clients->andWhere('o.talents like :talent');
  267.             $clients->setParameter('talent'"%".$talentGroupSlug."%");
  268.             $talentSlug $talentGroupSlug;
  269.         } else if($talentGroupSlug == "speciality") {
  270. //            dump("where o.talents like %$talentSlug%");
  271.             $clients->andWhere('o.talents like :talent');
  272.             $clients->setParameter('talent'"%".$talentGroupSlug."%");
  273.             $talentSlug $talentGroupSlug;
  274.         } else {
  275.             if(empty($talentSlug)) {
  276.                 $clients->andWhere('o.talents like :talent');
  277.                 $clients->setParameter('talent'"%".$talentGroupSlug."%");
  278.                 $talentSlug $talentGroupSlug;
  279.             } else {
  280.                 if ($talentGroupSlug === "dancers" && $talentSlug === "theatrical")
  281.                 {
  282.                     $talentx "theatre";
  283.                     //theater,
  284.                     $clients->andWhere('o.talents LIKE :talents1');
  285.                     $clients->setParameter('talents1'"$talentx,%");
  286.                     //.+ ,theater$
  287.                     $clients->orWhere('o.talents LIKE :talents2');
  288.                     $clients->setParameter('talents2'"%,$talentx");
  289.                     //,theater,
  290.                     $clients->orWhere('o.talents LIKE :talents3');
  291.                     $clients->setParameter('talents3'"%,$talentx,%");
  292.                     //theater
  293.                     $clients->orWhere('o.talents = :talents4');
  294.                     $clients->setParameter('talents4'"$talentx");
  295.                 } else {
  296.                     $clients->andWhere('o.talents like :talent');
  297.                     $clients->setParameter('talent'"%".$talentSlug."%");
  298.                 }
  299. //
  300.             }
  301.         }
  302. //        dump('$talentSlug', $talentSlug);
  303. //        dump('$talentGroupSlug', $talentGroupSlug);
  304. //        die;
  305.         $form_params = [
  306.             'ethnicity''age''real_age''displayName''first_name''sir_name''genderTwo',
  307.             'location''languages''infobox''descriptionOfClient',  'height''accent''real_families',
  308.             'userRegistered''location''area''is_beautiful''has_spotlight'
  309.         ];
  310.         foreach($form_params as $param)
  311.         {
  312.             if(
  313.                 (isset( $_REQUEST[$param] ))
  314.                 && (!empty( $_REQUEST[$param] ))
  315.                 && ( == )
  316.                 && ( $_REQUEST[$param] != '-1' )
  317.             ) {
  318.                 $clients->andWhere("o.$param LIKE :$param");
  319.                 $clients->setParameter($param'%'.$_REQUEST[$param].'%');
  320.                 $clients2->andWhere("o.$param LIKE :$param");
  321.                 $clients2->setParameter($param'%'.$_REQUEST[$param].'%');
  322.             }
  323.         }
  324.         $limit 18;
  325. //        $page = (int) $page;
  326. //        if(!is_int($page)) {
  327. //            $page = 1;
  328. //        }
  329.         $offset $page $limit;
  330.         $clients->orderBy('o.id''DESC');
  331.         $clients->setFirstResult$offset );
  332.         $clients->setMaxResults($limit);
  333.         $q $clients->getQuery();
  334.         $clients $q->getResult();
  335.         $paginator = new Paginator($q);
  336.         $path = ($talentSlug) ? "talents/".$talentGroupSlug."/".$talentSlug "talent-directory/".$talentGroupSlug;
  337.         $count $paginator->count();
  338.         $pagination_info = array(
  339.             'total' => (int) $count,
  340.             'current' => (int) $page,
  341.             'pages' => (int) ceil($count $limit),
  342.             'path' =>  $path
  343.         );
  344.         if($talentSlug) {
  345.             $talent =  $talent_repo->findOneBy(['slug' => $talentSlug]);
  346.         } else {
  347.             $talent false;
  348.         }
  349.         $count count($clients2->getQuery()->getResult());
  350.         $last_page $clients2->getQuery()->getResult();
  351.         $settings $this->getDoctrine()->getRepository('App\Entity\SiteSetting')->findAll();
  352.         if(!$settings) {
  353.             die;
  354.         }
  355.         $settings $settings[0];
  356.         $data_for_view = [
  357.             'settings' => $settings,
  358.             'by_type' => true,
  359.             'is_search' => $request->request->all()['search_active'] ?? false,
  360.             'pagi' => $pagination_info,
  361.             'paginator' => $paginator->count(),
  362.             'group' => $talent_groups_repo->findOneBy(['slug' => $talentGroupSlug]),
  363.             'talent_groups' => $talent_groups_repo->findAll(),
  364.             'talent' => $talent,
  365.             'slug' => $talentSlug,
  366.             'slug_group' => $talentGroupSlug,
  367.             'clients' => $clients ,
  368.             'page' => $page,
  369.             'last_page' => $count 30,
  370.             'talents' => $talent_repo->findAll(),
  371.         ];
  372.         return
  373.             $this->render('new/clients.html.twig'$data_for_view);
  374.     }
  375.     public function showKeywordPage(Request $request$keyword_slug$paged 0)
  376.     {
  377.         $keyword_pages_repo $this->getDoctrine()->getRepository('App\Entity\KeywordPage');
  378.         /** @var KeywordPage $page */
  379.         $page $keyword_pages_repo->findOneBy(['slug'=>$keyword_slug]);
  380.         $page_talents $page->getTalents();
  381.         $talentSlug $page->getTalents()[0]->getSlug();
  382.         $talentGroupSlug $page->getTalentGroups()[0]->getSlug();
  383. //        $talentGroupSlug = $page->
  384.         $clients_repo $this->getDoctrine()->getRepository('App\Entity\Clients');
  385.         $talent_groups_repo $this->getDoctrine()->getRepository('App\Entity\TalentGroup');
  386.         $talent_repo $this->getDoctrine()->getRepository('App\Entity\Talent');
  387.         $clients2 $clients_repo->createQueryBuilder('o');
  388.         $clients2->where('o.password IS NOT NULL');
  389.         $clients2->andWhere('o.incompleteProfile = :incompleteProfile');
  390.         $clients2->setParameter('incompleteProfile''false');
  391.         $clients2->andWhere('o.talents like :talent');
  392.         $clients2->setParameter('talent'"%".$talentGroupSlug."%");
  393.         $clients $clients_repo->createQueryBuilder('o');
  394.         $clients->where('o.password IS NOT NULL');
  395.         $clients->andWhere('o.incompleteProfile = :incompleteProfile');
  396.         $clients->setParameter('incompleteProfile''false');
  397.         if($talentSlug != "") {
  398.             $clients->andWhere('o.talents like :talent');
  399.             $clients->setParameter('talent'"%".$talentSlug."%");
  400.         } else {
  401.             $clients->andWhere('o.talents like :talent');
  402.             $clients->setParameter('talent'"%".$talentGroupSlug."%");
  403.         }
  404.         $form_params = [
  405.             'ethnicity''age''real_age''display_name''first_name''sir_name''gender_two',
  406.             'location''languages''infobox''description_of_client',  'height''accent''real_families',
  407.             'userRegistered''location''area''is_beautiful''has_spotlight'
  408.         ];
  409.         foreach($form_params as $param)
  410.         {
  411.             if(
  412.                 (isset( $_REQUEST[$param] ))
  413.                 && (!empty( $_REQUEST[$param] ))
  414.                 && ( == )
  415.                 && ( $_REQUEST[$param] != '-1' )
  416.             ) {
  417.                 $clients->andWhere("o.$param LIKE :$param");
  418.                 $clients->setParameter($param'%'.$_REQUEST[$param].'%');
  419.                 $clients2->andWhere("o.$param LIKE :$param");
  420.                 $clients2->setParameter($param'%'.$_REQUEST[$param].'%');
  421.             }
  422.         }
  423.         $clients->orderBy('o.userRegistered''DESC');
  424.         $clients->setFirstResult$paged 50 );
  425.         $clients->setMaxResults(50);
  426.         $clients $clients->getQuery()->getResult();
  427.         if($talentSlug) {
  428.             $talent =  $talent_repo->findOneBy(['slug' => $talentSlug]);
  429.         } else {
  430.             $talent false;
  431.         }
  432. //
  433.         $count count($clients2->getQuery()->getResult());
  434.         $last_page $clients2->getQuery()->getResult();
  435.         $settings $this->getDoctrine()->getRepository('App\Entity\SiteSetting')->findAll()[0];
  436.         $data_for_view = [
  437.             'settings' => $settings,
  438.             'keyword_page' => $page,
  439.             'by_type' => true,
  440.             'group' => $talent_groups_repo->findOneBy(['slug' => $talentGroupSlug]),
  441.             'talent' => $talent,
  442.             'slug' => $talentSlug,
  443.             'clients' => $clients ,
  444.             'paged' => $paged,
  445.             'last_page' => $count 30,
  446.         ];
  447. //        dump('$data_for_view', $data_for_view);
  448. //        dump('$talentSlug', $talentSlug);
  449. //        die;
  450.         return
  451.             $this->render('new/clients.html.twig'$data_for_view);
  452.         return
  453.             $this->render('theme::views.original.by_type', [
  454.                     'clients' => $clients ,
  455.                     'group' => $group,
  456.                     'slug' => $talentGroupSlug,
  457.                     'paged' => $paged,
  458.                     'last_page' => count($last_page) / 30
  459.                 ]
  460.             );
  461. //                ->withInput($request->request->all());
  462.     }
  463.     public function showMobileJobs(Request $request$paged 0)
  464.     {
  465.         $jobs $this->getDoctrine()->getRepository('App\Entity\Jobs')->createQueryBuilder('o');
  466.         $jobs->where('o.statuz = :statuz');
  467.         $jobs->setParameter('statuz''publish');
  468.         $jobs->orderBy('o.id''DESC');
  469. //        $jobs->setFirstResult( $paged * 30 );
  470. //        $jobs->setMaxResults(50);
  471.         $jobs $jobs->getQuery()->getResult();
  472.         return $this->render('theme::views.mobile.jobs', ['jobs' =>$jobs ]);
  473.     }
  474.     public function getLightboxSingle(Request $request$id)
  475.     {
  476.         $clients $this->getDoctrine()->getRepository('App\Entity\Clients')->find($id);
  477.         return new JsonResponse([
  478.             'html' => $this->get('twig')->render('new/partials/client_lightbox.html.twig', ['client' => $clients])
  479.         ]);
  480.     }
  481.     public function getLightboxClientsPreview(Request $request)
  482.     {
  483.         $ids array_values(json_decode($request->request->get("clients"), false) ?? []);
  484.         $ret $this->get_lbox_clients($ids'new/partials/client_lightbox_preview.html.twig');
  485.         return new JsonResponse([
  486.             'html' => $ret
  487.         ]);
  488.     }
  489.     public function getLightboxClients(Request $request)
  490.     {
  491.         $ids array_values($request->request->get("clients") ?? []);
  492.         $ret $this->get_lbox_clients($ids);
  493.         return new JsonResponse([
  494.             'html' => $ret
  495.                 ]);
  496.     }
  497.     public function sendGetLigthboxClients(Request $request)
  498.     {
  499.         $ids array_values(json_decode($request->request->get("clients"), false) ?? []);
  500.         $lightbox_html $this->get_lbox_clients($ids);
  501.     }
  502.     private function get_lbox_clients($ids$template 'new/partials/client_lightbox_new.html.twig')
  503.     {
  504.         $ret "";
  505.         if(!empty($ids)) {
  506.             $clients $this->getDoctrine()->getRepository('App\Entity\Clients')
  507.                 ->findBy(['id' => $ids]);
  508.             foreach($clients as $client) {
  509.                 $ret .= $this->get('twig')->render($template, ['client' => $client]);
  510.             }
  511.         }
  512.         return $ret;
  513.     }
  514.     public function showJobCallSelection($lightbox_id 0LightboxRepository $lrepoJobCallStageRepository $jobCallStageRepository) {
  515.         $lightbox $lrepo->findOneBy(['unique_id' => $lightbox_id]);
  516.         $jobCallStage $jobCallStageRepository->findOneBy(['lightbox' => $lightbox->getId()]);
  517.         $clients $lightbox->getClients();
  518.         $priorities json_decode($lightbox->getPriorities(), true);
  519.         if(!empty($priorities)) {
  520.             $newClientIds = [];
  521.             $newClients = [];
  522.             $prioClients = [];
  523.             $nonPrioClients = [];
  524.             foreach($clients as $client) {
  525.                 $prioFound false;
  526.                 foreach($priorities as $priority_set) {
  527.                     if($client->getId() == $priority_set['clientId']) {
  528.                         //                    dump("got prio to set");
  529.                         $client->priority $priority_set['priority'];
  530.                         $prioFound true;
  531.                         break;
  532.                     }
  533.                 }
  534.                 if($prioFound == true) {
  535.                     $prioClients[] = $client;
  536.                 } else {
  537.                     $nonPrioClients[] = $client;
  538.                 }
  539.                 $newClients[] = $client;
  540.             }
  541.             $clients $newClients;
  542.             usort($prioClients, function($a$b)
  543.             {
  544.                 return intval($a->priority) > intval($b->priority);
  545.             });
  546.             usort($nonPrioClients, function($a$b)
  547.             {
  548.                 return intval($a->getId()) > intval($b->getId());
  549.             });
  550.             $clients array_merge($prioClients$nonPrioClients);
  551.         }  else {
  552.             $newClients = [];
  553.             foreach ($clients as $client) {
  554.                 $newClients[] = $client;
  555.             }
  556.             $clients $newClients;
  557.             usort($clients, function($a$b)
  558.             {
  559.                 return intval($a->getId()) < intval($b->getId());
  560.             });
  561.         }
  562.         if($jobCallStage) {
  563.             $jobCall $jobCallStage->getJobCall();
  564.             return $this->render('new/lightbox_job_call.html.twig', [
  565.                 'lightbox' => $lightbox,
  566.                 'job_call' => $jobCall,
  567.                 'clients_sorted' => $clients,
  568.                 'job_call_stage' => $jobCallStage->toJson()
  569.             ]);
  570.         } else {
  571.             return $this->render('new/lightbox_new.html.twig', [
  572.                 'lightbox' => $lightbox,
  573.             ]);
  574.         }
  575.     }
  576.     public function showClientsSelection($lightbox_id 0LightboxRepository $lrepoJobCallStageRepository $jobCallStageRepository)
  577.     {
  578.         $lightbox $lrepo->findOneBy(['unique_id' => $lightbox_id]);
  579.         $clients $lightbox->getClients();
  580.         $priorities json_decode($lightbox->getPriorities(), true);
  581.         if(!empty($priorities)) {
  582.             $newClientIds = [];
  583.             $newClients = [];
  584.             $prioClients = [];
  585.             $nonPrioClients = [];
  586.             foreach($clients as $client) {
  587.                 $prioFound false;
  588.                 foreach($priorities as $priority_set) {
  589.                     if($client->getId() == $priority_set['clientId']) {
  590.     //                    dump("got prio to set");
  591.                         $client->priority $priority_set['priority'];
  592.                         $prioFound true;
  593.                         break;
  594.                     }
  595.                 }
  596.                 if($prioFound == true) {
  597.                     $prioClients[] = $client;
  598.                 } else {
  599.                     $nonPrioClients[] = $client;
  600.                 }
  601.                 $newClients[] = $client;
  602.             }
  603.             $clients $newClients;
  604.             usort($prioClients, function($a$b)
  605.             {
  606.                 return intval($a->priority) > intval($b->priority);
  607.             });
  608.             usort($nonPrioClients, function($a$b)
  609.             {
  610.                     return intval($a->getId()) < intval($b->getId());
  611.             });
  612.             $clients array_merge($prioClients$nonPrioClients);
  613.         }  else {
  614.             $newClients = [];
  615.             foreach ($clients as $client) {
  616.                 $newClients[] = $client;
  617.             }
  618.             $clients $newClients;
  619.             usort($clients, function($a$b)
  620.             {
  621.                 return intval($a->getId()) < intval($b->getId());
  622.             });
  623.         }
  624.         return $this->render('new/lightbox_clients.html.twig', [
  625.             'lightbox' => $lightbox,
  626.             'clients_sorted' => $clients
  627.         ]);
  628.     }
  629.     public function showEnquiryLightboxByUniqueId($lightbox_id 0LightboxRepository $lrepo) {
  630.         $lightbox $lrepo->findOneBy(['unique_id' => $lightbox_id]);
  631.         return $this->render('new/lightbox_enquire.html.twig', ['lightbox' => $lightbox]);
  632.     }
  633.     public function showLightbox(Request $request$paged 0) {
  634.         return $this->render('new/lightbox.html.twig', ['settings' => $this->getSettings()]);
  635.     }
  636.     public function showLightboxEnquiry(Request $request$paged 0) {
  637.         return $this->render('new/lightbox_enquire.html.twig', ['settings' => $this->getSettings()]);
  638.     }
  639.     public function showTermsAndConditions(Request $request) {
  640.         return $this->render('new/terms_and_conditions.html.twig', ['settings' => $this->getSettings()]);
  641.     }
  642.     public function showPrivacyPolicy(Request $request) {
  643.         return $this->render('new/privacy_policy.html.twig', ['settings' => $this->getSettings()]);
  644.     }
  645.     public function showProjects(Request $requestImageService $is$paged 0) {
  646.         $images $this->getDoctrine()->getRepository('App\Entity\ProjectImage')->findAll();
  647.         foreach($images as $image) {
  648. //            dump('$image', $image->getImage());
  649.             $is->resize_to_fit("/usr/share/nginx/fusion/public/images/theme_images/".$image->getImage());
  650.         }
  651.         return $this->render('new/projects.html.twig', [
  652.             'settings' => $this->getSettings(),
  653.             'project_videos' => $this->getDoctrine()->getRepository('App\Entity\ProjectVideo')->findAll(),
  654.             'project_images' => $images,
  655.             'talent_groups' => $this->getDoctrine()->getRepository('App\Entity\TalentGroup')->findAll(),
  656.         ]);
  657.     }
  658.     public function showJobs(Request $request$paged 0)
  659.     {
  660.         $jobs $this->getDoctrine()->getRepository('App\Entity\Jobs')->createQueryBuilder('o');
  661.         $jobs->where('o.statuz = :statuz');
  662.         $jobs->setParameter('statuz''publish');
  663.         $jobs->orderBy('o.id''DESC');
  664. //        $jobs->setFirstResult( $paged * 30 );
  665. //        $jobs->setMaxResults(100);
  666.         $jobs $jobs->getQuery()->getResult();
  667. //        dump(count($jobs));
  668. //        die;
  669.         $return  = array();
  670.         foreach($jobs as $job) {
  671.             if ($job->isExpired() == 1) continue;
  672.             $return[] = $job;
  673.         }
  674. //        dump('$return', $return);
  675. //        die;
  676.         return $this->render('new/jobs.html.twig', ['jobs' =>$return,
  677.             'settings' => $this->getSettings()
  678.             ]);
  679.     }
  680.     public function showClient(Request $request$userNicename)
  681.     {
  682.         if($this->getUser() && $this->getUser()->getIsAdmin()) {
  683. //        die('fss2');
  684.         }
  685.         /** @var Clients $client */
  686.         $client $this->getDoctrine()->getRepository('App\Entity\Clients')
  687.             ->findOneBy(array('userNicename' => $userNicename),
  688.                 array('id' => 'DESC')
  689.             );
  690.         $credits $this->getDoctrine()->getRepository('App\Entity\Credits')
  691.             ->findBy(array('userId' => $client->getId()));
  692.         $trainings $this->getDoctrine()->getRepository('App\Entity\Trainings')
  693.             ->findBy(array('id' => $client->getTrainings()));
  694.         $talent_groups $this->getDoctrine()->getRepository('App\Entity\TalentGroup')->findAll();
  695.         if($client->getIsArchived() == true) {
  696.             if ($_SERVER['REMOTE_ADDR']=='90.248.44.247') {
  697.                 echo $client->getId();
  698.                 die("ffff");
  699.             }
  700.             return $this->redirect("https://fusionmng.com"301);
  701.         }
  702.         $response =
  703.             $this->render('/new/client_public.html.twig', ['talent_groups' => $talent_groups'client' => $client'credits' => $credits'trainings' => $trainings'settings' => $this->getSettings()] );
  704.         $response->headers->addCacheControlDirective('no-cache'true);
  705.         $response->headers->addCacheControlDirective('must-revalidate'true);
  706.         return $response;
  707.     }
  708.     public function showClientMobile(Request $request$userNicename)
  709.     {
  710.         $client $this->getDoctrine()->getRepository('App\Entity\Clients')
  711.             ->findOneBy(array('userNicename' => $userNicename));
  712.         return
  713.             $this->render('theme::views.mobile.profile', ['client' => $client ]);
  714.     }
  715.     public function showForgot(Request $request)
  716.     {
  717.         return $this->render('new/forgot-password.html.twig',[
  718.             'settings' => $this->getSettings()
  719.         ]);
  720.     }
  721.     public function showMobileForgot(Request $request){
  722.         return $this->render('theme::views.mobile.forgot-password');
  723.     }
  724.     public function showReset(Request $request$rememberToken)
  725.     {
  726.         $client $this->getDoctrine()->getRepository('App\Entity\Clients')->findOneByRememberToken($rememberToken);
  727.         $session $this->get('session');
  728. //        $session->getFlashBag()->set('success_reset', true);
  729. //        dump($session->get("success_reset"));
  730. //        die;
  731.         return $this->render('new/forgot-password-reset.html.twig', ['user' => $client'settings' => $this->getSettings()]);
  732.     }
  733.     public function doReset(Request $requestUserPasswordEncoderInterface $enc)
  734.     {
  735.         $client $this->getDoctrine()->getRepository('App\Entity\Clients')->findOneById($request->request->all()['user']);
  736.         $new_pass $request->request->all()['password'];
  737.         $new_pass_confirm $request->request->all()['password_confirm'];
  738.         if($new_pass !== $new_pass_confirm) die('Bad password');
  739.         $encoded $enc->encodePassword($client$new_pass);
  740.         $client->setPassword($encoded);
  741.         $this->getDoctrine()->getManager()->persist($client);
  742.         $this->getDoctrine()->getManager()->flush();
  743.         $session $this->get('session');
  744. $session->getFlashBag()->set('success_reset'true);
  745.         return $this->render('new/forgot-password-reset.html.twig', ['user' => $client->getId(), 'settings' => $this->getSettings()]);
  746.     }
  747.     public function doForgot(Request $request)
  748.     {
  749.         $client $this->getDoctrine()->getRepository('App\Entity\Clients')->findOneByEmail($request->request->all()['email']);
  750.         $token uniqid();
  751.         $client->setRememberToken($token);
  752. //        $new_pass = str_random(12);
  753. //        $client->setPassword($new_pass);
  754.         $this->getDoctrine()->getManager()->persist($client);
  755.         $this->getDoctrine()->getManager()->flush();
  756. //        dd($client);
  757. //        dd($client->getRememberToken());
  758. //        die;
  759.         if(!is_null($client))
  760.         {
  761.             $url $this->getParameter('url');
  762.            $this->get("ses_mailer")->mailForgot(
  763.                 $client->getId() ,
  764.                 [
  765.                     'from'=>'admin@fusionmng.com',
  766.                     'subject' => 'Password reset instructions',
  767.                     'body' => "<a href='$url/password-reset/{$client->getRememberToken()}'>Click here</a> to change your password.<br/>You can as well visit link below:<br/>$url/password-reset/{$client->getRememberToken()}",
  768.                 ]);
  769.         } else {
  770.             die("Email incorrect, please double check it");
  771.         }
  772.         /** @var Session $session */
  773.         $session $this->get('session');
  774.         $session->getFlashBag()->set('success'true);
  775. //        $session = $this->get('session');
  776. $session->getFlashBag()->set('success'true);
  777.         return $this->redirect($request->server->get("HTTP_REFERER"));
  778.     }
  779.     public function showLogin(Request $request)
  780.     {
  781.         return $this->render('new/login.html.twig', ['settings' => $this->getSettings()]);
  782.     }
  783.     public function doLogout(Request $request){
  784.         \Auth::logout();
  785.         return $this->render('theme::views.original.login');
  786.     }
  787.     /** todo: remove or refactor */
  788.     public function doLogin(Request $request)
  789.     {
  790.         dump('$request'$request);
  791.         die;
  792. // validate the info, create rules for the inputs
  793.         $rules = array(
  794.             //'email'    => 'required|email', // make sure the email is an actual email
  795.             'password' => 'required|min:3' // password can only be alphanumeric and has to be greater than 3 characters
  796.         );
  797. // run the validation rules on the inputs from the form
  798.         $validator = \Validator::make($request->request->all(), $rules);
  799. // if the validator fails, redirect back to the form
  800.         if ($validator->fails()) {
  801.            // dd("Due to website version switch we require that you reset");
  802.             return \Redirect::to('https://fusionmng.com/login')
  803.                 ->withErrors($validator// send back all errors to the login form
  804.                 ->withInput($request->request->except('password')); // send back the input (not the password) so that we can repopulate the form
  805.         } else {
  806.             $userdata = array(
  807.                 'email'     => trim($request->request->get('email')),
  808.                 'password'  => trim($request->request->get('password'))
  809.             );
  810.             if (\Auth::attempt($userdata)) {
  811.                 return \Redirect::intended('profile');
  812.             } else {
  813.                 return \Redirect::to('https://fusionmng.com/login');
  814.             }
  815.         }
  816.     }
  817.     public function updateSelectedClientsPriorities(Request $request)
  818.     {
  819.         $selectionName null;
  820.         $clientName null;
  821.         $clientToAdd null;
  822.         $clientImage null;
  823.         $priority null;
  824.         $clients_to_update null;
  825.         $redis = new \Redis();
  826.         $redis->connect('localhost');
  827.         $redis->auth("vanXGmC9kHuLRaSfn2QmtG8Pgxc7N7BPnLKam2hdM");
  828.         $clients_to_update json_decode($request->request->all()['clients'], true);
  829.         if(isset($_REQUEST['selection_name'])) {
  830.             $selectionName $_REQUEST['selection_name'];
  831.         } else if($clients_to_update && count($clients_to_update) > && isset($clients_to_update[0]['user_id'])) {
  832.             $selectionName $clients_to_update[0]['user_id'];
  833.         }
  834.         $clients_selection unserialize($redis->get($selectionName));
  835.         $updated_selection = [];
  836.         foreach($clients_to_update as $client_to_update) {
  837.             unset($client_to_update['user_id']);
  838.             $updated_selection[] = $client_to_update;
  839.         }
  840.         $redis->set($selectionNameserialize($updated_selection));
  841.         return new JsonResponse([
  842.             'updated' => $updated_selection,
  843.             'original' => $clients_selection
  844.         ]);
  845.     }
  846.     public function selectedClient(Request $request)
  847.     {
  848.         $selectionName null;
  849.         $clientName null;
  850.         $clientToAdd null;
  851.         $clientImage null;
  852.         $priority null;
  853.         if(isset($_REQUEST['selection_name'])) {
  854.             $selectionName $_REQUEST['selection_name'];
  855.         } else  if(isset($_REQUEST['user_id'])) {
  856.             $selectionName $_REQUEST['user_id'];
  857.         }
  858.         if(isset($_REQUEST['clientName'])) {
  859.             $clientName $_REQUEST['clientName'];
  860.         } else {
  861.             $clientName 'noClientName';
  862.         }
  863.         if(isset($_REQUEST['priority'])) {
  864.             $priority $_REQUEST['priority'];
  865.         } else {
  866.             $priority 0;
  867.         }
  868.         if(isset($_REQUEST['client_image'])) {
  869.             $client_image $_REQUEST['client_image'];
  870.         } else {
  871.             $client_image "noimg";
  872.         }
  873.         $redis = new \Redis();
  874.         $redis->connect('localhost');
  875.         $redis->auth("vanXGmC9kHuLRaSfn2QmtG8Pgxc7N7BPnLKam2hdM");
  876.         $arr unserialize($redis->get($selectionName));
  877.         if(!is_array($arr)) {
  878.             $arr = [];
  879.         }
  880.         $respo '';
  881.         if(isset($_REQUEST['clientId'])) {
  882.             $clientToAdd $_REQUEST['clientId'];
  883.             $newArr = [];
  884.             $clientFound false;
  885.             foreach ($arr as $client ) {
  886.                 if($client['clientId'] != $clientToAdd) {
  887.                     $newArr[] = $client;
  888.                 } else {
  889.                     $clientFound true;
  890.                     $newArr[] = [
  891.                         'clientId' => $clientToAdd,
  892.                         'clientName' => $clientName,
  893.                         'priority' => $priority,
  894.                         'client_image' => $client_image
  895.                     ];
  896.                 }
  897.             }
  898.             if($clientFound == false) {
  899.                 $newArr[] = [
  900.                     'clientId' => $clientToAdd,
  901.                     'clientName' => $clientName,
  902.                     'priority' => $priority,
  903.                     'client_image' => $client_image
  904.                 ];
  905.             }
  906.             $respo $newArr;
  907.             $arr $newArr;
  908.         } else if(isset($_REQUEST['client_to_remove'])) {
  909.             //remove from array
  910.             $newArr = [];
  911.             foreach ($arr as $client ) {
  912.                 if($client['clientId'] !== $_REQUEST['client_to_remove']){
  913.                     $newArr[] = $client;
  914.                 }
  915.             }
  916.             $respo $newArr;
  917.             $arr $newArr;
  918.         } else if(isset($_REQUEST['ClearSelection'])) {
  919.             //clear array
  920.             $arr = [];
  921.         }
  922.         $redis->set($selectionNameserialize($arr));
  923.         return new JsonResponse($respo);
  924.     }
  925.     public function getSelectedClients(Request $request)
  926.     {
  927.         $selectionName null;
  928.         $clientName null;
  929.         $clientToAdd null;
  930.         if(isset($_REQUEST['user_id'])) {
  931.             $selectionName $_REQUEST['user_id'];
  932.         }
  933.         $redis = new \Redis();
  934.         $redis->connect('localhost');
  935.         $redis->auth("vanXGmC9kHuLRaSfn2QmtG8Pgxc7N7BPnLKam2hdM");
  936.         $arr unserialize($redis->get($selectionName));
  937.         if(!is_array($arr)) {
  938.             $arr = [];
  939.         }
  940. //        return $arr;
  941.         usort($arr, function ($a$b) {
  942.             if (intval($a['priority']) == intval($b['priority'])) return 0;
  943.             return (intval($a['priority']) > intval($b['priority'])) ? -1;
  944.         });
  945.         return new JsonResponse($arr);
  946.     }
  947.     public function showAboutUs(Request $request)
  948.     {
  949.         return $this->render('new/about_us.html.twig', ['settings' => $this->getSettings()]);
  950.     }
  951.     
  952.     public function showSitemap(Request $request)
  953.     {
  954.         if ($_SERVER['REMOTE_ADDR']=='79.118.101.15.5') {
  955.             $look_in='/usr/share/nginx/fusion';
  956.             $allowed_files=array('twig');
  957.             $search_for='the work we get our actors';
  958.             function search_in_files ($search_for$look_in$allowed_files) {
  959.                 $files=scandir($look_in);
  960.                 foreach ($files as $key => $value) {
  961.                     if (is_dir($look_in.'/'.$value) && !in_array(substr($value01), array('.'))) {
  962.                         search_in_files($search_for$look_in.'/'.$value$allowed_files);
  963.                     } elseif (is_file($look_in.'/'.$value) && in_array(substr($valuestrlen($value)-4), $allowed_files)) {
  964.                         $fc=file_get_contents($look_in.'/'.$value);
  965.                         if (strpos($fc$search_for)!==false) {
  966.                             echo $look_in.'/'.$value."<br>";
  967.                         }
  968.                     }
  969.                 }
  970.             }
  971.             search_in_files($search_for$look_in$allowed_files);
  972.             die("done");
  973.         }
  974.         return $this->render('new/sitemap.html.twig', ['settings' => $this->getSettings()]);
  975.     }
  976.     public function showHireTalents(Request $request)
  977.     {
  978.         return $this->render('new/hire_talents.html.twig', ['settings' => $this->getSettings()]);
  979.     }
  980.     public function showAgencyApplication(Request $request)
  981.     {
  982.         $session $this->get('session');
  983.             $suc false;
  984.             $success $session->getFlashBag()->get('success_application');
  985.             if(empty($success)) {
  986.                 $suc false;
  987.             } else {
  988.                 $suc true;
  989.             }
  990.         return $this->render('new/application.html.twig', ['settings' => $this->getSettings(), 'success' => $suc]);
  991.     }
  992.     public function showSubmitJob(Request $request)
  993.     {
  994.         if($this->getUser() && $this->getUser()->getIsAdmin()) {
  995.             return $this->render('new/submit-job.html.twig', ['settings' => $this->getSettings()]);
  996.         } else {
  997.             return $this->render('new/submit-job-non-admin.html.twig', ['settings' => $this->getSettings()]);
  998.         }
  999.     }
  1000.     public function showContact(Request $request)
  1001.     {
  1002.         return $this->render('new/contact.html.twig', ['settings' => $this->getSettings()]);
  1003.     }
  1004.     public function doContact(Request $request)
  1005.     {
  1006.         $mail $this->get('ses_mailer')->mailContactForm($request$this->get('twig'));
  1007.         return $this->render('new/contact.html.twig',['success'=>true,'settings' => $this->getSettings()]);
  1008.     }
  1009. }