Commit 2d0d9569 by Damien Moulard

presta info set reconversion frequency

parent 288434b1
......@@ -14,6 +14,7 @@ parameters:
sonata.media.admin.gallery.class: 'App\Admin\GalleryAdmin'
tav_env: '%env(TAV_ENV)%'
presta_self_init_and_eval: '%env(PRESTA_SELF_INIT_AND_EVAL)%'
automatisation_reconversion: '%env(AUTOMATISATION_RECONVERSION)%'
# PARAMETRES DES IMPORTS POSSIBLE POUR L'APPLICATION DE GESTION DE MONNAIE LOCALE COMPLEMENTAIRE
app.import.separator: ';'
......
......@@ -325,6 +325,15 @@ class Prestataire extends AccountableObject implements AccountableInterface
protected $tauxreconversion;
/**
* Fréquence de reconversion en cas d'automatisation des reconversions.
*
* @var string
* @ORM\Column(name="reconversionFrequency", type="string", length=50, nullable=true)
* @Groups({"read", "write"})
*/
protected $reconversionFrequency;
/**
* @var ArrayCollection|AccountPrestataire[]
* @ORM\OneToMany(targetEntity="AccountPrestataire", mappedBy="prestataire")
*/
......@@ -1107,6 +1116,28 @@ class Prestataire extends AccountableObject implements AccountableInterface
}
/**
* Get reconversionFrequency.
*
* @return
*/
public function getReconversionFrequency(): ?string
{
return $this->reconversionFrequency;
}
/**
* Set reconversionFrequency.
*
* @return $this
*/
public function setReconversionFrequency(?string $reconversionFrequency): self
{
$this->reconversionFrequency = $reconversionFrequency;
return $this;
}
/**
* Get comments.
*
* @return string comments
......
<?php
namespace App\Enum;
abstract class ReconversionFrequencyEnum
{
const MOYEN_ONCE_A_MONTH = 'once_a_month';
const MOYEN_TWICE_A_MONTH = 'twice_a_month';
const MOYEN_ONCE_TWO_MONTHS = 'once_every_two_month';
/** @var array user friendly named type */
protected static $typeName = [
self::MOYEN_ONCE_A_MONTH => '1 fois par mois',
self::MOYEN_TWICE_A_MONTH => '2 fois par mois',
self::MOYEN_ONCE_TWO_MONTHS => '1 fois tous les deux mois',
];
/**
* @param string $typeShortName
*
* @return string
*/
public static function getTypeName($typeShortName)
{
if (!isset(static::$typeName[$typeShortName])) {
return "Unknown type ($typeShortName)";
}
return static::$typeName[$typeShortName];
}
/**
* @return array<string>
*/
public static function getAvailableTypes()
{
return [
self::MOYEN_ONCE_A_MONTH,
self::MOYEN_TWICE_A_MONTH,
self::MOYEN_ONCE_TWO_MONTHS,
];
}
}
......@@ -5,6 +5,7 @@ namespace App\Form\Type;
use App\Application\Sonata\MediaBundle\Entity\Media;
use App\Entity\Prestataire;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use FOS\CKEditorBundle\Form\Type\CKEditorType;
use Sonata\MediaBundle\Form\Type\MediaType;
use Symfony\Component\Form\AbstractType;
......@@ -13,16 +14,20 @@ use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\UrlType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use App\Enum\ReconversionFrequencyEnum;
class PrestataireInfosFormType extends AbstractType
{
protected $em;
protected $container;
public function __construct(EntityManagerInterface $em)
public function __construct(EntityManagerInterface $em, ContainerInterface $container)
{
$this->em = $em;
$this->container = $container;
}
public function buildForm(FormBuilderInterface $builder, array $options)
......@@ -77,7 +82,26 @@ class PrestataireInfosFormType extends AbstractType
->add('web', UrlType::class, [
'label' => 'Site web :',
'required' => false,
])
]);
if ($this->container->getParameter('tav_env') && $this->container->getParameter('automatisation_reconversion')) {
$builder
->add('reconversionFrequency', ChoiceType::class, [
'choices' => ReconversionFrequencyEnum::getAvailableTypes(),
'choice_label' => function ($choice) {
return ReconversionFrequencyEnum::getTypeName($choice);
},
'expanded' => false,
'multiple' => false,
'label' => 'Fréquence de reconversion :',
'placeholder' => 'Choisir une option',
'required' => false,
]);
}
// $this->container->getParameter('tav_env')
$builder
->add('description', CKEditorType::class, [
'label' => 'Description :',
'required' => 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 Version20240216095500 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 prestataire ADD reconversionFrequency VARCHAR(50) DEFAULT NULL, 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 prestataire DROP reconversionFrequency, CHANGE iban iban LONGTEXT CHARACTER SET utf8mb3 DEFAULT NULL COLLATE `utf8mb3_general_ci` COMMENT \'(DC2Type:personal_data)\'');
}
}
......@@ -24,6 +24,9 @@
{{ form_row(form.metier) }}
{{ form_row(form.horaires) }}
{{ form_row(form.web) }}
{% if form.reconversionFrequency is defined %}
{{ form_row(form.reconversionFrequency) }}
{% endif %}
<hr/>
{{ form_row(form.media) }}
{{ form_row(form.description) }}
......
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