src/Controller/HomeController.php line 66

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Livraisons;
  4. use App\Entity\User;
  5. use App\Form\Typeabonnement;
  6. use App\Form\LivraisonsType;
  7. use App\Repository\LivraisonsRepository;
  8. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  9. use Symfony\Component\HttpFoundation\Response;
  10. use Symfony\Component\Routing\Annotation\Route;
  11. use Symfony\Component\HttpFoundation\Request;
  12. use App\Service\InfobipService;
  13. use App\Form\SouscriptionType;
  14. use App\Entity\PaymentMethod;
  15. use App\Entity\Souscription;
  16. use Detection\MobileDetect;
  17. class HomeController extends AbstractController
  18. {
  19.     
  20.     
  21.     
  22.     private $infobipService;
  23.         public function __construct(InfobipService $infobipService)
  24.         {
  25.             $this->infobipService $infobipService;
  26.         }
  27.         #[Route('/rapportpointage'name'pointagereport')]
  28.         public function pointage_reporting_date()
  29.         {
  30.             $user $this->getUser();
  31.         // 🔹 Vérifie abonnement et rôle
  32.         if (!$user->isOkAbonnement() && in_array('ROLE_ADMIN'$user->getRoles(), false)) {
  33.             // Redirection admin avec abonnement actif
  34.             $this->addFlash('error''Vous n\'êtes pas autorisé à accéder à cette page, veuillez vous abonner d\'abord.');
  35.             return $this->redirectToRoute('souscription_new');
  36.         }
  37.             return $this->render('admin/reporting1.html.twig');
  38.         }
  39.         #[Route('/send-whatsapp'name'send_whatsapp')]
  40.         public function sendWhatsAppMessage(): Response
  41.         {
  42.             $to '+221774271878';  // Remplace par le numéro du destinataire
  43.             $message 'Hello, this is a test message from Infobip API!';
  44.             
  45.             $response $this->infobipService->sendMessage($to$message);
  46.             
  47.             return new Response('Message sent! Response: ' $response->getContent());
  48.         }
  49.     /**
  50.      * @Route("/", name="home")
  51.      */
  52.     public function index(Request $request): Response
  53.     {
  54.                 //    return $this->redirectToRoute('app_login');
  55.         $detect = new MobileDetect();
  56.         $isMobile $detect->isMobile();
  57.         
  58.         $livraison = new Livraisons();
  59.         $form $this->createForm(LivraisonsType::class, $livraison);
  60.         $form->handleRequest($request);
  61.         $now = new \DateTime();
  62.         $liv_hours $now->modify('+2 hours'); // Adds 2 hours
  63.         return $this->render('home/index.html.twig', [
  64.             'form' => $form->createView(),
  65.             'liv_hours' => $liv_hours,
  66.             'isMobile' => $isMobile,
  67.         ]);
  68.     }
  69.     
  70. #[Route('/reporting'name'dashboard_admin_reporting')]
  71. public function reporting(): Response
  72. {
  73.     $user $this->getUser();
  74.         // 🔹 Vérifie abonnement et rôle
  75.         if (!$user->isOkAbonnement() && in_array('ROLE_ADMIN'$user->getRoles(), false)) {
  76.             // Redirection admin avec abonnement actif
  77.             $this->addFlash('error''Vous n\'êtes pas autorisé à accéder à cette page, veuillez vous abonner d\'abord.');
  78.             return $this->redirectToRoute('souscription_new');
  79.         }
  80.     return $this->render('admin/reporting.html.twig', [
  81.       //  'users' => $users,
  82.     ]);
  83. }
  84.     
  85.     #[Route('/cgi'name'app_cgi_index'methods: ['GET'])]
  86.     public function cgi(): Response
  87.     {
  88.         return $this->render('home/cgi.html.twig');
  89.     }
  90.     #[Route('/aboutus'name'app_aboutus_index'methods: ['GET'])]
  91.     public function aboutus(): Response
  92.     {
  93.         return $this->render('home/aboutus.html.twig');
  94.     }
  95.     #[Route('/privacy'name'app_privacy_index'methods: ['GET'])]
  96.     public function privacy(): Response
  97.     {
  98.         return $this->render('home/privacy.html.twig');
  99.     }
  100.     #[Route('/tarification'name'app_tarification_index'methods: ['GET'])]
  101.     public function tarification(Request $request): Response
  102.     {
  103.         $souscription = new Souscription();
  104.     $form $this->createForm(SouscriptionType::class, $souscription);
  105.     $form->handleRequest($request);
  106. return $this->render('home/tarification.html.twig', [
  107.                 'form' => $form->createView(),
  108.             ]);
  109. /*
  110.         $currentUser =  $this->getUser();
  111.         if ($currentUser == $user)
  112.         {
  113.             
  114. }
  115.     else
  116.     {
  117.         return $this->redirectToRoute('app_login', [], Response::HTTP_SEE_OTHER);
  118.     }*/
  119.         
  120.     }
  121.    
  122.     
  123.     #[Route('/services'name'app_services_index'methods: ['GET'])]
  124.     public function services(): Response
  125.     {
  126.         return $this->render('home/services.html.twig');
  127.     }
  128.     #[Route('/programmefidelite'name'app_programmefidelite_index'methods: ['GET'])]
  129.     public function programmefidelite(): Response
  130.     {
  131.         return $this->render('home/programmefidelite.html.twig');
  132.     }
  133.     #[Route('/dashboardold'name'app_dashboard_indexold'methods: ['GET'])]
  134.     public function dashboardold(LivraisonsRepository $livraisonRepository): Response
  135.     {
  136.         // KPIs
  137.         $totalLivraisons $livraisonRepository->count([]);
  138.        // $livraisonsEnCours = $livraisonRepository->count(['statut' => 'en cours']);
  139.        // $livraisonsTerminees = $livraisonRepository->count(['statut' => 'livrée']);
  140.        // $revenuTotal = $livraisonRepository->getTotalRevenue(); // Méthode personnalisée
  141.         return $this->render('dashboard/index.html.twig', [
  142.             'totalLivraisons' => $totalLivraisons,
  143.             'livraisonsEnCours' => 0//$livraisonsEnCours,
  144.             'livraisonsTerminees' => 0//$livraisonsTerminees,
  145.             'revenuTotal' => 0//$revenuTotal,
  146.         ]);
  147.     }
  148.     #[Route('/dashboard'name'app_dashboard_index')]
  149.     public function dashboard(LivraisonsRepository $livraisonRepository): Response
  150.     {
  151.         $livraisonsJour $livraisonRepository->findToday();
  152.         $livraisonsSemaine $livraisonRepository->findThisWeek();
  153.         $livraisonsMois $livraisonRepository->findThisMonth();
  154.         $livraisonsencours $livraisonRepository->findEnAttente();
  155.         $totalLivraisons $livraisonRepository->count([]);
  156.         $nombrelivraisonsparzone $livraisonRepository->getNombreLivraisonsParZone();
  157.         return $this->render('dashboard/index.html.twig', [
  158.             'totalLivraisons' => $totalLivraisons,
  159.             'livraisonsJour' => $livraisonsJour,
  160.             'livraisonsSemaine' => $livraisonsSemaine,
  161.             'livraisonsMois' => $livraisonsMois,
  162.             'livraisonsencours' => $livraisonsencours,
  163.             'nombrelivraisonsparzone'  => $nombrelivraisonsparzone,
  164.             'caJour' => $livraisonRepository->getChiffreAffaireGroupedBy('day'),
  165.             'caSemaine' => $livraisonRepository->getChiffreAffaireGroupedBy('week'),
  166.             'caMois' => $livraisonRepository->getChiffreAffaireGroupedBy('month'),
  167.         ]);
  168.     }
  169. }