Commit 65bf1fe3 by Damien Moulard

ssa: add params for Quartier and Territoire fields in adhérent admin & allow…

ssa: add params for Quartier and Territoire fields in adhérent admin & allow Quartier as list with param
parent f9011a4e
......@@ -172,6 +172,10 @@ class AdherentAdmin extends AbstractAdmin
$adherent->setGeoloc(new Geoloc());
}
$withQuartier = $em->getRepository(GlobalParameter::class)->val(GlobalParameter::SSA_HOUSEHOLD_WITH_QUARTIER);
$withSubterritory = $em->getRepository(GlobalParameter::class)->val(GlobalParameter::SSA_HOUSEHOLD_WITH_SUBTERRITORY);
$formMapper
->tab('General')
->with('Identité', ['class' => 'col-md-7'])
......@@ -185,11 +189,8 @@ class AdherentAdmin extends AbstractAdmin
'required' => true,
'with_geoloc' => false,
'with_latlon' => false,
'with_subterritory' =>
$tav_env
&& $household_based_allowance
&& !$simplified_household_based_allowance,
'with_quartier' => $tav_env && $household_based_allowance
'with_subterritory' => $tav_env && 'true' === $withSubterritory,
'with_quartier' => $tav_env && 'true' === $withQuartier
])
->end()
->with('Groupe', ['class' => 'col-md-5'])
......
......@@ -69,6 +69,9 @@ class GlobalParameter
const SSA_HOUSEHOLD_MAX_ALLOCATION_AMOUNT = 'SSA_HOUSEHOLD_MAX_ALLOCATION_AMOUNT';
const SSA_HOUSEHOLD_COTISATION_MINIMUM = 'SSA_HOUSEHOLD_COTISATION_MINIMUM';
const ALTERNATE_AVAILABLE_PAYMENT_TYPES_COMPTOIR = 'ALTERNATE_AVAILABLE_PAYMENT_TYPES_COMPTOIR';
const SSA_HOUSEHOLD_WITH_QUARTIER = 'SSA_HOUSEHOLD_WITH_QUARTIER';
const SSA_HOUSEHOLD_QUARTIER_LIST_VALUES = 'SSA_HOUSEHOLD_QUARTIER_LIST_VALUES';
const SSA_HOUSEHOLD_WITH_SUBTERRITORY = 'SSA_HOUSEHOLD_WITH_SUBTERRITORY';
/**
* @var \Ramsey\Uuid\UuidInterface
......@@ -139,7 +142,7 @@ class GlobalParameter
return $this->value;
}
public function setValue(string $value): self
public function setValue(?string $value): self
{
$this->value = $value;
......
......@@ -4,22 +4,27 @@ namespace App\Form\Type;
use App\Entity\Geoloc;
use App\Entity\Subterritory;
use App\Entity\GlobalParameter;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Routing\RouterInterface;
use Doctrine\ORM\EntityManagerInterface;
class GeolocFormType extends AbstractType
{
private $router;
protected $em;
public function __construct(RouterInterface $router)
public function __construct(RouterInterface $router, EntityManagerInterface $em)
{
$this->router = $router;
$this->em = $em;
}
public function buildForm(FormBuilderInterface $builder, array $options)
......@@ -74,11 +79,30 @@ class GeolocFormType extends AbstractType
;
}
if (true === $options['with_quartier']) {
$builder
->add('quartier', TextType::class, [
'required' => false,
])
;
$quartierListValues = $this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::SSA_HOUSEHOLD_QUARTIER_LIST_VALUES);
if (null !== $quartierListValues && '' !== $quartierListValues) {
$quartierListValuesArr = explode(",", $quartierListValues);
$builder
->add('quartier', ChoiceType::class, [
'choices' => $quartierListValuesArr,
'choice_label' => function ($choice) {
return $choice;
},
'expanded' => false,
'multiple' => false,
'required' => false,
//'label' => 'Sélectionnez un moyen de paiement :',
'attr' => ['autocomplete' => 'off']
])
;
} else {
$builder
->add('quartier', TextType::class, [
'required' => false,
])
;
}
}
if (true === $options['with_subterritory']) {
$builder
......
<?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 Version20250415103920 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_HOUSEHOLD_WITH_QUARTIER', 'En mode SSA, si la valeur est à true, affiche le champ \'Quartier\' dans la fiche Adhérent.', 'true', '0')");
$this->addSql("INSERT INTO global_parameter (id, name, description, value, mandatory) VALUES (UUID(), 'SSA_HOUSEHOLD_QUARTIER_LIST_VALUES', 'En mode SSA, si le champ \'Quartier\' est affiché et que ce paramètre est renseigné, affiche le champ sous forme de liste déroulante plutôt que de champ libre. Renseigner les valeurs séparées par une virgule sans espace (ex: Facultés,Hôpitaux,Montpellier Ouest,Gambetta).', '', '0')");
$this->addSql("INSERT INTO global_parameter (id, name, description, value, mandatory) VALUES (UUID(), 'SSA_HOUSEHOLD_WITH_SUBTERRITORY', 'En mode SSA, si la valeur est à true, affiche le champ \'Territoire\' dans la fiche Adhérent.', 'true', '0')");
}
public function down(Schema $schema) : void
{
$this->addSql("DELETE FROM global_parameter where name='SSA_HOUSEHOLD_WITH_QUARTIER'");
$this->addSql("DELETE FROM global_parameter where name='SSA_HOUSEHOLD_QUARTIER_LIST_VALUES'");
$this->addSql("DELETE FROM global_parameter where name='SSA_HOUSEHOLD_WITH_SUBTERRITORY'");
// 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