<?php

namespace OfficeBrain\Bundle\QuoteBundle\Entity;

use Doctrine\ORM\EntityRepository;

/**
 * QuoteSupplierContactMappingRepository
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class QuoteSupplierContactMappingRepository extends EntityRepository
{
	
	protected $projectSetting;
	protected $instanceId;
	protected $instanceType;
	protected $cultureId;
	protected $cultureCode;
	protected $projectSettingService;
	protected $projectUserSetting;
	
	
	public function getProjectSetting()
	{
		return $this->paginatorService;
	}
	
	/**
	 * @author Employee Id: 4493
	 * OB eCommerce Product - setProjectSetting
	 * Function created to set Project Setting
	 */
	public function setProjectSetting($projectSetting)
	{
		$this->projectSetting = $projectSetting;
		$this->prepareProjectSettingData();
	}
	
	public function setProjectUserSetting($projectUserSetting)
	{
		$this->projectUserSetting = $projectUserSetting;
		$this->prepareProjectUserSettingData();
	}
	
	public function getProjectUserSetting()
	{
		return $this->projectUserSetting;
	}
	
	public function prepareProjectSettingData()
	{
		$this->userId = $this->projectSetting['user_id'];
		$this->createdUid = $this->upatedUid = $this->userId;
		$this->instanceId = $this->projectSetting['instance_id'];
		$this->instanceType = $this->projectSetting['instance_type'];
		$this->cultureId = $this->projectSetting['culture_id'];
		$this->cultureCode = $this->projectSetting['culture_code'];
	}
	public function prepareProjectUserSettingData()
	{
		$this->user = $this->projectUserSetting['user_data'];
	}
	
	
	
	
	/**
	 * @author Employee Id: 4493
	 * OB eCommerce Product - Quote User Contact Mapping
	 * Function created for Quote User Contact Mapping
	 */
	
	public function addQuoteDistributorContact($addQuoteUserContact)
	{
		$this->getEntityManager()->persist($addQuoteUserContact);
		$this->getEntityManager()->flush();
		return $addQuoteUserContact;
	
	}
	
	/**
	 * @author Employee Id: 4493
	 * OB eCommerce Product - Quote Supplier Contact Info
	 * Function created for Quote Supplier Contact Info
	 */
	
    public function getQuoteSupplierContact($quoteId)
	{
		$query=$this->createQueryBuilder('qs');
		$query->where("qs.quoteMasterId =:quoteId")->setParameter('quoteId',$quoteId);		
		$result = $query->getQuery()->getResult();
		return  $result[0];
		
	}
	

	/**
	 * @author Employee Id: 4493
	 * OB eCommerce Product - Quote supplier edit
	 * Function created for Quote supplier  edit
	 */
	
	public function editQuoteSupplier($quoteUserObj,$userPhoto)
	{
		$quoteUserObj->setPhoto($userPhoto);
		$this->getEntityManager()->persist($quoteUserObj);
		$this->getEntityManager()->flush();
		return $quoteUserObj;
	
	}
	
	
	
}
