src/IlaveU/Apps/POSBundle/Controller/CartController.php line 168

  1. <?php
  2. namespace App\IlaveU\Apps\POSBundle\Controller;
  3. use App\Entity\LdryOrder;
  4. use App\Entity\LdryTrackOrder;
  5. use App\IlaveU\ShopBundle\Repository\Product\ProductRepository;
  6. use App\IlaveU\Apps\POSBundle\Repository\TableRepository;
  7. use App\IlaveU\ShopBundle\Entity\Customer\Customer;
  8. use App\IlaveU\ShopBundle\Entity\Customer\CustomerWalletPoint;
  9. use App\IlaveU\ShopBundle\Entity\Customer\PackEngagement;
  10. use App\IlaveU\ShopBundle\Entity\Order\Order;
  11. use App\IlaveU\ShopBundle\Entity\Order\OrderItem;
  12. use App\IlaveU\ShopBundle\Entity\Order\OrderItemNote;
  13. use App\IlaveU\ShopBundle\Entity\Shipping\Shipment;
  14. use App\IlaveU\ShopBundle\Entity\Shipping\ShipmentItem;
  15. use App\IlaveU\ShopBundle\Entity\Shipping\StepType;
  16. use App\IlaveU\ShopBundle\Entity\Shipping\TrackingStep;
  17. use App\IlaveU\ShopBundle\Repository\Customer\CustomerRepository;
  18. use App\IlaveU\ShopBundle\Repository\Order\OrderRepository;
  19. use App\IlaveU\ShopBundle\Repository\Payment\PaymentMethodRepository;
  20. use App\IlaveU\ShopBundle\Repository\Product\CategoryProductRepository;
  21. use App\IlaveU\ShopBundle\Repository\Promotion\CouponRepository;
  22. use App\IlaveU\ShopBundle\Repository\Shipping\ShippingMethodRepository;
  23. use App\IlaveU\ShopBundle\Repository\VendorRepository;
  24. use App\Repository\IlaveU\ShopBundle\Entity\Customer\PackRepository;
  25. use App\IlaveU\ShopBundle\Repository\Shipping\CityRegionRepository;
  26. use  App\IlaveU\ShopBundle\Repository\Resource\AgentRepository;
  27. use App\IlaveU\ShopBundle\Service\IlaveUShippingProvider;
  28. use App\IlaveU\ShopBundle\Service\IlaveUShopProvider;
  29. use Doctrine\Persistence\ManagerRegistry;
  30. use Exception;
  31. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  32. use Symfony\Component\HttpFoundation\Request;
  33. use Symfony\Component\HttpFoundation\Response;
  34. use Symfony\Component\Mercure\HubInterface;
  35. use Symfony\Component\Routing\Annotation\Route;
  36. class CartController extends AbstractController
  37. {
  38.     #[Route('/cart'name'pos_cart')]
  39.     /**
  40.      * @Route("/cart", name="pos_cart")
  41.      */
  42.     public function index(
  43.         Request $request,
  44.         ProductRepository $productRepository,
  45.         CategoryProductRepository $categoryProductRepository,
  46.         PaymentMethodRepository $paymentMethodRepository,
  47.         ShippingMethodRepository $shippingMethodRepository,
  48.         AgentRepository $agentRepository,
  49.         OrderRepository $orderRepository,
  50.         VendorRepository $vendorRepository,
  51.         CityRegionRepository $cityRegionRepository
  52.         ): Response
  53.     {
  54.         $order null;
  55.         
  56.         $editOrderIdParam null;
  57.         
  58.         
  59.         if( array_key_exists("routeParams",$request->query->all())){
  60.             $editOrderIdParam $request->query->all()["routeParams"]["editOrderId"];
  61.         }
  62.        
  63.         if($editOrderIdParam){
  64.             $order $orderRepository->find((int)$editOrderIdParam);
  65.         }
  66.         $products $productRepository->findBy(
  67.             ["vendor"=>null,"clonedProduct"=> null ]
  68.         );
  69.         if($this->isGranted("ROLE_VENDOR")){
  70.             $vendor $vendorRepository->findOneBy([
  71.                 "user"=>$this->getUser()
  72.             ]);
  73.             $products $productRepository->findVendorProducts($vendor
  74.             );
  75.         }
  76.         $categories $categoryProductRepository->findAll();
  77.         $paymentMethods $paymentMethodRepository->findBy(["isEnabled"=>true]);
  78.         $shippingMethods $shippingMethodRepository->findAll();
  79.         $agents $agentRepository->findAll();
  80.         $cityRegions $cityRegionRepository->findAll();
  81.         return $this->render('@IlaveU/Apps/POSBundle/templates/cart/index.html.twig', [
  82.             'order'=>$order,
  83.             'products' => $products,
  84.             "categories"=>$categories,
  85.             "paymentMethods"=>$paymentMethods,
  86.             "shippingMethods"=>$shippingMethods,
  87.             "agents"=>$agents,
  88.             "cityRegions"=>$cityRegions
  89.         ]);
  90.     }
  91.     
  92.     #[Route('/cart/checkout'name'pos_cart_checkout')]
  93.     #[Route(path'/cart/checkout'name'pos_cart_checkout')]
  94.     public function pos_cart_checkout(
  95.         ProductRepository $productRepository,
  96.         ShippingMethodRepository $shippingMethodRepository ,
  97.         CustomerRepository $customerRepository ,
  98.         PaymentMethodRepository $paymentMethodRepository ,
  99.         AgentRepository $agentRepository ,
  100.         IlaveUShopProvider $shopProvider,
  101.         OrderRepository $orderRepository,
  102.         CouponRepository $couponRepository,
  103.         CityRegionRepository $cityRegionRepository,
  104.         PackRepository $packRepository,
  105.         IlaveUShippingProvider $ilaveShippingProvider,
  106.         VendorRepository $vendorRepository,
  107.         ManagerRegistry $doctrine,
  108.         HubInterface $hub,
  109.         Request $request): Response
  110.         
  111.     {
  112.         //dd($request->getContentType());
  113.         //$request->request->replace(["test"=>"test"]);
  114.         
  115.         
  116.         if ($request->getContentType() == 'json' and $request->getContent()) {
  117.             $contentJsonRequest json_decode($request->getContent(),true512JSON_THROW_ON_ERROR);
  118.             if($contentJsonRequest){
  119.                 $request->request->replace($contentJsonRequest);
  120.             }else{
  121.                 return $this->json([
  122.                     "status"=>"error","message"=>"Content is not well formated"
  123.                 ]);
  124.             }
  125.             
  126.         }
  127.         
  128.         
  129.         //dd($request->request);
  130.         
  131.         
  132.         $em $doctrine->getManager();
  133.         $editMode false;
  134.         
  135.         
  136.         
  137.         $customer $customerRepository->find((int)$request->request->get("customerId"));
  138.         if($this->isGranted("ROLE_CUSTOMER")){
  139.             $customer $customerRepository->findOneBy(["user"=>$this->getUser()]);
  140.         }
  141.         $shippingMethod $shippingMethodRepository->find((int)$request->request->get("shippingMethod"));
  142.         $agent $agentRepository->find((int)$request->request->get("agent"));
  143.         $paymentMode $paymentMethodRepository->find((int)$request->request->get("paymentMethod"));
  144.         $deliveryType = (string)$request->request->get("deliveryType");
  145.         $coupon $couponRepository->findOneBy(["code"=>$request->request->get("codeCoupon")]);
  146.         $cityRegionCollect $cityRegionRepository->find((int)$request->request->get("cityRegionCollect"));
  147.         $cityRegionShipping $cityRegionRepository->find((int)$request->request->get("cityRegionShipping"));
  148.        
  149.         
  150.         $startProcessingAt = new \DateTime();
  151.         $startDeliveryAt = new \DateTime();
  152.         if($request->request->get("startProcessingAt")){
  153.             $startProcessingAt = new \DateTime($request->request->get("startProcessingAt"));
  154.         }
  155.         if($request->request->get("startDeliveryAt")){
  156.             $startDeliveryAt = new \DateTime($request->request->get("startDeliveryAt"));
  157.         }
  158.         
  159.         
  160.         
  161.         $editOrderIdParam null;
  162.         
  163.         
  164.         if( array_key_exists("routeParams",$request->query->all())){
  165.             $editOrderIdParam $request->query->all()["routeParams"]["editOrderId"];
  166.         }
  167.        
  168.         
  169.         if($request->request->get("editOrderId"))
  170.         {
  171.             $editMode true;
  172.             $order $orderRepository->find((int)$request->request->get("editOrderId"));
  173.             foreach($order->getOrderItems()  as $singleOrderItemToRemove){
  174.                 $order->removeOrderItem($singleOrderItemToRemove);
  175.             }
  176.             foreach($order->getCustomerWalletPoints()  as $singleCustomerWalletPoints){
  177.                 $em->remove($singleCustomerWalletPoints);
  178.             }
  179.         }else{
  180.             $order = new Order();// Instance Object
  181.         }
  182.         
  183.         
  184.         
  185.         //$order->setOldOrderNumber($orderNumberGenerator);
  186.         if($customer){
  187.             $order->setFirstName($customer->getFirstName());
  188.             $order->setLastName($customer->getLastName());
  189.             $order->setEmail((string)$customer->getEmail());
  190.             $order->setCustomer($customer);
  191.             $customer->setDescription((string)$request->request->get("commentCustomer"));
  192.             
  193.         }
  194.            
  195.             
  196.             $order->setEmail((string)$request->request->get("email"));
  197.             
  198.             //dd($couponService);
  199.            
  200.         
  201.         
  202.             if($request->request->get("status")){
  203.                 $order->setStatus((string)$request->request->get("status"));
  204.             }
  205.             if($request->request->get("distance")){
  206.                 $order->setDistance((float)$request->request->get("distance"));
  207.             }
  208.         $order->setStartProcessingAt($startProcessingAt);
  209.         $order->setStartDeliveryAt($startDeliveryAt);
  210.         $order->setTel((string)$request->request->get("telOrder"));
  211.         $order->setCollectTel((string)$request->request->get("collectTelOrder"));
  212.         $order->setCollectAddress((string)$request->request->get("collectAddress"));
  213.         $order->setShippingAddress((string)$request->request->get("shippingAddress"));
  214.         //$order->setNotifyCustomer(boolval($request->request->get("notifyCustomer")) ); hire
  215.          $notifyCustomerParam $request->request->get("notifyCustomer");
  216.         if ($request->request->get("source") === "mobile" && $request->request->get("status") === "draft" && $notifyCustomerParam === null) {
  217.             $order->setNotifyCustomer(true);
  218.         } else {
  219.             $order->setNotifyCustomer(boolval($notifyCustomerParam));
  220.         }
  221.         
  222.         $order->setCollectLng((string)$request->request->get("collectLng"));
  223.         $order->setCollectLat((string)$request->request->get("collectLat"));
  224.         
  225.         $order->setShippingLng((string)$request->request->get("shippingLng"));
  226.         $order->setShippingLat((string)$request->request->get("shippingLat"));
  227.         
  228.         $order->setComment((string)$request->request->get("commentOrder"));
  229.         $order->setOrderType((string)$request->request->get("orderType"));
  230.         $order->setCity("Casablanca");
  231.         $order->setDescription((string)$request->request->get("description"));
  232.         $order->setDepartment("Maarif");
  233.         if($request->request->get("source")){
  234.             $order->setSource((string)$request->request->get("source")); 
  235.         }
  236.         
  237.         $order->setPayedAmount((float)$request->request->get("payedAmount"));
  238.         
  239.         $order->setReduction((float)$request->request->get("reduction"));
  240.         
  241.         $order->setWalletPaymentAmount((float)$request->request->get("walletPaymentAmount"));
  242.         $order->setDeliveryAt($order->getCreatedAt()->format("Y-m-d H:i"));
  243.         $order->setRecoveryAt($order->getCreatedAt()->format("Y-m-d H:i"));
  244.         $order->setDeliveryType($deliveryType);
  245.         if($request->request->get("shippingTips")){
  246.             $order->setShippingTips((float)$request->request->get("shippingTips"));
  247.         }
  248.         
  249.         $order->setAgent($agent);
  250.         $order->setShippingMethod($shippingMethod);
  251.         $order->setPaymentMethod($paymentMode);
  252.         $order->setCityRegionCollect($cityRegionCollect);
  253.         $order->setCityRegionShipping($cityRegionShipping);
  254.         if($this->isGranted("ROLE_VENDOR")){
  255.             $vendor $vendorRepository->findOneBy([
  256.                 "user"=>$this->getUser()
  257.             ]);
  258.             $order->setVendor($vendor);
  259.            
  260.         }
  261.         
  262.         
  263.         $totalPrice 0;
  264.         $orderItemsArray=[];
  265.         if(array_key_exists("orderItems",$request->request->all())){
  266.             $orderItemsArray $request->request->all()["orderItems"];
  267.         }
  268.         
  269.         
  270.         
  271.         if(is_string($orderItemsArray)){
  272.             $orderItemsArray json_decode($orderItemsArray true512JSON_THROW_ON_ERROR);
  273.         }
  274.         
  275.         
  276.         foreach($orderItemsArray as $singleOrderItemCart){
  277.             $reduction 0;
  278.             $orderItem = new OrderItem();// Instance Object
  279.             if (array_key_exists('productType'$singleOrderItemCart)) {
  280.                 if($singleOrderItemCart["productType"] == "subscription"){
  281.                     $pack $packRepository->find((int)$singleOrderItemCart["idProduct"]);
  282.                     $packEngagement = new PackEngagement();
  283.                     $packEngagement->setCustomer($customer);
  284.                     $packEngagement->setPack($pack);
  285.                     $orderItem->setPackEngagement($packEngagement);
  286.     
  287.                 }else{
  288.                     $product $productRepository->find((int)$singleOrderItemCart["idProduct"]);
  289.                     $orderItem->setProduct($product);
  290.                     if($product){
  291.                         $reduction = ($product->getPrice()) - (float)$singleOrderItemCart["price"];
  292.                     }
  293.                     
  294.                 }
  295.             }
  296.             else{
  297.                 $product $productRepository->find((int)$singleOrderItemCart["idProduct"]);
  298.                 $orderItem->setProduct($product);
  299.                 if($product){
  300.                     $reduction = ($product->getPrice()) - (float)$singleOrderItemCart["price"];
  301.                 }
  302.             }
  303.             
  304.             
  305.             
  306.             
  307.             $orderItem->setPrice((float)$singleOrderItemCart["price"]);
  308.             $orderItem->setQuantity((int)$singleOrderItemCart["quantity"]);
  309.             $orderItem->setDescription((string)$singleOrderItemCart["name"]);
  310.             $orderItem->setReduction($reduction);
  311.             $orderItem->setParentOrder($order);
  312.             $order->addOrderItem($orderItem);
  313.             if(array_key_exists("notes",$singleOrderItemCart)){
  314.                 foreach($singleOrderItemCart["notes"] as $singleOrderItemNote ){
  315.                     $orderItemNote = new OrderItemNote();// Instance Object
  316.                     $orderItemNote->setContent($singleOrderItemNote["note"]);
  317.                     $orderItemNote->setOrderItem($orderItem);
  318.                     
  319.                     $em->persist($orderItemNote);
  320.                 }
  321.             }
  322.             
  323.             $totalPrice $totalPrice  + ((float)$singleOrderItemCart["price"] * (int)$singleOrderItemCart["quantity"]);
  324.             $em->persist($orderItem);
  325.             
  326.         }
  327.         $shippingFees $order->getShippingFees();
  328.        
  329.         
  330.         $payedAmount = (float)$request->request->get("payedAmount");
  331.         
  332.         $totalToPay $totalPrice $shippingFees;
  333.         $difference $payedAmount $totalToPay ;
  334.         
  335.         $restAmount 0;
  336.         if($order->getFullRestAmount() < 0){
  337.             $restAmount abs($order->getFullRestAmount());
  338.             $order->setPayedAmount($order->getPayedAmount() + $order->getFullRestAmount());
  339.         }
  340.         
  341.         
  342.         if((boolean)$request->request->get("isRestUsedAsCredit") and $restAmount ){
  343.                 $customerWalletPoint = new CustomerWalletPoint();// Instance Object
  344.                 $customerWalletPoint->setSource("POS");
  345.                 $customerWalletPoint->setCustomer($customer);
  346.                 $customerWalletPoint->setOriginOrder($order);
  347.                 $customerWalletPoint->setPoints($restAmount);
  348.                 $order->addCustomerWalletPoint($customerWalletPoint);
  349.                 //dd( $customerWalletPoint);
  350.                 $em->persist($customerWalletPoint);
  351.         }
  352.         
  353.         //dd($order->getPayedAmount());
  354.         
  355.         if($order->getWalletPaymentAmount() > ){
  356.             $customerWalletPoint = new CustomerWalletPoint();// Instance Object
  357.             $customerWalletPoint->setSource("Website");
  358.             $customerWalletPoint->setCustomer($customer);
  359.             $customerWalletPoint->setOriginOrder($order);
  360.             
  361.             $customerWalletPoint->setPoints(-$order->getWalletPaymentAmount());
  362.             
  363.             $order->addCustomerWalletPoint($customerWalletPoint);
  364.             //dd( $customerWalletPoint);
  365.             $em->persist($customerWalletPoint);
  366.         }
  367.         elseif( $difference 0){
  368.             if((boolean)$request->request->get("isWallet")){
  369.                 $customerWalletPoint = new CustomerWalletPoint();// Instance Object
  370.                 $customerWalletPoint->setSource("POS");
  371.                 $customerWalletPoint->setCustomer($customer);
  372.                 $customerWalletPoint->setOriginOrder($order);
  373.                 $customerWalletPoint->setPoints($difference);
  374.                 $order->addCustomerWalletPoint($customerWalletPoint);
  375.                 //dd( $customerWalletPoint);
  376.                 $em->persist($customerWalletPoint);
  377.                 $difference 0;
  378.             }
  379.             // Or Return real change money to customer 
  380.             
  381.             
  382.         }else{
  383.             if((boolean)$request->request->get("isWallet")){
  384.                 $points 0;
  385.                 foreach($customer->getCustomerWalletPoints() as $singleWalletPoints){
  386.                     $points $points $singleWalletPoints->getPoints();
  387.                 }
  388.                 
  389.                 if( $points  >=  abs($difference)){
  390.                     
  391.                     $totalToPay $totalToPay $points;
  392.                     $customerWalletPointBalance = new CustomerWalletPoint();// Instance Object
  393.                     $customerWalletPointBalance->setSource("POS");
  394.                     $customerWalletPointBalance->setCustomer($customer);
  395.                     $customerWalletPointBalance->setOriginOrder($order);
  396.                     $customerWalletPointBalance->setPoints($difference);
  397.                     $order->addCustomerWalletPoint($customerWalletPointBalance);
  398.                     $em->persist($customerWalletPointBalance);
  399.                 }else{
  400.                     
  401.                     echo '<div class="alert alert-danger" >Solde insufisant : Solde de client <b>'.$customer->getFirstName().' '.$customer->getLastName().'</b> est  '.$points.' DH !</div>';
  402.                     exit;
  403.                 }
  404.                 
  405.             }
  406.         }
  407.         $recieveDate "";
  408.         $deliveryDate "";
  409.         
  410.         
  411.         
  412.         
  413.         $collectDateTimePreview = new \DateTime();
  414.         if($request->request->get("startProcessingAt")){
  415.             $collectDateTimePreview->modify($request->request->get("startProcessingAt"));
  416.         }
  417.         $shippingDateTimePreview = new \DateTime();
  418.         if($request->request->get("startDeliveryAt")){
  419.             $shippingDateTimePreview->modify($request->request->get("startDeliveryAt"));
  420.             //dd($shippingDateTimePreview);
  421.         }
  422.         
  423.         
  424.             $shippingDetailsService $shopProvider->getOrderExtraInfos($order,$collectDateTimePreview,$shippingDateTimePreview,$editMode);
  425.         
  426.         
  427.         $couponService $shopProvider->useCoupon($order,$request->request->get("codeCoupon"));
  428.         if(!$order->getShipment()){
  429.             $shipment $ilaveShippingProvider->createShipment($order);
  430.             $order->setShipment($shipment);
  431.         }
  432.         
  433.         $em->persist($order);
  434.         if($request->request->get("isSimulationPreview") ){
  435.             return $this->render("@IlaveU/Apps/POSBundle/templates/cart/ajaxSimulationOrder.html.twig",["order"=>$order]);
  436.         }
  437.         if($request->request->get("isPromoPreview") ){
  438.             return $this->json($couponService);
  439.         }
  440.         
  441.         if($request->request->get("isChooseDatePreview") ){
  442.             
  443.             //dd($session->get("orderCart"));
  444.             return $this->json($shippingDetailsService);
  445.         }
  446.         if($request->request->get("isReadyForCheckout") ){
  447.             //dd($order);
  448.             //dd($shippingDetailsService);
  449.             
  450.             $session $request->getSession();
  451.             if($request->request->get("statusShipping")){
  452.                 //dd($order->getShipment());
  453.                 if(!$order->getShipment()){
  454.                     $shipment $ilaveShippingProvider->createShipment($order);
  455.                     $order->setShipment($shipment);
  456.                 }
  457.                     
  458.                 $trackingStep = new TrackingStep();
  459.                 $stepType $em->getRepository(StepType::class)->findOneBy(["code"=>$request->request->get("statusShipping")]);
  460.                 $trackingStep->setStepType($stepType);
  461.                 $trackingStep->setIsCompleted(true);
  462.                 $trackingStep->setShipment($order->getShipment());
  463.                 $order->getShipment()->addTrackingStep($trackingStep);
  464.                 $order->setStatusShipping($request->request->get("statusShipping"));
  465.                 $em->persist($order->getShipment());
  466.                 $em->persist($trackingStep);
  467.             }
  468.             // if($order->getFullRestAmount() == 0 or $order->getStatus() == "paid" ){
  469.             //     $order->setStatus("paid");
  470.             //     if($order->getFullRestAmount() > 0){
  471.             //         $order->setPayedAmount($order->getFullRestAmount());
  472.             //     }
  473.             // }else{
  474.                 
  475.             // }
  476.             // $order->setPayedAmount($order->getFullRestAmount());
  477.             // $order->setStatus("waiting");
  478.             $em->persist($order);
  479.             
  480.             $em->flush();
  481.             $this->addFlash("success","Votre commande a été enregistrée avec succès!");
  482.             $session->set("orderCart",$order->getId());
  483.             return $this->json([
  484.                 "status"=>"success",
  485.                 "orderId"=>$order->getId()
  486.             ]);
  487.         }
  488.         
  489.        
  490.         
  491.         
  492.         $em->flush();
  493.     
  494.         $request->getSession()->remove("orderStartProcessingAt");
  495.         if ($request->getContentType() == 'json') {
  496.             return $this->json([
  497.                 "status"=>"success",
  498.                 "orderId"=>$order->getId(),
  499.                 "message"=>"Commande ".$order->getOrderNumber()." Crée avec succès !"
  500.             ]);
  501.         }
  502.         return $this->render('@IlaveU/Apps/POSBundle/templates/cart/ajaxSuccessOrder.html.twig',[
  503.             "editOrderId"=>$request->request->get("editOrderId")
  504.         ]);
  505.     }
  506.     #[Route('/cart/create-customer'name'pos_cart_create_customer')]
  507.     /**
  508.      * @Route("/cart/create-customer", name="pos_cart_create_customer")
  509.      */
  510.     public function pos_cart_create_customer(
  511.         ProductRepository $productRepository,
  512.         CustomerRepository $customerRepository ,
  513.         VendorRepository $vendorRepository,
  514.         ManagerRegistry $doctrine,
  515.         Request $request): Response
  516.     {
  517.         $em $doctrine->getManager();
  518.         $firstName $request->request->get("firstName");
  519.         $lastName $request->request->get("lastName");
  520.         $email $request->request->get("Email");
  521.         $phone $request->request->get("phone");
  522.         $address $request->request->get("address");
  523.         $customer = new Customer();
  524.         $customer->setFirstName($firstName);
  525.         $customer->setLastName($lastName);
  526.         $customer->setEmail($email);
  527.         $customer->setPhone($phone);
  528.         $customer->setAddress($address);
  529.         if($this->isGranted("ROLE_VENDOR")){
  530.             $vendor $vendorRepository->findOneBy([
  531.                 "user"=>$this->getUser()
  532.             ]);
  533.             $customer->setVendor($vendor);
  534.            
  535.         }
  536.         
  537.         $em->persist($customer);
  538.         $em->flush();
  539.         return $this->redirectToRoute("select_customer_ajax");
  540.     }
  541.     #[Route('/select-customer-ajax'name'select_customer_ajax')]
  542.     /**
  543.      * @Route("/select-customer-ajax", name="select_customer_ajax")
  544.      */
  545.     public function select_customer_ajax(CustomerRepository $customerRepository,VendorRepository $vendorRepository): Response
  546.     {
  547.         $customers $customerRepository->findBy([],["id"=>"DESC"]);
  548.         if($this->isGranted("ROLE_VENDOR")){
  549.             $vendor $vendorRepository->findOneBy([
  550.                 "user"=>$this->getUser()
  551.             ]);
  552.             
  553.             $customers $customerRepository->findBy(["vendor"=>$vendor],["id"=>"DESC"]);
  554.         }
  555.         return $this->render('@IlaveU/Apps/POSBundle/templates/cart/ajaxSelectFormCustomer.html.twig', [
  556.             'customers' => $customers,
  557.         ]);
  558.     }
  559.     #[Route('/tables'name'tables')]
  560.     /**
  561.      * @Route("/tables", name="tables")
  562.      */
  563.     public function tables(TableRepository $tableRepository): Response
  564.     {
  565.         $tables $tableRepository->findAll();
  566.         return $this->render('@IlaveU/Apps/POSBundle/templates/cart/tables.html.twig', [
  567.             'tables' => $tables,
  568.         ]);
  569.     }
  570.     
  571. }