<%@page import="org.activiti.engine.repository.ProcessDefinition"%>
<%@page import="org.activiti.bpmn.model.*"%>
<%@page import="com.blueland.bpm.engine.config.model.*"%>
<%@page import="com.blueland.bpm.common.page.*"%>
<%@page import="com.blueland.bpm.common.util.*"%>
<%@page import="java.util.*"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib tagdir="/WEB-INF/tags/simpletable" prefix="simpletable"%>
<%@ include file="/commons/taglibs.jsp"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ include file="/commons/meta.jsp"%>
<base href="<%=basePath%>">
<title>环节用户列表</title>
	<link href="${ctx_js_plugins}/simpletable/simpletable.css" type="text/css" rel="stylesheet">
	<script type="text/javascript" src="${ctx_js_plugins}/simpletable/simpletable.js"></script>
<link href="${ctx}/resource/js/plugins/loadmask/jquery.loadmask.css" rel="stylesheet" type="text/css" />
<script type='text/javascript' src='${ctx}/resource/js/plugins/loadmask/jquery.loadmask.js'></script>

<script type="text/javascript">
	$(document).ready(function() {

	});

	function createActUser(values,names,actId) {
		var url="${ctx}/actInfo/setActResource/save.do";
		setMask("main-container");
		$.post(url, {"procDefId":$("#procDefId_"+actId).val(),"actId":$("#actId_"+actId).val(),"resourceStr":values},
				function (data){
					alert(data);
					window.location.reload();
			});
	}
	function deleteActUser(userTaskId) {
		if (!hasOneChecked("resources_"+userTaskId)) {
	    	alert('请选择要操作的对象!');
	        return;
	    }
	    if(!window.confirm('确定执行[删除]操作?')){
		   return;
	    }
	    setMask("main-container");
		var url="${ctx}/actInfo/setActResource/deleteForResourcesManage.do";
		var resources = getCheckedItem(userTaskId);
		$.post(url,{"procDefId":$("#procDefId_"+userTaskId).val(),"actId":userTaskId,"resources":resources.toString()},
				function (data){
					alert(data);
					window.location.reload();
				}
		);
		
	}
	
	function getCheckedItem(userTaskId){
		var chk_value =[]; 
		$('input[name="resources_'+userTaskId+'"]:checked').each(function(){ 
			chk_value.push($(this).val()); 
		}); 
		//alert(chk_value.length==0 ?'你还没有选择任何内容！':chk_value); 
		return chk_value;
		//alert(chk_value.length==0 ?'你还没有选择任何内容！':chk_value); 
	}
</script>
</head>
<body id="content" class="white-page">
	<%@ include file="/commons/messages.jsp"%>
	<form id="queryForm" name="queryForm"
		action="${ctx}/actInfo/setActResource/setAllResourcelist.do" method="post"
		style="width: 100%; height: 100%;display: inline;">
		<div class="main-container" id="main-container" style="overflow: auto;width: 100%; height: 800px;">
		<c:forEach items="${result}" var="item">
				<input name="actId" id="actId_${item.userTask.id}" value="${item.userTask.id}" type="hidden"/>
				<input name="procDefId" id="procDefId_${item.userTask.id}" value="${procDefId}" type="hidden"/>
				<div class="panel panel-primary panel-1">
					<div class="panel-heading">
						当前节点：${item.userTask.name}(${item.userTask.id})
					</div>
					<div class="panel-body" style="padding:3px;">
						<div class="well well-sm no-padding no-margin">
	
							<table border="0" cellspacing="0" cellpadding="0"
								class="table-search">
					<tr>
						<td colspan="6">
							<button type="button" onclick="showDiaLog('${ctx}/pages/user_org_select.jsp?orgId=0&showTreeType=USER&actId=${item.userTask.id}', '新增环节人员', '850px', '600px');" class="btn btn-xs btn-success">
								新&nbsp;&nbsp;增
								<i class="ace-icon fa fa-plus bigger-110"></i>
							</button>
							<button type="button" onclick="deleteActUser('${item.userTask.id}');" class="btn btn-xs btn-danger">
								删&nbsp;&nbsp;除
								<i class="ace-icon fa fa-trash-o bigger-110"></i>
							</button>
						</td>
					</tr>
				</table>
				</div>
			<div class="row">
				<div class="col-xs-12">
					<div class="table-responsive no-padding no-margin">
						<table id="sample-table-1"
							class="table table-striped table-bordered table-hover">
							<thead>
								<tr>
									<th style="width:25px;"><input type="checkbox" onclick="setAllCheckboxState('resources_${item.userTask.id}',this.checked)"></th>	
									<th style="width: 100px;">资源类型</th>
									<th>资源名称</th>
									<th style="width: 200px;">资源值</th>
								</tr>
							</thead>
							<tbody>
								<c:forEach items="${item.activityResources}" var="item1" varStatus="status">
									<tr class="${status.count % 2 == 0 ? 'odd' : 'even'}">
										<td><input type="checkbox" name="resources_${item.userTask.id}" value="${item1.type}#${item1.id}"></td>
										<td>${item1.parentId}</td>
										<td>${item1.name}&nbsp;</td>
										<td>${item1.remark}</td>
									</tr>
								</c:forEach>
							</tbody>
						</table>
					</div>
				</div>
			</div>
		</div>
	</div>
</c:forEach>
</div>
		
		
		
		
	</form>
</body>
</html>