<%@ 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 == 1) {
                  $("#flag").val("yes");
              }else {
                  $("#flag").val("no");
              }
			  $("#inputForm").submit();
			  return true;
		  }
		  return false;
		}
		$(document).ready(function() {
			$("#name").focus();
			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.render({
                elem: '#invoiceDate', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
                event: 'focus', //响应事件。如果没有传入event，则按照默认的click
                type : 'date'
            });
		});
	</script>
</head>
<body>
<div class="single-form">
	<div class="container">
	<form:form id="inputForm" modelAttribute="workInvoiceAlter" action="${ctx}/workinvoicealter/workInvoiceAlter/saveAudit" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<form:hidden path="home"/>
		<form:hidden path="act.taskId"/>
		<form:hidden path="act.taskName"/>
		<form:hidden path="act.taskDefKey"/>
		<form:hidden path="act.procInsId"/>
		<form:hidden path="act.procDefId"/>
		<form:hidden id="flag" path="act.flag"/>
		<c:set var="status" value="${workInvoiceAlter.act.status}" />

		<div class="form-group layui-row first lw14">
			<div class="form-group-label"><h2>基本信息</h2></div>
			<div class="layui-item layui-col-sm6">
				<label class="layui-form-label"><span class="require-item">*</span>项目名称：</label>
				<div class="layui-input-block  with-icon">
					<input htmlEscape="false" readonly="true"   class="form-control layui-input" value="${workInvoiceAlter.project.projectName}"/>
				</div>
			</div>
			<div class="layui-item layui-col-sm6">
				<label class="layui-form-label"><span class="require-item">*</span>发票申请编号：</label>
				<div class="layui-input-block">
					<div class="input-group">
						<input htmlEscape="false" readonly="true"   class="form-control layui-input" value="${workInvoiceAlter.number}"/>
						<span class="input-group-btn">
							<label class="form-status"><c:choose><c:when test="${ empty workInvoiceAlter.invoiceState}">新添</c:when><c:otherwise>${fns:getDictLabel(workInvoiceAlter.invoiceState, 'audit_state','')}</c:otherwise>	</c:choose></label>
						</span>
					</div>
				</div>
			</div>
			<div class="layui-item layui-col-sm6">
				<label class="layui-form-label"><span class="require-item">*</span>合同名称：</label>
				<div class="layui-input-block">
					<input htmlEscape="false" readonly="true"   class="form-control layui-input" value="${workInvoiceAlter.project.workContractInfo.name}"/>
				</div>
			</div>
			<div class="layui-item layui-col-sm6">
				<label class="layui-form-label"><span class="require-item">*</span>项目编号：</label>
				<div class="layui-input-block">
					<input htmlEscape="false" readonly="true"   class="form-control layui-input" value="${workInvoiceAlter.project.projectId}"/>
				</div>
			</div>
			<div class="layui-item layui-col-sm6">
				<label class="layui-form-label"><span class="require-item">*</span>委托方：</label>
				<div class="layui-input-block">
					<input htmlEscape="false" readonly="true"   class="form-control layui-input" value="${workInvoiceAlter.project.workContractInfo.client.name}"/>
				</div>
			</div>
			<div class="layui-item layui-col-sm6">
				<label class="layui-form-label"><span class="require-item">*</span>所属部门：</label>
				<div class="layui-input-block">
					<input htmlEscape="false" readonly="true"   class="form-control layui-input" value="${workInvoiceAlter.office.name}"/>
				</div>
			</div>
		</div>
		<div class="form-group layui-row first lw14">
			<div class="form-group-label"><h2>发票详情</h2></div>
			<div class="layui-item layui-col-sm6">
				<label class="layui-form-label"><span class="require-item">*</span>上级/本公司开票：</label>
				<div class="layui-input-block">
					<input htmlEscape="false" readonly="true"   class="form-control layui-input" value="<c:choose><c:when test="${workInvoiceAlter.ext eq '0'}">本公司开票	</c:when><c:when test="${workInvoiceAlter.ext eq '1'}">上级公司开票</c:when></c:choose>"/>
				</div>
			</div>
			<div class="layui-item layui-col-sm6">
				<label class="layui-form-label"><span class="require-item">*</span>发票类型：</label>
				<div class="layui-input-block">
					<input htmlEscape="false" readonly="true"   class="form-control layui-input" value="<c:choose><c:when test="${workInvoiceAlter.invoiceType eq '1'}">专票</c:when><c:when test="${workInvoiceAlter.invoiceType eq '2'}">普票</c:when></c:choose>"/>
				</div>
			</div>
			<div class="layui-item layui-col-sm6">
				<label class="layui-form-label"><span class="require-item">*</span>实际开票单位：</label>
				<div class="layui-input-block">
					<input htmlEscape="false" readonly="true"   class="form-control layui-input" value="${workInvoiceAlter.client.name}"/>
				</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="${workInvoiceAlter.orUnicode}"/>
				</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="${workInvoiceAlter.address}"/>
				</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="${workInvoiceAlter.telephone}"/>
				</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="${workInvoiceAlter.bank}"/>
				</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="${workInvoiceAlter.bankNumber}"/>
				</div>
			</div>
			<div class="layui-item layui-col-sm6">
				<label class="layui-form-label"><span class="require-item">*</span>价税合计(元)：</label>
				<div class="layui-input-block">
					<input htmlEscape="false" readonly="true"   class="form-control layui-input" value="<fmt:formatNumber value="${workInvoiceAlter.money}" pattern="#,#00.00"/>"/>
				</div>
			</div>
			<div class="layui-item layui-col-sm6">
				<label class="layui-form-label"><span class="require-item">*</span>开票内容要求：</label>
				<div class="layui-input-block">
					<input htmlEscape="false" readonly="true"   class="form-control layui-input" value="${workInvoiceAlter.content}"/>
				</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="${workInvoiceAlter.drawerName}"/>
				</div>
			</div>
			<div class="layui-item layui-col-sm6">
				<label class="layui-form-label">开票时间：</label>
				<div class="layui-input-block  with-icon">
					<input class="form-control layer-date laydate-icon layui-input laydate-icondate" id="invoiceDate" readonly="true" name="invoiceDate" value="<fmt:formatDate
							value="${workInvoiceAlter.invoiceDate}" pattern="yyyy-MM-dd"/>">
				</div>
			</div>
			<div class="layui-item layui-col-sm12">
				<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="${workInvoiceAlter.takeDate}" pattern="yyyy-MM-dd"/>"/>
				</div>
			</div>
			<div class="layui-item layui-col-sm12 with-textarea">
				<label class="layui-form-label">审批意见：</label>
				<div class="layui-input-block  with-icon">
					<form:textarea path="act.comment" class="form-control " rows="5" maxlength="20"/>
				</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="contentTable" class="table table-bordered table-condensed details">
					<thead>
					<tr>
						<th><span class="require-item">*</span>发票代码</th>
						<th><span class="require-item">*</span>发票号</th>
						<th><span class="require-item">*</span>价税合计</th>
						<th><span class="require-item">*</span>税率</th>
						<th><span class="require-item">*</span>金额</th>
						<th><span class="require-item">*</span>税额</th>
						<th><span class="require-item">*</span>累计登记金额</th>
						<th><span class="require-item">*</span>发票状态</th><%--正常--%>
						<th><span class="require-item">*</span>被退标记</th>
						<th><span class="require-item">*</span>被退票号</th>
						<th><span class="require-item">*</span>开票日期</th>
					</tr>
					</thead>
					<tbody id="workAccountList">
					<c:if test="${not empty workInvoiceAlter.workAccountList}">
						<c:forEach items="${workInvoiceAlter.workAccountList}" var="workAccount" varStatus="index">
							<tr id="workAccountList${index.index}">
								<td title="${workAccount.code}">
										${workAccount.code}
								</td>
								<td title="${workAccount.number}">
										${workAccount.number}
								</td>

								<td title="<fmt:formatNumber value="${workAccount.totalMoney}" pattern="#,#00.00"/>">
									<fmt:formatNumber value="${workAccount.totalMoney}" pattern="#,#00.00"/>
								</td>
								<td title="${workAccount.tax}">
										${workAccount.tax}
								</td>
								<td title="<fmt:formatNumber value="${workAccount.taxMoney}" pattern="#,#00.00"/>">
									<fmt:formatNumber value="${workAccount.taxMoney}" pattern="#,#00.00"/>
								</td>
								<td title="<fmt:formatNumber value="${workAccount.taxRate}" pattern="#,#00.00"/>">
									<fmt:formatNumber value="${workAccount.taxRate}" pattern="#,#00.00"/>
								</td>
								<td title="<fmt:formatNumber value="${workAccount.incomeMoney}" pattern="#,#00.00"/>">
									<fmt:formatNumber value="${workAccount.incomeMoney}" pattern="#,#00.00"/>
								</td>
								<td title="${workAccount.state}">
										${workAccount.state}
								</td>
								<td title="${workAccount.backSign}">
										${workAccount.backSign}
								</td>
								<td title="${workAccount.backNumber}">
										${workAccount.backNumber}
								</td>
								<td title="">
										<%--<fmt:formatDate value="${workInvoice.invoiceDate}" pattern="yyyy-MM-dd HH:mm:ss"/>--%>
								</td>
							</tr>
						</c:forEach>
					</c:if>
					</tbody>
				</table>
			</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" >
				<act:flowChart procInsId="${workInvoiceAlter.act.procInsId}"/>
				<act:histoicFlow procInsId="${workInvoiceAlter.act.procInsId}" />
			</div>
		</div>

		<div class="form-group layui-row page-end"></div>
	</form:form>
	</div>
</div>

</body>
</html>
