src/Controller/HomeController.php line 43

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Livraisons;
  4. use App\Form\Typeabonnement;
  5. use App\Form\LivraisonsType;
  6. use App\Repository\LivraisonsRepository;
  7. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. use Symfony\Component\HttpFoundation\Request;
  11. use App\Service\InfobipService;
  12. class HomeController extends AbstractController
  13. {
  14. private $infobipService;
  15. public function __construct(InfobipService $infobipService)
  16. {
  17. $this->infobipService = $infobipService;
  18. }
  19. #[Route('/send-whatsapp', name: 'send_whatsapp')]
  20. public function sendWhatsAppMessage(): Response
  21. {
  22. $to = '+221774271878'; // Remplace par le numéro du destinataire
  23. $message = 'Hello, this is a test message from Infobip API!';
  24. $response = $this->infobipService->sendMessage($to, $message);
  25. return new Response('Message sent! Response: ' . $response->getContent());
  26. }
  27. /**
  28. * @Route("/", name="home")
  29. */
  30. public function index(Request $request): Response
  31. {
  32. $livraison = new Livraisons();
  33. $form = $this->createForm(LivraisonsType::class, $livraison);
  34. $form->handleRequest($request);
  35. $now = new \DateTime();
  36. $liv_hours = $now->modify('+2 hours'); // Adds 2 hours
  37. return $this->render('home/index.html.twig', [
  38. 'form' => $form->createView(),
  39. 'liv_hours' => $liv_hours,
  40. ]);
  41. }
  42. #[Route('/cgi', name: 'app_cgi_index', methods: ['GET'])]
  43. public function cgi(): Response
  44. {
  45. return $this->render('home/cgi.html.twig');
  46. }
  47. #[Route('/aboutus', name: 'app_aboutus_index', methods: ['GET'])]
  48. public function aboutus(): Response
  49. {
  50. return $this->render('home/aboutus.html.twig');
  51. }
  52. #[Route('/tarification', name: 'app_tarification_index', methods: ['GET'])]
  53. public function tarification(): Response
  54. {
  55. return $this->render('home/tarification.html.twig');
  56. }
  57. #[Route('/services', name: 'app_services_index', methods: ['GET'])]
  58. public function services(): Response
  59. {
  60. return $this->render('home/services.html.twig');
  61. }
  62. #[Route('/programmefidelite', name: 'app_programmefidelite_index', methods: ['GET'])]
  63. public function programmefidelite(): Response
  64. {
  65. return $this->render('home/programmefidelite.html.twig');
  66. }
  67. #[Route('/dashboardold', name: 'app_dashboard_indexold', methods: ['GET'])]
  68. public function dashboardold(LivraisonsRepository $livraisonRepository): Response
  69. {
  70. // KPIs
  71. $totalLivraisons = $livraisonRepository->count([]);
  72. // $livraisonsEnCours = $livraisonRepository->count(['statut' => 'en cours']);
  73. // $livraisonsTerminees = $livraisonRepository->count(['statut' => 'livrée']);
  74. // $revenuTotal = $livraisonRepository->getTotalRevenue(); // Méthode personnalisée
  75. return $this->render('dashboard/index.html.twig', [
  76. 'totalLivraisons' => $totalLivraisons,
  77. 'livraisonsEnCours' => 0, //$livraisonsEnCours,
  78. 'livraisonsTerminees' => 0, //$livraisonsTerminees,
  79. 'revenuTotal' => 0, //$revenuTotal,
  80. ]);
  81. }
  82. #[Route('/dashboard', name: 'app_dashboard_index')]
  83. public function dashboard(LivraisonsRepository $livraisonRepository): Response
  84. {
  85. $livraisonsJour = $livraisonRepository->findToday();
  86. $livraisonsSemaine = $livraisonRepository->findThisWeek();
  87. $livraisonsMois = $livraisonRepository->findThisMonth();
  88. $livraisonsencours = $livraisonRepository->findEnAttente();
  89. $totalLivraisons = $livraisonRepository->count([]);
  90. $nombrelivraisonsparzone = $livraisonRepository->getNombreLivraisonsParZone();
  91. return $this->render('dashboard/index.html.twig', [
  92. 'totalLivraisons' => $totalLivraisons,
  93. 'livraisonsJour' => $livraisonsJour,
  94. 'livraisonsSemaine' => $livraisonsSemaine,
  95. 'livraisonsMois' => $livraisonsMois,
  96. 'livraisonsencours' => $livraisonsencours,
  97. 'nombrelivraisonsparzone' => $nombrelivraisonsparzone,
  98. 'caJour' => $livraisonRepository->getChiffreAffaireGroupedBy('day'),
  99. 'caSemaine' => $livraisonRepository->getChiffreAffaireGroupedBy('week'),
  100. 'caMois' => $livraisonRepository->getChiffreAffaireGroupedBy('month'),
  101. ]);
  102. }
  103. }