<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Email_setting extends MY_Controller{
	public function index(){
		$this->load->view($this->router->fetch_class()."/index");
	}
	
	public function update(){
		$this->load->model("email_setting_model");
		$post = $this->input->post();
		
		//To prevent loss---
		$this->fm->keep_all_page_filter();
		//------------------
		
		if($this->email_setting_model->edit($post)){
			$this->session->set_flashdata('success', "Update Successful!");
		}
		else{
			$this->session->set_flashdata('error', "Update Failed!");
		}
		
		redirect(base_url($this->router->fetch_class()."?".$this->session->flashdata($this->router->fetch_class().'_page_filter')));
	}
	
	public function load_data(){
		$this->load->model("email_setting_model");
		$post = $this->input->post();
		
//		print_r($post);

		$data = array();
		
		$main_condition = "";
		$sec_condition = "";
		
		$data_array = $this->email_setting_model->get_data();
		if(count($data_array) > 0) $data['data'] = $data_array[0];
		
		//Set parameter to avoid Filter Data lost---
		$this->session->set_flashdata($this->router->fetch_class().'_page_filter', $_SERVER['QUERY_STRING']);
		//------------------------------------------
		
		$this->load->view($this->router->fetch_class()."/load_data", $data);
	}
}