<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
	<title>考勤信息管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		var validateForm;
		function doSubmit(){//回调函数，在编辑和保存动作时，供openDialog调用提交表单。
		  if(validateForm.form()){
			  $("#inputForm").submit();
			  return true;
		  }
	
		  return false;
		}
		$(document).ready(function() {
			validateForm = $("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
			
					laydate({
			            elem: '#startTime', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
			            event: 'focus' //响应事件。如果没有传入event，则按照默认的click
			        });
					laydate({
			            elem: '#endTime', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
			            event: 'focus' //响应事件。如果没有传入event，则按照默认的click
			        });
            //只做查看时，禁用掉以下标签
            $('input,textarea,select').attr('disabled',<%=request.getAttribute("disabled")%>);
		});
	</script>
</head>
<body class="hideScroll">
		<form:form id="inputForm" modelAttribute="oaAttendance" action="${ctx}/oa/oaAttendance/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>	
		<table class="table table-bordered  table-condensed dataTables-example dataTable no-footer">
		   <tbody>
				<tr>
					<td class="width-15 active"><label class="pull-right">公司：</label></td>
					<td class="width-35">
						<c:choose>
							<c:when test="${requestScope.disabled == 'true'}">
								${oaAttendance.company.name}
							</c:when>
							<c:otherwise>
								<sys:treeselect id="company" name="company.id" value="${oaAttendance.company.id}" labelName="company.name" labelValue="${oaAttendance.company.name}"
									title="部门" url="/sys/office/treeData?type=2" cssClass="form-control " allowClear="true" notAllowSelectParent="true"/>
							</c:otherwise>
						</c:choose>
					</td>
					<td class="width-15 active"><label class="pull-right">考勤规则：</label></td>
					<td class="width-35">
						<c:choose>
							<c:when test="${requestScope.disabled eq 'true'}">
								${oaAttendance.rule.startTime}
								--
								${oaAttendance.rule.endTime}
								&nbsp;&nbsp;
								(${oaAttendance.rule.workdays})
							</c:when>
							<c:otherwise>
								<sys:gridselect url="${ctx}/oa/oaAttendance/selectrule" id="rule" name="rule.id"  value="${oaAttendance.rule.id}"  title="选择考勤规则" labelName="rule.id"
								 labelValue="${oaAttendance.rule.id}" cssClass="form-control required" fieldLabels="id|name" fieldKeys="" searchLabel="id" searchKey="id" ></sys:gridselect>
							</c:otherwise>
						</c:choose>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">用户：</label></td>
					<td class="width-35">
						<c:choose>
							<c:when test="${requestScope.disabled == 'true'}">
								${oaAttendance.user.name}
							</c:when>
							<c:otherwise>
								<sys:treeselect id="user" name="user.id" value="${oaAttendance.user.id}" labelName="user.name" labelValue="${oaAttendance.user.name}"
									title="用户" url="/sys/office/treeData?type=3" cssClass="form-control " allowClear="true" notAllowSelectParent="true"/>
							</c:otherwise>
						</c:choose>
					</td>
					<td class="width-15 active"><label class="pull-right">备注信息：</label></td>
					<td class="width-35">
							<%--<form:textarea path="remarks" htmlEscape="false" rows="4"    class="form-control "/>--%>
							${oaAttendance.remarks}
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">上班时间：</label></td>
					<td class="width-35">
						<c:choose>
							<c:when test="${requestScope.disabled == 'true'}">
								<fmt:formatDate value="${oaAttendance.startTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
							</c:when>
							<c:otherwise>
								<input id="startTime" name="startTime" type="text" maxlength="20" class="laydate-icon form-control layer-date "
									   value="<fmt:formatDate value="${oaAttendance.startTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"/>
							</c:otherwise>
						</c:choose>
					</td>
					<td class="width-15 active"><label class="pull-right">上班情况：</label></td>
					<td class="width-35">
						<c:if test="${oaAttendance.morning==1}">正常打卡</c:if>
						<c:if test="${oaAttendance.morning==2}"><strong style="color: red">迟到</strong></c:if>
						<c:if test="${oaAttendance.morning==5}"><strong style="color: red">待打卡</strong></c:if>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">下班时间：</label></td>
					<td class="width-35">
						<c:choose>
							<c:when test="${requestScope.disabled == 'true'}">
								<fmt:formatDate value="${oaAttendance.endTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
							</c:when>
							<c:otherwise>
								<input id="endTime" name="endTime" type="text" maxlength="20" class="laydate-icon form-control layer-date "
									   value="<fmt:formatDate value="${oaAttendance.endTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"/>
							</c:otherwise>
						</c:choose>
					</td>
					<td class="width-15 active"><label class="pull-right">下班情况：</label></td>
					<td class="width-35">
						<c:if test="${oaAttendance.afternoon==1}">正常打卡</c:if>
						<c:if test="${oaAttendance.afternoon==3}"><strong style="color: red">早退</strong></c:if>
						<c:if test="${oaAttendance.afternoon==5}"><strong style="color: red">待打卡</strong></c:if>
					</td>
				</tr>
		 	</tbody>
		</table>
	</form:form>
</body>
</html>