src/Controller/HomeController.php line 77
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Mime\Email;
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use App\Entity\Shipment;
use App\Entity\Blog;
use App\Repository\ShipmentRepository;
use App\Repository\BlogRepository;
use App\Repository\ImageGalleryRepository;
use App\Repository\TrackingUpdateRepository;
use App\Repository\SettingsInfoRepository;
use App\Service\CookieService;
class HomeController extends AbstractController
{
#[Route('/', name: 'app_home')]
public function index(CookieService $cookieService): Response
{
$beforeAwbno = $cookieService->getLastTrackingId();
return $this->render('home/index.html.twig', [
'controller_name' => 'HomeController',
'beforeAwbno' => $beforeAwbno,
]);
}
#[Route('/about', name: 'app_home_about')]
public function about(): Response
{
return $this->render('home/about.html.twig', [
'controller_name' => 'HomeController',
]);
}
#[Route('/mission-vision', name: 'app_home_mission')]
public function mission(): Response
{
return $this->render('home/mission.html.twig', [
'controller_name' => 'HomeController',
]);
}
#[Route('/team', name: 'app_home_team')]
public function team(): Response
{
return $this->render('home/team.html.twig', [
'controller_name' => 'HomeController',
]);
}
#[Route('/testimonial', name: 'app_home_testimonial')]
public function testimonial(): Response
{
return $this->render('home/testimonial.html.twig', [
'controller_name' => 'HomeController',
]);
}
#[Route('/shipping-guideline', name: 'app_home_guideline')]
public function guideline(): Response
{
return $this->render('home/guideline.html.twig', [
'controller_name' => 'HomeController',
]);
}
#[Route('/terms', name: 'app_home_terms')]
public function terms(): Response
{
return $this->render('home/terms.html.twig', [
'controller_name' => 'HomeController',
]);
}
#[Route('/all-services', name: 'app_home_allservices')]
public function allservices(): Response
{
return $this->render('home/allservices.html.twig', [
'controller_name' => 'HomeController',
]);
}
#[Route('/worldwide-express', name: 'app_home_express')]
public function express(): Response
{
return $this->render('home/express.html.twig', [
'controller_name' => 'HomeController',
]);
}
#[Route('/door-to-door', name: 'app_home_doortodoor')]
public function doortodoor(): Response
{
return $this->render('home/doortodoor.html.twig', [
'controller_name' => 'HomeController',
]);
}
#[Route('/customs-clering', name: 'app_home_customsclering')]
public function customsclering(): Response
{
return $this->render('home/customsclering.html.twig', [
'controller_name' => 'HomeController',
]);
}
#[Route('/air-cargo', name: 'app_home_aircargo')]
public function aircargo(): Response
{
return $this->render('home/aircargo.html.twig', [
'controller_name' => 'HomeController',
]);
}
#[Route('/social-development', name: 'app_home_socialdevelopment')]
public function socialdevelopment(): Response
{
return $this->render('home/socialdevelopment.html.twig', [
'controller_name' => 'HomeController',
]);
}
#[Route('/blog', name: 'app_home_blog')]
public function blog(BlogRepository $blogRepository): Response
{
$blogs = $blogRepository->findBy([], ['id' => 'DESC']);
return $this->render('home/blog.html.twig', [
'blogs' => $blogs,
]);
}
#[Route('/blog/{id}/{slug}', name: 'app_home_blog_details')]
public function blogDetails(Blog $blog, BlogRepository $blogRepository): Response
{
$blogs = $blogRepository->findBy([], ['id' => 'DESC'], 8);
return $this->render('home/blogDetails.html.twig', [
'blog' => $blog,
'blogs' => $blogs,
]);
}
#[Route('/fuel-surcharge', name: 'app_home_fuelsurcharge')]
public function fuelsurcharge(SettingsInfoRepository $SettingsInfoRepository): Response
{
// Get today's date
$today = new \DateTime();
// Set the day to 1 to get the first date of the month
$firstDateOfMonth = (clone $today)->modify('first day of this month');
// Calculate the date three months before
$beforeThreeMonth = (clone $firstDateOfMonth)->modify('-3 months');
$fscValues = $SettingsInfoRepository->findByDataforWebsiteFSC(2, $beforeThreeMonth, $today);
$fscValuesGroup = $SettingsInfoRepository->findByDataforWebsiteFSCGroupBy(2, $beforeThreeMonth, $today);
return $this->render('home/fuelsurcharge.html.twig', [
'fscValues' => $fscValues,
'fscValuesGroup' => $fscValuesGroup,
]);
}
#[Route('/volumetric-weight', name: 'app_home_volumetricweight')]
public function volumetricweight(): Response
{
return $this->render('home/volumetricweight.html.twig', [
'controller_name' => 'HomeController',
]);
}
#[Route('/contact', name: 'app_home_contact')]
public function contact(Request $request, MailerInterface $mailer): Response
{
$confactform = $this->createFormBuilder(null)
->add('fullName', TextType::class, [
'label' => false,
'attr' => ['placeholder' => 'Enter Full Name',],
])
->add('email', TextType::class, [
'label' => false,
'attr' => ['placeholder' => 'Enter Email',],
])
->add('contactno', TextType::class, [
'label' => false,
'attr' => [ 'placeholder' => 'Enter Phone',],
])
->add('subject', TextType::class, [
'label' => false,
'attr' => ['placeholder' => 'Enter Subject',],
])
->add('message', TextareaType::class, [
'label' => false,
'attr' => ['cols' => '85', 'rows' => '3','placeholder' => 'Enter Message...',],
])
->getForm();
$confactform->handleRequest($request);
if ($confactform->isSubmitted() && $confactform->isValid()) {
$fullName = $confactform->get('fullName')->getData();
$email = $confactform->get('email')->getData();
$contactno = $confactform->get('contactno')->getData();
$subject = $confactform->get('subject')->getData();
$message = $confactform->get('message')->getData();
$email = (new Email())
->from('sender@stiexpressbd.com')
->to('salmatradeint07@gmail.com')
->addTo('import.salmatradeint@gmail.com')
->addTo('mahbub@stiexpressbd.com')
->cc('info.stiexpressbd@gmail.com')
->addCc('khokan@stiexpressbd.com')
->addCc('info@stiexpressbd.com')
//->bcc('malayaroy99@gmail.com')
//->replyTo('fabien@example.com')
//->priority(Email::PRIORITY_HIGH)
->subject('Email from Contact of stiexpressbd.com Website')
->text('Sending emails is fun again!')
->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>');
try {
$mailer->send($email);
$this->addFlash('notice', 'Email has been sent successfully!');
return $this->redirectToRoute('app_home_contact');
} catch (TransportExceptionInterface $e) {
$this->addFlash('notice', 'Email not sent, Please try again.');
return $this->redirectToRoute('app_home_contact');
}
}
return $this->render('home/contact.html.twig', [
'controller_name' => 'HomeController',
'confactform' => $confactform->createView(),
]);
}
#[Route('/quote', name: 'app_home_quote')]
public function quote(Request $request, MailerInterface $mailer): Response
{
$confactform = $this->createFormBuilder(null)
->add('fullName', TextType::class, [
'label' => false,
'attr' => ['placeholder' => 'Enter Full Name',],
])
->add('email', TextType::class, [
'label' => false,
'attr' => ['placeholder' => 'Enter Email',],
])
->add('contactno', TextType::class, [
'label' => false,
'attr' => [ 'placeholder' => 'Enter Phone',],
])
->add('subject', TextType::class, [
'label' => false,
'attr' => ['placeholder' => 'Enter Subject',],
])
->add('message', TextareaType::class, [
'label' => false,
'attr' => ['cols' => '85', 'rows' => '3','placeholder' => 'Enter Message...',],
])
->getForm();
$confactform->handleRequest($request);
if ($confactform->isSubmitted() && $confactform->isValid()) {
$fullName = $confactform->get('fullName')->getData();
$email = $confactform->get('email')->getData();
$contactno = $confactform->get('contactno')->getData();
$subject = $confactform->get('subject')->getData();
$message = $confactform->get('message')->getData();
$email = (new Email())
->from('sender@stiexpressbd.com')
->to('salmatradeint07@gmail.com')
->addTo('import.salmatradeint@gmail.com')
->addTo('mahbub@stiexpressbd.com')
->cc('info.stiexpressbd@gmail.com')
->addCc('khokan@stiexpressbd.com')
->addCc('info@stiexpressbd.com')
//->bcc('malayaroy99@gmail.com')
//->replyTo('fabien@example.com')
//->priority(Email::PRIORITY_HIGH)
->subject('Email from Contact of stiexpressbd.com Website')
->text('Sending emails is fun again!')
->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>');
try {
$mailer->send($email);
$this->addFlash('notice', 'Email has been sent successfully!');
return $this->redirectToRoute('app_home_contact');
} catch (TransportExceptionInterface $e) {
$this->addFlash('notice', 'Email not sent, Please try again.');
return $this->redirectToRoute('app_home_contact');
}
}
return $this->render('home/quote.html.twig', [
'controller_name' => 'HomeController',
'confactform' => $confactform->createView(),
]);
}
#[Route('/image-gallery', name: 'app_home_gallery')]
public function gallery(ImageGalleryRepository $imageGalleryRepository): Response
{
$image_galleries = $imageGalleryRepository->findBy([], ['id' => 'DESC']);
return $this->render('home/gallery.html.twig', [
'image_galleries' => $image_galleries,
]);
}
#[Route('/tracking', name: 'app_home_tracking')]
public function tracking(CookieService $cookieService): Response
{
$beforeAwbno = $cookieService->getLastTrackingId();
return $this->render('home/tracking.html.twig', [
'controller_name' => 'HomeController',
'beforeAwbno' => $beforeAwbno,
]);
}
#[Route('/track', name: 'app_home_tracking_result')]
public function track(Request $request, ShipmentRepository $shipmentRepository, TrackingUpdateRepository $trackingUpdateRepository, CookieService $cookieService): Response
{
$data = $request->request->get('awbNo');
$shipment = $shipmentRepository->findOneBy(['hawbNo' => $data, 'trackingStatus' => 1 ]);
if($shipment !== null)
{
$response = $cookieService->setLastTrackingId($shipment->getHawbNo());
}
else
{
$response = null;
}
$trackingGroupBy = $trackingUpdateRepository->findGroupByTrackingUpdate($data);
$beforeAwbno = $cookieService->getLastTrackingId();
return $this->render('home/trackResult.html.twig', [
'shipments' => $shipment,
'trackingGroupBy' => $trackingGroupBy,
'beforeAwbno' => $beforeAwbno,
],
$response );
}
#[Route('/{hawbNo}/tracklink', name: 'app_home_tracking_link')]
public function trackingResultLink(Shipment $shipment, TrackingUpdateRepository $trackingUpdateRepository, CookieService $cookieService)
{
$beforeAwbno = $cookieService->getLastTrackingId();
$trackingGroupBy = $trackingUpdateRepository->findGroupByTrackingUpdate($shipment->getHawbNo());
return $this->render('home/trackResult.html.twig', [
'shipments' => $shipment,
'trackingGroupBy' => $trackingGroupBy,
'beforeAwbno' => $beforeAwbno,
]);
}
}