<?php

namespace RxConnexionBundle\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity(repositoryClass="RxConnexionBundle\Repository\AddInventoryItemUnitMeasurementRepository")
 * @ORM\Table(name="add_inventory_item_unit_measurement")
 * @ORM\HasLifecycleCallbacks()
 */
 
class AddInventoryItemUnitMeasurementEntity
{
    /**
     * @ORM\Column(type="bigint")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
	protected $id;

    /**
     * @ORM\Column(name="quantity", type="decimal", precision=12, scale=2)
     */
    protected $quantity;

    /**
     * @ORM\Column(name="created_by", type="string", length=50)
     */
	protected $createdBy;
	
    /**
     * @ORM\Column(name="created_at", type="datetime")
     */
	protected $createdAt;
	
    /**
     * @ORM\Column(name="updated_by", type="string", length=50)
     */
	protected $updatedBy;
	
    /**
     * @ORM\Column(name="updated_at", type="datetime")
     */
	protected $updatedAt;

    /**
     * @ORM\ManyToOne(targetEntity="AddInventoryItemEntity", inversedBy="addInventoryItemUnitMeasurements")
     * @ORM\JoinColumn(name="add_inventory_item_id", referencedColumnName="id")
     */
    protected $addInventoryItem;

    /**
     * @ORM\ManyToOne(targetEntity="ItemUnitMeasurementEntity", inversedBy="addInventoryItemUnitMeasurements")
     * @ORM\JoinColumn(name="item_unit_measurement_id", referencedColumnName="id")
     */
    protected $itemUnitMeasurement;
  
    /** 
     * Set createdAt 
     * 
     * @ORM\PrePersist 
     */      
    public function setCreatedAtValue()  
    {
    	$this->createdBy = isSet($_COOKIE['username']) ? $_COOKIE['username'] : 'System';
        $this->createdAt = new \DateTime();
    	$this->updatedBy = isSet($_COOKIE['username']) ? $_COOKIE['username'] : 'System';
        $this->updatedAt = new \DateTime();
    }
  
    /**
     * Set updatedAt
     * 
     * @ORM\PreUpdate 
     */  
    public function setUpdatedAtValue()  
    {

    	$this->updatedBy = $_COOKIE['username'];
        $this->updatedAt = new \DateTime();
    }

    public function __construct($data=null)
    {
    	if(!is_null($data)) {
    		$this->id = $data->getId();
    		$this->addInventoryItem = $data->getAddInventoryItem();
    		$this->itemUnitMeasurement = $data->getItemUnitMeasurement();

    	}
    }

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

    /**
     * Get idEncoded
     *
     * @return string
     */
    public function getIdEncoded() {

        return base64_encode($this->id);
    }


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


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

    /**
     * Set quantity
     *
     * @param string $quantity
     * @return AddInventoryItemUnitMeasurementEntity
     */
    public function setQuantity($quantity)
    {
        $this->quantity = $quantity;
    
        return $this;
    }

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

    /**
     * Set createdBy
     *
     * @param string $createdBy
     * @return AddInventoryItemUnitMeasurementEntity
     */
    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 AddInventoryItemUnitMeasurementEntity
     */
    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 AddInventoryItemUnitMeasurementEntity
     */
    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 AddInventoryItemUnitMeasurementEntity
     */
    public function setUpdatedAt($updatedAt)
    {
        $this->updatedAt = $updatedAt;
    
        return $this;
    }

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

    /**
     * Set addInventoryItem
     *
     * @param \RxConnexionBundle\Entity\AddInventoryItemEntity $addInventoryItem
     * @return AddInventoryItemUnitMeasurementEntity
     */
    public function setAddInventoryItem(\RxConnexionBundle\Entity\AddInventoryItemEntity $addInventoryItem = null)
    {
        $this->addInventoryItem = $addInventoryItem;
    
        return $this;
    }

    /**
     * Get addInventoryItem
     *
     * @return \RxConnexionBundle\Entity\AddInventoryItemEntity
     */
    public function getAddInventoryItem()
    {
        return $this->addInventoryItem;
    }

    /**
     * Set itemUnitMeasurement
     *
     * @param \RxConnexionBundle\Entity\ItemUnitMeasurementEntity $itemUnitMeasurement
     * @return AddInventoryItemUnitMeasurementEntity
     */
    public function setItemUnitMeasurement(\RxConnexionBundle\Entity\ItemUnitMeasurementEntity $itemUnitMeasurement = null)
    {
        $this->itemUnitMeasurement = $itemUnitMeasurement;
    
        return $this;
    }

    /**
     * Get itemUnitMeasurement
     *
     * @return \RxConnexionBundle\Entity\ItemUnitMeasurementEntity
     */
    public function getItemUnitMeasurement()
    {
        return $this->itemUnitMeasurement;
    }
}
