src/Entity/DeliveryModel.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Validator\Constraints as AppAssert;
  4. use DateTime;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. /**
  9.  * Class DeliveryModel
  10.  *
  11.  * @ORM\Entity
  12.  * @ORM\Table(name="malys_delivery_model")
  13.  * @ORM\HasLifecycleCallbacks()
  14.  * @package App\Entity
  15.  * @ORM\Entity(repositoryClass="App\Repository\DeliveryModelRepository")
  16.  * @AppAssert\DeliveryModel(groups={"create"})
  17.  *
  18.  */
  19. class DeliveryModel
  20. {
  21.     public const DELIVERYTIME_CHOICES = [
  22.         'A pour A' => 0,
  23.         'A pour B' => 1,
  24.         'A pour C' => 2,
  25.         'A pour D' => 3,
  26.         'A + 7'    => 7
  27.     ];
  28.     public const DAYS_CHOICES = [
  29.         'Lundi'    => 1,
  30.         'Mardi'    => 2,
  31.         'Mercredi' => 3,
  32.         'Jeudi'    => 4,
  33.         'Vendredi' => 5,
  34.         'Samedi'   => 6,
  35.         'Dimanche' => 7
  36.     ];
  37.     /**
  38.      * @var integer
  39.      *
  40.      * @ORM\Column(name="id", type="integer")
  41.      * @ORM\Id
  42.      * @ORM\GeneratedValue(strategy="AUTO")
  43.      */
  44.     protected $id;
  45.     /**
  46.      * @var string
  47.      *
  48.      * @ORM\Column(name="label", type="string", length=255, nullable=false)
  49.      */
  50.     protected $label;
  51.     /**
  52.      * @var string
  53.      *
  54.      * @ORM\Column(name="area", type="string", length=255, nullable=true)
  55.      */
  56.     protected $area;
  57.     /**
  58.      * @var integer
  59.      *
  60.      * @ORM\Column(name="delivery_time", type="integer", nullable=false)
  61.      */
  62.     protected $deliveryTime 0;
  63.     /**
  64.      * @var array
  65.      *
  66.      * @ORM\Column(name="days", type="simple_array")
  67.      * @Assert\NotBlank(message="Veuillez indiquer au moins un jour de livraison")
  68.      */
  69.     protected $days;
  70.     /**
  71.      * @var integer
  72.      *
  73.      * @ORM\Column(name="deadline", type="integer", nullable=false)
  74.      */
  75.     protected $deadline;
  76.     /**
  77.      * @var Supplier
  78.      *
  79.      * @ORM\ManyToOne(targetEntity="Supplier", inversedBy="deliveriesModel", cascade={"persist"})
  80.      * @ORM\JoinColumn(name="supplier_id", referencedColumnName="id", onDelete="CASCADE")
  81.      */
  82.     protected $supplier;
  83.     /**
  84.      * @var boolean
  85.      */
  86.     protected $calculated;
  87.     /**
  88.      * @var boolean
  89.      */
  90.     protected $timeIsPass;
  91.     /**
  92.      * @var string
  93.      */
  94.     protected $deliveryDate;
  95.     /**
  96.      * @var array
  97.      */
  98.     protected $daysOfWeekDisabled;
  99.     /**
  100.      * @var string
  101.      */
  102.     protected $deliveryTimeToString;
  103.     /**
  104.      * @var array
  105.      */
  106.     protected $daysToString;
  107.     /**
  108.      * @var string
  109.      */
  110.     protected $deadlineToString;
  111.     /**
  112.      * @var DateTime
  113.      *
  114.      * @ORM\Column(name="created_at", type="datetime", nullable=false)
  115.      */
  116.     protected $createdAt;
  117.     /**
  118.      * @var DateTime
  119.      *
  120.      * @ORM\Column(name="updated_at", type="datetime", nullable=true)
  121.      */
  122.     protected $updatedAt;
  123.     /**
  124.      * @var array
  125.      *
  126.      * @ORM\Column(name="update_order_days", type="integer", nullable=true)
  127.      */
  128.     protected $updateOrderDays 0;
  129.     /**
  130.      * @var integer
  131.      *
  132.      * @ORM\Column(name="update_order_deadline", type="integer", nullable=true)
  133.      */
  134.     protected $updateOrderDeadline 0;
  135.     /**
  136.      * @ORM\Column(name="monday_minimum_tax_excluded", type="float", nullable=true)
  137.      */
  138.     protected $mondayMinimumTaxExcluded;
  139.     /**
  140.      * @ORM\Column(name="tuesday_minimum_tax_excluded", type="float", nullable=true)
  141.      */
  142.     protected $tuesdayMinimumTaxExcluded;
  143.     /**
  144.      * @ORM\Column(name="wednesday_minimum_tax_excluded", type="float", nullable=true)
  145.      */
  146.     protected $wednesdayMinimumTaxExcluded;
  147.     /**
  148.      * @ORM\Column(name="thursday_minimum_tax_excluded", type="float", nullable=true)
  149.      */
  150.     protected $thursdayMinimumTaxExcluded;
  151.     /**
  152.      * @ORM\Column(name="friday_minimum_tax_excluded", type="float", nullable=true)
  153.      */
  154.     protected $fridayMinimumTaxExcluded;
  155.     /**
  156.      * @ORM\Column(name="saturday_minimum_tax_excluded", type="float", nullable=true)
  157.      */
  158.     protected $saturdayMinimumTaxExcluded;
  159.     /**
  160.      * @ORM\Column(name="sunday_minimum_tax_excluded", type="float", nullable=true)
  161.      */
  162.     protected $sundayMinimumTaxExcluded;
  163.     /**
  164.      * @ORM\Column(name="is_default", type="boolean", nullable=false)
  165.      */
  166.     protected $isDefault;
  167.     /**
  168.      * @ORM\OneToMany(targetEntity="App\Entity\SupplierCustomer", mappedBy="deliveryModel", cascade={"remove", "persist"})
  169.      */
  170.     protected $supplierCustomerLinks;
  171.     /**
  172.      * DeliveryModel constructor.
  173.      */
  174.     public function __construct()
  175.     {
  176.         // todo : vérifier si les valeurs carts et orders ont encore lieu d'exister
  177.         $this->carts                 = new ArrayCollection();
  178.         $this->orders                = new ArrayCollection();
  179.         $this->supplierCustomerLinks = new ArrayCollection();
  180.     }
  181.     public function __clone()
  182.     {
  183.         if ($this->id) {
  184.             $this->id null;
  185.         }
  186.         // there can be only one default DM
  187.         $this->isDefault false;
  188.         // start fresh on suppliercustomers relation
  189.         $this->supplierCustomerLinks = new ArrayCollection();
  190.         $this->label null;
  191.     }
  192.     /**
  193.      * @return int
  194.      */
  195.     public function getId()
  196.     {
  197.         return $this->id;
  198.     }
  199.     /**
  200.      * @param int $id
  201.      */
  202.     public function setId($id)
  203.     {
  204.         $this->id $id;
  205.     }
  206.     /**
  207.      * @return string
  208.      */
  209.     public function getLabel()
  210.     {
  211.         return $this->label;
  212.     }
  213.     /**
  214.      * @param string $label
  215.      */
  216.     public function setLabel($label)
  217.     {
  218.         $this->label $label;
  219.     }
  220.     /**
  221.      * @return string
  222.      */
  223.     public function getArea()
  224.     {
  225.         return $this->area;
  226.     }
  227.     /**
  228.      * @param string $area
  229.      */
  230.     public function setArea($area)
  231.     {
  232.         $this->area $area;
  233.     }
  234.     /**
  235.      * @return int
  236.      */
  237.     public function getDeliveryTime()
  238.     {
  239.         return $this->deliveryTime;
  240.     }
  241.     /**
  242.      * @param int $deliveryTime
  243.      */
  244.     public function setDeliveryTime($deliveryTime)
  245.     {
  246.         $this->deliveryTime $deliveryTime;
  247.     }
  248.     /**
  249.      * @return array
  250.      */
  251.     public function getDays()
  252.     {
  253.         return $this->days;
  254.     }
  255.     /**
  256.      * @param array $days
  257.      */
  258.     public function setDays(?array $days)
  259.     {
  260.         $this->days $days;
  261.     }
  262.     /**
  263.      * @return integer
  264.      */
  265.     public function getDeadline()
  266.     {
  267.         return $this->deadline;
  268.     }
  269.     /**
  270.      * @param integer $deadline
  271.      */
  272.     public function setDeadline($deadline)
  273.     {
  274.         $this->deadline $deadline;
  275.     }
  276.     /**
  277.      * @return Supplier
  278.      */
  279.     public function getSupplier()
  280.     {
  281.         return $this->supplier;
  282.     }
  283.     /**
  284.      * @param Supplier $supplier
  285.      */
  286.     public function setSupplier($supplier)
  287.     {
  288.         $this->supplier $supplier;
  289.         $supplier->addDeliveryModel($this);
  290.     }
  291.     /**
  292.      * @return bool
  293.      */
  294.     public function isCalculated()
  295.     {
  296.         return $this->calculated;
  297.     }
  298.     /**
  299.      * @param bool $calculated
  300.      */
  301.     public function setCalculated($calculated)
  302.     {
  303.         $this->calculated $calculated;
  304.     }
  305.     /**
  306.      * @return bool
  307.      */
  308.     public function isTimeIsPass()
  309.     {
  310.         return $this->timeIsPass;
  311.     }
  312.     /**
  313.      * @param bool $timeIsPass
  314.      */
  315.     public function setTimeIsPass($timeIsPass)
  316.     {
  317.         $this->timeIsPass $timeIsPass;
  318.     }
  319.     /**
  320.      * @return string
  321.      */
  322.     public function getDeliveryDate()
  323.     {
  324.         return $this->deliveryDate;
  325.     }
  326.     /**
  327.      * @param string $deliveryDate
  328.      */
  329.     public function setDeliveryDate($deliveryDate)
  330.     {
  331.         $this->deliveryDate $deliveryDate;
  332.     }
  333.     /**
  334.      * @return array
  335.      */
  336.     public function getDaysOfWeekDisabled()
  337.     {
  338.         return $this->daysOfWeekDisabled;
  339.     }
  340.     /**
  341.      * @param array $daysOfWeekDisabled
  342.      */
  343.     public function setDaysOfWeekDisabled($daysOfWeekDisabled)
  344.     {
  345.         $this->daysOfWeekDisabled $daysOfWeekDisabled;
  346.     }
  347.     /**
  348.      * @return string
  349.      * @deprecated See model DeliveryModel : getDeliveryTimeLabel (attention, ne retourne pas exactement la même chose ! )
  350.      * @todo à retirer
  351.      */
  352.     public function getDeliveryTimeToString()
  353.     {
  354.         return $this->deliveryTimeToString;
  355.     }
  356.     /**
  357.      * @param string $deliveryTimeToString
  358.      */
  359.     public function setDeliveryTimeToString($deliveryTimeToString)
  360.     {
  361.         $this->deliveryTimeToString $deliveryTimeToString;
  362.     }
  363.     /**
  364.      * @return array
  365.      */
  366.     public function getDaysToString()
  367.     {
  368.         return $this->daysToString;
  369.     }
  370.     /**
  371.      * @param array $daysToString
  372.      */
  373.     public function setDaysToString($daysToString)
  374.     {
  375.         $this->daysToString $daysToString;
  376.     }
  377.     /**
  378.      * @return string
  379.      */
  380.     public function getDeadlineToString()
  381.     {
  382.         return $this->deadlineToString;
  383.     }
  384.     /**
  385.      * @param string $deadlineToString
  386.      */
  387.     public function setDeadlineToString($deadlineToString)
  388.     {
  389.         $this->deadlineToString $deadlineToString;
  390.     }
  391.     /**
  392.      * @return DateTime
  393.      */
  394.     public function getCreatedAt()
  395.     {
  396.         return $this->createdAt;
  397.     }
  398.     /**
  399.      *
  400.      * @ORM\PrePersist
  401.      */
  402.     public function prePersist()
  403.     {
  404.         $this->createdAt = new DateTime();
  405.         $this->updatedAt = new DateTime();
  406.         return $this;
  407.     }
  408.     public function setCreatedAt(DateTime $dt)
  409.     {
  410.         $this->createdAt $dt;
  411.     }
  412.     /**
  413.      * @return DateTime
  414.      */
  415.     public function getUpdatedAt()
  416.     {
  417.         return $this->updatedAt;
  418.     }
  419.     /**
  420.      * Set updatedAt
  421.      *
  422.      * @ORM\PreUpdate
  423.      */
  424.     public function setUpdatedAt()
  425.     {
  426.         $this->updatedAt = new DateTime();
  427.     }
  428.     /**
  429.      * @return array
  430.      */
  431.     public function getUpdateOrderDays()
  432.     {
  433.         return $this->updateOrderDays;
  434.     }
  435.     /**
  436.      * @param array $updateOrderDays
  437.      */
  438.     public function setUpdateOrderDays($updateOrderDays)
  439.     {
  440.         $this->updateOrderDays $updateOrderDays;
  441.     }
  442.     /**
  443.      * @return int
  444.      */
  445.     public function getUpdateOrderDeadline()
  446.     {
  447.         return $this->updateOrderDeadline;
  448.     }
  449.     /**
  450.      * @param int $updateOrderDeadline
  451.      */
  452.     public function setUpdateOrderDeadline($updateOrderDeadline)
  453.     {
  454.         $this->updateOrderDeadline $updateOrderDeadline;
  455.     }
  456.     /**
  457.      * @return mixed
  458.      */
  459.     public function getMondayMinimumTaxExcluded()
  460.     {
  461.         return $this->mondayMinimumTaxExcluded;
  462.     }
  463.     /**
  464.      * @param mixed $mondayMinimumTaxExcluded
  465.      */
  466.     public function setMondayMinimumTaxExcluded($mondayMinimumTaxExcluded)
  467.     {
  468.         $this->mondayMinimumTaxExcluded $mondayMinimumTaxExcluded;
  469.     }
  470.     /**
  471.      * @return mixed
  472.      */
  473.     public function getTuesdayMinimumTaxExcluded()
  474.     {
  475.         return $this->tuesdayMinimumTaxExcluded;
  476.     }
  477.     /**
  478.      * @param mixed $tuesdayMinimumTaxExcluded
  479.      */
  480.     public function setTuesdayMinimumTaxExcluded($tuesdayMinimumTaxExcluded)
  481.     {
  482.         $this->tuesdayMinimumTaxExcluded $tuesdayMinimumTaxExcluded;
  483.     }
  484.     /**
  485.      * @return mixed
  486.      */
  487.     public function getWednesdayMinimumTaxExcluded()
  488.     {
  489.         return $this->wednesdayMinimumTaxExcluded;
  490.     }
  491.     /**
  492.      * @param mixed $wednesdayMinimumTaxExcluded
  493.      */
  494.     public function setWednesdayMinimumTaxExcluded($wednesdayMinimumTaxExcluded)
  495.     {
  496.         $this->wednesdayMinimumTaxExcluded $wednesdayMinimumTaxExcluded;
  497.     }
  498.     /**
  499.      * @return mixed
  500.      */
  501.     public function getThursdayMinimumTaxExcluded()
  502.     {
  503.         return $this->thursdayMinimumTaxExcluded;
  504.     }
  505.     /**
  506.      * @param mixed $thursdayMinimumTaxExcluded
  507.      */
  508.     public function setThursdayMinimumTaxExcluded($thursdayMinimumTaxExcluded)
  509.     {
  510.         $this->thursdayMinimumTaxExcluded $thursdayMinimumTaxExcluded;
  511.     }
  512.     /**
  513.      * @return mixed
  514.      */
  515.     public function getFridayMinimumTaxExcluded()
  516.     {
  517.         return $this->fridayMinimumTaxExcluded;
  518.     }
  519.     /**
  520.      * @param mixed $fridayMinimumTaxExcluded
  521.      */
  522.     public function setFridayMinimumTaxExcluded($fridayMinimumTaxExcluded)
  523.     {
  524.         $this->fridayMinimumTaxExcluded $fridayMinimumTaxExcluded;
  525.     }
  526.     /**
  527.      * @return mixed
  528.      */
  529.     public function getSaturdayMinimumTaxExcluded()
  530.     {
  531.         return $this->saturdayMinimumTaxExcluded;
  532.     }
  533.     /**
  534.      * @param mixed $saturdayMinimumTaxExcluded
  535.      */
  536.     public function setSaturdayMinimumTaxExcluded($saturdayMinimumTaxExcluded)
  537.     {
  538.         $this->saturdayMinimumTaxExcluded $saturdayMinimumTaxExcluded;
  539.     }
  540.     /**
  541.      * @return mixed
  542.      */
  543.     public function getSundayMinimumTaxExcluded()
  544.     {
  545.         return $this->sundayMinimumTaxExcluded;
  546.     }
  547.     /**
  548.      * @param mixed $sundayMinimumTaxExcluded
  549.      */
  550.     public function setSundayMinimumTaxExcluded($sundayMinimumTaxExcluded)
  551.     {
  552.         $this->sundayMinimumTaxExcluded $sundayMinimumTaxExcluded;
  553.     }
  554.     /**
  555.      * @param mixed $isDefault
  556.      */
  557.     public function setIsDefault($isDefault)
  558.     {
  559.         $this->isDefault $isDefault;
  560.     }
  561.     /**
  562.      * @return mixed
  563.      */
  564.     public function getIsDefault()
  565.     {
  566.         return $this->isDefault;
  567.     }
  568.     /**
  569.      * @return mixed
  570.      */
  571.     public function getSupplierCustomerLinks()
  572.     {
  573.         return $this->supplierCustomerLinks;
  574.     }
  575.     /**
  576.      * @param mixed $supplierCustomerLinks
  577.      */
  578.     public function setSupplierCustomerLinks($supplierCustomerLinks): void
  579.     {
  580.         $this->supplierCustomerLinks $supplierCustomerLinks;
  581.     }
  582.     public function addSupplierCustomerLink(SupplierCustomer $link)
  583.     {
  584.         if (! $this->supplierCustomerLinks->contains($link)) {
  585.             $this->supplierCustomerLinks->add($link);
  586.             $link->setDeliveryModel($this);
  587.         }
  588.     }
  589. }