mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
handle kind as contacts
This commit is contained in:
parent
4d71a1c630
commit
0633fd812f
@ -8,8 +8,12 @@ use Chill\MainBundle\Pagination\PaginatorInterface;
|
|||||||
use Chill\MainBundle\Templating\Listing\FilterOrderHelper;
|
use Chill\MainBundle\Templating\Listing\FilterOrderHelper;
|
||||||
use Chill\ThirdPartyBundle\Repository\ThirdPartyACLAwareRepositoryInterface;
|
use Chill\ThirdPartyBundle\Repository\ThirdPartyACLAwareRepositoryInterface;
|
||||||
use Chill\ThirdPartyBundle\Repository\ThirdPartyRepository;
|
use Chill\ThirdPartyBundle\Repository\ThirdPartyRepository;
|
||||||
|
use http\Exception\RuntimeException;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
|
use Symfony\Component\Form\FormInterface;
|
||||||
|
use Symfony\Component\HttpFoundation\RequestStack;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
@ -45,15 +49,19 @@ final class ThirdPartyController extends CRUDController
|
|||||||
|
|
||||||
protected ThirdPartyACLAwareRepositoryInterface $thirdPartyACLAwareRepository;
|
protected ThirdPartyACLAwareRepositoryInterface $thirdPartyACLAwareRepository;
|
||||||
|
|
||||||
|
protected RequestStack $requestStack;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
AuthorizationHelper $authorizationHelper,
|
AuthorizationHelper $authorizationHelper,
|
||||||
TranslatorInterface $translator,
|
TranslatorInterface $translator,
|
||||||
PaginatorFactory $paginatorFactory,
|
PaginatorFactory $paginatorFactory,
|
||||||
|
RequestStack $requestStack,
|
||||||
ThirdPartyACLAwareRepositoryInterface $thirdPartyACLAwareRepository
|
ThirdPartyACLAwareRepositoryInterface $thirdPartyACLAwareRepository
|
||||||
) {
|
) {
|
||||||
$this->authorizationHelper = $authorizationHelper;
|
$this->authorizationHelper = $authorizationHelper;
|
||||||
$this->translator = $translator;
|
$this->translator = $translator;
|
||||||
$this->paginatorFactory = $paginatorFactory;
|
$this->paginatorFactory = $paginatorFactory;
|
||||||
|
$this->requestStack = $requestStack;
|
||||||
$this->thirdPartyACLAwareRepository = $thirdPartyACLAwareRepository;
|
$this->thirdPartyACLAwareRepository = $thirdPartyACLAwareRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,9 +90,38 @@ final class ThirdPartyController extends CRUDController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ('new' === $action) {
|
||||||
|
if (!$request->query->has('kind')) {
|
||||||
|
return $this->render('@ChillThirdParty/ThirdParty/new_pick_kind.html.twig');
|
||||||
|
} else {
|
||||||
|
$kind = $request->query->getAlpha('kind', '');
|
||||||
|
|
||||||
|
if (!(ThirdParty::KIND_COMPANY === $kind || ThirdParty::KIND_CONTACT === $kind)) {
|
||||||
|
throw new BadRequestHttpException('This kind is not supported: '.$kind);
|
||||||
|
}
|
||||||
|
|
||||||
|
$entity->setKind($kind);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function createFormFor(string $action, $entity, string $formClass = null, array $formOptions = []): FormInterface
|
||||||
|
{
|
||||||
|
if ('new' === $action) {
|
||||||
|
return parent::createFormFor($action, $entity, $formClass, \array_merge(
|
||||||
|
$formOptions, [ 'kind' => $this->requestStack->getCurrentRequest()->query->getAlpha('kind')]
|
||||||
|
));
|
||||||
|
} elseif ('edit' === $action) {
|
||||||
|
return parent::createFormFor($action, $entity, $formClass, \array_merge(
|
||||||
|
$formOptions, [ 'kind' => $entity->getKind()]
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::createFormFor($action, $entity, $formClass, $formOptions);
|
||||||
|
}
|
||||||
|
|
||||||
protected function buildFilterOrderHelper(string $action, Request $request): ?FilterOrderHelper
|
protected function buildFilterOrderHelper(string $action, Request $request): ?FilterOrderHelper
|
||||||
{
|
{
|
||||||
return $this->getFilterOrderHelperFactory()
|
return $this->getFilterOrderHelperFactory()
|
||||||
|
@ -61,6 +61,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
|
|
||||||
const KIND_CONTACT = 'contact';
|
const KIND_CONTACT = 'contact';
|
||||||
const KIND_COMPANY = 'company';
|
const KIND_COMPANY = 'company';
|
||||||
|
const KIND_CHILD = 'child';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(name="kind", type="string", length="20", options={"default":""})
|
* @ORM\Column(name="kind", type="string", length="20", options={"default":""})
|
||||||
|
@ -18,14 +18,11 @@ use Symfony\Component\Form\AbstractType;
|
|||||||
use Symfony\Component\Form\CallbackTransformer;
|
use Symfony\Component\Form\CallbackTransformer;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\Form\FormInterface;
|
|
||||||
use Symfony\Component\Form\FormView;
|
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||||
use Chill\ThirdPartyBundle\Security\Voter\ThirdPartyVoter;
|
use Chill\ThirdPartyBundle\Security\Voter\ThirdPartyVoter;
|
||||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
use Symfony\Component\Security\Core\Role\Role;
|
|
||||||
use Chill\ThirdPartyBundle\ThirdPartyType\ThirdPartyTypeManager;
|
use Chill\ThirdPartyBundle\ThirdPartyType\ThirdPartyTypeManager;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
@ -64,7 +61,6 @@ class ThirdPartyType extends AbstractType
|
|||||||
*/
|
*/
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
|
|
||||||
$builder
|
$builder
|
||||||
->add('name', TextType::class, [
|
->add('name', TextType::class, [
|
||||||
'required' => true
|
'required' => true
|
||||||
@ -111,7 +107,7 @@ class ThirdPartyType extends AbstractType
|
|||||||
;
|
;
|
||||||
|
|
||||||
// Contact Person ThirdParty (child)
|
// Contact Person ThirdParty (child)
|
||||||
if ($options['is_child']) {
|
if (ThirdParty::KIND_CONTACT === $options['kind'] || ThirdParty::KIND_CHILD === $options['kind']) {
|
||||||
$builder
|
$builder
|
||||||
->add('civility', EntityType::class, [
|
->add('civility', EntityType::class, [
|
||||||
'label' => 'thirdparty.Civility',
|
'label' => 'thirdparty.Civility',
|
||||||
@ -156,6 +152,27 @@ class ThirdPartyType extends AbstractType
|
|||||||
'label' => 'thirdparty.Acronym',
|
'label' => 'thirdparty.Acronym',
|
||||||
'required' => false
|
'required' => false
|
||||||
])
|
])
|
||||||
|
->add('activeChildren', ChillCollectionType::class, [
|
||||||
|
'entry_type' => ThirdPartyType::class,
|
||||||
|
'entry_options' => [
|
||||||
|
'is_child' => true,
|
||||||
|
'block_name' => 'children',
|
||||||
|
'kind' => ThirdParty::KIND_CHILD,
|
||||||
|
],
|
||||||
|
'block_name' => 'active_children',
|
||||||
|
'allow_add' => true,
|
||||||
|
'allow_delete' => true,
|
||||||
|
'by_reference' => false,
|
||||||
|
'button_add_label' => "Add a contact",
|
||||||
|
'button_remove_label' => "Remove a contact",
|
||||||
|
'empty_collection_explain' => "Any contact"
|
||||||
|
])
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ThirdParty::KIND_CHILD !== $options['kind']) {
|
||||||
|
|
||||||
|
$builder
|
||||||
->add('categories', EntityType::class, [
|
->add('categories', EntityType::class, [
|
||||||
'label' => 'thirdparty.Categories',
|
'label' => 'thirdparty.Categories',
|
||||||
'class' => ThirdPartyCategory::class,
|
'class' => ThirdPartyCategory::class,
|
||||||
@ -170,20 +187,6 @@ class ThirdPartyType extends AbstractType
|
|||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'attr' => ['class' => 'select2']
|
'attr' => ['class' => 'select2']
|
||||||
])
|
])
|
||||||
->add('activeChildren', ChillCollectionType::class, [
|
|
||||||
'entry_type' => ThirdPartyType::class,
|
|
||||||
'entry_options' => [
|
|
||||||
'is_child' => true,
|
|
||||||
'block_name' => 'children'
|
|
||||||
],
|
|
||||||
'block_name' => 'active_children',
|
|
||||||
'allow_add' => true,
|
|
||||||
'allow_delete' => true,
|
|
||||||
'by_reference' => false,
|
|
||||||
'button_add_label' => "Add a contact",
|
|
||||||
'button_remove_label' => "Remove a contact",
|
|
||||||
'empty_collection_explain' => "Any contact"
|
|
||||||
])
|
|
||||||
->add('active', ChoiceType::class, [
|
->add('active', ChoiceType::class, [
|
||||||
'label' => 'thirdparty.Status',
|
'label' => 'thirdparty.Status',
|
||||||
'choices' => [
|
'choices' => [
|
||||||
@ -192,8 +195,7 @@ class ThirdPartyType extends AbstractType
|
|||||||
],
|
],
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'multiple' => false
|
'multiple' => false
|
||||||
])
|
]);
|
||||||
;
|
|
||||||
|
|
||||||
// add the types
|
// add the types
|
||||||
$types = [];
|
$types = [];
|
||||||
@ -242,6 +244,7 @@ class ThirdPartyType extends AbstractType
|
|||||||
$resolver->setDefaults(array(
|
$resolver->setDefaults(array(
|
||||||
'data_class' => ThirdParty::class,
|
'data_class' => ThirdParty::class,
|
||||||
'is_child' => false,
|
'is_child' => false,
|
||||||
|
'kind' => null
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,29 +1,31 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
{% if form.civility is defined %}
|
{% if form.civility is defined %}
|
||||||
{{ form_row(form.civility) }}
|
{{ form_row(form.civility) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{{ form_row(form.name) }}
|
{{ form_row(form.name) }}
|
||||||
|
|
||||||
{% if form.nameCompany is defined %}
|
{% if form.nameCompany is defined %}
|
||||||
{{ form_row(form.nameCompany) }}
|
{{ form_row(form.nameCompany) }}
|
||||||
{{ form_row(form.acronym) }}
|
{{ form_row(form.acronym) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if form.profession is defined %}
|
{% if form.profession is defined %}
|
||||||
{{ form_row(form.profession) }}
|
{{ form_row(form.profession) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{{ form_row(form.types) }}
|
{{ form_row(form.types) }}
|
||||||
{{ form_row(form.categories) }}
|
{{ form_row(form.categories) }}
|
||||||
|
|
||||||
{{ form_row(form.telephone) }}
|
{{ form_row(form.telephone) }}
|
||||||
{{ form_row(form.email) }}
|
{{ form_row(form.email) }}
|
||||||
|
|
||||||
<h2>{{ 'Contacts'|trans }}</h2>
|
{{ form_row(form.contactDataAnonymous) }}
|
||||||
{{ form_widget(form.activeChildren) }}
|
|
||||||
|
{% if form.activeChildren is defined %}
|
||||||
|
<h2>{{ 'Contacts'|trans }}</h2>
|
||||||
|
{{ form_widget(form.activeChildren) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<div class="mb-3 row">
|
<div class="mb-3 row">
|
||||||
{{ form_label(form.address) }}
|
{{ form_label(form.address) }}
|
||||||
@ -54,6 +56,6 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{ form_row(form.comment) }}
|
{{ form_row(form.comment) }}
|
||||||
{{ form_row(form.centers) }}
|
{{ form_row(form.centers) }}
|
||||||
|
|
||||||
{{ form_row(form.active) }}
|
{{ form_row(form.active) }}
|
||||||
|
37
src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/new_pick_kind.html.twig
vendored
Normal file
37
src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/new_pick_kind.html.twig
vendored
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
{% extends "@ChillMain/layout.html.twig" %}
|
||||||
|
|
||||||
|
{% block title 'thirdparty.Which kind of third party ?'|trans %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="col-10 centered">
|
||||||
|
<h1>{{ block('title') }}</h1>
|
||||||
|
|
||||||
|
<div class="container" style="margin-top: 2rem;">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4">
|
||||||
|
<a
|
||||||
|
href="{{ chill_path_forward_return_path('chill_crud_3party_3party_new', {'kind': 'company'}) }}"
|
||||||
|
class="btn btn-outline-chill-green-dark">
|
||||||
|
{{ 'thirdparty.A company'|trans }}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-8">
|
||||||
|
<p>{{ 'thirdparty.a_company_explanation'|trans }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4">
|
||||||
|
<a
|
||||||
|
href="{{ chill_path_forward_return_path('chill_crud_3party_3party_new', {'kind': 'contact'}) }}"
|
||||||
|
class="btn btn-outline-chill-green-dark">
|
||||||
|
{{ 'thirdparty.A contact'|trans }}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-8">
|
||||||
|
<p>{{ 'thirdparty.a_contact_explanation'|trans }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
@ -28,7 +28,7 @@
|
|||||||
{{ thirdParty.name }}
|
{{ thirdParty.name }}
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
{% if thirdParty.isLeaf == false %}
|
{% if thirdParty.kind == 'company' %}
|
||||||
<dt>{{ 'thirdparty.NameCompany'|trans }}</dt>
|
<dt>{{ 'thirdparty.NameCompany'|trans }}</dt>
|
||||||
<dd>
|
<dd>
|
||||||
{% if thirdParty.nameCompany == null %}
|
{% if thirdParty.nameCompany == null %}
|
||||||
@ -99,20 +99,22 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
<dt>{{ 'Contacts'|trans }}</dt>
|
{% if thirdParty.kind == 'company' %}
|
||||||
<dd>
|
<dt>{{ 'Contacts'|trans }}</dt>
|
||||||
{% if thirdParty.activeChildren|length == 0 %}
|
<dd>
|
||||||
<p class="chill-no-data-statement">{{ 'Any contacts associated'|trans }}</p>
|
{% if thirdParty.activeChildren|length == 0 %}
|
||||||
{% else %}
|
<p class="chill-no-data-statement">{{ 'Any contacts associated'|trans }}</p>
|
||||||
<div class="flex-table">
|
{% else %}
|
||||||
{% for tp in thirdParty.activeChildren %}
|
<div class="flex-table">
|
||||||
<div class="item-bloc">
|
{% for tp in thirdParty.activeChildren %}
|
||||||
{{ tp|chill_entity_render_box({'render': 'bloc', 'addLink': false}) }}
|
<div class="item-bloc">
|
||||||
|
{{ tp|chill_entity_render_box({'render': 'bloc', 'addLink': false}) }}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endif %}
|
||||||
</div>
|
</dd>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</dd>
|
|
||||||
|
|
||||||
<dt>{{ 'Centers'|trans }}</dt>
|
<dt>{{ 'Centers'|trans }}</dt>
|
||||||
<dd>
|
<dd>
|
||||||
|
@ -41,11 +41,11 @@ final class Version20211007165001 extends AbstractMigration
|
|||||||
NEW.canonicalized =
|
NEW.canonicalized =
|
||||||
UNACCENT(
|
UNACCENT(
|
||||||
LOWER(
|
LOWER(
|
||||||
name ||
|
NEW.name ||
|
||||||
CASE WHEN COALESCE(name_company, '') <> '' THEN ' ' ELSE '' END ||
|
CASE WHEN COALESCE(NEW.name_company, '') <> '' THEN ' ' ELSE '' END ||
|
||||||
COALESCE(name_company, '') ||
|
COALESCE(NEW.name_company, '') ||
|
||||||
CASE WHEN COALESCE(acronym, '') <> '' THEN ' ' ELSE '' END ||
|
CASE WHEN COALESCE(NEW.acronym, '') <> '' THEN ' ' ELSE '' END ||
|
||||||
COALESCE(acronym, '')
|
COALESCE(NEW.acronym, '')
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
|
@ -29,6 +29,14 @@ thirdparty.UpdateBy.short: ' par '
|
|||||||
thirdparty.CreatedAt.long: Date de création
|
thirdparty.CreatedAt.long: Date de création
|
||||||
thirdparty.UpdatedAt.long: Date de la dernière modification
|
thirdparty.UpdatedAt.long: Date de la dernière modification
|
||||||
thirdparty.UpdateBy.long: Utilisateur qui a effectué la dernière modification
|
thirdparty.UpdateBy.long: Utilisateur qui a effectué la dernière modification
|
||||||
|
thirdparty.A company: Une institution
|
||||||
|
thirdparty.A contact: Une personne physique
|
||||||
|
thirdparty.a_company_explanation: >-
|
||||||
|
Les institutions peuvent compter un ou plusieurs contacts, interne à l'instution. Il est également possible de
|
||||||
|
leur associer un acronyme, et le nom d'un service.
|
||||||
|
thirdparty.a_contact_explanation: >-
|
||||||
|
Les personnes physiques ne disposent pas d'acronyme, de service, ou de contacts sous-jacents.
|
||||||
|
thirdparty.Which kind of third party ?: Quel type de tiers souhaitez-vous créer ?
|
||||||
|
|
||||||
New third party: Ajouter un nouveau tiers
|
New third party: Ajouter un nouveau tiers
|
||||||
Show third party %name%: Tiers "%name%"
|
Show third party %name%: Tiers "%name%"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user