<?php
$job = 'add';
$title = '新增工作组';
$group_id=0;
$group_name='';
$group_desc='';
$group_grade=0;
$project_id=$_REQUEST['project_id'];

if(array_key_exists("job", $_REQUEST))
	$job = $_REQUEST['job'];

require_once('../module/module.project_workgroup.php');
$group = new CModuleWorkGroup();

if($job=='mod')
{
	$title = '修改工作组';
	$group_id=$_REQUEST['group_id'];
	
	$group->InitModule($group_id);
	if($group->module != '')
	{
		$group_name = $group->module->group_name;
		$group_desc = $group->module->group_desc;
		$group_grade = $group->module->group_grade;
	}
}

require_once('../module/module.dept.php');
$depts = new CModuleDept();
$depts->Init();
?>
<input type='hidden' id='project_id' value='<?php echo $project_id?>'>
<input type='hidden' id='group_id' value='<?php echo $group_id?>'>
<table border=0 cellspacing='1' cellpadding='0' width=100% bgcolor='#ffffff'>
	<tr bgcolor="#efefef" height=20>
		<td colspan=2>
			<b><span id="project_form_desc"><?php echo $title?></span></b>
			<hr size=1>
		</td>
	</tr>
	<tr>
		<td align=right width=80>工作组名称:</td>
		<td><input type=text id="group_name" class=txtput value='<?php echo $group_name?>'></td>
	</tr>
	<tr height=30>
		<td align=right>描述:</td>
		<td><input type=text id="group_desc" class=txtput size=40 value='<?php echo $group_desc?>'></td>
	</tr>
	<tr height=30>
		<td align=right>权限:</td>
		<td>
			<?php for($i=0;$i<sizeof($Config["issue_grade"]);$i++){
				if($i % 4 == 0 && $i>0) echo "<br>";
			?>
				<input type=checkbox value="<?php echo $Config["issue_grade"][$i]?>" <?php if($Config["issue_grade"][$i]&$group_grade) echo "checked"?>><?php echo $Config["issue_grade_name"][$i]?>
			<?php }?>
		</td>
	</tr>
	<tr height=30>
		<td align=right valign='top'>成员:</td>
		<td>
			<!------------------------------------------------------------------------------------------------>
			<table>
				<tr>
					<td align=right>
						<select class=box size=10 id="dept_members" multiple="multiple">
							<option value="-1">------请选择用户------</option>
						</select><br>
						<select class=box onchange="CallDeptMember()" id="dept_id">
							<option value=-1>------请选择部门------</option>
							<?php for($i=0;$i<$depts->GetSize();$i++){?><option value="<?php echo $depts->modules[$i]->dept_id?>"><?php echo $depts->modules[$i]->dept_name?></option><?php }?>
						</select>
					</td>
					<td align=center>
						<input type=button value=" 增加 " class=box onclick="AddGroupMember()">
						<br><br>
						<input type=button value=" 删除 " class=box onclick="DelGroupMember()">
					</td>
					<td valign="top">
						<select class=box size=10 id="group_members" multiple="multiple">
							<option value=-1>------工作组成员------</option>
							<?php for($i=0;$i<sizeof($group->module->group_members); $i++){?>
								<option value=<?php echo $group->module->group_members[$i]->user_id?>> <?php echo $group->module->group_members[$i]->real_name?> </option>
							<?php }?>
						</select>
					</td>
				</tr>
			</table>
			<!------------------------------------------------------------------------------------------------>
		</td>
	</tr>

	<tr height=40>
		<td colspan=2 bgcolor="#efefef" align=center>
				<input type=button value=" 提交 " class=button onclick="SubmitWorkGroup('<?php echo $job?>')">
				&nbsp;&nbsp;&nbsp;&nbsp;
				<input type=button value=" 取消 " class=button onclick="CloseDialog(0)">
		</td>
	</tr>
</table>