<?php 
class CActionConfigActionField extends CActionBase
{
	function doAction()
	{
		$ret = 0;
		$job = $_POST["job"];
		switch($job)
		{
			case "add":
				$ret = $this->Add();
			break;
			case "mod":
				$ret = $this->Mod();
			break;
			case "del":
				$ret = $this->Del();
			break;
		}
		
		return $ret;
	}	
	
	function Add()
	{		
		return 0;
	}
	
	function Mod()
	{
		$action_id=$_POST["action_id"];
		$issue_typeid=$_POST["issue_typeid"];
		$rules = json_decode($_POST["rules"]);
		
		$sql = "delete from tb_project_field_edit where issue_type_id=".$issue_typeid." and action_id=".$action_id;
		$this->db->ExeSql($sql);
		
		for($i=0;$i<sizeof($rules);$i++)
		{
			$sql = "insert into tb_project_field_edit (issue_type_id, action_id, field_id, edit_rule) values (";
			$sql = $sql . $issue_typeid . ",";
			$sql = $sql . $action_id . ",";
			$sql = $sql . $rules[$i]->field_id . ",";
			$sql = $sql . $rules[$i]->edit_rule;
			$sql = $sql . ")";
			$this->db->ExeSql($sql);
		}
		
		return 0;
	}
	
	function Del()
	{
		return 0;
	}
	
};
?>
