<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Routing\Annotation\Route;
use App\Controller\CommonController;
use Symfony\Component\HttpFoundation\Request;
use App\Form\SupportType;
use App\Service\EmailService;
class IndexController extends CommonController
{
/**
* Home Page Route
*
* @Route("/", name="home")
*/
public function indexAction()
{
return $this->redirectToRoute('invoice_list');
$data['table'] = [
['task' => 1, 'progress' => rand(0, 100)],
['task' => 2, 'progress' => rand(0, 100)],
['task' => 3, 'progress' => rand(0, 100)],
['task' => 4, 'progress' => rand(0, 100)],
];
$data['info'] = $this->getUser();
$data['menu'] = 'dashboard';
//check if user is logged in
$user = $this->getUser();
if (!$user) {
//$redirect = new RedirectResponse;
return $this->redirectToRoute('app_login');
}
return $this->render('index.html.twig', $data);
}
/**
* Home Page Route
*
* @Route("/support",name="support")
*/
public function supportAction(Request $request,EmailService $mailService)
{
$accessTree = $this->getAccessTree();
$form = $this->createForm(SupportType::class);
$user = $this->getUser();
$name = $user->getName();
$email = $user->getUsername();
$form->get('name')->setData($name);
$form->get('emailAddress')->setData($email);
$form->handleRequest($request);
if ($form->isSubmitted()) {
$data =$form->getData();
$to = $this->getParameter('support_destination');
$from = $this->getParameter('email_from');
$mailService->send($from,$to,'New Support Email','email/support.html.twig',$data);
$this->addFlash('success', "Your message has been sent to our support team");
}
$data = [
'navigation' => $this->getNavigationSections(),
'menu' => 'support',
'form' => $form->createView(),
];
return $this->render('support.html.twig', $data);
}
}