<%@ 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(obj){//回调函数，在编辑和保存动作时，供openDialog调用提交表单。
		  if(validateForm.form()){
              if(obj == 2){
                  var id = $("#id").val();
                  $.ajax({
                      type:'post',
                      url:'${ctx}/workattendance/workAttendanceCount/store',
                      data:{
                          "id":id
                      },
                      success:function(data){
                          parent.layer.msg(data.msg,{icon:1});
                          window.location= "${ctx}/workattendance/workAttendanceCount/form?id="+id+"&home=home";
                      }
                  })
                  return true;
              }else{
                  $("#inputForm").attr("action","${ctx}/workattendance/workAttendanceCount/save");
                  $("#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);
					}
				}
			});
			
		});
	</script>
</head>
<body>
<div class="single-form">
	<div class="container view-form">
		<form:form id="inputForm" modelAttribute="workAttendanceCount" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>
		<div class="form-group layui-row first">
				<div class="form-group-label"><h2>基本信息</h2></div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label">月    份:</label>
					<div class="layui-input-block with-icon">
						<form:input path="attendanceMonth" htmlEscape="false" readonly="true" maxlength="30" class="form-control layui-input required"/>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label">部    门:</label>
					<div class="layui-input-block">
						<form:input path="office.name" htmlEscape="false" readonly="true"  class="form-control layui-input "/>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label">部门人数:</label>
					<div class="layui-input-block with-icon">
						<form:input path="officeCount" htmlEscape="false" readonly="true" minlength="1" maxlength="3" class="form-control number layui-input "/>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label">考勤人数:</label>
					<div class="layui-input-block">
						<form:input path="attendanceCount" htmlEscape="false" readonly="true"   class="form-control number layui-input "/>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label">考勤截止日:</label>
					<div class="layui-input-block">
						<input htmlEscape="false" readonly="true"  class="form-control layui-input" value="<fmt:formatDate value="${workAttendanceCount.attendanceEndDate}" pattern="yyyy-MM-dd"/>"/>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label">确认时间:</label>
					<div class="layui-input-block">
						<input htmlEscape="false" readonly="true"  class="form-control layui-input" value="<fmt:formatDate value="${workAttendanceCount.attendanceDate}" pattern="yyyy-MM-dd"/>"/>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label">确认人:</label>
					<div class="layui-input-block">
						<form:input path="user.name" htmlEscape="false" readonly="true"  class="form-control layui-input"/>
					</div>
				</div>
			</div>
		<div class="form-group layui-row">
				<div class="form-group-label"><h2>考勤明细</h2></div>
				<div class="layui-item layui-col-xs12 form-table-container">
					<table id="userTable2" class="table table-bordered table-condensed details">
						<thead>
						<tr>
							<th>工号</th>
							<th>姓名</th>
							<th>是否考勤</th>
							<th width="120px">应出勤天数(天)</th>
							<th width="120px">实出勤天数(天)</th>
							<th>内勤(天)</th>
							<th>外勤(天)</th>
							<th>出差(天)</th>
							<th>加班(天)</th>
							<th>旷工(天)</th>
							<th>迟到(天)</th>
							<th>早退(天)</th>
							<th >请假(天)</th>
						</tr>
						</thead>
						<tbody id="workAttendanceMonths">
						<c:if test="${not empty workAttendanceCount.workAttendanceMonths}">
							<c:forEach items="${workAttendanceCount.workAttendanceMonths}" var="workAttendanceMonth" varStatus="index">
								<tr id="workAttendanceMonths${index.index}">
									<td>
										<a  href="javascript:void(0)" onclick="openDialogView('考勤详情', '${ctx}/workattendance/workAttendanceInfo/view?staffId=${workAttendanceMonth.staffId}&month=${workAttendanceCount.attendanceMonth}&home=${workAttendanceCount.home}','90%', '90%')">
												${workAttendanceMonth.workStaffBasicInfo.no}
										</a>
									</td>
									<td>
										<a  href="javascript:void(0)" onclick="openDialogView('考勤详情', '${ctx}/workattendance/workAttendanceInfo/view?staffId=${workAttendanceMonth.staffId}&month=${workAttendanceCount.attendanceMonth}&home=${workAttendanceCount.home}','90%', '90%')">
												${workAttendanceMonth.workStaffBasicInfo.name}
										</a>
									</td>

									<td>
											${fns:getDictLabel(workAttendanceMonth.isAttendance, 'yes_no', '')}
									</td>
									<td>
											${workAttendanceMonth.answerAttendanceDay}
									</td>
									<td>
											${workAttendanceMonth.realAttendanceDay}
									</td>
									<td>
											${workAttendanceMonth.internalDuty}
									</td>
									<td>
											${workAttendanceMonth.fieldPersonnel}
									</td>
									<td>
											${workAttendanceMonth.goOut}
									</td>
									<td>
											${workAttendanceMonth.overTime}
									</td>
									<td>
											${workAttendanceMonth.miner}
									</td>
									<td>
											${workAttendanceMonth.late}
									</td>
									<td>
											${workAttendanceMonth.early}
									</td>

									<td>
											${workAttendanceMonth.leave}
									</td>
								</tr>
							</c:forEach>
						</c:if>
						</tbody>
					</table>
				</div>
			</div>
		</form:form>
	</div>
</div>
</body>
</html>