<?php

namespace RxConnexionBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use RxConnexionBundle\Entity\Base\BaseEntity;
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer;

/**
 * @ORM\Entity(repositoryClass="RxConnexionBundle\Repository\LetterTemplateEmailRepository")
 * @ORM\Table(name="letter_template_email")
 */

class LetterTemplateEmailEntity extends BaseEntity
{

    /**
     * @ORM\Column(name="is_deleted", type="boolean")
     */
    protected $isDeleted;

    /**
     * @ORM\Column(name="description", type="text", nullable=true)
     */
    protected $description;

    /**
     * @ORM\Column(name="email", type="string", nullable=true)
     */
    protected $email;

    /**
     * @ORM\ManyToOne(targetEntity="RxConnexionBundle\Entity\LetterTemplateEntity", inversedBy="letterTemplateEmails")
     * @ORM\JoinColumn(name="letter_template_id", referencedColumnName="id")
     */
    protected $letterTemplate;


    /**
     * Set createdAt
     *
     * @ORM\PrePersist
     */
    public function setCreatedAtValue()
    {
        parent::setCreatedAtValue();
        $this->isDeleted = 0;
    }

    /*--------------------------------------------------------------------------------------------------------*/
    /*					Use Defined Setters and Getters														  */
    /*--------------------------------------------------------------------------------------------------------*/
    /**
     * Get createdAtAsString
     *
     * @return string
     * @throws \Exception
     */
    public function getCreatedAtAsString() {
        $dttst = new DateTimeToStringTransformer();
        return date('m/d/Y H:i A', strtotime($dttst->transform(new \DateTime())));
    }


    /*--------------------------------------------------------------------------------------------------------*/
    /*					Setters and Getters																	  */
    /*--------------------------------------------------------------------------------------------------------*/


    /**
     * Set isDeleted
     *
     * @param boolean $isDeleted
     *
     * @return LetterTemplateEmailEntity
     */
    public function setIsDeleted($isDeleted)
    {
        $this->isDeleted = $isDeleted;

        return $this;
    }

    /**
     * Get isDeleted
     *
     * @return boolean
     */
    public function getIsDeleted()
    {
        return $this->isDeleted;
    }

    /**
     * Set description
     *
     * @param string $description
     *
     * @return LetterTemplateEmailEntity
     */
    public function setDescription($description)
    {
        $this->description = $description;

        return $this;
    }

    /**
     * Get description
     *
     * @return string
     */
    public function getDescription()
    {
        return $this->description;
    }

    /**
     * Set email
     *
     * @param string $email
     *
     * @return LetterTemplateEmailEntity
     */
    public function setEmail($email)
    {
        $this->email = $email;

        return $this;
    }

    /**
     * Get email
     *
     * @return string
     */
    public function getEmail()
    {
        return $this->email;
    }

    /**
     * Set letterTemplate
     *
     * @param \RxConnexionBundle\Entity\LetterTemplateEntity $letterTemplate
     *
     * @return LetterTemplateEmailEntity
     */
    public function setLetterTemplate(\RxConnexionBundle\Entity\LetterTemplateEntity $letterTemplate = null)
    {
        $this->letterTemplate = $letterTemplate;

        return $this;
    }

    /**
     * Get letterTemplate
     *
     * @return \RxConnexionBundle\Entity\LetterTemplateEntity
     */
    public function getLetterTemplate()
    {
        return $this->letterTemplate;
    }
}
