<%@include file="/WEB-INF/common/layouts/common.jsp" %>
<%@ page language="java" pageEncoding="UTF-8" %>
<html>
<head>
    <title>CmDeliveryAddress列表</title>
</head>
<body>
<%-- <div class="row${fluid}">
    <div class="span6">
        <h2 class="page-title">CmDeliveryAddress列表</h2>
    </div>
    <div class="span6 header_buttons">
        <a href="${ctx}/cmdeliveryaddress?action=create" class="btn blue pull-right"><i class="icon-plus"></i></a>
    </div>
</div> --%>

<!-- 面包屑 begin -->
<div class="row-fluid">
	<div class="span12">
		<ul class="breadcrumb">
			<!-- <li><a href="/house365-hmc-web/">首页</a> <span class="divider"></span></li> -->
			<li class="active" ><span class="divider" style="color:#26a0da;font-weight:bold;">/</span>CmDeliveryAddress列表</li>
		</ul>
	</div>
</div>
<!-- 面包屑 begin -->

<div class="page-container">
    <div class="row${fluid}">
        <div class="span12">
            <form id="filterForm" class="form-inline filterForm" action="${ctx}/cmdeliveryaddress" method="get">
				<input type="text" name="search_LIKE_id" value="${param['search_LIKE_id']}" 
					class="m-wrap small" placeholder="编号">
				<input type="text" name="search_LIKE_userId" value="${param['search_LIKE_userId']}" 
					class="m-wrap small" placeholder="用户">
				<input type="text" name="search_LIKE_userName" value="${param['search_LIKE_userName']}" 
					class="m-wrap small" placeholder="用户姓名">
				<input type="text" name="search_LIKE_receiverPhone" value="${param['search_LIKE_receiverPhone']}" 
					class="m-wrap small" placeholder="接收人电话">
				<div class="buttons pull-right"  style="margin-left:15px;">
                    <a href="${ctx}/cmdeliveryaddress?action=create" class="btn blue pull-right" title="新增"><i class="icon-plus"></i></a>
                </div>
				<div class="buttons pull-right" >
                    <a href="javascript:void(0);" onclick="deleteById('')" class="btn blue pull-right" title="删除"><i class="icon-minus"></i></a>
                </div>
                <div class="buttons pull-right" style="margin:3px 30px 0 0;">
                    <i class="icon-search icon-2x pointer" onclick="$('#filterForm').submit();" title="搜索"></i>
                </div>
	            </form>
        </div>
    </div>
    <table class="table table-striped table-advance table-hover">
        <thead>
        	<tr>
        		<th width="40" style="text-align:center"><input id="memberCheckAll" type="checkbox" onclick="checkAll(this)" /></th>
				<th width="100">编号</th>
				<th width="100">用户</th>
				<th width="100">用户姓名</th>
				<th width="100">接收人电话</th>
				<th width="100">接收人姓名</th>
				<th width="100">送货地区</th>
				<th width="100">送货详细地址</th>
				<th width="100">邮编</th>
				<th width="100">是否删除 0:未删除 1:已删除</th>
				<th width="150">操作</th>
			</tr>
        </thead>
        <c:forEach items="${cmDeliveryAddresss}" var="cmDeliveryAddress">
            <tr>
            	<td nowrap="nowrap" style="text-align:center">
				    <input type="checkbox" name="memberCheck" value="${cmDeliveryAddress.id}" onclick="checkMember(this)"/>
				</td>
				<td nowrap="nowrap">
				    <a href="${ctx}/cmdeliveryaddress/${cmDeliveryAddress.id}">						<c:if test="${null ne cmDeliveryAddress.id && '' ne cmDeliveryAddress.id}">
							<c:out value="${cmDeliveryAddress.id}" />
						</c:if>
						<c:if test="${null eq cmDeliveryAddress.id || '' eq cmDeliveryAddress.id}">
							&nbsp;
						</c:if>
</a>
				</td>
				<td nowrap="nowrap">
						<c:if test="${null ne cmDeliveryAddress.userId && '' ne cmDeliveryAddress.userId}">
							<c:out value="${cmDeliveryAddress.userId}" />
						</c:if>
						<c:if test="${null eq cmDeliveryAddress.userId || '' eq cmDeliveryAddress.userId}">
							&nbsp;
						</c:if>
				</td>
				<td nowrap="nowrap">
						<c:if test="${null ne cmDeliveryAddress.userName && '' ne cmDeliveryAddress.userName}">
							<c:out value="${cmDeliveryAddress.userName}" />
						</c:if>
						<c:if test="${null eq cmDeliveryAddress.userName || '' eq cmDeliveryAddress.userName}">
							&nbsp;
						</c:if>
				</td>
				<td nowrap="nowrap">
						<c:if test="${null ne cmDeliveryAddress.receiverPhone && '' ne cmDeliveryAddress.receiverPhone}">
							<c:out value="${cmDeliveryAddress.receiverPhone}" />
						</c:if>
						<c:if test="${null eq cmDeliveryAddress.receiverPhone || '' eq cmDeliveryAddress.receiverPhone}">
							&nbsp;
						</c:if>
				</td>
				<td nowrap="nowrap">
						<c:if test="${null ne cmDeliveryAddress.receiverName && '' ne cmDeliveryAddress.receiverName}">
							<c:out value="${cmDeliveryAddress.receiverName}" />
						</c:if>
						<c:if test="${null eq cmDeliveryAddress.receiverName || '' eq cmDeliveryAddress.receiverName}">
							&nbsp;
						</c:if>
				</td>
				<td nowrap="nowrap">
						<c:if test="${null ne cmDeliveryAddress.deliverPosition && '' ne cmDeliveryAddress.deliverPosition}">
							<c:out value="${cmDeliveryAddress.deliverPosition}" />
						</c:if>
						<c:if test="${null eq cmDeliveryAddress.deliverPosition || '' eq cmDeliveryAddress.deliverPosition}">
							&nbsp;
						</c:if>
				</td>
				<td nowrap="nowrap">
						<c:if test="${null ne cmDeliveryAddress.deliverDetailAddress && '' ne cmDeliveryAddress.deliverDetailAddress}">
							<c:out value="${cmDeliveryAddress.deliverDetailAddress}" />
						</c:if>
						<c:if test="${null eq cmDeliveryAddress.deliverDetailAddress || '' eq cmDeliveryAddress.deliverDetailAddress}">
							&nbsp;
						</c:if>
				</td>
				<td nowrap="nowrap">
						<c:if test="${null ne cmDeliveryAddress.zipCode && '' ne cmDeliveryAddress.zipCode}">
							<c:out value="${cmDeliveryAddress.zipCode}" />
						</c:if>
						<c:if test="${null eq cmDeliveryAddress.zipCode || '' eq cmDeliveryAddress.zipCode}">
							&nbsp;
						</c:if>
				</td>
				<td nowrap="nowrap">
						<c:if test="${null ne cmDeliveryAddress.isDeleted && '' ne cmDeliveryAddress.isDeleted}">
							<c:out value="${cmDeliveryAddress.isDeleted}" />
						</c:if>
						<c:if test="${null eq cmDeliveryAddress.isDeleted || '' eq cmDeliveryAddress.isDeleted}">
							&nbsp;
						</c:if>
				</td>
				<td nowrap="nowrap">
                    <i class="icon-edit pointer icon-large"
						onclick="window.location='${ctx}/cmdeliveryaddress/${cmDeliveryAddress.id}?action=edit'"></i>
						&nbsp;&nbsp; <i
						title="删除"
						class="icon-minus pointer icon-large"
						onclick="deleteById('${cmDeliveryAddress.id}')"> </i>
					</td>
			</tr>
        </c:forEach>
    </table>
    <div class="row${fluid}">
        <house365:pagination page="${page}"/>
    </div>
</div>
<script type="text/javascript">
	
	//全选
	function checkAll(btn)       
	{       
		if(btn.checked)
		{
			for(i=0;i<document.all("memberCheck").length;i++)       
			{       
				document.all("memberCheck")[i].checked = "checked";
			}     
		}
		else
		{
			for(i=0;i<document.all("memberCheck").length;i++)       
			{       
				document.all("memberCheck")[i].checked = "";
			}     
		}
	}       
	
	//单选
	function checkMember(btn)
	{
		if(btn.checked)
		{
			var checkAll = true;
			for(i=0;i<document.all("memberCheck").length;i++)       
			{       
				if(document.all("memberCheck")[i].checked == false)
				{
					checkAll = false;
				}
			}     
			
			if(checkAll)
			{
				document.getElementById("memberCheckAll").checked = true;   
			}
		}
		else
		{
			document.getElementById("memberCheckAll").checked = false;   
		}
	}

	var deleteById = function (selectedId) {
		/*
		id为空则是多选  判断是否为空
		为空 提示选择
		不为空 确认后删除
		不为空单选确认后删除
		*/
			if(selectedId == "")
			{
				for(i=0;i<document.getElementsByName('memberCheck').length;i++)       
	    		{       
	    			if(document.getElementsByName('memberCheck')[i].checked)
	    			{
	    				selectedId += document.getElementsByName('memberCheck')[i].value + ",";
	    			}
	    		}     
	    		
	    		var str = "";
	    		if(selectedId != "")
	    		{
	    			str = selectedId.split(",");
	    			
	    			if(str[str.length-1] == "")
	    			{
	    				selectedId = selectedId.substring(0,selectedId.length-1);
	    			}
	    		}
			}
			
			if(selectedId == "")
			{
				House365Util.createModal("删除公告", "请至少选择一条公告!", function () {
			    });
			}
			else
				{
				House365Util.createModal("删除公告", "确定要删除该公告？", function () {
			        $.ajax({
			            url: '${ctx}/cmdeliveryaddress/' + selectedId,
			            type: "DELETE",
			            success: function () {
			                window.location.reload();
			            }
			        });
			    });
			}

	};
    
</script>
</body>
</html>
