Commit 8ad09006 by Damien Moulard

add parameters to prevent comptoir to update foyer & cotisation data

parent 7e886ec1
......@@ -162,6 +162,7 @@ class AdherentAdmin extends AbstractAdmin
}
// params
$em = $this->getConfigurationPool()->getContainer()->get('doctrine')->getManager();
$tav_env = $this->getConfigurationPool()->getContainer()->getParameter('tav_env');
$household_based_allowance = $this->getConfigurationPool()->getContainer()->getParameter('household_based_allowance');
$simplified_household_based_allowance = $this->getConfigurationPool()->getContainer()->getParameter('simplified_household_based_allowance');
......@@ -216,6 +217,12 @@ class AdherentAdmin extends AbstractAdmin
;
}
$isComptoirOnly =
$this->security->isGranted('ROLE_COMPTOIR')
&& !$this->isGranted('ROLE_ADMIN')
&& !$this->isGranted('ROLE_SUPER_ADMIN')
&& !$this->isGranted('ROLE_ADMIN_SIEGE');
/**
* In TAV env, 3 allowance processes possible:
* - household based (if param set)
......@@ -223,10 +230,18 @@ class AdherentAdmin extends AbstractAdmin
* - cotisation profile and rate based (default)
*/
if ($household_based_allowance) {
$allowComptoirUpdate = $em->getRepository(GlobalParameter::class)->val(GlobalParameter::SSA_ALLOW_COMPTOIR_TO_UPDATE_HOUSEHOLD_ALLOCATION_DATA);
$disableHouseholdAllowanceFields = $allowComptoirUpdate == 'false' && $isComptoirOnly && $this->isCurrentRoute('edit');
$comptoirAllocationMsg = $em->getRepository(GlobalParameter::class)->val(GlobalParameter::SSA_HOUSEHOLD_ALLOCATION_MSG_FOR_COMPTOIR);
if ($simplified_household_based_allowance) {
$formMapper
->tab('General')
->with('Foyer', ['class' => 'col-md-7'])
->with('Foyer', [
'class' => 'col-md-7',
'description' => $comptoirAllocationMsg
])
->add('householdComposition',ChoiceType::class, [
'choices' => [
"Personne seule" => "Personne seule",
......@@ -237,6 +252,7 @@ class AdherentAdmin extends AbstractAdmin
],
'label' => "Composition du foyer (pour information)",
'required' => true,
'disabled' => $disableHouseholdAllowanceFields,
'attr' => [
'autocomplete' => 'off'
],
......@@ -248,6 +264,7 @@ class AdherentAdmin extends AbstractAdmin
new GreaterThanOrEqual(['value' => 0]),
],
'required' => true,
'disabled' => $disableHouseholdAllowanceFields,
'attr' => [
'autocomplete' => 'off'
]
......@@ -302,7 +319,8 @@ class AdherentAdmin extends AbstractAdmin
->with('Informations de cotisation', ['class' => 'col-md-5'])
->add('cotisationAmount', NumberType::class, [
'label' => 'Montant de la cotisation (en €)',
'help' => $simplified_household_based_allowance ? '' : 'Montant minimum : 10€ par foyer + 5€/personne supplémentaire du foyer'
'help' => $simplified_household_based_allowance ? '' : 'Montant minimum : 10€ par foyer + 5€/personne supplémentaire du foyer',
'disabled' => $disableHouseholdAllowanceFields,
])
->add('allocationAmount', NumberType::class, [
'label' => 'Montant d\'allocation prévu en fonction du foyer (en MonA)',
......@@ -314,16 +332,7 @@ class AdherentAdmin extends AbstractAdmin
->end();
} else {
// For Comptoir role in edit mode, hide profile choice
$displayProfilChoice = true;
$isComptoirOnly =
$this->security->isGranted('ROLE_COMPTOIR')
&& !$this->isGranted('ROLE_ADMIN')
&& !$this->isGranted('ROLE_SUPER_ADMIN')
&& !$this->isGranted('ROLE_ADMIN_SIEGE');
if ($isComptoirOnly && $this->isCurrentRoute('edit')) {
$displayProfilChoice = false;
}
$displayProfilChoice = !($isComptoirOnly && $this->isCurrentRoute('edit'));
if ($displayProfilChoice) {
$formMapper
......@@ -400,7 +409,6 @@ class AdherentAdmin extends AbstractAdmin
}
if (!empty($adherent) && !empty($adherent->getEmlcAccount()) ) {
$em = $this->getConfigurationPool()->getContainer()->get('doctrine')->getManager();
$balance = $adherent->getEmlcAccount()->getBalance();
$mlc = $em->getRepository(GlobalParameter::class)->val(GlobalParameter::MLC_SYMBOL);
$formMapper
......@@ -483,7 +491,6 @@ class AdherentAdmin extends AbstractAdmin
}
}
$em = $this->getConfigurationPool()->getContainer()->get('doctrine')->getManager();
$formMapper->getFormBuilder()->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) use ($em) {
$adherent = $event->getData();
......
......@@ -54,6 +54,8 @@ class GlobalParameter
const VIREMENT_RECONVERSION_RAISON_GESTIONNAIRE = 'VIREMENT_RECONVERSION_RAISON_GESTIONNAIRE';
const VIREMENT_RECONVERSION_BIC_GESTIONNAIRE = 'VIREMENT_RECONVERSION_BIC_GESTIONNAIRE';
const VIREMENT_RECONVERSION_IBAN_GESTIONNAIRE = 'VIREMENT_RECONVERSION_IBAN_GESTIONNAIRE';
const SSA_ALLOW_COMPTOIR_TO_UPDATE_HOUSEHOLD_ALLOCATION_DATA = 'SSA_ALLOW_COMPTOIR_TO_UPDATE_HOUSEHOLD_ALLOCATION_DATA';
const SSA_HOUSEHOLD_ALLOCATION_MSG_FOR_COMPTOIR = 'SSA_HOUSEHOLD_ALLOCATION_MSG_FOR_COMPTOIR';
/**
* @var \Ramsey\Uuid\UuidInterface
......
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20250129104839 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql("INSERT INTO global_parameter (id, name, description, value, mandatory) VALUES (UUID(), 'SSA_ALLOW_COMPTOIR_TO_UPDATE_HOUSEHOLD_ALLOCATION_DATA', 'Définit si un comptoir à le droit de mettre à jour les information d\'allocation d\'un adhérent (update uniquement)', null, '1')");
$this->addSql("INSERT INTO global_parameter (id, name, description, value, mandatory) VALUES (UUID(), 'SSA_HOUSEHOLD_ALLOCATION_MSG_FOR_COMPTOIR', 'Affiche un message à l\'intention des comptoirs dans la fiche adhérent, section allocation', null, '1')");
}
public function down(Schema $schema) : void
{
$this->addSql("DELETE FROM global_parameter WHERE name='SSA_ALLOW_COMPTOIR_TO_UPDATE_HOUSEHOLD_ALLOCATION_DATA'");
$this->addSql("DELETE FROM global_parameter WHERE name='SSA_HOUSEHOLD_ALLOCATION_MSG_FOR_COMPTOIR'");
// this down() migration is auto-generated, please modify it to your needs
}
}
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