<?php
namespace App\Entity;
use App\Repository\TabletRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ORM\Entity(repositoryClass=TabletRepository::class)
*/
class Tablet
{
const STATUS_FREE = [
'value' => "FREE",
'text' => 'Laisva',
'color' => '#54c44f',
'description' => ''
];
const STATUS_NOT_WORKING = [
'value' => "NOT_WORKING",
'text' => 'Neveikianti',
'color' => '#54c44f',
'description' => ''
];
const STATUS_WAITING_SIGNATURE = [
'value' => "WAITING_SIGNATURE",
'text' => 'Laukiama parašo',
'color' => '#54c44f',
'description' => ''
];
const STATUS_RETURN_WAITING_SIGNATURE = [
'value' => "WAITING_RETURN_SIGNATURE",
'text' => 'Laukiama grąžinimo parašo',
'color' => '#54c44f',
'description' => ''
];
const STATUS_GIVEN = [
'value' => "GIVEN_SIGNED",
'text' => 'Išduota ir pasirašyta',
'color' => '#54c44f',
'description' => ''
];
const STATUS_RETURNED = [
'value' => "RETURNED",
'text' => 'Grąžinta',
'color' => '#54c44f',
'description' => ''
];
const STATUS_MUST_RETURN = [
'value' => "MUST_RETURN",
'text' => 'Turi grąžinti planšetę',
'color' => '#54c44f',
'description' => ''
];
const TABLET_STATUSES = [self::STATUS_FREE, self::STATUS_WAITING_SIGNATURE, self::STATUS_RETURN_WAITING_SIGNATURE, self::STATUS_RETURNED, self::STATUS_GIVEN, self::STATUS_NOT_WORKING, self::STATUS_MUST_RETURN];
const TABLET_STATUSES_REVERSED = [
self::STATUS_FREE['value'] => self::STATUS_FREE['text'],
self::STATUS_NOT_WORKING['value'] => self::STATUS_NOT_WORKING['text'],
self::STATUS_WAITING_SIGNATURE['value'] => self::STATUS_WAITING_SIGNATURE['text'],
self::STATUS_RETURN_WAITING_SIGNATURE['value'] => self::STATUS_RETURN_WAITING_SIGNATURE['text'],
self::STATUS_RETURNED['value'] => self::STATUS_RETURNED['text'],
self::STATUS_GIVEN['value'] => self::STATUS_GIVEN['text'],
self::STATUS_MUST_RETURN['value'] => self::STATUS_MUST_RETURN['text'],
];
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({"TabletList"})
*/
private $id;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"TabletList"})
*/
private $number;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"TabletList"})
*/
private $status;
/**
* @ORM\ManyToOne(targetEntity=Teacher::class, inversedBy="tablets")
* @Groups({"TabletList"})
*/
private $teacher;
/**
* @ORM\OneToMany(targetEntity=TeacherTablet::class, mappedBy="tablet")
* @Groups({"TabletList"})
*/
private $teacherTablets;
/**
* @ORM\Column(type="text", nullable=true)
* @Groups({"TabletList"})
*/
private $comment;
public function __construct()
{
$this->teacherTablets = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getNumber(): ?string
{
return $this->number;
}
public function setNumber(?string $number): self
{
$this->number = $number;
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(?string $status): self
{
$this->status = $status;
return $this;
}
public function getTeacher(): ?Teacher
{
return $this->teacher;
}
public function setTeacher(?Teacher $teacher): self
{
$this->teacher = $teacher;
return $this;
}
/**
* @return Collection<int, TeacherTablet>
*/
public function getTeacherTablets(): Collection
{
return $this->teacherTablets;
}
public function addTeacherTablet(TeacherTablet $teacherTablet): self
{
if (!$this->teacherTablets->contains($teacherTablet)) {
$this->teacherTablets[] = $teacherTablet;
$teacherTablet->setTablet($this);
}
return $this;
}
public function removeTeacherTablet(TeacherTablet $teacherTablet): self
{
if ($this->teacherTablets->removeElement($teacherTablet)) {
// set the owning side to null (unless already changed)
if ($teacherTablet->getTablet() === $this) {
$teacherTablet->setTablet(null);
}
}
return $this;
}
public function __toString(): string
{
return "{$this->id} - {$this->number}";
}
public function getComment(): ?string
{
return $this->comment;
}
public function setComment(?string $comment): self
{
$this->comment = $comment;
return $this;
}
}