{layout:default} {class:Shop.Admin.User.Message}
<lbhead>
    <title><%if (type == "0"){ %><%=Tag("收信箱")%>-<%}else if (type == "1"){ %><%=Tag("发信箱")%>-<%} %><%=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"><a href="<%=site.AdminPath %>/user/Message.aspx"><%=Tag("站内信")%></a></li>
        <li class="breadcrumb-item active"><%if (type == "0"){ %><%=Tag("收信箱")%><%}else if (type == "1"){ %><%=Tag("发信箱")%><%} %><%if (user_id > 0){ %> > <%=UserName%><%} %></li>
    </ol>
</lbpath>
<lbbody>
    <%string langstr = lang;
    if (langstr == "")
    langstr = CurrentLanguage.Code;
    %>
    <div class="col-xlg-2 col-lg-3 col-md-3">
        <div class="card">
            <div class="card-body">
                <div class="row">
                    <div class="card-body inbox-panel p-t-0 p-b-0">
                        <ul class="list-group list-group-full">
                            <li class="list-group-item<%if (type == "0"){ %> active<%}%>"><a href="Message.aspx?type=0"><i class="ti-import"></i> <%=Tag("收信箱")%></a></li>
                            <li class="list-group-item<%if (type == "1"){ %> active<%}%>"><a href="Message.aspx?type=1"><i class="ti-export"></i> <%=Tag("发信箱")%></a></li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
        <div class="card">
            <div class="card-body">
                <div class="row">
                    <div class="col-md-12 col-sm-12 col-xs-12">
                        <form>
                            <div class="form-group">
                                <select id="lang" class="form-control">
                                    <option value=""><%=Tag("语言")%></option>
                                    <%=Shop.Bussiness.Language.LanguageOption(lang)%>
                                </select>
                            </div>
                            <div class="form-group">
                                <select id="type_id" class="form-control">
                                    <option value=""><%=Tag("类别") %></option>
                                    <%=Shop.Bussiness.Message.Message_TypeOption(350,type_id, langstr)%>
                                    <option value="0"><%=Tag("系统消息") %></option>
                                </select>
                            </div>
                            <div class="form-group">
                                <div class="input-group">
                                    <input type="text" name="dateFrom" id="dateFrom" value="<%if (dateFrom !=""){%><%=dateFrom%><%}else{%><%=FormatDate(System.DateTime.Now.AddDays(-7))%><%}%>" class="form-control" placeholder="<%=Tag("开始日期")%>">
                                    <div class="input-group-append">
                                        <span class="input-group-text">
                                            <span class="ti-calendar"></span>
                                        </span>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="input-group">
                                    <input type="text" name="dateTo" id="dateTo" value="<%if (dateTo !=""){%><%=dateTo%><%}else{%><%=FormatDate(System.DateTime.Now)%><%}%>" class="form-control" placeholder="<%=Tag("结束日期")%>">
                                    <div class="input-group-append">
                                        <span class="input-group-text">
                                            <span class="ti-calendar"></span>
                                        </span>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="input-group">
                                    <input type="text" name="key" id="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>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="col-xlg-10 col-lg-9 col-md-9">
        <div class="card">
            <div class="card-body">
                <div class="row">
                    <div class="col-md-12 m-b-10">
                        <%if (PageReturnMsg == ""){%>
                        <button class="btn btn-info" onclick="Write('<%=UserName%>')"><i class="ti-plus"></i> <%=Tag("发信息")%></button>
                        <button class="btn btn-danger" onclick="DeleteConfirm()"><i class="ti-trash"></i> <%=Tag("删除")%></button>
                        <%}%>
                    </div>
                </div>
                <div class="table-responsive">
                    <table class="table table-hover no-wrap">
                        <thead>
                            <tr class="no-wrap">
                                <th class="selectAll" style="width:40px">
                                    <a href="javascript:void(0);" onclick="$('input[name=\'sid\']').attr('checked',!$(this).attr('checked'));$(this).attr('checked',!$(this).attr('checked'));"><%=Tag("全选")%></a>
                                </th>
                                <%if (type == "1"){ %>
                                <th>
                                    <%=Tag("收件人")%>
                                </th>
                                <%}%>
                                <%if (type == "0"){ %>
                                <th>
                                    <%=Tag("发件人")%>
                                </th>
                                <%}%>
                                <th>
                                    <%=Tag("标题")%>
                                </th>
                                <th>
                                    <%=Tag("类别")%>
                                </th>
                                <th>
                                    <%=Tag("时间")%>
                                </th>
                                <th>
                                    <%=Tag("操作")%>
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            <%foreach (DB.LebiShop.Lebi_Message model in models){%>
                            <tr ondblclick="Edit(<%=model.id %>)">
                                <td>
                                    <label class="custom-control custom-checkbox">
                                        <input type="checkbox" id="checkbox<%=model.id %>" name="sid" value="<%=model.id %>" class="custom-control-input">
                                        <span class="custom-control-label"></span>
                                    </label>
                                    <input type="hidden" name="Uid" shop="true" value="<%=model.id %>">
                                </td>
                                <%if (type == "1"){ %>
                                <td><%=model.User_Name_To %></td>
                                <%}%>
                                <%if (type == "0"){ %>
                                <td><%=model.User_Name_From %></td>
                                <%}%>
                                <td><%if (model.IsRead == 0){%><i class="ti-email" title="<%=Tag(" 未读") %>"></i> <%}%><a href="javascript:void(0)" onclick="Edit(<%=model.id %>,<%=model.User_id_From %>)"><%=model.Title%></a></td>
                                <td><%=Lang(Shop.Bussiness.Message.Message_Type(model.Message_Type_id).Name)%></td>
                                <td><%=FormatTime(model.Time_Add)%></td>
                                <td><a href="javascript:void(0)" onclick="Edit(<%=model.id %>,<%=model.User_id_From %>)"><%if (type == "1" || model.User_id_From == 0){ %><%=Tag("阅读")%><%}else{ %><%=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.AdminAssetsPath %>/plugins/moment/moment.js"></script>
    <script src="<%=site.AdminAssetsPath %>/plugins/daterangepicker/daterangepicker.js"></script>
    <script>
        $('#dateFrom').daterangepicker({
            singleDatePicker: true,
            showDropdowns: true,
            locale: {format: 'YYYY-MM-DD'}
        });
        $('#dateTo').daterangepicker({
            singleDatePicker: true,
            showDropdowns: true,
            locale: {format: 'YYYY-MM-DD'}
        });
        function search_() {
            var lang = $("#lang").val();
            var key = $("#key").val();
            var dateFrom = $("#dateFrom").val();
            var dateTo = $("#dateTo").val();
            var type_id = $("#type_id").val();
            window.location = "?user_id=<%=user_id %>&type=<%=type%>&key=" + escape(key) + "&lang=" + lang + "&dateFrom=" + dateFrom + "&dateTo=" + dateTo + "&type_id=" + type_id;
        }
        function Write(User_Name) {
            $('#EditModal').modal("show");
            $.ajax({
                url: "message_write_window.aspx",
                type: "GET",
                cache: false,
                data: {User_Name: User_Name},
            }).done(function(result){
                $("#EditModal .modal-content").html(result);
            });
        }
        function Edit(id,id_From) {
            var title_ = "<%=Tag("回复信息")%>";
            if (id_From =="0")
                var title_ = "<%=Tag("阅读信息")%>";
            $('#EditModal').modal("show");
            $.ajax({
                url: "message_reply_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 ids = GetChkCheckedValues("sid");
            var postData = { "ids": ids };
            var url = "<%=site.AdminPath %>/ajax/ajax_user.aspx?__Action=Message_Del";
            RequestAjax(url,postData,function(){MsgBox(1, "<%=Tag("操作成功")%>", "?")});
        }
    </script>
</lbscripts>