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


class Reguser_admin extends CI_Controller {
	
	private $id			=	''	; 
	private $uname		=	''	; 
	private $pword		=	''	; 
	private $error		=	'' 	;

	
	public function __construct()
	{
		parent::__construct();
		
		$this->load->library('loginfunctions');
		
		//logged out
		if($this->loginfunctions->checkloggedin()===FALSE)
		{
			redirect('Admin/') ;
		}
		else
		{
			$this->load->model('Db_model') ;
			
			$this->load->library(array('form_validation'));
		}

	}
	
	public function index()
	{
		$this->view();
	}

	
	public function view()
	{
		
		$result_array = array() ;
		$datas=array();
		if($this->Db_model->get_all_by_order('shop_location','location','asc')!==FALSE)
		{
			$loc_det = $this->Db_model->get_all_by_order('shop_location','location','asc');
		}
		else
		{
			$loc_det = array() ;
		}
		$data['loc_det'] = $loc_det;
		if( $this->Db_model->get_all_by_order('shop_checkoutusers','id','desc') !== FALSE )
		{
			$result_array= $this->Db_model->get_all_by_order('shop_checkoutusers','id','desc') ;
			
			
		}
			
		
			
				
		$data1=  array(
					  'page_name' => 'Registered Users' ,
					  'heading' => 'Registered Users' ,
					  'top_link_name' => '' ,
					  'top_link' =>  '' ,
					  'loc_det' => $data,
					  'result_array' => $result_array,
					  'datas'=>$datas
					 );
	
		
		$this->load->view('admin/home_header',$data1);
		$this->load->view('admin/menu');
		/*$this->load->view('admin/top_links',$data1);*/
		$this->load->view('admin/reguser_view',$data);
		$this->load->view('admin/footer');
	
	}
	
	private function _get_location($location)
	{
		if($this->Db_model->get_one('shop_location',array('lid '=>$location))!==FALSE)
		{
			$det = $this->Db_model->get_one('shop_location',array('lid '=>$location));
			
			return $det->location;
		}
		else
		{
			return '';
		}
	}
	
	
	
	
	
	public function delete($id='',$del=0)
	{
		if ($del==1)
		{	
		
			//delete all records in shop_order corresponding to this user
			$this->Db_model->delete('shop_order',array('user_id'=>$id));
			
			//delete all records in shop_shipdetails corresponding to this user
			$this->Db_model->delete('shop_shipdetails',array('user_id'=>$id));
			
			//delete record from `shop_checkoutusers`
			$this->Db_model->delete('shop_checkoutusers',array('id'=>$id));
			
			//redirect page to hide the id
			redirect('Reguser_admin/view') ;
		}
	}
	
	
private function get_location($location)
	{
		if($this->Db_model->get_one('shop_location',array('lid '=>$location))!==FALSE)
		{
			$det = $this->Db_model->get_one('shop_location',array('lid '=>$location));
			
			return $det->location;
		}
		else
		{
			return '';
		}
	}	
}//end class