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

class Quick_order extends CI_Controller {


	private $cart_qty   = '' ;
	private $logged 	= 0  ;	
	private $user 		= '' ;
	
	public function __construct()
	{
		parent::__construct();
		
		$this->load->model('Db_model');
		
		$this->load->library('cart');
		
		$this->load->helper('basic_helper');
		$ic=0;
		foreach ($this->cart->contents() as $items):
		$ic++;
		
		endforeach;
		$this->cart_qty = ''.$ic.'';
		
		if($this->session->userdata('shop_user2'))
		{
			$this->load->library('encrypt') ;
			$this->user = $this->encrypt->decode($this->session->userdata('shop_user2'));
			$this->logged = 1;
		}
		
	}
	
	public function index()
	{	
		
		$data['product'] = array();
		$data['preproduct'] = array();
		$data['result']= array();
		$data['categoryes']=array();
		$data['subcategoryquick']=array();
		$data['cart_qty'] = $this->cart_qty ;
		$data['brand_id'] = $this->brand_id ;
		$data['email'] = $this->user;
		$data['logged'] = $this->logged;
		
		$data['allproduct']= $this->Db_model->get_where_by_order('shop_product',array('active'=>'Y'),'order','asc') ;
        $data['brand'] = $this->Db_model->get_where_by_order('shop_brand',array(),'order','asc') ;
		$data['contactus'] = $this->Db_model->get_where_by_order('shop_contact',array('status'=>'1'),'id','desc') ;
		$data['site'] = $this->Db_model->get_all('site',array()) ;
		$data['service'] = $this->Db_model->get_where_by_order('shop_pages',array('active'=>'Y','type'=>'service'),'order','asc') ;
		$data['category']=$data['result'] = $this->Db_model->get_where_by_order('shop_category',array(),'order','asc') ;
		$data['subcategoryquick'] = $this->Db_model->get_where_by_order('shop_subcategory',array(),'id','asc') ;	
		$data['gift'] = $this->Db_model->get_where_by_order('shop_category',array(),'order','asc') ;

		
		
		if($product!==FALSE)
		{
		$data['product'] = $product;
	
		}
		
		

		
		
		
		$this->load->view('website/header',$data);
        $this->load->view('website/menu',$data);
		$this->load->view('website/quickorder',$data);
        $this->load->view('website/footer');
	}
	
	public function sub_categories_products()
	{	
		$sub_categories=$this->input->post('sub_categories');
		$sub_categories_products= $this->Db_model->get_where_by_order('shop_product',array('subcategory_id'=>$sub_categories),'aid','asc') ;
		echo json_encode($sub_categories_products);
	}
	
	
	
	

}
