<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Symfony\Component\Serializer\Annotation\Groups;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: 'App\Repository\AppraisalFormRepository')]
class AppraisalForm
{
#[Groups(['LogService'])]
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[Groups(['LogService', 'Appraisal'])]
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $title;
#[Groups(['LogService', 'Appraisal'])]
#[ORM\Column(type: 'text', nullable: true)]
private $description;
#[Groups(['LogService'])]
#[ORM\Column(type: 'datetime')]
private $createdAt;
#[Groups(['LogService'])]
#[ORM\ManyToOne(targetEntity: 'App\Entity\user')]
#[ORM\JoinColumn(nullable: false)]
private $createdBy;
#[ORM\ManyToOne(targetEntity: 'App\Entity\company', inversedBy: 'appraisalForms')]
#[ORM\JoinColumn(nullable: false)]
private $company;
#[Groups(['LogService', 'Appraisal'])]
#[ORM\Column(type: 'string', length: 32, nullable: true)]
private $scoreMin;
#[Groups(['LogService', 'Appraisal'])]
#[ORM\Column(type: 'string', length: 32, nullable: true)]
private $scoreMax;
#[ORM\OneToMany(targetEntity: 'App\Entity\AppraisalComment', mappedBy: 'form', orphanRemoval: false)]
private $appraisalComments;
#[ORM\Column(type: 'boolean')]
private $isHidden = false;
#[ORM\ManyToOne(targetEntity: office::class, inversedBy: 'appraisalForms')]
private $office;
#[ORM\Column(type: 'boolean', options: ['default' => true])]
private $useScore;
#[ORM\ManyToOne(targetEntity: Department::class, inversedBy: 'appraisalForms')]
private $department;
#[ORM\ManyToOne(targetEntity: Appraisal::class, inversedBy: 'appraisalForms')]
private $appraisal;
#[ORM\Column(type: 'string', length: 64, nullable: true)]
private $type;
#[ORM\ManyToOne(targetEntity: User::class)]
private $updatedBy;
#[ORM\Column(type: 'datetime_immutable', nullable: true)]
private $updatedAt;
#[Groups(['Appraisal'])]
#[ORM\ManyToOne(inversedBy: 'questionnaire')]
private ?AppraisalCategory $appraisalCategory = null;
#[ORM\Column(type: Types::SMALLINT, options: ['default' => 0])]
private ?int $customOrder = 0;
public function __construct()
{
$this->appraisalComments = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(?string $title): self
{
$this->title = $title;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getCreatedBy(): ?user
{
return $this->createdBy;
}
public function setCreatedBy(?user $createdBy): self
{
$this->createdBy = $createdBy;
return $this;
}
public function getCompany(): ?company
{
return $this->company;
}
public function setCompany(?company $company): self
{
$this->company = $company;
return $this;
}
public function getScoreMin(): ?string
{
return $this->scoreMin;
}
public function setScoreMin(?string $scoreMin): self
{
$this->scoreMin = $scoreMin;
return $this;
}
public function getScoreMax(): ?string
{
return $this->scoreMax;
}
public function setScoreMax(?string $scoreMax): self
{
$this->scoreMax = $scoreMax;
return $this;
}
/**
* @return Collection|AppraisalComment[]
*/
public function getAppraisalComments(): Collection
{
return $this->appraisalComments;
}
public function addAppraisalComment(AppraisalComment $appraisalComment): self
{
if (!$this->appraisalComments->contains($appraisalComment)) {
$this->appraisalComments[] = $appraisalComment;
$appraisalComment->setForm($this);
}
return $this;
}
public function removeAppraisalComment(AppraisalComment $appraisalComment): self
{
if ($this->appraisalComments->contains($appraisalComment)) {
$this->appraisalComments->removeElement($appraisalComment);
// set the owning side to null (unless already changed)
if ($appraisalComment->getForm() === $this) {
$appraisalComment->setForm(null);
}
}
return $this;
}
public function currentAppraisalComments($id){
$comments = [];
foreach($this->appraisalComments as $comment){
if($comment->getAppraisal()->getId() == $id){
array_push($comments, $comment);
}
};
return $comments;
}
public function appraisalCommentsByUser($uid){
$comments = [];
foreach($this->appraisalComments as $comment){
if($comment->getUser()->getId() == $uid){
array_push($comments, $comment);
}
};
return $comments;
}
public function appraisalCommentsByOwner($fid,$uid){
foreach($this->appraisalComments as $comment){
if($comment->getAppraisal()->getId() == $fid && $comment->getUser()->getId() == $uid){
return $comment;
}
};
return null;
}
public function getIsHidden(): ?bool
{
return $this->isHidden;
}
public function setIsHidden(bool $isHidden): self
{
$this->isHidden = $isHidden;
return $this;
}
public function getOffice(): ?office
{
return $this->office;
}
public function setOffice(?office $office): self
{
$this->office = $office;
return $this;
}
public function getUseScore(): ?bool
{
return $this->useScore;
}
public function setUseScore(bool $useScore): self
{
$this->useScore = $useScore;
return $this;
}
public function getDepartment(): ?Department
{
return $this->department;
}
public function setDepartment(?Department $department): self
{
$this->department = $department;
return $this;
}
public function getAppraisal(): ?Appraisal
{
return $this->appraisal;
}
public function setAppraisal(?Appraisal $appraisal): self
{
$this->appraisal = $appraisal;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(?string $type): self
{
$this->type = $type;
return $this;
}
public function getUpdatedBy(): ?User
{
return $this->updatedBy;
}
public function setUpdatedBy(?User $updatedBy): self
{
$this->updatedBy = $updatedBy;
return $this;
}
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updatedAt;
}
public function setUpdatedAt(\DateTimeImmutable $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getAppraisalCategory(): ?AppraisalCategory
{
return $this->appraisalCategory;
}
public function setAppraisalCategory(?AppraisalCategory $appraisalCategory): self
{
$this->appraisalCategory = $appraisalCategory;
return $this;
}
public function getCustomOrder(): ?int
{
return $this->customOrder;
}
public function setCustomOrder(int $customOrder): self
{
$this->customOrder = $customOrder;
return $this;
}
}