<?php

namespace OfficeBrain\CustomBundle\CmsBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;

/**
 * @author OfficeBrain 5069 <info@officebrain.com>
 *
 * Description : CMS Admin controller class
 *
 * @Route("/admin/{_locale}/cms/ordercatalog")
 **/
class OrderCatalogAdminController extends Controller
{
	private $request;
	
	private $session;
	
	private $translator;
	
	private $projectSetting;
	
	private $recordsPerPage;
	
	private $cmsUploadArtworkCenterManager;
	
	private $responseArray;
	
	public function __destruct()
	{
		unset($this->request);
		unset($this->session);
		unset($this->translator);
		unset($this->projectSetting);
	//	unset($this->cmsUploadArtworkCenterManager);
		unset($this->responseArray);
	}
	
	public function initAction()
	{
		$this->request = $this->getRequest();
		$this->session = $this->request->getSession();
		$this->translator = $this->get('translator');
		$this->projectSetting = $this->request->get('project_setting');
		$this->cmsOrderCatalog = $this->get('office_brain_cms_order_catalog_manager_custom');
		$this->responseArray = array();
	}
	/**
	 * @author Employee Id: 4242
	 * Description : Get the list of all order using ajax.
	 *
	 * @Route("/list/{instance_id}/{page}", name="office_brain_cmsbundle_ordercatalogadmin_pagelist",
	 * options={"expose"=true},
	 * requirements={"instance_id"="\d+", "page"="\d+"},
	 * defaults={"instance_id"="0", "page"=1})
	 *
	 * @Method("GET")
	 * @Template("OfficeBrainCustomBundleCmsBundle:OrderCatalogAdmin:orderCatalogList.html.twig")
	 *
	 * @return array
	 */
	public function orderCatalogListAction()
	{
		$this->initAction();
	
		$this->responseArray = $this->cmsOrderCatalog->getCmsOrderCatalogList();
		return $this->responseArray;
	}
	
	/**
	 * @author Employee Id: 4242
	 * Description : Get the list of all order using ajax.
	 *
	 * @Route("/list-ajax/{page}", name="office_brain_cmsbundle_ordercatalogadmin_pagelistajax",
	 * options={"expose"=true},
	 * requirements={ "page"="\d+"},
	 * defaults={ "page"=1})
	 *
	 * @Method("POST")
	 * @Template("OfficeBrainCustomBundleCmsBundle:OrderCatalogAdmin:orderCatalogListAjax.html.twig")
	 *
	 * @return array
	 */
	public function orderCatalogListAjaxAction()
	{
		$this->initAction();
	
		$this->responseArray = $this->cmsOrderCatalog->getCmsOrderCatalogList();
	
		return $this->responseArray;
	}
	
	/**
	 * @author Employee Id: 4242
	 *
	 * Description : Ajax base cms order  search
	 *
	 * @Route("/search/{page}", name="office_brain_cmsbundle_ordercatalogadmin_ordercatalogsearch",
	 * requirements={"page"="\d+"},
	 * options={"expose"=true},
	 * defaults={"page"=1})
	 *
	 * @Method("POST")
	 * @Template("OfficeBrainCustomBundleCmsBundle:OrderCatalogAdmin:orderCatalogListAjax.html.twig")
	 */
	public function cmsUploadArtworkCenterSearchAction()
	{
		$this->initAction();
	
		$this->responseArray = $this->cmsOrderCatalog->searchCmsOrderCatalogList();
	
		return $this->responseArray;
	}
	
	/**
	 * @author Employee Id: 5069
	 *
	 * Description : Soft delete order from database
	 *
	 * 
	 *
	 * @return type : Redirect to list page
	 *
	 * @throws Exception: Null
	 *
	 * @Route("/delete-order-catalog/{id}", name="office_brain_cmsbundle_ordercatalogadmin_orderdelete",options={"expose"=true})
	 *
	 * @Method("GET")
	 */
	public function deleteOrderCatalogAction($id)
	{
		$this->initAction();
	
		$this->cmsOrderCatalog->deleteOrderCatalogId($id);
	
		return $this->redirect($this->generateUrl('office_brain_cmsbundle_ordercatalogadmin_pagelist'));
	}
	
	/**
	 * @author Employee Id: 4242
	 *
	 *
	 *
	 * @throws Exception: Null
	 *
	 * @Route("/order-catalog-detail/{id}",
	 * name="office_brain_cmsbundle_ordercatalogadmin_ordercatalogdetail",
	 * options={"expose"=true}
	 * )
	 * @Template()
	 *
	 */
	public function orderCatalogDetailsAction($id)
	{
		$this->initAction();
	
		$this->responseArray = $this->cmsOrderCatalog->getCmsOrderCatalogDetail($id);
	
		return $this->responseArray;
	}
	
}
