Commit 793313a4 by Damien Moulard

Merge branch '6344-operations-adherents-ajout-filtrage-sur-cotisation' into 'develop'

allow passing role to ListOperationFormType ; as adherent, add checkbox to show…

See merge request cooperatic/kohinos-tav!100
parents 21f3092e a57602de
......@@ -58,7 +58,7 @@ Copier le fichier .env.dist en .env et configurer :
- en environnement TAV, la variable AUTOMATISATION_RECONVERSION permet d'activer l'automatisation des reconversions
- en environnement TAV, la variable PRESTA_EXTRA_DATA permet d'indiquer puis d'afficher publiquement plus de données concernant les prestataires (e.g. familles de produits)
- en environnement TAV, la variable HOUSEHOLD_BASED_ALLOWANCE permet d'activer un mode de cotisations libres et d'allocations basées sur la composition du foyer
- en environnement TAV, la variable SSA_FRIENDLY_FLUX_TYPE_NAMES permet d'adapter le nommage des types de flux à un projet de type ssa
- en environnement TAV, la variable SSA_FRIENDLY_FLUX_TYPE_NAMES permet d'adapter le nommage des types de flux et les écrans de visualisation des flux à un projet de type SSA
Si vous utilisez Payzen comme moyen de paiement par CB :
......
......@@ -9,19 +9,26 @@ use Doctrine\ORM\EntityManagerInterface;
use Knp\Component\Pager\PaginatorInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Security as Secur;
class OperationsController extends AbstractController
{
protected $em;
protected $paginator;
protected $operationUtils;
protected $security;
private $session;
public function __construct(EntityManagerInterface $em, PaginatorInterface $paginator, OperationUtils $operationUtils)
public function __construct(EntityManagerInterface $em, PaginatorInterface $paginator, OperationUtils $operationUtils, Secur $security, SessionInterface $session)
{
$this->em = $em;
$this->paginator = $paginator;
$this->operationUtils = $operationUtils;
$this->security = $security;
$this->session = $session;
}
/**
......@@ -32,6 +39,20 @@ class OperationsController extends AbstractController
if (empty($this->getUser())) {
return $this->redirectToRoute('index');
}
//Prepare query depending on user role
$user = $this->security->getUser();
$role = "";
if (null != $this->session->get('_prestagere') && $user->isGranted('ROLE_PRESTATAIRE')) {
$role = "ROLE_PRESTATAIRE";
} elseif (null != $user->getAdherent() && $user->isGranted('ROLE_ADHERENT')) {
$role = "ROLE_ADHERENT";
} elseif (null != $this->session->get('_comptoirgere') && $user->isGranted('ROLE_COMPTOIR')) {
$role = "ROLE_COMPTOIR";
} elseif (null != $this->session->get('_groupegere') && $user->isGranted('ROLE_GESTION_GROUPE')) {
$role = "ROLE_GESTION_GROUPE";
}
if (!in_array($currency, CurrencyEnum::getAvailableTypes())) {
throw new \Exception('Opération impossible ! Type de currency ' . $currency . ' inexistant');
}
......@@ -39,7 +60,7 @@ class OperationsController extends AbstractController
$datemin = new \DateTime('first day of this month');
$datemin->setTime(0, 0, 0);
$datemax = new \DateTime('now');
$form = $this->createForm(ListOperationFormType::class);
$form = $this->createForm(ListOperationFormType::class, null, array("role" => $role));
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
......
......@@ -2,9 +2,12 @@
namespace App\Form\Type;
use App\Entity\Cotisation;
use App\Entity\Transaction;
use App\Enum\MoyenEnum;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
......@@ -58,6 +61,13 @@ class ListOperationFormType extends AbstractType
->add('xls', SubmitType::class)
->add('xml', SubmitType::class)
;
if($options['role'] === 'ROLE_ADHERENT') {
$builder
->add('showMonAPurchaseOnly', CheckboxType::class, [
'label' => 'Afficher uniquement les cotisations',
'required' => false
]);
}
}
/**
......@@ -67,6 +77,7 @@ class ListOperationFormType extends AbstractType
{
$resolver->setDefaults([
'data_class' => null,
'role' => ""
]);
}
......
......@@ -7,8 +7,10 @@ use App\Entity\AccountComptoir;
use App\Entity\AccountGroupe;
use App\Entity\AccountPrestataire;
use App\Entity\AccountSiege;
use App\Entity\AchatMonnaie;
use App\Entity\Adherent;
use App\Entity\Comptoir;
use App\Entity\Flux;
use App\Entity\Groupe;
use App\Entity\OperationAdherent;
use App\Entity\OperationComptoir;
......@@ -17,6 +19,7 @@ use App\Entity\OperationPrestataire;
use App\Entity\OperationSiege;
use App\Entity\Prestataire;
use App\Entity\Siege;
use App\Entity\VenteEmlc;
use App\Enum\CurrencyEnum;
use App\Enum\MoyenEnum;
use App\Events\FluxEvent;
......@@ -78,6 +81,13 @@ class OperationUtils
->setParameter('moyen', $request->get('formListOperations')['moyen'])
;
}
if (!empty($request->get('formListOperations')['showMonAPurchaseOnly'])) {
$qb
->andWhere('flux.type IN (:type_achat_monnaie_adherent, :type_vente_emlc_adherent)')
->setParameter('type_achat_monnaie_adherent', AchatMonnaie::TYPE_ACHAT_ADHERENT)
->setParameter('type_vente_emlc_adherent', VenteEmlc::TYPE_VENTE_EMLC_ADHERENT)
;
}
return $qb->getQuery();
}
......
......@@ -13,7 +13,12 @@
<div class='col-4'>{{ form_row(searchForm.moyen) }}</div>
<div class='col-4'>{{ form_row(searchForm.datemin) }}</div>
<div class='col-4'>{{ form_row(searchForm.datemax) }}</div>
<div class='col-12 text-right'>{{ form_row(searchForm.submit) }}</div>
{% if searchForm.showMonAPurchaseOnly is defined and ssa_friendly_flux_type_names %}
<div class='col-4'>{{ form_row(searchForm.showMonAPurchaseOnly) }}</div>
<div class='col-8 text-right'>{{ form_row(searchForm.submit) }}</div>
{% else %}
<div class='col-12 text-right'>{{ form_row(searchForm.submit) }}</div>
{% endif %}
</div>
<div class="table-responsive">
<table class="table">
......
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