<?php

namespace RxConnexionBundle\Entity;

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

/**
 * @ORM\Entity(repositoryClass="RxConnexionBundle\Repository\ReferralServiceRepository")
 * @ORM\Table(name="referral_service")
 */

class ReferralServiceEntity extends BaseEntity
{

    /**
     * @ORM\ManyToOne(targetEntity="ReferralEntity", inversedBy="referralServices")
     * @ORM\JoinColumn(name="referral_id", referencedColumnName="id")
     * @Groups("forAudit")
     * @MaxDepth(1)
     */
    protected $referral;

    /**
     * @ORM\ManyToOne(targetEntity="ServiceEntity", inversedBy="referralServices")
     * @ORM\JoinColumn(name="service_id", referencedColumnName="id")
     * @Groups("forAudit")
     * @MaxDepth(1)
     */
    protected $service;

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

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


    /*--------------------------------------------------------------------------------------------------------*/
    /*					Use 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 ReferralServiceEntity
     */
    public function setIsDeleted($isDeleted)
    {
        $this->isDeleted = $isDeleted;

        return $this;
    }

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

    /**
     * Set referral
     *
     * @param \RxConnexionBundle\Entity\ReferralEntity $referral
     *
     * @return ReferralServiceEntity
     */
    public function setReferral(\RxConnexionBundle\Entity\ReferralEntity $referral = null)
    {
        $this->referral = $referral;

        return $this;
    }

    /**
     * Get referral
     *
     * @return \RxConnexionBundle\Entity\ReferralEntity
     */
    public function getReferral()
    {
        return $this->referral;
    }

    /**
     * Set service
     *
     * @param \RxConnexionBundle\Entity\ServiceEntity $service
     *
     * @return ReferralServiceEntity
     */
    public function setService(\RxConnexionBundle\Entity\ServiceEntity $service = null)
    {
        $this->service = $service;

        return $this;
    }

    /**
     * Get service
     *
     * @return \RxConnexionBundle\Entity\ServiceEntity
     */
    public function getService()
    {
        return $this->service;
    }
}
