<?php
namespace App\Entity;
use App\Repository\ProjectStakeholdersRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Doctrine\ORM\Mapping\UniqueConstraint;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ORM\Entity(repositoryClass=ProjectStakeholdersRepository::class)
* UniqueEntity(
* fields={"customer", "project", "start_at"},
* errorPath="customer",
* message="This customer already assigned to this project"
* )
*
* ORM\Table("project_stakeholders",
* uniqueConstraints={UniqueConstraint(name="project_stakeholders_unique", columns={"customer_id", "project_id", "start_at", "end_at"}),
* })
* @ORM\Table(name="project_stakeholders", uniqueConstraints={
* @UniqueConstraint(name="project_stakeholders_unique", columns={"customer_id", "project_id", "start_at", "end_at"})},
* options={"comment": "Customer joined Project's table"}
* )
* ORM\Table(name="project_stakeholders", options={"comment": "Customer joined Project's table"})
* @ORM\HasLifecycleCallbacks
*
*/
class ProjectStakeholders
{
/**
* IN Worker/Projects Component, Selectable Stakeholder Projects decide worker in stakeholder project or not
* This is a dynamic prop managed from
* CustomerController / fetchCustomerProjects
*/
/**
* @Groups({
* "worker.manage.selectable.stakeholder.projects"
* })
*/
// private $is_in_included_to_project;
private $is_worker_included_to_project;
public function getIsWorkerIncludedToProject(){ return $this->is_worker_included_to_project;}
public function setIsWorkerIncludedToProject(string $is_in_included_to_project): self { $this->is_worker_included_to_project = $is_in_included_to_project; return $this;}
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({"customer.joined.projects",
* "customer.selected.project",
* "worker.join.to.project",
* "worker.manage.joined.projects",
* "worker.manage.selectable.stakeholder.projects",
* "selected.customer.project.for.worker",
* "worker.manage.selected.worker.in.project",
* "timesheet.for.customer"
* })
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=Customer::class, inversedBy="project_stakeholders")
* @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
*/
private $customer;
/**
* @ORM\ManyToOne(targetEntity=Projects::class, inversedBy="stakeholders")
* @ORM\JoinColumn(nullable=true, onDelete="CASCADE")
* @Groups({"customer.joined.projects",
* "customer.selected.project",
* "worker.join.to.project",
* "worker.manage.joined.projects",
* "worker.manage.selectable.stakeholder.projects",
* "worker.manage.selected.worker.in.project",
* "selected.customer.project.for.worker",
* "worker.manage.base.timesheet.payments",
* "timesheet.for.customer"
* })
*/
private $project;
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
* @Groups({
* "customer.joined.projects",
* "customer.selected.project",
* "worker.manage.joined.projects",
* "selected.customer.project.for.worker",
* "worker.manage.selected.worker.in.project"
* })
*/
private $start_at;
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
* @Groups({
* "customer.joined.projects",
* "customer.selected.project",
* "worker.manage.joined.projects",
* "selected.customer.project.for.worker",
* "worker.manage.selected.worker.in.project"
* })
*/
private $end_at;
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
*/
private $created_at;
/**
* @ORM\OneToMany(targetEntity=WorkerInProject::class, mappedBy="project", cascade={"persist", "remove"})
* @ORM\JoinColumn(onDelete="CASCADE")
* @Groups({
* "customer.manage.base",
* "customer.selected.project",
* "timesheet.for.stakeholder",
* "timesheet.for.customer"
* })
*/
/// TODO In react for frontend workerInProjects doesn't use so use worker_in_projects
/// Check This words in app
private $worker_in_projects;
/**
* ----------------------------------------------------------------------------------------------------------------
* This is custom column not associated to table
* Event Listener Prop
* This prop Update during event.listener
* @Groups({
* "customer.joined.projects",
* "customer.selected.project",
* "worker.manage.joined.projects",
* "worker.manage.selectable.stakeholder.projects",
* "selected.customer.project.for.worker",
* "worker.manage.selected.worker.in.project"
* })
*/
private $status;
/**
* Event Listener Prop
* This prop Update during event.listener
* @param array $status
*/
public function setStatus( array $status ): void {
$this->status = $status;
}
/** * Event Listener Prop */
public function getStatus(){
return $this->status;
}
// ----------------------------------------------------------------------------------------------------------------
/**
* @ORM\ManyToMany(targetEntity=Qualification::class, inversedBy="projectStakeholders", cascade={"persist"})
* @ORM\JoinColumn(onDelete="CASCADE")
* @Groups({
* "customer.joined.projects.depended.qualifications",
* "selected.customer.project.for.worker",
* "worker.manage.selected.worker.in.project"
* })
*/
private $dependent_qualifications;
/**
* @ORM\ManyToMany(targetEntity=Certificates::class, inversedBy="projectStakeholders", cascade={"persist"}, fetch="EXTRA_LAZY")
* @ORM\JoinColumn(onDelete="CASCADE")
* @Groups({
* "customer.joined.projects.depended.certificates",
* "customer.joined.projects.depended.certificates.eligibility",
* "worker.manage.selected.worker.in.project",
* "selected.customer.project.for.worker"
* })
*/
private $dependent_certificates;
/**
* @ORM\OneToMany(targetEntity=ProjectStakeholdersTimesheet::class, mappedBy="project_stakeholder", cascade={"persist", "remove"} )
* @ORM\JoinColumn(onDelete="CASCADE")
*/
private $projectStakeholdersTimesheets;
/**
* @ORM\OneToMany(targetEntity=WorkerTimesheetPayments::class, mappedBy="project_stakeholder")
*/
private $workerTimesheetPayments;
public function __construct()
{
$this->workerInProjects = new ArrayCollection();
$this->dependent_qualifications = new ArrayCollection();
$this->dependent_certificates = new ArrayCollection();
// $this->workerTimesheets = new ArrayCollection();
$this->projectStakeholdersTimesheets = new ArrayCollection();
$this->workerTimesheetPayments = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getCustomer(): ?Customer
{
return $this->customer;
}
public function setCustomer(?Customer $customer): self
{
$this->customer = $customer;
return $this;
}
public function getProject(): ?Projects
{
return $this->project;
}
public function setProject(?Projects $project): self
{
$this->project = $project;
return $this;
}
public function getStartAt(): ?\DateTimeImmutable
{
return $this->start_at;
}
public function setStartAt(?\DateTimeImmutable $start_at): self
{
$this->start_at = $start_at;
return $this;
}
public function getEndAt(): ?\DateTimeImmutable
{
return $this->end_at;
}
public function setEndAt(?\DateTimeImmutable $end_at): self
{
$this->end_at = $end_at;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->created_at;
}
public function setCreatedAt(?\DateTimeImmutable $created_at): self
{
$this->created_at = $created_at;
return $this;
}
/**
* @return Collection<int, WorkerInProject>
*/
public function getWorkerInProjects(): Collection
{
return $this->worker_in_projects;
}
public function addWorkerInProject(WorkerInProject $workerInProject): self
{
if (!$this->worker_in_projects->contains($workerInProject)) {
$this->worker_in_projects[] = $workerInProject;
$workerInProject->setProject($this);
}
return $this;
}
public function removeWorkerInProject(WorkerInProject $workerInProject): self
{
if ($this->worker_in_projects->removeElement($workerInProject)) {
// set the owning side to null (unless already changed)
if ($workerInProject->getProject() === $this) {
$workerInProject->setProject(null);
}
}
return $this;
}
/**
* @return Collection<int, Qualification>
*/
public function getDependentQualifications(): Collection
{
return $this->dependent_qualifications;
}
public function addDependentQualification(Qualification $dependentQualification): self
{
if (!$this->dependent_qualifications->contains($dependentQualification)) {
$this->dependent_qualifications[] = $dependentQualification;
}
return $this;
}
public function removeDependentQualification(Qualification $dependentQualification): self
{
$this->dependent_qualifications->removeElement($dependentQualification);
return $this;
}
/**
* @return Collection<int, Certificates>
*/
public function getDependentCertificates(): Collection
{
return $this->dependent_certificates;
}
public function addDependentCertificate(Certificates $dependentCertificate): self
{
if (!$this->dependent_certificates->contains($dependentCertificate)) {
$this->dependent_certificates[] = $dependentCertificate;
}
return $this;
}
public function removeDependentCertificate(Certificates $dependentCertificate): self
{
$this->dependent_certificates->removeElement($dependentCertificate);
return $this;
}
// /**
// * @return Collection<int, WorkerTimesheet>
// */
// public function getWorkerTimesheets(): Collection
// {
// return $this->workerTimesheets;
// }
//
// public function addWorkerTimesheet(WorkerTimesheet $workerTimesheet): self
// {
// if (!$this->workerTimesheets->contains($workerTimesheet)) {
// $this->workerTimesheets[] = $workerTimesheet;
// $workerTimesheet->setProjectStakeholder($this);
// }
//
// return $this;
// }
//
// public function removeWorkerTimesheet(WorkerTimesheet $workerTimesheet): self
// {
// if ($this->workerTimesheets->removeElement($workerTimesheet)) {
// // set the owning side to null (unless already changed)
// if ($workerTimesheet->getProjectStakeholder() === $this) {
// $workerTimesheet->setProjectStakeholder(null);
// }
// }
//
// return $this;
// }
/**
* @return Collection<int, ProjectStakeholdersTimesheet>
*/
public function getProjectStakeholdersTimesheets(): Collection
{
return $this->projectStakeholdersTimesheets;
}
public function addProjectStakeholdersTimesheet(ProjectStakeholdersTimesheet $projectStakeholdersTimesheet): self
{
if (!$this->projectStakeholdersTimesheets->contains($projectStakeholdersTimesheet)) {
$this->projectStakeholdersTimesheets[] = $projectStakeholdersTimesheet;
$projectStakeholdersTimesheet->setProjectStakeholder($this);
}
return $this;
}
public function removeProjectStakeholdersTimesheet(ProjectStakeholdersTimesheet $projectStakeholdersTimesheet): self
{
if ($this->projectStakeholdersTimesheets->removeElement($projectStakeholdersTimesheet)) {
// set the owning side to null (unless already changed)
if ($projectStakeholdersTimesheet->getProjectStakeholder() === $this) {
$projectStakeholdersTimesheet->setProjectStakeholder(null);
}
}
return $this;
}
/**
* @return Collection<int, WorkerTimesheetPayments>
*/
public function getWorkerTimesheetPayments(): Collection
{
return $this->workerTimesheetPayments;
}
public function addWorkerTimesheetPayment(WorkerTimesheetPayments $workerTimesheetPayment): self
{
if (!$this->workerTimesheetPayments->contains($workerTimesheetPayment)) {
$this->workerTimesheetPayments[] = $workerTimesheetPayment;
$workerTimesheetPayment->setProjectStakeholder($this);
}
return $this;
}
public function removeWorkerTimesheetPayment(WorkerTimesheetPayments $workerTimesheetPayment): self
{
if ($this->workerTimesheetPayments->removeElement($workerTimesheetPayment)) {
// set the owning side to null (unless already changed)
if ($workerTimesheetPayment->getProjectStakeholder() === $this) {
$workerTimesheetPayment->setProjectStakeholder(null);
}
}
return $this;
}
}