src/Entity/Period.php line 13

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PeriodRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Gedmo\Timestampable\Traits\TimestampableEntity;
  9. #[ORM\Entity(repositoryClassPeriodRepository::class)]
  10. class Period
  11. {
  12.     use TimestampableEntity;
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column]
  16.     private ?int $id null;
  17.     #[ORM\Column(length255nullabletrue)]
  18.     private ?string $name null;
  19.     #[ORM\Column]
  20.     private ?bool $isOpen false;
  21.     #[ORM\Column]
  22.     private ?bool $isPublished false;
  23.     #[ORM\Column]
  24.     private ?bool $isHidden false;
  25.     #[ORM\Column]
  26.     private ?bool $isCalcPeriod false;
  27.     #[ORM\Column]
  28.     private ?int $orderNumber null;
  29.     #[ORM\Column(typeTypes::DATE_MUTABLEnullabletrue)]
  30.     private ?\DateTimeInterface $startDate null;
  31.     #[ORM\Column(typeTypes::DATE_MUTABLEnullabletrue)]
  32.     private ?\DateTimeInterface $endDate null;
  33.     #[ORM\ManyToOne(inversedBy'periods')]
  34.     private ?Calendar $calendar null;
  35.     #[ORM\ManyToOne(inversedBy'periods'fetch'EAGER')]
  36.     private ?PeriodType $periodType null;
  37.     #[ORM\ManyToOne(targetEntityself::class, inversedBy'childrenPeriods')]
  38.     private ?self $parentPeriod null;
  39.     #[ORM\OneToMany(mappedBy'parentPeriod'targetEntityself::class)]
  40.     private Collection $childrenPeriods;
  41.     #[ORM\OneToMany(mappedBy'period'targetEntityQuota::class)]
  42.     private Collection $quotas;
  43.     #[ORM\OneToMany(mappedBy'period'targetEntityQuotaAssignment::class)]
  44.     private Collection $quotaAssignments;
  45.     #[ORM\OneToMany(mappedBy'period'targetEntityPlan::class)]
  46.     private Collection $plans;
  47.     #[ORM\OneToMany(mappedBy'period'targetEntityOrder::class)]
  48.     private Collection $orders;
  49.     #[ORM\OneToMany(mappedBy'quotaPeriod'targetEntityRuleResult::class)]
  50.     private Collection $ruleResults;
  51.     #[ORM\OneToMany(mappedBy'period'targetEntityCommission::class)]
  52.     private Collection $commissions;
  53.     #[ORM\OneToMany(mappedBy'period'targetEntityCredit::class)]
  54.     private Collection $credits;
  55.     public function __construct()
  56.     {
  57.         $this->childrenPeriods = new ArrayCollection();
  58.         $this->quotas = new ArrayCollection();
  59.         $this->quotaAssignments = new ArrayCollection();
  60.         $this->plans = new ArrayCollection();
  61.         $this->orders = new ArrayCollection();
  62.         $this->ruleResults = new ArrayCollection();
  63.         $this->commissions = new ArrayCollection();
  64.         $this->credits = new ArrayCollection();
  65.     }
  66.     public function getId(): ?int
  67.     {
  68.         return $this->id;
  69.     }
  70.     public function getName(): ?string
  71.     {
  72.         return $this->name;
  73.     }
  74.     public function setName(?string $name): self
  75.     {
  76.         $this->name $name;
  77.         return $this;
  78.     }
  79.     public function isIsOpen(): ?bool
  80.     {
  81.         return $this->isOpen;
  82.     }
  83.     public function setIsOpen(bool $isOpen): self
  84.     {
  85.         $this->isOpen $isOpen;
  86.         return $this;
  87.     }
  88.     public function isIsPublished(): ?bool
  89.     {
  90.         return $this->isPublished;
  91.     }
  92.     public function setIsPublished(bool $isPublished): self
  93.     {
  94.         $this->isPublished $isPublished;
  95.         return $this;
  96.     }
  97.     public function isIsHidden(): ?bool
  98.     {
  99.         return $this->isHidden;
  100.     }
  101.     public function setIsHidden(bool $isHidden): self
  102.     {
  103.         $this->isHidden $isHidden;
  104.         return $this;
  105.     }
  106.     public function isIsCalcPeriod(): ?bool
  107.     {
  108.         return $this->isCalcPeriod;
  109.     }
  110.     public function setIsCalcPeriod(bool $isCalcPeriod): self
  111.     {
  112.         $this->isCalcPeriod $isCalcPeriod;
  113.         return $this;
  114.     }
  115.     public function getOrderNumber(): ?int
  116.     {
  117.         return $this->orderNumber;
  118.     }
  119.     public function setOrderNumber(int $orderNumber): self
  120.     {
  121.         $this->orderNumber $orderNumber;
  122.         return $this;
  123.     }
  124.     public function getStartDate(): ?\DateTimeInterface
  125.     {
  126.         return $this->startDate;
  127.     }
  128.     public function setStartDate(?\DateTimeInterface $startDate): self
  129.     {
  130.         $this->startDate $startDate;
  131.         return $this;
  132.     }
  133.     public function getEndDate(): ?\DateTimeInterface
  134.     {
  135.         return $this->endDate;
  136.     }
  137.     public function setEndDate(?\DateTimeInterface $endDate): self
  138.     {
  139.         $this->endDate $endDate;
  140.         return $this;
  141.     }
  142.     public function getCalendar(): ?Calendar
  143.     {
  144.         return $this->calendar;
  145.     }
  146.     public function setCalendar(?Calendar $calendar): self
  147.     {
  148.         $this->calendar $calendar;
  149.         return $this;
  150.     }
  151.     public function getPeriodType(): ?PeriodType
  152.     {
  153.         return $this->periodType;
  154.     }
  155.     public function setPeriodType(?PeriodType $periodType): self
  156.     {
  157.         $this->periodType $periodType;
  158.         return $this;
  159.     }
  160.     public function getParentPeriod(): ?self
  161.     {
  162.         return $this->parentPeriod;
  163.     }
  164.     public function setParentPeriod(?self $parentPeriod): self
  165.     {
  166.         $this->parentPeriod $parentPeriod;
  167.         return $this;
  168.     }
  169.     /**
  170.      * @return Collection<int, self>
  171.      */
  172.     public function getChildrenPeriods(): Collection
  173.     {
  174.         return $this->childrenPeriods;
  175.     }
  176.     public function addChildrenPeriod(self $childrenPeriod): self
  177.     {
  178.         if (!$this->childrenPeriods->contains($childrenPeriod)) {
  179.             $this->childrenPeriods->add($childrenPeriod);
  180.             $childrenPeriod->setParentPeriod($this);
  181.         }
  182.         return $this;
  183.     }
  184.     public function removeChildrenPeriod(self $childrenPeriod): self
  185.     {
  186.         if ($this->childrenPeriods->removeElement($childrenPeriod)) {
  187.             // set the owning side to null (unless already changed)
  188.             if ($childrenPeriod->getParentPeriod() === $this) {
  189.                 $childrenPeriod->setParentPeriod(null);
  190.             }
  191.         }
  192.         return $this;
  193.     }
  194.     /**
  195.      * @return Collection<int, Quota>
  196.      */
  197.     public function getQuotas(): Collection
  198.     {
  199.         return $this->quotas;
  200.     }
  201.     public function addQuota(Quota $quota): self
  202.     {
  203.         if (!$this->quotas->contains($quota)) {
  204.             $this->quotas->add($quota);
  205.             $quota->setPeriod($this);
  206.         }
  207.         return $this;
  208.     }
  209.     public function removeQuota(Quota $quota): self
  210.     {
  211.         if ($this->quotas->removeElement($quota)) {
  212.             // set the owning side to null (unless already changed)
  213.             if ($quota->getPeriod() === $this) {
  214.                 $quota->setPeriod(null);
  215.             }
  216.         }
  217.         return $this;
  218.     }
  219.     /**
  220.      * @return Collection<int, QuotaAssignment>
  221.      */
  222.     public function getQuotaAssignments(): Collection
  223.     {
  224.         return $this->quotaAssignments;
  225.     }
  226.     public function addQuotaAssignment(QuotaAssignment $quotaAssignment): self
  227.     {
  228.         if (!$this->quotaAssignments->contains($quotaAssignment)) {
  229.             $this->quotaAssignments->add($quotaAssignment);
  230.             $quotaAssignment->setPeriod($this);
  231.         }
  232.         return $this;
  233.     }
  234.     public function removeQuotaAssignment(QuotaAssignment $quotaAssignment): self
  235.     {
  236.         if ($this->quotaAssignments->removeElement($quotaAssignment)) {
  237.             // set the owning side to null (unless already changed)
  238.             if ($quotaAssignment->getPeriod() === $this) {
  239.                 $quotaAssignment->setPeriod(null);
  240.             }
  241.         }
  242.         return $this;
  243.     }
  244.     /**
  245.      * @return Collection<int, Plan>
  246.      */
  247.     public function getPlans(): Collection
  248.     {
  249.         return $this->plans;
  250.     }
  251.     public function addPlan(Plan $plan): self
  252.     {
  253.         if (!$this->plans->contains($plan)) {
  254.             $this->plans->add($plan);
  255.             $plan->setPeriod($this);
  256.         }
  257.         return $this;
  258.     }
  259.     public function removePlan(Plan $plan): self
  260.     {
  261.         if ($this->plans->removeElement($plan)) {
  262.             // set the owning side to null (unless already changed)
  263.             if ($plan->getPeriod() === $this) {
  264.                 $plan->setPeriod(null);
  265.             }
  266.         }
  267.         return $this;
  268.     }
  269.     /**
  270.      * @return Collection<int, Order>
  271.      */
  272.     public function getOrders(): Collection
  273.     {
  274.         return $this->orders;
  275.     }
  276.     public function addOrder(Order $order): self
  277.     {
  278.         if (!$this->orders->contains($order)) {
  279.             $this->orders->add($order);
  280.             $order->setPeriod($this);
  281.         }
  282.         return $this;
  283.     }
  284.     public function removeOrder(Order $order): self
  285.     {
  286.         if ($this->orders->removeElement($order)) {
  287.             // set the owning side to null (unless already changed)
  288.             if ($order->getPeriod() === $this) {
  289.                 $order->setPeriod(null);
  290.             }
  291.         }
  292.         return $this;
  293.     }
  294.     /**
  295.      * @return Collection<int, RuleResult>
  296.      */
  297.     public function getRuleResults(): Collection
  298.     {
  299.         return $this->ruleResults;
  300.     }
  301.     public function addRuleResult(RuleResult $ruleResult): static
  302.     {
  303.         if (!$this->ruleResults->contains($ruleResult)) {
  304.             $this->ruleResults->add($ruleResult);
  305.             $ruleResult->setQuotaPeriod($this);
  306.         }
  307.         return $this;
  308.     }
  309.     public function removeRuleResult(RuleResult $ruleResult): static
  310.     {
  311.         if ($this->ruleResults->removeElement($ruleResult)) {
  312.             // set the owning side to null (unless already changed)
  313.             if ($ruleResult->getQuotaPeriod() === $this) {
  314.                 $ruleResult->setQuotaPeriod(null);
  315.             }
  316.         }
  317.         return $this;
  318.     }
  319.     /**
  320.      * @return Collection<int, Commission>
  321.      */
  322.     public function getCommissions(): Collection
  323.     {
  324.         return $this->commissions;
  325.     }
  326.     public function addCommission(Commission $commission): static
  327.     {
  328.         if (!$this->commissions->contains($commission)) {
  329.             $this->commissions->add($commission);
  330.             $commission->setPeriod($this);
  331.         }
  332.         return $this;
  333.     }
  334.     public function removeCommission(Commission $commission): static
  335.     {
  336.         if ($this->commissions->removeElement($commission)) {
  337.             // set the owning side to null (unless already changed)
  338.             if ($commission->getPeriod() === $this) {
  339.                 $commission->setPeriod(null);
  340.             }
  341.         }
  342.         return $this;
  343.     }
  344.     /**
  345.      * @return Collection<int, Credit>
  346.      */
  347.     public function getCredits(): Collection
  348.     {
  349.         return $this->credits;
  350.     }
  351.     public function addCredit(Credit $credit): static
  352.     {
  353.         if (!$this->credits->contains($credit)) {
  354.             $this->credits->add($credit);
  355.             $credit->setPeriod($this);
  356.         }
  357.         return $this;
  358.     }
  359.     public function removeCredit(Credit $credit): static
  360.     {
  361.         if ($this->credits->removeElement($credit)) {
  362.             // set the owning side to null (unless already changed)
  363.             if ($credit->getPeriod() === $this) {
  364.                 $credit->setPeriod(null);
  365.             }
  366.         }
  367.         return $this;
  368.     }
  369.     public function __toString(): string
  370.     {
  371.         return (string)$this->name;
  372.     }
  373. }