<?php

namespace RxConnexionBundle\Entity;

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

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

    /**
     * @ORM\Column(name="code", type="string", nullable=true)
     */
	protected $code;
	
    /**
     * @ORM\Column(name="description", type="string")
     */
	protected $description;

    /**
     * @ORM\Column(name="init_check_no", type="integer", nullable=true)
     */
    protected $initCheckNo;
	
    /**
     * @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\OneToMany(targetEntity="PurchaseOrderBreakdownItemDeliveryEntity", mappedBy="bank")
//     */
//    protected $purchaseOrderBreakdownItemDeliveries;
//
//    /**
//     * @ORM\OneToMany(targetEntity="UserBankEntity", mappedBy="bank")
//     */
//    protected $userBanks;

//    /**
//     * @ORM\OneToMany(targetEntity="PurchaseInvoicePaymentEntity", mappedBy="bank")
//     */
//    protected $purchaseInvoicePayments;
//
//    /**
//     * @ORM\OneToMany(targetEntity="PurchaseInvoiceCreditPaymentEntity", mappedBy="bank")
//     */
//    protected $purchaseInvoiceCreditPayments;
//
//    /**
//     * @ORM\OneToMany(targetEntity="SlAccountLinkEntity", mappedBy="bank")
//     */
//    protected $slAccountLinks;
//
//    /**
//     * @ORM\OneToMany(targetEntity="SalesOrderPaymentEntity", mappedBy="bank")
//     */
//    protected $salesOrderPayments;
//
//    /**
//     * @ORM\OneToMany(targetEntity="SalesOrderCreditPaymentEntity", mappedBy="bank")
//     */
//    protected $salesOrderCreditPayments;
//
//    /**
//     * @ORM\OneToMany(targetEntity="SalesOrderReturnPaymentEntity", mappedBy="bank")
//     */
//    protected $salesOrderReturnPayments;

    /**
     * @ORM\OneToMany(targetEntity="AddInventoryPaymentEntity", mappedBy="bank")
     */
    protected $addInventoryPayments;

//    /**
//     * @ORM\OneToMany(targetEntity="AddFixedAssetPaymentEntity", mappedBy="bank")
//     */
//    protected $addFixedAssetPayments;
//
//    /**
//     * @ORM\OneToMany(targetEntity="CheckTranEntity", mappedBy="bank")
//     */
//    protected $checkTrans;
  
    /** 
     * 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->code = $data->getCode();
            $this->description = $data->getDescription();
            $this->initCheckNo = $data->getInitCheckNo();
    	}

//        $this->purchaseOrderBreakdownItemDeliveries = new ArrayCollection();
//        $this->userBanks = new ArrayCollection();
//        $this->slAccountLinks = new ArrayCollection();
//        $this->salesOrderPayments = new ArrayCollection();
//        $this->salesOrderReturnPayments = new ArrayCollection();
        $this->addInventoryPayments = new ArrayCollection();
//        $this->addFixedAssetPayments = new ArrayCollection();
//        $this->checkTrans = new ArrayCollection();
//        $this->salesOrderCreditPayments = new ArrayCollection();
    }

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



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

    /**
     * Set code
     *
     * @param string $code
     *
     * @return BankEntity
     */
    public function setCode($code)
    {
        $this->code = $code;

        return $this;
    }

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

    /**
     * Set description
     *
     * @param string $description
     *
     * @return BankEntity
     */
    public function setDescription($description)
    {
        $this->description = $description;

        return $this;
    }

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

    /**
     * Set initCheckNo
     *
     * @param integer $initCheckNo
     *
     * @return BankEntity
     */
    public function setInitCheckNo($initCheckNo)
    {
        $this->initCheckNo = $initCheckNo;

        return $this;
    }

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

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

        return $this;
    }

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

    /**
     * Add addInventoryPayment
     *
     * @param \RxConnexionBundle\Entity\AddInventoryPaymentEntity $addInventoryPayment
     *
     * @return BankEntity
     */
    public function addAddInventoryPayment(\RxConnexionBundle\Entity\AddInventoryPaymentEntity $addInventoryPayment)
    {
        $this->addInventoryPayments[] = $addInventoryPayment;

        return $this;
    }

    /**
     * Remove addInventoryPayment
     *
     * @param \RxConnexionBundle\Entity\AddInventoryPaymentEntity $addInventoryPayment
     */
    public function removeAddInventoryPayment(\RxConnexionBundle\Entity\AddInventoryPaymentEntity $addInventoryPayment)
    {
        $this->addInventoryPayments->removeElement($addInventoryPayment);
    }

    /**
     * Get addInventoryPayments
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getAddInventoryPayments()
    {
        return $this->addInventoryPayments;
    }
}
