Subversion Repositories SmartDukaan

Rev

Rev 11811 | Rev 11845 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
11805 anikendra 1
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2
 
3
class Privatedeals extends MY_Controller {
4
 
5
public $layoutName ='';
6
	function __construct() {
7
		// Call the CI_controller constructor
8
		parent::__construct();		
9
		$authorized = $this->session->userdata('authorized');
10
		if(!isset($authorized) || empty($authorized)){
11
			redirect(base_url().'auth/login');
12
		}
13
		$this->layout->setlayout('layout/layout_main');
14
		$this->load->model('privatedeal_model');
15
		$this->load->model('magento_model');
16
		$this->layoutName= $this->layout->getLayout();
17
		$this->layoutName =substr($this->layoutName , 0, strrpos($this->layoutName , "/")).'/';
18
	}
19
 
20
	public function index()
21
	{
22
		$userId = $this->session->userdata['authorized']['Id'];
23
		$data = array();
24
		//get cache 
25
		$configdata =array();
26
		$configdata = $this->config->item('privatedeals');
27
		$name = $configdata['response'];
28
 
29
		foreach ($name as $key => $value) {
30
			$name = $value;
31
		}
32
		$cachemodule = array('header','footer');
33
		$configdata = getCache($configdata,$cachemodule);
34
 
35
		$data['response']=$this->privatedeal_model->getProducts('',$this->input->post(),$configdata['module'], $userId);
11813 anikendra 36
		if(isset($data['response']['response']['private_deals'][0]->response->redirectUrl)) {
37
	        redirect($data['response']['response']['private_deals'][0]->response->redirectUrl);
38
	        exit();
39
        }
11805 anikendra 40
		//set cache to output or renew cache
41
		if(isset($cachemodule) and !empty($cachemodule))
42
		{
43
			foreach($cachemodule as $cm)
44
			{
45
				if(isset($configdata[$cm]) and !empty($configdata[$cm]))
46
				{
47
					$data['response'][$cm]=$configdata[$cm];
48
				}
49
			}
50
		}
51
		setCache($configdata['module'],$cachemodule,$data['response']);
52
		$this->lessphp->object()->ccompile('assets/css/pd-list.less','assets/css/pd-list.css');
53
		$data['stylesheet'] = 'pd-list.css';
11811 anikendra 54
		//TODO: Get coupon code from api
55
		$data['response']['couponcode'] = "saholicdeal";
11805 anikendra 56
		$this->layout->view('privatedeals/products_view',$data);
57
	}
58
}