<?php
namespace App\Entity;
use App\Repository\CustomerRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\PersistentCollection;
use Gedmo\Mapping\Annotation as Gedmo;
use Monolog\DateTimeImmutable;
use function PHPUnit\Framework\objectEquals;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\MaxDepth;
use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Serializer\Annotation\Ignore;
/**
* @ORM\Entity(repositoryClass=CustomerRepository::class)
*/
class Customer
{
// // Certificate Document Subscriber
// // ________________________________________________________________________________________________________
//
// private $serviceArgumentFileDirs = [];
//
// # private $documentManagerController;
// private function getServiceArgumentFileDirs(): array { return $this->serviceArgumentFileDirs; }
//
// /**
// * @param $serviceArgumentFileFetchDir
// * Manage from EventSubscriber
// */
// public function setServiceArgumentFileDirs( $serviceArgumentFileFetchDir ): void {
// $this->serviceArgumentFileDirs = [
// "fetch" => $serviceArgumentFileFetchDir
// ];
// }
// // ________________________________________________________________________________________________________
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({
* "customer.list.base",
* "customer.manage.base",
* "worker.actually.activity",
* "timesheet.for.stakeholder",
* "customer.selected.project",
*
* "customer.base",
* "customer.core", "customer@core"
* })
*/
private $id;
/**
* @ORM\Column(type="string", length=128)
* @Groups({
* "customer.list.base",
* "customer.manage.base",
* "worker.actually.activity",
* "timesheet.for.stakeholder",
* "customer.selected.project",
*
* "customer.base",
* "customer.core", "customer@core"
* })
*/
private $company;
/**
* @ORM\Column(type="string", unique=true, nullable=true)
* @Gedmo\Slug(fields={"company"})
* @Groups({
* "customer.list.base",
* "customer.manage.base",
* "worker.actually.activity",
* "customer.selected.project"
* })
*/
private $slug;
/**
* @ORM\ManyToOne(targetEntity=Countries::class)
* @Groups({"customer.list.base", "customer.manage.base"})
*/
private $country;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"customer.list.base", "customer.manage.base"})
*/
private $tel;
/**
* @ORM\Column(type="text", nullable=true)
* @Groups({"customer.list.base", "customer.manage.base"})
*/
private $company_logo;
/**
* ____________________________________________________________________________________________________
* Event Listener Prop
* This prop Update during event.listener
* @Groups({"customer.list.base", "customer.manage.base"})
*/
private $logo_image_full_path;
/**
* Event Listener Prop
* This prop Update during event.listener
* @param string $logo_image_full_path
* @return Customer|null
*/
public function setLogoImageFullPath( string $logo_image_full_path ): ?self {
$this->logo_image_full_path = $logo_image_full_path; // $this->getServiceArgumentFileDirs()['fetch'] . DIRECTORY_SEPARATOR . $this->getCompanyLogo();
return $this;
}
/**
* Event Listener Prop
*/
public function getLogoImageFullPath(): ?string { /* $this->getServiceArgumentFileDirs()['fetch'] . DIRECTORY_SEPARATOR . $this->getCompanyLogo(); */
return $this->logo_image_full_path;
}
// ____________________________________________________________________________________________________
/**
* @ORM\OneToMany(targetEntity=ProjectStakeholders::class, mappedBy="customer", fetch="EXTRA_LAZY")
* @ORM\OrderBy({"id":"DESC"})
* @ORM\JoinColumn(onDelete="CASCADE")
* @Groups({
* "customer.joined.projects",
* "worker.join.to.project",
* "worker.manage.selectable.stakeholder.projects",
* "timesheet.for.customer"
* })
*/
private $project_stakeholders;
/**
* @ORM\OneToMany(targetEntity=WorkerActivities::class, mappedBy="customer", fetch="EXTRA_LAZY")
* @Groups({"customer.smart.active.employees"})
* @ORM\JoinColumn(onDelete="CASCADE")
*/
private $worker_activities;
/**
* Ignore()
* @ORM\OneToMany(targetEntity=CustomerCertificates::class, mappedBy="customer", cascade={"persist", "remove"}, fetch="EXTRA_LAZY")
* @Groups({"customer.manage.base"})
* @ORM\JoinColumn(onDelete="CASCADE")
*/
private $customer_certificates;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"customer.list.base", "customer.manage.base"})
*/
private $city;
/**
* @ORM\OneToOne(targetEntity=Administrative::class, mappedBy="paired_customer", cascade={"persist", "remove"})
* @Groups({"customer.manage.base", "customer.list.base", "worker.actually.activity"})
*/
private $administrative;
public function __construct()
{
$this->project_stakeholders = new ArrayCollection();
$this->worker_activities = new ArrayCollection();
$this->customer_certificates = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getCompany(): ?string
{
return $this->company;
}
public function setCompany(string $company): self
{
$this->company = $company;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(?string $slug): self
{
$this->slug = $slug;
return $this;
}
public function getCountry(): ?Countries
{
return $this->country;
}
public function setCountry(?Countries $country): self
{
$this->country = $country;
return $this;
}
public function getTel(): ?string
{
return $this->tel;
}
public function setTel(string $tel): self
{
$this->tel = $tel;
return $this;
}
public function getCompanyLogo(): ?string
{
return $this->company_logo;
}
public function setCompanyLogo(?string $company_logo): self
{
$this->company_logo = $company_logo;
return $this;
}
/**
* @return Collection<int, ProjectStakeholders>
*/
public function getProjectStakeholders(): Collection
{
return $this->project_stakeholders;
}
/**
* @return Collection<int, WorkerActivities>
*/
public function getWorkerActivities(): Collection
{
return new ArrayCollection($this->worker_activities->filter( function ( /**@var $workerActivity WorkerActivities*/ $workerActivity ){
return $workerActivity->getEntryAt() && ( is_null( $workerActivity->getExitAt() ) || $workerActivity->getExitAt() > new DateTimeImmutable('now')) ;
})->getValues());
}
public function getAllWorkers(): Collection
{
return $this->worker_activities;
}
public function addWorkerActivity(WorkerActivities $workerActivity): self
{
if (!$this->worker_activities->contains($workerActivity)) {
$this->worker_activities[] = $workerActivity;
$workerActivity->setCustomer($this);
}
return $this;
}
public function removeWorkerActivity(WorkerActivities $workerActivity): self
{
if ($this->worker_activities->removeElement($workerActivity)) {
// set the owning side to null (unless already changed)
if ($workerActivity->getCustomer() === $this) {
$workerActivity->setCustomer(null);
}
}
return $this;
}
/**
* @return Collection<int, CustomerCertificates>
*/
public function getCustomerCertificates(): Collection
{
return $this->customer_certificates;
}
public function addCustomerCertificate(CustomerCertificates $customerCertificate): self
{
if (!$this->customer_certificates->contains($customerCertificate)) {
$this->customer_certificates[] = $customerCertificate;
$customerCertificate->setCustomer($this);
}
return $this;
}
public function removeCustomerCertificate(CustomerCertificates $customerCertificate): self
{
if ($this->customer_certificates->removeElement($customerCertificate)) {
// set the owning side to null (unless already changed)
if ($customerCertificate->getCustomer() === $this) {
$customerCertificate->setCustomer(null);
}
}
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(?string $city): self
{
$this->city = $city;
return $this;
}
public function getAdministrative(): ?Administrative
{
return $this->administrative;
}
public function setAdministrative(Administrative $administrative): self
{
// set the owning side of the relation if necessary
if ($administrative->getPairedCustomer() !== $this) {
$administrative->setPairedCustomer($this);
}
$this->administrative = $administrative;
return $this;
}
}