<%@ 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(obj){//回调函数，在编辑和保存动作时，供openDialog调用提交表单。
			debugger
		  if(validateForm.form()){
              if(obj == 2){
                  $("#flag").val("no");
              }else{
                  $("#flag").val("yes");
              }
              $("#inputForm").submit();
              return true;
		  }
		  return false;
		}
		$(document).ready(function() {
            /*$('#money').keyup(function(){
                var c=$(this);
                if(/[^\d]/.test(c.val())){//替换非数字字符
                    var temp_amount=c.val().replace(/[^\d]/g,'');
                    $(this).val(temp_amount);
                }
            })*/

            $("input[name='ext']").on('ifChecked', function(event){
                var radioVal = $(this).val();
                if(radioVal == 0){
                    $("#td1").removeClass("hide");
                    $("#td2").addClass("hide");
                    $("#tr1").show()
                }else{
                    $("#td1").addClass("hide");
                    $("#td2").removeClass("hide");
                    $("#tr1").hide()
                }
            });
            if("${workInvoiceDetail.returnCancle}" == "2"){
                $("#returnCancle1").iCheck('check')
            }else{
                $("#returnCancle").iCheck('check')
            }
            if("${workInvoiceDetail.returnSign}" == "2"){
                $("#returnSign1").iCheck('check')
            }else{
                $("#returnSign").iCheck('check')
            }
            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);
					}
				}
			});
		});
        function setValue(obj){
            $.ajax({
                type:'post',
                url:'${ctx}/workinvoicedetail/workInvoiceDetail/getWorkInvoice',
                data:{
                    "obj":obj
                },
                success:function(data){
                    var d = JSON.parse(data);
                    $("#cInfoName").val(d.cInfoName);
                    $("#pNumber").val(d.pNumber);
                    $("#cName").val(d.cName);
                    $("#clientName").val(d.clientName);
                    $("#leaderName").val(d.leaderName);
                    $("#officeName").val(d.officeName);
                    $("#invoiceType").val(d.invoiceType);
                    $("#invoiceCName").val(d.invoiceCName);
                    $("#orUnicode").val(d.orUnicode);
                    $("#address").val(d.address);
                    $("#telephone").val(d.telephone);
                    $("#bank").val(d.bank);
                    $("#bankNumber").val(d.bankNumber);
                    $("#startDate").val(d.startDate);
                    $("#totalMoney").val(d.totalMoney);
                    $("#tax").val(d.tax);
                    $("#taxMoney").val(d.taxMoney);
                    $("#taxRate").val(d.taxRate);
                    $("#number").val(d.number);
                    $("#id").val(obj);
                }
            })
        }
        function setDp(obj){
            $.ajax({
                type:'post',
                url:'${ctx}/workinvoice/workInvoice/getUserDp',
                data:{
                    "obj":obj
                },
                success:function(data){
                    var d = JSON.parse(data);
                    $("#dp").val(d.dp);
                }
            })
        }
        function setPNumber(obj){
            $.ajax({
                type:'post',
                url:'${ctx}/workinvoice/workInvoice/getPNumber',
                data:{
                    "obj":obj
                },
                success:function(data){
                    var d = JSON.parse(data);
                    $("#pNumber").val(d.pNumber);
                    $("#cInfoName").val(d.cInfoName);
                    $("#cName").val(d.cName);
                    $("#officeName").val(d.officeName);
                    $("#officeId").val(d.officeId);
                }
            })
        }

	</script>
</head>
<body class="gray-bg">
	<div class="ibox-content">
		<form:form id="inputForm" modelAttribute="workInvoiceDetail" action="${ctx}/workinvoicedetail/workInvoiceDetail/saveAudit" method="post" class="form-horizontal">
		<form:hidden id="id" 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"/>
		<sys:message content="${message}"/>
		<div class="tab-content">
			<div class="tabs-container">
				<ul class="nav nav-tabs">
					<li class="active"><a data-toggle="tab" href="#tab-1" aria-expanded="true" >退票信息</a>
					</li>
				</ul>
			</div>
		<table class="table table-bordered  table-condensed dataTables-example dataTable no-footer">
		   <tbody>
		   <tr>
			   <td class="width-15 active"><label class="pull-right"><font color="red">*</font>被退票号：</label></td>
			   <td class="width-35">
				   <sys:gridselectInvoiceDetail url="${ctx}/workinvoicedetail/workInvoiceDetail/selectinvoice" id="detail" name=""  value="${workInvoiceDetail.id}"  title="选择开票单位" labelName="workInvoiceDetail.number"
								   labelValue="${workInvoiceDetail.number}" cssClass="form-control required" fieldLabels="单位" fieldKeys="number" searchLabel="发票号" searchKey="number" ></sys:gridselectInvoiceDetail>
			   </td>
			   <td class="width-15 active"><label class="pull-right">退票申请编号：</label></td>
			   <td class="width-35">
				   <form:input path="returnNumber" htmlEscape="false" readonly="true"   class="form-control"/>
			   </td>
		   </tr>
		   <tr >
			   <td class="width-15 active"><label class="pull-right">项目名称：</label></td>
			   <td class="width-35">
				   <form:input id ="cInfoName" path="workInvoice.project.projectName" htmlEscape="false"  readonly="true" class="form-control "/>
			   </td>
			   <td class="width-15 active"><label class="pull-right">项目编号：</label></td>
			   <td class="width-35">
				   <form:input id ="pNumber" path="workInvoice.project.projectId" htmlEscape="false"  readonly="true" class="form-control "/>
			   </td>

		   </tr>
		   <tr >
			   <td class="width-15 active"><label class="pull-right">合同名称：</label></td>
			   <td class="width-35">
				   <form:input id ="cName" path="workInvoice.project.workContractInfo.name" htmlEscape="false"  readonly="true" class="form-control "/>
			   </td>
			   <td class="width-15 active"><label class="pull-right">所属部门：</label></td>
			   <td class="width-35">
				   <form:input id ="officeName" path="workInvoice.office.name" htmlEscape="false"  readonly="true" class="form-control "/>
			   </td>
		   </tr>
		   <tr >
			   <td class="width-15 active"><label class="pull-right">委托方：</label></td>
			   <td class="width-35">
				   <form:input id ="clientName" path="workInvoice.project.workContractInfo.client.name" htmlEscape="false"  readonly="true" class="form-control "/>
			   </td>
			   <td class="width-15 active"><label class="pull-right">项目负责人：</label></td>
			   <td class="width-35">
				   <form:input id ="leaderName" path="workInvoice.project.leaderNameStr" htmlEscape="false"  readonly="true" class="form-control "/>
			   </td>
		   </tr>
		   <tr >
			   <td class="width-15 active"><label class="pull-right">发票类型：</label></td>
			   <td class="width-35">
				   <form:input id ="invoiceType" path="workInvoice.invoiceType" htmlEscape="false"  readonly="true" class="form-control "/>
			   </td>
			   <td class="width-15 active"><label class="pull-right">实际开票单位：</label></td>
			   <td class="width-35">
				   <form:input id ="invoiceCName" path="workInvoice.client.name" htmlEscape="false"  readonly="true" class="form-control "/>
			   </td>
		   </tr>
		   <tr >
			   <td class="width-15 active"><label class="pull-right">纳税人识别号：</label></td>
			   <td class="width-35">
				   <form:input id ="orUnicode" path="workInvoice.client.uscCode" htmlEscape="false"  readonly="true" class="form-control "/>
			   </td>
			   <td class="width-15 active"><label class="pull-right">地址：</label></td>
			   <td class="width-35">
				   <form:input id ="address" path="workInvoice.client.address" htmlEscape="false"  readonly="true" class="form-control "/>
			   </td>
		   </tr>
		   <tr >
			   <td class="width-15 active"><label class="pull-right">电话：</label></td>
			   <td class="width-35">
				   <form:input id ="telephone" path="workInvoice.client.telephone" htmlEscape="false"  readonly="true" class="form-control "/>
			   </td>
			   <td class="width-15 active"><label class="pull-right">开户银行：</label></td>
			   <td class="width-35">
				   <form:input id ="bank" path="workInvoice.bank" htmlEscape="false"  readonly="true" class="form-control "/>
			   </td>
		   </tr>
		   <tr >
			   <td class="width-15 active"><label class="pull-right">银行账号：</label></td>
			   <td class="width-35">
				   <form:input id ="bankNumber" path="workInvoice.bankNumber" htmlEscape="false"  readonly="true" class="form-control "/>
			   </td>
			   <td class="width-15 active"><label class="pull-right">开票时间：</label></td>
			   <td class="width-35">
				   <input class="form-control layer-date laydate-icon" readonly="readonly" id="startDate" name="startDate" value="<fmt:formatDate
							value="${workInvoiceDetail.workInvoice.invoiceDate}" pattern="yyyy-MM-dd"/>" onclick="laydate({istime: false, format: 'yyyy-MM-dd'})">
			   </td>
		   </tr>
		   <tr >
			   <td class="width-15 active"><label class="pull-right">价税合计：</label></td>
			   <td class="width-35">
				   <form:input id ="totalMoney" path="totalMoney" htmlEscape="false"  readonly="true" class="form-control "/>
			   </td>
			   <td class="width-15 active"><label class="pull-right">税率：</label></td>
			   <td class="width-35">
				   <form:input id ="tax" path="tax" htmlEscape="false"  readonly="true" class="form-control "/>
			   </td>
		   </tr>
		   <tr >
			   <td class="width-15 active"><label class="pull-right">金额：</label></td>
			   <td class="width-35">
				   <form:input id ="taxMoney" path="taxMoney" htmlEscape="false"  readonly="true" class="form-control "/>
			   </td>
			   <td class="width-15 active"><label class="pull-right">税额：</label></td>
			   <td class="width-35">
				   <form:input id ="taxRate" path="taxRate" htmlEscape="false"  readonly="true" class="form-control "/>
			   </td>
		   </tr>
		   <tr>
			   <td class="width-15 active"><label class="pull-right"><font color="red">*</font>退票原因：</label></td>
			   <td class="width-35" colspan="3">
				   <form:textarea path="returnReason" htmlEscape="false" rows="4"    class="form-control required"/>
			   </td>
		   </tr>
		 	</tbody>
		</table>

			<div class="tabs-container">
				<ul class="nav nav-tabs">
					<li class="active"><a data-toggle="tab" href="#tab-1" aria-expanded="true" style="margin-top: 15px">财务受理信息</a>
					</li>
				</ul>
			</div>
			<table class="table table-bordered  table-condensed dataTables-example dataTable no-footer">
				<tbody>
				<tr>
					<td class="width-15 active"><label class="pull-right"><font color="red">*</font>作废/退票：</label></td>
					<td class="width-35">
						<input type="radio" class="i-checks" name="returnCancle" checked id="returnCancle" value="1">
						<label for="returnCancle">退票</label>
						<input type="radio" class="i-checks" name="returnCancle" id="returnCancle1" value="2">
						<label for="returnCancle1">作废</label>
					</td>
					<td class="width-15 active"><label class="pull-right">发票号：</label></td>
					<td class="width-35">
						<form:input id ="number" path="number" htmlEscape="false"  readonly="true" class="form-control "/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right"><font color="red">*</font>原票是否退回：</label></td>
					<td class="width-35">
						<input type="radio" class="i-checks" name="returnSign" checked id="returnSign" value="1">
						<label for="returnSign">是</label>
						<input type="radio" class="i-checks" name="returnSign" id="returnSign1" value="2">
						<label for="returnSign1">否</label>
					</td>
					<td class="width-15 active"><label class="pull-right">退票人：</label></td>
					<td class="width-35">
						<form:input id ="returnUser" path="returnUser" htmlEscape="false"  readonly="true" class="form-control "/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right"><font color="red">*</font>退票时间：</label></td>
					<td class="width-35">
						<input class="form-control layer-date reuired laydate-icon" id="returnDate" name="returnDate" value="<fmt:formatDate
							value="${workInvoiceDetail.returnDate}" pattern="yyyy-MM-dd"/>" onclick="laydate({istime: false, format: 'yyyy-MM-dd'})">
					</td>
				</tr>
				</tbody>
			</table>
		</div>
	</form:form>
	</div>
	</div>
</body>
</html>