<?php

namespace RxConnexionBundle\Entity;

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

/**
 * @ORM\Entity(repositoryClass="RxConnexionBundle\Repository\UserGroupAccountUserRepository")
 * @ORM\Table(name="user_group_account_user")
 */

class UserGroupAccountUserEntity extends BaseEntity
{

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

    /**
     * @ORM\Column(name="start_date", type="datetime")
     */
    protected $startDate;

    /**
     * @ORM\Column(name="end_date", type="datetime", nullable=true)
     */
    protected $endDate;

    /**
     * @ORM\ManyToOne(targetEntity="UserGroupEntity", inversedBy="userGroupAccountUsers")
     * @ORM\JoinColumn(name="user_group_id", referencedColumnName="id")
     */
    protected $userGroup;

    /**
     * @ORM\ManyToOne(targetEntity="AccountUserEntity", inversedBy="userGroupAccountUsers")
     * @ORM\JoinColumn(name="account_user_id", referencedColumnName="id")
     */
    protected $accountUser;


    public function __construct()
    {
    }

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

        return $this;
    }

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

    /**
     * Set startDate
     *
     * @param \DateTime $startDate
     *
     * @return UserGroupAccountUserEntity
     * @throws \Exception
     */
    public function setStartDate($startDate)
    {
        $this->startDate = empty($startDate) ? null : new \DateTime($startDate);

        return $this;
    }

    /**
     * Get startDate
     *
     * @return \DateTime
     */
    public function getStartDate()
    {
        return $this->startDate;
    }

    /**
     * Set endDate
     *
     * @param \DateTime $endDate
     *
     * @return UserGroupAccountUserEntity
     * @throws \Exception
     */
    public function setEndDate($endDate)
    {
        $this->endDate = empty($endDate) ? null : new \DateTime($endDate);

        return $this;
    }


    /**
     * Get endDate
     *
     * @return \DateTime
     */
    public function getEndDate()
    {
        return $this->endDate;
    }

    /**
     * Set userGroup
     *
     * @param \RxConnexionBundle\Entity\UserGroupEntity $userGroup
     *
     * @return UserGroupAccountUserEntity
     */
    public function setUserGroup(\RxConnexionBundle\Entity\UserGroupEntity $userGroup = null)
    {
        $this->userGroup = $userGroup;

        return $this;
    }

    /**
     * Get userGroup
     *
     * @return \RxConnexionBundle\Entity\UserGroupEntity
     */
    public function getUserGroup()
    {
        return $this->userGroup;
    }

    /**
     * Set accountUser
     *
     * @param \RxConnexionBundle\Entity\AccountUserEntity $accountUser
     *
     * @return UserGroupAccountUserEntity
     */
    public function setAccountUser(\RxConnexionBundle\Entity\AccountUserEntity $accountUser = null)
    {
        $this->accountUser = $accountUser;

        return $this;
    }

    /**
     * Get accountUser
     *
     * @return \RxConnexionBundle\Entity\AccountUserEntity
     */
    public function getAccountUser()
    {
        return $this->accountUser;
    }
}
