<%@include file="/WEB-INF/common/layouts/common.jsp" %>
<%@ page language="java" pageEncoding="UTF-8" %>
<html>
<head>
    <title>签到淘房币奖品列表</title>
</head>
<body>
<%-- <div class="row${fluid}">
    <div class="span6">
        <h2 class="page-title">CmLotteryRule列表</h2>
    </div>
    <div class="span6 header_buttons">
        <a href="${ctx}/cmlotteryrule?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>签到淘房币奖品列表</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}/cmlotteryrule" 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_credits" value="${param['search_LIKE_credits']}" 
					class="m-wrap small" placeholder="淘房币数量">
				<input type="text" name="search_LIKE_creditRuleName" value="${param['search_LIKE_creditRuleName']}" 
					class="m-wrap small" placeholder="奖品名称">
				<input type="text" name="search_LIKE_probability" value="${param['search_LIKE_probability']}" 
					class="m-wrap small" placeholder="中奖概率(小数表示)"> --%>
				<div class="buttons pull-right"  style="margin-left:15px;">
                    <a href="javascript:addNewRule()" class="btn blue pull-right" title="新增"><i class="icon-plus"></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="100">编号</th>
				<th width="100">奖品名称</th>
				<th width="100">淘房币数量</th>
				<th width="100">中奖概率(小数表示)</th>
				<th width="100">更新时间</th>
				<th width="150">操作</th>
			</tr>
        </thead>
        <c:forEach items="${cmLotteryRules}" var="cmLotteryRule">
            <tr class="ruleTrClass">
				<td nowrap="nowrap">
				    <a href="${ctx}/cmlotteryrule/${cmLotteryRule.id}">						<c:if test="${null ne cmLotteryRule.id && '' ne cmLotteryRule.id}">
							<c:out value="${cmLotteryRule.id}" />
						</c:if>
						<c:if test="${null eq cmLotteryRule.id || '' eq cmLotteryRule.id}">
							&nbsp;
						</c:if>
					</a>
				</td>
				<td nowrap="nowrap">
						<c:if test="${null ne cmLotteryRule.creditRuleName && '' ne cmLotteryRule.creditRuleName}">
							<c:out value="${cmLotteryRule.creditRuleName}" />
						</c:if>
						<c:if test="${null eq cmLotteryRule.creditRuleName || '' eq cmLotteryRule.creditRuleName}">
							&nbsp;
						</c:if>
				</td>
				<td nowrap="nowrap">
						<c:if test="${null ne cmLotteryRule.credits && '' ne cmLotteryRule.credits}">
							<c:out value="${cmLotteryRule.credits}" />
						</c:if>
						<c:if test="${null eq cmLotteryRule.credits || '' eq cmLotteryRule.credits}">
							&nbsp;
						</c:if>
				</td>
				<td nowrap="nowrap">
						<c:if test="${null ne cmLotteryRule.probability && '' ne cmLotteryRule.probability}">
							<c:out value="${cmLotteryRule.probability}" />
						</c:if>
						<c:if test="${null eq cmLotteryRule.probability || '' eq cmLotteryRule.probability}">
							&nbsp;
						</c:if>
				</td>
				<td nowrap="nowrap">
						<c:if test="${null ne cmLotteryRule.updateTime && '' ne cmLotteryRule.updateTime}">
							<f:formatDate value='${cmLotteryRule.updateTime}' pattern='yyyy-MM-dd HH:mm:ss' />
						</c:if>
						<c:if test="${null eq cmLotteryRule.updateTime || '' eq cmLotteryRule.updateTime}">
							&nbsp;
						</c:if>
				</td>
				<td nowrap="nowrap">
                    <i class="icon-edit pointer icon-large editLinkClass"
						onclick="window.location='${ctx}/cmlotteryrule/${cmLotteryRule.id}?action=edit'"></i>
						&nbsp;&nbsp; <i
						title="编辑"
						class="icon-minus pointer icon-large"
						onclick="deleteById('${cmLotteryRule.id}')"> </i>
					<input type="hidden" class="orderNumberClass" value="${cmLotteryRule.orderNumber}"/>
				</td>
			</tr>
        </c:forEach>
    </table>
    <div class="row${fluid}">
        <house365:pagination page="${page}"/>
    </div>
</div>
<script type="text/javascript">

	function addNewRule(){
		//判断条数，大于9的话就不给添加
		var totalRuleCount = $(".ruleTrClass").length;
		
		if(totalRuleCount>9){
			House365Util.createModal("提示", "最多只能10个奖项！", function () {
		    });
		}else{
			window.location = "${ctx}/cmlotteryrule?action=create";
		}
	}
	
	//全选
	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) {
		
		//判断条数，小于3的话就不给添加
		var totalRuleCount = $(".ruleTrClass").length;
		
		if(totalRuleCount<3){
			House365Util.createModal("提示", "至少要保留2个奖项！", function () {
		    });
			return;
		}
		
		
		/*
		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}/cmlotteryrule/' + selectedId,
			            type: "DELETE",
			            success: function () {
			                window.location.reload();
			            }
			        });
			    });
			}

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