<?php if( ! defined('BASEPATH')) exit('No direct script access allowed');
class Email_template_model extends Model
{
	function Email_template_model()
	{
		parent::Model();
	}
	
	function get_record($id)
	{
		$query=$this->db->get_where("shop_email_template",array('id'=>$id));
		if($query->num_rows()>0)
		{
			return $query->row_array();
		}
	}
	
	function save_record()
	{
		$rd_id=$this->input->post("rd_id");
		$data=array(
			'title'=>$this->input->post("title"),
			'status'=>$this->input->post("status")?1:0,
			'content'=>$this->input->post("content")
		);
		$this->db->update("shop_email_template",$data,array('id'=>$rd_id));
		return TRUE;
	}

	function ajax_toggle()
	{
		$rd_id=$this->input->post('rd_id');
		$query=$this->db->get_where("shop_email_template",array('id'=>$rd_id));
		$rs=$query->row_array();
		$data=$rs['status']?0:1;
		$this->db->update('shop_email_template',array('status'=>$data),array('id'=>$rd_id));
		return TRUE;
	}
}
?>