src\Form\UserSurvey\AFCType.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Form\UserSurvey;
  3. use App\Entity\TaxRectificationRequest;
  4. use App\Entity\UserSurvey;
  5. use App\Form\Type\CheckboxBtnType;
  6. use App\Form\Type\RadioBtnType;
  7. use App\Form\Type\SwitchType;
  8. use Doctrine\ORM\EntityManagerInterface;
  9. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  10. use Symfony\Component\Form\AbstractType;
  11. use Symfony\Component\Form\Extension\Core\Type\DateType;
  12. use Symfony\Component\Form\Extension\Core\Type\NumberType;
  13. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  14. use Symfony\Component\Form\FormBuilderInterface;
  15. use Symfony\Component\OptionsResolver\OptionsResolver;
  16. class AFCType extends AbstractType
  17. {
  18.     private EntityManagerInterface $em;
  19.     public function __construct(EntityManagerInterface $em)
  20.     {
  21.         $this->em $em;
  22.     }
  23.     public function buildForm(FormBuilderInterface $builder, array $options): void
  24.     {
  25.         $taxRecifications $this->em->getRepository(TaxRectificationRequest::class)->createQueryBuilder('trr')
  26.             ->andWhere('trr.code != :code')
  27.             ->setParameter(':code''PIT_ONLINE_FR')
  28.             ->getQuery()->getResult();
  29.         $builder
  30.             ->add('dateAFC'DateType::class, [
  31.                 'label' => 'Date dépôt AFC',
  32.                 'required' => false,
  33.                 'widget' => 'single_text',
  34.                 'row_attr' => [
  35.                     'class' => 'input-group input-group-static my-3',
  36.                 ],
  37.             ])
  38.             ->add('resultAFCComment'TextareaType::class, [
  39.                 'label' => false,
  40.                 'required' => false,
  41.                 'row_attr' => [
  42.                     'class' => 'input-group input-group-dynamic my-3',
  43.                 ],
  44.                 'attr' => [
  45.                     'placeholder' => 'Commentaires sur résultat AFC',
  46.                 ],
  47.             ])
  48.             ->add('resultAFC'NumberType::class, [
  49.                 'label' => 'Résultat AFC',
  50.                 'required' => false,
  51.                 'row_attr' => [
  52.                     'class' => 'input-group input-group-static my-3',
  53.                 ],
  54.             ])
  55.             ->add('noAFCResult'CheckboxBtnType::class, [
  56.                 'label' => false,
  57.                 'required' => false,
  58.                 'row_attr' => [
  59.                     'class' => 'my-3',
  60.                 ],
  61.                 'choices' => [
  62.                     'Pas de résultat AFC' => true,
  63.                 ],
  64.                 'attr' => [
  65.                     'class' => 'btn-checkbox-info',
  66.                 ],
  67.             ]);
  68.         if ($options['with_afc_request']) {
  69.             $builder
  70.                 ->add('hasAFCRequested'RadioBtnType::class, [
  71.                     'label' => 'Demande de choix à l\'AFC déposée ?',
  72.                     'required' => false,
  73.                     'choices' => [
  74.                         'Oui' => true,
  75.                         'Non' => false,
  76.                     ],
  77.                     'expanded' => true,
  78.                     'multiple' => false,
  79.                     'row_attr' => [
  80.                         'class' => 'mb-4',
  81.                     ],
  82.                     'attr' => [
  83.                         'class' => 'btn-radio-info',
  84.                     ],
  85.                 ])
  86.                 ->add('taxRectificationRequest'EntityType::class, [
  87.                     'class' => TaxRectificationRequest::class,
  88.                     'label' => 'Demande de rectification d\'impôt',
  89.                     'choice_label' => 'title',
  90.                     'choices' => $taxRecifications,
  91.                     'required' => false,
  92.                     'empty_data' => '',
  93.                     'placeholder' => '',
  94.                     'row_attr' => [
  95.                         'class' => 'input-group input-group-static mb-4',
  96.                     ],
  97.                 ]);
  98.         }
  99.         $builder
  100.             ->add('statusChange'SwitchType::class, [
  101.                 'mapped' => false,
  102.                 'required' => false,
  103.                 'label' => 'Changer le statut en "Dépôt AFC"',
  104.                 'value' => true,
  105.             ])
  106.             ->add('switchToPaid'SwitchType::class, [
  107.                 'mapped' => false,
  108.                 'required' => false,
  109.                 'label' => 'Passer en "Payé"',
  110.                 'value' => false,
  111.             ])
  112.             ->add('sendMail'SwitchType::class, [
  113.                 'mapped' => false,
  114.                 'required' => false,
  115.                 'label' => 'Prévenir Le client',
  116.                 'value' => true,
  117.             ]);
  118.     }
  119.     public function configureOptions(OptionsResolver $resolver): void
  120.     {
  121.         $resolver->setDefaults([
  122.             'with_afc_request' => true,
  123.             'data_class' => UserSurvey::class,
  124.             'csrf_protection' => true,
  125.             'csrf_token_id' => 'front_update_item',
  126.             'csrf_field_name' => 'front_update_token',
  127.         ]);
  128.     }
  129. }