Rev 12694 | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');class Productinfo extends MY_Controller {public $layoutName ='';function __construct() {// Call the CI_controller constructorparent::__construct();// $admin = $this->session->userdata('admin');// if(!isset($admin) || empty($admin)) {// redirect(base_url().'authorize');// }$this->layout->setlayout('layout/layout_main');$this->load->model('productinfo_model');$this->layoutName= $this->layout->getLayout();$this->layoutName =substr($this->layoutName , 0, strrpos($this->layoutName , "/")).'/';}public function index(){$authorized=$this->session->userdata('authorized');//standard array$data = array();//get cache$configdata =array();$configdata = $this->config->item('productinfo');$cachemodule = array('header','footer');$configdata = getCache($configdata,$cachemodule);//end of get cache//echo $this->uri->segment(2);$last = $this->uri->total_segments();$itemcode = $this->uri->segment($last);$originalCode = $itemcode;if (strpos($itemcode,'-') !== false) {$itemcode = explode('-', $itemcode);$itemcode = end($itemcode);}//print_r($itemcode);if(!is_numeric($itemcode)){redirect(base_url());}$productinfo = 'productinfo'.$itemcode;$cache = getFIleCache($productinfo);if(isset($cache) && !empty($cache)){$data['response'] = $cache;}else{$data['response']=$this->productinfo_model->getProducts($this->input->get(),$this->input->post(),$configdata['module'],$itemcode);if(isset($data['response']['response']['product_details']) && !empty($data['response']['response']['product_details']))setFileCache($data['response'], $productinfo,60);}$entity = $data['response']['response']['product_details'][0]->entity;if(!isset($entity)) {redirect(base_url());}elseif(isset($entity) && !empty($entity)){$id = $data['response']['response']['product_details'][0]->entity->id;$items = $data['response']['response']['product_details'][0]->entity->items;$i=0;foreach ($items as $item) {if(isset($item->sellingPrice) && !empty($item->sellingPrice)){$sellingPrice = $item->sellingPrice;}if(isset($item->mrp) && $item->mrp != 0){$mrp = $item->mrp;$discount = (($mrp - $sellingPrice)/$mrp);$discount = round($discount*100);$data['response']['response']['product_details'][0]->entity->items[$i]->discount = $discount;}if(isset($item->dealPojo) && !empty($authorized['isPrivateDealUser'])) {$mrp = $item->mrp;$discount = (($mrp - $item->dealPojo->dealPrice)/$mrp);$discount = round($discount*100);$data['response']['response']['product_details'][0]->entity->items[$i]->discount = $discount;$data['response']['response']['product_details'][0]->entity->items[$i]->dealPrice = $item->dealPojo->dealPrice;$data['response']['response']['product_details'][0]->entity->items[$i]->dealText = $item->dealPojo->dealText;}$i++;}if(!isset($id) || empty($id)){redirect(base_url());}$name = str_replace(' ', '-', $data['response']['response']['product_details'][0]->entity->name);$apiCode = strtolower($name.'-'.$id);$apicode = str_replace('-','',$apiCode);$originalCode = str_replace('-','',$originalCode);//echo $originalCode;if($itemcode == $id){//set cache to output or renew cacheif(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-detail.less','assets/css/pd-detail.css');$data['stylesheet'] = 'pd-detail.css';$title = $data['response']['response']['product_details'][0]->entity->title;if(isset($title) && !empty($title)){$data['title'] = $title;}$metaDescription = $data['response']['response']['product_details'][0]->entity->metaDescription;if(isset($metaDescription) && !empty($metaDescription)){$data['metaDescription'] = $metaDescription;}/*$subView = $this->session->userdata('subView');if(isset($subView) && !empty($subView)){$data['subView'] = $subView;}elseif(mt_rand(1,2) % 2){$data['subView'] = 'a';$this->session->set_userdata('subView','a');}else{$data['subView'] = 'b';$this->session->set_userdata('subView','b');}*/$data['subView'] = 'b';/* if(!empty($entity->exclusiveAffiliateInfo[0])) {$data['subView'] = 'c';}*///end of set cache$this->layout->view('productinfo/productinfo_view',$data);}else{$url = base_url().strtolower(get_class()).'/'.$apiCode;redirect($url);}}}function getDeliveryDetails($itemId,$pinCode){$url = $this->config->item('estimate_delivery');$url = $url['url'];$url = $this->config->item('curl_base_url').$url;$params = array();$params['itemId'] = $itemId;$params['pinCode'] = $pinCode;$this->mcurl->add_call('delivery','get',$url,$params);$response = $this->mcurl->execute($url);$data['response'] = $response['delivery']['response'];echo($data['response']);}function removeStuff($string) {return preg_replace('/[^a-zA-Z0-9]/', '', $string);}}/* End of file welcome.php *//* Location: ./application/controllers/welcome.php */