Commit 92ee1955 by Julien Jorry

Fix admin : export reconversion + achat monnait + filters by groupe in operations...

parent 5ebef175
......@@ -253,7 +253,7 @@ jQuery(document).ready(function() {
var form = this.closest('form')
// Set form moyen
$('#' + form.name + '_moyen')[0].value = 'mlc'
$('#' + form.name + '_moyen')[0].value = 'emlc'
if (form.checkValidity()) {
var div = '.confirmCotisation'
......
......@@ -31,7 +31,10 @@ class AchatMonnaieAConfirmerAdmin extends AbstractAdmin
protected $datagridValues = [
'_sort_order' => 'DESC',
'_sort_by' => 'createdAt',
'_per_page' => 100,
];
protected $maxPerPage = 100;
protected $perPageOptions = [50, 100, 250, 500, 1000];
public function setSecurity(Security $security)
{
......@@ -68,8 +71,8 @@ class AchatMonnaieAConfirmerAdmin extends AbstractAdmin
'show_filter' => true,
])
->add('createdAt', 'doctrine_orm_datetime_range', [
'field_type'=> DateTimeRangePickerType::class,
'label' => 'Date'
'field_type' => DateTimeRangePickerType::class,
'label' => 'Date',
])
;
}
......
......@@ -3,6 +3,7 @@
namespace App\Admin;
use App\Entity\Flux;
use App\Entity\Groupe;
use App\Entity\Prestataire;
use App\Entity\User;
use App\Enum\MoyenEnum;
......@@ -36,7 +37,10 @@ class CotisationAdmin extends AbstractAdmin
protected $datagridValues = [
'_sort_order' => 'DESC',
'_sort_by' => 'createdAt',
'_per_page' => 250,
];
protected $maxPerPage = 250;
protected $perPageOptions = [50, 100, 250, 500, 1000];
public function setSecurity(Security $security)
{
......@@ -48,9 +52,37 @@ class CotisationAdmin extends AbstractAdmin
*/
protected function configureDatagridFilters(DatagridMapper $datagridMapper): void
{
$em = $this->getConfigurationPool()->getContainer()->get('doctrine')->getManager();
$datagridMapper
->add('cotisationInfos.annee', null, ['label' => 'Année'])
->add('montant', null, ['label' => 'Montant'])
->add('groupe', 'doctrine_orm_callback', [
'label' => 'Groupe local',
'callback' => function ($queryBuilder, $alias, $field, $value) {
if (!$value['value']) {
return;
}
$queryBuilder
->leftJoin('App\Entity\CotisationPrestataire', 'c', 'WITH', $alias . '.id = c.id')
->leftJoin('App\Entity\CotisationAdherent', 'ca', 'WITH', $alias . '.id = ca.id')
->leftJoin('c.expediteur', 'e')
->leftJoin('ca.expediteur', 'f')
->andWhere('e.groupe = :groupe OR f.groupe = :groupe')
->setParameter('groupe', $value['value']);
return true;
},
'advanced_filter' => false,
'show_filter' => true,
'field_type' => ChoiceType::class,
'field_options' => [
'choices' => $em->getRepository(Groupe::class)->findBy(['enabled' => true], ['name' => 'ASC']),
'choice_label' => 'name',
'placeholder' => 'Indifférent',
'expanded' => false,
'multiple' => false,
],
])
->add('cotisationInfos.recu', null, [
'label' => 'Recu ?',
'show_filter' => true,
......@@ -154,6 +186,9 @@ class CotisationAdmin extends AbstractAdmin
->add('id', 'text', [
'template' => '@kohinos/bundles/SonataAdminBundle/Block/cotisation_obj.html.twig',
])
->add('expediteur.groupe.name', null, [
'label' => 'Groupe',
])
->add('cotisationInfos.annee', null, [
'label' => 'Année',
])
......@@ -184,4 +219,30 @@ class CotisationAdmin extends AbstractAdmin
])
;
}
public function getDataSourceIterator()
{
$iterator = parent::getDataSourceIterator();
$iterator->setDateTimeFormat('d/m/Y H:i:s'); //change this to suit your needs
return $iterator;
}
public function getExportFields()
{
return [
'Id' => 'expediteur',
'Groupe' => 'expediteur.groupe.name',
'Annee' => 'cotisationInfos.annee',
'Type' => 'type',
'Montant' => 'montant',
'Moyen' => 'moyen',
'Crée le' => 'cotisationInfos.debut',
'Expire le' => 'cotisationInfos.fin',
'Reçu ?' => 'cotisationInfos.recu',
'Operateur' => 'operateurAndRole',
'Reference' => 'reference',
'Date' => 'created_at',
];
}
}
......@@ -26,7 +26,10 @@ class FluxAdmin extends AbstractAdmin
protected $datagridValues = [
'_sort_order' => 'DESC',
'_sort_by' => 'createdAt',
'_per_page' => 250,
];
protected $maxPerPage = 250;
protected $perPageOptions = [50, 100, 250, 500, 1000];
public function setTranslator(TranslatorInterface $translator)
{
......@@ -141,24 +144,24 @@ class FluxAdmin extends AbstractAdmin
'show_filter' => true,
])
->add('createdAt', 'doctrine_orm_datetime_range', [
'field_type'=> DateTimeRangePickerType::class,
'label' => 'Date'
'field_type' => DateTimeRangePickerType::class,
'label' => 'Date',
])
;
}
public function getTemplate($name)
{
if ('list' == $name) {
return '@kohinos/block/base_list_with_total.html.twig';
}
// if ('list' == $name) {
// return '@kohinos/block/base_list_with_total.html.twig';
// }
return parent::getTemplate($name);
}
public function getTotalLabel()
{
return $this->translator->trans('Total des flux :');
return $this->translator->trans('Total des flux');
}
public function getTotal()
......@@ -180,14 +183,14 @@ class FluxAdmin extends AbstractAdmin
public function getExportFields()
{
return [
'Date' => 'created_at',
'Type' => 'type',
'Montant' => 'montant',
'Expediteur' => 'expediteur',
'Destinataire' => 'destinataire',
'Operateur' => 'operateur',
'Moyen' => 'moyen',
'Reference' => 'reference',
'Date' => 'created_at',
'Type' => 'type',
'Montant' => 'montant',
'Expediteur' => 'expediteur',
'Destinataire' => 'destinataire',
'Operateur' => 'operateur',
'Moyen' => 'moyen',
'Reference' => 'reference',
];
}
}
......@@ -7,8 +7,6 @@ use App\Entity\Adherent;
use App\Entity\OperationAdherent;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Route\RouteCollection;
use Symfony\Component\Security\Core\Security;
/**
* Administration des operation des prestataires.
......@@ -19,23 +17,6 @@ use Symfony\Component\Security\Core\Security;
*/
class OperationAdherentAdmin extends OperationAdmin
{
protected $security;
protected $session;
protected $datagridValues = [
'_sort_order' => 'DESC',
'_sort_by' => 'createdAt',
];
public function setSecurity(Security $security)
{
$this->security = $security;
}
protected function configureRoutes(RouteCollection $collection)
{
$collection->clearExcept(['list', 'export']);
}
protected function configureListFields(ListMapper $listMapper)
{
$listMapper->add('account.accountableObject', null, ['label' => 'Compte adherent', 'template' => '@kohinos/bundles/SonataAdminBundle/Block/accountable.html.twig']);
......
......@@ -27,7 +27,10 @@ class OperationAdmin extends AbstractAdmin
protected $datagridValues = [
'_sort_order' => 'DESC',
'_sort_by' => 'createdAt',
'_per_page' => 250,
];
protected $maxPerPage = 250;
protected $perPageOptions = [50, 100, 250, 500, 1000];
public function setTranslator(TranslatorInterface $translator)
{
......@@ -56,7 +59,7 @@ class OperationAdmin extends AbstractAdmin
'Type' => 'flux.type',
'Moyen' => 'flux.moyen',
'Operateur' => 'flux.operateur',
'Importé' => 'historical'
'Importé' => 'historical',
];
}
......@@ -104,7 +107,7 @@ class OperationAdmin extends AbstractAdmin
// public function getTotalLabel()
// {
// return $this->translator->trans('Total des opérations :');
// return $this->translator->trans('Total des opérations');
// }
protected function configureDatagridFilters(DatagridMapper $datagridMapper): void
......@@ -114,7 +117,7 @@ class OperationAdmin extends AbstractAdmin
->add('show_verify', CallbackFilter::class, [
'label' => 'Vérifier la validité des flux',
'advanced_filter' => false,
'show_filter' => true,
'show_filter' => false,
'field_type' => CheckboxType::class,
'callback' => static function (ProxyQueryInterface $query, string $alias, string $field, array $data): bool {
if (!$data['value']) {
......@@ -125,8 +128,8 @@ class OperationAdmin extends AbstractAdmin
},
])
->add('createdAt', 'doctrine_orm_datetime_range', [
'field_type'=> DateTimeRangePickerType::class,
'label' => 'Date'
'field_type' => DateTimeRangePickerType::class,
'label' => 'Date',
])
;
}
......
......@@ -7,8 +7,6 @@ use App\Entity\Comptoir;
use App\Entity\OperationComptoir;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Route\RouteCollection;
use Symfony\Component\Security\Core\Security;
/**
* Administration des operation des comptoirs.
......@@ -19,23 +17,6 @@ use Symfony\Component\Security\Core\Security;
*/
class OperationComptoirAdmin extends OperationAdmin
{
protected $security;
protected $session;
protected $datagridValues = [
'_sort_order' => 'DESC',
'_sort_by' => 'createdAt',
];
public function setSecurity(Security $security)
{
$this->security = $security;
}
protected function configureRoutes(RouteCollection $collection)
{
$collection->clearExcept(['list', 'export']);
}
protected function configureListFields(ListMapper $listMapper)
{
$listMapper->add('account.accountableObject', null, ['label' => 'Compte Comptoir', 'template' => '@kohinos/bundles/SonataAdminBundle/Block/accountable.html.twig']);
......
......@@ -4,8 +4,6 @@ namespace App\Admin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Route\RouteCollection;
use Symfony\Component\Security\Core\Security;
/**
* Administration des operation des groupes.
......@@ -16,23 +14,6 @@ use Symfony\Component\Security\Core\Security;
*/
class OperationGroupeAdmin extends OperationAdmin
{
protected $security;
protected $session;
protected $datagridValues = [
'_sort_order' => 'DESC',
'_sort_by' => 'createdAt',
];
public function setSecurity(Security $security)
{
$this->security = $security;
}
protected function configureRoutes(RouteCollection $collection)
{
$collection->clearExcept(['list', 'export']);
}
protected function configureListFields(ListMapper $listMapper)
{
$listMapper->add('account.accountableObject', null, ['label' => 'Compte Groupe', 'template' => '@kohinos/bundles/SonataAdminBundle/Block/accountable.html.twig']);
......
......@@ -7,8 +7,6 @@ use App\Entity\OperationPrestataire;
use App\Entity\Prestataire;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Route\RouteCollection;
use Symfony\Component\Security\Core\Security;
/**
* Administration des operation des prestataires.
......@@ -19,23 +17,6 @@ use Symfony\Component\Security\Core\Security;
*/
class OperationPrestataireAdmin extends OperationAdmin
{
protected $security;
protected $session;
protected $datagridValues = [
'_sort_order' => 'DESC',
'_sort_by' => 'createdAt',
];
public function setSecurity(Security $security)
{
$this->security = $security;
}
protected function configureRoutes(RouteCollection $collection)
{
$collection->clearExcept(['list', 'export']);
}
protected function configureListFields(ListMapper $listMapper)
{
$listMapper->add('account.accountableObject', null, ['label' => 'Compte prestataire', 'template' => '@kohinos/bundles/SonataAdminBundle/Block/accountable.html.twig']);
......
......@@ -5,9 +5,7 @@ namespace App\Admin;
use App\Entity\Siege;
use App\Enum\CurrencyEnum;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Route\RouteCollection;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Security\Core\Security;
/**
* Administration des operation du siege.
......@@ -18,23 +16,6 @@ use Symfony\Component\Security\Core\Security;
*/
class OperationSiegeAdmin extends OperationAdmin
{
protected $security;
protected $session;
protected $datagridValues = [
'_sort_order' => 'DESC',
'_sort_by' => 'createdAt',
];
public function setSecurity(Security $security)
{
$this->security = $security;
}
protected function configureRoutes(RouteCollection $collection)
{
$collection->clearExcept(['list', 'export']);
}
/**
* {@inheritdoc}
*/
......@@ -47,12 +28,14 @@ class OperationSiegeAdmin extends OperationAdmin
if (!$value['value']) {
return;
}
$queryBuilder
->where($alias . '.currency = :type')
->setParameter('type', $value['value']);
->andWhere($queryBuilder->expr()->in($alias . '.currency', ':types'))
->setParameter('types', $value['value']);
return true;
},
'label' => 'Devise',
'advanced_filter' => false,
'show_filter' => true,
'field_type' => ChoiceType::class,
......@@ -61,11 +44,11 @@ class OperationSiegeAdmin extends OperationAdmin
'choice_label' => function ($choice) {
return CurrencyEnum::getTypeName($choice);
},
'empty_data' => CurrencyEnum::CURRENCY_EMLC,
'data' => CurrencyEnum::CURRENCY_EMLC,
'empty_data' => [CurrencyEnum::CURRENCY_EMLC],
'data' => [CurrencyEnum::CURRENCY_EMLC],
'placeholder' => false,
'expanded' => true,
'multiple' => false,
'multiple' => true,
],
])
;
......
......@@ -50,10 +50,8 @@ class ReconversionAdmin extends FluxAdmin
unset($this->listModes['mosaic']);
$listMapper
->addIdentifier('createdAt', null, ['label' => 'Date'])
->addIdentifier('type', null, ['label' => 'Type'])
->addIdentifier('operateur', User::class, ['label' => 'Operateur'])
->addIdentifier('expediteur', null, ['label' => 'Expediteur'])
->addIdentifier('destinataire', null, ['label' => 'Destinataire'])
->add('montant', 'decimal', ['label' => 'Montant initial', 'attributes' => ['fraction_digits' => 2]])
->add('tauxreconversionpercent', 'percent', ['label' => 'Taux reconversion'])
->add('montantareconvertir', 'decimal', ['label' => 'Montant à transférer', 'attributes' => ['fraction_digits' => 2]])
......@@ -74,4 +72,28 @@ class ReconversionAdmin extends FluxAdmin
->remove('operateur')
;
}
public function getDataSourceIterator()
{
$iterator = parent::getDataSourceIterator();
$iterator->setDateTimeFormat('d/m/Y H:i:s'); //change this to suit your needs
return $iterator;
}
public function getExportFields()
{
return [
'Date' => 'created_at',
'Operateur' => 'operateurAndRole',
'Expediteur' => 'expediteur',
'Montant' => 'montant',
'tauxreconversionpercent' => 'tauxreconversionpercent',
'montantareconvertir' => 'montantareconvertir',
'montantcommission' => 'montantcommission',
'montantcommission' => 'montantcommission',
'Reference' => 'reference',
'Reconverti ?' => 'reconverti',
];
}
}
......@@ -40,7 +40,7 @@ class TransactionAdmin extends FluxAdmin
public function getTotalLabel()
{
return $this->translator->trans('Total des transactions :');
return $this->translator->trans('Total des transactions');
}
public function getTotal()
......@@ -105,8 +105,8 @@ class TransactionAdmin extends FluxAdmin
'show_filter' => true,
])
->add('createdAt', 'doctrine_orm_datetime_range', [
'field_type'=> DateTimeRangePickerType::class,
'label' => 'Date'
'field_type' => DateTimeRangePickerType::class,
'label' => 'Date',
])
;
}
......
......@@ -76,7 +76,7 @@ class TransfertAdmin extends FluxAdmin
->setParameter('ids', $ids)
;
}
} else if ($this->security->isGranted('ROLE_COMPTOIR')) {
} elseif ($this->security->isGranted('ROLE_COMPTOIR')) {
if (empty($this->getRequest()->getSession()->get('_comptoirgere'))) {
$query->andWhere('false = true');
} else {
......@@ -101,7 +101,7 @@ class TransfertAdmin extends FluxAdmin
public function getTotalLabel()
{
return $this->translator->trans('Total des transferts :');
return $this->translator->trans('Total des transferts');
}
public function getTotal()
......
......@@ -35,6 +35,12 @@
</ul>
</div>
</div>
{% if admin.total is defined and admin.total > 0 %}
<div class="pull-left" style="margin: 5px 5px;">
<label for="{{ admin.uniqid }}_sum_of_orders" class="control-label">{{ admin.totalLabel is defined ? admin.totalLabel : (('Total'|trans))}} : </label>
<label class="control-label">{{ admin.total }}</label>
</div>
{% endif %}
{#
{% if block('pager_results') is not empty %}
&nbsp;-&nbsp;
......
......@@ -260,4 +260,6 @@ Cotiser: Cotiser
Cotisation: Cotisation
'Votre adhésion a bien été prise en compte, bienvenue !': 'Votre adhésion a bien été prise en compte, bienvenue !'
'Décharger prestataire': 'Décharger prestataire'
invalid_message: 'Captcha invalide !'
\ No newline at end of file
invalid_message: 'Captcha invalide !'
Mlc: 'Monnaie papier'
Emlc: 'Monnaie numérique'
\ No newline at end of file
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