<?php include ADMIN_COMMON_PATH.'/header.html';?>
<div class="layui-container fly-marginTop fly-user-main">
    <?php include ADMIN_COMMON_PATH.'/products-nav.html';?>
    <div class="fly-panel fly-panel-user" pad20>
        <div class="layui-tab layui-tab-brief" lay-filter="user">
            <ul class="layui-tab-title" id="LAY_mine">
                <li class="layui-this" lay-id="list">卡密管理</li>
                <li class="" lay-id="add"><a href="/<?php echo ADMIN_DIR;?>/productscard/add">添加</a></li>
				<li class="" lay-id="addplus"><a href="/<?php echo ADMIN_DIR;?>/productscard/addplus">批量添加</a></li>
                <li class="" lay-id="import"><a href="/<?php echo ADMIN_DIR;?>/productscard/import">导入</a></li>
				<li class="" lay-id="download"><a href="/<?php echo ADMIN_DIR;?>/productscard/download">导出</a></li>
            </ul>
            <div class="layui-tab-content" style="padding: 20px 0;">
                <div class="layui-form layui-form-pane layui-tab-item layui-show">
                    <div class="layui-form-item layui-show">
						<div class="layui-form layui-row layui-col-space10">
							<div class="layui-inline layui-col-xs12 layui-col-sm4 layui-col-md3 layui-col-lg2">
								<input type="text" name="card" class="layui-input" value="" placeholder="卡密" />
							</div>
							<div class="layui-col-xs12 layui-col-sm4 layui-col-md3 layui-col-lg2">
								<select name="pid">
									<option value="0" >筛选商品</option>
                                    <?php if(!empty($products)):?>
                                    <?php foreach($products AS $p):?>
                                    <option value="<?php echo $p['id'];?>"><?php echo $p['name'];?></option>
                                    <?php endforeach;?>
                                    <?php endif;?>
								</select>
							</div>
							<div class="layui-col-xs12 layui-col-sm4 layui-col-md3 layui-col-lg2">
								<select name="active">
									<option value="-1" >筛选状态</option>
									<option value="0">可用</option>
									<option value="1">已使用</option>
								</select>
							</div>

							<div class="layui-inline layui-col-xs12 layui-col-sm4 layui-col-md3 layui-col-lg2">
								<button lay-submit class="layui-btn" lay-filter="search">查询</button>
							</div>
						</div>
						<div class="layui-inline layui-col-xs12 layui-col-sm4 layui-col-md3 layui-col-lg2">
							<button class="layui-btn layui-btn-danger" id="deleteALL"><i class="layui-icon">&#xe640;</i>批量删除</button>
						</div>
						<div class="layui-inline layui-col-xs12 layui-col-sm4 layui-col-md3 layui-col-lg2">
							<button class="layui-btn layui-btn-danger" id="deleteempty"><i class="layui-icon">&#xe640;</i>最终回收站</button>
						</div>
                        <table class="layui-table" id="table" lay-filter="table"></table>
                    </div>
                </div>
            </div>
            <script type="text/javascript">
            function createTime(v) {
                var date = new Date();
                date.setTime(parseInt(v) * 1000);
                var y = date.getFullYear();
                var m = date.getMonth() + 1;
                m = m < 10 ? '0' + m : m;
                var d = date.getDate();
                d = d < 10 ? ("0" + d) : d;
                var h = date.getHours();
                h = h < 10 ? ("0" + h) : h;
                var M = date.getMinutes();
                M = M < 10 ? ("0" + M) : M;
                var s = date.getSeconds();
                s = s < 10 ? ("0" + s) : s;
                var str = y + "-" + m + "-" + d + " " + h + ":" + M + ":" + s;
                return str;
            }
            </script>
            <script type="text/html" id="addtime">
                {{ createTime(d.addtime) }}
            </script>
            <script type="text/html" id="status">
                {{# if(d.active >0){ }}
                <span class="layui-badge layui-bg-gray">已使用</span>
                {{# } else { }}
                <span class="layui-badge layui-bg-green">可用</span>
                {{# } }}
            </script>
            <script type="text/html" id="opt">
				<a data-href="/<?php echo ADMIN_DIR;?>/productscard/delete/?id={{d.id}}" class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">删除</a>
            </script>
        </div>
    </div>
</div>
</div>
<!--引入公共底文件-->
<?php include ADMIN_COMMON_PATH.'/footer.html';?>
<script>
layui.use('adminproductscard');
</script>