diff --git a/src/Bundle/ChillMainBundle/Controller/LocationApiController.php b/src/Bundle/ChillMainBundle/Controller/LocationApiController.php index 4e0e9d2d2..5c0301959 100644 --- a/src/Bundle/ChillMainBundle/Controller/LocationApiController.php +++ b/src/Bundle/ChillMainBundle/Controller/LocationApiController.php @@ -20,7 +20,10 @@ class LocationApiController extends ApiController $query->expr()->eq('e.createdBy', ':user'), $query->expr()->gte('e.createdAt', ':dateBefore') ), - $query->expr()->eq('e.availableForUsers', "'TRUE'") + $query->expr()->andX( + $query->expr()->eq('e.availableForUsers', "'TRUE'"), + $query->expr()->eq('e.active', "'TRUE'") + ) )) ->setParameters([ 'user' => $this->getUser(), diff --git a/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadLocationType.php b/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadLocationType.php index 5ad32168f..4e103cc8e 100644 --- a/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadLocationType.php +++ b/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadLocationType.php @@ -58,7 +58,8 @@ class LoadLocationType extends AbstractFixture implements ContainerAwareInterfac foreach ($arr as $a) { $locationType = (new LocationType()) ->setTitle($a['name']) - ->setAvailableForUsers(True) + ->setAvailableForUsers(true) + ->setActive(true) ->setAddressRequired($a['address_required']); $manager->persist($locationType); } diff --git a/src/Bundle/ChillMainBundle/Entity/Location.php b/src/Bundle/ChillMainBundle/Entity/Location.php index be97a4373..06e5ccca5 100644 --- a/src/Bundle/ChillMainBundle/Entity/Location.php +++ b/src/Bundle/ChillMainBundle/Entity/Location.php @@ -76,6 +76,12 @@ class Location implements TrackCreationInterface, TrackUpdateInterface */ private bool $availableForUsers = false; + /** + * @ORM\Column(type="boolean", nullable=true) + * @Serializer\Groups({"read"}) + */ + private bool $active = true; + /** * @ORM\ManyToOne(targetEntity=User::class) * @Serializer\Groups({"read"}) @@ -192,6 +198,18 @@ class Location implements TrackCreationInterface, TrackUpdateInterface return $this; } + public function getActive(): ?bool + { + return $this->active; + } + + public function setActive(bool $active): self + { + $this->active = $active; + + return $this; + } + public function getCreatedBy(): ?User { return $this->createdBy; diff --git a/src/Bundle/ChillMainBundle/Entity/LocationType.php b/src/Bundle/ChillMainBundle/Entity/LocationType.php index 6510d5c22..026fc727d 100644 --- a/src/Bundle/ChillMainBundle/Entity/LocationType.php +++ b/src/Bundle/ChillMainBundle/Entity/LocationType.php @@ -40,6 +40,12 @@ class LocationType */ private bool $availableForUsers = true; + /** + * @ORM\Column(type="boolean", nullable=true) + * @Serializer\Groups({"read"}) + */ + private bool $active = true; + /** * @ORM\Column(type="string", length=32, options={"default"="optional"}) * @Serializer\Groups({"read"}) @@ -70,6 +76,18 @@ class LocationType return $this; } + public function getActive(): ?bool + { + return $this->active; + } + + public function setActive(bool $active): self + { + $this->active = $active; + + return $this; + } + public function getAvailableForUsers(): ?bool { return $this->availableForUsers; diff --git a/src/Bundle/ChillMainBundle/Form/LocationFormType.php b/src/Bundle/ChillMainBundle/Form/LocationFormType.php index ba46445f2..5d0c58f38 100644 --- a/src/Bundle/ChillMainBundle/Form/LocationFormType.php +++ b/src/Bundle/ChillMainBundle/Form/LocationFormType.php @@ -51,6 +51,14 @@ final class LocationFormType extends AbstractType 'use_valid_from' => false, 'use_valid_to' => false, 'mapped' => false, + ]) + ->add('active', ChoiceType::class, + [ + 'choices' => [ + 'Yes' => true, + 'No' => false + ], + 'expanded' => true ]); } diff --git a/src/Bundle/ChillMainBundle/Form/LocationTypeType.php b/src/Bundle/ChillMainBundle/Form/LocationTypeType.php index a720c6f8d..dded13327 100644 --- a/src/Bundle/ChillMainBundle/Form/LocationTypeType.php +++ b/src/Bundle/ChillMainBundle/Form/LocationTypeType.php @@ -41,6 +41,14 @@ final class LocationTypeType extends AbstractType 'never' => LocationType::STATUS_NEVER, ], 'expanded' => true + ]) + ->add('active', ChoiceType::class, + [ + 'choices' => [ + 'Yes' => true, + 'No' => false + ], + 'expanded' => true ]); } } diff --git a/src/Bundle/ChillMainBundle/Resources/views/Location/index.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Location/index.html.twig index 37a520338..22ed42f55 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Location/index.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Location/index.html.twig @@ -11,6 +11,7 @@