src/Controller/CompanyAssociationController.php line 65

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Cart;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Doctrine\ORM\EntityManagerInterface;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Entity;
  9. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  10. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
  11. use App\Entity\Company;
  12. use App\Entity\CompanyAssociation;
  13. use App\Entity\CompanyDeposit;
  14. use App\Entity\Product;
  15. use App\Entity\ProductAdjustment;
  16. use App\Entity\Variable;
  17. use App\Service\UserService;
  18. use App\Service\ProductService;
  19. use App\Service\ImageService;
  20. use App\Service\CompanyService;
  21. use App\Service\DistributorService;
  22. use App\Service\PaymentService;
  23. use App\Service\VariableService;
  24. use Sonata\AdminBundle\Form\Type\Filter\NumberType;
  25. use Symfony\Component\Form\Extension\Core\Type\MoneyType;
  26. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  27. use Symfony\Component\Form\Extension\Core\Type\TextType;
  28. use Symfony\Component\HttpFoundation\Response;
  29. class CompanyAssociationController extends AbstractController
  30. {
  31.     /**
  32.      * @Route("/brome-missisquoi")
  33.      *
  34.      * @Template("frontend/associations.html.twig")
  35.      *
  36.      */
  37.     public function tmpBromeRedirect(EntityManagerInterface $entityManagerUserService $userServ){
  38.         // get Brome Missiquoi Association
  39.         $association $entityManager->getRepository(CompanyAssociation::class)->find(3);
  40.         return $this->redirectToRoute('companyAssociationList', [
  41.             'urlName' => $association->getUrlName(),
  42.             'city' => null,
  43.         ]);
  44.     }
  45.     /**
  46.      * @Route(
  47.      *      "/groupe/{urlName}/{city}",
  48.      *      defaults={
  49.      *          "urlName" = null,
  50.      *          "city" = null,
  51.      *      },
  52.      *      name="companyAssociationList",
  53.      *  )
  54.      * @Template("frontend/associations.html.twig")
  55.      */
  56.     public function companyAssociationList(CompanyAssociation $associationnull$city=nullEntityManagerInterface $emUserService $userServ)
  57.     {
  58.         $twigData = array();
  59.         $twigData['title']= 'Les associations';
  60.         $twigData['association'] = $association->getUrlName();
  61.         if($association){
  62.             //We set a var for 2h to stay in this branch
  63.             $userServ->setAssociationUserIsBrowsing($association->getId());
  64.             $twigData['title']= $association->getName();
  65.             if($association->getBanner())
  66.                 $twigData['logoPage']= $association->getBanner();
  67.             if($association->getDescription())
  68.                 $twigData['pageText'] = $association->getDescription();
  69.             $twigData['companies']= $em->getRepository(Company::class)->findByAssociationOrderedByCity($associationurldecode($city));
  70.             $twigData['inCity'] = $city;
  71.             foreach ($twigData['companies'] as $company) {
  72.                 $city $company->getMainLocation()->getCity();
  73.                 //echo $city;
  74.                 if (!isset($twigData['cities'][$city])) {
  75.                     $twigData['cities'][$city] = $city;
  76.                 }
  77.             }
  78.             # if not cities, probably because, no company found , use empty city array
  79.             if(!isset($twigData['cities'])){
  80.                 $twigData['cities'] = [];
  81.             }
  82.         }else{
  83.             $twigData['companies']=
  84.                 $em
  85.                 ->getRepository(Company::class)
  86.                 ->findWithAssociation();
  87.         }
  88.         return $twigData;
  89.     }
  90.     /**
  91.      * @Route("/user/removeAssociation", name="removeAssociationFromBrowsing");
  92.      */
  93.     public function removeAssociation(USerService $userServRequest $request)
  94.     {
  95.         // remove user's association variable
  96.         $userServ->delVariable('showThisAssociationIdOnly''customBrowsing');
  97.         // redirect to home if user is browsing an association page
  98.         $referer $request->headers->get('referer');
  99.         if (strpos($request->headers->get('referer'), 'groupe') !== false){
  100.             //$companyAssociation = explode('/', explode('/groupe/', $referer)[1])[0];
  101.             //$referer = str_replace('/groupe/'.$companyAssociation, '', $referer);
  102.             return $this->redirectToRoute('home');
  103.         }
  104.         // else redirect to current page (like cart or profile)
  105.         return $this->redirect($referer);
  106.     }
  107.     /**
  108.      * @Route({
  109.      *      "fr": "/vendeur/association/ajax_remove_company",
  110.      *      "en": "/seller/association/ajax_remove_company"
  111.      *      },
  112.      *      name="associationProfileConfigAJAXRemoveCompany"
  113.      * )
  114.      * @Security("has_role('ROLE_ADMIN')")
  115.      */
  116.     public function associationProfileConfigAJAXRemoveCompany(UserService $userServRequest $requestEntityManagerInterface $em) {
  117.       $association_id $request->get("association_id");
  118.       $company_id $request->get("company_id");
  119.       $company $em->getRepository(Company::class)->findOneBy(["id"=>$company_id]);
  120.       $association $em->getRepository(CompanyAssociation::class)->findOneBy(["id"=>$association_id]);
  121.       $association->removeCompany($company);
  122.       $em->persist($association);
  123.       $em->flush();
  124.       die(json_encode(["results"=>"OK"]));
  125.     }
  126.     /**
  127.      * @Route({
  128.      *      "fr": "/vendeur/association/ajax_add_company",
  129.      *      "en": "/seller/association/ajax_add_company"
  130.      *      },
  131.      *      name="associationProfileConfigAJAXAddCompany"
  132.      * )
  133.      * @Security("has_role('ROLE_ADMIN')")
  134.      */
  135.     public function associationProfileConfigAJAXAddCompany(UserService $userServRequest $requestEntityManagerInterface $em) {
  136.       $association_id $request->get("association_id");
  137.       $company_id $request->get("company_id");
  138.       $company $em->getRepository(Company::class)->findOneBy(["id"=>$company_id]);
  139.       $association $em->getRepository(CompanyAssociation::class)->findOneBy(["id"=>$association_id]);
  140.       $association->addCompany($company);
  141.       $em->persist($association);
  142.       $em->flush();
  143.       die(json_encode(["results"=>"OK"]));
  144.     }
  145.     /**
  146.      * @Route({
  147.      *      "fr": "/vendeur/association/ajax_search",
  148.      *      "en": "/seller/association/ajax_search"
  149.      *      },
  150.      *      name="associationProfileConfigAJAXSearch"
  151.      * )
  152.      * @Security("has_role('ROLE_ADMIN')")
  153.      */
  154.     public function associationProfileConfigAJAXSearch(UserService $userServRequest $requestEntityManagerInterface $em) {
  155.       $search_query $request->get("term");
  156.       $search_query "%".str_replace(" ""%"trim($search_query))."%";
  157.       $user $userServ->getUser();
  158.       $search_results $em->getRepository(Company::class)->searchByName($search_query$user);
  159.       $results = [];
  160.       foreach($search_results as $result) {
  161.         $results[] = ["id"=>$result->getId(), "text"=>$result->getName()];
  162.       }
  163.       die(json_encode(["results"=>$results]));
  164.     }
  165.     /**
  166.      * @Route({
  167.      *      "fr": "/vendeur/association/editer",
  168.      *      "en": "/seller/association/edit"
  169.      *      },
  170.      *      name="associationProfileConfiguration"
  171.      * )
  172.      * @Security("has_role('ROLE_ADMIN')")
  173.      * @Template("admin/company/association.profile.html.twig")
  174.      */
  175.     public function associationProfileConfiguration(UserService $userServRequest $requestEntityManagerInterface $emCompanyService $companyServImageService $imageServ){
  176.       $twigData = array();
  177.       $twigData['company'] = $userServ->getUser()->getMakeCompanyForAssociation();
  178.       $action $request->get('action');
  179.       if ($action == "update_profile") {
  180.         $company $request->get('company');
  181.         $banner $request->files->get('company')['banner'];
  182.         $image $request->files->get('company')['logo'];
  183.         $CA $em->getRepository(CompanyAssociation::class)->findOneBy(["id"=>$twigData['company']->getId()]);
  184.         $CA->setName($company["name"]);
  185.         $CA->setDescription($company["description"]);
  186.         if(!empty($image)) {
  187.           $imgImage $imageServ->saveUploadedFile($image'company_association'false);
  188.           if($imgImage) {
  189.               $CA->setLogo($imgImage);
  190.           } else {
  191.               $CA->setLogo('reset');
  192.           }
  193.         }
  194.         if(!empty($banner)) {
  195.           $imgBanner $imageServ->saveUploadedFile($banner'company_association_banner'false);
  196.           if($imgBanner) {
  197.               $CA->setBanner($imgBanner);
  198.           } else {
  199.               $CA->setBanner('reset');
  200.           }
  201.         }
  202.         $em->persist($CA);
  203.         $em->flush();
  204.         $twigData['company'] = $CA;
  205.       }
  206.       return $twigData;
  207.     }
  208.     /**
  209.      * @Route({
  210.      *      "fr": "/vendeur/variableAssociation/liste",
  211.      *      "en": "/seller/variableAssociation/list"
  212.      *      },
  213.      *      name="associationVariableList"
  214.      * )
  215.      * @Security("has_role('ROLE_ADMIN')")
  216.      * @Template("admin/company/listVariables.html.twig")
  217.      */
  218.     public function associationVariableList(UserService $userServRequest $requestEntityManagerInterface $emCompanyService $companyServVariableService $variableServ){
  219.         if(empty($userServ->getUser()->getMakeCompanyForAssociation())){
  220.                 $this->addFlash('error'"Vous n'avez pas d'association");
  221.                     return $this->redirectToRoute('dashboard');
  222.         }
  223.         $twigData = array();
  224.         $twigData['company'] = $userServ->getUser()->getMakeCompanyForAssociation();
  225.         $twigData['title'] = "Vos paramètres d'association";
  226.         $twigData['schedule_available_hours'] = [
  227.           '00h00',
  228.           '00h30',
  229.           '01h00',
  230.           '01h30',
  231.           '02h00',
  232.           '02h30',
  233.           '03h00',
  234.           '03h30',
  235.           '04h00',
  236.           '04h30',
  237.           '05h00',
  238.           '05h30',
  239.           '06h00',
  240.           '06h30',
  241.           '07h00',
  242.           '07h30',
  243.           '08h00',
  244.           '08h30',
  245.           '09h00',
  246.           '09h30',
  247.           '10h00',
  248.           '10h30',
  249.           '11h00',
  250.           '11h30',
  251.           '12h00',
  252.           '12h30',
  253.           '13h00',
  254.           '13h30',
  255.           '14h00',
  256.           '14h30',
  257.           '15h00',
  258.           '15h30',
  259.           '16h00',
  260.           '16h30',
  261.           '17h00',
  262.           '17h30',
  263.           '18h00',
  264.           '18h30',
  265.           '19h00',
  266.           '19h30',
  267.           '20h00',
  268.           '20h30',
  269.           '21h00',
  270.           '21h30',
  271.           '22h00',
  272.           '22h30',
  273.           '23h00',
  274.           '23h30',
  275.         ];
  276.         $twigData['schedule_available_days'] = [
  277.           => 'Lundi',
  278.           => 'Mardi',
  279.           => 'Mercredi',
  280.           => 'Jeudi',
  281.           => 'Vendredi',
  282.           => 'Samedi',
  283.           => 'Dimanche',
  284.         ];
  285.         $variables = [
  286.          'orders.canPackUp' => '0',
  287.          'orders.canPickUp' => '0',
  288.          'orders.pickUpSchedule' => [],
  289.          'orders.pickUpScheduleTimes' => [],
  290.          'orders.pickUpScheduleDurations' => [],
  291.          'orders.pickUpScheduleSlotLimits' => [],
  292.          'orders.pickUpScheduleDaysChecked' => [],
  293.          'orders.pickUpAdress' => '',
  294.          'orders.prepareDelay' => '0',
  295.          'orders.packingFixedFee' => '0',
  296.         ];
  297.         $action $request->get('action');
  298.         if ($action == "save_variables") {
  299.           $orders_packingFixedFee $request->get('orders_packingFixedFee');
  300.           $em->getRepository(Variable::class)->saveVariableForAsso(
  301.             $twigData['company'],
  302.             'Frais fixe de montage d\'une commande (cueillette)',
  303.             'orders.packingFixedFee',
  304.             $orders_packingFixedFee
  305.           );
  306.           $orders_prepareDelay $request->get('orders_prepareDelay');
  307.           $em->getRepository(Variable::class)->saveVariableForAsso(
  308.             $twigData['company'],
  309.             'Delais de preparation d\'une commande en jours',
  310.             'orders.prepareDelay',
  311.             $orders_prepareDelay
  312.           );
  313.           $orders_canPickUp $request->get('orders_canPickUp');
  314.           $em->getRepository(Variable::class)->saveVariableForAsso(
  315.             $twigData['company'],
  316.             'Ramassage possible',
  317.             'orders.canPickUp',
  318.             $orders_canPickUp
  319.           );
  320.           $orders_canPackUp $request->get('orders_canPackUp');
  321.           $em->getRepository(Variable::class)->saveVariableForAsso(
  322.             $twigData['company'],
  323.             'Option de montage des commandes',
  324.             'orders.canPackUp',
  325.             $orders_canPackUp
  326.           );
  327.           $orders_pickUpAdress $request->get('orders_pickUpAdress');
  328.           $em->getRepository(Variable::class)->saveVariableForAsso(
  329.             $twigData['company'],
  330.             'Adresse de ramassage',
  331.             'orders.pickUpAdress',
  332.             $orders_pickUpAdress
  333.           );
  334.           $orders_pickUpSchedule $request->get('orders_pickUpSchedule');
  335.           $orders_pickUpScheduleDaysChecked $request->get('orders_pickUpScheduleDaysChecked');
  336.           $orders_pickUpScheduleDuration $request->get('orders_pickUpScheduleDuration');
  337.           $orders_pickUpScheduleSlotLimits $request->get('orders_pickUpScheduleSlotLimits');
  338.           $pickUpSchedule = [];
  339.           $pickUpScheduleDurations = [];
  340.           $pickUpScheduleSlotLimits = [];
  341.           foreach($twigData['schedule_available_days'] as $day_idx => $day_name) {
  342.             if (isset($orders_pickUpScheduleDaysChecked[$day_idx])) {
  343.               if ($orders_pickUpScheduleDaysChecked[$day_idx] == "on") {
  344.                 $pickUpSchedule[$day_idx] = [];
  345.                 $time_start strtotime(date("Y-m-d ").str_replace("h"":"$orders_pickUpSchedule[$day_idx][0]));
  346.                 $time_stop strtotime(date("Y-m-d ").str_replace("h"":"$orders_pickUpSchedule[$day_idx][1]));
  347.                 $minutes 30;
  348.                 if ($orders_pickUpScheduleDuration[$day_idx] == "30") {
  349.                   $minutes 30;
  350.                 }
  351.                 if ($orders_pickUpScheduleDuration[$day_idx] == "60") {
  352.                   $minutes 60;
  353.                 }
  354.                 $pickUpScheduleDurations[$day_idx] = $minutes;
  355.                 $pickUpScheduleSlotLimits[$day_idx] = $orders_pickUpScheduleSlotLimits[$day_idx];
  356.                 $current_time_start $time_start;
  357.                 while ( true ) {
  358.                   $current_time_stop $current_time_start + ( $minutes 60 );
  359.                   $pickUpSchedule[$day_idx][] = [date("H\hi"$current_time_start), date("H\hi"$current_time_stop)];
  360.                   if ( $current_time_stop >= $time_stop ) {
  361.                     break;
  362.                   }
  363.                   $current_time_start $current_time_start + ( $minutes 60 );
  364.                 }
  365.               }
  366.             }
  367.           }
  368.           $pickUpSchedule json_encode($pickUpSchedule);
  369.           $em->getRepository(Variable::class)->saveVariableForAsso(
  370.             $twigData['company'],
  371.             'Horaire de ramassage',
  372.             'orders.pickUpSchedule',
  373.             $pickUpSchedule
  374.           );
  375.           $pickUpScheduleDurations json_encode($pickUpScheduleDurations);
  376.           $em->getRepository(Variable::class)->saveVariableForAsso(
  377.             $twigData['company'],
  378.             'Durée des plages horaires',
  379.             'orders.pickUpScheduleDurations',
  380.             $pickUpScheduleDurations
  381.           );
  382.           $pickUpScheduleSlotLimits json_encode($pickUpScheduleSlotLimits);
  383.           $em->getRepository(Variable::class)->saveVariableForAsso(
  384.             $twigData['company'],
  385.             'Limite de personnes des plages horaires',
  386.             'orders.pickUpScheduleSlotLimits',
  387.             $pickUpScheduleSlotLimits
  388.           );
  389.           $this->addFlash('success'"Vos paramètres on été mise à jour");
  390.         }
  391.         $company_variables $twigData["company"]->getVariables();
  392.         foreach($company_variables as $company_variable) {
  393.           $codeName $company_variable->getCodeName();
  394.           if (isset($variables[$codeName])) {
  395.             $variables[$codeName] = $company_variable->getValue();
  396.             if (
  397.               $codeName == "orders.pickUpSchedule" ||
  398.               $codeName == "orders.pickUpScheduleDurations" ||
  399.               $codeName == "orders.pickUpScheduleSlotLimits"
  400.             ) {
  401.               $variables[$codeName] = json_decode($variables[$codeName], true);
  402.             }
  403.           }
  404.         }
  405.         /* set default values */
  406.         foreach($twigData['schedule_available_days'] as $x => $day) {
  407.           if (!isset($variables["orders.pickUpSchedule"][$x])) {
  408.             $variables["orders.pickUpScheduleTimes"][$x]["time_start"] = "00h00";
  409.             $variables["orders.pickUpScheduleTimes"][$x]["time_stop"] = "00h00";
  410.             $variables["orders.pickUpScheduleDaysChecked"][$x] = false;
  411.           } else {
  412.             $variables["orders.pickUpScheduleDaysChecked"][$x] = true;
  413.             $time_start "23h59";
  414.             $time_stop "00h00";
  415.             foreach($variables["orders.pickUpSchedule"][$x] as $times) {
  416.               if ($times[0] < $time_start) {
  417.                 $time_start $times[0];
  418.               }
  419.               if ($times[1] > $time_stop) {
  420.                 $time_stop $times[1];
  421.               }
  422.             }
  423.             $variables["orders.pickUpScheduleTimes"][$x]["time_start"] = $time_start;
  424.             $variables["orders.pickUpScheduleTimes"][$x]["time_stop"] = $time_stop;
  425.           }
  426.         }
  427.         $twigData["variables"] = $variables;
  428.         return $twigData;
  429.     }
  430.     /**
  431.      * @route({
  432.      *          "fr": "/association/produits/liste/{id}",
  433.      *          "en": "/groupe/product/list/{id}"
  434.      *      },
  435.      *      defaults = {
  436.      *          "id" = false
  437.      *      },
  438.      *      options = { "expose" = true },
  439.      *      name="adminCompanyGroupProductList")
  440.      * @Template("admin/product/companyGroupProductList.html.twig")
  441.      */
  442.     public function listAssociationProducts(ProductService $ProductServiceEntityManagerInterface $emCompanyAssociation $association=nullDistributorService $distributorServUserService $userServ){
  443.       $twigData = array();
  444.       if(empty($association)){
  445.           $user $userServ->getUser();
  446.           $association $user->getMakeCompanyForAssociation();
  447. /*
  448.           if(count($companyAssociation) > 1){
  449.               $this->addFlash('error', "Vous avez plusieur boutiques, pour accéder a l'inventaire via le menu");
  450.               return $this->redirectToRoute('dashboard');
  451.           }else{
  452.               $company = $companies->get(0);
  453.           }
  454. */
  455.       }
  456.       //@SECuritY
  457.       if($this->getUser()->getMakeCompanyForAssociation()->getId() != $association->getId()
  458.           && !($this->getUser()->isGranted('ROLE_ADMIN_MATURIN') && !$this->getUser()->isGranted('ROLE_SUPER_ADMIN'))
  459.       ){
  460.           $this->addFlash('error'"Vous n'avez pas d'accès à cette boutique, veuillez utiliser le menu");
  461.           return $this->redirectToRoute('dashboard');
  462.       }
  463.       /*
  464.        * Conflict with the cart, when a sale occur the quantity change
  465.        * If the producer check the list of product when a order was done but not shipped yet
  466.        * The quantity will reset to the one in Inventory which can make a "sale" happen
  467.        * as quantity is available again
  468.        */
  469.       $twigData['products'] = $em->getRepository(Product::class)
  470.           ->findAllAssociationProducts($association->getId());
  471.       $twigData['association']=$association;
  472.       return $twigData;
  473.   }
  474.   /**
  475.    * @Route({
  476.    *          "fr": "/association/commandes/liste/{id}",
  477.    *          "en": "/sellerGroup/orders/list/{id}",
  478.    *      },
  479.    *      defaults={
  480.    *          "id" = false
  481.    *      },
  482.    *      name="companyGroupOrders")
  483.    *
  484.    * @Security("has_role('ROLE_ADMIN')")
  485.    * @Template("admin/companyGroup/ordersList.html.twig")
  486.    */
  487.   public function companyGroupOrders(CompanyAssociation $association=nullEntityManagerInterface $emUserService $userServRequest $request){
  488.       $twigData = array();
  489.       if(empty($association)){
  490.           $user $userServ->getUser();
  491.           $association $user->getMakeCompanyForAssociation();
  492.       }
  493.       //@SECuritY
  494.       if($this->getUser()->getMakeCompanyForAssociation()->getId() != $association->getId()
  495.           && !($this->getUser()->isGranted('ROLE_ADMIN_MATURIN') && !$this->getUser()->isGranted('ROLE_SUPER_ADMIN'))
  496.       ){
  497.           $this->addFlash('error'"Vous n'avez pas d'accès à cette association, veuillez utiliser le menu");
  498.           return $this->redirectToRoute('dashboard');
  499.       }
  500.       if ($request->getMethod() == 'POST'){
  501.           $orderId = (int)$request->request->get('orderId');
  502.           $cart $em->getRepository(Cart::class)->find($orderId);
  503.           $adjustments = [];
  504.           $orderHasBeenModified=false;
  505.           foreach ($cart->getProducts() as $cp){
  506.               // check if cart product quantity is in request
  507.               $cpId $cp->getId();
  508.               if ($request->request->has($cpId)){
  509.                   $qtConfirmed = (int)$request->request->get($cpId);
  510.                   // check if confirmed quantity is different from original quntity
  511.                   if ($qtConfirmed != $cp->getFinalQuantity()) {
  512.                       // remove BOs if quantity confirmed is order initial quantity
  513. //                        if ($qtConfirmed == $cp->getQuantity()){
  514. //                            foreach ($cp->getProductAdjustments() as $pa){
  515. //                                $em->remove($pa);
  516. //                                $orderHasBeenModified = true;
  517. //                            }
  518. //                            continue;
  519. //                        }
  520.                       // create new adjustment
  521.                       $pa = new ProductAdjustment();
  522.                       $pa->setQuantity($qtConfirmed-$cp->getFinalQuantity());
  523.                       $em->persist($pa);
  524.                       // link adjustment
  525.                       $cp->addProductAdjustment($pa);
  526.                       $adjustments []= $cp;
  527.                   }
  528.                   if ($qtConfirmed 0){
  529.                       $cp->setIsShipped(true);
  530.                   }
  531.                   $em->persist($cp);
  532.               };
  533.           }
  534.           foreach ($cart->getCustomOrders() as $co){
  535.               $shipped true;
  536.               foreach ($co->getItems() as $cp){
  537.                   if (!$cp->getIsShipped()){
  538.                       $shipped false;
  539.                       break;
  540.                   }
  541.               }
  542.               $co->setIsShipped($shipped);
  543.               $em->persist($co);
  544.           }
  545.           // apply changes
  546.           $em->flush();
  547.           if(count($adjustments) > 0){
  548.               $emailSubject 'Produits en rupture de stock sur votre commande '.$cart->getOrderNo();
  549.               $emailBody $this->get('twig')->render('emails/back-order.html.twig', [
  550.                   'cart' => $cart,
  551.                   'user' => $cart->getUser(),
  552.                   'cartProducts' => $adjustments
  553.               ]);
  554.               $destAddress $cart->getUser()->getEmail();
  555.               $userServ->sendEmail($emailSubject$emailBodyfalse$destAddressnulltrue);
  556.               $this->addFlash('success''Commande '.$cart->getOrderNo().' validée !');
  557.               return $this->redirectToRoute('companyGroupOrders', [
  558.                   'id' => $association->getId()
  559.               ]);
  560.           }
  561.       }
  562.       $twigData['orders'] = $em->getRepository(Cart::class)
  563.           ->getCompanyAssociationOrdersQuery($association)
  564.           ->getResult();
  565.       return $twigData;
  566.   }
  567.   /**
  568.    * @Route({
  569.    *          "fr": "/associat/{id}",
  570.    *          "en": "/seller/{id}",
  571.    *      },
  572.    *      defaults={
  573.    *          "id" = false
  574.    *      },
  575.    *      name="associat")
  576.    *
  577.    * @Security ("has_role('ROLE_ADMIN')")
  578.    * 
  579.    */
  580.   public function associatAjax(UserService $userServRequest $requestEntityManagerInterface $em,CompanyAssociation $association=null)
  581.   {
  582.       die();
  583.   }
  584. }