Rev 10691 | 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 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(){//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);}$id = $data['response']['response']['product_details'][0]->entity->id;$items = $data['response']['response']['product_details'][0]->entity->items;$i=0;foreach ($items as $item) {$sellingPrice = $item->sellingPrice;$mrp = $item->mrp;if(isset($mrp) && $mrp != 0){$discount = (($mrp - $sellingPrice)/$mrp);$discount = round($discount*100);$data['response']['response']['product_details'][0]->entity->items[$i]->discount = $discount;$i++;}}if(!isset($id) || empty($id)){redirect(base_url());}$title = str_replace(' ', '-', $data['response']['response']['product_details'][0]->entity->title);$apiCode = strtolower($title.'-'.$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';//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 */