<?php
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use App\Repository\JobsRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\MaxDepth;
use ApiPlatform\Core\Annotation\ApiProperty;
#[ORM\Entity(repositoryClass: JobsRepository::class)]
#[ApiResource(
normalizationContext: ['groups' => ['job:read']],
denormalizationContext: ['groups' => ['job:write']],
order: ['id' => 'DESC'],
)]
#[ApiFilter(SearchFilter::class, properties: [
'name' => 'ipartial',
'code1c' => 'exact',
'email' => 'exact',
'status' => 'exact',
'account.user.id' => 'exact',
'account.id' => 'exact',
'account.name' => 'ipartial',
'factory.id' => 'exact',
])]
class Jobs
{
#[Groups(['job:read', 'job:write', 'worker:read', 'worker:write', 'account_worker:read', 'account:read', 'read', 'account:write' ])]
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[Groups(['job:read', 'job:write', 'worker:read', 'worker:write', 'account_worker:read', 'account:read', 'read', 'account:write' ])]
#[ORM\Column(length: 255, nullable: true)]
private ?string $name = null;
#[Groups(['job:read', 'job:write', 'worker:read', 'worker:write'])]
#[ORM\ManyToOne(inversedBy: 'jobs')]
private ?Accounts $account = null;
#[Groups(['job:read', 'job:write', 'worker:read', 'worker:write', 'account_worker:read', 'account:read', 'read', 'account:write' ])]
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $description = null;
#[Groups(['job:read', 'job:write', 'worker:read', 'worker:write', 'account_worker:read', 'account:read', 'read', 'account:write' ])]
#[ORM\Column(length: 100, nullable: true)]
private ?string $code1c = null;
#[Groups(['job:read', 'job:write', 'worker:read', 'worker:write', 'account_worker:read', 'account:read', 'read', 'account:write' ])]
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $dateEntered = null;
#[Groups(['job:read', 'job:write', 'worker:read', 'worker:write', 'account_worker:read', 'account:read', 'read', 'account:write' ])]
#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
private ?\DateTimeInterface $date = null;
#[Groups(['job:read', 'job:write', 'worker:read', 'worker:write', 'account_worker:read', 'account:read', 'read', 'account:write' ])]
#[ORM\OneToMany(mappedBy: 'job', targetEntity: JobWorker::class)]
private Collection $jobWorkers;
#[Groups(['job:read', 'job:write', 'worker:read', 'worker:write', 'account_worker:read', 'account:read', 'read', 'account:write' ])]
#[ORM\OneToMany(mappedBy: 'job', targetEntity: MediaObject::class)]
private Collection $mediaObjects;
#[Groups(['job:read', 'job:write', 'worker:read', 'worker:write', 'account_worker:read', 'account:read', 'read', 'account:write' ])]
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $dateStart = null;
#[Groups(['job:read', 'job:write', 'worker:read', 'worker:write', 'account_worker:read', 'account:read', 'read', 'account:write' ])]
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $dateEnd = null;
// #[Groups(['job:read', 'job:write', 'worker:read', 'worker:write', 'account_worker:read', 'account:read', 'read', 'account:write' ])]
// #[ORM\ManyToMany(targetEntity: JobsLib::class, mappedBy: 'jobs')]
// private Collection $jobsLibs;
#[Groups(['job:read', 'job:write', 'worker:read', 'worker:write', 'account_worker:read', 'account:read', 'read', 'account:write' ])]
#[ORM\ManyToMany(targetEntity: AccountJobsList::class, inversedBy: 'jobs')]
private Collection $AccountJobsList;
#[Groups(['job:read', 'job:write', 'worker:read', 'worker:write', 'account_worker:read', 'account:read', 'read', 'account:write' ])]
#[ORM\Column(length: 100, nullable: true)]
private ?string $status = null;
#[Groups(['job:read', 'job:write', 'worker:read', 'worker:write', 'account_worker:read', 'account:read', 'read', 'account:write' ])]
#[ORM\ManyToOne(inversedBy: 'commandment_jobs', cascade:['persist'])]
private ?MediaObject $commandment = null;
#[Groups(['job:read', 'job:write', 'worker:read', 'worker:write', 'account_worker:read', 'account:read', 'read', 'account:write' ])]
#[ORM\ManyToOne(inversedBy: 'graph_jobs', cascade:['persist'])]
private ?MediaObject $graph = null;
#[Groups(['job:read', 'job:write', 'worker:read', 'worker:write', 'account_worker:read', 'account:read', 'read', 'account:write' ])]
#[ORM\ManyToOne(inversedBy: 'protocole_jobs', cascade:['persist']
)]
private ?MediaObject $protocole = null;
#[Groups(['job:read', 'job:write', 'worker:read', 'worker:write', 'account_worker:read', 'account:read', 'read', 'account:write' ])]
#[ORM\ManyToOne(inversedBy: 'jobs')]
private ?Engineer $engineer = null;
#[Groups(['job:read', 'job:write', 'worker:read', 'worker:write', 'account_worker:read', 'account:read', 'read', 'account:write' ])]
#[ORM\ManyToOne(inversedBy: 'jobs')]
private ?Factory $factory = null;
#[Groups(['job:read', 'job:write', 'worker:read', 'worker:write', 'account_worker:read', 'account:read', 'read', 'account:write' ])]
#[ORM\Column(length: 255, nullable: true)]
private ?string $comentar = null;
public function __construct()
{
$this->jobWorkers = new ArrayCollection();
$this->mediaObjects = new ArrayCollection();
// $this->jobsLibs = new ArrayCollection();
$this->AccountJobsList = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
public function getAccount(): ?Accounts
{
return $this->account;
}
public function setAccount(?Accounts $account): self
{
$this->account = $account;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getCode1c(): ?string
{
return $this->code1c;
}
public function setCode1c(?string $code1c): self
{
$this->code1c = $code1c;
return $this;
}
public function getDateEntered(): ?\DateTimeInterface
{
return $this->dateEntered;
}
public function setDateEntered(?\DateTimeInterface $dateEntered): self
{
$this->dateEntered = $dateEntered;
return $this;
}
public function getDate(): ?\DateTimeInterface
{
return $this->date;
}
public function setDate(?\DateTimeInterface $date): self
{
$this->date = $date;
return $this;
}
/**
* @return Collection<int, JobWorker>
*/
public function getJobWorkers(): Collection
{
return $this->jobWorkers;
}
public function addJobWorker(JobWorker $jobWorker): self
{
if (!$this->jobWorkers->contains($jobWorker)) {
$this->jobWorkers->add($jobWorker);
$jobWorker->setJob($this);
}
return $this;
}
public function removeJobWorker(JobWorker $jobWorker): self
{
if ($this->jobWorkers->removeElement($jobWorker)) {
// set the owning side to null (unless already changed)
if ($jobWorker->getJob() === $this) {
$jobWorker->setJob(null);
}
}
return $this;
}
/**
* @return Collection<int, MediaObject>
*/
public function getMediaObjects(): Collection
{
return $this->mediaObjects;
}
public function addMediaObject(MediaObject $mediaObject): self
{
if (!$this->mediaObjects->contains($mediaObject)) {
$this->mediaObjects->add($mediaObject);
$mediaObject->setJob($this);
}
return $this;
}
public function removeMediaObject(MediaObject $mediaObject): self
{
if ($this->mediaObjects->removeElement($mediaObject)) {
// set the owning side to null (unless already changed)
if ($mediaObject->getJob() === $this) {
$mediaObject->setJob(null);
}
}
return $this;
}
public function getDateStart(): ?\DateTimeInterface
{
return $this->dateStart;
}
public function setDateStart(?\DateTimeInterface $dateStart): self
{
$this->dateStart = $dateStart;
return $this;
}
public function getDateEnd(): ?\DateTimeInterface
{
return $this->dateEnd;
}
public function setDateEnd(?\DateTimeInterface $dateEnd): self
{
$this->dateEnd = $dateEnd;
return $this;
}
// /**
// * @return Collection<int, JobsLib>
// */
// public function getJobsLibs(): Collection
// {
// return $this->jobsLibs;
// }
// public function addJobsLib(JobsLib $jobsLib): self
// {
// if (!$this->jobsLibs->contains($jobsLib)) {
// $this->jobsLibs->add($jobsLib);
// $jobsLib->addJob($this);
// }
// return $this;
// }
// public function removeJobsLib(JobsLib $jobsLib): self
// {
// if ($this->jobsLibs->removeElement($jobsLib)) {
// $jobsLib->removeJob($this);
// }
// return $this;
// }
/**
* @return Collection<int, AccountJobsList>
*/
public function getAccountJobsList(): Collection
{
return $this->AccountJobsList;
}
public function addAccountJobsList(AccountJobsList $accountJobsList): self
{
if (!$this->AccountJobsList->contains($accountJobsList)) {
$this->AccountJobsList->add($accountJobsList);
}
return $this;
}
public function removeAccountJobsList(AccountJobsList $accountJobsList): self
{
$this->AccountJobsList->removeElement($accountJobsList);
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(?string $status): self
{
$this->status = $status;
return $this;
}
public function getCommandment(): ?MediaObject
{
return $this->commandment;
}
public function setCommandment(?MediaObject $commandment): self
{
$this->commandment = $commandment;
return $this;
}
public function getGraph(): ?MediaObject
{
return $this->graph;
}
public function setGraph(?MediaObject $graph): self
{
$this->graph = $graph;
return $this;
}
public function getProtocole(): ?MediaObject
{
return $this->protocole;
}
public function setProtocole(?MediaObject $protocole): self
{
$this->protocole = $protocole;
return $this;
}
public function getEngineer(): ?Engineer
{
return $this->engineer;
}
public function setEngineer(?Engineer $engineer): self
{
$this->engineer = $engineer;
return $this;
}
public function getFactory(): ?Factory
{
return $this->factory;
}
public function setFactory(?Factory $factory): self
{
$this->factory = $factory;
return $this;
}
public function getComentar(): ?string
{
return $this->comentar;
}
public function setComentar(string $comentar): self
{
$this->comentar = $comentar;
return $this;
}
}