<%@page import="com.blueland.bpm.engine.config.model.*" %>
<%@page import="com.blueland.bpm.common.page.*" %>
<%@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" %>
<jsp:include page="/commons/userOrgTree.jsp" flush="true" />
<%
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>


	<script type="text/javascript" >
		$(document).ready(function() {
			// 分页需要依赖的初始化动作
			window.simpleTable = new SimpleTable('queryForm',${page.thisPageNumber},${page.pageSize},'${pageRequest.sortColumns}');
		});
		function createDepute(url,title,width,height){
			if("" == $("#userId").val() || null == $("#userId").val()){
				alert("请输入委托人的ID！");
				return;
			}else{
				var url = url+"?userId="+$("#userId").val();
				showDiaLog(url,title,width,height);
			}		
		}
		function deputeUserNameOnDbClick(name, value) {
			$("#deputeUserName").val(name);
			$("#deputeUserId").val(value);
		}
		function mandataryUserNameOnDbClick(name, value) {
			$("#mandataryUserName").val(name);
			$("#mandataryUserId").val(value);
		}
	</script>
</head>
<body>
	<%@ include file="/commons/messages.jsp"%>
	<form id="queryForm" name="queryForm"
		action="${ctx}/depute/list.do" method="post"
		style="display: inline;">
		<div class="main-container" id="main-container">
			<div class="panel panel-primary">
				<div class="panel-heading">
					委托代办设置
				</div>
				<div class="panel-body" id="panel-body" style="padding:3px;">
					<div class="well well-sm" style="margin-bottom: 2px;">

						<table border="0" cellspacing="0" cellpadding="0" class="table-search">
							<tbody>		
											
								<tr colspan="7">
									<td>
										委托人ID：<input type="text" id="userId" name="userId"  style="height:25px;margin-right: 2px;"/>
										<button type="button" class="btn btn-xs btn-success" 
											onclick="createDepute('${ctx}/depute/backCreate.do','新增委托代办','600px','400px');">
												新增
												<i class="ace-icon fa fa-plus bigger-110"></i>
										</button>
									</td>
								</tr>
								
								<tr colspan="7">
									<td style="letter-spacing: 3.2px;">
										<input type="hidden" id="deputeUserId" name="deputeUserId"/>
										委托人：<input type="text" id="deputeUserName" name="deputeUserName" value="${query.deputeUserName}" style="margin-right: 2px;height:25px;" onclick="showUserOrg('deputeUserName','','','USER'); return false;" readonly />
										<input type="hidden" id="mandataryUserId" name="mandataryUserId"/>
										被委托人：<input type="text" id="mandataryUserName" name="mandataryUserName"  value="${query.mandataryUserName}" style="height:25px;" onclick="showUserOrg('mandataryUserName','','','USER'); return false;" readonly/>
										<button type="submit" class="btn btn-xs btn-primary" 
										onclick="getReferenceForm(this).action='${ctx}/depute/list.do'">
												查&nbsp;&nbsp;询
												<i class="ace-icon fa fa-search bigger-110"></i>
										</button>
										<!-- <button type="submit" class="btn btn-xs btn-success" 
										onclick="getReferenceForm(this).action='${ctx}/depute/create.do'"> -->								
										
										<button type="button" class="btn btn-xs btn-danger" 
										onclick="batchDelete('${ctx}/depute/delete.do','items',document.forms.queryForm)">
											删除
											<i class="ace-icon fa fa-trash-o bigger-110"></i>
										</button>							
									</td>
								</tr>								
								
						</tbody>
					</table>
				</div>
			
			<div class="row">
				<div class="col-xs-12">
					<div class="table-responsive">
						<table id="sample-table-1" class="table table-striped table-bordered table-hover">
					<thead>
					  <tr>
						<th style="width:25px;"><input type="checkbox" onclick="setAllCheckboxState('items',this.checked)"></th>
						<!-- 排序时为th增加sortColumn即可,new SimpleTable('sortColumns')会为tableHeader自动增加排序功能; -->
						<th sortColumn="roleName" >委托类型</th>
						<th sortColumn="roleId" >委托人</th>
						<th sortColumn="roleId" >被委托人</th>
						<!-- 
						<th sortColumn="roleSort" width="300px">起止时间</th> -->
						<th sortColumn="roleAppId">委托流程</th>						
						<th sortColumn="roleAppId">委托状态</th>
					  </tr>
					</thead>
				<tbody>
		  
		   		<c:forEach items="${page.result}" var="item" varStatus="status">
			  		<tr class="${status.count % 2 == 0 ? 'odd' : 'even'}">
						<td><input type="checkbox" name="items" value="deputeId=${item.deputeId}&"></td>
						<td class="td" title="${item.deputeTypeVal}">${item.deputeTypeVal}&nbsp;</td>
						<td class="td" title="${item.deputeUserName}">${item.deputeUserName}&nbsp;</td>
						<td class="td" title="${item.mandataryUserName}">${item.mandataryUserName}&nbsp;</td>
						 <!-- <td>从${item.startTimeString}&nbsp;至${item.endTimeString}</td>-->
						<td class="td" title="${item.processDefName}&nbsp;">${item.processDefName}&nbsp;</td>
					
						<td class="td" title="${item.deputeStatusVal}&nbsp;"><span class="label label-success">${item.deputeStatusVal}&nbsp;</span></td>
						
					 </tr>
			  
		  	  </c:forEach>
				</tbody>
				</table>
				<simpletable:pageToolbar page="${page}">
				</simpletable:pageToolbar>
			</div>
						<!-- /.table-responsive -->
					</div>
					<!-- /span -->
				</div>
			</div>
		</div>
		</div>
		</form>
</body>
</html>	
