<?php

namespace AppBundle\Entity\Core;

use AppBundle\Entity\AccessAndFunction\Access;
use AppBundle\Entity\Traits\ActivityPeriodTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Dunglas\ApiBundle\Annotation\Iri;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use AppBundle\Entity\Traits\TimestampableEntity;
use AppBundle\Entity\Traits\CreatorUpdaterEntity;

/**
 * Classe de base de @see PlaceRepair, RoomRepair, EquipmentRepair
 *
 * @author vincent
 *
 */
#[ORM\Entity]
#[ORM\Table(name: 'Repair')]
#[ORM\InheritanceType('SINGLE_TABLE')]
#[ORM\DiscriminatorColumn(name: 'discr', type: 'string')]
#[ORM\DiscriminatorMap(['place' => 'AppBundle\Entity\Place\PlaceRepair', 'room' => 'AppBundle\Entity\Place\RoomRepair', 'equipment' => 'AppBundle\Entity\Product\EquipmentRepair'])]
abstract class AbstractRepair
{
    use TimestampableEntity;
    use CreatorUpdaterEntity;
    use ActivityPeriodTrait;
    /**
     * @var int
     */
    #[ORM\Column(type: 'integer')]
    #[ORM\Id]
    #[ORM\GeneratedValue(strategy: 'AUTO')]
    #[Groups(['repair', 'equipmentrepair_list', 'placerepair_list', 'equipment_details', 'repair_edit'])]
    private $id;
    /**
     * @var string
     */
    #[ORM\Column(type: 'string', nullable: true)]
    #[Assert\Type(type: 'string')]
    #[Assert\Choice(callback: ['AppBundle\Enum\Core\RepairTypeEnum', 'toArray'])]
    #[Groups(['repair', 'equipmentrepair_list', 'placerepair_list', 'equipment_details_equipmentrepair', 'repair_edit'])]
    private $repairType;
    /**
     * @var string
     */
    #[ORM\Column(type: 'text', nullable: true)]
    #[Assert\Type(type: 'string')]
    #[Groups(['repair', 'equipmentrepair_list', 'placerepair_list', 'repair_edit'])]
    private $workToDo;
    /**
     * @var Access
     */
    #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\AccessAndFunction\Access')]
    #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
    #[Groups(['repair', 'equipmentrepair_list', 'placerepair_list', 'equipment_details_equipmentrepair', 'repair_edit'])]
    private $provider;
    /**
     * @var string
     */
    #[ORM\Column(type: 'text', nullable: true)]
    #[Assert\Type(type: 'string')]
    #[Groups(['repair', 'equipmentrepair_list', 'placerepair_list', 'repair_edit'])]
    private $workDoing;
    /**
     * @var float
     */
    #[ORM\Column(type: 'float', nullable: true)]
    #[Assert\Type(type: 'float')]
    #[Groups(['repair', 'equipmentrepair_list', 'placerepair_list', 'repair_edit'])]
    private $cost;
    /**
     * @var float
     */
    #[ORM\Column(type: 'float', nullable: true)]
    #[Assert\Type(type: 'float')]
    #[Groups(['repair', 'equipmentrepair_list', 'placerepair_list', 'repair_edit'])]
    private $tva;
    /**
     * @var int
     */
    #[ORM\Column(type: 'string', nullable: true)]
    #[Assert\Type(type: 'string')]
    #[Groups(['repair', 'equipmentrepair_list', 'placerepair_list', 'repair_edit'])]
    private $invoiceNumber;
    /**
     * @var string
     */
    #[ORM\Column(type: 'string', nullable: true)]
    #[Assert\Type(type: 'string')]
    #[Assert\Choice(callback: ['AppBundle\Enum\Core\AppreciationEnum', 'toArray'])]
    #[Groups(['repair', 'equipmentrepair_list', 'placerepair_list', 'repair_edit'])]
    private $appreciation;
    /**
     * @var ArrayCollection<Tagg>
     */
    #[ORM\ManyToMany(targetEntity: 'AppBundle\Entity\Core\Tagg', cascade: ['persist'], inversedBy: 'repairs')]
    #[Assert\Valid]
    #[ORM\JoinTable(name: 'tag_repair', joinColumns: [], inverseJoinColumns: [])]
    #[ORM\JoinColumn(name: 'repair_id', referencedColumnName: 'id')]
    #[ORM\JoinColumn(name: 'tag_id', referencedColumnName: 'id')]
    #[Groups(['repair_tags', 'manage_tags', 'equipmentrepair_list', 'repair_edit'])]
    private $tags;
    public function __construct() {
        $this->tags = new ArrayCollection();
    }
    /**
     * Sets id.
     * 
     * @param int $id
     * 
     * @return $this
     */
    public function setId($id)
    {
        $this->id = $id;

        return $this;
    }
    /**
     * Gets id.
     * 
     * @return int
     */
    public function getId()
    {
        return $this->id;
    }
    /**
     * Sets repairType.
     * 
     * @param string $repairType
     * 
     * @return $this
     */
    public function setRepairType($repairType)
    {
        $this->repairType = $repairType;

        return $this;
    }
    /**
     * Gets RepairType.
     * 
     * @return string
     */
    public function getRepairType()
    {
        return $this->repairType;
    }
    /**
     * Sets workToDo.
     * 
     * @param string $workToDo
     * 
     * @return $this
     */
    public function setWorkToDo($workToDo)
    {
        $this->workToDo = $workToDo;

        return $this;
    }
    /**
     * Gets workToDo.
     * 
     * @return string
     */
    public function getWorkToDo()
    {
        return $this->workToDo;
    }
    /**
     * Sets provider.
     * 
     * @param Access $provider
     * 
     * @return $this
     */
    public function setProvider(Access $provider = null)
    {
        $this->provider = $provider;

        return $this;
    }
    /**
     * Gets provider.
     * 
     * @return Access
     */
    public function getProvider()
    {
        return $this->provider;
    }
    /**
     * Sets workDoing.
     * 
     * @param string $workDoing
     * 
     * @return $this
     */
    public function setWorkDoing($workDoing)
    {
        $this->workDoing = $workDoing;

        return $this;
    }
    /**
     * Gets workDoing.
     * 
     * @return string
     */
    public function getWorkDoing()
    {
        return $this->workDoing;
    }
    /**
     * Sets cost.
     * 
     * @param float $cost
     * 
     * @return $this
     */
    public function setCost($cost)
    {
        $this->cost = floatval($cost);

        return $this;
    }
    /**
     * Gets cost.
     * 
     * @return float
     */
    public function getCost()
    {
        return $this->cost;
    }
    /**
     * Sets tva.
     * 
     * @param float $tva
     * 
     * @return $this
     */
    public function setTva($tva)
    {
        $this->tva = floatval($tva);

        return $this;
    }
    /**
     * Gets tva.
     * 
     * @return float
     */
    public function getTva()
    {
        return $this->tva;
    }
    /**
     * Sets invoiceNumber.
     * 
     * @param string $invoiceNumber
     * 
     * @return $this
     */
    public function setInvoiceNumber($invoiceNumber)
    {
        $this->invoiceNumber = $invoiceNumber;

        return $this;
    }
    /**
     * Gets invoiceNumber.
     * 
     * @return string
     */
    public function getInvoiceNumber()
    {
        return $this->invoiceNumber;
    }
    /**
     * Sets appreciation.
     * 
     * @param string $appreciation
     * 
     * @return $this
     */
    public function setAppreciation($appreciation)
    {
        $this->appreciation = $appreciation;

        return $this;
    }
    /**
     * Gets appreciation.
     * 
     * @return string
     */
    public function getAppreciation()
    {
        return $this->appreciation;
    }
    /**
     * Add tag
     *
     * @param \AppBundle\Entity\Core\Tagg $tag
     *
     * @return AbstractRepair
     */
    public function addTag(\AppBundle\Entity\Core\Tagg $tag)
    {
        $this->tags[] = $tag;

        return $this;
    }
    /**
     * Remove tag
     *
     * @param \AppBundle\Entity\Core\Tagg $tag
     */
    public function removeTag(\AppBundle\Entity\Core\Tagg $tag)
    {
        $this->tags->removeElement($tag);
    }
    /**
     * Get tags
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getTags()
    {
        return $this->tags;
    }
}
