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

class ItemPackageItemEntity extends BaseEntity
{
    /**
     * @ORM\ManyToOne(targetEntity="RxConnexionBundle\Entity\ItemPackageEntity", inversedBy="itemPackageItems")
     * @ORM\JoinColumn(name="item_package_id", referencedColumnName="id")
     * @Groups("forAudit")
     * @MaxDepth(1)
     */
    protected $itemPackage;

    /**
     * @ORM\ManyToOne(targetEntity="RxConnexionBundle\Entity\ItemEntity", inversedBy="itemPackageItems")
     * @ORM\JoinColumn(name="item_id", referencedColumnName="id")
     * @Groups("forAudit")
     * @MaxDepth(1)
     */
    protected $item;

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

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

        return $this;
    }

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

    /**
     * Set itemPackage
     *
     * @param \RxConnexionBundle\Entity\ItemPackageEntity $itemPackage
     *
     * @return ItemPackageItemEntity
     */
    public function setItemPackage(\RxConnexionBundle\Entity\ItemPackageEntity $itemPackage = null)
    {
        $this->itemPackage = $itemPackage;

        return $this;
    }

    /**
     * Get itemPackage
     *
     * @return \RxConnexionBundle\Entity\ItemPackageEntity
     */
    public function getItemPackage()
    {
        return $this->itemPackage;
    }

    /**
     * Set item
     *
     * @param \RxConnexionBundle\Entity\ItemEntity $item
     *
     * @return ItemPackageItemEntity
     */
    public function setItem(\RxConnexionBundle\Entity\ItemEntity $item = null)
    {
        $this->item = $item;

        return $this;
    }

    /**
     * Get item
     *
     * @return \RxConnexionBundle\Entity\ItemEntity
     */
    public function getItem()
    {
        return $this->item;
    }
}
