<?php

namespace RxConnexionBundle\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use RxConnexionBundle\Entity\Base\BaseEntity;

/**
 * @ORM\Entity(repositoryClass="RxConnexionBundle\Repository\UserRepository")
 * @ORM\Table(name="user")
 */
 
class UserEntity extends BaseEntity
{
    /**
     * @ORM\Column(type="string", length=50)
     */
	protected $username;
	
    /**
     * @ORM\Column(type="string", length=100)
     */
	protected $password;

    /**
     * @ORM\Column(type="string")
     */
    protected $type;
		
    /**
     * @ORM\Column(name="is_active", type="boolean")
     */
	protected $isActive=0;

    /**
     * @ORM\Column(name="first_name", type="string", length=50)
     */
	protected $firstName;	

    /**
     * @ORM\Column(name="middle_name", type="string", length=50, nullable = true)
     */
	protected $middleName;

    /**
     * @ORM\Column(name="last_name", type="string", length=50)
     */
	protected $lastName;

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

    /**
     * @ORM\Column(name="full_name", type="string", length=100, nullable=true)
     */
	protected $fullName;

    /**
     * @ORM\OneToMany(targetEntity="AccountUserReminderEntity", mappedBy="user", cascade={"remove"})
     */
    protected $accountUserReminders;

//    /**
//     * @ORM\OneToMany(targetEntity="RxConnexionBundle\Entity\TransferInventoryEntity", mappedBy="user", cascade={"remove"})
//     */
//    protected $transferInventories;

    /**
     * @ORM\OneToMany(targetEntity="RxConnexionBundle\Entity\CanvassStatusEntity", mappedBy="user", cascade={"remove"})
     */
    protected $canvassStatuses;

    /**
     * @ORM\OneToMany(targetEntity="RxConnexionBundle\Entity\TransferInventoryStatusEntity", mappedBy="user", cascade={"remove"})
     */
    protected $transferInventoryStatuses;

    /** 
     * Set createdAt 
     * 
     * @ORM\PrePersist 
     */      
    public function setCreatedAtValue()  
    {
        parent::setCreatedAtValue();
		$this->fullName = ucfirst($this->firstName) . ' ' . ucfirst($this->lastName);
		$this->isDeleted = 0;
    }    
  
    /** 
     * Set updatedAt 
     * 
     * @ORM\PreUpdate 
     */  
    public function setUpdatedAtValue()  
    {
        parent::setUpdatedAtValue();
		$this->fullName = ucfirst($this->firstName) . ' ' . ucfirst($this->lastName);
    }

    public function __construct()
    {
        $this->accountUserReminders = new ArrayCollection();
//        $this->transferInventories = new ArrayCollection();
    }

	/*--------------------------------------------------------------------------------------------------------*/
	/*					User Defined setters and Getters													  */
	/*--------------------------------------------------------------------------------------------------------*/

    /**
     * Get materialRequisitionStatusDescriptions
     *
     * @return array
     */
    public function getMaterialRequisitionStatusDescriptions() {

        switch($this->type) {
            case 'Super Admin':
            case 'Admin':
            case 'Admin Assistant':
            case 'Purchasing Staff':
            case 'Purchasing Manager':
            case 'Operations Staff':
            case 'Operations Manager':
            case 'Finance Officer':
            case 'Staff':
            case 'Project Officer':
                $statusDescriptions = array(
                    'New',
                    'Pending Purchasing Manager Approval',
                    'Pending Operations Division Manager Approval',
                    'Pending Finance Officer Approval',
                    'Pending Admin Approval',
                    'Active',
                    'Closed',
                    'Voided'
                );
                break;
            default:
                $statusDescriptions = array();
                break;
        }
        $statusDescriptions = array(
            'New',
            'Pending Purchasing Manager Approval',
            'Pending Operations Division Manager Approval',
            'Pending Finance Officer Approval',
            'Pending Admin Approval',
            'Active',
            'Closed',
            'Voided'
        );

        return $statusDescriptions;
    }

    /**
     * Get canvassStatusDescriptions
     *
     * @return array
     */
    public function getCanvassStatusDescriptions() {

        switch($this->type) {
            case 'Super Admin':
            case 'Admin':
            case 'Admin Assistant':
            case 'Purchasing Staff':
            case 'Purchasing Manager':
            case 'Operations Staff':
            case 'Finance Officer':
            case 'Operations Manager':
            case 'Project Officer':
                $statusDescriptions = array(
                    'Supplier Canvassing',
                    'Pending Finance Officer Approval For PO',
                    'Pending Admin Approval For PO',
                    'Approved',
                    'Voided',
                    'Cancelled'
                );
                break;
            default:
                $statusDescriptions = array();
                break;
        }

        $statusDescriptions = array(
            'Supplier Canvassing',
            'Pending Finance Officer Approval For PO',
            'Pending Admin Approval For PO',
            'Approved',
            'Voided',
            'Cancelled'
        );

        return $statusDescriptions;
    }

    /**
     * Get purchaseOrderStatusDescriptions
     *
     * @return array
     */
    public function getPurchaseOrderStatusDescriptions() {

        switch($this->type) {
            case 'Super Admin':
            case 'Admin':
            case 'Admin Assistant':
            case 'Purchasing Staff':
            case 'Purchasing Manager':
            case 'Operations Staff':
            case 'Operations Manager':
            case 'Finance Officer':
            case 'Project Officer':
                $statusDescriptions = array(
                    'New',
                    'Pending Finance Officer Signature For PO',
                    'Pending Operations Division Manager Signature For PO',
                    'Pending Final Admin Approval For PO',
                    'Approved',
                    'Sent',
                    'Received',
                    'Voided',
                    'Cancelled',
                    'Rejected'
                );
                break;
            default:
                $statusDescriptions = array();
                break;
        }

        $statusDescriptions = array(
            'New',
            'Pending Finance Officer Signature For PO',
            'Pending Operations Division Manager Signature For PO',
            'Pending Final Admin Approval For PO',
            'Approved',
            'Sent',
            'Received',
            'Voided',
            'Cancelled',
            'Rejected'
        );

        return $statusDescriptions;
    }

    /**
     * Get receivedOrderStatusDescriptions
     *
     * @return array
     */
    public function getReceivedOrderStatusDescriptions() {
        /*
                switch($this->type) {
                    case 'Super Admin':
                    case 'Admin':
                    case 'Admin Assistant':
                    case 'Purchasing Staff':
                    case 'Purchasing Manager':
                    case 'Operations Staff':
                    case 'Operations Manager':
                        $statusDescriptions = array(
                            'New',
                            'Sent',
                            'Received',
                            'Voided',
                            'Cancelled'
                        );
                        break;
                    default:
                        $statusDescriptions = array();
                        break;
                }*/

        $statusDescriptions = array(
            'New',
            'Sent',
            'Received',
            'Voided',
            'Cancelled'
        );

        return $statusDescriptions;
    }

    /**
     * Get purchaseInvoiceStatusDescriptions
     *
     * @return array
     */
    public function getPurchaseInvoiceStatusDescriptions() {

        switch($this->type) {
            case 'Super Admin':
            case 'Admin':
            case 'Admin Assistant':
            case 'Purchasing Staff':
            case 'Purchasing Manager':
            case 'Operations Staff':
            case 'Operations Manager':
            case 'Staff':
                $statusDescriptions = array(
                    'Pending',
                    'Pending Payment',
                    'Completed'
                );
                break;
            default:
                $statusDescriptions = array();
                break;
        }
        $statusDescriptions = array(
            'Pending',
            'Pending Payment',
            'Completed'
        );

        return $statusDescriptions;
    }

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

    /**
     * Set username
     *
     * @param string $username
     *
     * @return UserEntity
     */
    public function setUsername($username)
    {
        $this->username = $username;

        return $this;
    }

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

    /**
     * Set password
     *
     * @param string $password
     *
     * @return UserEntity
     */
    public function setPassword($password)
    {
        $this->password = $password;

        return $this;
    }

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

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

        return $this;
    }

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

    /**
     * Set isActive
     *
     * @param boolean $isActive
     *
     * @return UserEntity
     */
    public function setIsActive($isActive)
    {
        $this->isActive = $isActive;

        return $this;
    }

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

    /**
     * Set firstName
     *
     * @param string $firstName
     *
     * @return UserEntity
     */
    public function setFirstName($firstName)
    {
        $this->firstName = $firstName;

        return $this;
    }

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

    /**
     * Set middleName
     *
     * @param string $middleName
     *
     * @return UserEntity
     */
    public function setMiddleName($middleName)
    {
        $this->middleName = $middleName;

        return $this;
    }

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

    /**
     * Set lastName
     *
     * @param string $lastName
     *
     * @return UserEntity
     */
    public function setLastName($lastName)
    {
        $this->lastName = $lastName;

        return $this;
    }

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

    /**
     * Set fullName
     *
     * @param string $fullName
     *
     * @return UserEntity
     */
    public function setFullName($fullName)
    {
        $this->fullName = $fullName;

        return $this;
    }

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

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

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

        return $this;
    }

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

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

        return $this;
    }

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

    /**
     * Add accountUserReminder
     *
     * @param \RxConnexionBundle\Entity\AccountUserReminderEntity $accountUserReminder
     *
     * @return UserEntity
     */
    public function addAccountUserReminder(\RxConnexionBundle\Entity\AccountUserReminderEntity $accountUserReminder)
    {
        $this->accountUserReminders[] = $accountUserReminder;

        return $this;
    }

    /**
     * Remove accountUserReminder
     *
     * @param \RxConnexionBundle\Entity\AccountUserReminderEntity $accountUserReminder
     */
    public function removeAccountUserReminder(\RxConnexionBundle\Entity\AccountUserReminderEntity $accountUserReminder)
    {
        $this->accountUserReminders->removeElement($accountUserReminder);
    }

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

    /**
     * Add transferInventory
     *
     * @param \RxConnexionBundle\Entity\TransferInventoryEntity $transferInventory
     *
     * @return UserEntity
     */
    public function addTransferInventory(\RxConnexionBundle\Entity\TransferInventoryEntity $transferInventory)
    {
        $this->transferInventories[] = $transferInventory;

        return $this;
    }

    /**
     * Remove transferInventory
     *
     * @param \RxConnexionBundle\Entity\TransferInventoryEntity $transferInventory
     */
    public function removeTransferInventory(\RxConnexionBundle\Entity\TransferInventoryEntity $transferInventory)
    {
        $this->transferInventories->removeElement($transferInventory);
    }

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

    /**
     * Add canvassStatus
     *
     * @param \RxConnexionBundle\Entity\CanvassStatusEntity $canvassStatus
     *
     * @return UserEntity
     */
    public function addCanvassStatus(\RxConnexionBundle\Entity\CanvassStatusEntity $canvassStatus)
    {
        $this->canvassStatuses[] = $canvassStatus;

        return $this;
    }

    /**
     * Remove canvassStatus
     *
     * @param \RxConnexionBundle\Entity\CanvassStatusEntity $canvassStatus
     */
    public function removeCanvassStatus(\RxConnexionBundle\Entity\CanvassStatusEntity $canvassStatus)
    {
        $this->canvassStatuses->removeElement($canvassStatus);
    }

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

    /**
     * Add transferInventoryStatus
     *
     * @param \RxConnexionBundle\Entity\TransferInventoryStatusEntity $transferInventoryStatus
     *
     * @return UserEntity
     */
    public function addTransferInventoryStatus(\RxConnexionBundle\Entity\TransferInventoryStatusEntity $transferInventoryStatus)
    {
        $this->transferInventoryStatuses[] = $transferInventoryStatus;

        return $this;
    }

    /**
     * Remove transferInventoryStatus
     *
     * @param \RxConnexionBundle\Entity\TransferInventoryStatusEntity $transferInventoryStatus
     */
    public function removeTransferInventoryStatus(\RxConnexionBundle\Entity\TransferInventoryStatusEntity $transferInventoryStatus)
    {
        $this->transferInventoryStatuses->removeElement($transferInventoryStatus);
    }

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