src/Controller/MarketPlace/TarifModeLivraisonController.php line 25

Open in your IDE?
  1. <?php
  2. namespace App\Controller\MarketPlace;
  3. use App\Entity\MarketPlace\ArticleMarketPlace;
  4. use App\Entity\MarketPlace\TarifModeLivraison;
  5. use App\Form\MarketPlace\ProfilType;
  6. use App\Library\Datatable\Util\Datatable;
  7. use Doctrine\ORM\EntityManagerInterface;
  8. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  9. use Symfony\Component\HttpFoundation\Request;
  10. use Symfony\Component\HttpFoundation\Response;
  11. use Symfony\Component\Routing\Annotation\Route;
  12. use Symfony\Component\Validator\Validator\ValidatorInterface;
  13. use Symfony\Contracts\Translation\TranslatorInterface;
  14. //use DTC\ArticlesBundle\Form\SupprimerMarketPlaceType;
  15. class TarifModeLivraisonController extends AbstractController
  16. {
  17.     /**
  18.      * @Route("/tarif-mode-livraison/{id}/{type}", name="dtc_tarif_mode_livraison_liste")
  19.      */
  20.     public function listerAction(Request $request$id$type ""$objet ""EntityManagerInterface $emDatatable $datatableTranslatorInterface $translator)
  21.     {
  22.         if ($type == 'articleMarketPlace') {
  23.             $em         $em;
  24.             $repo_objet $em->getRepository(ArticleMarketPlace::class);
  25.             $objet      $repo_objet->find($id);
  26.         }
  27.         $tableau_class_cellule[] = ["className" => "visible_export colonne_id""targets" => [0], "visible" => true"orderable" => true"searchable" => true];
  28.         $tableau_class_cellule[] = ["className" => "visible_export colonne_id""targets" => [1], "visible" => true"orderable" => true"searchable" => true];
  29.         $tableau_class_cellule[] = ["className" => "visible_export colonne_id text-right""targets" => [2], "visible" => true"orderable" => true"searchable" => true];
  30.         $tableau_class_cellule[] = ["className" => "visible_export colonne_id text-right""targets" => [3], "visible" => true"orderable" => true"searchable" => true];
  31.         $this->datatable($datatable$translator$objet$type);
  32.         return $this->render('MarketPlace/TarifModeLivraison/lister.html.twig', ['tableauClassColonne' => $tableau_class_cellule"id" => $id"type" => $type]);
  33.         //return $this->render('Adresses/Adresse/lister.html.twig', array('tableauClassColonne'=>$tableau_class_cellule,"id"=>$id,"type"=>$type));
  34.     }
  35.     /**
  36.      * set datatable configs
  37.      *
  38.      * @return \App\Library\Datatable\Util\Datatable
  39.      */
  40.     private function datatable(Datatable $datatableTranslatorInterface $translator$objet$type "")
  41.     {
  42.         $type_jointure 'x.'.$type;
  43.         $datatable->setDatatableId('dta-tarif-mode-livraison')
  44.                   ->setEntity(TarifModeLivraison::class, "x")
  45.                   ->setFields(
  46.                       [
  47.                           $translator->trans("ID")               => 'x.id',
  48.                           $translator->trans("Code")             => 'x.code',
  49.                           $translator->trans("Frais")            => 'x.frais',
  50.                           $translator->trans("Frais additionel") => 'x.fraisAdditionel',
  51.                           //$translator->trans("Actions") =>  'x.id',
  52.                           "_identifier_"                         => 'x.id',
  53.                       ]
  54.                   )
  55.             //->addJoin('x.ville', 'v', \Doctrine\ORM\Query\Expr\Join::LEFT_JOIN)
  56.                   ->setWhere(
  57.                 $type_jointure.' = :objet ',
  58.                 ['objet' => $objet]
  59.             )
  60.                   ->setRenderers(
  61.                       [
  62.                           => [
  63.                               'view'   => 'FO/DataTable/edit_texte.html.twig',
  64.                               'params' => [
  65.                                   'objet' => TarifModeLivraison::class,
  66.                                   'champ' => 'setFrais',
  67.                                   'debug' => '0',
  68.                               ],
  69.                           ],
  70.                           => [
  71.                               'view'   => 'FO/DataTable/edit_texte.html.twig',
  72.                               'params' => [
  73.                                   'objet' => TarifModeLivraison::class,
  74.                                   'champ' => 'setFraisAdditionel',
  75.                                   'debug' => '0',
  76.                               ],
  77.                           ],
  78.                           /*
  79.                           1 => array(
  80.                             'view' => 'FO/DataTable/actions_modal.html.twig',
  81.                             'params' => array(
  82.                               //'edit_route'  => 'dtc_adresse_modifier',
  83.                               //'supprimer_route'  => 'dtc_adresse_supprimer',
  84.                               'id'    => $objet->getId(),
  85.                               'type'    => $type,
  86.                               'entite'    => 'TarifModeLivraison',
  87.                               'objet' => "DTCMarketPlaceBundle:TarifModeLivraison",
  88.                               'table' => "dta-tarif-mode-livraison",
  89.                             ),
  90.                           ),
  91.                           */
  92.                       ]
  93.                   )
  94.                   ->setOrder("x.id""asc")
  95.                   ->setSearch(true)
  96.                   ->setSearchFields([]);
  97.         return $datatable;
  98.     }
  99.     /**
  100.      * Grid action
  101.      * @return Response
  102.      */
  103.     /**
  104.      * @Route("/tarif-mode-livraison/grid/{id}/{type}", name="dtc_tarif_mode_livraison_liste_grid")
  105.      */
  106.     public function gridAction(Request $request$id ""$type ""EntityManagerInterface $emDatatable $datatableTranslatorInterface $translator)
  107.     {
  108.         if ($type == 'articleMarketPlace') {
  109.             $repo_objet $em->getRepository(ArticleMarketPlace::class);
  110.             $objet      $repo_objet->find($id);
  111.         }
  112.         return $this->datatable($datatable$translator$objet$type)->execute();
  113.     }
  114. }