src/Form/Subscriber/OrderTypeSubscriber.php line 65

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