diff --git a/.gitignore b/.gitignore index eac073f..81ddf95 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,4 @@ yarn-error.log /public/media/ /migrations/* !/migrations/.gitkeep +/.build diff --git a/src/Entity/Conference.php b/src/Entity/Conference.php index 9d19915..dff0440 100644 --- a/src/Entity/Conference.php +++ b/src/Entity/Conference.php @@ -4,6 +4,8 @@ namespace App\Entity; use App\Core\Entity\EntityInterface; use App\Repository\ConferenceRepository; +use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; /** @@ -54,6 +56,21 @@ class Conference implements EntityInterface */ protected $date; + /** + * @ORM\Column(type="float", nullable=true) + */ + private $price; + + /** + * @ORM\ManyToMany(targetEntity=Speaker::class, inversedBy="conferences") + */ + private $speakers; + + public function __construct() + { + $this->speakers = new ArrayCollection(); + } + public function getId(): ?int { return $this->id; @@ -142,4 +159,40 @@ class Conference implements EntityInterface return $this; } + + public function getPrice(): ?float + { + return $this->price; + } + + public function setPrice(?float $price): self + { + $this->price = $price; + + return $this; + } + + /** + * @return Collection + */ + public function getSpeakers(): Collection + { + return $this->speakers; + } + + public function addSpeaker(Speaker $speaker): self + { + if (!$this->speakers->contains($speaker)) { + $this->speakers[] = $speaker; + } + + return $this; + } + + public function removeSpeaker(Speaker $speaker): self + { + $this->speakers->removeElement($speaker); + + return $this; + } } diff --git a/src/Entity/Project.php b/src/Entity/Project.php index c0edf7e..8a9ffe6 100644 --- a/src/Entity/Project.php +++ b/src/Entity/Project.php @@ -55,6 +55,11 @@ class Project implements EntityInterface */ private $events; + /** + * @ORM\Column(type="float", nullable=true) + */ + private $price; + public function __construct() { $this->establishments = new ArrayCollection(); @@ -206,4 +211,16 @@ class Project implements EntityInterface return $this; } + + public function getPrice(): ?float + { + return $this->price; + } + + public function setPrice(?float $price): self + { + $this->price = $price; + + return $this; + } } diff --git a/src/Entity/Speaker.php b/src/Entity/Speaker.php index 5b6e52c..fa513b8 100644 --- a/src/Entity/Speaker.php +++ b/src/Entity/Speaker.php @@ -61,10 +61,16 @@ class Speaker implements EntityInterface, EncryptedEntityInterface */ private $color; + /** + * @ORM\ManyToMany(targetEntity=Conference::class, mappedBy="speakers") + */ + private $conferences; + public function __construct() { $this->interventions = new ArrayCollection(); $this->events = new ArrayCollection(); + $this->conferences = new ArrayCollection(); } public function __toString() @@ -209,4 +215,31 @@ class Speaker implements EntityInterface, EncryptedEntityInterface return $this; } + + /** + * @return Collection + */ + public function getConferences(): Collection + { + return $this->conferences; + } + + public function addConference(Conference $conference): self + { + if (!$this->conferences->contains($conference)) { + $this->conferences[] = $conference; + $conference->addSpeaker($this); + } + + return $this; + } + + public function removeConference(Conference $conference): self + { + if ($this->conferences->removeElement($conference)) { + $conference->removeSpeaker($this); + } + + return $this; + } } diff --git a/src/Form/ConferenceType.php b/src/Form/ConferenceType.php index 9ffcf15..cef31ed 100644 --- a/src/Form/ConferenceType.php +++ b/src/Form/ConferenceType.php @@ -6,6 +6,7 @@ use App\Entity\Conference; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; +use Symfony\Component\Form\Extension\Core\Type\NumberType; class ConferenceType extends AbstractType { @@ -14,10 +15,21 @@ class ConferenceType extends AbstractType $builder ->add('label') ->add('themeType') + ->add('price', NumberType::class, [ + 'attr' => [ + 'step' => 0.01, + ], + 'scale' => 2, + 'required' => false, + 'html5' => true, + ]) ->add('date', null, [ 'html5' => true, 'widget' => 'single_text', ]) + ->add('speakers', null, [ + 'expanded' => true, + ]) ->add('persons') ->add('content', null, [ 'attr' => ['rows' => 7], diff --git a/src/Form/ProjectType.php b/src/Form/ProjectType.php index 8180aa6..312781d 100644 --- a/src/Form/ProjectType.php +++ b/src/Form/ProjectType.php @@ -8,6 +8,7 @@ use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; use App\Core\Form\Type\CollectionType; use Doctrine\ORM\EntityRepository; +use Symfony\Component\Form\Extension\Core\Type\NumberType; class ProjectType extends AbstractType { @@ -26,8 +27,23 @@ class ProjectType extends AbstractType ->addOrderBy('e.name', 'ASC'); }, ]) - ->add('description') - ->add('client') + ->add('price', NumberType::class, [ + 'row_attr' => [ + 'class' => 'col-md-3', + ], + 'attr' => [ + 'step' => 0.01, + ], + 'scale' => 2, + 'required' => false, + 'html5' => true, + ]) + ->add('description', null, [ + 'attr' => ['rows' => 7], + ]) + ->add('client', null, [ + 'attr' => ['rows' => 7], + ]) ->add('files', CollectionType::class, [ diff --git a/templates/admin/conference/_form.html.twig b/templates/admin/conference/_form.html.twig index c08b13d..0cecf16 100644 --- a/templates/admin/conference/_form.html.twig +++ b/templates/admin/conference/_form.html.twig @@ -1,6 +1,6 @@
- {% for item in ['themeType', 'date', 'persons'] %} + {% for item in ['themeType', 'date', 'persons', 'price', 'speakers'] %} {% include(configuration.view('form_widget', '@Core/admin/crud/_form_widget.html.twig')) with {form: form[item]} %} {% endfor %}
diff --git a/templates/admin/intervention/_form.html.twig b/templates/admin/intervention/_form.html.twig index d2372a2..9a397a3 100644 --- a/templates/admin/intervention/_form.html.twig +++ b/templates/admin/intervention/_form.html.twig @@ -1,6 +1,6 @@
- {% for item in ['date', 'establishmentGroups', 'activityReference', 'groups', 'levels', 'speakers'] %} + {% for item in ['date', 'establishmentGroups', 'activityReference', 'groups', 'levels', 'speakers', 'price'] %} {% include(configuration.view('form_widget', '@Core/admin/crud/_form_widget.html.twig')) with {form: form[item]} %} {% endfor %}
diff --git a/translations/messages.fr.yaml b/translations/messages.fr.yaml index 2f2154d..16518a3 100644 --- a/translations/messages.fr.yaml +++ b/translations/messages.fr.yaml @@ -44,3 +44,4 @@ "Distance": "Distance (sans retour)" "Is round trip": "Aller-retour" "Amount": "Montant (TTC)" +"Price": "Prix"