src/Controller/Front/AbonnementPro/IndexController.php line 142

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by PhpStorm.
  4.  */
  5. namespace App\Controller\Front\AbonnementPro;
  6. use App\Entity\Abonnement;
  7. use App\Entity\AbonnementPay;
  8. use App\Entity\AbonnementPro;
  9. use App\Entity\BlockPageAbonnementPro;
  10. use App\Entity\CompteAbonnementPro;
  11. use App\Entity\FaqB2b;
  12. use App\Entity\Product;
  13. use App\Services\AbonnementService;
  14. use App\Services\CartService;
  15. use App\Services\CheckoutService;
  16. use App\Services\FactureService;
  17. use App\Services\Notifications;
  18. use App\Services\OrderService;
  19. use Symfony\Component\HttpFoundation\RedirectResponse;
  20. use Symfony\Component\Routing\Annotation\Route;
  21. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  22. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  23. use Twig\Environment;
  24. use Symfony\Component\HttpFoundation\Response;
  25. use Symfony\Component\HttpFoundation\Request;
  26. use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
  27. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  28. use Doctrine\ORM\EntityManagerInterface;
  29. use Symfony\Contracts\Translation\TranslatorInterface;
  30. use App\Services\Liseuse;
  31. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  32. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  33. use App\Services\Compte;
  34. class IndexController extends AbstractController
  35. {
  36.     private $em;
  37.     private $session;
  38.     private $params;
  39.     private $cart_service;
  40.     private $abonnement_service;
  41.     private $facture_service;
  42.     private $notifications;
  43.     private $compte;
  44.     public function __construct(Compte $compte,Notifications $notifications,FactureService $factureService,AbonnementService $abonnement_serviceOrderService $order_service ,CheckoutService $checkout_service,CartService $cart_service,SessionInterface $session,AuthenticationUtils $authenticationUtils  EntityManagerInterface $em,ParameterBagInterface $params)
  45.     {
  46.         $this->em $em;
  47.         $this->session $session;
  48.         $this->params $params;
  49.         $this->cart_service $cart_service;
  50.         $this->checkout_service $checkout_service;
  51.         $this->authenticationUtils $authenticationUtils;
  52.         $this->order_service $order_service;
  53.         $this->abonnement_service $abonnement_service ;
  54.         $this->facture_service $factureService ;
  55.         $this->notifications $notifications ;
  56.         $this->compte $compte ;
  57.     }
  58.     /**
  59.      * @Route("/abonnement-pro/", name="abonnementPro_index")
  60.      */
  61.     public function index(Request $request) : Response
  62.     {
  63.         $abonnement $this->cart_service->checkIsAbonnementPro($this->getUser());
  64.         $myAbonnement false;
  65.         if($abonnement['is_abonnemen_pro']) {
  66.             if (($abonnement['is_abonnemen_pro'] && isset($abonnement['is_admin']) && $abonnement['is_admin'])) {
  67.                 $myAbonnement $abonnement['compte_abonnement_object'];
  68.             }
  69.         }
  70. //        $response = $this->render('front/abonnement-pro/landing-page.html.twig',
  71.         $response $this->render('front/abonnement-pro/landing-page-2.html.twig',
  72.             [
  73.                 'myAbonnement'=>$myAbonnement,
  74.                 'faqs' => $this->em->getRepository(FaqB2b::class)->findActive(),
  75.                 'blockPageAbonnementPro' => $this->em->getRepository(BlockPageAbonnementPro::class)->findOneBy([])
  76.             ]);
  77.         return $response;
  78.     }
  79.     /**
  80.      * @Route("/abonnement-pro/offre", name="abonnementPro_offre")
  81.      */
  82.     public function offrePage(Request $request) : Response
  83.     {
  84.         return $this->redirectToRoute('abonnementPro_adresse_facture',['typeAbonnement'=>AbonnementPro::TYPE_TEAM,'typeComptePaiement'=>1,'isFree'=>1]);
  85. //        $response = $this->render('front/abonnement-pro/offre-page.html.twig');
  86. //        return $response;
  87.     }
  88.     /**
  89.      * @Route("/abonnement-pro/edit-abonnement-to-cart/{typeAbonnement}-{typePay}", name="edit_abonnement_in_cart",options={"expose"=true})
  90.      */
  91.     public function editAbonnementCart(Request $request$typeAbonnement,$typePay): Response
  92.     {
  93.         $cart $this->cart_service->getCartCurrent();
  94.         $abonnement $this->em->getRepository(AbonnementPro::class)->findOneBy(array('typeAbonnement'=>$typeAbonnement));
  95.         $abonnementProCart $cart->getAbonnementProCart();
  96.         if($abonnementProCart){
  97.             $abonnementProCart->setAbonnement($abonnement);
  98.             $abonnementProCart->setCart($cart);
  99.             $abonnementProCart->setAdmin($cart->getCustomer());
  100.             if($abonnementProCart->getPrixTtc() == 0){
  101.                 $abonnementProCart->setTypeComptePaiement(CompteAbonnementPro::PAIEMENT_MENSUEL);
  102.                 $abonnementProCart->setPrixHt(0);
  103.                 $abonnementProCart->setPrixTtc(0);
  104.             }else{
  105.                 $abonnementProCart->setTypeComptePaiement($typePay);
  106.                 if ($typePay == CompteAbonnementPro::PAIEMENT_MENSUEL) {
  107.                     $abonnementProCart->setPrixHt($abonnement->getPrixMensuelHt());
  108.                     $abonnementProCart->setPrixTtc($abonnement->getPrixMensuelTtc());
  109.                 }else{
  110.                     $abonnementProCart->setPrixHt($abonnement->getPrixAnnuelHt());
  111.                     $abonnementProCart->setPrixTtc($abonnement->getPrixAnnuelTtc());
  112.                 }
  113.             }
  114.             $this->em->persist($abonnementProCart);
  115.             $this->em->flush();
  116.             $cart $this->cart_service->updatePriceCart($cart); // update price cart
  117.         }
  118.         //return
  119.         $user $this->getUser();
  120.         $abonnementPro $this->cart_service->checkAbonnementToCartOrOrder($user,$cart->getId());
  121.         $blockProductPanier $this->render('front/checkout/blockPanierMultiple.html.twig', array(
  122.             'cart' => $cart,
  123.             'abonnementPro' => $abonnementPro
  124.         ));
  125.         return $blockProductPanier;
  126.     }
  127.     /**
  128.      * @Route("/tarif-abonnement", name="tarif_abonnement_page")
  129.      */
  130.     public function tarif(Request $request) : Response
  131.     {
  132.         $response $this->render('page/tarif-abonnement.html.twig');
  133.         return $response;
  134.     }
  135.     /**
  136.      * @Route("/newazaza", name="azezessssszzaze")
  137.      */
  138.     public function indqsdex(Request $request) : Response
  139.     {
  140.         $response $this->render('front/b2b/index.html.twig');
  141.         return $response;
  142.     }
  143. }