Commit 2c1beaf3 by Yvon

6048 : show all achats de monnaie in achats de monnaie tab

parent dbfbae89
...@@ -27,9 +27,17 @@ class AchatMonnaieAdmin extends FluxAdmin ...@@ -27,9 +27,17 @@ class AchatMonnaieAdmin extends FluxAdmin
public function createQuery($context = 'list') public function createQuery($context = 'list')
{ {
$query = parent::createQuery($context); $query = parent::createQuery($context);
$query->andWhere($query->getRootAliases()[0] . '.parenttype = :parenttype') //In mode ssa_friendly_flux_type_names, we display on this page all cotisation
//initial operation (i.e. we display vente_emlc operations in addition to achat_monnaie)
if($this->getConfigurationPool()->getContainer()->getParameter('tav_env')
&& $this->getConfigurationPool()->getContainer()->getParameter('ssa_friendly_flux_type_names')) {
$query->andWhere($query->getRootAliases()[0] . '.parenttype = :parenttype' . ' OR ' . $query->getRootAliases()[0] . '.parenttype = :parenttype2')
->setParameter('parenttype', Flux::TYPE_ACHAT)
->setParameter('parenttype2', Flux::TYPE_VENTE_EMLC);
} else {
$query->andWhere($query->getRootAliases()[0] . '.parenttype = :parenttype')
->setParameter('parenttype', Flux::TYPE_ACHAT); ->setParameter('parenttype', Flux::TYPE_ACHAT);
}
return $query; return $query;
} }
...@@ -43,17 +51,24 @@ class AchatMonnaieAdmin extends FluxAdmin ...@@ -43,17 +51,24 @@ class AchatMonnaieAdmin extends FluxAdmin
*/ */
protected function configureDatagridFilters(DatagridMapper $datagridMapper): void protected function configureDatagridFilters(DatagridMapper $datagridMapper): void
{ {
$datagridMapper->add('type', null, [ //In mode ssa_friendly_flux_type_names, we display on this page all cotisation
'advanced_filter' => false, //initial operation (i.e. we display vente_emlc operations in addition to achat_monnaie)
'show_filter' => true, //therefore filtering by type achat_monnaie_adherent VS achat_monnaie_prestataire
'field_type' => ChoiceType::class, //would be confusing (selecting one of them would hide all vente_emlc operations)
'field_options' => [ if(!$this->getConfigurationPool()->getContainer()->getParameter('tav_env')
'choices' => ['Adhérent' => 'achat_monnaie_adherent', 'Prestataire' => 'achat_monnaie_prestataire'], || !$this->getConfigurationPool()->getContainer()->getParameter('ssa_friendly_flux_type_names')) {
'placeholder' => 'Indifférent', $datagridMapper->add('type', null, [
'expanded' => true, 'advanced_filter' => false,
'multiple' => false, 'show_filter' => true,
], 'field_type' => ChoiceType::class,
]); 'field_options' => [
'choices' => ['Adhérent' => 'achat_monnaie_adherent', 'Prestataire' => 'achat_monnaie_prestataire'],
'placeholder' => 'Indifférent',
'expanded' => true,
'multiple' => false,
],
]);
}
} }
/** /**
...@@ -81,12 +96,24 @@ class AchatMonnaieAdmin extends FluxAdmin ...@@ -81,12 +96,24 @@ class AchatMonnaieAdmin extends FluxAdmin
$datagrid->buildPager(); $datagrid->buildPager();
$query = clone $datagrid->getQuery(); $query = clone $datagrid->getQuery();
$query if($this->getConfigurationPool()->getContainer()->getParameter('tav_env')
->select('SUM( ' . $query->getRootAlias() . '.montant) as total') && $this->getConfigurationPool()->getContainer()->getParameter('ssa_friendly_flux_type_names')) {
->andWhere($query->getRootAlias() . '.parenttype = :parenttype') $query
->setParameter('parenttype', Flux::TYPE_ACHAT) ->select('SUM( ' . $query->getRootAlias() . '.montant) as total')
->setFirstResult(null) ->andWhere($query->getRootAlias() . '.parenttype = :parenttype' . ' OR ' . $query->getRootAliases()[0] . '.parenttype = :parenttype2')
->setMaxResults(null); ->setParameter('parenttype', Flux::TYPE_ACHAT)
->setParameter('parenttype2', Flux::TYPE_VENTE_EMLC)
->setFirstResult(null)
->setMaxResults(null);
} else {
$query
->select('SUM( ' . $query->getRootAlias() . '.montant) as total')
->andWhere($query->getRootAlias() . '.parenttype = :parenttype')
->setParameter('parenttype', Flux::TYPE_ACHAT)
->setFirstResult(null)
->setMaxResults(null);
}
$result = $query->execute([], \Doctrine\ORM\Query::HYDRATE_SINGLE_SCALAR); $result = $query->execute([], \Doctrine\ORM\Query::HYDRATE_SINGLE_SCALAR);
......
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