<?php
namespace App\Entity;
use App\Validator\Constraints as AppAssert;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Class DeliveryModel
*
* @ORM\Entity
* @ORM\Table(name="malys_delivery_model")
* @ORM\HasLifecycleCallbacks()
* @package App\Entity
* @ORM\Entity(repositoryClass="App\Repository\DeliveryModelRepository")
* @AppAssert\DeliveryModel(groups={"create"})
*
*/
class DeliveryModel
{
public const DELIVERYTIME_CHOICES = [
'A pour A' => 0,
'A pour B' => 1,
'A pour C' => 2,
'A pour D' => 3,
'A + 7' => 7
];
public const DAYS_CHOICES = [
'Lundi' => 1,
'Mardi' => 2,
'Mercredi' => 3,
'Jeudi' => 4,
'Vendredi' => 5,
'Samedi' => 6,
'Dimanche' => 7
];
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @var string
*
* @ORM\Column(name="label", type="string", length=255, nullable=false)
*/
protected $label;
/**
* @var string
*
* @ORM\Column(name="area", type="string", length=255, nullable=true)
*/
protected $area;
/**
* @var integer
*
* @ORM\Column(name="delivery_time", type="integer", nullable=false)
*/
protected $deliveryTime = 0;
/**
* @var array
*
* @ORM\Column(name="days", type="simple_array")
* @Assert\NotBlank(message="Veuillez indiquer au moins un jour de livraison")
*/
protected $days;
/**
* @var integer
*
* @ORM\Column(name="deadline", type="integer", nullable=false)
*/
protected $deadline;
/**
* @var Supplier
*
* @ORM\ManyToOne(targetEntity="Supplier", inversedBy="deliveriesModel", cascade={"persist"})
* @ORM\JoinColumn(name="supplier_id", referencedColumnName="id", onDelete="CASCADE")
*/
protected $supplier;
/**
* @var boolean
*/
protected $calculated;
/**
* @var boolean
*/
protected $timeIsPass;
/**
* @var string
*/
protected $deliveryDate;
/**
* @var array
*/
protected $daysOfWeekDisabled;
/**
* @var string
*/
protected $deliveryTimeToString;
/**
* @var array
*/
protected $daysToString;
/**
* @var string
*/
protected $deadlineToString;
/**
* @var DateTime
*
* @ORM\Column(name="created_at", type="datetime", nullable=false)
*/
protected $createdAt;
/**
* @var DateTime
*
* @ORM\Column(name="updated_at", type="datetime", nullable=true)
*/
protected $updatedAt;
/**
* @var array
*
* @ORM\Column(name="update_order_days", type="integer", nullable=true)
*/
protected $updateOrderDays = 0;
/**
* @var integer
*
* @ORM\Column(name="update_order_deadline", type="integer", nullable=true)
*/
protected $updateOrderDeadline = 0;
/**
* @ORM\Column(name="monday_minimum_tax_excluded", type="float", nullable=true)
*/
protected $mondayMinimumTaxExcluded;
/**
* @ORM\Column(name="tuesday_minimum_tax_excluded", type="float", nullable=true)
*/
protected $tuesdayMinimumTaxExcluded;
/**
* @ORM\Column(name="wednesday_minimum_tax_excluded", type="float", nullable=true)
*/
protected $wednesdayMinimumTaxExcluded;
/**
* @ORM\Column(name="thursday_minimum_tax_excluded", type="float", nullable=true)
*/
protected $thursdayMinimumTaxExcluded;
/**
* @ORM\Column(name="friday_minimum_tax_excluded", type="float", nullable=true)
*/
protected $fridayMinimumTaxExcluded;
/**
* @ORM\Column(name="saturday_minimum_tax_excluded", type="float", nullable=true)
*/
protected $saturdayMinimumTaxExcluded;
/**
* @ORM\Column(name="sunday_minimum_tax_excluded", type="float", nullable=true)
*/
protected $sundayMinimumTaxExcluded;
/**
* @ORM\Column(name="is_default", type="boolean", nullable=false)
*/
protected $isDefault;
/**
* @ORM\OneToMany(targetEntity="App\Entity\SupplierCustomer", mappedBy="deliveryModel", cascade={"remove", "persist"})
*/
protected $supplierCustomerLinks;
/**
* DeliveryModel constructor.
*/
public function __construct()
{
// todo : vérifier si les valeurs carts et orders ont encore lieu d'exister
$this->carts = new ArrayCollection();
$this->orders = new ArrayCollection();
$this->supplierCustomerLinks = new ArrayCollection();
}
public function __clone()
{
if ($this->id) {
$this->id = null;
}
// there can be only one default DM
$this->isDefault = false;
// start fresh on suppliercustomers relation
$this->supplierCustomerLinks = new ArrayCollection();
$this->label = null;
}
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @param int $id
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return string
*/
public function getLabel()
{
return $this->label;
}
/**
* @param string $label
*/
public function setLabel($label)
{
$this->label = $label;
}
/**
* @return string
*/
public function getArea()
{
return $this->area;
}
/**
* @param string $area
*/
public function setArea($area)
{
$this->area = $area;
}
/**
* @return int
*/
public function getDeliveryTime()
{
return $this->deliveryTime;
}
/**
* @param int $deliveryTime
*/
public function setDeliveryTime($deliveryTime)
{
$this->deliveryTime = $deliveryTime;
}
/**
* @return array
*/
public function getDays()
{
return $this->days;
}
/**
* @param array $days
*/
public function setDays(?array $days)
{
$this->days = $days;
}
/**
* @return integer
*/
public function getDeadline()
{
return $this->deadline;
}
/**
* @param integer $deadline
*/
public function setDeadline($deadline)
{
$this->deadline = $deadline;
}
/**
* @return Supplier
*/
public function getSupplier()
{
return $this->supplier;
}
/**
* @param Supplier $supplier
*/
public function setSupplier($supplier)
{
$this->supplier = $supplier;
$supplier->addDeliveryModel($this);
}
/**
* @return bool
*/
public function isCalculated()
{
return $this->calculated;
}
/**
* @param bool $calculated
*/
public function setCalculated($calculated)
{
$this->calculated = $calculated;
}
/**
* @return bool
*/
public function isTimeIsPass()
{
return $this->timeIsPass;
}
/**
* @param bool $timeIsPass
*/
public function setTimeIsPass($timeIsPass)
{
$this->timeIsPass = $timeIsPass;
}
/**
* @return string
*/
public function getDeliveryDate()
{
return $this->deliveryDate;
}
/**
* @param string $deliveryDate
*/
public function setDeliveryDate($deliveryDate)
{
$this->deliveryDate = $deliveryDate;
}
/**
* @return array
*/
public function getDaysOfWeekDisabled()
{
return $this->daysOfWeekDisabled;
}
/**
* @param array $daysOfWeekDisabled
*/
public function setDaysOfWeekDisabled($daysOfWeekDisabled)
{
$this->daysOfWeekDisabled = $daysOfWeekDisabled;
}
/**
* @return string
* @deprecated See model DeliveryModel : getDeliveryTimeLabel (attention, ne retourne pas exactement la même chose ! )
* @todo à retirer
*/
public function getDeliveryTimeToString()
{
return $this->deliveryTimeToString;
}
/**
* @param string $deliveryTimeToString
*/
public function setDeliveryTimeToString($deliveryTimeToString)
{
$this->deliveryTimeToString = $deliveryTimeToString;
}
/**
* @return array
*/
public function getDaysToString()
{
return $this->daysToString;
}
/**
* @param array $daysToString
*/
public function setDaysToString($daysToString)
{
$this->daysToString = $daysToString;
}
/**
* @return string
*/
public function getDeadlineToString()
{
return $this->deadlineToString;
}
/**
* @param string $deadlineToString
*/
public function setDeadlineToString($deadlineToString)
{
$this->deadlineToString = $deadlineToString;
}
/**
* @return DateTime
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
*
* @ORM\PrePersist
*/
public function prePersist()
{
$this->createdAt = new DateTime();
$this->updatedAt = new DateTime();
return $this;
}
public function setCreatedAt(DateTime $dt)
{
$this->createdAt = $dt;
}
/**
* @return DateTime
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
/**
* Set updatedAt
*
* @ORM\PreUpdate
*/
public function setUpdatedAt()
{
$this->updatedAt = new DateTime();
}
/**
* @return array
*/
public function getUpdateOrderDays()
{
return $this->updateOrderDays;
}
/**
* @param array $updateOrderDays
*/
public function setUpdateOrderDays($updateOrderDays)
{
$this->updateOrderDays = $updateOrderDays;
}
/**
* @return int
*/
public function getUpdateOrderDeadline()
{
return $this->updateOrderDeadline;
}
/**
* @param int $updateOrderDeadline
*/
public function setUpdateOrderDeadline($updateOrderDeadline)
{
$this->updateOrderDeadline = $updateOrderDeadline;
}
/**
* @return mixed
*/
public function getMondayMinimumTaxExcluded()
{
return $this->mondayMinimumTaxExcluded;
}
/**
* @param mixed $mondayMinimumTaxExcluded
*/
public function setMondayMinimumTaxExcluded($mondayMinimumTaxExcluded)
{
$this->mondayMinimumTaxExcluded = $mondayMinimumTaxExcluded;
}
/**
* @return mixed
*/
public function getTuesdayMinimumTaxExcluded()
{
return $this->tuesdayMinimumTaxExcluded;
}
/**
* @param mixed $tuesdayMinimumTaxExcluded
*/
public function setTuesdayMinimumTaxExcluded($tuesdayMinimumTaxExcluded)
{
$this->tuesdayMinimumTaxExcluded = $tuesdayMinimumTaxExcluded;
}
/**
* @return mixed
*/
public function getWednesdayMinimumTaxExcluded()
{
return $this->wednesdayMinimumTaxExcluded;
}
/**
* @param mixed $wednesdayMinimumTaxExcluded
*/
public function setWednesdayMinimumTaxExcluded($wednesdayMinimumTaxExcluded)
{
$this->wednesdayMinimumTaxExcluded = $wednesdayMinimumTaxExcluded;
}
/**
* @return mixed
*/
public function getThursdayMinimumTaxExcluded()
{
return $this->thursdayMinimumTaxExcluded;
}
/**
* @param mixed $thursdayMinimumTaxExcluded
*/
public function setThursdayMinimumTaxExcluded($thursdayMinimumTaxExcluded)
{
$this->thursdayMinimumTaxExcluded = $thursdayMinimumTaxExcluded;
}
/**
* @return mixed
*/
public function getFridayMinimumTaxExcluded()
{
return $this->fridayMinimumTaxExcluded;
}
/**
* @param mixed $fridayMinimumTaxExcluded
*/
public function setFridayMinimumTaxExcluded($fridayMinimumTaxExcluded)
{
$this->fridayMinimumTaxExcluded = $fridayMinimumTaxExcluded;
}
/**
* @return mixed
*/
public function getSaturdayMinimumTaxExcluded()
{
return $this->saturdayMinimumTaxExcluded;
}
/**
* @param mixed $saturdayMinimumTaxExcluded
*/
public function setSaturdayMinimumTaxExcluded($saturdayMinimumTaxExcluded)
{
$this->saturdayMinimumTaxExcluded = $saturdayMinimumTaxExcluded;
}
/**
* @return mixed
*/
public function getSundayMinimumTaxExcluded()
{
return $this->sundayMinimumTaxExcluded;
}
/**
* @param mixed $sundayMinimumTaxExcluded
*/
public function setSundayMinimumTaxExcluded($sundayMinimumTaxExcluded)
{
$this->sundayMinimumTaxExcluded = $sundayMinimumTaxExcluded;
}
/**
* @param mixed $isDefault
*/
public function setIsDefault($isDefault)
{
$this->isDefault = $isDefault;
}
/**
* @return mixed
*/
public function getIsDefault()
{
return $this->isDefault;
}
/**
* @return mixed
*/
public function getSupplierCustomerLinks()
{
return $this->supplierCustomerLinks;
}
/**
* @param mixed $supplierCustomerLinks
*/
public function setSupplierCustomerLinks($supplierCustomerLinks): void
{
$this->supplierCustomerLinks = $supplierCustomerLinks;
}
public function addSupplierCustomerLink(SupplierCustomer $link)
{
if (! $this->supplierCustomerLinks->contains($link)) {
$this->supplierCustomerLinks->add($link);
$link->setDeliveryModel($this);
}
}
}