File: /var/www/dvpis2025/dvpis.kaunokolegija.lt/src/Entity/LecturerAgreement.php
<?php
namespace App\Entity;
use App\Repository\LecturerAgreementRepository;
use DateTime;
use DateTimeInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: LecturerAgreementRepository::class)]
#[ORM\Table(name: 'lecturer_agreement')]
class LecturerAgreement
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\ManyToOne(inversedBy: 'lecturerAgreements')]
#[ORM\JoinColumn(name: 'lecturer_id', referencedColumnName: 'id', nullable: false)]
private ?Lecturer $lecturer = null;
#[ORM\JoinColumn(name: 'lecturer_position_id', referencedColumnName: 'id')]
#[ORM\ManyToOne(targetEntity: LecturerPosition::class, inversedBy: 'lecturerAgreements')]
private ?LecturerPosition $lecturerPosition = null;
#[ORM\Column(name: 'contract_from', type: 'date', nullable: true)]
private ?DateTimeInterface $contractFrom;
#[ORM\Column(name: 'contract_to', type: 'date', nullable: true)]
private ?DateTimeInterface $contractTo;
#[ORM\Column(name: 'post_size', type: 'float', nullable: true)]
private ?float $postSize;
#[ORM\Column(name: 'notes', type: 'text', nullable: true)]
private ?string $notes;
/**
* @var Collection<int, FiveYearLecturerPlan>
*/
#[ORM\OneToMany(mappedBy: 'lecturerAgreement', targetEntity: FiveYearLecturerPlan::class)]
private Collection $fiveYearLecturerPlans;
/**
* @var Collection<int, FiveYearLecturerPlanApproval>
*/
#[ORM\OneToMany(mappedBy: 'lecturerAgreement', targetEntity: FiveYearLecturerPlanApproval::class)]
private Collection $fiveYearLecturerPlanApprovals;
#[ORM\ManyToOne(inversedBy: 'lecturerAgreements')]
private ?LecturerAgreementType $lecturerAgreementType = null;
/**
* @var Collection<int, ActivitiesPlan>
*/
#[ORM\OneToMany(mappedBy: 'lecturerAgreement', targetEntity: ActivitiesPlan::class, orphanRemoval: true)]
private Collection $activitiesPlans;
public function __construct()
{
$this->fiveYearLecturerPlans = new ArrayCollection();
$this->fiveYearLecturerPlanApprovals = new ArrayCollection();
$this->activitiesPlans = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getContractFrom(): ?\DateTimeInterface
{
return $this->contractFrom;
}
public function setContractFrom(?\DateTimeInterface $contractFrom): static
{
$this->contractFrom = $contractFrom;
return $this;
}
public function getContractTo(): ?\DateTimeInterface
{
return $this->contractTo;
}
public function setContractTo(?\DateTimeInterface $contractTo): static
{
$this->contractTo = $contractTo;
return $this;
}
public function getPostSize(): ?float
{
return $this->postSize;
}
public function setPostSize(?float $postSize): static
{
$this->postSize = $postSize;
return $this;
}
public function getNotes(): ?string
{
return $this->notes;
}
public function setNotes(?string $notes): static
{
$this->notes = $notes;
return $this;
}
public function getLecturer(): ?Lecturer
{
return $this->lecturer;
}
public function setLecturer(?Lecturer $lecturer): static
{
$this->lecturer = $lecturer;
return $this;
}
public function getLecturerPosition(): ?LecturerPosition
{
return $this->lecturerPosition;
}
public function setLecturerPosition(?LecturerPosition $lecturerPosition): static
{
$this->lecturerPosition = $lecturerPosition;
return $this;
}
/**
* @return Collection<int, FiveYearLecturerPlan>
*/
public function getFiveYearLecturerPlans(): Collection
{
return $this->fiveYearLecturerPlans;
}
public function addFiveYearLecturerPlan(FiveYearLecturerPlan $fiveYearLecturerPlan): static
{
if (!$this->fiveYearLecturerPlans->contains($fiveYearLecturerPlan)) {
$this->fiveYearLecturerPlans->add($fiveYearLecturerPlan);
$fiveYearLecturerPlan->setLecturerAgreement($this);
}
return $this;
}
public function removeFiveYearLecturerPlan(FiveYearLecturerPlan $fiveYearLecturerPlan): static
{
if ($this->fiveYearLecturerPlans->removeElement($fiveYearLecturerPlan)) {
// set the owning side to null (unless already changed)
if ($fiveYearLecturerPlan->getLecturerAgreement() === $this) {
$fiveYearLecturerPlan->setLecturerAgreement(null);
}
}
return $this;
}
/**
* @return Collection<int, FiveYearLecturerPlanApproval>
*/
public function getFiveYearLecturerPlanApprovals(): Collection
{
return $this->fiveYearLecturerPlanApprovals;
}
public function addFiveYearLecturerPlanApproval(FiveYearLecturerPlanApproval $fiveYearLecturerPlanApproval): static
{
if (!$this->fiveYearLecturerPlanApprovals->contains($fiveYearLecturerPlanApproval)) {
$this->fiveYearLecturerPlanApprovals->add($fiveYearLecturerPlanApproval);
$fiveYearLecturerPlanApproval->setLecturerAgreement($this);
}
return $this;
}
public function removeFiveYearLecturerPlanApproval(FiveYearLecturerPlanApproval $fiveYearLecturerPlanApproval): static
{
if ($this->fiveYearLecturerPlanApprovals->removeElement($fiveYearLecturerPlanApproval)) {
// set the owning side to null (unless already changed)
if ($fiveYearLecturerPlanApproval->getLecturerAgreement() === $this) {
$fiveYearLecturerPlanApproval->setLecturerAgreement(null);
}
}
return $this;
}
public function getLecturerAgreementType(): ?LecturerAgreementType
{
return $this->lecturerAgreementType;
}
public function setLecturerAgreementType(?LecturerAgreementType $lecturerAgreementType): static
{
$this->lecturerAgreementType = $lecturerAgreementType;
return $this;
}
/**
* @return Collection<int, ActivitiesPlan>
*/
public function getActivitiesPlans(): Collection
{
return $this->activitiesPlans;
}
public function addActivitiesPlan(ActivitiesPlan $activitiesPlan): static
{
if (!$this->activitiesPlans->contains($activitiesPlan)) {
$this->activitiesPlans->add($activitiesPlan);
$activitiesPlan->setLecturerAgreement($this);
}
return $this;
}
public function removeActivitiesPlan(ActivitiesPlan $activitiesPlan): static
{
if ($this->activitiesPlans->removeElement($activitiesPlan)) {
// set the owning side to null (unless already changed)
if ($activitiesPlan->getLecturerAgreement() === $this) {
$activitiesPlan->setLecturerAgreement(null);
}
}
return $this;
}
public function __toString(): string
{
return $this->getLecturer()
. ' ' . $this->lecturerPosition->getName()
. ' ' . $this->getLecturerAgreementType()?->getName()
. ' ' . $this->getContractFrom()->format('Y-m-d')
. '-' . ($this->getContractTo()?->format('Y-m-d') ?? 'N/A')
. ' (' . $this->getPostSize() . ')'
;
}
}