Commit 38241d8e by Damien Moulard

re set Flux/Achat de monnaie filter in admin

parent 793313a4
...@@ -8,6 +8,7 @@ use Sonata\AdminBundle\Datagrid\DatagridMapper; ...@@ -8,6 +8,7 @@ use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper; use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Route\RouteCollection; use Sonata\AdminBundle\Route\RouteCollection;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Sonata\DoctrineORMAdminBundle\Filter\CallbackFilter;
/** /**
* Administration des flux 'Achat de monnaie'. * Administration des flux 'Achat de monnaie'.
...@@ -51,18 +52,34 @@ class AchatMonnaieAdmin extends FluxAdmin ...@@ -51,18 +52,34 @@ class AchatMonnaieAdmin extends FluxAdmin
*/ */
protected function configureDatagridFilters(DatagridMapper $datagridMapper): void protected function configureDatagridFilters(DatagridMapper $datagridMapper): void
{ {
//In mode ssa_friendly_flux_type_names, we display on this page all cotisation if($this->getConfigurationPool()->getContainer()->getParameter('tav_env')
//initial operation (i.e. we display vente_emlc operations in addition to achat_monnaie) && $this->getConfigurationPool()->getContainer()->getParameter('ssa_friendly_flux_type_names')) {
//therefore filtering by type achat_monnaie_adherent VS achat_monnaie_prestataire $datagridMapper->add('type', null, [
//would be confusing (selecting one of them would hide all vente_emlc operations) 'advanced_filter' => false,
if(!$this->getConfigurationPool()->getContainer()->getParameter('tav_env') 'show_filter' => true,
|| !$this->getConfigurationPool()->getContainer()->getParameter('ssa_friendly_flux_type_names')) { 'field_type' => ChoiceType::class,
'field_options' => [
'choices' => [
'Achat des adhérents' => 'achat_monnaie_adherent',
'Achat des prestataires' => 'achat_monnaie_prestataire',
'Vente aux adhérents' => 'vente_emlc_adherent',
'Vente aux prestataires' => 'vente_emlc_prestataire',
],
'placeholder' => 'Indifférent',
'expanded' => false,
'multiple' => false,
],
]);
} else {
$datagridMapper->add('type', null, [ $datagridMapper->add('type', null, [
'advanced_filter' => false, 'advanced_filter' => false,
'show_filter' => true, 'show_filter' => true,
'field_type' => ChoiceType::class, 'field_type' => ChoiceType::class,
'field_options' => [ 'field_options' => [
'choices' => ['Adhérent' => 'achat_monnaie_adherent', 'Prestataire' => 'achat_monnaie_prestataire'], 'choices' => [
'Adhérent' => 'achat_monnaie_adherent',
'Prestataire' => 'achat_monnaie_prestataire',
],
'placeholder' => 'Indifférent', 'placeholder' => 'Indifférent',
'expanded' => true, 'expanded' => true,
'multiple' => false, 'multiple' => false,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment