src/Form/Subscriber/OrderTypeSubscriber.php line 75

Open in your IDE?
  1. <?php
  2. namespace App\Form\Subscriber;
  3. use App\Entity\Company;
  4. use App\Entity\CompanyGroup;
  5. use App\Entity\Order;
  6. use App\Entity\Product;
  7. use App\Entity\User;
  8. use App\Form\Validator\RodneCisloConstraint;
  9. use App\Helper\EnumsHelper;
  10. use App\Helper\EsfHelper;
  11. use App\Repository\CompanyRepository;
  12. use App\Repository\ProductRepository;
  13. use PhpOffice\PhpWord\Shared\Text;
  14. use PhpParser\Node\Expr\BinaryOp\GreaterOrEqual;
  15. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  16. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  17. use Symfony\Component\Form\Event\PreSetDataEvent;
  18. use Symfony\Component\Form\Event\PreSubmitEvent;
  19. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  20. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  21. use Symfony\Component\Form\Extension\Core\Type\DateType;
  22. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  23. use Symfony\Component\Form\Extension\Core\Type\NumberType;
  24. use Symfony\Component\Form\Extension\Core\Type\PercentType;
  25. use Symfony\Component\Form\Extension\Core\Type\TextType;
  26. use Symfony\Component\Form\FormEvent;
  27. use Symfony\Component\Form\FormEvents;
  28. use Symfony\Component\Form\FormInterface;
  29. use Symfony\Component\Validator\Constraints\GreaterThan;
  30. use Symfony\Component\Validator\Constraints\GreaterThanOrEqual;
  31. class OrderTypeSubscriber implements EventSubscriberInterface
  32. {
  33.     /**
  34.      * @var ProductRepository
  35.      */
  36.     protected $productRepository;
  37.     /**
  38.      * @var CompanyRepository
  39.      */
  40.     protected $_companyRepository;
  41.     /**
  42.      * OrderTypeSubscriber constructor.
  43.      */
  44.     public function __construct(ProductRepository $productRepositoryCompanyRepository $companyRepository)
  45.     {
  46.         $this->productRepository $productRepository;
  47.         $this->_companyRepository $companyRepository;
  48.     }
  49.     public static function getSubscribedEvents(): array
  50.     {
  51.         return [
  52.             FormEvents::PRE_SET_DATA => 'dependsOn',
  53.             FormEvents::PRE_SUBMIT => 'dependsOn',
  54.             FormEvents::POST_SUBMIT => 'postSubmit'
  55.         ];
  56.     }
  57.     public function postSubmit(FormEvent $event)
  58.     {
  59.         /** @var Order $data */
  60.         $data $event->getData();
  61.         if (!$data) return;
  62.         $this->reloadProductPrice($data);
  63.     }
  64.     public function dependsOn(FormEvent $event)
  65.     {
  66.         /** @var FormInterface $form */
  67.         $form $event->getForm();
  68.         /** @var Order $data */
  69.         $data $event->getData();
  70.         if (!$data) return;
  71.         if (isset($data['idType']) && $data['idType'] == EnumsHelper::OTHER_TYPES) {
  72.             $form->add('idTypeOther'TextType::class, [
  73.                 'required' => true,
  74.                 'attr' => [
  75.                     'placeholder' => 'Typ dokladu'
  76.                 ],
  77.                 'label' => false,
  78.             ]);
  79.         }
  80.         $this->personTypeFields(@$data['personType'], $form);
  81.         $this->loadProduct($data$form);
  82.         $this->loadCompany($data$form);
  83.         if(isset($data['personType']) && $data['personType'] == 'PO'){
  84.             $form->remove('generateDigiSign');
  85.             $form->remove('politicallyExposedPerson');
  86.         }else{
  87.             $form->add('politicallyExposedPerson'CheckboxType::class, [
  88.                 'label' => 'Jsem politicky exponovanou osobu',
  89.                 'required' => false,
  90.                 'attr' => [
  91. //                    'data-action' => 'change->order-form#politicallyExposedPerson',
  92.                     'data-order-form-target' => 'politicallyExposedPerson'
  93.                 ]
  94.             ]);
  95.         }
  96.     }
  97.     /**
  98.      * Set price after submit form - in the case of hack form
  99.      *
  100.      * @param Order $order
  101.      * @throws \Exception
  102.      */
  103.     protected function reloadProductPrice(Order $order): void
  104.     {
  105.         /** @var Product $product */
  106.         $product $order->getProduct();
  107.         if ($product && $product instanceof Product) {
  108.             $order->setProductPrice($product->getPrice());
  109.             $order->setProductTax($product->getTax());
  110.             if ($product->getProductType() === EnumsHelper::PRODUCT_TYPE_LOAN) {
  111.             } else {
  112.                 $order->setDueDate($product->getDueDate());
  113.                 $order->setProductInterest($product->getInterest());
  114.                 $order->setProductPriceTotal($product->getPrice() * ((float)$order->getProductCount() > ? (float)$order->getProductCount() : 1));
  115.                 $order->setProductPriceTotalInWords(EsfHelper::convertByIntl($order->getProductPriceTotal()));
  116.                 // akcie
  117.                 if ($product->getProductType() === EnumsHelper::PRODUCT_TYPE_STOCK) {
  118.                     $order->setProductPriceSecondaryTotal($product->getPriceSecondary() * ((float)$order->getProductCount() > ? (float)$order->getProductCount() : 1));
  119.                     $order->setProductPriceSecondaryTotalInWords(EsfHelper::convertByIntl($order->getProductPriceSecondaryTotal()));
  120.                 }
  121.             }
  122.         }
  123.     }
  124.     /**
  125.      * @param Order $data
  126.      * @param FormInterface $form
  127.      * @throws \Exception
  128.      */
  129.     protected function loadProduct($dataFormInterface $form): void
  130.     {
  131.         $productPriceOptions = [
  132.             'required' => false,
  133.             'disabled' => true,
  134.             'label' => 'Cena produktu'
  135.         ];
  136.         $productInterestOptions = [
  137.             'required' => false,
  138.             'attr' => [
  139.                 'placeholder' => 'Výnos'
  140.             ],
  141.             'label' => false
  142.         ];
  143.         $productTaxOptions = [
  144.             'required' => true,
  145.             'attr' => [
  146.                 'placeholder' => 'Daň'
  147.             ],
  148.             'label' => false
  149.         ];
  150.         $productPriceTotal = [
  151.             'required' => true,
  152.             'disabled' => true,
  153.             'label' => 'Cena celkem'
  154.         ];
  155.         $productPriceTotalWords = [
  156.             'required' => true,
  157.             'disabled' => true,
  158.             'label' => 'Cena celkem slovy'
  159.         ];
  160.         $form->add('productTax'HiddenType::class, $productTaxOptions)
  161.             ->add('productInterest'HiddenType::class, $productInterestOptions);
  162.         if (isset($data['product']) && false == is_null($data['product']) && $data['product'] != '') {
  163.             $product $this->productRepository->findOneBy(['id' => $data['product']]);
  164.             if ($product instanceof Product) {
  165.                 if ($product->getProductType() === EnumsHelper::PRODUCT_TYPE_LOAN) {
  166.                     // zapujcka
  167.                     $form->add('dueDate'DateType::class, [
  168.                         'required' => false,
  169.                         'label' => 'Splatnost',
  170.                         'widget' => 'single_text',
  171.                         'html5' => false,
  172.                         'format' => 'dd.MM.yyyy',
  173.                         'disabled' => false,
  174. //                        'data' => $product->getDueDate(),
  175. //                        'empty_data' => $product->getDueDate(),
  176.                         'attr' => [
  177.                             'placeholder' => 'Splatnost',
  178.                             'class' => "bg-white",
  179.                             'data-order-form-target' => 'dueDate',
  180.                         ]
  181.                     ]);
  182.                     // do policka total ulozim celkove zadanou castku
  183.                     $productInterestOptions['disabled'] = false;
  184.                     $productInterestOptions['label'] = 'Úrok';
  185.                     $productInterestOptions['attr']['placeholder'] = 'Úrok';
  186.                     $productInterestOptions['attr']['data-action'] = 'input->order-form#percentsInput';
  187.                     $productPriceTotal['label'] = 'Částka';
  188.                     $productPriceTotal['disabled'] = false;
  189.                     $form->add('productPriceTotal'TextType::class, $productPriceTotal)
  190.                         // produkt interest se zobrazi jako textfield v zapujcce
  191.                         ->add('productInterest'TextType::class, $productInterestOptions)
  192.                         ->add('productCount'HiddenType::class, []);
  193.                 } else {
  194.                     $productCountParams = [
  195.                         'required' => true,
  196.                         'attr' => [
  197.                             'placeholder' => '* Počet',
  198.                             'data-action' => 'change->order-form#productCountChange',
  199.                             'data-order-form-target' => 'productCount',
  200.                             'data-min-count' => $product->getMinCount()
  201.                         ],
  202.                         'label' => false,
  203.                     ];
  204.                     if((float)$data['productCount'] <= $product->getMinCount()){
  205. //                        $productCountParams['constraints'] = [];
  206.                         $productCountParams['attr']['data-min-count'] = $product->getMinCount();
  207.                         $productCountParams['data'] = $product->getMinCount();
  208.                         $productCountParams['empty_data'] = $product->getMinCount();
  209.                         $data['productCount'] = $product->getMinCount();
  210.                         $productCountParams['constraints'] = [
  211.                             new GreaterThanOrEqual([
  212.                                 'value' => $product->getMinCount(),
  213.                                 'message' => 'Min. počet je {{ compared_value }} ks'
  214.                             ])
  215.                         ];
  216.                     }
  217.                     // dluhopis - default
  218.                     $productPriceOptions['empty_data'] = $product->getPrice() . EsfHelper::currencyExt($product); // neodeslany form
  219.                     $productPriceOptions['data'] = $product->getPrice() . EsfHelper::currencyExt($product); // odeslany form
  220.                     $productInterestOptions['empty_data'] = $product->getInterest();
  221.                     $productInterestOptions['data'] = $product->getInterest();
  222.                     $productTaxOptions['empty_data'] = $product->getTax();
  223.                     $productTaxOptions['data'] = $product->getTax();
  224.                     $productPriceTotal['empty_data'] = ($product->getPrice() * ((float)$data['productCount'] > ? (float)$data['productCount'] : 1)) . EsfHelper::currencyExt($product);
  225.                     $productPriceTotal['data'] = ($product->getPrice() * ((float)$data['productCount'] > ? (float)$data['productCount'] : 1)) . EsfHelper::currencyExt($product);
  226.                     $productPriceTotalWords['empty_data'] = EsfHelper::convertByIntl($productPriceTotal['empty_data']) . ' ' EsfHelper::currencyExtText($product);
  227.                     $productPriceTotalWords['data'] = EsfHelper::convertByIntl($productPriceTotal['empty_data']) . ' ' EsfHelper::currencyExtText($product);
  228.                     $form->add('productPriceTotalInWords'TextType::class, $productPriceTotalWords)
  229.                         ->add('productPrice'TextType::class, $productPriceOptions)
  230.                         ->add('productPriceTotal'TextType::class, $productPriceTotal);
  231.                     $form->add('productCount'NumberType::class, $productCountParams);
  232.                 }
  233.                 if($product->isUseAdamna()){
  234.                     $options $form->getConfig()->getOptions();
  235.                     $form->add('birthnumber'TextType::class, [
  236.                         'required' => (boolean)@$options['check_required'],
  237.                         'label' => false,
  238.                         'attr' => [
  239.                             'maxlength' => 11,
  240.                             'placeholder' => '* Rodné číslo',
  241.                             'data-order-form-target' => 'birthnumber'
  242.                         ]
  243.                     ]);
  244.                 }
  245.                 if($product->isGeneratorSigni() || $product->isUseAdamna()) {
  246.                     $form->add('generateSigni'CheckboxType::class, [
  247.                         'required' => false,
  248.                         'mapped' => false,
  249.                         'label' => 'Vygenerovat smlouvu a digitálně podepsat přes <a href="www.signi.com" target="_blank">Signi.com</a>',
  250.                         'label_html' => true,
  251.                         'attr' => [
  252.                             'data-order-form-target' => 'generateSigni',
  253.                             'data-action' => 'change->order-form#changeSigniVsPdf'
  254.                         ],
  255.                     ]);
  256.                 }
  257.                 if($product->isGeneratorDigiSign()) {
  258.                     $form->add('generateDigiSign'CheckboxType::class, [
  259.                         'required' => false,
  260.                         'mapped' => false,
  261.                         'label' => 'Vygenerovat smlouvu a digitálně podepsat přes <a href="www.digisign.org" target="_blank">DigiSign.org</a>',
  262.                         'label_html' => true,
  263.                         'attr' => [
  264.                             'data-order-form-target' => 'generateDigiSign',
  265.                             'data-action' => 'change->order-form#changeDigiSign'
  266.                         ],
  267.                     ]);
  268.                 }
  269.                 if($product->isGeneratorPdf()) {
  270.                     $form->add('generatePdf'CheckboxType::class, [
  271.                         'required' => false,
  272.                         'mapped' => false,
  273.                         'label' => "Vygenerovat smlouvu a uložit do PDF k manuálnímu podpisu",
  274.                         'attr' => [
  275.                             'data-order-form-target' => 'generatePdf',
  276.                             'data-action' => 'change->order-form#changeSigniVsPdf'
  277.                         ],
  278.                     ]);
  279.                 }
  280.                 if($product->getCurrency() != EnumsHelper::CURRENCY_CZK) {
  281.                     $this->makeFieldRequire($form'bankAccount'false);
  282.                     $this->makeFieldRequire($form'bankCode'falseChoiceType::class);
  283.                     $this->makeFieldRequire($form'swift'true);
  284.                     $this->makeFieldRequire($form'iban'true);
  285.                 }
  286.                 // kvuli Adamna IS, protoze potrebuje pro svuj chod rodne cislo, tak to musime osetrit
  287.                 if($product->isUseAdamna() && $form->has('birthdate')){
  288.                     // odebereme datum narozeni a misto neho dame rodne cislo
  289.                     $form->remove('birthdate');
  290.                 }
  291.             }
  292.         }
  293.     }
  294.     protected function makeFieldRequire(FormInterface $formstring $itemNamebool $isRequired$type TextType::class){
  295.         $options $form->get($itemName)->getConfig()->getOptions();
  296.         if($type == TextType::class) {
  297.             $options['attr']['placeholder'] = str_replace('* '''$options['attr']['placeholder']);
  298.             if ($isRequired == true) {
  299.                 $options['attr']['placeholder'] = '* ' $options['attr']['placeholder'];
  300.             }
  301.         }
  302.         if($type == ChoiceType::class) {
  303.             $options['placeholder'] = str_replace('* '''$options['placeholder']);
  304.             if ($isRequired == true) {
  305.                 $options['placeholder'] = '* ' $options['placeholder'];
  306.             }
  307.         }
  308.         $options['required'] = $isRequired;
  309.         $form->remove($itemName)
  310.             ->add($itemName$type$options);
  311.     }
  312.     /**
  313.      * @param Order $data
  314.      * @param FormInterface $form
  315.      */
  316.     protected function loadCompany($dataFormInterface $form): void
  317.     {
  318.         $options $form->getConfig()->getOptions();
  319.         if (isset($data['company']) && false == is_null($data['company']) && $data['company'] != '') {
  320.             $companyId $data['company'];
  321.             if ($companyId instanceof Company) {
  322.                 $companyId $companyId->getId();
  323.             }
  324.             $companyRepository $this->_companyRepository;
  325.             $form->add('product'EntityType::class, [
  326.                 'class' => Product::class,
  327.                 'label' => false,
  328.                 'placeholder' => '* Vyberte produkt',
  329.                 'attr' => [
  330.                     'data-action' => 'change->order-form#productChange',
  331.                     'data-order-form-target' => 'product'
  332.                 ],
  333.                 'choice_label' => function (Product $product) {
  334.                     return $product->getName();
  335.                 },
  336.                 'query_builder' => function (ProductRepository $er) use ($data$companyId$options$companyRepository) {
  337.                     $qb $er->createQueryBuilder('pr');
  338.                     $companyIds = [$companyId];
  339.                     if(isset($companyId)) {
  340.                         $companyEnt $companyRepository->findOneBy(['id' => $companyId]);
  341.                         if(isset($companyEnt)) {
  342.                             $companyGroup $companyEnt->getCompanyGroup();
  343.                             if(isset($companyGroup)) {
  344.                                 $companiesByGroup $companyRepository->findBy(['companyGroup' => $companyGroup->getId()]);
  345.                                 foreach ($companiesByGroup as $companyFromGroup) {
  346.                                     $companyIds[] = $companyFromGroup->getId();
  347.                                 }
  348.                             }
  349.                         }
  350.                     }
  351.                     // volanio api, nacitam pouze produkty pro dan ou spolecnost
  352.                     $qb->andWhere($qb->expr()->in('pr.company'$companyIds));
  353.                     $loggedUser = @$options['logged_user'];
  354.                     // pokud se nejdena o admin, pridavam podminku pouze pro aktivni produkty a nesmazane
  355.                     if(!(isset($loggedUser) && $loggedUser instanceof User && $loggedUser->hasRole(User::ROLE_ADMIN))){
  356.                         // neadmin pouze aktivni
  357.                         $qb->andWhere($qb->expr()->eq('pr.active'1));
  358.                     }
  359.                     return $qb;
  360.                 }
  361.             ]);
  362.             if (isset($data['product']) && false == is_null($data['product']) && $data['product'] != '') {
  363.                 $product $data['product'];
  364.                 if ($options['api_complete'] == true) {
  365.                     $attr['data-action'] = 'change->order-form#reload';
  366.                     $attr['data-order-form-target'] = 'company';
  367.                     if ($product instanceof Product) {
  368.                         $form->add('company'EntityType::class, [
  369.                             'class' => Company::class,
  370.                             'query_builder' => function (CompanyRepository $companyRepository) use ($product) {
  371.                                 $qb $companyRepository->createQueryBuilder('c');
  372.                                 return $qb->select('c')
  373.                                     ->andWhere($qb->expr()->in('c.id'$product->getCompany()->getId()));
  374.                             },
  375.                             'choice_label' => function (Company $company) {
  376.                                 return $company->getName();
  377.                             },
  378.                             'attr' => $attr,
  379.                             'placeholder' => 'Vyberte společnost',
  380.                             'label' => false,
  381.                         ]);
  382.                     }
  383.                 }
  384.             }
  385.         }
  386.     }
  387.     /**
  388.      * @param $personType
  389.      * @param FormInterface $form
  390.      */
  391.     protected function personTypeFields($personTypeFormInterface $form): void
  392.     {
  393.         $options $form->getConfig()->getOptions();
  394.         if ($personType == 'FO' || is_null($personType)) {
  395.             $this->fPerson($form$options);
  396.             if($form->has('businessmanRegistrationPlace')) { $form->remove('businessmanRegistrationPlace'); }
  397.             if($form->has('businessmanRegistrationNumber')) { $form->remove('businessmanRegistrationNumber'); }
  398.             if($form->has('ic')) { $form->remove('ic'); }
  399.             if($form->has('dic')) { $form->remove('dic'); }
  400.             if($form->has('companyRegistrationPlace')) { $form->remove('companyRegistrationPlace'); }
  401.             if($form->has('companyRegistrationNumber')) { $form->remove('companyRegistrationNumber'); }
  402.             if($form->has('companyRegistrationPartition')) { $form->remove('companyRegistrationPartition'); }
  403.             if($form->has('companyRegistrationInsertion')) { $form->remove('companyRegistrationInsertion'); }
  404.             if($form->has('companyRepresentantive')) { $form->remove('companyRepresentantive'); }
  405.         }
  406.         if ($personType == 'FP') {
  407.             $this->fPerson($form$options);
  408.             $this->icDic($form$options);
  409.             $this->businessmanRegistration($form$options);
  410.             if($form->has('companyRegistrationPlace')) { $form->remove('companyRegistrationPlace'); }
  411.             if($form->has('companyRegistrationNumber')) { $form->remove('companyRegistrationNumber'); }
  412.             if($form->has('companyRegistrationPartition')) { $form->remove('companyRegistrationPartition'); }
  413.             if($form->has('companyRegistrationInsertion')) { $form->remove('companyRegistrationInsertion'); }
  414.             if($form->has('companyRepresentantive')) { $form->remove('companyRepresentantive'); }
  415.         }
  416.         if ($personType == 'PO') {
  417.             if($form->has('birthdate')) { $form->remove('birthdate'); }
  418.             if($form->has('birthnumber')) { $form->remove('birthnumber'); }
  419.             if($form->has('idType')) { $form->remove('idType'); }
  420.             if($form->has('idNumber')) { $form->remove('idNumber'); }
  421.             if($form->has('idAuthor')) { $form->remove('idAuthor'); }
  422.             if($form->has('idValidity')) { $form->remove('idValidity'); }
  423.             if($form->has('nationality')) { $form->remove('nationality'); }
  424.             if($form->has('businessmanRegistrationPlace')) { $form->remove('businessmanRegistrationPlace'); }
  425.             if($form->has('businessmanRegistrationNumber')) { $form->remove('businessmanRegistrationNumber'); }
  426.             $this->icDic($form$options);
  427.             $this->companyRegistration($form$options);
  428.         }
  429.     }
  430.     /**
  431.      * @param FormInterface $form
  432.      */
  433.     private function icDic(FormInterface $form, array $options): void
  434.     {
  435.         $form->add('ic'TextType::class, [
  436.             'required' => (boolean)@$options['check_required'],
  437.             'attr' => [
  438.                 'placeholder' => '* IČO'
  439.             ],
  440.             'label' => false
  441.         ])
  442.             ->add('dic'TextType::class, [
  443.                 'required' => false,
  444.                 'attr' => [
  445.                     'placeholder' => '* DIČ'
  446.                 ],
  447.                 'label' => false
  448.             ]);
  449.     }
  450.     /**
  451.      * @param FormInterface $form
  452.      */
  453.     private function businessmanRegistration(FormInterface $form, array $options): void
  454.     {
  455.         $form->add('businessmanRegistrationPlace'TextType::class, [
  456.             'required' => (boolean)@$options['check_required'],
  457.             'attr' => [
  458.                 'placeholder' => '* Podnikatel zapsaný u'
  459.             ],
  460.             'label' => false,
  461.         ])
  462.             ->add('businessmanRegistrationNumber'TextType::class, [
  463.                 'required' => (boolean)@$options['check_required'],
  464.                 'attr' => [
  465.                     'placeholder' => '* Číslo zápisu'
  466.                 ],
  467.                 'label' => false,
  468.             ]);
  469.     }
  470.     /**
  471.      * @param FormInterface $form
  472.      */
  473.     private function companyRegistration(FormInterface $form, array $options): void
  474.     {
  475.         $form->add('companyRegistrationPlace'TextType::class, [
  476.             'required' => (boolean)@$options['check_required'],
  477.             'attr' => [
  478.                 'placeholder' => '* Společnost zapsaná v'
  479.             ],
  480.             'label' => false,
  481.         ])
  482.             ->add('companyRegistrationNumber'TextType::class, [
  483.                 'required' => (boolean)@$options['check_required'],
  484.                 'attr' => [
  485.                     'placeholder' => '* Číslo zápisu'
  486.                 ],
  487.                 'label' => false,
  488.             ])
  489.             ->add('companyRegistrationPartition'TextType::class, [
  490.                 'required' => (boolean)@$options['check_required'],
  491.                 'attr' => [
  492.                     'placeholder' => '* Oddíl'
  493.                 ],
  494.                 'label' => false,
  495.             ])
  496.             ->add('companyRegistrationInsertion'TextType::class, [
  497.                 'required' => (boolean)@$options['check_required'],
  498.                 'attr' => [
  499.                     'placeholder' => '* Vložka'
  500.                 ],
  501.                 'label' => false,
  502.             ])
  503.             ->add('companyRepresentantive'TextType::class, [
  504.                 'required' => (boolean)@$options['check_required'],
  505.                 'attr' => [
  506.                     'placeholder' => '* Společnost zastupuje'
  507.                 ],
  508.                 'label' => false,
  509.             ]);
  510.     }
  511.     /**
  512.      * @param FormInterface $form
  513.      */
  514.     private function fPerson(FormInterface $form, array $options): void
  515.     {
  516.         $form->add('surname'TextType::class, [
  517.             'required' => (boolean)@$options['check_required'],
  518.             'attr' => [
  519.                 'placeholder' => '* Příjmení',
  520.                 'data-order-form-target' => 'surname'
  521.             ],
  522.             'label' => false
  523.         ])->add('birthdate'DateType::class, [
  524.             'required' => (boolean)@$options['check_required'],
  525.             'label' => false,
  526.             'widget' => 'single_text',
  527.             'html5' => false,
  528.             'format' => 'dd.MM.yyyy',
  529.             'attr' => [
  530.                 'placeholder' => '* Datum narození',
  531.                 'class' => "datepicker-input bg-white",
  532.                 'data-order-form-target' => 'birthdate'
  533.             ]
  534.         ])->add('idType'ChoiceType::class, [
  535.             'required' => (boolean)@$options['check_required'],
  536.             'placeholder' => '* Typ dokladu',
  537.             'label' => false,
  538.             'choices' => EnumsHelper::idTypes(),
  539.             'attr' => [
  540.                 'data-action' => 'change->order-form#reload',
  541.                 'data-order-form-target' => 'idType'
  542.             ]
  543.         ])
  544.             ->add('idNumber'TextType::class, [
  545.                 'required' => (boolean)@$options['check_required'],
  546.                 'attr' => [
  547.                     'placeholder' => '* Číslo dokladu',
  548.                     'data-order-form-target' => 'idNumber'
  549.                 ],
  550.                 'label' => false,
  551.             ])
  552.             ->add('idAuthor'TextType::class, [
  553.                 'required' => (boolean)@$options['check_required'],
  554.                 'attr' => [
  555.                     'placeholder' => '* Doklad vydal',
  556.                     'data-order-form-target' => 'idAuthor'
  557.                 ],
  558.                 'label' => false,
  559.             ])
  560.             ->add('idValidity'DateType::class, [
  561.                 'required' => (boolean)@$options['check_required'],
  562.                 'label' => false,
  563.                 'widget' => 'single_text',
  564.                 'html5' => false,
  565.                 'format' => 'dd.MM.yyyy',
  566.                 'attr' => [
  567.                     'placeholder' => '* Platnost dokladu',
  568.                     'class' => "datepicker-input bg-white",
  569.                     'data-order-form-target' => 'idValidity'
  570.                 ],
  571.             ])->add('nationality'ChoiceType::class, [
  572.                 'required' => (boolean)@$options['check_required'],
  573.                 'attr' => [
  574.                     'data-order-form-target' => 'nationality'
  575.                 ],
  576.                 'label' => false,
  577.                 'choices' => EnumsHelper::countries(true),
  578.                 'placeholder' => (boolean)@$options['api_call'] ? '* Země původu' '* Národnost',
  579.             ]);
  580.     }
  581. }