src/Controller/Articles/CategorieController.php line 567

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Articles;
  3. use App\Entity\Articles\Article;
  4. use App\Entity\Articles\ArticleCategorie;
  5. use App\Entity\Articles\Categorie;
  6. use App\Entity\MarketPlace\ArticleMarketPlace;
  7. use App\Entity\MarketPlace\CompteMarketPlace;
  8. use App\Entity\MarketPlace\MarketPlace;
  9. use App\Entity\Remises\Remise;
  10. use App\Entity\Remises\RemiseCategorieArticle;
  11. use App\Form\Articles\CategorieModalType;
  12. use App\Form\Articles\CategorieType;
  13. use App\Form\Articles\SupprimerCategorieType;
  14. use App\Library\Datatable\Util\Datatable;
  15. use App\Security\Voter\EntityVoter;
  16. use App\Service\FO\Logo;
  17. use App\Service\Utilisateur\ColonneTableauService;
  18. use Doctrine\ORM\EntityManagerInterface;
  19. use JMS\Serializer\SerializerBuilder;
  20. use Knp\Component\Pager\PaginatorInterface;
  21. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  22. use Symfony\Component\HttpFoundation\Request;
  23. use Symfony\Component\HttpFoundation\JsonResponse;
  24. use Symfony\Component\HttpFoundation\Response;
  25. use Symfony\Component\Routing\Annotation\Route;
  26. use Symfony\Component\Validator\Validator\ValidatorInterface;
  27. use Symfony\Contracts\Translation\TranslatorInterface;
  28. class CategorieController extends AbstractController
  29. {
  30.     /**
  31.      * @Route("/categorie/nouveau", name="dtc_categorie_ajouter")
  32.      */
  33.     public function ajouterAction(Request $requestEntityManagerInterface $emLogo $logoServiceValidatorInterface $validatorTranslatorInterface $translator)
  34.     {
  35.         $user      $this->getUser();
  36.         $categorie = new Categorie();
  37.         $categorie->setUtilisateur($user);
  38.         $form   $this->createForm(CategorieType::class, $categorie);
  39.         $errors "";
  40.         $form->handleRequest($request);
  41.         if ($form->isSubmitted()) {
  42.             $tokenP $request->request->get('tokenPicture');
  43.             if ($form->isValid()) {
  44.                 $em->persist($categorie);
  45.                 $em->flush();
  46.                 $logoService->sauvegarder($categorie'categorie'$tokenP);
  47.                 $this->addFlash(
  48.                     'notice',
  49.                     $translator->trans('Catégorie ajoutée avec succès !')
  50.                 );
  51.                 return $this->redirectToRoute('dtc_categorie_liste');
  52.             } else {
  53.                 $errors $validator->validate($categorie);
  54.             }
  55.         }
  56.         return $this->render('Articles/Categorie/ajouter.html.twig', ['form' => $form->createView(), 'errors' => $errors]);
  57.     }
  58.     /**
  59.      * @Route("/categorie/modifier/{id}", name="dtc_categorie_modifier")
  60.      */
  61.     public function modifierAction(Request             $requestCategorie $categorieEntityManagerInterface $emLogo $logoService,
  62.                                    TranslatorInterface $translatorValidatorInterface $validatorDatatable $datatable
  63.     ) {
  64.         $repo_categorie $em->getRepository(Categorie::class);
  65.         $user           $this->getUser();
  66.         $categorie->setUtilisateur($user);
  67.         $form      $this->createForm(CategorieType::class, $categorie);
  68.         $errors    "";
  69.         $errorsSup "";
  70.         $form->handleRequest($request);
  71.         //verifier si la categorie existe
  72.         $refExisteDeja $repo_categorie->refExisteDeja($categorie);
  73.         if ($refExisteDeja) {
  74.             $errorsSup[] = 'Cette référence de catégorie existe déjà!';
  75.         }
  76.         if ($form->isSubmitted()) {
  77.             $droit $this->isGranted(EntityVoter::UPDATECategorie::class);
  78.             if ( ! $droit) {
  79.                 return $this->redirectToRoute('dtc_categorie_modifier', ["id" => $categorie->getId()]);
  80.             }
  81.             if ($form->isValid() && ! $refExisteDeja) {
  82.                 $logoService->sauvegarder($categorie'categorie');
  83.                 $logoService->sauvegarder2($categorie'categorielogo');
  84.                 $em->persist($categorie);
  85.                 $em->flush();
  86.                 if ($this->getParameter('domaine_prestashop') != '') {
  87.                     $categorieParent 1;
  88.                     if (is_object($categorie->getCategorieParent())) {
  89.                         $categorieParent $categorie->getCategorieParent()->getId();
  90.                     }
  91.                     @fopen(
  92.                         'http://'.$this->getParameter('domaine_prestashop').'/67PHEAuaps4P4h3/categories.php?id_category='.$categorie->getId().'&id_category_parent='.$categorieParent,
  93.                         'r'
  94.                     );
  95.                 }
  96.                 $this->addFlash(
  97.                     'notice',
  98.                     $translator->trans('Catégorie sauvegardée avec succès !')
  99.                 );
  100.                 return $this->redirectToRoute('dtc_categorie_modifier', ["id" => $categorie->getId()]);
  101.             } else {
  102.                 $errors $validator->validate($categorie);
  103.             }
  104.         }
  105.         $this->datatableProduits($categorie$datatable$translator);
  106.         $this->datatableRemises($categorie$datatable$translator);
  107.         return $this->render('Articles/Categorie/ajouter.html.twig', ['form' => $form->createView(), 'errors' => $errors'errorsSup' => $errorsSup'categorie' => $categorie]);
  108.     }
  109.     /**
  110.      * @Route("/categorie/{page}", name="dtc_categorie_liste", defaults={"page": 1})
  111.      */
  112.     public function listerAction($pageColonneTableauService $serviceColonneTableau)
  113.     {
  114.         $tableau_class_cellule[] = ["className" => "colonne_id""targets" => [0], "visible" => true"orderable" => false];
  115.         $tableau_class_cellule[] = ["className" => "colonne_id""targets" => [1], "visible" => $serviceColonneTableau->getColonneUtilisateur(Categorie::class, "id")];
  116.         $tableau_class_cellule[] = [
  117.             "className" => "colonne_logo",
  118.             "targets"   => [2],
  119.             "visible"   => $serviceColonneTableau->getColonneUtilisateur(Categorie::class, "logo"),
  120.         ];
  121.         $tableau_class_cellule[] = [
  122.             "className" => "colonne_libelle",
  123.             "targets"   => [3],
  124.             "visible"   => $serviceColonneTableau->getColonneUtilisateur(Categorie::class, "libelle"),
  125.         ];
  126.         $tableau_class_cellule[] = [
  127.             "className" => "colonne_libelle",
  128.             "targets"   => [4],
  129.             "visible"   => $serviceColonneTableau->getColonneUtilisateur(Categorie::class, "parent"),
  130.         ];
  131.         $tableau_class_cellule[] = [
  132.             "className" => "colonne_statut",
  133.             "targets"   => [5],
  134.             "visible"   => $serviceColonneTableau->getColonneUtilisateur(Categorie::class, "statut"),
  135.         ];
  136.         //$this->datatable();
  137.         return $this->render('Articles/Categorie/lister.html.twig', ['name' => 'categorie''tableauClassColonne' => $tableau_class_cellule]);
  138.     }
  139.     /**
  140.      * set datatable configs
  141.      *
  142.      * @return \App\Library\Datatable\Util\Datatable
  143.      */
  144.     private function datatable(Datatable $datatableTranslatorInterface $translator)
  145.     {
  146.         $datatable->setEntity(Categorie::class, "x")
  147.                   ->setFields(
  148.                       [
  149.                           $translator->trans("ID")         => 'x.id',
  150.                           $translator->trans("Logo")       => 'x.logo',
  151.                           $translator->trans("Libellé")    => 'x.libelle',
  152.                           $translator->trans("Parent")     => 'p.libelle',
  153.                           $translator->trans("Statut Web") => 'x.statut',
  154.                           $translator->trans("Actions") => 'x.id',
  155.                           "_identifier_"                => 'x.id',
  156.                       ]
  157.                   )
  158.                   ->addJoin('x.categorieParent''p'\Doctrine\ORM\Query\Expr\Join::INNER_JOIN)
  159.                   ->setRenderers(
  160.                       [
  161.                           => [
  162.                               'view'   => 'FO/DataTable/avec_lien_edit_route.html.twig',
  163.                               'params' => [
  164.                                   'edit_route' => 'dtc_categorie_modifier',
  165.                               ],
  166.                           ],
  167.                           => [
  168.                               'view'   => 'FO/DataTable/logo.html.twig',
  169.                               'params' => [
  170.                                   'edit_route' => 'dtc_categorie_modifier',
  171.                               ],
  172.                           ],
  173.                           => [
  174.                               'view'   => 'FO/DataTable/actions.html.twig',
  175.                               'params' => [
  176.                                   'edit_route' => 'dtc_categorie_modifier',
  177.                                   'objet'      => Categorie::class,
  178.                                   //'ajouterCategorie' => true
  179.                               ],
  180.                           ],
  181.                           => [
  182.                               'view'   => 'FO/DataTable/statut.html.twig',
  183.                               'params' => [
  184.                                   'edit_route' => 'dtc_categorie_changer_statut',
  185.                               ],
  186.                           ],/*
  187.                                 2 => array(
  188.                                     'view' => 'FO/DataTable/edit_texte.html.twig',
  189.                                     'params' => array(
  190.                                             'objet'    => Categorie::class,
  191.                                             'champ'    => 'setLibelle',
  192.                                         ),                               
  193.                                 ),*/
  194.                       ]
  195.                   )
  196.                   ->setMultiple(
  197.                       [
  198.                           'delete' => [
  199.                               'title' => 'Non disponible',
  200.                               'route' => 'dtc_categorie_liste',
  201.                           ],
  202.                       ]
  203.                   )
  204.                   ->setOrder("x.id""desc")
  205.                   ->setSearch(true)
  206.                   ->setSearchFields([23]);
  207.         return $datatable;
  208.     }
  209.     /**
  210.      * @Route("/categorie/grid", name="dtc_categorie_liste_grid")
  211.      */
  212.     public function gridAction(Datatable $datatableTranslatorInterface $translator)
  213.     {
  214.         return $this->datatable($datatable$translator)->execute();
  215.     }
  216.     /**
  217.      * @Route("/categorie/recherche", name="dtc_categorie_recherche")
  218.      */
  219.     public function rechercheAction(Request $requestEntityManagerInterface $emPaginatorInterface $paginator)
  220.     {
  221.         $q      $request->query->get('q');
  222.         $parent $request->query->get('par');
  223.         $repo    $em->getRepository(Categorie::class);
  224.         $results $repo->getRechercheCategorie($q$parent);
  225.         $pagination $paginator->paginate(
  226.             $results/* query NOT result */
  227.             $request->query->getInt('page'1/*page number*/,
  228.             10 /*limit per page*/
  229.         );
  230.         $pagination_results $pagination->getItems();
  231.         $option_placeholde  = ["libelle" => "Sélectionnez""id" => ""];
  232.         if ($request->query->getInt('page'1) == 1) {
  233.             array_unshift($pagination_results$option_placeholde);
  234.         }
  235.         $pagination->setItems($pagination_results);
  236.         $serializer SerializerBuilder::create()->build();
  237.         return JsonResponse::fromJsonString($serializer->serialize($pagination'json'));
  238.     }
  239.     /**
  240.      * @Route("/categorie/statut/{id}", name="dtc_categorie_changer_statut")
  241.      */
  242.     public function changeStatutAction(Categorie $categorieEntityManagerInterface $em)
  243.     {
  244.         if ($categorie->getStatut() == 1) {
  245.             $categorie->setStatut(0);
  246.         } else {
  247.             $categorie->setStatut(1);
  248.         }
  249.         $em->persist($categorie);
  250.         $em->flush();
  251.         $headers = [
  252.             'Content-Type'                 => 'application/json',
  253.             'Access-Control-Allow-Origin'  => '*',
  254.             'Access-Control-Allow-Methods' => 'POST',
  255.         ];
  256.         return new JsonResponse(['data' => '1'], 200$headers);
  257.     }
  258.     //\Doctrine\Common\Util\Debug::dump($tabCategories);
  259.     /**
  260.      * @Route("/checkbox/categorie", name="dtc_categorie_checkbox")
  261.      */
  262.     public function listerCategorieCheckboxAction(Request $requestEntityManagerInterface $em)
  263.     {
  264.         $id                     '';
  265.         $article                = [];
  266.         $repo_article           $em->getRepository(Article::class);
  267.         $repo_categorie         $em->getRepository(Categorie::class);
  268.         $repo_article_categorie $em->getRepository(ArticleCategorie::class);
  269.         $id                     $request->query->get('id');
  270.         $url                    $this->generateUrl('dtc_categorie_checkbox', []);
  271.         if ($request->query->get('article') != '') {
  272.             $article $repo_article->find($request->query->get('article'));
  273.         }
  274.         $categories $repo_categorie->getCategorieEnfant($id);
  275.         $tabCategories = [];
  276.         foreach ($categories as $c) {
  277.             $c['checked']            = 0;
  278.             $c['totalSousCategorie'] = count($repo_categorie->findBy(["categorieParent" => $c]));
  279.             $c['selection']          = 0;
  280.             if (is_object($article) and is_object($repo_article_categorie->findOneBy(['article' => $article'categorie' => $c]))) {
  281.                 $c['checked'] = 1;
  282.             }
  283.             $tabCategories[] = $c;
  284.         }
  285.         $categories $tabCategories;
  286.         if ($request->isXmlHttpRequest()) {
  287.             $rendu $this->renderView('Articles/Categorie/checkbox.html.twig', ['categories' => $categories'article' => $article'url' => $url'objet' => 'article']);
  288.             return new JsonResponse(['rendu' => $rendu]);
  289.         }
  290.         return $this->render('Articles/Categorie/checkbox.html.twig', ['categories' => $categories'article' => $article'url' => $url'objet' => 'article']);
  291.     }
  292.     /**
  293.      * set datatable configs
  294.      *
  295.      * @return \App\Library\Datatable\Util\Datatable
  296.      */
  297.     private function datatableProduits($categorieDatatable $datatableTranslatorInterface $translator)
  298.     {
  299.         $datatable
  300.             ->setDatatableId('dta-produits')
  301.             ->setEntity(Article::class, "x")
  302.             ->setFields(
  303.                 [
  304.                     $translator->trans("ID")              => 'x.id',
  305.                     $translator->trans("Img")             => 'x.reference',
  306.                     $translator->trans("Réf")             => 'x.reference',
  307.                     $translator->trans("Libellé")         => 'x.libelle',
  308.                     $translator->trans("Marque")          => 'm.libelle',
  309.                     $translator->trans("Desc courte")     => 'x.descriptionCourte',
  310.                     $translator->trans("Prix HT")         => 'x.prixVente',
  311.                     $translator->trans("Prix TTC")        => 'x.prixVente',
  312.                     $translator->trans("Marge")           => 'x.marge',
  313.                     $translator->trans("Cump")            => 'x.cpump',
  314.                     $translator->trans("Stock")           => 'x.stock',
  315.                     $translator->trans("Statut Internet") => 'x.statut',
  316.                     $translator->trans("Actions")         => 'x.id',
  317.                     "_identifier_"                        => 'x.id',
  318.                 ]
  319.             )
  320.             ->addJoin('x.articleCategorie''ac'\Doctrine\ORM\Query\Expr\Join::INNER_JOIN)
  321.             ->setWhere(
  322.                 'ac.categorie = :categorie',
  323.                 ['categorie' => $categorie]
  324.             )
  325.             ->addJoin('x.marque''m'\Doctrine\ORM\Query\Expr\Join::LEFT_JOIN)
  326.             ->setRenderers(
  327.                 [
  328.                     => [
  329.                         'view'   => 'FO/DataTable/avec_lien_edit_route.html.twig',
  330.                         'params' => [
  331.                             'edit_route' => 'dtc_article_modifier',
  332.                         ],
  333.                     ],
  334.                     => [
  335.                         'view'   => 'FO/DataTable/image.html.twig',
  336.                         'params' => [
  337.                             'edit_route' => 'dtc_article_modifier',
  338.                         ],
  339.                     ],
  340.                     => [
  341.                         'view'   => 'FO/DataTable/avec_lien_edit_route.html.twig',
  342.                         'params' => [
  343.                             'edit_route' => 'dtc_article_modifier',
  344.                         ],
  345.                     ],
  346.                     => [
  347.                         'view'   => 'FO/DataTable/avec_lien_edit_route.html.twig',
  348.                         'params' => [
  349.                             'edit_route' => 'dtc_article_modifier',
  350.                         ],
  351.                     ],
  352.                     6  => [
  353.                         'view'   => 'FO/DataTable/prixSuivi.html.twig',
  354.                         'params' => [
  355.                             'surveillance' => false,
  356.                         ],
  357.                     ],
  358.                     7  => [
  359.                         'view' => 'FO/DataTable/prix_article_ttc.html.twig',
  360.                     ],
  361.                     8  => [
  362.                         'view' => 'FO/DataTable/prix.html.twig',
  363.                     ],
  364.                     9  => [
  365.                         'view' => 'FO/DataTable/prix.html.twig',
  366.                     ],
  367.                     11 => [
  368.                         'view'   => 'FO/DataTable/statut.html.twig',
  369.                         'params' => [
  370.                             'edit_route' => 'dtc_article_changer_statut',
  371.                         ],
  372.                     ],
  373.                     12 => [
  374.                         'view'   => 'FO/DataTable/actions.html.twig',
  375.                         'params' => [
  376.                             'edit_route'      => 'dtc_article_modifier',
  377.                             'dupliquer_route' => 'dtc_article_dupliquer',
  378.                             'objet'           => Article::class,
  379.                         ],
  380.                     ],
  381.                 ]
  382.             )->setOrder("x.id""desc")
  383.             ->setSearch(true)
  384.             ->setSearchFields([234]);
  385.         //$datatable->setSearchFields(array(0,2));
  386.         return $datatable;
  387.     }
  388.     /**
  389.      * @Route("/categorie/produits/grid/{id}", name="dtc_categorie_produits_liste_grid")
  390.      */
  391.     public function gridProduitsAction(Categorie $categorieDatatable $datatableTranslatorInterface $translator)
  392.     {
  393.         //$this->datatableProduits($categorie);
  394.         return $this->datatableProduits($categorie$datatable$translator)->execute();
  395.     }
  396.     /**
  397.      * set datatable configs
  398.      *
  399.      * @return \App\Library\Datatable\Util\Datatable
  400.      */
  401.     private function datatableRemises($categorieDatatable $datatableTranslatorInterface $translator)
  402.     {
  403.         $datatable
  404.             ->setDatatableId('dta-remises')
  405.             ->setEntity(Remise::class, "x")
  406.             ->setFields(
  407.                 [
  408.                     $translator->trans("ID")      => 'x.id',
  409.                     $translator->trans("Libelle") => 'x.libelle',
  410.                     $translator->trans("Actions") => 'x.id',
  411.                     "_identifier_"                => 'x.id',
  412.                 ]
  413.             )
  414.             ->addJoin('x.remiseCategorieArticle''rca'\Doctrine\ORM\Query\Expr\Join::INNER_JOIN)
  415.             ->setWhere(
  416.                 'rca.categorie = :categorie',
  417.                 ['categorie' => $categorie]
  418.             )
  419.             ->setRenderers(
  420.                 [
  421.                     => [
  422.                         'view'   => 'FO/DataTable/avec_lien_edit_route.html.twig',
  423.                         'params' => [
  424.                             'edit_route' => 'dtc_remise_modifier',
  425.                         ],
  426.                     ],
  427.                     => [
  428.                         'view'   => 'FO/DataTable/actions.html.twig',
  429.                         'params' => [
  430.                             'edit_route' => 'dtc_remise_modifier',
  431.                             'objet'      => Remise::class,
  432.                         ],
  433.                     ],
  434.                 ]
  435.             )
  436.             ->setOrder("x.id""desc")
  437.             ->setSearch(true)
  438.             ->setSearchFields([1]);
  439.         //$datatable->setSearchFields(array(0,2));
  440.         return $datatable;
  441.     }
  442.     /**
  443.      * Grid action
  444.      * @return Response
  445.      */
  446.     /**
  447.      * @Route("/categorie/remises/grid/{id}", name="dtc_categorie_remises_liste_grid")
  448.      */
  449.     public function gridRemisesAction(Categorie $categorieDatatable $datatableTranslatorInterface $translator)
  450.     {
  451.         //$this->datatableRemises($categorie);
  452.         return $this->datatableRemises($categorie$datatable$translator)->execute();
  453.     }
  454.     /**
  455.      * @Route("", name="")
  456.      */
  457.     public function listerCategorieDossierGlobalAction(EntityManagerInterface $em)
  458.     {
  459.         $repo_article           $em->getRepository(Article::class);
  460.         $repo_categorie         $em->getRepository(Categorie::class);
  461.         $repo_article_categorie $em->getRepository(ArticleCategorie::class);
  462.         $repo_compte_market_place $em->getRepository(CompteMarketPlace::class);
  463.         $compteMarketPlace        $repo_compte_market_place->findAll();
  464.         $articleCategories = [];
  465.         //\Doctrine\Common\Util\Debug::dump($articleId);
  466.         $categories $repo_categorie->findBy(['categorieParent' => 1], ['position' => 'ASC']);//CategorieParent
  467.         return $this->render('Articles/Categorie/lister-dossier-global.html.twig', [
  468.             'nbCategoriesEnfant' => [],
  469.             'categories'         => $categories,
  470.             'categoriesArticle'  => $articleCategories,
  471.             'compteMarketPlace'  => $compteMarketPlace,
  472.             'mode'               => '',
  473.             'move'               => true,
  474.         ]);
  475.     }
  476.     /**
  477.      * @Route("", name="")
  478.      */
  479.     public function listerCategorieDossierAction($articleId ''EntityManagerInterface $em)
  480.     {
  481.         $repo_article           $em->getRepository(Article::class);
  482.         $repo_categorie         $em->getRepository(Categorie::class);
  483.         $repo_article_categorie $em->getRepository(ArticleCategorie::class);
  484.         $article           $repo_article->find($articleId);
  485.         $articleCategories = [];
  486.         if (is_object($article)) {
  487.             $categoriesArticle $repo_article_categorie->findBy(['article' => $articleId], ['position' => 'ASC']);
  488.             foreach ($categoriesArticle as $categorieArticle) {
  489.                 $articleCategories[] = $categorieArticle->getCategorie()->getId();
  490.             }
  491.         }
  492.         //\Doctrine\Common\Util\Debug::dump($articleId);
  493.         $categories $repo_categorie->findBy(['categorieParent' => 1], ['position' => 'ASC']);//CategorieParent
  494.         return $this->render('Articles/Categorie/lister-dossier.html.twig', [
  495.             'nbCategoriesEnfant' => [],
  496.             'categories'         => $categories,
  497.             'article'            => $article,
  498.             'categoriesArticle'  => $articleCategories,
  499.             'mode'               => '',
  500.             'move'               => true,
  501.         ]);
  502.     }
  503.     /**
  504.      * @Route("", name="")
  505.      */
  506.     public function listerCategorieDossierRemiseAction($remise nullEntityManagerInterface $em)
  507.     {
  508.         $repo_remise           $em->getRepository(Remise::class);
  509.         $remise                $repo_remise->find($remise);
  510.         $repo_categorie        $em->getRepository(Categorie::class);
  511.         $repo_remise_categorie $em->getRepository(RemiseCategorieArticle::class);
  512.         $nbCategoriesEnfant = [];
  513.         $remiseCategories   = [];
  514.         if (is_object($remise)) {
  515.             //$categoriesRemise = $repo_article_categorie->findByArticle($articleId);
  516.             foreach ($remise->getRemiseCategorieArticle() as $categorieRemise) {
  517.                 $boucler            true;
  518.                 $remiseCategories[] = $categorieRemise->getCategorie()->getId();
  519.                 if (is_object($categorieRemise->getCategorie()->getCategorieParent()) and $categorieRemise->getCategorie()->getCategorieParent()->getId() > 1) {
  520.                     $parent $categorieRemise->getCategorie()->getCategorieParent();
  521.                     while ($boucler) {
  522.                         if ( ! array_key_exists($parent->getId(), $nbCategoriesEnfant)) {
  523.                             $nbCategoriesEnfant[$parent->getId()] = 1;
  524.                         } else {
  525.                             $nbCategoriesEnfant[$parent->getId()]++;
  526.                         }
  527.                         if (is_object($parent->getCategorieParent()) and $parent->getCategorieParent()->getId() > 1) {
  528.                             $parent $parent->getCategorieParent();
  529.                         } else {
  530.                             $boucler false;
  531.                         }
  532.                     }
  533.                 }
  534.             }
  535.         }
  536.         //print_r($nbCategoriesEnfant);
  537.         //\Doctrine\Common\Util\Debug::dump($articleId);
  538.         $categories $repo_categorie->findBy(['categorieParent' => 1], ['libelle' => 'ASC']);//CategorieParent
  539.         return $this->render(
  540.             'Articles/Categorie/lister-dossier-remise.html.twig',
  541.             ['nbCategoriesEnfant' => $nbCategoriesEnfant'categories' => $categories'remise' => $remise'categoriesRemise' => $remiseCategories]
  542.         );
  543.     }
  544.     /**
  545.      * @Route("", name="")
  546.      */
  547.     public function listerCategorieDossierArticleAction(EntityManagerInterface $em$article null$mode "")
  548.     {
  549.         $repo_article           $em->getRepository(Article::class);
  550.         $article                $repo_article->find($article);
  551.         $repo_categorie         $em->getRepository(Categorie::class);
  552.         $repo_article_categorie $em->getRepository(ArticleCategorie::class);
  553.         $nbCategoriesEnfant = [];
  554.         $articleCategories  = [];
  555.         if (is_object($article)) {
  556.             //$categoriesArticle = $repo_article_categorie->findByArticle($articleId);
  557.             foreach ($article->getArticleCategorie() as $categorieArticle) {
  558.                 $boucler             true;
  559.                 $articleCategories[] = $categorieArticle->getCategorie()->getId();
  560.                 if (is_object($categorieArticle->getCategorie()->getCategorieParent()) and $categorieArticle->getCategorie()->getCategorieParent()->getId() > 1) {
  561.                     $parent $categorieArticle->getCategorie()->getCategorieParent();
  562.                     while ($boucler) {
  563.                         if ( ! array_key_exists($parent->getId(), $nbCategoriesEnfant)) {
  564.                             $nbCategoriesEnfant[$parent->getId()] = 1;
  565.                         } else {
  566.                             $nbCategoriesEnfant[$parent->getId()]++;
  567.                         }
  568.                         if (is_object($parent->getCategorieParent()) and $parent->getCategorieParent()->getId() > 1) {
  569.                             $parent $parent->getCategorieParent();
  570.                         } else {
  571.                             $boucler false;
  572.                         }
  573.                     }
  574.                 }
  575.             }
  576.         }
  577.         //print_r($nbCategoriesEnfant);
  578.         //\Doctrine\Common\Util\Debug::dump($articleId);
  579.         $categories $repo_categorie->findBy(['categorieParent' => 1], ['position' => 'ASC']);//CategorieParent
  580.         return $this->render('Articles/Categorie/lister-dossier.html.twig', [
  581.             'nbCategoriesEnfant' => $nbCategoriesEnfant,
  582.             'categories'         => $categories,
  583.             'article'            => $article,
  584.             'categoriesArticle'  => $articleCategories,
  585.             'mode'               => $mode,
  586.         ]);
  587.     }
  588.     /**
  589.      * @Route("/categorie/supprimer/{id}", name="dtc_categorie_supprimer")
  590.      */
  591.     public function supprimerAction(Request $requestCategorie $objetEntityManagerInterface $emValidatorInterface $validatorTranslatorInterface $translator)
  592.     {
  593.         $titre_modal $translator->trans("Demande de confirmation.");
  594.         $user        $this->getUser();
  595.         $message     '';
  596.         $errorsSup   = [];
  597.         //Verifier si la categorie a des produits
  598.         if (count($objet->getArticleCategorie()) > 0) {
  599.             $errorsSup[] = 'La catégorie n\'est pas supprimable car elle contient des produits.';
  600.         }
  601.         //Verifier si la categorie a des categories enfantes
  602.         if (count($objet->getCategoriesEnfant()) > 0) {
  603.             //if ($message != '') $message .= ' ';
  604.             $errorsSup[] = 'La catégorie n\'est pas supprimable car elle contient des catégories enfants';
  605.         }
  606.         $form   $this->createForm(SupprimerCategorieType::class, $objet);
  607.         $errors "";
  608.         $form->handleRequest($request);
  609.         if ($form->isSubmitted() && count($errorsSup) == 0) {
  610.             if ($form->isValid()) {
  611.                 foreach ($objet->getRemiseCategorieArticle() as $remiseCatArticle) {
  612.                     $em->remove($remiseCatArticle);
  613.                 }
  614.                 $em->remove($objet);
  615.                 $em->flush();
  616.                 $this->addFlash('notice'$translator->trans('Catégorie supprimée avec succès !'));
  617.                 $url $this->generateUrl('dtc_categorie_liste');
  618.                 return new JsonResponse(['rendu' => '''valide' => '1''url' => $url]);
  619.             } else {
  620.                 $errors $validator->validate($objet);
  621.                 $rendu  $this->renderView(
  622.                     'Articles/Categorie/supprimer.html.twig',
  623.                     ['form' => $form->createView(), 'errors' => $errors'errorsSup' => $errorsSup'message' => $message]
  624.                 );
  625.                 return new Response(json_encode(['rendu' => $rendu'valide' => '0''url' => '''titre' => $titre_modal]));
  626.             }
  627.         }
  628.         $rendu $this->renderView('Articles/Categorie/supprimer.html.twig', ['form' => $form->createView(), 'errors' => $errors'errorsSup' => $errorsSup'message' => $message]);
  629.         return new Response(json_encode(['rendu' => $rendu'valide' => '0''url' => '''titre' => $titre_modal]));
  630.     }
  631.     /**
  632.      * @Route("/article/categorie/enfants", name="dtc_article_lister_categorie_enfant_liste")
  633.      */
  634.     public function listerCategorieEnfantListeAction(Request $requestEntityManagerInterface $em)
  635.     {
  636.         $id             $request->query->get('id');
  637.         $repo_categorie $em->getRepository(Categorie::class);
  638.         $rendu          "";
  639.         $categories     $repo_categorie->getCategorieEnfant($id);
  640.         $rendu .= '<option value="">Sélectionnez</option>';
  641.         foreach ($categories as $e) {
  642.             $rendu .= '<option value="'.$e['id'].'">';
  643.             $rendu .= $e['libelle'];
  644.             $rendu .= '</option>';
  645.         }
  646.         return new JsonResponse(['rendu' => $rendu]);
  647.     }
  648.     /**
  649.      * @Route("/article/categorie/gerer", name="dtc_gerer_cat")
  650.      */
  651.     public function gererCategorieAction(EntityManagerInterface $em)
  652.     {
  653.         $repo_article $em->getRepository(Article::class);
  654.         $repo_cat $em->getRepository(Categorie::class);
  655.         $repo_cat_article $em->getRepository(ArticleCategorie::class);
  656.         $articles $repo_article->findall();
  657.         foreach ($articles as $article) {
  658.             $articleCat $article->getArticleCategorie();
  659.             foreach ($articleCat as $AC) {
  660.                 if ($AC->getCategorie()->getParent()->getId() == 1) {
  661.                 } else {
  662.                     $newAC = new ArticleCategorie();
  663.                     $newAC->setArticle($article);
  664.                     $newAC->setCategorie($AC->getCategorie()->getParent());
  665.                     $newAC->setPosition(0);
  666.                     echo "nouvelle liasion : ";
  667.                     $em->persist($newAC);
  668.                     $em->flush();
  669.                 }
  670.             }
  671.         }
  672.         return new Response("ok");
  673.     }
  674.     /**
  675.      * @Route("/categorie/changer/positions/ajax", name="dtc_categorie_change_positions")
  676.      */
  677.     public function changerPositionsAjaxAction(Request $requestEntityManagerInterface $emTranslatorInterface $translator)
  678.     {
  679.         $repo_cat $em->getRepository(Categorie::class);
  680.         $errors    = [];
  681.         $positions $request->request->get('positions');
  682.         //var_dump($positions);
  683.         if (count($positions)) {
  684.             foreach ($positions as $key => $position) {
  685.                 $categorie $repo_cat->find($position);
  686.                 if (is_object($categorie)) {
  687.                     $categorie->setPosition($key);
  688.                     $em->persist($categorie);
  689.                 }
  690.             }
  691.             $em->flush();
  692.             $this->addFlash(
  693.                 'notice',
  694.                 $translator->trans('Positions modifiées avec succès !')
  695.             );
  696.         }
  697.         $rendu $this->renderView('layout-errors.html.twig', ['errors' => $errors]);
  698.         return new JsonResponse(['rendu' => $rendu,]);
  699.     }
  700.     /**
  701.      * @Route("/categorie/ajouter/modal", name="dtc_categorie_ajouter_modal")
  702.      */
  703.     public function ajouterModalAction(Request $requestEntityManagerInterface $emLogo $logoServiceTranslatorInterface $translatorValidatorInterface $validator)
  704.     {
  705.         $repo_categorie $em->getRepository(Categorie::class);
  706.         $titre_modal    $translator->trans("Créer une nouvelle catégorie");
  707.         $errors         "";
  708.         $errorsSup      = [];
  709.         $categorie      = new Categorie;
  710.         $parentId $request->query->get('parent');
  711.         if ($parentId == '') {
  712.             $parentId 1;
  713.         }//par defaut le parent est la categorie racine.
  714.         if ($parentId != '') {
  715.             $parent $repo_categorie->find($parentId);
  716.             if (is_object($parent)) {
  717.                 $titre_modal .= ' enfant de '.$parent->getLibelle().'('.$parent->getReference().')';
  718.                 $categorie->setCategorieParent($parent);
  719.             }
  720.         }
  721.         $user $this->getUser();
  722.         $categorie->setUtilisateur($user);
  723.         $form      $this->createForm(CategorieModalType::class, $categorie);
  724.         $form->handleRequest($request);
  725.         //verifier si la categorie existe
  726.         $catTmp $repo_categorie->findBy([
  727.                                               'categorieParent' => $categorie->getCategorieParent(),
  728.                                               'reference'       => $categorie->getReference(),
  729.                                           ]);
  730.         if (count($catTmp) > 0) {
  731.             $errorsSup[] = 'Cette référence de catégorie existe déjà!';
  732.         }
  733.         if ($form->isSubmitted()) {
  734.             if ($form->isValid() && count($catTmp) == 0) {
  735.                 $em->persist($categorie);
  736.                 $em->flush();
  737.                 //print_r($request->request->all());
  738.                 $tokenP $request->request->get('tokenPicture');
  739.                 $logoService->sauvegarder($categorie'categorie'$tokenP);
  740.                 $tokenP $request->request->get('tokenPicture2');
  741.                 $logoService->sauvegarder2($categorie'categorielogo'$tokenP);
  742.                 /*
  743.                 $em->persist($categorie);
  744.         $em->flush();
  745.                  *
  746.                  */
  747.                 /*
  748.               $tokenP = $request->request->get('tokenPicture');
  749.               $this->addFlash(
  750.               'notice',
  751.               $$tokenP
  752.           );
  753.       $logoService->sauvegarder($categorie,'categorie',$tokenP);
  754.                  *
  755.                  */
  756.                 $url $this->generateUrl('dtc_categorie_liste', []);
  757.                 //$url="";
  758.                 $this->addFlash(
  759.                     'notice',
  760.                     $translator->trans('Categorie ajoutée avec succès !')
  761.                 );
  762.                 return new JsonResponse(['rendu' => '''errorsSup' => $errorsSup'valide' => '1''url' => $url'type' => '''libelle' => '']);
  763.             } else {
  764.                 $errors $validator->validate($categorie);
  765.             }
  766.         }
  767.         $rendu $this->renderView(
  768.             'Articles/Categorie/ajouter-modal.html.twig',
  769.             ['form' => $form->createView(), 'errorsSup' => $errorsSup'errors' => $errors'errorsSup' => $errorsSup'categorie' => $categorie]
  770.         );
  771.         return new Response(json_encode(['rendu' => $rendu'valide' => '0''url' => '''titre' => $titre_modal]));
  772.     }
  773.     public function listerCategorieDossierArticleAjaxAction(Request $requestEntityManagerInterface $em$article null$mode ""$mpId ''$compteMarketPlace ''$amp '')
  774.     {
  775.         $get  $request->query->all();
  776.         $type "";
  777.         $s    "";
  778.         if (is_array($get) && array_key_exists('mpid'$get)) {
  779.             $mpId    $get["mpid"];
  780.             $s       $get["sc"];
  781.             $article $get["article"];
  782.             $cmp_id  $get["cmp"];
  783.             $amp     $get["amp"];
  784.             $mode    $get["mode"];
  785.             $repo_article_market_place $em->getRepository(ArticleMarketPlace::class);
  786.             //$articleMarketPlace = $repo_article_market_place->find($amp_id);
  787.             $repo_compte_market_place $em->getRepository(CompteMarketPlace::class);
  788.             $compteMarketPlace        $repo_compte_market_place->find($cmp_id);
  789.             $type                     "recherche";
  790.         }
  791.         //echo "test".$mode;
  792.         $repo_article_market_place $em->getRepository(ArticleMarketPlace::class);
  793.         $repo_market_place         $em->getRepository(MarketPlace::class);
  794.         $marketPlace               $repo_market_place->find($mpId);
  795.         //echo $marketPlace->getLibelle();
  796.         $repo_article $em->getRepository(Article::class);
  797.         $article      $repo_article->find($article);
  798.         $repo_categorie         $em->getRepository(Categorie::class);
  799.         $repo_article_categorie $em->getRepository(ArticleCategorie::class);
  800.         $nbCategoriesEnfant = [];
  801.         $articleCategories  = [];
  802.         if (is_object($compteMarketPlace)) {
  803.             $repo_article_market_place $em->getRepository(ArticleMarketPlace::class);
  804.             //$article = $repo_article_market_place->findOneBy(array("article"=>$article,"compteMarketPlace"=>$compteMarketPlace));
  805.             $article $repo_article_market_place->find($amp);
  806.         }
  807.         $articleMarketPlace $repo_article_market_place->find($amp);
  808.         //echo "AAAA";
  809.         if (is_object($articleMarketPlace)) {
  810.             //echo "BBBBBB";
  811.             //$categoriesArticle = $repo_article_categorie->findByArticle($articleId);
  812.             if (count($articleMarketPlace->getArticleCategorie()) > 0) {
  813.                 foreach ($articleMarketPlace->getArticleCategorie() as $categorieArticle) {
  814.                     //echo "<div>C ".$categorieArticle->getCategorie()->getLibelle()."</div>";
  815.                     $boucler             true;
  816.                     $articleCategories[] = $categorieArticle->getCategorie()->getId();
  817.                     if (is_object($categorieArticle->getCategorie()->getCategorieParent()) and $categorieArticle->getCategorie()->getCategorieParent()->getId() > 1) {
  818.                         $parent $categorieArticle->getCategorie()->getCategorieParent();
  819.                         while ($boucler) {
  820.                             if ( ! array_key_exists($parent->getId(), $nbCategoriesEnfant)) {
  821.                                 $nbCategoriesEnfant[$parent->getId()] = 1;
  822.                             } else {
  823.                                 $nbCategoriesEnfant[$parent->getId()]++;
  824.                             }
  825.                             if (is_object($parent->getCategorieParent()) and $parent->getCategorieParent()->getId() > 1) {
  826.                                 $parent $parent->getCategorieParent();
  827.                             } else {
  828.                                 $boucler false;
  829.                             }
  830.                         }
  831.                     }
  832.                 }
  833.             } else {
  834.                 /*
  835.                 $categorieArticle  = $repo_categorie->find(12928);
  836.                 $boucler = true;
  837.                 $articleCategories[] = $categorieArticle->getId();
  838.                 if(is_object($categorieArticle->getCategorieParent()) and $categorieArticle->getCategorieParent()->getId() > 1) {
  839.                     $parent = $categorieArticle->getCategorieParent();
  840.                     while($boucler) {
  841.                         if(!array_key_exists($parent->getId(), $nbCategoriesEnfant)) $nbCategoriesEnfant[$parent->getId()]=1;
  842.                         else $nbCategoriesEnfant[$parent->getId()]++;
  843.                         if(is_object($parent->getCategorieParent()) and $parent->getCategorieParent()->getId() > 1) {
  844.                             $parent = $parent->getCategorieParent();
  845.                         }
  846.                         else $boucler = false;
  847.                     }
  848.                 }
  849.                 */
  850.                 //$articleCategories[] = 12928;
  851.             }
  852.         } elseif (is_object($article)) {
  853.             //$categoriesArticle = $repo_article_categorie->findByArticle($articleId);
  854.             if (count($article->getArticleCategorie()) > 0) {
  855.                 foreach ($article->getArticleCategorie() as $categorieArticle) {
  856.                     //echo "<div>C ".$categorieArticle->getCategorie()->getLibelle()."</div>";
  857.                     $boucler             true;
  858.                     $articleCategories[] = $categorieArticle->getCategorie()->getId();
  859.                     if (is_object($categorieArticle->getCategorie()->getCategorieParent()) and $categorieArticle->getCategorie()->getCategorieParent()->getId() > 1) {
  860.                         $parent $categorieArticle->getCategorie()->getCategorieParent();
  861.                         while ($boucler) {
  862.                             if ( ! array_key_exists($parent->getId(), $nbCategoriesEnfant)) {
  863.                                 $nbCategoriesEnfant[$parent->getId()] = 1;
  864.                             } else {
  865.                                 $nbCategoriesEnfant[$parent->getId()]++;
  866.                             }
  867.                             if (is_object($parent->getCategorieParent()) and $parent->getCategorieParent()->getId() > 1) {
  868.                                 $parent $parent->getCategorieParent();
  869.                             } else {
  870.                                 $boucler false;
  871.                             }
  872.                         }
  873.                     }
  874.                 }
  875.             }
  876.         }
  877.         //echo "AZERTYU ".$article->getId();
  878.         //print_r($articleCategories);
  879.         //\Doctrine\Common\Util\Debug::dump($articleId);
  880.         //$categories = $repo_categorie->findBy(array('categorieParent'=>1),array('libelle'=>'ASC'));//CategorieParent
  881.         //echo "type".$type;
  882.         if ($type == "recherche") {
  883.             //$rendu =  $this->renderView('Articles/Categorie/lister-dossier-ajax.html.twig', array('nbCategoriesEnfant'=>array(),'categories' =>$categories,'article'=>$article, 'categoriesArticle' => $articleCategories,"marketPlace"=>$marketPlace));
  884.             //return new JsonResponse(array('rendu'=>$rendu), 200, array('Content-Type'=>'application/json'));
  885.             if (is_object($marketPlace)) {
  886.                 $categories $repo_categorie->getCategorieMarketPlace($marketPlace$s);
  887.             } else {
  888.                 $categories $repo_categorie->getCategorieRecherche($s);
  889.             }
  890.             $rendu $this->renderView('Articles/Categorie/lister-dossier-ajax.html.twig', [
  891.                 'nbCategoriesEnfant' => $nbCategoriesEnfant,
  892.                 'categories'         => $categories,
  893.                 'article'            => $article,
  894.                 'categoriesArticle'  => $articleCategories,
  895.                 'marketPlace'        => $marketPlace,
  896.                 'compteMarketPlace'  => $compteMarketPlace,
  897.                 'articleMarketPlace' => $articleMarketPlace,
  898.                 'type'               => $type,
  899.                 'mode'               => $mode,
  900.             ]);
  901.             return new JsonResponse(['rendu' => $rendu]);
  902.         } else {
  903.             $categories $repo_categorie->getCategorieMarketPlace($marketPlace);
  904.             return $this->render('Articles/Categorie/lister-dossier-ajax.html.twig', [
  905.                 'nbCategoriesEnfant' => $nbCategoriesEnfant,
  906.                 'categories'         => $categories,
  907.                 'article'            => $article,
  908.                 'categoriesArticle'  => $articleCategories,
  909.                 'marketPlace'        => $marketPlace,
  910.                 'compteMarketPlace'  => $compteMarketPlace,
  911.                 'articleMarketPlace' => $articleMarketPlace,
  912.                 'type'               => $type,
  913.                 'mode'               => $mode,
  914.             ]);
  915.         }
  916.     }
  917.     /**
  918.      * @Route("/categorie/enfants/{id}", name="dtc_categorie_lister_enfants")
  919.      */
  920.     public function listerCategorieDossierEnfantsAjaxAction(Request $requestCategorie $categorieEntityManagerInterface $em)
  921.     {
  922.         //echo $categorie->getId();
  923.         $articleMarketPlaceId      "";
  924.         $repo_categorie            $em->getRepository(Categorie::class);
  925.         $repo_article              $em->getRepository(Article::class);
  926.         $repo_article_categorie    $em->getRepository(ArticleCategorie::class);
  927.         $repo_article_market_place $em->getRepository(ArticleMarketPlace::class);
  928.         $repo_article_market_place $em->getRepository(ArticleMarketPlace::class);
  929.         $repo_market_place         $em->getRepository(MarketPlace::class);
  930.         $categories $repo_categorie->findBy(["categorieParent" => $categorie]);
  931.         $type          $request->query->get('type');
  932.         $mode          $request->query->get('mode');
  933.         $niveau        intval($request->query->get('niveau')) + 1;
  934.         $articleId     intval($request->query->get('article'));
  935.         $marketPlaceId intval($request->query->get('marketPlaceId'));
  936.         $typecategorie $request->query->get('typecategorie');
  937.         $article "";
  938.         //echo $mode." aid:".$articleId;
  939.         if ($typecategorie != "erp" && $mode != "catArtMp") {
  940.             $article $repo_article_market_place->find($articleId);
  941.         } else {
  942.             $article $repo_article->find($articleId);
  943.         }
  944.         //echo $article->getId();
  945.         $repo_article_market_place $em->getRepository(ArticleMarketPlace::class);
  946.         $repo_market_place         $em->getRepository(MarketPlace::class);
  947.         $articleMarketPlace "";
  948.         if ($marketPlaceId != "" && $articleId != "" && $mode != "catArtMp") {
  949.             $repo_article_market_place $em->getRepository(ArticleMarketPlace::class);
  950.             //$article = $repo_article_market_place->findOneBy(array("article"=>$article,"compteMarketPlace"=>$compteMarketPlace));
  951.             $article $repo_article_market_place->find($articleId);
  952.             $articleMarketPlace   $repo_article_market_place->find($articleId);
  953.             $articleMarketPlaceId $articleMarketPlace->getId();
  954.         }
  955.         $articleCategories  = [];
  956.         $nbCategoriesEnfant = [];
  957.         if (is_object($article)) {
  958.             //$categoriesArticle = $repo_article_categorie->findByArticle($articleId);
  959.             if (count($article->getArticleCategorie()) > 0) {
  960.                 foreach ($article->getArticleCategorie() as $categorieArticle) {
  961.                     $boucler             true;
  962.                     $articleCategories[] = $categorieArticle->getCategorie()->getId();
  963.                     //echo "<div>ART ".$article->getId()." CAT ".$categorieArticle->getCategorie()->getId()."</div>";
  964.                     if (is_object($categorieArticle->getCategorie()->getCategorieParent()) and $categorieArticle->getCategorie()->getCategorieParent()->getId() > 1) {
  965.                         $parent $categorieArticle->getCategorie()->getCategorieParent();
  966.                         while ($boucler) {
  967.                             if ( ! array_key_exists($parent->getId(), $nbCategoriesEnfant)) {
  968.                                 $nbCategoriesEnfant[$parent->getId()] = 1;
  969.                             } else {
  970.                                 $nbCategoriesEnfant[$parent->getId()]++;
  971.                             }
  972.                             if (is_object($parent->getCategorieParent()) and $parent->getCategorieParent()->getId() > 1) {
  973.                                 $parent $parent->getCategorieParent();
  974.                             } else {
  975.                                 $boucler false;
  976.                             }
  977.                         }
  978.                     }
  979.                 }
  980.             } else {
  981.                 /*
  982.                 $categorieArticle  = $repo_categorie->find(12928);
  983.                 $boucler = true;
  984.                 $articleCategories[] = $categorieArticle->getId();
  985.                 if(is_object($categorieArticle->getCategorieParent()) and $categorieArticle->getCategorieParent()->getId() > 1) {
  986.                     $parent = $categorieArticle->getCategorieParent();
  987.                     while($boucler) {
  988.                         if(!array_key_exists($parent->getId(), $nbCategoriesEnfant)) $nbCategoriesEnfant[$parent->getId()]=1;
  989.                         else $nbCategoriesEnfant[$parent->getId()]++;
  990.                         if(is_object($parent->getCategorieParent()) and $parent->getCategorieParent()->getId() > 1) {
  991.                             $parent = $parent->getCategorieParent();
  992.                         }
  993.                         else $boucler = false;
  994.                     }
  995.                 }
  996.                 */
  997.             }
  998.         }
  999.         //print_r($articleCategories);
  1000.         //exit;
  1001.         /*
  1002.         'nbCategoriesEnfant'=>$nbCategoriesEnfant,
  1003.         'categories' =>$categories,
  1004.         'article'=>$article,
  1005.         'categoriesArticle' => $articleCategories,
  1006.         'mode' => $mode,
  1007.         'marketPlace' => $marketPlace,
  1008.         'compteMarketPlace' => $compteMarketPlace,
  1009.         'articleMarketPlace' => $articleMarketPlace,
  1010.         */
  1011.         //echo count($categories);
  1012.         //$rendu = $this->render('Articles/Categorie/lister-dossier-ajax.html.twig', array('nbCategoriesEnfant'=>array(),'categories' =>$categories,'article'=>"", 'categoriesArticle' => "","marketPlace"=>""));
  1013.         $rendu $this->renderView(
  1014.             'Articles/Categorie/lister-dossier-ligne-ajax_1.html.twig',
  1015.             [
  1016.                 'nbCategoriesEnfant'   => $nbCategoriesEnfant,
  1017.                 'niveau'               => $niveau,
  1018.                 'categories'           => $categories,
  1019.                 'ajax'                 => '1',
  1020.                 'mode'                 => $mode,
  1021.                 'parents'              => '',
  1022.                 'parent'               => $categorie->getId(),
  1023.                 'categorie'            => $categorie,
  1024.                 'article'              => $article,
  1025.                 'categoriesArticle'    => $articleCategories,
  1026.                 "marketPlace"          => "",
  1027.                 "marketPlaceId"        => $marketPlaceId,
  1028.                 "articleMarketPlace"   => $articleMarketPlace,
  1029.                 "articleMarketPlaceId" => $articleMarketPlaceId,
  1030.                 "type"                 => $type,
  1031.                 "typecategorie"        => $typecategorie,
  1032.             ]
  1033.         );
  1034.         return new JsonResponse(['rendu' => $rendu]);
  1035.     }
  1036. }