<?php
/**
 * @author Colinet Julien
 */

namespace CpCreation\VitiCore\Shop\Model;

use CpCreation\VitiCore\Behavior\HasTimestamp;
use CpCreation\VitiCore\Behavior\Impl\Timestamp;
use CpCreation\VitiCore\Product\Model\ProductPriceGroup;
use CpCreation\VitiCore\Product\Model\ProductType;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;
use Symfony\Component\Validator\Constraints as Assert;

#[ORM\Entity(repositoryClass: 'CpCreation\VitiCore\Shop\Repository\ShippingAdditionalManualRepository')]
#[ORM\Table(name: 'shop_shipping_additional_manual')]
#[ORM\HasLifecycleCallbacks]
class ShippingAdditionalManual implements HasTimestamp
{
    use Timestamp;

    #[ORM\Id]
    #[ORM\Column(type: 'uuid')]
    #[ORM\GeneratedValue(strategy: 'NONE')]
    private UuidInterface $id;

    #[ORM\Column(type: 'integer')]
    #[Assert\NotBlank]
    private ?int $qtyOf = null;

    #[ORM\Column(type: 'integer')]
    #[Assert\NotBlank]
    private ?int $qtyAt = null;

    #[ORM\Column(type: 'integer')]
    private ?int $dateOf = null;

    #[ORM\Column(type: 'integer')]
    private ?int $dateAt = null;

    #[ORM\Column(type: 'integer', nullable: true)]
    private ?int $packagePrice = null;

    #[ORM\Column(type: 'integer', nullable: true)]
    private ?int $bottlePrice = null;

    #[ORM\ManyToMany(targetEntity: ShippingZone::class)]
    #[Assert\Count(min: 1, minMessage: 'Vous devez ajouter au moins une zone')]
    private Collection $zones;

    #[ORM\ManyToMany(targetEntity: ProductType::class)]
    #[Assert\Count(min: 1, minMessage: 'Vous devez ajouter au moins un type')]
    private Collection $types;

    #[ORM\ManyToMany(targetEntity: ProductPriceGroup::class)]
    #[Assert\Count(min: 1, minMessage: 'Vous devez ajouter au moins un groupe')]
    private Collection $groups;

    #[ORM\Column(type: 'boolean')]
    private bool $ht = false;

    public function __construct()
    {
        $this->id = Uuid::uuid4();
        $this->zones = new ArrayCollection();
        $this->types = new ArrayCollection();
        $this->groups = new ArrayCollection();
    }

    public function getId(): UuidInterface
    {
        return $this->id;
    }

    public function getQtyOf(): ?int
    {
        return $this->qtyOf;
    }

    public function setQtyOf(?int $qtyOf = null): void
    {
        $this->qtyOf = $qtyOf;
    }

    public function getQtyAt(): ?int
    {
        return $this->qtyAt;
    }

    public function setQtyAt(?int $qtyAt = null): void
    {
        $this->qtyAt = $qtyAt;
    }

    public function getDateOf(): ?int
    {
        return $this->dateOf;
    }

    public function setDateOf(?int $dateOf = null): void
    {
        $this->dateOf = $dateOf;

        // Correspond au 31 décembre
        if (!$dateOf) {
            $this->dateOf = 1231;
        }
    }

    public function getDateAt(): ?int
    {
        return $this->dateAt;
    }

    public function setDateAt(?int $dateAt = null): void
    {
        $this->dateAt = $dateAt;

        if (!$dateAt) {
            $this->dateAt = 1231;
        }
    }

    public function getPackagePrice(): ?int
    {
        return $this->packagePrice;
    }

    public function setPackagePrice(?int $packagePrice): void
    {
        $this->packagePrice = $packagePrice;
    }

    public function getBottlePrice(): ?int
    {
        return $this->bottlePrice;
    }

    public function setBottlePrice(?int $bottlePrice): void
    {
        $this->bottlePrice = $bottlePrice;
    }

    public function getZones(): Collection
    {
        return $this->zones;
    }

    public function setZones(Collection $zones): void
    {
        $this->zones = $zones;
    }

    public function getTypes(): Collection
    {
        return $this->types;
    }

    public function setTypes(Collection $types): void
    {
        $this->types = $types;
    }

    public function getGroups(): Collection
    {
        return $this->groups;
    }

    public function setGroups(Collection $groups): void
    {
        $this->groups = $groups;
    }

    public function isHt(): bool
    {
        return $this->ht;
    }

    public function setHt(bool $ht): void
    {
        $this->ht = $ht;
    }
}
