<%
layout("/include/_container.html", {title:"表单", parent:"请假申请"}){
%>
	<script type="text/javascript">

		$(document).ready(function() {
			jp.ajaxForm("#inputForm",function(data){
				if(data.success){
				    jp.toastr_success(data.msg);
				    jp.unblock("#inputForm", 0);//立即清除loading层
					jp.go("${ctx}/test/activiti/testActivitiLeave");
				}else{
				    jp.toastr_error(data.msg);
				    $("#inputForm").find("button:submit").button("reset");
				}
			});


            $("#agree").click(function () {
                jp.prompt("同意, 审批意见", function (message) {
                    jp.post("${ctx}/act/task/audit",
                        {
                            "taskId":"${testActivitiLeave.act.taskId}",
                            "taskName":"${testActivitiLeave.act.taskName}",
                            "taskDefKey":"${testActivitiLeave.act.taskDefKey}",
                            "procInsId":"${testActivitiLeave.act.procInsId}",
                            "procDefId":"${testActivitiLeave.act.procDefId}",
                            "flag":"yes",
                            "comment":message

                        },
                        function (data) {
								if(data.success){
									jp.success(data.msg);
									jp.go("${ctx}/act/task/todo")
								}
                        })
                })
            })


            $("#reject").click(function () {
                jp.prompt("驳回, 审批意见", function (message) {
                    jp.post("${ctx}/act/task/audit",
                        {
                            "taskId":"${testActivitiLeave.act.taskId}",
                            "taskName":"${testActivitiLeave.act.taskName}",
                            "taskDefKey":"${testActivitiLeave.act.taskDefKey}",
                            "procInsId":"${testActivitiLeave.act.procInsId}",
                            "procDefId":"${testActivitiLeave.act.procDefId}",
                            "flag":"no",
                            "comment":message

                        },
                        function (data) {

                            if(data.success){
								jp.success(data.msg);
								jp.go("${ctx}/act/task/todo")
                            }


                        })
                })
            })


	        $('#startTime').datetimepicker({
				 format:'Y-m-d H:i'
		    });
	        $('#endTime').datetimepicker({
				 format:'Y-m-d H:i'
		    });
		});
	</script>
<div class="white-box">
	
		<div class="form-group text-center">
			<h3>${testActivitiLeave.act.taskName}</h3>
		</div>
		<form id="inputForm" action="${ctx}/test/activiti/testActivitiLeave/save" method="post" class="form-horizontal">
		<input type="hidden" name="id" value="${testActivitiLeave.id!}"/>
				<div class="form-group">
					<label class="col-sm-2 control-label"><font color="red">*</font>请假类型：</label>
					<div class="col-sm-10">
			 		${fn.getDictLabel(testActivitiLeave.leaveType!, 'oa_leave_type', '')}
					</div>
				</div>
			<hr>
				<div class="form-group">
					<label class="col-sm-2 control-label"><font color="red">*</font>请假开始时间：</label>
					<div class="col-sm-10">
					${fn.formatDate(testActivitiLeave.startTime!, 'yyyy-MM-dd HH:mm:ss')}
					</div>
				</div>
			<hr>
				<div class="form-group">
					<label class="col-sm-2 control-label"><font color="red">*</font>请假结束时间：</label>
					<div class="col-sm-10">
					${fn.formatDate(testActivitiLeave.endTime!, 'yyyy-MM-dd HH:mm:ss')}
					</div>
				</div>
			<hr>
				<div class="form-group">
					<label class="col-sm-2 control-label"><font color="red">*</font>报销事由：</label>
					<div class="col-sm-10">
					${testActivitiLeave.reason!}
					</div>
				</div>
			<hr>
		</form>

		
			<% if(testActivitiLeave.act.taskDefKey! != '' && !testActivitiLeave.act.finishTask! && testActivitiLeave.act.isNextGatewaty!){ %>
			<div class="row">
				<div class="col-sm-3"></div>
				<div class="col-sm-6">
					<div class="form-group text-center">
						<input id="agree" class="btn  btn-primary btn-lg btn-parsley" type="submit" value="同 意" />&nbsp;
						<input id="reject" class="btn  btn-danger btn-lg btn-parsley" type="submit" value="驳 回" />&nbsp;
					</div>
				</div>
			</div>
			<% } %>
			<% if(testActivitiLeave.act.taskDefKey! != '' && !testActivitiLeave.act.finishTask! && !testActivitiLeave.act.isNextGatewaty!){ %>
			<div class="row">
				<div class="col-sm-3"></div>
				<div class="col-sm-6">
					<div class="form-group text-center">
						<input id="agree" class="btn  btn-primary btn-lg btn-parsley" type="submit" value="办 理" />&nbsp;
					</div>
				</div>
			</div>
			<% } %>

			<%if(isNotEmpty(testActivitiLeave.id!)){ %>
				<#flowChart procInsId="${testActivitiLeave.act.procInsId!}"/>
				<#histoicFlow procInsId="${testActivitiLeave.act.procInsId!}" />
			<% } %>

		</div>				
	</div>
	</div>
</div>
<% } %>