<?php 
class CActionConfigProjectIssuetype 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()
	{
		$project_id	 = $_POST["project_id"];
		$flow_id	 = $_POST["flow_id"];
		$type_name	 = $_POST["type_name"];
		$type_desc = $_POST["type_desc"];
		
		$type_id = $this->db->GetMaxField('tb_project_issue_type', 'issue_type_id')+1;
		$sql = "insert into tb_project_issue_type (issue_type_id, project_id, flow_id, issue_type_name, issue_type_desc) values (";
		$sql = $sql . $type_id . ",";
		$sql = $sql . $project_id . ",";
		$sql = $sql . $flow_id . ",";
		$sql = $sql . "'".$type_name."',";
		$sql = $sql . "'".$type_desc."'";
		$sql = $sql . ")";
		//return $sql;
		$this->db->ExeSql($sql);
		return 0;
	}
	
	function Mod()
	{
		$type_id	 = $_POST["type_id"];
		$flow_id	 = $_POST["flow_id"];
		$type_name	 = $_POST["type_name"];
		$type_desc = $_POST["type_desc"];
		
		$sql = "update tb_project_issue_type set ";
		$sql = $sql . "issue_type_name ='".$type_name."',";
		$sql = $sql . "issue_type_desc ='".$type_desc."',";
		$sql = $sql . "flow_id = ".$flow_id;		
		$sql = $sql . " where issue_type_id=".$type_id;
		$this->db->ExeSql($sql);
		return 0;
	}
	
	function Del()
	{
		$type_id = $_POST["type_id"];
		$sql = "delete from tb_project_worker where issue_type_id=".$type_id;
		$this->db->ExeSql($sql);
		
		$sql = "delete from tb_project_field_edit where issue_type_id=".$type_id;
		$this->db->ExeSql($sql);
		
		$sql = "delete from tb_project_issue_type where issue_type_id=".$type_id;
		$this->db->ExeSql($sql);
		return 0;
	}
	
};
?>
