Commit 187ab678 by Damien Moulard

adherents external data in admin, add cohortes list global parameter

parent 956fa2ea
......@@ -4,10 +4,16 @@ namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Ramsey\Uuid\Doctrine\UuidGenerator;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity
* @ORM\Table(name="external_adherent_dated_data")
* @ORM\Table(name="external_adherent_dated_data", uniqueConstraints={@ORM\UniqueConstraint(name="adherentyear", columns={"adherent_id", "year"})})
* @UniqueEntity(
* fields={"adherent", "year"},
* errorPath="adherent",
* message="Une entrée existe déjà pour cet adhérent et cette année"
* )
*/
class ExternalAdherentDatedData
{
......
......@@ -76,6 +76,7 @@ class GlobalParameter
const GEOLOC_QUARTIER_LIST_VALUES = 'GEOLOC_QUARTIER_LIST_VALUES';
const GEOLOC_WITH_SUBTERRITORY = 'GEOLOC_WITH_SUBTERRITORY';
const COMPTOIR_PAYMENT_TYPES = 'COMPTOIR_PAYMENT_TYPES';
const SSA_ADH_EXTERNAL_DATA_COHORTES_LIST = 'SSA_ADH_EXTERNAL_DATA_COHORTES_LIST';
/**
* @var \Ramsey\Uuid\UuidInterface
......
......@@ -3,8 +3,10 @@
namespace App\Form\Type;
use App\Entity\ExternalAdherentData;
use App\Entity\GlobalParameter;
use Symfony\Component\Form\AbstractType;
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 Doctrine\ORM\EntityManagerInterface;
......@@ -20,14 +22,29 @@ class ExternalAdherentDataFormType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$cohortesList = $this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::SSA_ADH_EXTERNAL_DATA_COHORTES_LIST);
$cohortesListArr = [];
foreach (explode(",", $cohortesList) as $cohorte) {
$cohortesListArr[$cohorte] = $cohorte;
}
$builder
->add('cohort', TextType::class, [
'label' => 'Cohorte',
->add('cohort',ChoiceType::class, [
'choices' => $cohortesListArr,
'label' => "Cohorte",
'required' => false,
'attr' => [
'autocomplete' => 'off'
],
'placeholder' => "Choix de la cohorte",
])
->add('external_id', TextType::class, [
'label' => 'ID externe',
'required' => false,
'attr' => [
'autocomplete' => 'off'
],
])
;
}
......
......@@ -24,14 +24,23 @@ class ExternalAdherentDatedDataFormType extends AbstractType
->add('year', NumberType::class, [
'label' => 'Année',
'required' => true,
'attr' => [
'autocomplete' => 'off'
],
])
->add('annual_income', NumberType::class, [
'label' => 'Revenu annuel',
'required' => false,
'attr' => [
'autocomplete' => 'off'
],
])
->add('monthly_income', NumberType::class, [
'label' => 'Revenu mensuel',
'required' => false,
'attr' => [
'autocomplete' => 'off'
],
])
;
}
......
<?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 Version20251009075632 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('ALTER TABLE caissier DROP FOREIGN KEY FK_1F038BC2A76ED395');
$this->addSql('ALTER TABLE caissier DROP FOREIGN KEY FK_1F038BC2BE3DB2B7');
$this->addSql('ALTER TABLE caissier CHANGE last_transactions_export_datetime last_transactions_export_datetime DATETIME DEFAULT NULL');
$this->addSql('DROP INDEX idx_ff8e6fc2a76ed395 ON caissier');
$this->addSql('CREATE INDEX IDX_1F038BC2A76ED395 ON caissier (user_id)');
$this->addSql('DROP INDEX idx_ff8e6fc2be3db2b7 ON caissier');
$this->addSql('CREATE INDEX IDX_1F038BC2BE3DB2B7 ON caissier (prestataire_id)');
$this->addSql('ALTER TABLE caissier ADD CONSTRAINT FK_1F038BC2A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE caissier ADD CONSTRAINT FK_1F038BC2BE3DB2B7 FOREIGN KEY (prestataire_id) REFERENCES prestataire (id)');
$this->addSql('CREATE UNIQUE INDEX adherentyear ON external_adherent_dated_data (adherent_id, year)');
$this->addSql('ALTER TABLE prestataire CHANGE iban iban LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:personal_data)\'');
$this->addSql("INSERT INTO global_parameter (id, name, description, value, mandatory) VALUES (UUID(), 'SSA_ADH_EXTERNAL_DATA_COHORTES_LIST', 'Si les données de suivi sont activées (paramètre USE_EXTERNAL_DATA), définit les valeurs de la liste des roulantes des cohortes. Insérer les valeurs désirées dans l\'ordre séparées par une virgule sans espace.', NULL, '0')");
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE caissier DROP FOREIGN KEY FK_1F038BC2A76ED395');
$this->addSql('ALTER TABLE caissier DROP FOREIGN KEY FK_1F038BC2BE3DB2B7');
$this->addSql('ALTER TABLE caissier CHANGE last_transactions_export_datetime last_transactions_export_datetime DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\'');
$this->addSql('DROP INDEX idx_1f038bc2be3db2b7 ON caissier');
$this->addSql('CREATE INDEX IDX_FF8E6FC2BE3DB2B7 ON caissier (prestataire_id)');
$this->addSql('DROP INDEX idx_1f038bc2a76ed395 ON caissier');
$this->addSql('CREATE INDEX IDX_FF8E6FC2A76ED395 ON caissier (user_id)');
$this->addSql('ALTER TABLE caissier ADD CONSTRAINT FK_1F038BC2A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE caissier ADD CONSTRAINT FK_1F038BC2BE3DB2B7 FOREIGN KEY (prestataire_id) REFERENCES prestataire (id)');
$this->addSql('DROP INDEX adherentyear ON external_adherent_dated_data');
$this->addSql('ALTER TABLE prestataire CHANGE iban iban LONGTEXT CHARACTER SET utf8mb3 DEFAULT NULL COLLATE `utf8mb3_general_ci` COMMENT \'(DC2Type:personal_data)\'');
$this->addSql("DELETE FROM global_parameter where name='SSA_ADH_EXTERNAL_DATA_COHORTES_LIST'");
}
}
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