src/Controller/HomeController.php line 143

  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use Symfony\Component\Mailer\MailerInterface;
  8. use Symfony\Component\Mime\Email;
  9. use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
  10. use Symfony\Component\Form\Extension\Core\Type\TextType;
  11. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  12. use App\Entity\Shipment;
  13. use App\Entity\Blog;
  14. use App\Repository\ShipmentRepository;
  15. use App\Repository\BlogRepository;
  16. use App\Repository\ImageGalleryRepository;
  17. use App\Repository\TrackingUpdateRepository;
  18. use App\Repository\SettingsInfoRepository;
  19. use App\Service\CookieService;
  20. class HomeController extends AbstractController
  21. {  
  22.     #[Route('/'name'app_home')]
  23.     public function index(CookieService $cookieService): Response
  24.     {   
  25.         $beforeAwbno $cookieService->getLastTrackingId();
  26.         
  27.         return $this->render('home/index.html.twig', [
  28.             'controller_name' => 'HomeController',  
  29.             'beforeAwbno' => $beforeAwbno,
  30.         ]);
  31.     }
  32.    
  33.     #[Route('/about'name'app_home_about')]
  34.     public function about(): Response
  35.     {       
  36.         return $this->render('home/about.html.twig', [
  37.             'controller_name' => 'HomeController',
  38.         ]);
  39.     }
  40.   
  41.     #[Route('/mission-vision'name'app_home_mission')]
  42.     public function mission(): Response
  43.     {
  44.         return $this->render('home/mission.html.twig', [
  45.             'controller_name' => 'HomeController',
  46.         ]);
  47.     }
  48.     #[Route('/team'name'app_home_team')]
  49.     public function team(): Response
  50.     {
  51.         return $this->render('home/team.html.twig', [
  52.             'controller_name' => 'HomeController',
  53.         ]);
  54.     }
  55.     #[Route('/testimonial'name'app_home_testimonial')]
  56.     public function testimonial(): Response
  57.     {
  58.         return $this->render('home/testimonial.html.twig', [
  59.             'controller_name' => 'HomeController',
  60.         ]);
  61.     }
  62.     #[Route('/shipping-guideline'name'app_home_guideline')]
  63.     public function guideline(): Response
  64.     {
  65.         return $this->render('home/guideline.html.twig', [
  66.             'controller_name' => 'HomeController',
  67.         ]);
  68.     }
  69.     #[Route('/terms'name'app_home_terms')]
  70.     public function terms(): Response
  71.     {
  72.         return $this->render('home/terms.html.twig', [
  73.             'controller_name' => 'HomeController',
  74.         ]);
  75.     }
  76.     #[Route('/all-services'name'app_home_allservices')]
  77.     public function allservices(): Response
  78.     {
  79.         return $this->render('home/allservices.html.twig', [
  80.             'controller_name' => 'HomeController',
  81.         ]);
  82.     }
  83.     #[Route('/worldwide-express'name'app_home_express')]
  84.     public function express(): Response
  85.     {
  86.         return $this->render('home/express.html.twig', [
  87.             'controller_name' => 'HomeController',
  88.         ]);
  89.     }
  90.     #[Route('/door-to-door'name'app_home_doortodoor')]
  91.     public function doortodoor(): Response
  92.     {
  93.         return $this->render('home/doortodoor.html.twig', [
  94.             'controller_name' => 'HomeController',
  95.         ]);
  96.     }
  97.     #[Route('/customs-clering'name'app_home_customsclering')]
  98.     public function customsclering(): Response
  99.     {
  100.         return $this->render('home/customsclering.html.twig', [
  101.             'controller_name' => 'HomeController',
  102.         ]);
  103.     }
  104.     #[Route('/air-cargo'name'app_home_aircargo')]
  105.     public function aircargo(): Response
  106.     {
  107.         return $this->render('home/aircargo.html.twig', [
  108.             'controller_name' => 'HomeController',
  109.         ]);
  110.     }
  111.     #[Route('/social-development'name'app_home_socialdevelopment')]
  112.     public function socialdevelopment(): Response
  113.     {
  114.         return $this->render('home/socialdevelopment.html.twig', [
  115.             'controller_name' => 'HomeController',
  116.         ]);
  117.     }
  118.     #[Route('/blog'name'app_home_blog')]
  119.     public function blog(BlogRepository $blogRepository): Response
  120.     {
  121.         $blogs $blogRepository->findBy([], ['id' => 'DESC']);
  122.         
  123.         return $this->render('home/blog.html.twig', [
  124.             'blogs' => $blogs,
  125.         ]);
  126.     }
  127.     #[Route('/blog/{id}/{slug}'name'app_home_blog_details')]
  128.     public function blogDetails(Blog $blogBlogRepository $blogRepository): Response
  129.     {
  130.         $blogs $blogRepository->findBy([], ['id' => 'DESC'], 8);
  131.         return $this->render('home/blogDetails.html.twig', [
  132.             'blog' => $blog,
  133.             'blogs' => $blogs,
  134.         ]);
  135.     }
  136.     #[Route('/fuel-surcharge'name'app_home_fuelsurcharge')]
  137.     public function fuelsurcharge(SettingsInfoRepository $SettingsInfoRepository): Response
  138.     {
  139.         // Get today's date
  140.         $today = new \DateTime();
  141.         // Set the day to 1 to get the first date of the month
  142.         $firstDateOfMonth = (clone $today)->modify('first day of this month');
  143.         // Calculate the date three months before
  144.         $beforeThreeMonth = (clone $firstDateOfMonth)->modify('-3 months');
  145.         $fscValues $SettingsInfoRepository->findByDataforWebsiteFSC(2$beforeThreeMonth$today);
  146.         $fscValuesGroup $SettingsInfoRepository->findByDataforWebsiteFSCGroupBy(2$beforeThreeMonth$today);
  147.        
  148.         return $this->render('home/fuelsurcharge.html.twig', [
  149.             'fscValues' => $fscValues,
  150.             'fscValuesGroup' => $fscValuesGroup,
  151.         ]);
  152.     }
  153.          
  154.     #[Route('/volumetric-weight'name'app_home_volumetricweight')]
  155.     public function volumetricweight(): Response
  156.     {
  157.         return $this->render('home/volumetricweight.html.twig', [
  158.             'controller_name' => 'HomeController',
  159.         ]);
  160.     }
  161.    
  162.     #[Route('/contact'name'app_home_contact')]
  163.     public function contact(Request $requestMailerInterface $mailer): Response
  164.     {
  165.         $confactform $this->createFormBuilder(null)  
  166.             ->add('fullName'TextType::class, [               
  167.                 'label' => false,
  168.                 'attr' => ['placeholder' => 'Enter Full Name',],  
  169.                 ])
  170.         
  171.             ->add('email'TextType::class, [              
  172.                 'label' => false,
  173.                 'attr' => ['placeholder' => 'Enter Email',],     
  174.                 ])
  175.             ->add('contactno'TextType::class, [               
  176.                     'label' => false,
  177.                     'attr' => [ 'placeholder' => 'Enter Phone',],  
  178.                     ])
  179.             ->add('subject'TextType::class, [               
  180.                         'label' => false,
  181.                         'attr' => ['placeholder' => 'Enter Subject',],    
  182.                         ])
  183.             ->add('message'TextareaType::class, [            
  184.                 'label' => false,
  185.                 'attr' => ['cols' => '85''rows' => '3','placeholder' => 'Enter Message...',],     
  186.                 ])        
  187.             ->getForm();
  188.         $confactform->handleRequest($request);
  189.      
  190.         if ($confactform->isSubmitted() && $confactform->isValid()) {
  191.            
  192.             $fullName =  $confactform->get('fullName')->getData();
  193.             $email =  $confactform->get('email')->getData();
  194.             $contactno =  $confactform->get('contactno')->getData();
  195.             $subject =  $confactform->get('subject')->getData();
  196.             $message =  $confactform->get('message')->getData();
  197.                                 
  198.             $email = (new Email())
  199.                 ->from('sender@stiexpressbd.com')
  200.                 ->to('salmatradeint07@gmail.com'
  201.                 ->addTo('import.salmatradeint@gmail.com')   
  202.                 ->addTo('mahbub@stiexpressbd.com')            
  203.                 ->cc('info.stiexpressbd@gmail.com')
  204.                 ->addCc('khokan@stiexpressbd.com')
  205.                 ->addCc('info@stiexpressbd.com')
  206.                 //->bcc('malayaroy99@gmail.com')
  207.                 //->replyTo('fabien@example.com')
  208.                 //->priority(Email::PRIORITY_HIGH)
  209.                 ->subject('Email from Contact of stiexpressbd.com Website')
  210.                 ->text('Sending emails is fun again!')
  211.                 ->html('<p> Sender Details Information: </p> <p> <b>Full Name:</b> '.$fullName.'<br> <b>Email:</b> '.$email.' <br> <b>Contact No:</b> '.$contactno.'<br> <b>Subject :</b> '.$subject .'<br><b> Message: </b>'.$message.'</p><p>**The Email is a system-generated email.</p>');
  212.            
  213.             try {
  214.                 $mailer->send($email);
  215.                 $this->addFlash('notice''Email has been sent successfully!');
  216.                 return $this->redirectToRoute('app_home_contact');
  217.             } catch (TransportExceptionInterface $e) {
  218.               
  219.                 $this->addFlash('notice''Email not sent, Please try again.');
  220.                 return $this->redirectToRoute('app_home_contact');
  221.             }
  222.        }
  223.         return $this->render('home/contact.html.twig', [
  224.             'controller_name' => 'HomeController',
  225.             'confactform' => $confactform->createView(),            
  226.         ]);
  227.     }
  228.     #[Route('/quote'name'app_home_quote')]
  229.     public function quote(Request $requestMailerInterface $mailer): Response
  230.     {
  231.         $confactform $this->createFormBuilder(null)  
  232.             ->add('fullName'TextType::class, [               
  233.                 'label' => false,
  234.                 'attr' => ['placeholder' => 'Enter Full Name',],  
  235.                 ])
  236.         
  237.             ->add('email'TextType::class, [              
  238.                 'label' => false,
  239.                 'attr' => ['placeholder' => 'Enter Email',],     
  240.                 ])
  241.             ->add('contactno'TextType::class, [               
  242.                     'label' => false,
  243.                     'attr' => [ 'placeholder' => 'Enter Phone',],  
  244.                     ])
  245.             ->add('subject'TextType::class, [               
  246.                         'label' => false,
  247.                         'attr' => ['placeholder' => 'Enter Subject',],    
  248.                         ])
  249.             ->add('message'TextareaType::class, [            
  250.                 'label' => false,
  251.                 'attr' => ['cols' => '85''rows' => '3','placeholder' => 'Enter Message...',],     
  252.                 ])        
  253.             ->getForm();
  254.         $confactform->handleRequest($request);
  255.     
  256.         if ($confactform->isSubmitted() && $confactform->isValid()) {
  257.         
  258.             $fullName =  $confactform->get('fullName')->getData();
  259.             $email =  $confactform->get('email')->getData();
  260.             $contactno =  $confactform->get('contactno')->getData();
  261.             $subject =  $confactform->get('subject')->getData();
  262.             $message =  $confactform->get('message')->getData();
  263.                                 
  264.             $email = (new Email())
  265.                 ->from('sender@stiexpressbd.com')
  266.                 ->to('salmatradeint07@gmail.com'
  267.                 ->addTo('import.salmatradeint@gmail.com')   
  268.                 ->addTo('mahbub@stiexpressbd.com')            
  269.                 ->cc('info.stiexpressbd@gmail.com')
  270.                 ->addCc('khokan@stiexpressbd.com')
  271.                 ->addCc('info@stiexpressbd.com')
  272.                 //->bcc('malayaroy99@gmail.com')
  273.                 //->replyTo('fabien@example.com')
  274.                 //->priority(Email::PRIORITY_HIGH)
  275.                 ->subject('Email from Contact of stiexpressbd.com Website')
  276.                 ->text('Sending emails is fun again!')
  277.                 ->html('<p> Sender Details Information: </p> <p> <b>Full Name:</b> '.$fullName.'<br> <b>Email:</b> '.$email.' <br> <b>Contact No:</b> '.$contactno.'<br> <b>Subject :</b> '.$subject .'<br><b> Message: </b>'.$message.'</p><p>**The Email is a system-generated email.</p>');
  278.         
  279.             try {
  280.                 $mailer->send($email);
  281.                 $this->addFlash('notice''Email has been sent successfully!');
  282.                 return $this->redirectToRoute('app_home_contact');
  283.             } catch (TransportExceptionInterface $e) {
  284.             
  285.                 $this->addFlash('notice''Email not sent, Please try again.');
  286.                 return $this->redirectToRoute('app_home_contact');
  287.             }
  288.         }
  289.         return $this->render('home/quote.html.twig', [
  290.             'controller_name' => 'HomeController',
  291.             'confactform' => $confactform->createView(),
  292.         ]);
  293.     }
  294.     #[Route('/image-gallery'name'app_home_gallery')]
  295.     public function gallery(ImageGalleryRepository $imageGalleryRepository): Response
  296.     {       
  297.         $image_galleries $imageGalleryRepository->findBy([], ['id' => 'DESC']);
  298.         return $this->render('home/gallery.html.twig', [
  299.             'image_galleries' => $image_galleries,
  300.         ]);
  301.     }
  302.  
  303.     #[Route('/tracking'name'app_home_tracking')]
  304.     public function tracking(CookieService $cookieService): Response
  305.     {
  306.         $beforeAwbno $cookieService->getLastTrackingId();
  307.         return $this->render('home/tracking.html.twig', [
  308.             'controller_name' => 'HomeController',
  309.             'beforeAwbno' => $beforeAwbno,
  310.         ]);
  311.     }
  312.  
  313.     #[Route('/track'name'app_home_tracking_result')]
  314.     public function track(Request $requestShipmentRepository $shipmentRepositoryTrackingUpdateRepository $trackingUpdateRepositoryCookieService $cookieService): Response
  315.     {
  316.         $data $request->request->get('awbNo');    
  317.         
  318.         $shipment $shipmentRepository->findOneBy(['hawbNo' => $data'trackingStatus' => ]);
  319.         if($shipment !== null)
  320.         {
  321.             $response $cookieService->setLastTrackingId($shipment->getHawbNo());           
  322.         }
  323.         else
  324.         {
  325.             $response null;
  326.         }
  327.         $trackingGroupBy $trackingUpdateRepository->findGroupByTrackingUpdate($data);
  328.         $beforeAwbno $cookieService->getLastTrackingId();
  329.                
  330.         return $this->render('home/trackResult.html.twig', [
  331.             'shipments' => $shipment,
  332.             'trackingGroupBy' => $trackingGroupBy,
  333.             'beforeAwbno' => $beforeAwbno,
  334.         ],
  335.         $response );
  336.     }
  337.     #[Route('/{hawbNo}/tracklink'name'app_home_tracking_link')]
  338.     public function trackingResultLink(Shipment $shipmentTrackingUpdateRepository $trackingUpdateRepositoryCookieService $cookieService)
  339.     { 
  340.         $beforeAwbno $cookieService->getLastTrackingId();
  341.         $trackingGroupBy $trackingUpdateRepository->findGroupByTrackingUpdate($shipment->getHawbNo());
  342.         return $this->render('home/trackResult.html.twig', [
  343.             'shipments' => $shipment,
  344.             'trackingGroupBy' => $trackingGroupBy,
  345.             'beforeAwbno' => $beforeAwbno,
  346.         ]);
  347.    
  348.     }
  349. }