<?php 

class CGroupMember
{
	var $user_id;
	var $user_name;
	var $real_name;
}

class CWorkGroupInfo
{
	var $group_id;
	var $group_name;
	var $group_desc;
	var $group_grade;
	var $group_members;
	
	function CWorkGroupInfo()
	{$this->group_members=array();}
	
	function InitMembers($db)
	{
		$sql = "select a.user_id, b.real_name, b.user_name from tb_project_group_member a, tb_user b where a.group_id=".$this->group_id." and a.user_id=b.user_id";
		$db->ExeQuerySql($sql);
		while($db->FetchRow())
		{
			$mod = new CGroupMember();
			$mod->user_id		= $db->Get("user_id");
			$mod->real_name = $db->Get("real_name");
			$mod->user_name	= $db->Get("user_name");
			$this->group_members[sizeof($this->group_members)] = $mod;
		}
		$db->FreeResult();
	}
};

class CModuleWorkGroup extends CModuleBase
{
	function Init($project_id=0)
	{
		$sql = "select * from tb_project_group where project_id=".$project_id." order by 1";		
		$this->db->ExeQuerySql($sql);
	
		while($this->db->FetchRow())
		{			
			$mod = new CWorkGroupInfo();
			$mod->group_id		= $this->db->Get("group_id");
			$mod->group_name	= $this->db->Get("group_name");
			$mod->group_desc	= $this->db->Get("group_desc");
			$mod->group_grade	= $this->db->Get("group_grade");
			$this->modules[$this->GetSize()] = $mod;
		} 
		$this->db->FreeResult();
		
		for($i=0;$i<sizeof($this->modules);$i++)
			$this->modules[$i]->InitMembers($this->db);
	}
	
	function InitModule($module_id)
	{
		$this->module = new CWorkGroupInfo();
		
		$sql = "select * from tb_project_group where group_id=".$module_id." order by 1";
		$this->db->ExeQuerySql($sql);
	
		if($this->db->FetchRow())
		{
			$this->module->group_id		= $this->db->Get("group_id");
			$this->module->group_name	= $this->db->Get("group_name");
			$this->module->group_desc	= $this->db->Get("group_desc");
			$this->module->group_grade	= $this->db->Get("group_grade");
		} 
		$this->db->FreeResult();
		
		$this->module->InitMembers($this->db);
	}
};
?>
