src/Entity/XmlApi.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\XmlApiRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Validator\Constraints as Asserts;
  7. use Doctrine\Common\Collections\Collection;
  8. #[ORM\Entity(repositoryClass: XmlApiRepository::class)]
  9. class XmlApi extends Product
  10. {
  11.     const XMLAPI_DEFAULT_MARGIN = 10;
  12.     #[ORM\Column(length: 255)]
  13.     private ?string $name = null;
  14.     #[ORM\Column(length: 128)]
  15.     private ?string $gdsCode = null;
  16.     #[ORM\Column(length: 32, nullable: true)]
  17.     private ?string $color = null;
  18.     #[ORM\Column]
  19.     private ?bool $payAtHotelAuthorized = null;
  20.     #[ORM\Column(nullable: true)]
  21.     #[Asserts\LessThanOrEqual(100, message: 'The value should be between 1 and 100!')]
  22.     private ?float $immediatePaymentPercent = null;
  23.     #[ORM\ManyToOne]
  24.     private ?CreditCard $creditCard = null;
  25.     #[ORM\Column]
  26.     private ?int $source = null;
  27.     #[ORM\Column]
  28.     private ?float $marginB2C = null;
  29.     #[ORM\Column]
  30.     private ?float $marginB2B = null;
  31.     #[ORM\OneToMany(mappedBy: 'xmlApi', targetEntity: CustomerXmlApi::class)]
  32.     private  $customerXmlApis;
  33.     #[ORM\Column]
  34.     private ?bool $active = null;
  35.     #[ORM\Column(length: 45, nullable: true)]
  36.     private ?string $xmlApiType = null;
  37.     #[ORM\ManyToOne(inversedBy: 'b2cXmlApis')]
  38.     private ?MarkupStrategy $b2cMarkupStrategy = null;
  39.     #[ORM\ManyToOne(inversedBy: 'b2bXmlApis')]
  40.     private ?MarkupStrategy $b2bMarkupStrategy = null;
  41.     #[ORM\OneToMany(mappedBy: 'xmlApi', targetEntity: AirlineXmlApi::class, orphanRemoval: true)]
  42.     private Collection $airlineXmlApis;
  43.     #[ORM\Column(length: 45, nullable: true)]
  44.     private ?string $commissionType = null;
  45.     #[ORM\Column]
  46.     private ?bool $isAllowedPagination = null;
  47.     public function __construct()
  48.     {
  49.         parent::__construct();
  50.         $this->customerXmlApis = new ArrayCollection();
  51.         $this->airlineXmlApis = new ArrayCollection();
  52.     }
  53.     public function getName(): ?string
  54.     {
  55.         return $this->name;
  56.     }
  57.     public function setName(string $name): self
  58.     {
  59.         $this->name = $name;
  60.         return $this;
  61.     }
  62.     public function getGdsCode(): ?string
  63.     {
  64.         return $this->gdsCode;
  65.     }
  66.     public function setGdsCode(string $gdsCode): self
  67.     {
  68.         $this->gdsCode = $gdsCode;
  69.         return $this;
  70.     }
  71.     public function getColor(): ?string
  72.     {
  73.         return $this->color;
  74.     }
  75.     public function setColor(?string $color): self
  76.     {
  77.         $this->color = $color;
  78.         return $this;
  79.     }
  80.     public function isPayAtHotelAuthorized(): ?bool
  81.     {
  82.         return $this->payAtHotelAuthorized;
  83.     }
  84.     public function setPayAtHotelAuthorized(bool $payAtHotelAuthorized): self
  85.     {
  86.         $this->payAtHotelAuthorized = $payAtHotelAuthorized;
  87.         return $this;
  88.     }
  89.     public function getImmediatePaymentPercent(): ?float
  90.     {
  91.         return $this->immediatePaymentPercent;
  92.     }
  93.     public function setImmediatePaymentPercent(?float $immediatePaymentPercent): self
  94.     {
  95.         $this->immediatePaymentPercent = $immediatePaymentPercent;
  96.         return $this;
  97.     }
  98.     public function getCreditCard(): ?CreditCard
  99.     {
  100.         return $this->creditCard;
  101.     }
  102.     public function setCreditCard(?CreditCard $creditCard): self
  103.     {
  104.         $this->creditCard = $creditCard;
  105.         return $this;
  106.     }
  107.     public function getSource(): ?int
  108.     {
  109.         return $this->source;
  110.     }
  111.     public function setSource(int $source): self
  112.     {
  113.         $this->source = $source;
  114.         return $this;
  115.     }
  116.     public function __toString(): string
  117.     {
  118.         return $this->name ?? 'UNDEFINED';
  119.         // Todo - s'assurer que les xml-api ont des noms non vides
  120.     }
  121.     public function getmarginB2C(): ?float
  122.     {
  123.         return $this->marginB2C;
  124.     }
  125.     public function setmarginB2C(float $marginB2C): static
  126.     {
  127.         $this->marginB2C = $marginB2C;
  128.         return $this;
  129.     }
  130.     public function getmarginB2B(): ?float
  131.     {
  132.         return $this->marginB2B;
  133.     }
  134.     public function setmarginB2B(float $marginB2B): static
  135.     {
  136.         $this->marginB2B = $marginB2B;
  137.         return $this;
  138.     }
  139.     /**
  140.      * @return Collection<int, CustomerXmlApi>
  141.      */
  142.     public function getCustomerXmlApis(): Collection
  143.     {
  144.         return $this->customerXmlApis;
  145.     }
  146.     public function addCustomerXmlApi(CustomerXmlApi $customerXmlApi): self
  147.     {
  148.         if (!$this->customerXmlApis->contains($customerXmlApi)) {
  149.             $this->customerXmlApis[] = $customerXmlApi;
  150.             $customerXmlApi->setXmlApi($this);
  151.         }
  152.         return $this;
  153.     }
  154.     public function removeCustomerXmlApis(CustomerXmlApi $customerXmlApis): self
  155.     {
  156.         if ($this->customerXmlApis->removeElement($customerXmlApis)) {
  157.             // set the owning side to null (unless already changed)
  158.             if ($customerXmlApis->getXmlApi() === $this) {
  159.                 $customerXmlApis->setXmlApi(null);
  160.             }
  161.         }
  162.         return $this;
  163.     }
  164.     public function isActive(): ?bool
  165.     {
  166.         return $this->active;
  167.     }
  168.     public function setActive(bool $active): static
  169.     {
  170.         $this->active = $active;
  171.         return $this;
  172.     }
  173.     public function getClass()  : string {
  174.         return "XmlApi";
  175.     }
  176.     public function getIcon(): string
  177.     {
  178.         return match ($this->xmlApiType) {
  179.             "HOTEL" => "fas fa-hotel",
  180.             "TRANSFER" => "fas fa-car",
  181.             "FLIGHT" => "fas fa-plane",
  182.             default => "fe-rss",
  183.         };
  184.     }
  185.     public function getXmlApiType(): ?string
  186.     {
  187.         return $this->xmlApiType;
  188.     }
  189.     public function setXmlApiType(?string $xmlApiType): static
  190.     {
  191.         $this->xmlApiType = $xmlApiType;
  192.         return $this;
  193.     }
  194.     public function getB2cMarkupStrategy(): ?MarkupStrategy
  195.     {
  196.         return $this->b2cMarkupStrategy;
  197.     }
  198.     public function setB2cMarkupStrategy(?MarkupStrategy $b2cMarkupStrategy): static
  199.     {
  200.         $this->b2cMarkupStrategy = $b2cMarkupStrategy;
  201.         return $this;
  202.     }
  203.     public function getB2bMarkupStrategy(): ?MarkupStrategy
  204.     {
  205.         return $this->b2bMarkupStrategy;
  206.     }
  207.     public function setB2bMarkupStrategy(?MarkupStrategy $b2bMarkupStrategy): static
  208.     {
  209.         $this->b2bMarkupStrategy = $b2bMarkupStrategy;
  210.         return $this;
  211.     }
  212.     /**
  213.      * @return Collection<int, AirlineXmlApi>
  214.      */
  215.     public function getAirlineXmlApis(): Collection
  216.     {
  217.         return $this->airlineXmlApis;
  218.     }
  219.     public function addAirlineXmlApi(AirlineXmlApi $airlineXmlApi): static
  220.     {
  221.         if (!$this->airlineXmlApis->contains($airlineXmlApi)) {
  222.             $this->airlineXmlApis->add($airlineXmlApi);
  223.             $airlineXmlApi->setXmlApi($this);
  224.         }
  225.         return $this;
  226.     }
  227.     public function removeAirlineXmlApi(AirlineXmlApi $airlineXmlApi): static
  228.     {
  229.         if ($this->airlineXmlApis->removeElement($airlineXmlApi)) {
  230.             // set the owning side to null (unless already changed)
  231.             if ($airlineXmlApi->getXmlApi() === $this) {
  232.                 $airlineXmlApi->setXmlApi(null);
  233.             }
  234.         }
  235.         return $this;
  236.     }
  237.     public function getCommissionType(): ?string
  238.     {
  239.         return $this->commissionType;
  240.     }
  241.     public function setCommissionType(string $commissionType): static
  242.     {
  243.         $this->commissionType = $commissionType;
  244.         return $this;
  245.     }
  246.     public function getIsAllowedPagination(): ?bool
  247.     {
  248.         return $this->isAllowedPagination;
  249.     }
  250.     public function setIsAllowedPagination(?bool $isAllowedPagination): void
  251.     {
  252.         $this->isAllowedPagination = $isAllowedPagination;
  253.     }
  254. }