mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
adapt Thirdparty form and templates
This commit is contained in:
@@ -3,6 +3,11 @@
|
||||
namespace Chill\ThirdPartyBundle\Form;
|
||||
|
||||
use Chill\MainBundle\Form\Type\ChillTextareaType;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdPartyCategory;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdPartyCivility;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdPartyProfession;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
@@ -21,32 +26,24 @@ use Chill\MainBundle\Form\Type\AddressType;
|
||||
|
||||
class ThirdPartyType extends AbstractType
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var AuthorizationHelper
|
||||
*/
|
||||
protected $authorizationHelper;
|
||||
protected AuthorizationHelper $authorizationHelper;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var TokenStorageInterface
|
||||
*/
|
||||
protected $tokenStorage;
|
||||
protected TokenStorageInterface $tokenStorage;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var ThirdPartyTypeManager
|
||||
*/
|
||||
protected $typesManager;
|
||||
protected ThirdPartyTypeManager $typesManager;
|
||||
|
||||
protected TranslatableStringHelper $translatableStringHelper;
|
||||
|
||||
public function __construct(
|
||||
AuthorizationHelper $authorizationHelper,
|
||||
TokenStorageInterface $tokenStorage,
|
||||
ThirdPartyTypeManager $typesManager
|
||||
ThirdPartyTypeManager $typesManager,
|
||||
TranslatableStringHelper $translatableStringHelper
|
||||
) {
|
||||
$this->authorizationHelper = $authorizationHelper;
|
||||
$this->tokenStorage = $tokenStorage;
|
||||
$this->typesManager = $typesManager;
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,26 +57,87 @@ class ThirdPartyType extends AbstractType
|
||||
}
|
||||
|
||||
$builder
|
||||
->add('civility', EntityType::class, [
|
||||
'label' => 'thirdparty.Civility',
|
||||
'class' => ThirdPartyCivility::class,
|
||||
'choice_label' => function (ThirdPartyCivility $civility) {
|
||||
return $this->translatableStringHelper->localize($civility->getName());
|
||||
},
|
||||
'query_builder' => function(EntityRepository $er) {
|
||||
return $er->createQueryBuilder('c')
|
||||
->where('c.active = true');
|
||||
},
|
||||
'placeholder' => 'thirdparty.choose civility',
|
||||
'required' => true
|
||||
])
|
||||
|
||||
->add('name', TextType::class, [
|
||||
'required' => true
|
||||
])
|
||||
->add('telephone', TextType::class, [
|
||||
'label' => 'Phonenumber',
|
||||
|
||||
->add('nameCompany', TextType::class, [
|
||||
'label' => 'thirdparty.NameCompany',
|
||||
'required' => false
|
||||
])
|
||||
->add('email', EmailType::class, [
|
||||
|
||||
->add('profession', EntityType::class, [
|
||||
'label' => 'thirdparty.Profession',
|
||||
'class' => ThirdPartyProfession::class,
|
||||
'choice_label' => function (ThirdPartyProfession $profession) {
|
||||
return $this->translatableStringHelper->localize($profession->getName());
|
||||
},
|
||||
'query_builder' => function (EntityRepository $er) {
|
||||
return $er->createQueryBuilder('p')
|
||||
->where('p.active = true');
|
||||
},
|
||||
'placeholder' => 'thirdparty.choose profession',
|
||||
'required' => false
|
||||
])
|
||||
->add('comment', ChillTextareaType::class, [
|
||||
|
||||
->add('acronym', TextType::class, [
|
||||
'label' => 'thirdparty.Acronym',
|
||||
'required' => false
|
||||
])
|
||||
|
||||
->add('categories', EntityType::class, [
|
||||
'label' => 'thirdparty.Categories',
|
||||
'class' => ThirdPartyCategory::class,
|
||||
'choice_label' => function (ThirdPartyCategory $category) {
|
||||
return $this->translatableStringHelper->localize($category->getName());
|
||||
},
|
||||
'query_builder' => function (EntityRepository $er) {
|
||||
return $er->createQueryBuilder('c')
|
||||
->where('c.active = true');
|
||||
},
|
||||
'required' => true,
|
||||
'multiple' => true,
|
||||
'attr' => ['class' => 'select2']
|
||||
])
|
||||
|
||||
->add('type', ChoiceType::class, [
|
||||
'choices' => $types,
|
||||
'expanded' => true,
|
||||
'multiple' => true,
|
||||
'label' => 'thirdparty.Type'
|
||||
])
|
||||
|
||||
->add('telephone', TextType::class, [
|
||||
'label' => 'Phonenumber',
|
||||
'required' => false
|
||||
])
|
||||
|
||||
->add('email', EmailType::class, [
|
||||
'required' => false
|
||||
])
|
||||
|
||||
->add('address', AddressType::class, [
|
||||
'has_valid_from' => false,
|
||||
'null_if_empty' => true,
|
||||
'required' => false
|
||||
])
|
||||
|
||||
->add('active', ChoiceType::class, [
|
||||
'label' => 'thirdparty.Status',
|
||||
'choices' => [
|
||||
'Active, shown to users' => true,
|
||||
'Inactive, not shown to users' => false
|
||||
@@ -87,18 +145,18 @@ class ThirdPartyType extends AbstractType
|
||||
'expanded' => true,
|
||||
'multiple' => false
|
||||
])
|
||||
|
||||
->add('comment', ChillTextareaType::class, [
|
||||
'required' => false
|
||||
])
|
||||
|
||||
->add('centers', EntityType::class, [
|
||||
'choices' => $this->getReachableCenters($options),
|
||||
'class' => \Chill\MainBundle\Entity\Center::class,
|
||||
'multiple' => true,
|
||||
'expanded' => true
|
||||
'attr' => ['class' => 'select2']
|
||||
])
|
||||
->add('address', AddressType::class, [
|
||||
'has_valid_from' => false,
|
||||
'null_if_empty' => true,
|
||||
'required' => false
|
||||
])
|
||||
;
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user