<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\RedirectResponse;
use App\Repository\DemandeTarifsRepository;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Dompdf\Dompdf;
use Dompdf\Options;
class DefaultController extends AbstractController
{
/**
* @Route("/", name="app_home")
*/
public function home(Request $request, DemandeTarifsRepository $demandeTarifsRepository )
{
return $this->render('default/home.html.twig');
}
/**
* @Route("/lea", name="app_lea")
*/
public function lea(Request $request )
{
return $this->render('default/lea.html.twig');
}
/**
*
* @Security("is_granted('ROLE_USER')")
*/
/**
* @Route("/alerts/requete", name="app_altert_requete" )
*/
public function report_requete(Request $request, DemandeTarifsRepository $demandeTarifsRepository )
{
$tarifs= null;
$reservations=null;
$dossiers=null;
//if ($request->isXmlHttpRequest() ){
//On calcul le nombre de demande de tarif
$tarifs= count( $demandeTarifsRepository->findBy(array('isDone'=>false )));
if ($tarifs !=0 ){
return new Response('<span class="badge btn-danger">'.$tarifs.'</span>');
}else{
return new Response('<span class=""></span>');
}
}
/**
* @Route("/alerts/report", name="app_alterts")
*/
public function report(Request $request, DemandeTarifsRepository $demandeTarifsRepository )
{
$tarifs= null;
$reservations=null;
$dossiers=null;
//if ($request->isXmlHttpRequest() ){
//On calcul le nombre de demande de tarif
$tarifs= count( $demandeTarifsRepository->findAll());
return $this->render('_backend_menu.html.twig', ['dossiers_agence'=>$dossiers , 'tarifs'=>$tarifs, 'reservations'=>$reservations ] );
//}
//throw new NotFoundHttpException();
}
/**
* @Route("/dash-dash", name="app_dash")
*/
public function index()
{
if (!$this->isGranted('IS_AUTHENTICATED_FULLY') ){
return new RedirectResponse($this->generateUrl("app_login"));
}
if ($this->isGranted('ROLE_APPORTEUR') ) {
if ( !$this->getUser()->getApporteur() ) {
$this->addFlash('warning',"Nous n'avons pas trouvé vos données d'identification.");
//$this->addFlash('info','Rechercher " @LISTACommercial " sur telegram afin de vous abonner.');
return $this->render('apporteur/no_registration.html.twig', [
'controller_name' => 'DefaultController',
]);
}
}
if ($this->getUser()->getApporteur()){
if (!$this->getUser()->getApporteur()->getSissionId()){
$this->addFlash('warning','Vous n\'êtes pas abonné au canal de notifications!');
$this->addFlash('info','Rechercher " @LISTACommercial " sur telegram afin de vous abonner.');
return $this->render('default/telegram_info.html.twig', [
'controller_name' => 'DefaultController',
]);
}
}
return $this->render('default/index.html.twig', [
'message' => 'Heureux de vous accueillir.',
]);
}
}