src/Form/FicheType.php line 318

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. //FOS\CKEditorBundle\Form\Type\CKEditorType
  4. //composer require friendsofsymfony/ckeditor-bundle
  5. use App\Entity\CertificationType;
  6. use App\Entity\DeviceAndTraining;
  7. use App\Entity\Domain;
  8. use App\Entity\EducationLevel;
  9. use App\Entity\Keywords;
  10. use App\Entity\SubDomain;
  11. use App\Entity\TrainingPlace;
  12. use App\Entity\Trainings;
  13. use App\Entity\Type;
  14. use App\Entity\User;
  15. use App\Repository\CertificationTypeRepository;
  16. use App\Repository\DeviceAndTrainingRepository;
  17. use App\Repository\DomainRepository;
  18. use App\Repository\EducationLevelRepository;
  19. use App\Repository\KeywordsRepository;
  20. use App\Repository\SubDomainRepository;
  21. use App\Repository\TrainingPlaceRepository;
  22. use App\Repository\TrainingsRepository;
  23. use App\Repository\TypeRepository;
  24. use App\Repository\UserRepository;
  25. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  26. use Symfony\Component\Form\AbstractType;
  27. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  28. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  29. use Symfony\Component\Form\Extension\Core\Type\DateType;
  30. use Symfony\Component\Form\Extension\Core\Type\IntegerType;
  31. use Symfony\Component\Form\Extension\Core\Type\TextType;
  32. use Symfony\Component\Form\FormBuilderInterface;
  33. use Symfony\Component\OptionsResolver\OptionsResolver;
  34. use Symfony\Component\Security\Core\Security;
  35. use FOS\CKEditorBundle\Form\Type\CKEditorType;
  36. class FicheType extends AbstractType
  37. {
  38.     private $security;
  39.     public function __construct(Security $security)
  40.     {
  41.         $this->security $security;
  42.     }
  43.     public function buildForm(FormBuilderInterface $builder, array $options): void
  44.     {
  45.         $builder
  46.             ->add('ficheTitle'TextType::class, [
  47.                 'label' => 'Titre de la proposition*',
  48.                 'required' => true,
  49.             ])
  50.             ->add('title'TextType::class, [
  51.                 'label' => 'Titre de la fiche*',
  52.                 'required' => true,
  53.             ])
  54.             ->add('subTitle'TextType::class, [
  55.                 'label' => 'Sous-titre',
  56.                 'required' => false,
  57.             ])
  58.             ->add('rncpOrRs'TextType::class, [
  59.                 'label' => 'Enregistré RNCP ou RS',
  60.                 'required' => false
  61.             ])
  62.             ->add('traineeOrEnterprise'TextType::class, [
  63.                 'label' => 'Stagiaire et/ou Entreprise',
  64.                 'required' => false,
  65.             ])
  66.             ->add('code'TextType::class, [
  67.                 'label' => 'Code',
  68.                 'required' => false,
  69.             ])
  70.             ->add('cutInBlocks'CheckboxType::class, [
  71.                 'label' => 'Découpé en blocs',
  72.                 'required' => false,
  73.             ])
  74.             ->add('domain'EntityType::class, [
  75.                 'label' => 'Domaines',
  76.                 'class' => Domain::class,
  77.                 'choice_label' => 'name',
  78.                 'query_builder' => function (DomainRepository $er) {
  79.                     return $er->createQueryBuilder('d')
  80.                         ->orderBy('d.name''ASC');
  81.                 },
  82.                 'attr' => [
  83.                     'class' => 'form-select choices select2',
  84.                 ],
  85.                 'multiple' => true,
  86.                 'required' => false,
  87.             ])
  88.             ->add('subDomain'EntityType::class, [
  89.                 'label' => 'Sous-domaines',
  90.                 'class' => SubDomain::class,
  91.                 'choice_label' => 'name',
  92.                 'query_builder' => function (SubDomainRepository $er) {
  93.                     return $er->createQueryBuilder('s')
  94.                         ->orderBy('s.name''ASC');
  95.                 },
  96.                 'attr' => [
  97.                     'class' => 'form-select choices select2',
  98.                 ],
  99.                 'mapped' => true,
  100.                 'multiple' => true,
  101.                 'required' => false,
  102.             ])
  103.             ->add('new'CheckboxType::class, [
  104.                 'label' => 'Nouveau',
  105.                 'required' => false,
  106.             ])
  107.             ->add('objectives'CKEditorType::class, [
  108.                 'label' => 'Objectifs',
  109.                 'required' => false,
  110.             ])
  111.             ->add('complementaryObjectives'CKEditorType::class, [
  112.                 'label' => 'Objectifs complémentaires',
  113.                 'required' => false,
  114.             ])
  115.             ->add('pedagogicContent'CKEditorType::class, [
  116.                 'label' => 'Contenu pédagogique',
  117.                 'required' => false,
  118.             ])
  119.             ->add('pluses'CKEditorType::class, [
  120.                 'label' => 'Les plus de la formation',
  121.                 'required' => false,
  122.             ])
  123.             ->add('concernedPersons'CKEditorType::class, [
  124.                 'label' => 'Personnes concernées',
  125.                 'required' => false,
  126.             ])
  127.             ->add('prerequisites'CKEditorType::class, [
  128.                 'label' => 'Prérequis',
  129.                 'required' => false,
  130.             ])
  131.             ->add('companyMissions'CKEditorType::class, [
  132.                 'label' => 'Missions en entreprise',
  133.                 'required' => false,
  134.             ])
  135.             ->add('price'TextType::class, [
  136.                 'label' => 'Prix',
  137.                 'required' => false,
  138.             ])
  139.             ->add('time'CKEditorType::class, [
  140.                 'required' => false,
  141.                 'label' => 'Commentaire de durée',
  142.             ])
  143.             ->add('days'IntegerType::class, [
  144.                 'label' => 'Nombre de jours',
  145.                 'required' => false,
  146.             ])
  147.             ->add('hours'IntegerType::class, [
  148.                 'label' => "Nombre d'heures",
  149.                 'required' => false,
  150.             ])
  151.             ->add('date'TextType::class, [
  152.                 'label' => 'Date de la formation',
  153.                 'required' => false,
  154.             ])
  155.             ->add('trainingPlace'EntityType::class, [
  156.                 'label' => 'Lieu de la formation',
  157.                 'class' => TrainingPlace::class,
  158.                 'choice_label' => 'name',
  159.                 'query_builder' => function (TrainingPlaceRepository $trainingPlaceRepository) {
  160.                     return $trainingPlaceRepository->createQueryBuilder('tp')
  161.                         ->orderBy('tp.name''ASC');
  162.                 },
  163.                 'attr' => [
  164.                     'class' => 'form-select choices select2',
  165.                 ],
  166.                 'required' => false,
  167.             ])
  168.             ->add('place'TextType::class, [
  169.                 'label' => 'Lieu de la formation',
  170.                 'required' => false,
  171.             ])
  172.             ->add('deviceAndTraining'EntityType::class, [
  173.                 'label' => 'Dispositif de formation',
  174.                 'class' => DeviceAndTraining::class,
  175.                 'choice_label' => 'name',
  176.                 'query_builder' => function (DeviceAndTrainingRepository $er) {
  177.                     return $er->createQueryBuilder('d')
  178.                         ->orderBy('d.name''ASC');
  179.                 },
  180.                 'attr' => [
  181.                     'class' => 'form-select choices select2',
  182.                 ],
  183.                 'multiple' => true,
  184.                 'required' => false,
  185.             ])
  186.             ->add('termsOfAccess'CKEditorType::class, [
  187.                 'label' => "Modalités d'accès",
  188.                 'required' => false,
  189.             ])
  190.             ->add('alternatingRythm'CKEditorType::class, [
  191.                 'label' => "Rythme d'alternance",
  192.                 'required' => false,
  193.             ])
  194.             ->add('teachingMethods'CKEditorType::class, [
  195.                 'label' => 'Méthodes pédagogiques',
  196.                 'required' => false,
  197.             ])
  198.             ->add('teachingMeans'CKEditorType::class, [
  199.                 'label' => 'Moyens pédagogiques',
  200.                 'required' => false,
  201.             ])
  202.             ->add('certificationType'EntityType::class, [
  203.                 'label' => 'Type de certification',
  204.                 'class' => CertificationType::class,
  205.                 'choice_label' => 'name',
  206.                 'query_builder' => function (CertificationTypeRepository $er) {
  207.                     return $er->createQueryBuilder('d')
  208.                         ->orderBy('d.name''ASC');
  209.                 },
  210.                 'attr' => [
  211.                     'class' => 'form-select choices select2',
  212.                 ],
  213.                 'required' => false,
  214.             ])
  215.             ->add('educationLevel'CKEditorType::class, [
  216.                 'label' => 'Commentaire niveau de formation',
  217.                 'required' => false,
  218.             ])
  219.             ->add('educationLevelName'EntityType::class, [
  220.                 'label' => 'Niveau de formation',
  221.                 'class' => EducationLevel::class,
  222.                 'choice_label' => 'name',
  223.                 'query_builder' => function (EducationLevelRepository $educationLevelRepository) {
  224.                     return $educationLevelRepository->createQueryBuilder('el')
  225.                         ->orderBy('el.name''ASC');
  226.                 },
  227.                 'attr' => [
  228.                     'class' => 'form-select choices select2',
  229.                 ],
  230.                 'multiple' => false,
  231.                 'required' => false,
  232.             ])
  233.             ->add('certificationName'TextType::class, [
  234.                 'label' => 'Nom de la certification',
  235.                 'required' => false,
  236.             ])
  237.             ->add('assessmentMethods'CKEditorType::class, [
  238.                 'label' => "Modalités d'évaluation",
  239.                 'required' => false,
  240.             ])
  241.             ->add('targetFunctions'CKEditorType::class, [
  242.                 'label' => 'Fonctions visées',
  243.                 'required' => false,
  244.             ])
  245.             ->add('continuingStudies'CKEditorType::class, [
  246.                 'label' => "Poursuite d'études",
  247.                 'required' => false,
  248.             ])
  249.             ->add('disabledAccessibility'ChoiceType::class, [
  250.                 'label' => 'Accessibilité',
  251.                 'choices' => [
  252.                     'Oui' => '0',
  253.                     'Non' => '1',
  254.                     'Rien' => '2',
  255.                 ],
  256.                 'attr' => [
  257.                     'class' => 'custom-control custom-radio selectgroup',
  258.                 ],
  259.                 'multiple' => false,
  260.                 'expanded' => true,
  261.                 'required' => false
  262.             ])
  263.             ->add('pedagogicalReferent'EntityType::class, [
  264.                 'label' => 'Référent pédagogique',
  265.                 'class' => User::class,
  266.                 'choice_label' => function($choice$key$value){
  267.                     return $choice->getFirstName().' '.$choice->getLastName();
  268.                 },
  269.                 'query_builder' => function (UserRepository $er) {
  270.                     return $er->createQueryBuilder('u')
  271.                         ->where("u.roles LIKE '%ROLE_INTERVENANT%'")
  272.                         ->orWhere("u.roles LIKE '%ROLE_COMMERCIAL%'")
  273.                         ->orWhere("u.roles LIKE '%ROLE_ADMIN%'")
  274.                         ->orderBy('u.firstName''ASC');
  275.                 },
  276.                 'attr' => [
  277.                     'class' => 'form-select choices select2',
  278.                 ],
  279.                 'required' => false,
  280.                 'multiple' => true,
  281.             ])
  282.             ->add('commercials'EntityType::class, [
  283.                 'label' => 'Contact Commercial',
  284.                 'class' => User::class,
  285.                 'choice_label' => function ($choice$key$value) {
  286.                     return $choice->getFirstName() . ' ' $choice->getLastName();
  287.                 },
  288.                 'query_builder' => function (UserRepository $er) {
  289.                     return $er->createQueryBuilder('u')
  290.                         ->where("u.roles LIKE '%ROLE_COMMERCIAL%'")
  291.                         ->orWhere("u.roles LIKE '%ROLE_ADMIN%'")
  292.                         ->orderBy('u.firstName''ASC');
  293.                 },
  294.                 'attr' => [
  295.                     'class' => 'form-select choices select2',
  296.                 ],
  297.                 'required' => false,
  298.                 'multiple' => true,
  299.             ])
  300.             ->add('accessibilityText'CKEditorType::class, [
  301.                 'label' => "Texte d'accessiblité",
  302.                 'required' => false,
  303.             ])
  304.             ->add('testimonials'CKEditorType::class, [
  305.                 'label' => 'Témoignages',
  306.                 'required' => false,
  307.             ])
  308.             ->add('linkedTrainings'EntityType::class, [
  309.                 'class' => Trainings::class,
  310.                 'choice_label' => 'title',
  311.                 'query_builder' => function (TrainingsRepository $trainingsRepository) {
  312.                     return $trainingsRepository->createQueryBuilder('t')
  313.                         ->andWhere('t.isFiche = :isFiche')
  314.                         ->setParameter('isFiche',0)
  315.                         ->orderBy('t.title''ASC');
  316.                 },
  317.                 'attr' => [
  318.                     'class' => 'form-select choices select2',
  319.                 ],
  320.                 'label' => 'Formations liées',
  321.                 'required' => false,
  322.                 'multiple' => true
  323.             ])
  324.             ->add('validityDateRncp'DateType::class, [
  325.                 'label' => 'Date de validité du RNCP',
  326.                 'required' => true
  327.             ])
  328.         ;
  329.     }
  330.     public function configureOptions(OptionsResolver $resolver): void
  331.     {
  332.         $resolver->setDefaults([
  333.             'data_class' => Trainings::class,
  334.         ]);
  335.     }
  336. }