Commit 9d4bb669 by Damien Moulard

Merge branch '7915-quartier-as-list' into 'develop'

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

See merge request !142
parents f9011a4e 58f95bad
......@@ -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,10 @@ class GlobalParameter
return $this->value;
}
public function setValue(string $value): self
/**
* Allow to set null value with '?string'
*/
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,29 @@ 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,
'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 '
For SSA ("tav") projects, configure the presence / absence and content of quartier and subterritory in adherent profile.
At the time this migration is created, subterritory flag has different values in two different project already in production.
This is why we have a rule to decide what should be default value for it.
';
}
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')");
$containerName = trim(file_get_contents('/etc/hostname'));
if (str_contains($containerName, 'ssagironde')) {
$withSubterritoryDefaultValue = 'true';
} else {
$withSubterritoryDefaultValue = 'false';
}
$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.',
'$withSubterritoryDefaultValue',
'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