{layout:default} {class:Shop.Admin.theme.Advert}
<lbhead>
    <title><%=theme.Name %>-<%=Tag("主题管理")%>-<%=site.title%></title>
</lbhead>
<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"><a href="<%=site.AdminPath %>/theme/default.aspx"><%=Tag("主题管理")%></a></li>
        <li class="breadcrumb-item active"><%=theme.Name %></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="Editobj(<%=theme.id %>,0);"><i class="ti-plus"></i> <%=Tag("添加")%></button>
                        <button class="btn btn-default" onclick="Update(<%=theme.id %>,0,'Advert');"><i class="ti-world"></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>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="table-responsive">
                    <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>
                                <th>
                                    <%=Tag("尺寸")%>
                                </th>
                                <th>
                                    <%=Tag("图片数")%>
                                </th>
                                <th>
                                    <%=Tag("排序")%>
                                </th>
                                <th>
                                    <%=Tag("操作")%>
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            <%foreach (DB.LebiShop.Lebi_Theme_Advert model in models){%>
                            <tr ondblclick="Editobj(<%=theme.id %>,<%=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" update="true">
                                        <span class="custom-control-label"></span>
                                    </label>
                                </td>
                                <td>
                                    {AD:<%=model.Code %>}
                                </td>
                                <td>
                                    <%=model.Description %>
                                </td>
                                <td>
                                    <%=model.Width+" * "+model.Height%>
                                </td>
                                <td>
                                    <a href="AdvertList.aspx?tid=<%=theme.id %>&id=<%=model.id %>"><%=DB.LebiShop.B_Lebi_Advert.Counts("Theme_Advert_id=" + model.id) %></a>
                                </td>
                                <td>
                                    <%=model.Sort %>
                                </td>
                                <td>
                                    <a href="javascript:void(0)" onclick="Editobj(<%=theme.id %>,<%=model.id %>);"><%=Tag("编辑")%></a> | <a href="javascript:void(0)" onclick="DeleteConfirm(<%=model.id %>);"><%=Tag("删除")%></a> | <a href="AdvertList.aspx?tid=<%=theme.id %>&id=<%=model.id %>"><%=Tag("图片列表")%></a> | <a href="javascript:void(0)" onclick="AdvertImage(<%=model.id %>,0);"><%=Tag("添加图片")%></a>
                                </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.AdminJsPath %>/ajaxfileupload.js"></script>
    <script>
        function search_() {
            var key = $("#key").val();
            window.location = "?id=<%=id%>&key=" + escape(key);
        }
        function Editobj(tid,id) {
            var title_ = "<%=Tag("编辑")%>";
            if (id == 0)
                var title_ = "<%=Tag("添加")%>";
            $("#EditModal").modal("show");
            $.ajax({
                url: "advert_edit_window.aspx",
                type: "GET",
                cache: false,
                data: {id: id,tid: tid,title: title_},
            }).done(function(result){
                $("#EditModal .modal-content").html(result);
            });
        }
        function Update(id,ids,table) {
            if (ids == 0)
                ids = GetChkCheckedValues("id");
            $("#EditModal").modal("show");
            $.ajax({
                url: "<%=site.AdminPath %>/config/setlanguage_edit_window.aspx",
                type: "GET",
                cache: false,
                data: {id: id,ids: ids,table: table},
            }).done(function(result){
                $("#EditModal .modal-content").html(result);
            });
        }
        function AdvertImage(aid,id) {
            var title_ = "<%=Tag("编辑")%>";
            if (id == 0)
                var title_ = "<%=Tag("添加")%>";
            $("#EditModal").modal("show");
            $.ajax({
                url: "advertimage_edit_window.aspx",
                type: "GET",
                cache: false,
                data: {id: id,aid: aid,title: title_},
            }).done(function(result){
                $("#EditModal .modal-content").html(result);
            });
        }
        function DeleteConfirm(id) {
            $("#Modal-Confirm").modal("show");
            $("#Confirm-Content").html("<%=Tag("确认要删除吗？")%>");
            $("#Modal-Confirm .btn-success.btn-ok").attr("onclick", "Advert_Del(" + id + ");");
        }
        function Advert_Del(id) {
            $("#Modal-Confirm").modal("hide");
            var postData = { "id": id };
            var url="<%=site.AdminPath %>/ajax/ajax_theme.aspx?__Action=Advert_Del";
            RequestAjax(url,postData,function(res){MsgBox(1, "<%=Tag("操作成功")%>", "?")});
        }
    </script>
</lbscripts>