diff --git a/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig b/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig index 3457c883a..f9924eb11 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig @@ -10,30 +10,32 @@ {% endif %} - {% if form.checkboxes|length > 0 %} - {% for checkbox_name, options in form.checkboxes %} -
-
- {% for c in form['checkboxes'][checkbox_name].children %} -
- {{ form_widget(c) }} - {{ form_label(c) }} -
- {% endfor %} -
-
- {% if loop.last %} + {% if form.checkboxes is defined %} + {% if form.checkboxes|length > 0 %} + {% for checkbox_name, options in form.checkboxes %}
- + {% for c in form['checkboxes'][checkbox_name].children %} +
+ {{ form_widget(c) }} + {{ form_label(c) }} +
+ {% endfor %}
- {% endif %} - {% endfor %} + {% if loop.last %} +
+
+ +
+
+ {% endif %} + {% endfor %} + {% endif %} {% endif %} {{ form_end(form) }} diff --git a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php index 2c7380116..e2ebfa6d9 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php @@ -18,6 +18,7 @@ use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\QueryBuilder; +use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\CallbackTransformer; use Symfony\Component\Form\Extension\Core\Type\CheckboxType; @@ -46,18 +47,22 @@ class ThirdPartyType extends AbstractType protected EntityManagerInterface $om; + private bool $askCenter; + public function __construct( AuthorizationHelper $authorizationHelper, TokenStorageInterface $tokenStorage, ThirdPartyTypeManager $typesManager, TranslatableStringHelper $translatableStringHelper, - EntityManagerInterface $om + EntityManagerInterface $om, + ParameterBagInterface $parameterBag ) { $this->authorizationHelper = $authorizationHelper; $this->tokenStorage = $tokenStorage; $this->typesManager = $typesManager; $this->translatableStringHelper = $translatableStringHelper; $this->om = $om; + $this->askCenter = $parameterBag->get('chill_main')['acl']['form_show_centers']; } /** @@ -78,16 +83,19 @@ class ThirdPartyType extends AbstractType ]) ->add('comment', ChillTextareaType::class, [ 'required' => false - ]) - ->add('centers', PickCenterType::class, [ - 'role' => (\array_key_exists('data', $options) && $this->om->contains($options['data'])) ? - ThirdPartyVoter::UPDATE : ThirdPartyVoter::CREATE, - 'choice_options' => [ - 'multiple' => true, - 'attr' => ['class' => 'select2'] - ] - ]) - ; + ]); + + if ($this->askCenter) { + $builder + ->add('centers', PickCenterType::class, [ + 'role' => (\array_key_exists('data', $options) && $this->om->contains($options['data'])) ? + ThirdPartyVoter::UPDATE : ThirdPartyVoter::CREATE, + 'choice_options' => [ + 'multiple' => true, + 'attr' => ['class' => 'select2'] + ] + ]); + } // Contact Person ThirdParty (child) if (ThirdParty::KIND_CONTACT === $options['kind'] || ThirdParty::KIND_CHILD === $options['kind']) { diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form.html.twig b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form.html.twig index 6bc4e3da7..c53764871 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form.html.twig +++ b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form.html.twig @@ -30,38 +30,10 @@ {{ form_row(form.address) }} -{# -
- {{ form_label(form.address) }} - {{ form_widget(form.address) }} - -
- {% if thirdParty.address %} - {# include vue_address component # - {% include '@ChillMain/Address/_insert_vue_address.html.twig' with { - targetEntity: { name: 'thirdparty', id: thirdParty.id }, - mode: 'edit', - addressId: thirdParty.address.id, - buttonSize: 'btn-sm', - } %} - {# - backUrl: path('chill_3party_3party_new'), - # - {% else %} - {# include vue_address component # - {% include '@ChillMain/Address/_insert_vue_address.html.twig' with { - targetEntity: { name: 'thirdparty', id: thirdParty.id }, - mode: 'new', - buttonSize: 'btn-sm', - buttonText: 'Create a new address', - modalTitle: 'Create a new address', - } %} - {% endif %} -
-
-#} - {{ form_row(form.comment) }} + +{% if form.centers is defined %} {{ form_row(form.centers) }} +{% endif %} {{ form_row(form.active) }}