<?php 
class CIssueTypeInfo
{
	var $type_id;
	var $type_name;
	var $type_desc;
	var $flow_id;
	var $flow_name;
};

class CModuleIssueType extends CModuleBase
{
	function Init($project_id=0)
	{
		$sql = "select a.*, b.flow_name from tb_project_issue_type a, tb_flow b where project_id=".$project_id." and a.flow_id=b.flow_id order by 1";		
		$this->db->ExeQuerySql($sql);
	
		while($this->db->FetchRow())
		{			
			$mod = new CIssueTypeInfo();
			$mod->type_id		= $this->db->Get("issue_type_id");
			$mod->type_name	= $this->db->Get("issue_type_name");
			$mod->type_desc	= $this->db->Get("issue_type_desc");
			$mod->flow_id	= $this->db->Get("flow_id");
			$mod->flow_name	= $this->db->Get("flow_name");
			$this->modules[$this->GetSize()] = $mod;
		} 
		  
		$this->db->FreeResult();
	}   
	
	function InitModule($module_id)
	{
		$this->module = new CIssueTypeInfo();
		
		$sql = "select a.*, b.flow_name from tb_project_issue_type a, tb_flow b where a.issue_type_id=".$module_id."  and a.flow_id=b.flow_id order by 1";		
		$this->db->ExeQuerySql($sql);
	
		if($this->db->FetchRow())
		{
			$this->module->type_id		= $this->db->Get("issue_type_id");
			$this->module->type_name	= $this->db->Get("issue_type_name");
			$this->module->type_desc	= $this->db->Get("issue_type_desc");
			$this->module->flow_id	= $this->db->Get("flow_id");
			$this->module->flow_name	= $this->db->Get("flow_name");
		} 
		$this->db->FreeResult();   
	}
	
	function InitByUserID($user_id, $project_id)
	{
		$sql = "select a.*, b.flow_name from tb_project_issue_type a, tb_flow b where project_id=".$project_id." and a.flow_id=b.flow_id ";
		$sql = $sql . " and issue_type_id in ";
		$sql = $sql . "(";
		$sql = $sql . " select issue_type_id from tb_project_worker where ";
		$sql = $sql . " ( (member_type=0 and member_id=".$user_id.") or (member_type=1 and member_id in (select group_id from tb_project_group_member where user_id=".$user_id.")) )";
		$sql = $sql . " and action_id in (select action_id from tb_flow_action where src_status in (select chart_state_id from tb_flow_status where state_type=1) )";
		$sql = $sql . ")";
		$this->db->ExeQuerySql($sql);
	
		while($this->db->FetchRow())
		{			
			$mod = new CIssueTypeInfo();
			$mod->type_id		= $this->db->Get("issue_type_id");
			$mod->type_name	= $this->db->Get("issue_type_name");
			$mod->type_desc	= $this->db->Get("issue_type_desc");
			$mod->flow_id	= $this->db->Get("flow_id");
			$mod->flow_name	= $this->db->Get("flow_name");
			$this->modules[$this->GetSize()] = $mod;
		} 
		  
		$this->db->FreeResult();	
	}
	
};
?>
