src/Entity/DeliveryMethod.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5.  * @ORM\Entity(repositoryClass="App\Repository\DeliveryMethodRepository")
  6.  */
  7. class DeliveryMethod
  8. {
  9.     /**
  10.      * @ORM\Id()
  11.      * @ORM\GeneratedValue()
  12.      * @ORM\Column(type="integer")
  13.      */
  14.     private $id;
  15.     /**
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $averageDays;
  19.     /**
  20.      * @ORM\Column(type="float", nullable=true)
  21.      */
  22.     private $firstItem;
  23.     /**
  24.      * @ORM\Column(type="float", nullable=true)
  25.      */
  26.     private $additionalItem;
  27.     /**
  28.      * @ORM\ManyToOne(targetEntity="App\Entity\Product", inversedBy="deliveryMethods")
  29.      */
  30.     private $product;
  31.     /**
  32.      * @ORM\Column(type="integer")
  33.      */
  34.     private $serviceId;
  35.     /**
  36.      * @ORM\Column(type="boolean")
  37.      */
  38.     private $valid=false;
  39.     /**
  40.      * @ORM\ManyToOne(targetEntity="App\Entity\CompanyDefaultShipping", inversedBy="deliveryMethods")
  41.      */
  42.     private $companyDefaultShipping;
  43.     /**
  44.      * @ORM\Column(type="float", nullable=true)
  45.      */
  46.     private $freeAboveATotalOf;
  47.     /**
  48.      * @ORM\Column(type="float", nullable=true)
  49.      */
  50.     private $fixedPrice;
  51.     /**
  52.      * @ORM\Column(type="text", nullable=true)
  53.      */
  54.     private $pickupSchedule;
  55.     /**
  56.      * @ORM\Column(type="text", nullable=true)
  57.      */
  58.     private $pickupAddress;
  59.     /**
  60.      * @ORM\Column(type="boolean")
  61.      */
  62.     private $isAPickup=false;
  63.     /**
  64.      * @ORM\Column(type="integer")
  65.      */
  66.     private $pickupLocationId=false;
  67.     /**
  68.      * @ORM\Column(type="boolean")
  69.      */
  70.     private $withPacking=false;
  71.     public function getId()
  72.     {
  73.         return $this->id;
  74.     }
  75.     public function getServiceName(){
  76.         switch($this->getServiceId()){
  77.         case 0:
  78.             return 'Poste Canada';
  79.         case 1:
  80.             return 'Purolator';
  81.         case 2:
  82.             return 'FedEx';
  83.         case 3:
  84.             return 'UPS';
  85.         case 4:
  86.             return 'Autre';
  87.         case 5:
  88.             return 'Dicom';
  89.         case 9999:
  90.             return 'Pickup';
  91.         }
  92.     }
  93.     public function getDeliveryDays(){
  94.         switch($this->getAverageDays()){
  95.         case 1:
  96.             return '1-2';
  97.         case 2:
  98.             return '2-4';
  99.         case 3:
  100.             return '5-7';
  101.         case 4:
  102.             return '7-10';
  103.         case 5:
  104.             return '10+';
  105.         case 6:
  106.             return '3-5';
  107.         }
  108.     }
  109.     public function getAverageDays(): ?int
  110.     {
  111.         return $this->averageDays;
  112.     }
  113.     public function setAverageDays(int $averageDays): self
  114.     {
  115.         $this->averageDays $averageDays;
  116.         return $this;
  117.     }
  118.     public function getPickupLocationId(): ?int
  119.     {
  120.         return $this->pickupLocationId;
  121.     }
  122.     public function setPickupLocationId(int $pickupLocationId): self
  123.     {
  124.         $this->pickupLocationId $pickupLocationId;
  125.         return $this;
  126.     }
  127.     public function getFirstItem(): ?float
  128.     {
  129.         return $this->firstItem;
  130.     }
  131.     public function setFirstItem(?float $firstItem): self
  132.     {
  133.         $this->firstItem $firstItem;
  134.         return $this;
  135.     }
  136.     public function getAdditionalItem(): ?float
  137.     {
  138.         return $this->additionalItem;
  139.     }
  140.     public function setAdditionalItem(?float $additionalItem): self
  141.     {
  142.         $this->additionalItem $additionalItem;
  143.         return $this;
  144.     }
  145.     public function getProduct(): ?Product
  146.     {
  147.         return $this->product;
  148.     }
  149.     public function setProduct(?Product $product): self
  150.     {
  151.         $this->product $product;
  152.         return $this;
  153.     }
  154.     public function getServiceId(): ?int
  155.     {
  156.         return $this->serviceId;
  157.     }
  158.     public function setServiceId(int $serviceId): self
  159.     {
  160.         $this->serviceId $serviceId;
  161.         return $this;
  162.     }
  163.     public function getValid(): ?bool
  164.     {
  165.         return $this->valid;
  166.     }
  167.     public function setValid(bool $valid): self
  168.     {
  169.         $this->valid $valid;
  170.         return $this;
  171.     }
  172.     public function getCompanyDefaultShipping(): ?CompanyDefaultShipping
  173.     {
  174.         return $this->companyDefaultShipping;
  175.     }
  176.     public function setCompanyDefaultShipping(?CompanyDefaultShipping $companyDefaultShipping): self
  177.     {
  178.         $this->companyDefaultShipping $companyDefaultShipping;
  179.         return $this;
  180.     }
  181.     public function getFreeAboveATotalOf(): ?float
  182.     {
  183.         return $this->freeAboveATotalOf;
  184.     }
  185.     public function setFreeAboveATotalOf(?float $freeAboveATotalOf): self
  186.     {
  187.         $this->freeAboveATotalOf $freeAboveATotalOf;
  188.         return $this;
  189.     }
  190.     public function getFixedPrice(): ?float
  191.     {
  192.         return $this->fixedPrice;
  193.     }
  194.     public function setFixedPrice(?float $fixedPrice): self
  195.     {
  196.         $this->fixedPrice $fixedPrice;
  197.         return $this;
  198.     }
  199.     public function getDisplayPrice()
  200.     {
  201.         if(is_float($this->getFixedPrice()) && $this->getFixedPrice() == 0){
  202.             if($this->getServiceId() != 9999)
  203.                 return 'Gratuite en '.$this->getDeliveryDays().' Jour(s) avec le transporteur '.$this->getServiceName();
  204.             else
  205.                 return "Ramassage par vous même d'ici ".$this->getDeliveryDays().' jour(s)';
  206.         }
  207.         if(!empty($this->getFreeAboveATotalOf()) && $this->getFixedPrice()){
  208.             if($this->getServiceId() != 9999){
  209.                 $free 'Gratuite avec achat minimum de '.number_format($this->getFreeAboveATotalOf(),2).'$ en '.$this->getDeliveryDays().' Jour(s) avec le transporteur '.$this->getServiceName();
  210.             }else{
  211.                 $free 'Ramassage par vous même avec achat minimum de '.number_format($this->getFreeAboveATotalOf(),2).'$ en '.$this->getDeliveryDays().' Jour(s) ';
  212.             }
  213.             if($this->getFixedPrice()){
  214.                 $free number_format($this->getFixedPrice(),2).'$ ou '.$free;
  215.             }
  216.             return $free;
  217.         }
  218.         if(!empty($this->getFreeAboveATotalOf())){
  219.             if($this->getServiceId() != 9999){
  220.                 return 'Gratuite avec achat minimum de '.number_format($this->getFreeAboveATotalOf(),2).'$ en '.$this->getDeliveryDays().' Jour(s) avec le transporteur '.$this->getServiceName();
  221.             }else{
  222.                 return 'Ramassage par vous même avec achat minimum de '.number_format($this->getFreeAboveATotalOf(),2).'$ en '.$this->getDeliveryDays().' Jour(s) ';
  223.             }
  224.         }
  225.         if($this->getFixedPrice() != null){
  226.             if($this->getServiceId() != 9999)
  227.                 return number_format($this->getFixedPrice(),2).'$ en '.$this->getDeliveryDays().' Jour(s) avec le transporteur '.$this->getServiceName();
  228.             else
  229.                 return 'Ramassage par vous même pour un prix fixe de '.number_format($this->getFixedPrice(),2)."$ d'ici ".$this->getDeliveryDays().' Jour(s)';
  230.         }
  231.         if($this->getFirstItem() != null){
  232.             $text number_format($this->getFirstItem(),2).'$ par unité ';
  233.             if($this->getAdditionalItem() != null){
  234.                 $text .= 'et '.number_format($this->getAdditionalItem(),2).'$ par unité supplémentaire';
  235.             }
  236.             $text .= 'en '.$this->getDeliveryDays().' Jour(s) avec le transporteur '.$this->getServiceName();
  237.             return $text;
  238.         }
  239.         return 'Inconnu';
  240.     }
  241.     public function __toString(){
  242.         return $this->getDisplayPrice();
  243.     }
  244.     public function getPickupSchedule(): ?string
  245.     {
  246.         return $this->pickupSchedule;
  247.     }
  248.     public function setPickupSchedule(?string $pickupSchedule): self
  249.     {
  250.         $this->pickupSchedule $pickupSchedule;
  251.         return $this;
  252.     }
  253.     public function getPickupAddress(): ?string
  254.     {
  255.         return $this->pickupAddress;
  256.     }
  257.     public function setPickupAddress(?string $pickupAddress): self
  258.     {
  259.         $this->pickupAddress $pickupAddress;
  260.         return $this;
  261.     }
  262.     public function getIsAPickup(): ?bool
  263.     {
  264.         return $this->isAPickup;
  265.     }
  266.     public function setIsAPickup(bool $isAPickup): self
  267.     {
  268.         $this->isAPickup $isAPickup;
  269.         return $this;
  270.     }
  271.     public function getWithPacking(): bool {
  272.         return $this->withPacking;
  273.     }
  274.     public function setWithPacking(bool $withPacking): self {
  275.         $this->withPacking $withPacking;
  276.         return $this;
  277.     }
  278. }