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

class Home extends CI_Controller {

	public function __construct() 
	{
		parent::__construct();
		
		$this->lang->load('account_general', get_language());
		$this->load->model('member_model');
	}
	
	public function index()
	{
		save_current_url(base_url() . 'home/');
		
		if($this->session->userdata('user_type') && $this->session->userdata('user_type') == MEMBER) {
			$data = $this->member_model->get_member_account_details();
			$data['insurance_status'] = $this->member_model->get_member_insurance_status();
			
			if(isset($data['package_type'])) {
				$this->session->set_userdata('member_package_type', $data['package_type']);
			}
			
			if(isset($data['allowed_withdraw'])) {
				$this->session->set_userdata('member_allowed_withdraw', $data['allowed_withdraw']);
			}
			
			if(isset($data['unlimited_withdraw'])) {
				$this->session->set_userdata('member_unlimited_withdraw', $data['unlimited_withdraw']);
			}
			
			if(isset($data['allowed_transfer'])) {
				$this->session->set_userdata('member_allowed_transfer', $data['allowed_transfer']);
			}
			
			if(isset($data['allowed_convert'])) {
				$this->session->set_userdata('member_allowed_convert', $data['allowed_convert']);
			}
			
			if(isset($data['allowed_topup'])) {
				$this->session->set_userdata('member_allowed_topup', $data['allowed_topup']);
			}
			
			if(isset($data['active'])) {
				$this->session->set_userdata('member_active', $data['active']);
			}
			
			$data['highest_level'] = (($data['special_level'] > $data['level']) ? $data['special_level'] : $data['level']);
			$data['direct_downline'] = $this->member_model->get_direct_downlines();
			$data['all_downline'] = $this->member_model->get_all_downlines();
			
			$data['page_title'] = $this->lang->line('website_name') . ' | ' . $this->lang->line('hf_home');
			
			$this->load->view('home', $data);
		}
		else {
			redirect('', 'refresh');
		}
	}
	
	public function notice($type = NULL)
	{
		if($type == 3) {
			if( ! $this->session->userdata('lang') OR $this->session->userdata('lang') == 'zh-CN' OR $this->session->userdata('lang') == 'zh-HK'){
				echo '<img src="' . base_url() . 'assets/img/promo_cn_2.jpg" border="0" style="width: 100%;" />';
			}
			else {
				echo '<img src="' . base_url() . 'assets/img/promo_en_2.jpg" border="0" style="width: 100%;" />';
			}
		}
		else if($type == 2) {
			if( ! $this->session->userdata('lang') OR $this->session->userdata('lang') == 'zh-CN' OR $this->session->userdata('lang') == 'zh-HK'){
				echo '<img src="' . base_url() . 'assets/img/promo_cn.jpg" border="0" style="width: 100%;" />';
			}
			else {
				echo '<img src="' . base_url() . 'assets/img/promo_en.jpg" border="0" style="width: 100%;" />';
			}
		}
		else {
			$this->load->view('agreement');
		}	
	}
	
	public function agree()
	{
		$this->session->set_userdata('read_notice', 1);
	}
}

/* End of file home.php */
/* Location: ./application/controllers/home.php */