<?php

namespace RxConnexionBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use RxConnexionBundle\Entity\Base\BaseEntity;
use JMS\Serializer\Annotation\Groups;
use JMS\Serializer\Annotation\MaxDepth;
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer;

/**
 * @ORM\Entity(repositoryClass="RxConnexionBundle\Repository\LetterTemplateRepository")
 * @ORM\Table(name="letter_template")
 */

class LetterTemplateEntity extends BaseEntity
{
    /**
     * @ORM\Column(name="is_deleted", type="boolean")
     */
    protected $isDeleted;

    /**
     * @ORM\Column(name="letter_type", type="string")
     * @Groups("forAudit")
     */
    protected $letterType;

    /**
     * @ORM\Column(name="fax_cover_body", type="text", nullable=true)
     * @Groups("forAudit")
     */
    protected $faxCoverBody;

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

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

    /*--------------------------------------------------------------------------------------------------------*/
    /*					User Defined Setters and Getters													  */
    /*--------------------------------------------------------------------------------------------------------*/

    /**
     * Get startDateAsString
     *
     * @return string
     */
    public function getStartDateAsString() {

        $dttst = new DateTimeToStringTransformer();
        return !empty($this->startDate) ? date('m/d/Y', strtotime($dttst->transform($this->startDate))) : '';
    }

    /**
     * Get endDateAsString
     *
     * @return string
     */
    public function getEndDateAsString() {

        $dttst = new DateTimeToStringTransformer();
        return !empty($this->endDate) ? date('m/d/Y', strtotime($dttst->transform($this->endDate))) : '';
    }

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


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

        return $this;
    }

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

    /**
     * Set letterType
     *
     * @param string $letterType
     *
     * @return LetterTemplateEntity
     */
    public function setLetterType($letterType)
    {
        $this->letterType = $letterType;

        return $this;
    }

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

    /**
     * Set faxCoverBody
     *
     * @param string $faxCoverBody
     *
     * @return LetterTemplateEntity
     */
    public function setFaxCoverBody($faxCoverBody)
    {
        $this->faxCoverBody = $faxCoverBody;

        return $this;
    }

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

    /**
     * Set body
     *
     * @param string $body
     *
     * @return LetterTemplateEntity
     */
    public function setBody($body)
    {
        $this->body = $body;

        return $this;
    }

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