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





function get_category_by_id($pcid='')

{

	$ci = & get_instance();

	

	$ci->load->model('db_model');

	

	$category='';

	

	$row = $ci->db_model->get_by_id('category','pcid',$pcid) ;

	

	if($row!==FALSE)

	{

		$category = $row->title ;	

	}

	

	return $category ;

}





function get_category_by_act($pcid='')

{

	$ci = & get_instance();

	

	$ci->load->model('db_model');

	

	$category='';

	

	$row = $ci->db_model->get_by_id('category','pcid',$pcid) ;

	

	if($row!==FALSE)

	{

		$category = $row->active ;	

	}

	

	return $category ;

}





function get_subcategory_by_id($id='')

{

	$ci = & get_instance();

	

	$ci->load->model('db_model');

	

	$subcategory='';

	

	$row = $ci->db_model->get_by_id('shop_subcategory','id',$id) ;

	

	if($row!==FALSE)

	{

		$subcategory = $row->title ;	

	}

	

	return $subcategory ;

}



function get_brand_by_id($id='')

{

	$ci = & get_instance();

	

	$ci->load->model('db_model');

	

	$brand='';

	

	$row = $ci->db_model->get_by_id('pages','aid',$id) ;

	

	if($row!==FALSE)

	{

		$brand = $row->title ;	

	}

	

	return $brand ;

}





function get_brand_by_act($id='')

{

	$ci = & get_instance();

	

	$ci->load->model('db_model');

	

	$brand='';

	

	$row = $ci->db_model->get_by_id('pages','aid',$id) ;

	

	if($row!==FALSE)

	{

		$brand = $row->active ;	

	}

	

	return $brand ;

}









function get_prdimg_from_aid($aid='')

{

	$ci = & get_instance();

	

	$ci->load->model('db_model');

	

	$img = '' ;

	

	$row_img = $ci->db_model->get_by_id('shop_image','aid',$aid);

	

	if($row_img !== FALSE)

	{

		$img = $row_img->tmb_img ;

	}

	

	return $img ;

	

}





function get_customer_by_id($id='')

{

	$ci = & get_instance();

	

	$ci->load->model('db_model');

	

	$customer='';

	

	$row = $ci->db_model->get_by_id('shop_checkoutusers','id',$id) ;

	

	if($row!==FALSE)

	{

		$customer = $row->first_name.' '.$row->last_name ;

		/*$customer.= ' <br />';

		$customer.= ' <label style="font-size:12px;">' ;

		$customer.= ' username : '.$row->username ;

		$customer.= ' <br /> ';

		$customer.= ' email : '.$row->email ;	

		$customer.= ' </label>';*/

	}

	

	return $customer ;

}	





function get_datetime($_24hr_format)

{

	list($date,$time) = explode(' ',$_24hr_format);

	list($yr,$mt,$dt) = explode('-',$date);

	$date = $dt.'-'.date("M", mktime(0,0,0,$mt,1,0)).'-'.$yr;

	$convertingtime = strtotime($time);

	$time = date("g:i:s A", $convertingtime); 

	

	return $date.' '.$time ;

}





function cat_list()

{

	$ci = & get_instance();

	

	$ci->load->model('db_model');

	

	$cat_list = $ci->db_model->get_all_by_order('shop_category','order','asc') ;

		

	if($cat_list!==FALSE)

	{

		return $cat_list ;

	}

	else

	{

		return array();

	}

}



function get_area_by_id($area_id = '')

{

	$ci = & get_instance();

	

	$ci->load->model('db_model');

	

	if($ci->db_model->get_one('shop_shipping',array('id'=>$area_id))!==FALSE)

	{

		$det = $ci->db_model->get_one('shop_shipping',array('id'=>$area_id));

		

		return $det->area;

	}

	else

	{

		return '';

	}

}





function encode_str($str = '')

{

	$ci = & get_instance();

	

	$ci->load->library('encrypt');

	

	return $ci->encrypt->encode($str);

	

}



function decode_str($str = '')

{

	$ci = & get_instance();

	

	$ci->load->library('encrypt');

	

	return $ci->encrypt->decode($str);

}