<?php
namespace OfficeBrain\Bundle\PrioritizeSupplierBundle\Manager\AbstractManager;;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\DependencyInjection\ContainerInterface as Container;
use OfficeBrain\Bundle\PrioritizeSupplierBundle\Entity\PrioritizeSupplier;

abstract class PrioritizeSupplierAbstract
{
	protected $countryId;
	protected $countryCode;
	
	protected $languageId;
	protected $languageCode;
	
	protected $culture;
	protected $cultureAjax;
	protected $translatorManager;
	protected $translator;
	protected $paginationManager;
	protected $prioritizeSupplierRepositoryManager;
	public function __construct($entityManager, $request, $sessionManager,$paginationManager,$country,$language,$transalatorManager)
	{
		$this->entityManager = $entityManager;
		$this->request= $request;
		$this->sessionManager = $sessionManager;
		$this->paginationManager=$paginationManager;
		$this->translator = $transalatorManager;
		$this->country=$country;
		$this->language=$language;
		$this->projectSetting = $this->request->get('project_setting');
		$this->projectUserSetting = $this->request->get('project_user_setting');
		$this->instanceId = $this->projectSetting['instance_id'];
		$this->instanceType = $this->projectSetting['instance_type'];
		$this->userId = $this->projectSetting['user_id'];
		$this->cultureId = $this->projectSetting['culture_id'];
		$this->cultureCode = $this->projectSetting['culture_code'];
		$this->prioritizeSupplierRepositoryManager = $this->entityManager->getRepository('OfficeBrainPrioritizeSupplierBundle:PrioritizeSupplier');
		$this->prioritizeSupplierRepositoryManager->setPaginatorService($this->paginationManager);
		$this->prioritizeSupplierRepositoryManager->setProjectSetting($this->projectSetting);
		
		
	}
	public function getAllSupplierPrioritize($locale,$user,$page='',$recordPage='')
	{
		return $this->prioritizeSupplierRepositoryManager->findAllSupplierPrioritize($locale,$user,$page,$recordPage);	
	}
	public function savePrioritySupplier($prioritySupplier)
	{
		$position = '';
		$id = '';
		foreach($prioritySupplier as $key=>$val)
		{
			$id = $key;
			$position = $val;
			$this->prioritizeSupplierRepositoryManager->setValues($id, $position, $this->userId);
				
		}
	}
	
	/**
	 * @author Employee Id: 4571
	 *
	 * Description : Remove priority
	 *
	 * @param null
	 *
	 * @return result
	 *
	 * @throws null
	 *
	 **/
	public function removePrioritizeSupplier()
	{
		return $this->prioritizeSupplierRepositoryManager->remove($this->userId);		
	}
	
} 