<?php namespace App\Controller;
use App\Entity\Clients;
use App\Entity\KeywordPage;
use App\Entity\TalentGroup;
use App\Repository\JobCallRepository;
use App\Repository\JobCallStageRepository;
use App\Repository\LightboxRepository;
use App\Services\ImageService;
use App\Services\MailerService;
use Doctrine\ORM\Tools\Pagination\Paginator;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
class HomeController extends BaseController {
// /**
// * @var MailerService
// */
// private $sesmail;
//
// public function __construct(MailerService $ms)
// {
// $this->sesmail = null;//$ms;
// }
/*
|--------------------------------------------------------------------------
| Default Home Controller
|--------------------------------------------------------------------------
|
| You may wish to use controllers instead of, or in addition to, Closure
| based routes. That's great! Here is an example controller method to
| get you started. To route to this controller, just add the route:
|
| Route::get('/', 'HomeController@showWelcome');
|
*/
public function showMobileClients(Request $request, $paged = 0){
// var_dump($paged);
if(isset($request->request->all()['paged'])) $paged = $request->request->all()['paged'];
$clients = $this->getDoctrine()->getRepository('App\Entity\Clients')->createQueryBuilder('o');
$clients2 = $this->getDoctrine()->getRepository('App\Entity\Clients')->createQueryBuilder('o');
$clients2->where('o.password IS NOT NULL');
// dd($clients2);
$clients->where('o.password IS NOT NULL');
$clients->andWhere('o.incompleteProfile = :incompleteProfile');
$clients->setParameter('incompleteProfile', 'false');
$clients->setFirstResult( $paged * 30);
$clients->setMaxResults(30);
$form_params = [
'incompleteProfile', 'ethnicity', 'age', 'real_age', 'display_name', 'first_name', 'sir_name',
'languages', 'infobox', 'description_of_client', 'gender_two', 'height', 'accent', 'real_families',
'userRegistered', 'location','talents', 'area'
,
];
foreach($form_params as $param)
{
if(
(isset( $_REQUEST[$param] ))
&& (!empty( $_REQUEST[$param] ))
&& ( 1 == 1 )
&& ( $_REQUEST[$param] != '-1' )
) {
$clients->andWhere("o.$param LIKE :$param");
$clients->setParameter($param, '%'.$_REQUEST[$param].'%');
$clients2->andWhere("o.$param LIKE :$param");
$clients2->setParameter($param, '%'.$_REQUEST[$param].'%');
}
}
$clients = $clients->getQuery()->getResult();
$clients2->andWhere('o.incompleteProfile = :incompleteProfile');
$clients2->setParameter('incompleteProfile', 'false');
$clients2->orderBy('o.userRegistered', 'DESC');
$clients2 = $clients2->getQuery()->getResult();
// dd(count($clients2) / 30);
return $this->render('theme::views.mobile.all_clients', [
'clients' =>$clients,
'paged' => $paged,
'dataAjaxFalse' => 'data-ajax="false"' ,
'last_page' => count($clients2) / 30,
]);
return "ddd";
$this->showClients($paged, true);
}
public function showClients(Request $request, $page = 0, $isMobileView = false)
{
// dump($request->request->all()['search_page_num'] ?? "no");
// die;
if(isset($request->request->all()['paged'])) $paged = $request->request->all()['paged'];
$clients = $this->getDoctrine()->getRepository('App\Entity\Clients')->createQueryBuilder('o');
$clients2 = $this->getDoctrine()->getRepository('App\Entity\Clients')->createQueryBuilder('o');
// dd($clients2);
$clients->where('o.password IS NOT NULL');
$clients->andWhere('o.incompleteProfile = :incompleteProfile');
$clients->setParameter('incompleteProfile', 'false');
$clients->orderBy('o.userRegistered', 'DESC');
$clients2->where('o.password IS NOT NULL');
$clients2->andWhere('o.incompleteProfile = :incompleteProfile');
$clients2->setParameter('incompleteProfile', 'false');
$form_params = [
'incompleteProfile', 'ethnicity', 'age', 'real_age', 'display_name', 'first_name', 'sir_name',
'languages', 'infobox', 'description_of_client', 'gender_two', 'height', 'accent', 'real_families',
'userRegistered', 'location', 'area', 'is_beautiful', 'has_spotlight'
,
];
// $jobs = $this->getDoctrine()->getRepository('App\Entity\Jobs');
// $jobs->findAll()
foreach($form_params as $param)
{
if(
(isset( $_REQUEST[$param] ))
&& (!empty( $_REQUEST[$param] ))
&& ( 1 == 1 )
&& ( $_REQUEST[$param] != '-1' )
) {
$clients->andWhere("o.$param LIKE :$param");
$clients->setParameter($param, '%'.$_REQUEST[$param].'%');
$clients2->andWhere("o.$param LIKE :$param");
$clients2->setParameter($param, '%'.$_REQUEST[$param].'%');
}
}
$limit = 18;
$offset = $page * $limit;
//dump('$_REQUEST', $_REQUEST);
//die;
if( isset($request->request->all()['paged']) )
{
$paged = $request->request->all()['paged'];
}
$clients->setFirstResult($offset);
//$clients->setFirstResult( $paged );
$clients->setMaxResults($limit);
$q = $clients->getQuery();
$clients = $q->getResult();
$count = count($clients2->getQuery()->getResult());
$paginator = new Paginator($q);
$talent_groups = $this->getDoctrine()->getRepository('App\Entity\TalentGroup');
$settings = $this->getDoctrine()->getRepository('App\Entity\SiteSetting')->findAll()[0];
$pagination_info = array(
'total' => (int) $count,
'current' => (int) $page,
'pages' => (int) ceil($count / $limit),
'path' => 'all-clients'
);
$talent_groups_repo = $this->getDoctrine()->getRepository('App\Entity\TalentGroup');
$talent_repo = $this->getDoctrine()->getRepository('App\Entity\Talent');
return
$this->render('new/clients.html.twig', [
'paginator' => $paginator,
'settings' => $settings,
'talent-groups' => $talent_groups,
'last_page' => $count / 30,
'is_search' => $request->request->all()['search_active'] ?? 'no',
'clients' => $clients,
'page' => $page,
'pagi' => $pagination_info,
'talent_groups' => $talent_groups_repo->findAll(),
'talents' => $talent_repo->findAll(),
]);
}
public function showExtras(Request $request, $paged = 0)
{
return $this->showClientsByType("","extras", $paged = 0);
}
public function showClientsByTypeMobile(Request $request, $slug, $paged = 0, $group = "actors")
{
if(isset($request->request->all()['paged'])) $paged = $request->request->all()['paged'];
$clients2 = $this->getDoctrine()->getRepository('App\Entity\Clients')->createQueryBuilder('o');
$clients2->where('o.password IS NOT NULL');
$clients2->andWhere('o.incompleteProfile = :incompleteProfile');
$clients2->setParameter('incompleteProfile', 'false');
$clients2->andWhere('o.talents like :talent');
$clients2->setParameter('talent', "%".$slug."%");
$clients = $this->getDoctrine()->getRepository('App\Entity\Clients')->createQueryBuilder('o');
$clients->where('o.password IS NOT NULL');
$clients->andWhere('o.incompleteProfile = :incompleteProfile');
$clients->setParameter('incompleteProfile', 'false');
$clients->andWhere('o.talents like :talent');
$clients->setParameter('talent', "%".$slug."%");
$clients->orderBy('o.userRegistered', 'DESC');
$clients->setFirstResult( $paged * 30);
$clients->setMaxResults(30);
$form_params = [
'incompleteProfile', 'ethnicity', 'age', 'real_age', 'display_name', 'first_name', 'sir_name',
'languages', 'infobox', 'description_of_client', 'gender_two', 'height', 'accent', 'real_families',
'userRegistered', 'location','talents', 'area'
,
];
foreach($form_params as $param)
{
if(
(isset( $_REQUEST[$param] ))
&& (!empty( $_REQUEST[$param] ))
&& ( 1 == 1 )
&& ( $_REQUEST[$param] != '-1' )
) {
$clients->andWhere("o.$param LIKE :$param");
$clients->setParameter($param, '%'.$_REQUEST[$param].'%');
$clients2->andWhere("o.$param LIKE :$param");
$clients2->setParameter($param, '%'.$_REQUEST[$param].'%');
}
}
$clients = $clients->getQuery()->getResult();
$clients2->orderBy('o.userRegistered', 'DESC');
$clients2 = $clients2->getQuery()->getResult();
return
$this->render('theme::views.mobile.by_type', [
'clients' => $clients ,
'slug' => $slug,
'group' => $group,
'paged' => $paged,
'last_page' => count($clients2) / 30]
);
}
public function showClientsByGroup(Request $request, $talentGroupSlug, $page = 0) {
// dump('$talentGroupSlug', $talentGroupSlug);
// die;
return $this->showClientsByType($request, $talentGroupSlug, null, $page);
}
public function showClientsByTalent(Request $request, $talentGroupSlug, $talentSlug, $page = 0) {
// dump('$talentSlug', $talentSlug);
// die;
// die;
return $this->showClientsByType($request, $talentGroupSlug, $talentSlug, $page);
}
public function showClientsByType(Request $request, $talentGroupSlug, $talentSlug = "", $page = 0)
{
//dump('$_REQUEST', $_REQUEST);
//die;
$is_search = $request->request->all()['search_active'] ?? false;
if($is_search) {
$page = $request->request->all()['search_page'];
}
// die;
$clients_repo = $this->getDoctrine()->getRepository('App\Entity\Clients');
$talent_groups_repo = $this->getDoctrine()->getRepository('App\Entity\TalentGroup');
$talent_repo = $this->getDoctrine()->getRepository('App\Entity\Talent');
if(isset($request->request->all()['page'])) $page = $request->request->all()['page'];
$clients2 = $clients_repo->createQueryBuilder('o');
$clients2->where('o.password IS NOT NULL');
$clients2->andWhere('o.incompleteProfile = :incompleteProfile');
$clients2->setParameter('incompleteProfile', '0');
$clients2->andWhere('o.talents like :talent');
$clients2->setParameter('talent', "%".$talentGroupSlug."%");
$clients = $clients_repo->createQueryBuilder('o');
$clients->where('o.password IS NOT NULL');
$clients->andWhere('o.incompleteProfile = :incompleteProfile');
$clients->setParameter('incompleteProfile', '0');
if($talentGroupSlug == "extras") {
// dump("extras where o.talents like %$talentGroupSlug%");
$clients->andWhere('o.talents like :talent');
$clients->setParameter('talent', "%".$talentGroupSlug."%");
$talentSlug = $talentGroupSlug;
} else if($talentGroupSlug == "disabilities") {
// dump("where o.talents like %$talentSlug%");
$clients->andWhere('o.talents like :talent');
$clients->setParameter('talent', "%".$talentGroupSlug."%");
$talentSlug = $talentGroupSlug;
} else if($talentGroupSlug == "athletes") {
// dump("where o.talents like %$talentSlug%");
$clients->andWhere('o.talents like :talent');
$clients->setParameter('talent', "%".$talentGroupSlug."%");
$talentSlug = $talentGroupSlug;
} else if($talentGroupSlug == "musicians") {
// dump("where o.talents like %$talentSlug%");
$clients->andWhere('o.talents like :talent');
$clients->setParameter('talent', "%".$talentGroupSlug."%");
$talentSlug = $talentGroupSlug;
} else if($talentGroupSlug == "speciality") {
// dump("where o.talents like %$talentSlug%");
$clients->andWhere('o.talents like :talent');
$clients->setParameter('talent', "%".$talentGroupSlug."%");
$talentSlug = $talentGroupSlug;
} else {
if(empty($talentSlug)) {
$clients->andWhere('o.talents like :talent');
$clients->setParameter('talent', "%".$talentGroupSlug."%");
$talentSlug = $talentGroupSlug;
} else {
if ($talentGroupSlug === "dancers" && $talentSlug === "theatrical")
{
$talentx = "theatre";
//theater,
$clients->andWhere('o.talents LIKE :talents1');
$clients->setParameter('talents1', "$talentx,%");
//.+ ,theater$
$clients->orWhere('o.talents LIKE :talents2');
$clients->setParameter('talents2', "%,$talentx");
//,theater,
$clients->orWhere('o.talents LIKE :talents3');
$clients->setParameter('talents3', "%,$talentx,%");
//theater
$clients->orWhere('o.talents = :talents4');
$clients->setParameter('talents4', "$talentx");
} else {
$clients->andWhere('o.talents like :talent');
$clients->setParameter('talent', "%".$talentSlug."%");
}
//
}
}
// dump('$talentSlug', $talentSlug);
// dump('$talentGroupSlug', $talentGroupSlug);
// die;
$form_params = [
'ethnicity', 'age', 'real_age', 'displayName', 'first_name', 'sir_name', 'genderTwo',
'location', 'languages', 'infobox', 'descriptionOfClient', 'height', 'accent', 'real_families',
'userRegistered', 'location', 'area', 'is_beautiful', 'has_spotlight'
];
foreach($form_params as $param)
{
if(
(isset( $_REQUEST[$param] ))
&& (!empty( $_REQUEST[$param] ))
&& ( 1 == 1 )
&& ( $_REQUEST[$param] != '-1' )
) {
$clients->andWhere("o.$param LIKE :$param");
$clients->setParameter($param, '%'.$_REQUEST[$param].'%');
$clients2->andWhere("o.$param LIKE :$param");
$clients2->setParameter($param, '%'.$_REQUEST[$param].'%');
}
}
$limit = 18;
// $page = (int) $page;
// if(!is_int($page)) {
// $page = 1;
// }
$offset = $page * $limit;
$clients->orderBy('o.id', 'DESC');
$clients->setFirstResult( $offset );
$clients->setMaxResults($limit);
$q = $clients->getQuery();
$clients = $q->getResult();
$paginator = new Paginator($q);
$path = ($talentSlug) ? "talents/".$talentGroupSlug."/".$talentSlug : "talent-directory/".$talentGroupSlug;
$count = $paginator->count();
$pagination_info = array(
'total' => (int) $count,
'current' => (int) $page,
'pages' => (int) ceil($count / $limit),
'path' => $path
);
if($talentSlug) {
$talent = $talent_repo->findOneBy(['slug' => $talentSlug]);
} else {
$talent = false;
}
$count = count($clients2->getQuery()->getResult());
$last_page = $clients2->getQuery()->getResult();
$settings = $this->getDoctrine()->getRepository('App\Entity\SiteSetting')->findAll();
if(!$settings) {
die;
}
$settings = $settings[0];
$data_for_view = [
'settings' => $settings,
'by_type' => true,
'is_search' => $request->request->all()['search_active'] ?? false,
'pagi' => $pagination_info,
'paginator' => $paginator->count(),
'group' => $talent_groups_repo->findOneBy(['slug' => $talentGroupSlug]),
'talent_groups' => $talent_groups_repo->findAll(),
'talent' => $talent,
'slug' => $talentSlug,
'slug_group' => $talentGroupSlug,
'clients' => $clients ,
'page' => $page,
'last_page' => $count / 30,
'talents' => $talent_repo->findAll(),
];
return
$this->render('new/clients.html.twig', $data_for_view);
}
public function showKeywordPage(Request $request, $keyword_slug, $paged = 0)
{
$keyword_pages_repo = $this->getDoctrine()->getRepository('App\Entity\KeywordPage');
/** @var KeywordPage $page */
$page = $keyword_pages_repo->findOneBy(['slug'=>$keyword_slug]);
$page_talents = $page->getTalents();
$talentSlug = $page->getTalents()[0]->getSlug();
$talentGroupSlug = $page->getTalentGroups()[0]->getSlug();
// $talentGroupSlug = $page->
$clients_repo = $this->getDoctrine()->getRepository('App\Entity\Clients');
$talent_groups_repo = $this->getDoctrine()->getRepository('App\Entity\TalentGroup');
$talent_repo = $this->getDoctrine()->getRepository('App\Entity\Talent');
$clients2 = $clients_repo->createQueryBuilder('o');
$clients2->where('o.password IS NOT NULL');
$clients2->andWhere('o.incompleteProfile = :incompleteProfile');
$clients2->setParameter('incompleteProfile', 'false');
$clients2->andWhere('o.talents like :talent');
$clients2->setParameter('talent', "%".$talentGroupSlug."%");
$clients = $clients_repo->createQueryBuilder('o');
$clients->where('o.password IS NOT NULL');
$clients->andWhere('o.incompleteProfile = :incompleteProfile');
$clients->setParameter('incompleteProfile', 'false');
if($talentSlug != "") {
$clients->andWhere('o.talents like :talent');
$clients->setParameter('talent', "%".$talentSlug."%");
} else {
$clients->andWhere('o.talents like :talent');
$clients->setParameter('talent', "%".$talentGroupSlug."%");
}
$form_params = [
'ethnicity', 'age', 'real_age', 'display_name', 'first_name', 'sir_name', 'gender_two',
'location', 'languages', 'infobox', 'description_of_client', 'height', 'accent', 'real_families',
'userRegistered', 'location', 'area', 'is_beautiful', 'has_spotlight'
];
foreach($form_params as $param)
{
if(
(isset( $_REQUEST[$param] ))
&& (!empty( $_REQUEST[$param] ))
&& ( 1 == 1 )
&& ( $_REQUEST[$param] != '-1' )
) {
$clients->andWhere("o.$param LIKE :$param");
$clients->setParameter($param, '%'.$_REQUEST[$param].'%');
$clients2->andWhere("o.$param LIKE :$param");
$clients2->setParameter($param, '%'.$_REQUEST[$param].'%');
}
}
$clients->orderBy('o.userRegistered', 'DESC');
$clients->setFirstResult( $paged * 50 );
$clients->setMaxResults(50);
$clients = $clients->getQuery()->getResult();
if($talentSlug) {
$talent = $talent_repo->findOneBy(['slug' => $talentSlug]);
} else {
$talent = false;
}
//
$count = count($clients2->getQuery()->getResult());
$last_page = $clients2->getQuery()->getResult();
$settings = $this->getDoctrine()->getRepository('App\Entity\SiteSetting')->findAll()[0];
$data_for_view = [
'settings' => $settings,
'keyword_page' => $page,
'by_type' => true,
'group' => $talent_groups_repo->findOneBy(['slug' => $talentGroupSlug]),
'talent' => $talent,
'slug' => $talentSlug,
'clients' => $clients ,
'paged' => $paged,
'last_page' => $count / 30,
];
// dump('$data_for_view', $data_for_view);
// dump('$talentSlug', $talentSlug);
// die;
return
$this->render('new/clients.html.twig', $data_for_view);
return
$this->render('theme::views.original.by_type', [
'clients' => $clients ,
'group' => $group,
'slug' => $talentGroupSlug,
'paged' => $paged,
'last_page' => count($last_page) / 30
]
);
// ->withInput($request->request->all());
}
public function showMobileJobs(Request $request, $paged = 0)
{
$jobs = $this->getDoctrine()->getRepository('App\Entity\Jobs')->createQueryBuilder('o');
$jobs->where('o.statuz = :statuz');
$jobs->setParameter('statuz', 'publish');
$jobs->orderBy('o.id', 'DESC');
// $jobs->setFirstResult( $paged * 30 );
// $jobs->setMaxResults(50);
$jobs = $jobs->getQuery()->getResult();
return $this->render('theme::views.mobile.jobs', ['jobs' =>$jobs ]);
}
public function getLightboxSingle(Request $request, $id)
{
$clients = $this->getDoctrine()->getRepository('App\Entity\Clients')->find($id);
return new JsonResponse([
'html' => $this->get('twig')->render('new/partials/client_lightbox.html.twig', ['client' => $clients])
]);
}
public function getLightboxClientsPreview(Request $request)
{
$ids = array_values(json_decode($request->request->get("clients"), false) ?? []);
$ret = $this->get_lbox_clients($ids, 'new/partials/client_lightbox_preview.html.twig');
return new JsonResponse([
'html' => $ret
]);
}
public function getLightboxClients(Request $request)
{
$ids = array_values($request->request->get("clients") ?? []);
$ret = $this->get_lbox_clients($ids);
return new JsonResponse([
'html' => $ret
]);
}
public function sendGetLigthboxClients(Request $request)
{
$ids = array_values(json_decode($request->request->get("clients"), false) ?? []);
$lightbox_html = $this->get_lbox_clients($ids);
}
private function get_lbox_clients($ids, $template = 'new/partials/client_lightbox_new.html.twig')
{
$ret = "";
if(!empty($ids)) {
$clients = $this->getDoctrine()->getRepository('App\Entity\Clients')
->findBy(['id' => $ids]);
foreach($clients as $client) {
$ret .= $this->get('twig')->render($template, ['client' => $client]);
}
}
return $ret;
}
public function showJobCallSelection($lightbox_id = 0, LightboxRepository $lrepo, JobCallStageRepository $jobCallStageRepository) {
$lightbox = $lrepo->findOneBy(['unique_id' => $lightbox_id]);
$jobCallStage = $jobCallStageRepository->findOneBy(['lightbox' => $lightbox->getId()]);
$clients = $lightbox->getClients();
$priorities = json_decode($lightbox->getPriorities(), true);
if(!empty($priorities)) {
$newClientIds = [];
$newClients = [];
$prioClients = [];
$nonPrioClients = [];
foreach($clients as $client) {
$prioFound = false;
foreach($priorities as $priority_set) {
if($client->getId() == $priority_set['clientId']) {
// dump("got prio to set");
$client->priority = $priority_set['priority'];
$prioFound = true;
break;
}
}
if($prioFound == true) {
$prioClients[] = $client;
} else {
$nonPrioClients[] = $client;
}
$newClients[] = $client;
}
$clients = $newClients;
usort($prioClients, function($a, $b)
{
return intval($a->priority) > intval($b->priority);
});
usort($nonPrioClients, function($a, $b)
{
return intval($a->getId()) > intval($b->getId());
});
$clients = array_merge($prioClients, $nonPrioClients);
} else {
$newClients = [];
foreach ($clients as $client) {
$newClients[] = $client;
}
$clients = $newClients;
usort($clients, function($a, $b)
{
return intval($a->getId()) < intval($b->getId());
});
}
if($jobCallStage) {
$jobCall = $jobCallStage->getJobCall();
return $this->render('new/lightbox_job_call.html.twig', [
'lightbox' => $lightbox,
'job_call' => $jobCall,
'clients_sorted' => $clients,
'job_call_stage' => $jobCallStage->toJson()
]);
} else {
return $this->render('new/lightbox_new.html.twig', [
'lightbox' => $lightbox,
]);
}
}
public function showClientsSelection($lightbox_id = 0, LightboxRepository $lrepo, JobCallStageRepository $jobCallStageRepository)
{
$lightbox = $lrepo->findOneBy(['unique_id' => $lightbox_id]);
$clients = $lightbox->getClients();
$priorities = json_decode($lightbox->getPriorities(), true);
if(!empty($priorities)) {
$newClientIds = [];
$newClients = [];
$prioClients = [];
$nonPrioClients = [];
foreach($clients as $client) {
$prioFound = false;
foreach($priorities as $priority_set) {
if($client->getId() == $priority_set['clientId']) {
// dump("got prio to set");
$client->priority = $priority_set['priority'];
$prioFound = true;
break;
}
}
if($prioFound == true) {
$prioClients[] = $client;
} else {
$nonPrioClients[] = $client;
}
$newClients[] = $client;
}
$clients = $newClients;
usort($prioClients, function($a, $b)
{
return intval($a->priority) > intval($b->priority);
});
usort($nonPrioClients, function($a, $b)
{
return intval($a->getId()) < intval($b->getId());
});
$clients = array_merge($prioClients, $nonPrioClients);
} else {
$newClients = [];
foreach ($clients as $client) {
$newClients[] = $client;
}
$clients = $newClients;
usort($clients, function($a, $b)
{
return intval($a->getId()) < intval($b->getId());
});
}
return $this->render('new/lightbox_clients.html.twig', [
'lightbox' => $lightbox,
'clients_sorted' => $clients
]);
}
public function showEnquiryLightboxByUniqueId($lightbox_id = 0, LightboxRepository $lrepo) {
$lightbox = $lrepo->findOneBy(['unique_id' => $lightbox_id]);
return $this->render('new/lightbox_enquire.html.twig', ['lightbox' => $lightbox]);
}
public function showLightbox(Request $request, $paged = 0) {
return $this->render('new/lightbox.html.twig', ['settings' => $this->getSettings()]);
}
public function showLightboxEnquiry(Request $request, $paged = 0) {
return $this->render('new/lightbox_enquire.html.twig', ['settings' => $this->getSettings()]);
}
public function showTermsAndConditions(Request $request) {
return $this->render('new/terms_and_conditions.html.twig', ['settings' => $this->getSettings()]);
}
public function showPrivacyPolicy(Request $request) {
return $this->render('new/privacy_policy.html.twig', ['settings' => $this->getSettings()]);
}
public function showProjects(Request $request, ImageService $is, $paged = 0) {
$images = $this->getDoctrine()->getRepository('App\Entity\ProjectImage')->findAll();
foreach($images as $image) {
// dump('$image', $image->getImage());
$is->resize_to_fit("/usr/share/nginx/fusion/public/images/theme_images/".$image->getImage());
}
return $this->render('new/projects.html.twig', [
'settings' => $this->getSettings(),
'project_videos' => $this->getDoctrine()->getRepository('App\Entity\ProjectVideo')->findAll(),
'project_images' => $images,
'talent_groups' => $this->getDoctrine()->getRepository('App\Entity\TalentGroup')->findAll(),
]);
}
public function showJobs(Request $request, $paged = 0)
{
$jobs = $this->getDoctrine()->getRepository('App\Entity\Jobs')->createQueryBuilder('o');
$jobs->where('o.statuz = :statuz');
$jobs->setParameter('statuz', 'publish');
$jobs->orderBy('o.id', 'DESC');
// $jobs->setFirstResult( $paged * 30 );
// $jobs->setMaxResults(100);
$jobs = $jobs->getQuery()->getResult();
// dump(count($jobs));
// die;
$return = array();
foreach($jobs as $job) {
if ($job->isExpired() == 1) continue;
$return[] = $job;
}
// dump('$return', $return);
// die;
return $this->render('new/jobs.html.twig', ['jobs' =>$return,
'settings' => $this->getSettings()
]);
}
public function showClient(Request $request, $userNicename)
{
if($this->getUser() && $this->getUser()->getIsAdmin()) {
// die('fss2');
}
/** @var Clients $client */
$client = $this->getDoctrine()->getRepository('App\Entity\Clients')
->findOneBy(array('userNicename' => $userNicename),
array('id' => 'DESC')
);
$credits = $this->getDoctrine()->getRepository('App\Entity\Credits')
->findBy(array('userId' => $client->getId()));
$trainings = $this->getDoctrine()->getRepository('App\Entity\Trainings')
->findBy(array('id' => $client->getTrainings()));
$talent_groups = $this->getDoctrine()->getRepository('App\Entity\TalentGroup')->findAll();
if($client->getIsArchived() == true) {
if ($_SERVER['REMOTE_ADDR']=='90.248.44.247') {
echo $client->getId();
die("ffff");
}
return $this->redirect("https://fusionmng.com", 301);
}
$response =
$this->render('/new/client_public.html.twig', ['talent_groups' => $talent_groups, 'client' => $client, 'credits' => $credits, 'trainings' => $trainings, 'settings' => $this->getSettings()] );
$response->headers->addCacheControlDirective('no-cache', true);
$response->headers->addCacheControlDirective('must-revalidate', true);
return $response;
}
public function showClientMobile(Request $request, $userNicename)
{
$client = $this->getDoctrine()->getRepository('App\Entity\Clients')
->findOneBy(array('userNicename' => $userNicename));
return
$this->render('theme::views.mobile.profile', ['client' => $client ]);
}
public function showForgot(Request $request)
{
return $this->render('new/forgot-password.html.twig',[
'settings' => $this->getSettings()
]);
}
public function showMobileForgot(Request $request){
return $this->render('theme::views.mobile.forgot-password');
}
public function showReset(Request $request, $rememberToken)
{
$client = $this->getDoctrine()->getRepository('App\Entity\Clients')->findOneByRememberToken($rememberToken);
$session = $this->get('session');
// $session->getFlashBag()->set('success_reset', true);
// dump($session->get("success_reset"));
// die;
return $this->render('new/forgot-password-reset.html.twig', ['user' => $client, 'settings' => $this->getSettings()]);
}
public function doReset(Request $request, UserPasswordEncoderInterface $enc)
{
$client = $this->getDoctrine()->getRepository('App\Entity\Clients')->findOneById($request->request->all()['user']);
$new_pass = $request->request->all()['password'];
$new_pass_confirm = $request->request->all()['password_confirm'];
if($new_pass !== $new_pass_confirm) die('Bad password');
$encoded = $enc->encodePassword($client, $new_pass);
$client->setPassword($encoded);
$this->getDoctrine()->getManager()->persist($client);
$this->getDoctrine()->getManager()->flush();
$session = $this->get('session');
$session->getFlashBag()->set('success_reset', true);
return $this->render('new/forgot-password-reset.html.twig', ['user' => $client->getId(), 'settings' => $this->getSettings()]);
}
public function doForgot(Request $request)
{
$client = $this->getDoctrine()->getRepository('App\Entity\Clients')->findOneByEmail($request->request->all()['email']);
$token = uniqid();
$client->setRememberToken($token);
// $new_pass = str_random(12);
// $client->setPassword($new_pass);
$this->getDoctrine()->getManager()->persist($client);
$this->getDoctrine()->getManager()->flush();
// dd($client);
// dd($client->getRememberToken());
// die;
if(!is_null($client))
{
$url = $this->getParameter('url');
$this->get("ses_mailer")->mailForgot(
$client->getId() ,
[
'from'=>'admin@fusionmng.com',
'subject' => 'Password reset instructions',
'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()}",
]);
} else {
die("Email incorrect, please double check it");
}
/** @var Session $session */
$session = $this->get('session');
$session->getFlashBag()->set('success', true);
// $session = $this->get('session');
$session->getFlashBag()->set('success', true);
return $this->redirect($request->server->get("HTTP_REFERER"));
}
public function showLogin(Request $request)
{
return $this->render('new/login.html.twig', ['settings' => $this->getSettings()]);
}
public function doLogout(Request $request){
\Auth::logout();
return $this->render('theme::views.original.login');
}
/** todo: remove or refactor */
public function doLogin(Request $request)
{
dump('$request', $request);
die;
// validate the info, create rules for the inputs
$rules = array(
//'email' => 'required|email', // make sure the email is an actual email
'password' => 'required|min:3' // password can only be alphanumeric and has to be greater than 3 characters
);
// run the validation rules on the inputs from the form
$validator = \Validator::make($request->request->all(), $rules);
// if the validator fails, redirect back to the form
if ($validator->fails()) {
// dd("Due to website version switch we require that you reset");
return \Redirect::to('https://fusionmng.com/login')
->withErrors($validator) // send back all errors to the login form
->withInput($request->request->except('password')); // send back the input (not the password) so that we can repopulate the form
} else {
$userdata = array(
'email' => trim($request->request->get('email')),
'password' => trim($request->request->get('password'))
);
if (\Auth::attempt($userdata)) {
return \Redirect::intended('profile');
} else {
return \Redirect::to('https://fusionmng.com/login');
}
}
}
public function updateSelectedClientsPriorities(Request $request)
{
$selectionName = null;
$clientName = null;
$clientToAdd = null;
$clientImage = null;
$priority = null;
$clients_to_update = null;
$redis = new \Redis();
$redis->connect('localhost');
$redis->auth("vanXGmC9kHuLRaSfn2QmtG8Pgxc7N7BPnLKam2hdM");
$clients_to_update = json_decode($request->request->all()['clients'], true);
if(isset($_REQUEST['selection_name'])) {
$selectionName = $_REQUEST['selection_name'];
} else if($clients_to_update && count($clients_to_update) > 0 && isset($clients_to_update[0]['user_id'])) {
$selectionName = $clients_to_update[0]['user_id'];
}
$clients_selection = unserialize($redis->get($selectionName));
$updated_selection = [];
foreach($clients_to_update as $client_to_update) {
unset($client_to_update['user_id']);
$updated_selection[] = $client_to_update;
}
$redis->set($selectionName, serialize($updated_selection));
return new JsonResponse([
'updated' => $updated_selection,
'original' => $clients_selection
]);
}
public function selectedClient(Request $request)
{
$selectionName = null;
$clientName = null;
$clientToAdd = null;
$clientImage = null;
$priority = null;
if(isset($_REQUEST['selection_name'])) {
$selectionName = $_REQUEST['selection_name'];
} else if(isset($_REQUEST['user_id'])) {
$selectionName = $_REQUEST['user_id'];
}
if(isset($_REQUEST['clientName'])) {
$clientName = $_REQUEST['clientName'];
} else {
$clientName = 'noClientName';
}
if(isset($_REQUEST['priority'])) {
$priority = $_REQUEST['priority'];
} else {
$priority = 0;
}
if(isset($_REQUEST['client_image'])) {
$client_image = $_REQUEST['client_image'];
} else {
$client_image = "noimg";
}
$redis = new \Redis();
$redis->connect('localhost');
$redis->auth("vanXGmC9kHuLRaSfn2QmtG8Pgxc7N7BPnLKam2hdM");
$arr = unserialize($redis->get($selectionName));
if(!is_array($arr)) {
$arr = [];
}
$respo = '';
if(isset($_REQUEST['clientId'])) {
$clientToAdd = $_REQUEST['clientId'];
$newArr = [];
$clientFound = false;
foreach ($arr as $client ) {
if($client['clientId'] != $clientToAdd) {
$newArr[] = $client;
} else {
$clientFound = true;
$newArr[] = [
'clientId' => $clientToAdd,
'clientName' => $clientName,
'priority' => $priority,
'client_image' => $client_image
];
}
}
if($clientFound == false) {
$newArr[] = [
'clientId' => $clientToAdd,
'clientName' => $clientName,
'priority' => $priority,
'client_image' => $client_image
];
}
$respo = $newArr;
$arr = $newArr;
} else if(isset($_REQUEST['client_to_remove'])) {
//remove from array
$newArr = [];
foreach ($arr as $client ) {
if($client['clientId'] !== $_REQUEST['client_to_remove']){
$newArr[] = $client;
}
}
$respo = $newArr;
$arr = $newArr;
} else if(isset($_REQUEST['ClearSelection'])) {
//clear array
$arr = [];
}
$redis->set($selectionName, serialize($arr));
return new JsonResponse($respo);
}
public function getSelectedClients(Request $request)
{
$selectionName = null;
$clientName = null;
$clientToAdd = null;
if(isset($_REQUEST['user_id'])) {
$selectionName = $_REQUEST['user_id'];
}
$redis = new \Redis();
$redis->connect('localhost');
$redis->auth("vanXGmC9kHuLRaSfn2QmtG8Pgxc7N7BPnLKam2hdM");
$arr = unserialize($redis->get($selectionName));
if(!is_array($arr)) {
$arr = [];
}
// return $arr;
usort($arr, function ($a, $b) {
if (intval($a['priority']) == intval($b['priority'])) return 0;
return (intval($a['priority']) > intval($b['priority'])) ? -1 : 1;
});
return new JsonResponse($arr);
}
public function showAboutUs(Request $request)
{
return $this->render('new/about_us.html.twig', ['settings' => $this->getSettings()]);
}
public function showSitemap(Request $request)
{
if ($_SERVER['REMOTE_ADDR']=='79.118.101.15.5') {
$look_in='/usr/share/nginx/fusion';
$allowed_files=array('twig');
$search_for='the work we get our actors';
function search_in_files ($search_for, $look_in, $allowed_files) {
$files=scandir($look_in);
foreach ($files as $key => $value) {
if (is_dir($look_in.'/'.$value) && !in_array(substr($value, 0, 1), array('.'))) {
search_in_files($search_for, $look_in.'/'.$value, $allowed_files);
} elseif (is_file($look_in.'/'.$value) && in_array(substr($value, strlen($value)-4), $allowed_files)) {
$fc=file_get_contents($look_in.'/'.$value);
if (strpos($fc, $search_for)!==false) {
echo $look_in.'/'.$value."<br>";
}
}
}
}
search_in_files($search_for, $look_in, $allowed_files);
die("done");
}
return $this->render('new/sitemap.html.twig', ['settings' => $this->getSettings()]);
}
public function showHireTalents(Request $request)
{
return $this->render('new/hire_talents.html.twig', ['settings' => $this->getSettings()]);
}
public function showAgencyApplication(Request $request)
{
$session = $this->get('session');
$suc = false;
$success = $session->getFlashBag()->get('success_application');
if(empty($success)) {
$suc = false;
} else {
$suc = true;
}
return $this->render('new/application.html.twig', ['settings' => $this->getSettings(), 'success' => $suc]);
}
public function showSubmitJob(Request $request)
{
if($this->getUser() && $this->getUser()->getIsAdmin()) {
return $this->render('new/submit-job.html.twig', ['settings' => $this->getSettings()]);
} else {
return $this->render('new/submit-job-non-admin.html.twig', ['settings' => $this->getSettings()]);
}
}
public function showContact(Request $request)
{
return $this->render('new/contact.html.twig', ['settings' => $this->getSettings()]);
}
public function doContact(Request $request)
{
$mail = $this->get('ses_mailer')->mailContactForm($request, $this->get('twig'));
return $this->render('new/contact.html.twig',['success'=>true,'settings' => $this->getSettings()]);
}
}