<?php

namespace App\Entity;

use App\Enum\PartnerType;
use App\Repository\PartnerRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity(repositoryClass: PartnerRepository::class)]
class Partner
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    private ?int $id = null;

    #[ORM\Column(type: "integer", unique: true, nullable: true, options: ["unsigned" => true])]
    protected ?int $navisionId = null;

    #[ORM\Column(length: 255)]
    private string $name;

    #[ORM\Column(type: 'string', enumType: PartnerType::class)]
    private PartnerType $type;

    #[ORM\Column(type: Types::TEXT, nullable: true)]
    private ?string $description = null;

    #[ORM\Column(length: 255, nullable: true)]
    private ?string $street = null;

    #[ORM\Column(length: 255, nullable: true)]
    private ?string $streetNo = null;

    #[ORM\Column(length: 255, nullable: true)]
    private ?string $zip = null;

    #[ORM\Column(length: 255, nullable: true)]
    private ?string $city = null;

    #[ORM\Column(length: 255, nullable: true)]
    private ?string $country = null;

    #[ORM\Column(length: 255, nullable: true)]
    private ?string $website = null;

    #[ORM\ManyToOne]
    #[ORM\JoinColumn(nullable: true, onDelete: "SET NULL")]
    private ?MediaObject $logo = null;

    #[ORM\Column(length: 255, nullable: true)]
    private ?string $nameAddition = null;

    #[ORM\Column(length: 255, nullable: true)]
    private ?string $addressAddition = null;

    #[ORM\Column(length: 255, nullable: true)]
    private ?string $phone = null;

    #[ORM\Column(length: 255, nullable: true)]
    private ?string $language = null;

    #[ORM\Column(length: 255, nullable: true)]
    private ?string $currency = null;

    #[ORM\Column(length: 255, nullable: true)]
    private ?string $paymentCondition = null;

    #[ORM\Column(length: 255, nullable: true)]
    private ?string $deliveryCondition = null;

    #[ORM\Column(length: 255, nullable: true)]
    private ?string $businessGroup = null;

    #[ORM\Column(length: 255, nullable: true)]
    private ?string $vatBusinessGroup = null;

    #[ORM\Column(nullable: true)]
    private ?int $creditLimit = null;

    #[ORM\Column(length: 255, nullable: true)]
    private ?string $routePoint = null;

    #[ORM\OneToMany(mappedBy: 'partner', targetEntity: Contact::class)]
    private Collection $contacts;

    #[ORM\OneToMany(mappedBy: 'partner', targetEntity: Posting::class)]
    private Collection $postings;

    #[ORM\OneToMany(mappedBy: 'partner', targetEntity: Sale::class)]
    private Collection $sales;

    #[ORM\OneToMany(mappedBy: 'partner', targetEntity: Document::class)]
    private Collection $documentObjects;

    #[ORM\OneToMany(mappedBy: 'partner', targetEntity: PartnerFollow::class)]
    private Collection $partnerFollows;

    #[ORM\OneToMany(mappedBy: 'partner', targetEntity: PartnerProduct::class)]
    private Collection $partnerProducts;

    #[ORM\ManyToOne]
    #[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
    private ?User $createdBy = null;

    #[ORM\Column]
    private ?\DateTimeImmutable $createdAt = null;

    public function __construct(User $createdBy)
    {
        $this->createdBy = $createdBy;
        $this->createdAt = new \DateTimeImmutable();
        $this->contacts = new ArrayCollection();
        $this->postings = new ArrayCollection();
        $this->sales = new ArrayCollection();
        $this->documentObjects = new ArrayCollection();
        $this->partnerFollows = new ArrayCollection();
        $this->partnerProducts = new ArrayCollection();
    }

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

    public function getNavisionId(): ?int
    {
        return $this->navisionId;
    }

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

    public function getName(): string
    {
        return $this->name;
    }

    public function setName(string $name): void
    {
        $this->name = $name;
    }

    public function getType(): PartnerType
    {
        return $this->type;
    }

    public function setType(PartnerType $type): void
    {
        $this->type = $type;
    }

    public function getDescription(): ?string
    {
        return $this->description;
    }

    public function setDescription(?string $description): void
    {
        $this->description = $description;
    }

    public function getStreet(): ?string
    {
        return $this->street;
    }

    public function setStreet(?string $street): void
    {
        $this->street = $street;
    }

    public function getStreetNo(): ?string
    {
        return $this->streetNo;
    }

    public function setStreetNo(?string $streetNo): void
    {
        $this->streetNo = $streetNo;
    }

    public function getZip(): ?string
    {
        return $this->zip;
    }

    public function setZip(?string $zip): void
    {
        $this->zip = $zip;
    }

    public function getCity(): ?string
    {
        return $this->city;
    }

    public function setCity(?string $city): void
    {
        $this->city = $city;
    }

    public function getCountry(): ?string
    {
        return $this->country;
    }

    public function setCountry(?string $country): void
    {
        $this->country = $country;
    }

    public function getWebsite(): ?string
    {
        return $this->website;
    }

    public function setWebsite(?string $website): void
    {
        $this->website = $website;
    }

    public function getCreatedAt(): ?\DateTimeImmutable
    {
        return $this->createdAt;
    }

    public function getCreatedBy(): ?User
    {
        return $this->createdBy;
    }

    public function setCreatedAt(?\DateTimeImmutable $createdAt): void
    {
        $this->createdAt = $createdAt;
    }

    public function getContacts(): Collection
    {
        return $this->contacts;
    }

    public function setContacts(Collection $contacts): void
    {
        $this->contacts = $contacts;
    }

    public function getLogo(): ?MediaObject
    {
        return $this->logo;
    }

    public function setLogo(?MediaObject $logo): void
    {
        $this->logo = $logo;
    }

    /**
     * @return Collection<int, Posting>
     */
    public function getPostings(): Collection
    {
        return $this->postings;
    }

    public function addPosting(Posting $posting): static
    {
        if (!$this->postings->contains($posting)) {
            $this->postings->add($posting);
            $posting->setPartner($this);
        }

        return $this;
    }

    public function removePosting(Posting $posting): static
    {
        if ($this->postings->removeElement($posting)) {
            // set the owning side to null (unless already changed)
            if ($posting->getPartner() === $this) {
                $posting->setPartner(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection<int, Sale>
     */
    public function getSales(): Collection
    {
        return $this->sales;
    }

    public function addSale(Sale $sale): static
    {
        if (!$this->sales->contains($sale)) {
            $this->sales->add($sale);
            $sale->setPartner($this);
        }

        return $this;
    }

    public function removeSale(Sale $sale): static
    {
        if ($this->sales->removeElement($sale)) {
            // set the owning side to null (unless already changed)
            if ($sale->getPartner() === $this) {
                $sale->setPartner(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection<int, Document>
     */
    public function getDocumentObjects(): Collection
    {
        return $this->documentObjects;
    }

    public function addDocumentObject(Document $documentObject): static
    {
        if (!$this->documentObjects->contains($documentObject)) {
            $this->documentObjects->add($documentObject);
            $documentObject->setPartner($this);
        }

        return $this;
    }

    public function removeDocumentObject(Document $documentObject): static
    {
        if ($this->documentObjects->removeElement($documentObject)) {
            // set the owning side to null (unless already changed)
            if ($documentObject->getPartner() === $this) {
                $documentObject->setPartner(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection<int, PartnerFollow>
     */
    public function getPartnerFollows(): Collection
    {
        return $this->partnerFollows;
    }

    public function addPartnerFollow(PartnerFollow $partnerFollow): static
    {
        if (!$this->partnerFollows->contains($partnerFollow)) {
            $this->partnerFollows->add($partnerFollow);
            $partnerFollow->setPartner($this);
        }

        return $this;
    }

    public function removePartnerFollow(PartnerFollow $partnerFollow): static
    {
        if ($this->partnerFollows->removeElement($partnerFollow)) {
            // set the owning side to null (unless already changed)
            if ($partnerFollow->getPartner() === $this) {
                $partnerFollow->setPartner(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection<int, PartnerProduct>
     */
    public function getPartnerProducts(): Collection
    {
        return $this->partnerProducts;
    }

    public function addPartnerProduct(PartnerProduct $partnerProduct): static
    {
        if (!$this->partnerProducts->contains($partnerProduct)) {
            $this->partnerProducts->add($partnerProduct);
            $partnerProduct->setPartner($this);
        }

        return $this;
    }

    public function removePartnerProduct(PartnerProduct $partnerProduct): static
    {
        if ($this->partnerProducts->removeElement($partnerProduct)) {
            // set the owning side to null (unless already changed)
            if ($partnerProduct->getPartner() === $this) {
                $partnerProduct->setPartner(null);
            }
        }

        return $this;
    }

    public function getNameAddition(): ?string
    {
        return $this->nameAddition;
    }

    public function setNameAddition(?string $nameAddition): static
    {
        $this->nameAddition = $nameAddition;

        return $this;
    }

    public function getAddressAddition(): ?string
    {
        return $this->addressAddition;
    }

    public function setAddressAddition(?string $addressAddition): static
    {
        $this->addressAddition = $addressAddition;

        return $this;
    }

    public function getLanguage(): ?string
    {
        return $this->language;
    }

    public function setLanguage(?string $language): static
    {
        $this->language = $language;

        return $this;
    }

    public function getCurrency(): ?string
    {
        return $this->currency;
    }

    public function setCurrency(?string $currency): static
    {
        $this->currency = $currency;

        return $this;
    }

    public function getPaymentCondition(): ?string
    {
        return $this->paymentCondition;
    }

    public function setPaymentCondition(?string $paymentCondition): static
    {
        $this->paymentCondition = $paymentCondition;

        return $this;
    }

    public function getDeliveryCondition(): ?string
    {
        return $this->deliveryCondition;
    }

    public function setDeliveryCondition(?string $deliveryCondition): static
    {
        $this->deliveryCondition = $deliveryCondition;

        return $this;
    }

    public function getBusinessGroup(): ?string
    {
        return $this->businessGroup;
    }

    public function setBusinessGroup(?string $businessGroup): static
    {
        $this->businessGroup = $businessGroup;

        return $this;
    }

    public function getVatBusinessGroup(): ?string
    {
        return $this->vatBusinessGroup;
    }

    public function setVatBusinessGroup(?string $vatBusinessGroup): static
    {
        $this->vatBusinessGroup = $vatBusinessGroup;

        return $this;
    }

    public function getCreditLimit(): ?int
    {
        return $this->creditLimit;
    }

    public function setCreditLimit(?int $creditLimit): static
    {
        $this->creditLimit = $creditLimit;

        return $this;
    }

    public function getRoutePoint(): ?string
    {
        return $this->routePoint;
    }

    public function setRoutePoint(?string $routePoint): static
    {
        $this->routePoint = $routePoint;

        return $this;
    }

    public function getPhone(): ?string
    {
        return $this->phone;
    }

    public function setPhone(?string $phone): static
    {
        $this->phone = $phone;

        return $this;
    }

}
