Subversion Repositories SmartDukaan

Rev

Rev 11805 | Rev 11813 | 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);
11811 anikendra 36
		print_r($data['response']['private_deals']);
37
		if(isset($data['response']['private_deals'][0]->response->redirectUrl)) {
38
			redirect($data['response']['private_deals'][0]->response->redirectUrl);
39
			exit();
40
		}
11805 anikendra 41
		//set cache to output or renew cache
42
		if(isset($cachemodule) and !empty($cachemodule))
43
		{
44
			foreach($cachemodule as $cm)
45
			{
46
				if(isset($configdata[$cm]) and !empty($configdata[$cm]))
47
				{
48
					$data['response'][$cm]=$configdata[$cm];
49
				}
50
			}
51
		}
52
		setCache($configdata['module'],$cachemodule,$data['response']);
53
		$this->lessphp->object()->ccompile('assets/css/pd-list.less','assets/css/pd-list.css');
54
		$data['stylesheet'] = 'pd-list.css';
11811 anikendra 55
		//TODO: Get coupon code from api
56
		$data['response']['couponcode'] = "saholicdeal";
11805 anikendra 57
		$this->layout->view('privatedeals/products_view',$data);
58
	}
59
}