<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
	<title>收入登记管理</title>
	<meta name="decorator" content="default"/>
    <%--<script src="${ctxStatic}/layer-v2.3/laydate/laydate.js"></script>--%>
	<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);
					}
				}
			});

			if("${workReceiptsRegister.ext}" == "1"){
				$("#ext1").iCheck('check')
				$("#divv").hide();
			}else{
				$("#ext").iCheck('check')
				$("#divv").show();
			}
			
		});

        function formatNum(obj) {
            var val = $(obj).val();
            if(val==null||val==''|| isNaN(val))return;
            var money = parseFloat((val + "").replace(/[^\d\.-]/g, "")).toFixed(2) + "";
            var l = money.split(".")[0].split("").reverse(),
                r = money.split(".")[1];
            t = "";
            for(i = 0; i < l.length; i ++ )
            {
                t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? "," : "");
            }
            $(obj).val(t.split("").reverse().join("") + "." + r);
        }
	</script>
	<style>
		/*超过5个汉字，调整label的长度，以下是配套的*/
		.layui-item .layui-form-label{
			width:90px;
		}
		.form-group .layui-item .layui-input-block,
		.query .layui-input-block {
			margin-left: 116px;
		}
	</style>
</head>
<body>
<div class="single-form">
	<div class="container view-form">
		<form:form id="inputForm" modelAttribute="workReceiptsRegister" action="${ctx}/workreceiptsregister/workReceiptsRegister/saveDetail" method="post" class="form-horizontal">
			<form:hidden path="id"/>
			<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"><span class="require-item">*</span>收入类型：</label>
					<div class="layui-input-block">
						<input type="radio" class="i-checks" name="ext" checked id="ext" value="0">
						<label for="ext">项目收入</label>
						<input type="radio" class="i-checks" name="ext" id="ext1" value="1">
						<label for="ext1">非项目收入</label>
							<%--<input type="text" name="title" lay-verify="title" autocomplete="off" readonly="true" placeholder="" class="layui-input" value="全过程管理用户01">--%>
					</div>
				</div>
				<div id="divv">
					<div class="layui-item layui-col-sm6 td1">
						<label class="layui-form-label"><span class="require-item">*</span>收入项目：</label>
						<div class="layui-input-block with-icon">
							<%--<sys:gridselectcallprojectt url="${ctx}/workinvoice/workInvoice/selectproject" id="project" name="project.id"  value="${workReceiptsRegister.project.id}"  title="选择所属项目" labelName="workInvoice.project.projectName"--%>
														<%--labelValue="${workReceiptsRegister.project.projectName}" cssClass="form-control required layui-input" fieldLabels="项目" fieldKeys="projectName" searchLabel="项目名称" searchKey="projectName" ></sys:gridselectcallprojectt>--%>
							<form:input path="project.projectName" readonly="true" class="form-control layui-input"/>
						</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">
							<form:input id ="pNumber" path="project.projectId" htmlEscape="false"  readonly="true" class="form-control layui-input"/>
						</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">
							<form:input id ="cInfoName" path="project.workContractInfo.name" htmlEscape="false"  readonly="true" class="form-control layui-input"/>
						</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">
							<form:input id ="cName" path="project.workContractInfo.client.name" htmlEscape="false"  readonly="true" class="form-control layui-input"/>
						</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 id ="cMoney"  value="<fmt:formatNumber value="${workReceiptsRegister.project.workContractInfo.contractPrice}" pattern="#,##0.00#"/>" htmlEscape="false"  readonly="true" class="form-control layui-input"/>
						</div>
					</div>
				</div>
			</div>
			<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"><span class="require-item">*</span>到账时间：</label>
					<div class="layui-input-block">
						<input id="arrivalDate" name="arrivalDate" type="text" readonly="true" maxlength="20" class=" form-control required layui-input"
							   value="<fmt:formatDate value="${workReceiptsRegister.arrivalDate}" pattern="yyyy-MM-dd"/>"/>
					</div>
				</div>
                <div class="layui-item layui-col-sm6 td1">
                    <label class="layui-form-label"><span class="require-item">*</span>到账金额：</label>
                    <div class="layui-input-block">
                        <input name="arrivalAmt" htmlEscape="false" value="<fmt:formatNumber value="${workReceiptsRegister.arrivalAmt}" pattern="#,##0.00#"/>"  readonly="true" class="form-control required number layui-input"/>
                    </div>
                </div>
				<div class="layui-item layui-col-sm6 td1">
					<label class="layui-form-label"><span class="require-item">*</span>对方户名：</label>
					<div class="layui-input-block">
						<form:input path="clientAccname" htmlEscape="false"  readonly="true" class="form-control required layui-input"/>
					</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">
                        <form:input path="clientAccno" htmlEscape="false"  readonly="true" class="form-control required layui-input"/>
                    </div>
                </div>
				<div class="layui-item layui-col-sm6 td1">
					<label class="layui-form-label">登记金额：</label>
					<div class="layui-input-block">
						<input name="registerAmt" htmlEscape="false" value="<fmt:formatNumber value="${workReceiptsRegister.registerAmt}" pattern="#,##0.00#"/>" class="form-control number layui-input" readonly="true" />
					</div>
				</div>
				<div class="layui-item layui-col-sm6 td1">
					<label class="layui-form-label">收入状态：</label>
					<div class="layui-input-block">
						<input path="statuStr" htmlEscape="false" readonly="true" class="form-control layui-input"  <c:if test="${workReceiptsRegister.status eq '0'}">value="未登记"</c:if> <c:if test="${workReceiptsRegister.status eq '1'}">value="已登记"</c:if>/>
					</div>
				</div>
				<div class="layui-item layui-col-sm6 td1">
					<label class="layui-form-label">所属分公司：</label>
					<div class="layui-input-block">
						<form:input path="company.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="contentTable" class="table table-bordered table-condensed no-bottom-margin details">
						<thead>
						<tr>
							<th class="hide"></th>
							<th><font style="color: red">*</font>所属部门</th>
							<th><font style="color: red">*</font>发票号</th>
							<th>发票金额</th>
							<th>累计登记金额</th>
							<th>开票时间</th>
							<th><font style="color: red">*</font>登记金额</th>
							<th><font style="color: red">*</font>登记日期</th>
							<th>登记状态</th>
						</tr>
						</thead>
						<tbody id="registerDetailList">
                        <c:forEach items="${workReceiptsRegister.registerDetailList}" var="row">
                            <tr>
                                <td style='text-align:center;'>
                                        ${row.office.name}
                                </td>
                                <td style='text-align:center;'>
                                        ${row.invoice.number}
                                </td>
                                <td style='text-align:center;'>
                                    <fmt:formatNumber value="${row.invoice.totalMoney}" pattern="#,##0.00#"/>
                                </td>
                                <td style='text-align:center;'>
                                    <fmt:formatNumber value="${row.invoice.incomeMoney}" pattern="#,##0.00#"/>
                                </td>
                                <td style='text-align:center;'>
                                    <fmt:formatDate value="${row.invoice.date}" pattern="yyyy-MM-dd"/>
                                </td>
                                <td style='text-align:center;'>
                                    <fmt:formatNumber value="${row.registerAmt}" pattern="#,##0.00#"/>
                                </td>
                                <td style='text-align:center;'>
                                    <fmt:formatDate value="${row.registerDate}" pattern="yyyy-MM-dd"/>
                                </td>
                                <td style='text-align:center;'>
                                        ${row.statusStr}
                                </td>
                            </tr>
                        </c:forEach>
						</tbody>
					</table>
				</div>
			</div>
			<div class="form-group layui-row page-end"></div>
		</form:form>
	</div>
</div>

</body>
</html>