<?php
namespace App\Entity\Slave;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="eposm_s_supplier")
* @ORM\Entity(repositoryClass="App\Repository\Slave\SupplierRepository")
*/
class Supplier
{
public function __toString(){
return $this->getName();
}
public function getCanDelete(){
if($this->idSupplier != null) return false;
if(sizeof($this->products) > 0) return false;
if(sizeof($this->tickets) > 0) return false;
if(sizeof($this->operations) > 0) return false;
if(sizeof($this->models) > 0) return false;
return true;
}
public function getUAVOperation(){
foreach($this->getOperations() as $operation){
if($operation->isUav()){
return $operation;
break;
}
}
}
public function displayTicketEmails()
{
$html = '<table class="table table-sm b_none m_b_none font_14"><tbody>';
foreach($this->ticketEmails as $te){
$html.= '<tr><td>'.$te->getValue().'</td></tr>';
}
$html.= '</tbody></table>';
return $html;
}
public function getOperationMaintenance()
{
foreach($this->getOperations() as $operation){
if($operation->getGroup()->isMaintenance())
return $operation;
}
}
/**
* @ORM\Column(name="id", type="bigint")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(name="name", type="string", length=191)
*/
protected $name;
/**
* @ORM\Column(name="slug", type="string", length=191)
*/
protected $slug;
/**
* @ORM\Column(name="amount_regenerate", type="decimal", scale=2, nullable=true)
*/
protected $amountRegenerate;
/**
* @ORM\Column(name="id_supplier", type="bigint", nullable=true)
*/
protected $idSupplier;
/**
* @ORM\Column(name="operation_mapping", type="string", length=191, nullable=true)
*/
protected $operationMapping;
/**
* @ORM\Column(name="amount_ticket_extra_hour", type="decimal", scale=2, nullable=true)
*/
protected $amountTicketExtraHour;
// OneToMany
/**
* @ORM\OneToMany(targetEntity="App\Entity\Slave\Ticket", mappedBy="supplier")
*/
private $tickets;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Slave\Operation", mappedBy="supplier")
*/
private $operations;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Slave\JoinTableUserSupplier", mappedBy="supplier")
*/
private $users;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Slave\ProductTransfer", mappedBy="supplier")
*/
private $transfers;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Slave\SupplierTicketEmail", mappedBy="supplier")
*/
private $ticketEmails;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Slave\JoinTableProductModelSupplier", mappedBy="supplier")
*/
private $models;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Slave\ProductRegenerated", mappedBy="supplier")
*/
private $regeneratedProducts;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Slave\TicketColumnValue", mappedBy="supplier")
*/
private $ticketColumnValues;
//
// ManyToMany
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Slave\Product", mappedBy="suppliers")
*/
private $products;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Slave\User", mappedBy="autoAssignSuppliers")
*/
private $autoAssignUsers;
public function __construct()
{
$this->tickets = new ArrayCollection();
$this->operations = new ArrayCollection();
$this->users = new ArrayCollection();
$this->transfers = new ArrayCollection();
$this->ticketEmails = new ArrayCollection();
$this->models = new ArrayCollection();
$this->regeneratedProducts = new ArrayCollection();
$this->ticketColumnValues = new ArrayCollection();
$this->products = new ArrayCollection();
$this->autoAssignUsers = new ArrayCollection();
}
//
public function getId(): ?string
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): static
{
$this->slug = $slug;
return $this;
}
public function getAmountRegenerate(): ?string
{
return $this->amountRegenerate;
}
public function setAmountRegenerate(?string $amountRegenerate): static
{
$this->amountRegenerate = $amountRegenerate;
return $this;
}
public function getIdSupplier(): ?string
{
return $this->idSupplier;
}
public function setIdSupplier(?string $idSupplier): static
{
$this->idSupplier = $idSupplier;
return $this;
}
public function getOperationMapping(): ?string
{
return $this->operationMapping;
}
public function setOperationMapping(?string $operationMapping): static
{
$this->operationMapping = $operationMapping;
return $this;
}
public function getAmountTicketExtraHour(): ?string
{
return $this->amountTicketExtraHour;
}
public function setAmountTicketExtraHour(?string $amountTicketExtraHour): static
{
$this->amountTicketExtraHour = $amountTicketExtraHour;
return $this;
}
/**
* @return Collection<int, Ticket>
*/
public function getTickets(): Collection
{
return $this->tickets;
}
public function addTicket(Ticket $ticket): static
{
if (!$this->tickets->contains($ticket)) {
$this->tickets->add($ticket);
$ticket->setSupplier($this);
}
return $this;
}
public function removeTicket(Ticket $ticket): static
{
if ($this->tickets->removeElement($ticket)) {
// set the owning side to null (unless already changed)
if ($ticket->getSupplier() === $this) {
$ticket->setSupplier(null);
}
}
return $this;
}
/**
* @return Collection<int, Operation>
*/
public function getOperations(): Collection
{
return $this->operations;
}
public function addOperation(Operation $operation): static
{
if (!$this->operations->contains($operation)) {
$this->operations->add($operation);
$operation->setSupplier($this);
}
return $this;
}
public function removeOperation(Operation $operation): static
{
if ($this->operations->removeElement($operation)) {
// set the owning side to null (unless already changed)
if ($operation->getSupplier() === $this) {
$operation->setSupplier(null);
}
}
return $this;
}
/**
* @return Collection<int, JoinTableUserSupplier>
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(JoinTableUserSupplier $user): static
{
if (!$this->users->contains($user)) {
$this->users->add($user);
$user->setSupplier($this);
}
return $this;
}
public function removeUser(JoinTableUserSupplier $user): static
{
if ($this->users->removeElement($user)) {
// set the owning side to null (unless already changed)
if ($user->getSupplier() === $this) {
$user->setSupplier(null);
}
}
return $this;
}
/**
* @return Collection<int, ProductTransfer>
*/
public function getTransfers(): Collection
{
return $this->transfers;
}
public function addTransfer(ProductTransfer $transfer): static
{
if (!$this->transfers->contains($transfer)) {
$this->transfers->add($transfer);
$transfer->setSupplier($this);
}
return $this;
}
public function removeTransfer(ProductTransfer $transfer): static
{
if ($this->transfers->removeElement($transfer)) {
// set the owning side to null (unless already changed)
if ($transfer->getSupplier() === $this) {
$transfer->setSupplier(null);
}
}
return $this;
}
/**
* @return Collection<int, SupplierTicketEmail>
*/
public function getTicketEmails(): Collection
{
return $this->ticketEmails;
}
public function addTicketEmail(SupplierTicketEmail $ticketEmail): static
{
if (!$this->ticketEmails->contains($ticketEmail)) {
$this->ticketEmails->add($ticketEmail);
$ticketEmail->setSupplier($this);
}
return $this;
}
public function removeTicketEmail(SupplierTicketEmail $ticketEmail): static
{
if ($this->ticketEmails->removeElement($ticketEmail)) {
// set the owning side to null (unless already changed)
if ($ticketEmail->getSupplier() === $this) {
$ticketEmail->setSupplier(null);
}
}
return $this;
}
/**
* @return Collection<int, JoinTableProductModelSupplier>
*/
public function getModels(): Collection
{
return $this->models;
}
public function addModel(JoinTableProductModelSupplier $model): static
{
if (!$this->models->contains($model)) {
$this->models->add($model);
$model->setSupplier($this);
}
return $this;
}
public function removeModel(JoinTableProductModelSupplier $model): static
{
if ($this->models->removeElement($model)) {
// set the owning side to null (unless already changed)
if ($model->getSupplier() === $this) {
$model->setSupplier(null);
}
}
return $this;
}
/**
* @return Collection<int, ProductRegenerated>
*/
public function getRegeneratedProducts(): Collection
{
return $this->regeneratedProducts;
}
public function addRegeneratedProduct(ProductRegenerated $regeneratedProduct): static
{
if (!$this->regeneratedProducts->contains($regeneratedProduct)) {
$this->regeneratedProducts->add($regeneratedProduct);
$regeneratedProduct->setSupplier($this);
}
return $this;
}
public function removeRegeneratedProduct(ProductRegenerated $regeneratedProduct): static
{
if ($this->regeneratedProducts->removeElement($regeneratedProduct)) {
// set the owning side to null (unless already changed)
if ($regeneratedProduct->getSupplier() === $this) {
$regeneratedProduct->setSupplier(null);
}
}
return $this;
}
/**
* @return Collection<int, TicketColumnValue>
*/
public function getTicketColumnValues(): Collection
{
return $this->ticketColumnValues;
}
public function addTicketColumnValue(TicketColumnValue $ticketColumnValue): static
{
if (!$this->ticketColumnValues->contains($ticketColumnValue)) {
$this->ticketColumnValues->add($ticketColumnValue);
$ticketColumnValue->setSupplier($this);
}
return $this;
}
public function removeTicketColumnValue(TicketColumnValue $ticketColumnValue): static
{
if ($this->ticketColumnValues->removeElement($ticketColumnValue)) {
// set the owning side to null (unless already changed)
if ($ticketColumnValue->getSupplier() === $this) {
$ticketColumnValue->setSupplier(null);
}
}
return $this;
}
/**
* @return Collection<int, Product>
*/
public function getProducts(): Collection
{
return $this->products;
}
public function addProduct(Product $product): static
{
if (!$this->products->contains($product)) {
$this->products->add($product);
$product->addSupplier($this);
}
return $this;
}
public function removeProduct(Product $product): static
{
if ($this->products->removeElement($product)) {
$product->removeSupplier($this);
}
return $this;
}
/**
* @return Collection<int, User>
*/
public function getAutoAssignUsers(): Collection
{
return $this->autoAssignUsers;
}
public function addAutoAssignUser(User $autoAssignUser): static
{
if (!$this->autoAssignUsers->contains($autoAssignUser)) {
$this->autoAssignUsers->add($autoAssignUser);
$autoAssignUser->addAutoAssignSupplier($this);
}
return $this;
}
public function removeAutoAssignUser(User $autoAssignUser): static
{
if ($this->autoAssignUsers->removeElement($autoAssignUser)) {
$autoAssignUser->removeAutoAssignSupplier($this);
}
return $this;
}
}