<?php

namespace RxConnexionBundle\Entity;

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

/**
 * @ORM\Entity(repositoryClass="RxConnexionBundle\Repository\MaterialRequisitionItemUnitMeasurementRepository")
 * @ORM\Table(name="material_requisition_item_unit_measurement")
 * @ORM\HasLifecycleCallbacks()
 */
 
class MaterialRequisitionItemUnitMeasurementEntity
{
    /**
     * @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="MaterialRequisitionItemEntity", inversedBy="materialRequisitionItemUnitMeasurements")
     * @ORM\JoinColumn(name="material_requisition_item_id", referencedColumnName="id")
     */
    protected $materialRequisitionItem;

    /**
     * @ORM\ManyToOne(targetEntity="ItemUnitMeasurementEntity", inversedBy="materialRequisitionItemUnitMeasurements")
     * @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->materialRequisitionItem = $data->getMaterialRequisitionItem();
    		$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 createdBy
     *
     * @param string $createdBy
     * @return MaterialRequisitionItemUnitMeasurementEntity
     */
    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 MaterialRequisitionItemUnitMeasurementEntity
     */
    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 MaterialRequisitionItemUnitMeasurementEntity
     */
    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 MaterialRequisitionItemUnitMeasurementEntity
     */
    public function setUpdatedAt($updatedAt)
    {
        $this->updatedAt = $updatedAt;
    
        return $this;
    }

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

    /**
     * Set materialRequisitionItem
     *
     * @param \RxConnexionBundle\Entity\MaterialRequisitionItemEntity $materialRequisitionItem
     * @return MaterialRequisitionItemUnitMeasurementEntity
     */
    public function setMaterialRequisitionItem(\RxConnexionBundle\Entity\MaterialRequisitionItemEntity $materialRequisitionItem = null)
    {
        $this->materialRequisitionItem = $materialRequisitionItem;
    
        return $this;
    }

    /**
     * Get materialRequisitionItem
     *
     * @return \RxConnexionBundle\Entity\MaterialRequisitionItemEntity
     */
    public function getMaterialRequisitionItem()
    {
        return $this->materialRequisitionItem;
    }

    /**
     * Set itemUnitMeasurement
     *
     * @param \RxConnexionBundle\Entity\ItemUnitMeasurementEntity $itemUnitMeasurement
     * @return MaterialRequisitionItemUnitMeasurementEntity
     */
    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;
    }

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

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