Commit 7d1fb02a by Yvon

5895-add-territory-to-address-section

parent 7ba7843f
......@@ -85,13 +85,12 @@ Création des tables et des contraintes :
Charger les fixtures standards :
Pour une instance non TAV :
**$ php bin/console hautelook:fixtures:load --purge-with-truncate --env=pro**
Pour une instance TAV :
**$ php bin/console hautelook:fixtures:load --purge-with-truncate --env=tavpro**
Pour une instance non SSA :
**$ php bin/console hautelook:fixtures:load --purge-with-truncate --env=pro**
Pour une instance TAV, ou bien :
**$ php bin/console hautelook:fixtures:load --purge-with-truncate --env=tavpro**
ou bien :
**$ php bin/console hautelook:fixtures:load --purge-with-truncate --env=ssagirondepro**
Vous obtiendrez cette erreur ci dessous, c'est normal !
......@@ -100,13 +99,13 @@ There is no main category related to context: rubrique
**$ php bin/console sonata:media:fix-media-context**
Pour une instance non TAV :
**$ php bin/console hautelook:fixtures:load --append --env=pro**
Pour une instance TAV :
Pour une instance non SSA :
**$ php bin/console hautelook:fixtures:load --append --env=pro**
Pour une instance TAV, ou bien :
**$ php bin/console hautelook:fixtures:load --append --env=tavpro**
ou bien :
**$ php bin/console hautelook:fixtures:load --append --env=ssagirondepro**
**$ php bin/console hautelook:fixtures:load --append --env=tavpro**
Supprimer le cache (si besoin)
......
......@@ -160,6 +160,9 @@ class AdherentAdmin extends AbstractAdmin
'required' => true,
'with_geoloc' => false,
'with_latlon' => false,
'with_subterritory' =>
$this->getConfigurationPool()->getContainer()->getParameter('tav_env')
&& $this->getConfigurationPool()->getContainer()->getParameter('household_based_allowance')
])
->end()
->with('Groupe', ['class' => 'col-md-5'])
......
......@@ -66,6 +66,14 @@ class Geoloc
*/
private $lon;
/**
* @var Subterritory
*
* @ORM\ManyToOne(targetEntity="Subterritory")
* @ORM\JoinColumn(name="subterritory_id", referencedColumnName="id", nullable=true)
*/
private $subterritory;
public function getId()
{
return $this->id;
......@@ -171,6 +179,26 @@ class Geoloc
return $this;
}
/**
* @return Subterritory|null
*/
public function getSubterritory(): ?Subterritory
{
return $this->subterritory;
}
/**
* @param Subterritory|null $subterritory
*
* @return Geoloc
*/
public function setSubterritory(?Subterritory $subterritory): Geoloc
{
$this->subterritory = $subterritory;
return $this;
}
public function __toString(): string
{
return (!empty($this->adresse) ? $this->adresse : '') . ' ' . (!empty($this->cpostal) ? $this->cpostal : '') . ' ' . (!empty($this->ville) ? $this->ville : '');
......
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Ramsey\Uuid\Doctrine\UuidGenerator;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity
* @ORM\Table(name="subterritory")
*/
class Subterritory
{
/**
* @var \Ramsey\Uuid\UuidInterface
*
* @ORM\Id
* @ORM\Column(type="uuid", unique=true)
* @ORM\GeneratedValue(strategy="CUSTOM")
* @ORM\CustomIdGenerator(class=UuidGenerator::class)
*/
protected $id;
/**
* @var string|null
*
* @ORM\Column(type="string", unique=true)
* @Assert\NotBlank
*/
protected $name;
public function getId()
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name)
{
$this->name = $name;
return $this;
}
}
......@@ -3,6 +3,8 @@
namespace App\Form\Type;
use App\Entity\Geoloc;
use App\Entity\Subterritory;
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;
......@@ -71,6 +73,18 @@ class GeolocFormType extends AbstractType
])
;
}
if (true === $options['with_subterritory']) {
$builder
->add('subterritory', EntityType::class, [
'class' => Subterritory::class,
'label' => 'Territoire',
'required' => true,
'choice_label' => 'name',
'placeholder' => "Choix du territoire",
'attr' => ['autocomplete' => 'off']
])
;
}
}
public function configureOptions(OptionsResolver $resolver)
......@@ -80,6 +94,7 @@ class GeolocFormType extends AbstractType
'data_class' => Geoloc::class,
'with_geoloc' => true,
'with_latlon' => true,
'with_subterritory' => false
]);
}
......
<?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 Version20240311154311 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('CREATE TABLE subterritory (id CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_7D1B925F5E237E06 (name), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_general_ci` ENGINE = InnoDB');
$this->addSql("INSERT INTO subterritory (id, name) VALUES (UUID(), 'Bordeaux Nord / Bordeaux La Benauge')");
$this->addSql("INSERT INTO subterritory (id, name) VALUES (UUID(), 'Pays foyen')");
$this->addSql("INSERT INTO subterritory (id, name) VALUES (UUID(), 'Bègles')");
$this->addSql("INSERT INTO subterritory (id, name) VALUES (UUID(), 'Sud Gironde / Bazadais')");
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE subterritory');
}
}
<?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 Version20240311155641 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 geoloc ADD subterritory_id CHAR(36) DEFAULT NULL COMMENT \'(DC2Type:uuid)\'');
$this->addSql('ALTER TABLE geoloc ADD CONSTRAINT FK_E1B7F4E7C8B38DB4 FOREIGN KEY (subterritory_id) REFERENCES subterritory (id)');
$this->addSql('CREATE INDEX IDX_E1B7F4E7C8B38DB4 ON geoloc (subterritory_id)');
$this->addSql('ALTER TABLE prestataire CHANGE iban iban LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:personal_data)\'');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE geoloc DROP FOREIGN KEY FK_E1B7F4E7C8B38DB4');
$this->addSql('DROP INDEX IDX_E1B7F4E7C8B38DB4 ON geoloc');
$this->addSql('ALTER TABLE geoloc DROP subterritory_id');
$this->addSql('ALTER TABLE prestataire CHANGE iban iban LONGTEXT CHARACTER SET utf8 DEFAULT NULL COLLATE `utf8_general_ci` COMMENT \'(DC2Type:personal_data)\'');
}
}
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