src/Entity/Slave/OperationTariff.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Slave;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Table(name="eposm_s_operation_tariff")
  9.  * @ORM\Entity(repositoryClass="App\Repository\Slave\OperationTariffRepository")
  10.  */
  11. class OperationTariff
  12. {
  13.     public function canDuplicate()
  14.     {
  15.         return true;
  16.     }
  17.     public function canDelete()
  18.     {
  19.         foreach($this->getAmounts() as $ota){
  20.             if(sizeof($ota->getTickets()) > || sizeof($ota->getUavTickets()) > 0)
  21.                 return false;
  22.         }
  23.         return true;
  24.     }
  25.     public function displayZips()
  26.     {
  27.         $string '';
  28.         $first true;
  29.         foreach($this->zips as $arrayZip){
  30.             if($first$first false; else $string.= ' - ';
  31.             $string.= $arrayZip[1];
  32.         }
  33.         return $string;
  34.     }
  35.     public function displayFirstThreeZips()
  36.     {
  37.         $length sizeof($this->zips);
  38.         $string $this->zips[0][1];
  39.         if(sizeof($this->zips) > 1)
  40.             $string.=' - '.$this->zips[1][1];
  41.         if(sizeof($this->zips) > 2)
  42.             $string.=' - '.$this->zips[2][1];
  43.         return $string.' ... ';
  44.     }
  45.     public function displayZipIds()
  46.     {
  47.         $string '';
  48.         $first true;
  49.         foreach($this->zips as $arrayZip){
  50.             if($first$first false; else $string.= ' ';
  51.             $string.= $arrayZip[0];
  52.         }
  53.         return $string;
  54.     }
  55.     public function getStandardAmount()
  56.     {
  57.         foreach($this->amounts as $amount){
  58.             if($amount->isStandard()){
  59.                 return $amount;
  60.                 break;
  61.             }
  62.         }
  63.         return null;
  64.     }
  65.     public function getUavAmount()
  66.     {
  67.         foreach($this->amounts as $amount){
  68.             if($amount->getValue() == 'UAV'){
  69.                 return $amount;
  70.                 break;
  71.             }
  72.         }
  73.         return null;
  74.     }
  75.     /**
  76.      * @ORM\Column(name="id", type="bigint")
  77.      * @ORM\Id
  78.      * @ORM\GeneratedValue(strategy="AUTO")
  79.      */
  80.     protected $id;
  81.         
  82.     /**
  83.      * @ORM\Column(name="is_all_zip", type="boolean")
  84.      */
  85.     protected $allZip;
  86.     
  87.     /**
  88.      * @ORM\Column(name="id_province", type="bigint")
  89.      */
  90.     protected $idProvince;
  91.     
  92.     /**
  93.      * @ORM\Column(name="zips", type="array", nullable=true)
  94.      */
  95.     protected $zips;
  96.     // ManyToOne
  97.         /**
  98.          * @ORM\ManyToOne(targetEntity="App\Entity\Slave\Operation", inversedBy="tariffs")
  99.          * @ORM\JoinColumn(name="operation_id", referencedColumnName="id")
  100.          */
  101.         private $operation;
  102.     //
  103.     // OneToMany
  104.         /**
  105.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\OperationTariffAmount", mappedBy="tariff", cascade={"persist", "remove"})
  106.          */
  107.         private $amounts;
  108.     //
  109.     public function __construct()
  110.     {
  111.         $this->amounts = new ArrayCollection();
  112.     }
  113.     public function getId(): ?string
  114.     {
  115.         return $this->id;
  116.     }
  117.     public function isAllZip(): ?bool
  118.     {
  119.         return $this->allZip;
  120.     }
  121.     public function setAllZip(bool $allZip): self
  122.     {
  123.         $this->allZip $allZip;
  124.         return $this;
  125.     }
  126.     public function getIdProvince(): ?string
  127.     {
  128.         return $this->idProvince;
  129.     }
  130.     public function setIdProvince(string $idProvince): self
  131.     {
  132.         $this->idProvince $idProvince;
  133.         return $this;
  134.     }
  135.     public function getZips(): array
  136.     {
  137.         return $this->zips;
  138.     }
  139.     public function setZips(?array $zips): self
  140.     {
  141.         $this->zips $zips;
  142.         return $this;
  143.     }
  144.     public function getOperation(): ?Operation
  145.     {
  146.         return $this->operation;
  147.     }
  148.     public function setOperation(?Operation $operation): self
  149.     {
  150.         $this->operation $operation;
  151.         return $this;
  152.     }
  153.     /**
  154.      * @return Collection<int, OperationTariffAmount>
  155.      */
  156.     public function getAmounts(): Collection
  157.     {
  158.         return $this->amounts;
  159.     }
  160.     public function addAmount(OperationTariffAmount $amount): self
  161.     {
  162.         if (!$this->amounts->contains($amount)) {
  163.             $this->amounts->add($amount);
  164.             $amount->setTariff($this);
  165.         }
  166.         return $this;
  167.     }
  168.     public function removeAmount(OperationTariffAmount $amount): self
  169.     {
  170.         if ($this->amounts->removeElement($amount)) {
  171.             // set the owning side to null (unless already changed)
  172.             if ($amount->getTariff() === $this) {
  173.                 $amount->setTariff(null);
  174.             }
  175.         }
  176.         return $this;
  177.     }
  178. }