{layout:default} {class:Shop.Admin.Config.cardtlist}
<lbhead>
    <title><%=Tag("优惠券")%>-<%=site.title%></title>
</lbhead>
<lbfile>
    <link href="<%=site.AdminAssetsPath %>/plugins/daterangepicker/daterangepicker.css" rel="stylesheet">
</lbfile>
<lbpath>
    <h3 class="text-themecolor m-b-0 m-t-0"><%=Tag("优惠券")%></h3>
    <ol class="breadcrumb">
        <li class="breadcrumb-item"><a href="<%=site.AdminPath %>/Ajax/ajax_admin.aspx?__Action=MenuJump&pid=0"><%=Tag("管理首页")%></a></li>
        <li class="breadcrumb-item active"><%=Tag("优惠券")%> <%=su.Description%></li>
    </ol>
</lbpath>
<lbbody>
    <div class="col-12">
        <div class="card">
            <div class="card-body">
                <div class="row">
                    <div class="col-md-9 m-b-10">
                        <%if (PageReturnMsg == ""){%>
                        <button class="btn btn-info" onclick="AddObj(0)"><i class="ti-plus"></i> <%=Tag("添加")%></button>
                        <button class="btn btn-danger" onclick="DeleteConfirm()"><i class="ti-trash"></i> <%=Tag("删除")%></button>
                        <button class="btn btn-default" onclick="cardexport()"><i class="ti-Export"></i> <%=Tag("导出")%></button>
                        <button class="btn btn-default" onclick="EditObj(0)"><i class="ti-pencil"></i> <%=Tag("批量修改")%></button>
                        <%}%>
                    </div>
                    <div class="col-md-3 m-b-10">
                        <div class="input-group">
                            <input type="text" id="key" name="key" value="<%=key %>" class="form-control" onkeydown="if(event.keyCode==13){search_();}">
                            <div class="input-group-append">
                                <button type="button" class="btn btn-primary" onclick="search_();"><i class="ti-search"></i></button>
                                <button class="btn btn-default" onclick="SearchWindow();"><i class="ti-filter"></i></button>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="table-responsive sorttable">
                    <table class="table table-hover no-wrap">
                        <thead>
                            <tr>
                                <th class="selectAll" style="width:40px">
                                    <a href="javascript:void(0);" onclick="$('input[name=\'id\']').attr('checked',!$(this).attr('checked'));$(this).attr('checked',!$(this).attr('checked'));"><%=Tag("全选")%></a>
                                </th>
                                <th>
                                    <%=Tag("名称")%>
                                </th>
                                <th>
                                    <%=Tag("编号")%>
                                </th>
                                <% if (type == 311)
                                { %>
                                <th>
                                    <%=Tag("密码")%>
                                </th>
                                <%} %>
                                <th>
                                    <%=Tag("会员")%>
                                </th>
                                <th>
                                    <%=Tag("面值")%>
                                </th>
                                <th>
                                    <%=Tag("剩余")%>
                                </th>
                                <th>
                                    <%=Tag("最低消费")%>
                                </th>
                                <th>
                                    <%=Tag("找零")%>
                                </th>
                                <th>
                                    <%=Tag("单独使用")%>
                                </th>
                                <th>
                                    <%=Tag("状态")%>
                                </th>
                                <th>
                                    <%=Tag("有效期")%>
                                </th>
                                <th>
                                    <%=Tag("限制分类")%>
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            <%foreach (DB.LebiShop.Lebi_Card model in models){%>
                            <tr ondblclick="EditObj(<%=model.id %>);">
                                <td>
                                    <label class="custom-control custom-checkbox">
                                        <input type="checkbox" id="checkbox<%=model.id %>" name="id" value="<%=model.id %>" class="custom-control-input" del="true">
                                        <span class="custom-control-label"></span>
                                    </label>
                                </td>
                                <td>
                                    <%=TypeName(model.CardOrder_id)%>
                                </td>
                                <td>
                                    <%=model.Code%>
                                </td>
                                <% if (type == 311){ %>
                                <td>
                                    <%=model.Password%>
                                </td>
                                <%} %>
                                <td>
                                    <%=model.User_UserName%>
                                </td>
                                <td>
                                    <%=FormatMoney(model.Money)%>
                                </td>
                                <td>
                                    <%=FormatMoney(model.Money_Last)%>
                                </td>
                                <td>
                                    <%=FormatMoney(model.Money_Buy)%>
                                </td>
                                <td>
                                    <%=model.IsPayOnce == 0 ? "<span class=\"label label-success\">" + Tag("是") + "</span>" : "<span class=\"label label-danger\">" + Tag("否") + "</span>"%>
                                </td>
                                <td>
                                    <%=model.IsCanOtherUse == 0 ? "<span class=\"label label-success\">" + Tag("是") + "</span>" : "<span class=\"label label-danger\">" + Tag("否") + "</span>"%>
                                </td>
                                <td>
                                    <%=Shop.Bussiness.EX_Type.TypeName(model.Type_id_CardStatus,CurrentLanguage)%>
                                </td>
                                <td>
                                    <%=FormatDate(model.Time_Begin)+"-"+FormatDate(model.Time_End)%>
                                </td>
                                <td><%=Shop.Bussiness.EX_Product.TypeNames(model.Pro_Type_ids,CurrentLanguage.Code) %></td>
                            </tr>
                            <%} %>
                        </tbody>
                    </table>
                </div>
                <div class="row">
                    <div class="col-12">
                        <nav aria-label="Page navigation">
                            <%=PageString%>
                        </nav>
                    </div>
                </div>
            </div>
        </div>
    </div>
</lbbody>
<lbscripts>
    <script src="<%=site.AdminAssetsPath %>/plugins/moment/moment.js"></script>
    <script src="<%=site.AdminAssetsPath %>/plugins/daterangepicker/daterangepicker.js"></script>
    <script>
        function AddObj(id) {
            window.location="cardtype.aspx?type=<%=type %>";
        }
        function CreateObj(id) {
            $("#EditModal").modal("show");
            $.ajax({
                url: "card_create_window.aspx",
                type: "GET",
                cache: false,
                data: {id:id},
            }).done(function(result){
                $("#EditModal .modal-content").html(result);
            });
        }
        function Update() {
            var postData = GetFormJsonData("shop");
            var url = "<%=site.AdminPath %>/ajax/ajax_site.aspx?__Action=Pay_Update";
            RequestAjax(url,postData,function(){MsgBox(1, "<%=Tag("操作成功")%>", "?")});
        }
        function DeleteConfirm() {
            $("#Modal-Confirm").modal("show");
            $("#Confirm-Content").html("<%=Tag("确认要删除吗？")%>");
            $("#Modal-Confirm .btn-success.btn-ok").attr("onclick", "Delete();");
        }
        function Delete() {
            $("#Modal-Confirm").modal("hide");
            var postData = GetFormJsonData("del");
            var url = "<%=site.AdminPath %>/Ajax/ajax_sale.aspx?__Action=Card_Del";
            RequestAjax(url,postData,function(){MsgBox(1, "<%=Tag("操作成功")%>", "?")});
        }
        function search_(scurl) {
            var key = $("#key").val();
            if(scurl==undefined || scurl=='')
                scurl='<%=su.URL %>';
            window.location = "?key=" + escape(key) + "&user_id=<%=user_id %>&"+scurl;
        }
        function cardexport()
        {
            var key = $("#key").val();
            var dateFrom = $("#dateFrom").val();
            var dateTo = $("#dateTo").val();
            var status = $("#status").val();
            var money = $("#money").val();
            window.location = "<%=site.AdminPath %>/ajax/export.aspx?__Action=Card&key=" + escape(key) + "&user_id=<%=user_id %>&<%=su.URL %>";
        }
        function SearchWindow() {
            $("#EditModal").modal("show");
            $.ajax({
                url: "card_search.aspx?callback=search_&<%=su.URL %>",
                type: "GET",
                cache: false,
                data: {},
            }).done(function(result){
                $("#EditModal .modal-content").html(result);
            });
        }
        function EditObj(ids) {
            if (ids == 0){
                var ids = GetChkCheckedValues("id");
            }
            var title_="<%=Tag("批量修改") %>";
            $("#EditModal").modal("show");
            $.ajax({
                url: "card_edit_window.aspx?ids="+ids+"&<%=su.URL %>",
                type: "GET",
                cache: false,
                data: {title:title_},
            }).done(function(result){
                $("#EditModal .modal-content").html(result);
            });
        }
    </script>
</lbscripts>