<?php
/**
* Created by PhpStorm.
*/
namespace App\Controller\Front;
use App\Entity\AbonnementPay;
use App\Entity\BesoinProductFavoris;
use App\Entity\BesoinProductPage;
use App\Entity\BesoinProductPageCategory;
use App\Entity\Cart;
use App\Entity\CartDetail;
use App\Entity\CompteAbonnementPro;
use App\Entity\CompteAbonnementProCommandesFactures;
use App\Entity\CompteAbonnementProFacture;
use App\Entity\NosCrea;
use App\Entity\Orders;
use App\Entity\Page\Page;
use App\Entity\Product;
use App\Entity\Stats;
use App\Entity\StuartOrder;
use App\Entity\User;
use App\Entity\UserStripe;
use App\Services\AbonnementService;
use App\Services\AvisVerifiesService;
use App\Services\CartService;
use App\Services\CheckoutService;
use App\Services\FactureService;
use App\Services\MerchPack;
use App\Services\NbDesigner;
use App\Services\Notifications;
use App\Services\OrderService;
use App\Services\ReferalCandyService;
use App\Services\StripeConnect;
use App\Services\StripeConnectTest;
use Spipu\Html2Pdf\Html2Pdf;
use Stripe\Invoice;
use Stripe\Subscription;
use Symfony\Component\Finder\Finder;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Twig\Environment;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use JouwWeb\SendCloud\Client;
use JouwWeb\SendCloud\Model\Address;
use JouwWeb\SendCloud\Model\Parcel;
use JouwWeb\SendCloud\Model\WebhookEvent;
use JouwWeb\SendCloud\Exception\SendCloudRequestException;
use App\Services\SendCloudApi;
use App\Services\DelivreeService;
use Stripe\Stripe;
use Stripe\Customer;
use Stripe\PaymentMethod;
/**
* @Route("/page-20000-templates" )
*/
class PageTemplatesController extends AbstractController
{
private $em;
private $session;
private $cartService;
public function __construct(
ParameterBagInterface $params,
TranslatorInterface $trans,
EntityManagerInterface $em,
CartService $cartService,
NbDesigner $nbDesigner
) {
$this->em = $em;
$this->trans = $trans;
$this->params = $params;
$this->cartService = $cartService;
$this->nbDesigner = $nbDesigner;
}
/**
* @Route("/", name="page_templates_20000")
*/
public function PageTemplates(Request $request) : Response
{
$data = $this->nbDesigner->getBlocksTemplate20000Page();
$response = $this->render('front/page-templates-20000/index.html.twig',['data'=>$data]);
return $response;
}
/**
* @Route("/search", name="search_page_templates",options={"expose"=true})
*/
public function pageTemplatesProduct(Request $request) : Response
{
$requestData = $request->query->get('search');
$data = $this->nbDesigner->searchTemplate20000Page($request,$requestData);
$response = new Response(json_encode($data,true));
return $response;
}
/**
* @Route("/get-blocs-plus", name="page_templates_20000_bloc_plus",options={"expose"=true})
*/
public function PageTemplatesBlocsPlus(Request $request) : Response
{
$data = $this->nbDesigner->getBlocksTemplate20000PagePlus($request);
$response = $this->render('front/page-templates-20000/content-cat.html.twig',['data'=>$data]);
return $response;
}
/**
* @Route("/template-page-crello-add-to-cart/{id}", name="template_page_crollo_add_to_cart",options={"expose"=true})
*/
public function templatePageCrelloAddToCart(Request $request,$id): Response
{
$data = $this->nbDesigner->addToCartNewNbDesignerTemplatePageNosCrea($request,$this->getUser(),$id);
if($data){
$redirect = $this->generateUrl('product_option', array('token'=>$data->getToken(),'product'=>$data->getProduct()->getId()));
}else{
$redirect = $this->generateUrl('besoin_produits');
}
$responce = new Response();
$responce->setContent($redirect);
return $responce;
}
/**
* @Route("/template-page-category-crello-add-to-cart/{id}", name="template_page_category_crollo_add_to_cart",options={"expose"=true})
*/
public function templatePageCategoryCrelloAddToCart(Request $request,$id): Response
{
$data = $this->nbDesigner->addToCartNewNbDesignerTemplatePageCategoryNosCrea($request,$this->getUser(),$id);
if($data){
$redirect = $this->generateUrl('product_option', array('token'=>$data->getToken(),'product'=>$data->getProduct()->getId()));
}else{
$redirect = $this->generateUrl('besoin_produits');
}
$responce = new Response();
$responce->setContent($redirect);
return $responce;
}
}