{layout:default} {class:Shop.Admin.storeConfig.FriendLink}
<lbhead>
    <title><%=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 active"><%=Tag("友情链接")%></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="EditFirendLink(0)"><i class="ti-plus"></i> <%=Tag("添加")%></button>
                        <button class="btn btn-success" onclick="Update()"><i class="ti-check"></i> <%=Tag("保存")%></button>
                        <button class="btn btn-danger" onclick="DeleteConfirm()"><i class="ti-trash"></i> <%=Tag("删除")%></button>
                        <button class="btn btn-default" onclick="UpdateLang(0,'FriendLink');"><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>
                                <button class="btn btn-default" data-toggle="modal" data-target="#SearchModal"><i class="ti-filter"></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=\'Fid\']').attr('checked',!$(this).attr('checked'));$(this).attr('checked',!$(this).attr('checked'));"><%=Tag("全选")%></a>
                                </th>
                                <th style="width: 10%">
                                    <%=Tag("网站名称")%>
                                </th>
                                <th style="width: 15%">
                                    <%=Tag("网址")%>
                                </th>
                                <th>
                                    <%=Tag("LOGO")%>
                                </th>
                                <th style="width: 10%">
                                    <%=Tag("图片")%>
                                </th>
                                <th style="width: 10%">
                                    <%=Tag("显示")%>
                                </th>
                                <th>
                                    <%=Tag("显示语言")%>
                                </th>
                                <th style="width: 7%">
                                    <%=Tag("排序")%>
                                </th>
                                <th>
                                    <%=Tag("操作")%>
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            <%foreach (DB.LebiShop.Lebi_FriendLink model in models){%>
                            <tr ondblclick="EditFirendLink(<%=model.id %>);">
                                <td>
                                    <label class="custom-control custom-checkbox">
                                        <input type="checkbox" id="checkbox<%=model.id %>" name="Fid" value="<%=model.id %>" class="custom-control-input" del="true">
                                        <span class="custom-control-label"></span>
                                    </label>
                                    <input type="hidden" name="IDS" shop="true" value="<%=model.id %>" />
                                </td>
                                <td>
                                    <input type="text" name="Name<%=model.id %>" value="<%=model.Name %>" class="form-control form-control-sm" shop="true">
                                </td>
                                <td>
                                    <input type="text" name="Url<%=model.id %>" value="<%=model.Url %>" class="form-control form-control-sm" shop="true">
                                </td>
                                <td>
                                    <% if (model.Logo != ""){ %>
                                    <img src="<%=site.WebPath + model.Logo %>" style="height: 30px;" name="logoimg" />
                                    <%} %>
                                </td>
                                <td>
                                    <select id="IsPic<%=model.id %>" shop="true" name="IsPic<%=model.id %>" class="form-control form-control-sm">
                                        <option value="1" style="color: Red;" <%if(model.IsPic==1){%>selected<%} %>><%=Tag("是")%></option>
                                        <option value="0" <%if(model.IsPic==0){%>selected<%} %>><%=Tag("否")%></option>
                                    </select>
                                </td>
                                <td>
                                    <select id="IsShow<%=model.id %>" shop="true" name="IsShow<%=model.id %>" class="form-control form-control-sm">
                                        <option value="1" style="color: Red;" <%if(model.IsShow==1){%>selected<%} %>><%=Tag("是")%></option>
                                        <option value="0" <%if(model.IsShow==0){%>selected<%} %>><%=Tag("否")%></option>
                                    </select>
                                </td>
                                <td>
                                    <%=model.Language%>
                                </td>
                                <td>
                                    <input type="text" id="Sort<%=model.id %>" name="Sort<%=model.id %>" value="<%=model.Sort %>" class="form-control form-control-sm" shop="true" onkeyup="value=value.replace(/[^\d]/g,'')">
                                </td>
                                <td>
                                    <a href="javascript:void(0)" onclick="EditFirendLink(<%=model.id %>);"><%=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>
    <div class="modal fade" id="SearchModal" tabindex="-1" role="dialog" aria-labelledby="SearchModal">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title"><%=Tag("高级搜索")%></h4>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                </div>
                <div class="modal-body">
                    <form>
                        <div class="form-group">
                            <select id="lang" name="lang" class="form-control">
                                <option value=""><%=Tag("语言")%></option>
                                <%=Shop.Bussiness.Language.LanguageOption(lang) %>
                            </select>
                        </div>
                        <div class="form-group">
                            <select id="pic" name="pic" class="form-control">
                                <option value="2"><%=Tag("链接属性")%></option>
                                <option value="0" <%if (pic ==0){%>selected<%}%>><%=Tag("文字链接")%></option>
                                <option value="1" <%if (pic==1){%>selected<%}%>><%=Tag("图片链接")%></option>
                            </select>
                        </div>
                        <div class="form-group">
                            <select id="show" name="show" class="form-control">
                                <option value="2"><%=Tag("显示")%></option>
                                <option value="1" <%if (show==1){%>selected<%}%>><%=Tag("是")%></option>
                                <option value="0" <%if (show==0){%>selected<%}%>><%=Tag("否")%></option>
                            </select>
                        </div>
                        <div class="form-group">
                            <input name="key" type="text" id="key" class="form-control" value="<%=key %>" onkeydown="if(event.keyCode==13){modal_search_();}">
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal"><i class="ti-close"></i> <%=Tag("关闭")%></button>
                    <button type="button" class="btn btn-success" onclick="modal_search_();"><i class="ti-search"></i> <%=Tag("搜索")%></button>
                </div>
            </div>
        </div>
    </div>
</lbbody>
<lbscripts>
    <script src="<%=site.AdminJsPath %>/ajaxfileupload.js"></script>
    <script>
        function search_() {
            var key = $("#key").val();
            window.location.href = "?key=" + escape(key);
        }
        function modal_search_() {
            $("#SearchModal").modal("hide");
            var lang = $("#lang").val();
            var pic = $("#pic").val();
            var show = $("#show").val();
            var key = $("#key").val();
            window.location.href = "?key=" + escape(key) + "&show=" + show + "&pic=" + pic + "&lang=" + lang;
        }
        function EditFirendLink(id) {
            var title_ = "<%=Tag("编辑友情链接")%>";
            if (id == 0) title_ = "<%=Tag("添加友情链接")%>"
            $("#EditModal").modal("show");
            $.ajax({
                url: "friendlink_edit_window.aspx",
                type: "GET",
                cache: false,
                data: {id:id,title:title_},
            }).done(function(result){
                $("#EditModal .modal-content").html(result);
            });
        }
        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_site.aspx?__Action=FriendLink_Del";
            RequestAjax(url,postData,function(){MsgBox(1, "<%=Tag("操作成功")%>", "?")});
        }
        function Update() {
            var postData = GetFormJsonData("shop");
            var url = "<%=site.AdminPath %>/ajax/ajax_site.aspx?__Action=FriendLinks_Edit";
            RequestAjax(url,postData,function(){MsgBox(1, "<%=Tag("操作成功")%>", "?")});
        }
        function UpdateLang(ids,table) {
            if (ids == 0)
                ids = GetChkCheckedValues("ids");
            $("#EditModal").modal("show");
            $.ajax({
                url: "<%=site.AdminPath %>/config/setlanguage_edit_window.aspx",
                type: "GET",
                cache: false,
                data: {ids: ids,table: table},
            }).done(function(result){
                $("#EditModal .modal-content").html(result);
            });
        }
    </script>
</lbscripts>