<%@ page language="java" errorPage="/error.jsp" pageEncoding="UTF-8"
	contentType="text/html; charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>账单打印</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- bootstrap 3.0.2 -->
<link href="<c:url value='/styles/lib/bootstrap.min.css'/>"
	rel="stylesheet" type="text/css" />
<link href="<c:url value='/styles/lib/font-awesome.min.css'/>"
	rel="stylesheet" type="text/css" />
<link href='<c:url value='/styles/lib/ionicons.min.css' />'
	rel="stylesheet" type="text/css" />
<link
	href="<c:url value='/styles/lib/datatables/dataTables.bootstrap.css' />"
	rel="stylesheet" type="text/css" />
<link href="<c:url value='/styles/AdminLTE.css?ver=4.0'/>"
	rel="stylesheet" type="text/css" />
<link href="<c:url value='/styles/bill/bill.css?ver=4.4'/>" rel="stylesheet" type="text/css" media="print" />
<link href="<c:url value='/styles/bill/bill.css?ver=4.4' />" rel="stylesheet" type="text/css" />
<script src="${ctx }/scripts/lib/jquery-1.8.2.min.js"></script>
<script type="text/javascript"
	src="<c:url value='/scripts/bootstrap.min.js'/>"></script>
<script type="text/javascript"
	src="<c:url value='/plugin/layer/layer.js'/>"></script>
<script type="text/javascript"
	src="<c:url value='/scripts/jquery/jquery.PrintArea.js'/>"></script>
</head>
<script type="text/javascript">
	/**
	 * 跳转账单编辑页面
	 */
	function saveUpdateGeneralBills(id) {
		var virtualId = $("#virtualId").val();
		var contextPath = $("#contextPath").val();
		var url = contextPath + "/admin/bill/generalBillsEidtView?virtualId="
				+ virtualId + "&generalBillsId=" + id+"&funcid="+$("#funcid").val();
		location.href = url;
	}
	
	function generalBillsPrint(){
		$(".billwrap").printArea();
	}
</script>
<body>
	<input type="hidden" id="funcid" value="${funcid}">
	<input type="hidden" value="${ctx}" id="contextPath">
	<input type="hidden" id="funcid" value="${funcid}">
	<input type="hidden" name="virtualId" value="${virtualId}"
		id="virtualId">
	<div class="billwrap" style="height: auto;">
		<div class="brandlogo"><img src="${ctx }/images/main_logo.png"/></div>
		<a href="#" class="phone">统一服务热线： 400-838-6065</a>
		<h3>${virtualArchitecture.name }账单</h3>
		<div>
			<!-- 1. -->
			<div class="back_view">
				<div class="left_view">
					<div class="left_view_left">客户名称：</div>
					<div class="left_view_right divleft">${virtualArchitecture.name }</div>
				</div>
				<div class="right_view">
					<div class="left_view_left divright">本期费用总额：</div>
					<div class="left_view_right divright2">￥${generalBills.totalFee  }</div>
				</div>

			</div>
			<!-- 2. -->
			<div class="back_view">
				<div class="left_view">
					<div class="left_view_left">客户编码：</div>
					<div class="left_view_right divleft">
						${virtualArchitecture.customerNumber }</div>
				</div>
				<div class="right_view">
					<div class="left_view_left divright">预付款余额：</div>
					<div class="left_view_right divright2">￥${virtualArchitecture.reserveBalance }</div>
				</div>

			</div>
			<!-- 3 -->
			<div class="back_view">
				<div class="left_view">
					<div class="left_view_left">客户地址：</div>
					<div class="left_view_right divleft">${virtualArchitecture.address }
					</div>
				</div>
				<div class="right_view">
					<div class="left_view_left divright">历史欠缴：</div>
					<div class="left_view_right divright2">￥${sumOwed }</div>
				</div>

			</div>
			<!-- 4 -->
			<div class="back_view back_view_groud">
				<div class="left_view">
					<div class="left_view_left">计费周期：</div>
					<div class="left_view_right  divleft">${startTime }-${endTime }</div>
				</div>
				<div class="right_view">
					<div class="left_view_left font_change divright">剩余应缴：</div>
					<div class="left_view_right font_change divright2">
						￥
						<c:if test="${payable<0 }">
					0.00
					</c:if>
						<c:if test="${payable>=0 }">
					${payable }
					</c:if>
					</div>
				</div>

			</div>
		</div>
		<!-- 表格 -->
		<table class="table_show" cellspacing="0">
			<tr>
				<th colspan="5">本期消费明细</th>
			</tr>
			<tr>
				<th class="serviceContent">服务项</th>
				<th class="serviceContent">日期</th>
				<th class="serviceContent_td">服务内容</th>
				<th class="serviceContent">数量</th>
				<th class="serviceContent">金额</th>
			</tr>
			<!-- 增加数量复制粘贴 -->
			<c:forEach items="${generalbillServiceList }" var="model">
				<tr>
					<td colspan="2" class="serviceContent_service">
						${model.serviceName }</td>
					<td>优惠：￥${model.freeFee }</td>
					<td colspan="2" class="serviceContent_money">合计￥${model.totalFee }</td>
				</tr>
				<c:forEach items="${model.list }" var="obj">
					<tr>
						<td class="serviceContent"></td>
						<td class="serviceContent"><fmt:formatDate
								pattern="yyyy-MM-dd" value="${obj.orderTime}" /></td>
						<td class="serviceContent_td">${obj.goodName }</td>
						<td class="serviceContent">X ${obj.amount }</td>
						<td class="serviceContent">￥ ${obj.totalFee }</td>
					</tr>
				</c:forEach>
			</c:forEach>
		</table>
		<table class="table_show_net" cellspacing="0">
			<tr>
				<th colspan="5" class="service_title">历史消费情况（近6个月）</th>
			</tr>
			<tr>
				<th class="serviceContent">账期</th>
				<th class="serviceContent">费用</th>
				<th class="serviceContent_td">内容</th>
				<th class="serviceContent">支付状态</th>
				<th class="serviceContent">支付日期</th>
			</tr>
			<c:forEach items="${resultList }" var="model">
				<!-- 更多显示拷贝下面 -->
				<tr>
					<td class="serviceContent">${model.outMonth }</td>
					<td class="serviceContent">${model.totalFee }</td>
					<td class="serviceContent_td">${model.serviceName }</td>
					<td class="serviceContent"><c:if test="${model.payStatus==0 }">
                  		未支付
                  	</c:if> <c:if test="${model.payStatus==1 }">
                  		已支付
                  	</c:if></td>
					<td class="serviceContent">${model.payTime }</td>
				</tr>
			</c:forEach>
		</table>
		<!-- 制单 -->
		<div class="net">
			<div class="One_man">
				<div class="leftView_left">
					<div class="leftContent">制单人:</div>
					<div class="leftName">${generalBills.makePerson }</div>
				</div>
				<div class="leftView_right">
					<div class="leftContent">制表时间:</div>
					<div class="leftName">${generalBills.makeTime }</div>
				</div>
			</div>
		</div>

		<!-- 按钮 -->
		
	</div>
	<div class="billbtns">
		<div class="wrapbtn">
			<input type="button" value="打印" class="btn btn-primary"
				onclick="generalBillsPrint()" />
			<c:if test="${generalBills.payStatus=='0' }">
				<input type="button" value="编辑" class="btn btn-gray" onclick="saveUpdateGeneralBills('${generalBills.id}')" />
			</c:if>
			<c:if test="${generalBills.payStatus=='1' }">
				<a href="${ctx}/admin/bill/generalBillsPage?virtualId=${virtualArchitecture.id}&funcid=${funcid}" class="btn btn-gray">返回</a>
			</c:if>
		</div>
	</div>
</body>
</html>