src\Form\UserSurvey\updateUserSurveyType.php line 23

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Form\UserSurvey;
  4. use App\Entity\Order;
  5. use App\Entity\UserSurvey;
  6. use App\Entity\UserSurveyStatus;
  7. use App\Form\Type\LastDayOfMonthType;
  8. use App\Form\Type\SwitchType;
  9. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  10. use Symfony\Component\Form\AbstractType;
  11. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  12. use Symfony\Component\Form\Extension\Core\Type\DateType;
  13. use Symfony\Component\Form\Extension\Core\Type\MoneyType;
  14. use Symfony\Component\Form\FormBuilderInterface;
  15. use Symfony\Component\OptionsResolver\OptionsResolver;
  16. /**
  17.  * Class updateUserSurveyType.php.
  18.  */
  19. final class updateUserSurveyType extends AbstractType
  20. {
  21.     public function buildForm(FormBuilderInterface $builder, array $options): void
  22.     {
  23.         $userSurvey $options['data'];
  24.         if (!is_null($userSurvey)) {
  25.             $userSurvey->fillDateLimitArray(true);
  26.             if (is_null($userSurvey->getOrder())) {
  27.                 $order = new Order($userSurvey->getPrice(), $userSurvey);
  28.                 $order->setPaymentStatus($userSurvey->getPaymentStatus());
  29.                 $userSurvey->setOrder($order);
  30.                 $userSurvey->setOrderReference($order->getReference());
  31.             }
  32.         }
  33.         $builder
  34.             ->add('userSurveyStatus'EntityType::class, [
  35.                 'class' => UserSurveyStatus::class,
  36.                 'label' => 'Statut',
  37.                 'required' => true,
  38.                 'row_attr' => [
  39.                     'class' => 'input-group input-group-static form-group mb-4',
  40.                 ],
  41.             ])
  42.             ->add('paymentStatus'ChoiceType::class, [
  43.                 'label' => 'Statut de paiement',
  44.                 'choices' => [
  45.                     'En attente' => 'pending',
  46.                     'Payé' => 'payedout',
  47.                     'Paiement reçu' => 'captured',
  48.                     'Annulé' => 'canceled',
  49.                 ],
  50.                 'required' => true,
  51.                 'empty_data' => '',
  52.                 'row_attr' => [
  53.                     'class' => 'input-group input-group-static mb-4',
  54.                 ],
  55.             ])
  56.             ->add('price'MoneyType::class, [
  57.                 'label' => 'Prix',
  58.                 'required' => true,
  59.                 'attr' => ['min' => 0'class' => 'h-40'],
  60.                 'row_attr' => [
  61.                     'class' => 'input-group input-group-static mb-4 ',
  62.                 ],
  63.                 'disabled' => true,
  64.             ])
  65.             ->add('internalAlertDate'DateType::class, [
  66.                 'label' => 'Dossier a problème, date d\'alerte',
  67.                 'required' => false,
  68.                 'widget' => 'single_text',
  69.                 'row_attr' => [
  70.                     'class' => 'input-group input-group-static mb-4',
  71.                 ],
  72.             ])
  73.             ->add('dateLimit'LastDayOfMonthType::class, [
  74.                 'label' => 'Date limite (QR)',
  75.                 'required' => false,
  76.                 'row_attr' => [
  77.                     'class' => 'input-group input-group-static mb-4',
  78.                 ],
  79.             ])
  80.             ->add('sendMail'SwitchType::class, [
  81.                 'mapped' => false,
  82.                 'required' => false,
  83.                 'label' => 'Prévenir Le client',
  84.                 'value' => true,
  85.             ]);
  86.         if (!is_null($userSurvey) && !$userSurvey->isPaid()) {
  87.             $builder->add('order'updateUserSurveyOrderType::class, [
  88.                 'label' => false,
  89.             ]);
  90.         }
  91.     }
  92.     public function configureOptions(OptionsResolver $resolver): void
  93.     {
  94.         $resolver->setDefaults([
  95.             'data_class' => UserSurvey::class,
  96.             'validation_groups' => null,
  97.             'csrf_protection' => true,
  98.             'csrf_token_id' => 'front_update_item',
  99.             'csrf_field_name' => 'front_update_token',
  100.         ]);
  101.     }
  102. }