<?php

namespace AppBundle\Entity\Message;

use AppBundle\Entity\Organization\Organization;
use AppBundle\Entity\Place\Place;
use AppBundle\Entity\Place\Room;
use AppBundle\Services\Messenger\Reporter\ReporterManager;
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;

/**
 * Logs des envois de messages (mails, sms, courriers)
 *
 * @Iri("http://schema.org/ReportMessage")
 */
#[ORM\Entity]
#[ORM\Table(name: 'ReportMessage')]
#[ORM\Index(name: 'recipientType', columns: ['recipientType'])]
#[ORM\Index(name: 'recipientId', columns: ['recipientId'])]
class ReportMessage
{
    /**
     * @var int
     */
    #[ORM\Column(type: 'integer')]
    #[ORM\Id]
    #[ORM\GeneratedValue(strategy: 'AUTO')]
    #[Groups(['reportmessage', 'messagesend_list'])]
    private $id;
    /**
     *
     * @var MessageInterface 
     *
     */
    #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Message\Message', inversedBy: 'reportMessage')]
    #[Assert\NotNull]
    #[Groups(['reportmessage'])]
    private $message;
    /**
     * @var \DateTime
     */
    #[ORM\Column(type: 'datetime')]
    #[Assert\DateTime]
    #[Assert\NotNull]
    #[Groups(['reportmessage', 'report'])]
    private $dateSend;
    /**
     * @var string
     */
    #[ORM\Column(type: 'string')]
    #[Assert\NotNull]
    #[Groups(['reportmessage'])]
    private $recipientType;
    /**
     * @var int
     */
    #[ORM\Column(type: 'integer')]
    #[Assert\NotNull]
    #[Groups(['reportmessage'])]
    private $recipientId;
    /**
     * @var string
     */
    #[Groups(['report', 'messagesend_list_reportmessage'])]
    private $recipient;
    /**
     * @var ReporterManager
     */
    protected $reporterManager;
    /**
     * @var string
     */
    #[ORM\Column(type: 'string')]
    #[Assert\Type(type: 'string')]
    #[Assert\NotNull]
    #[Assert\Choice(callback: ['AppBundle\Enum\Message\ReportMessageSatusEnum', 'toArray'])]
    #[Groups(['reportmessage', 'report'])]
    private $status;
    /**
     * @var string
     */
    #[ORM\Column(type: 'string', nullable: true)]
    #[Assert\Type(type: 'string')]
    #[Groups(['reportmessage', 'report'])]
    private $smsId;
    public function __construct()
    {
      $this->dateSend = new \DateTime();
    }
    /**
     * Get id
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }
    /**
     * Set dateSend
     *
     * @param \DateTime $dateSend
     *
     * @return ReportMessage
     */
    public function setDateSend($dateSend)
    {
        $this->dateSend = $dateSend;

        return $this;
    }
    /**
     * Get dateSend
     *
     * @return \DateTime
     */
    public function getDateSend()
    {
        return $this->dateSend;
    }
    /**
     * Set status
     *
     * @param string $status
     *
     * @return ReportMessage
     */
    public function setStatus($status)
    {
        $this->status = $status;

        return $this;
    }
    /**
     * Get status
     *
     * @return string
     */
    public function getStatus()
    {
        return $this->status;
    }
    /**
     * Set message
     *
     * @param \AppBundle\Entity\Message\Message $message
     *
     * @return ReportMessage
     */
    public function setMessage(\AppBundle\Entity\Message\Message $message)
    {
        $this->message = $message;

        return $this;
    }
    /**
     * Get message
     *
     * @return \AppBundle\Entity\Message\Message
     */
    public function getMessage()
    {
        return $this->message;
    }
    /**
     * Gets sms id
     * 
     * @return string
     */
    public function getSmsId() {
        return $this->smsId;
    }
    /**
     * Sets sms id
     * 
     * @param string $smsId
     * @return $this
     */
    public function setSmsId($smsId) {
        $this->smsId = $smsId;
        return $this;
    }
    /**
     * Set recipient
     *
     * @param string $recipientType
     *
     * @return ReportMessage
     */
    public function setRecipientType($recipientType)
    {
        $this->recipientType = $recipientType;

        return $this;
    }
    /**
     * Get recipient
     *
     * @return string
     */
    public function getRecipientType()
    {
        return $this->recipientType;
    }
    /**
     * Get the recipient id
     * 
     * @return type
     */
    public function getRecipientId() {
        return $this->recipientId;
    }
    /**
     * Set the recipient id
     * 
     * @param type $recipientId
     * @return $this
     */
    public function setRecipientId($recipientId) {
        $this->recipientId = $recipientId;
        return $this;
    }
    /**
     * {@inheritdoc}
     */
    public function getRecipient()
    {
        if (!$this->recipient) {
            if ($this->reporterManager) {
                return $this->reporterManager->loadRecipient($this);
            }
        }
        return null;
    }
    /**
     * {@inheritdoc}
     */
    public function setReportManagerr(ReporterManager $reporterManager)
    {
        $this->reporterManager = $reporterManager;
    }
}
