<?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\ProviderWorkScheduleRepository")
 * @ORM\Table(name="provider_work_schedule")
 */

class ProviderWorkScheduleEntity extends BaseEntity
{
    CONST TYPE_REGULAR = 'Regular';
    CONST TYPE_IRREGULAR = 'Irregular';
    CONST TYPE_OUT = 'Out';

    CONST DAYNAME_MONDAY = 'Monday';
    CONST DAYNAME_TUESDAY = 'Tuesday';
    CONST DAYNAME_WEDNESDAY = 'Wednesday';
    CONST DAYNAME_THURSDAY = 'Thurday';
    CONST DAYNAME_FRIDAY = 'Friday';
    CONST DAYNAME_SATURDAY = 'Saturday';

    CONST FROMAM_AM = 'AM';
    CONST FROMAM_PM = 'PM';

    CONST TOAM_AM = 'AM';
    CONST TOPM_PM = 'PM';


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

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

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

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

    /**
     * @ORM\Column(name="to_hr", type="string", length=10, nullable=true)
     * @Groups("forAudit")
     */
    protected $toHr;

    /**
     * @ORM\Column(name="to_min", type="string", length=10, nullable=true)
     * @Groups("forAudit")
     */
    protected $toMin;

    /**
     * @ORM\Column(name="to_am", type="string", length=10, nullable=true)
     * @Groups("forAudit")
     */
    protected $toAm;

    /**
     * @ORM\Column(name="from_hr", type="string", length=10, nullable=true)
     * @Groups("forAudit")
     */
    protected $fromHr;

    /**
     * @ORM\Column(name="from_min", type="string", length=10, nullable=true)
     * @Groups("forAudit")
     */
    protected $fromMin;

    /**
     * @ORM\Column(name="from_am", type="string", length=10, nullable=true)
     * @Groups("forAudit")
     */
    protected $fromAm;

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

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

    /**
     * @ORM\ManyToOne(targetEntity="ProviderEntity", inversedBy="providerWorkSchedules")
     * @ORM\JoinColumn(name="provider_id", referencedColumnName="id")
     * @Groups("forAudit")
     * @MaxDepth(1)
     */
    protected $provider;

    /**
     * @ORM\ManyToOne(targetEntity="HealthFacilityEntity", inversedBy="providerWorkSchedules")
     * @ORM\JoinColumn(name="health_facility_id", referencedColumnName="id")
     * @Groups("forAudit")
     * @MaxDepth(1)
     */
    protected $healthFacility;

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


    /*--------------------------------------------------------------------------------------------------------*/
    /*					Use Defined Setters and Getters														  */
    /*--------------------------------------------------------------------------------------------------------*/
    /**
     * Get fromDateAsString
     *
     * @return string
     */
    public function getFromDateAsString() {

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

    /**
     * Get toDateAsString
     *
     * @return string
     */
    public function getToDateAsString() {

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

	public function getTimeFrom()
	{
		return $this->fromHr . ':' . str_pad($this->fromMin, 2, 0) . ' ' . $this->fromAm;
    }

	public function getTimeTo()
	{
		return $this->toHr . ':' . str_pad($this->toMin, 2, 0) . ' ' . $this->toAm;
    }
    /*--------------------------------------------------------------------------------------------------------*/
    /*					Setters and Getters																	  */
    /*--------------------------------------------------------------------------------------------------------*/


    /**
     * Set type
     *
     * @param string $type
     *
     * @return ProviderWorkScheduleEntity
     */
    public function setType($type)
    {
        $this->type = $type;

        return $this;
    }

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

    /**
     * Set dayName
     *
     * @param string $dayName
     *
     * @return ProviderWorkScheduleEntity
     */
    public function setDayName($dayName)
    {
        $this->dayName = $dayName;

        return $this;
    }

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

    /**
     * Set fromDate
     *
     * @param \DateTime $fromDate
     *
     * @return ProviderWorkScheduleEntity
     */
    public function setFromDate($fromDate)
    {
        $this->fromDate = empty($fromDate) ? NULL : new \DateTime($fromDate);
        return $this;
    }

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

    /**
     * Set toDate
     *
     * @param \DateTime $toDate
     *
     * @return ProviderWorkScheduleEntity
     */
    public function setToDate($toDate)
    {
        $this->toDate = empty($toDate) ? NULL : new \DateTime($toDate);

        return $this;
    }

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

    /**
     * Set toHr
     *
     * @param string $toHr
     *
     * @return ProviderWorkScheduleEntity
     */
    public function setToHr($toHr)
    {
        $this->toHr = $toHr;

        return $this;
    }

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

    /**
     * Set toMin
     *
     * @param string $toMin
     *
     * @return ProviderWorkScheduleEntity
     */
    public function setToMin($toMin)
    {
        $this->toMin = $toMin;

        return $this;
    }

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

    /**
     * Set toAm
     *
     * @param string $toAm
     *
     * @return ProviderWorkScheduleEntity
     */
    public function setToAm($toAm)
    {
        $this->toAm = $toAm;

        return $this;
    }

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

    /**
     * Set fromHr
     *
     * @param string $fromHr
     *
     * @return ProviderWorkScheduleEntity
     */
    public function setFromHr($fromHr)
    {
        $this->fromHr = $fromHr;

        return $this;
    }

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

    /**
     * Set fromMin
     *
     * @param string $fromMin
     *
     * @return ProviderWorkScheduleEntity
     */
    public function setFromMin($fromMin)
    {
        $this->fromMin = $fromMin;

        return $this;
    }

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

    /**
     * Set fromAm
     *
     * @param string $fromAm
     *
     * @return ProviderWorkScheduleEntity
     */
    public function setFromAm($fromAm)
    {
        $this->fromAm = $fromAm;

        return $this;
    }

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

    /**
     * Set note
     *
     * @param string $note
     *
     * @return ProviderWorkScheduleEntity
     */
    public function setNote($note)
    {
        $this->note = $note;

        return $this;
    }

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

    /**
     * Get id
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set createdBy
     *
     * @param string $createdBy
     *
     * @return ProviderWorkScheduleEntity
     */
    public function setCreatedBy($createdBy)
    {
        $this->createdBy = $createdBy;

        return $this;
    }

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

    /**
     * Set createdAt
     *
     * @param \DateTime $createdAt
     *
     * @return ProviderWorkScheduleEntity
     */
    public function setCreatedAt($createdAt)
    {
        $this->createdAt = $createdAt;

        return $this;
    }

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

    /**
     * Set updatedBy
     *
     * @param string $updatedBy
     *
     * @return ProviderWorkScheduleEntity
     */
    public function setUpdatedBy($updatedBy)
    {
        $this->updatedBy = $updatedBy;

        return $this;
    }

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

    /**
     * Set updatedAt
     *
     * @param \DateTime $updatedAt
     *
     * @return ProviderWorkScheduleEntity
     */
    public function setUpdatedAt($updatedAt)
    {
        $this->updatedAt = $updatedAt;

        return $this;
    }

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

    /**
     * Set provider
     *
     * @param \RxConnexionBundle\Entity\ProviderEntity $provider
     *
     * @return ProviderWorkScheduleEntity
     */
    public function setProvider(\RxConnexionBundle\Entity\ProviderEntity $provider = null)
    {
        $this->provider = $provider;

        return $this;
    }

    /**
     * Get provider
     *
     * @return \RxConnexionBundle\Entity\ProviderEntity
     */
    public function getProvider()
    {
        return $this->provider;
    }

    /**
     * Set healthFacility
     *
     * @param \RxConnexionBundle\Entity\HealthFacilityEntity $healthFacility
     *
     * @return ProviderWorkScheduleEntity
     */
    public function setHealthFacility(\RxConnexionBundle\Entity\HealthFacilityEntity $healthFacility = null)
    {
        $this->healthFacility = $healthFacility;

        return $this;
    }

    /**
     * Get healthFacility
     *
     * @return \RxConnexionBundle\Entity\HealthFacilityEntity
     */
    public function getHealthFacility()
    {
        return $this->healthFacility;
    }

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

        return $this;
    }

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