<?php
namespace App\Entity;
use App\Validator\Constraints as AppAssert;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="App\Repository\SupplierHolidayRepository")
* @ORM\Table(name="malys_supplier_holiday")
* @ORM\HasLifecycleCallbacks()
* @UniqueEntity (fields={"supplier", "code"}, errorPath="code", message="Vous avez déjà ce code date pour ce fournisseur")
*/
class SupplierHoliday
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(name="code", type="string", nullable=false)
* @AppAssert\DateCode()
* @Assert\NotBlank
*/
protected $code;
/**
* @ORM\Column(name="label", type="string", nullable=false)
* @Assert\NotBlank
* @Assert\Length (max=15)
*/
protected $label;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Supplier", inversedBy="holidays", fetch="EAGER")
* @ORM\JoinColumn(name="supplier_id", referencedColumnName="id", nullable=false)
* @Assert\NotBlank
*/
public $supplier;
/**
* @var DateTime
*
* @ORM\Column(name="createdAt", type="datetime", nullable=false)
*/
protected $createdAt;
/**
*
* @var DateTime
*
* @ORM\Column(name="updatedAt", type="datetime", nullable=true)
*/
protected $updatedAt;
/**
* @var boolean
*
* @ORM\Column(name="not_delivering_orders", type="boolean", options={"default" : true})
*/
protected $notDeliveringOrders = true;
/**
* @var boolean
*
* @ORM\Column(name="not_reading_orders", type="boolean", options={"default" : true})
*/
protected $notReadingOrders = true;
public function __toString()
{
return $this->supplier->getCompanyName() . ' - ' . $this->code;
}
/**
* @return int
*/
public function getId(): ?int
{
return $this->id;
}
/**
* @return mixed
*/
public function getCode()
{
return $this->code;
}
/**
* @param mixed $code
*/
public function setCode($code): void
{
$this->code = $code;
}
/**
* @return mixed
*/
public function getLabel()
{
return $this->label;
}
/**
* @param mixed $label
*/
public function setLabel($label): void
{
$this->label = $label;
}
/**
* @return mixed
*/
public function getSupplier()
{
return $this->supplier;
}
/**
* @param mixed $supplier
*/
public function setSupplier($supplier): void
{
$this->supplier = $supplier;
}
/**
* @return DateTime
*/
public function getCreatedAt(): DateTime
{
return $this->createdAt;
}
/**
* Set createdAt
* @ORM\PrePersist
*/
public function setCreatedAt()
{
$this->createdAt = new DateTime();
$this->updatedAt = new DateTime();
return $this;
}
/**
* @return DateTime
*/
public function getUpdatedAt(): DateTime
{
return $this->updatedAt;
}
/**
* Set updatedAt
* @ORM\PreUpdate
*/
public function setUpdatedAt()
{
$this->updatedAt = new DateTime();
return $this;
}
/**
* @return bool
*/
public function isNotDeliveringOrders(): bool
{
return $this->notDeliveringOrders;
}
/**
* @param bool $notDeliveringOrders
*/
public function setNotDeliveringOrders(bool $notDeliveringOrders): void
{
$this->notDeliveringOrders = $notDeliveringOrders;
}
/**
* @return bool
*/
public function isNotReadingOrders(): bool
{
return $this->notReadingOrders;
}
/**
* @param bool $notReadingOrders
*/
public function setNotReadingOrders(bool $notReadingOrders): void
{
$this->notReadingOrders = $notReadingOrders;
}
}