Subversion Repositories SmartDukaan

Rev

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

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Privatedeals extends MY_Controller {

public $layoutName ='';
        function __construct() {
                // Call the CI_controller constructor
                parent::__construct();          
                $authorized = $this->session->userdata('authorized');
                if(!isset($authorized) || empty($authorized)){
                        redirect(base_url().'auth/login');
                }
                $this->layout->setlayout('layout/layout_main');
                $this->load->model('privatedeal_model');
                $this->load->model('magento_model');
                $this->layoutName= $this->layout->getLayout();
                $this->layoutName =substr($this->layoutName , 0, strrpos($this->layoutName , "/")).'/';
        }

        public function index()
        {
                $userId = $this->session->userdata['authorized']['Id'];
                $data = array();
                //get cache 
                $configdata =array();
                $configdata = $this->config->item('privatedeals');
                $name = $configdata['response'];

                foreach ($name as $key => $value) {
                        $name = $value;
                }
                $cachemodule = array('header','footer');
                $configdata = getCache($configdata,$cachemodule);
                
                $data['response']=$this->privatedeal_model->getProducts('',$this->input->post(),$configdata['module'], $userId);
                if(isset($data['response']['response']['private_deals'][0]->response->redirectUrl)) {
                redirect($data['response']['response']['private_deals'][0]->response->redirectUrl);
                exit();
        }
                //set cache to output or renew cache
                if(isset($cachemodule) and !empty($cachemodule))
                {
                        foreach($cachemodule as $cm)
                        {
                                if(isset($configdata[$cm]) and !empty($configdata[$cm]))
                                {
                                        $data['response'][$cm]=$configdata[$cm];
                                }
                        }
                }
                setCache($configdata['module'],$cachemodule,$data['response']);
                $this->lessphp->object()->ccompile('assets/css/pd-list.less','assets/css/pd-list.css');
                $data['stylesheet'] = 'pd-list.css';
                //TODO: Get coupon code from api
                $data['response']['couponcode'] = "saholicdeal";
                $this->layout->view('privatedeals/products_view',$data);
        }
}