<!--#include file="../../Inc/Cls_Main.Asp"-->
<!--#include file="../inc/Cls_Admin.Asp"-->
<!--#include file="../inc/Cls_MapPath.Asp"-->
<!--#include file="../Admin_Check.Asp"-->
<%
Dim CmsAdmin, ToUrl
ToUrl = CmsFun.LoadToUrl()
'=============================================================================
Set CmsAdmin = New Cls_Admin
CmsAdmin.SetAdminTitle = CmsSiteName
CmsAdmin.SetBodyCssName = "mainbody"
CmsAdmin.SetAdminPath = CmsAdminMapPath
CmsAdmin.LoadHead()
'============================================================================= 查询频道信息
Dim ChannelId, ChannelName, BriefName, TabName
ChannelId = Easp.Get("ChannelId:n:0")
If ChannelId = 0 Then
    CmsAdmin.JscriptMsg "频道参数错误！", "", "Error", "null"
End If
' 读取频道信息
Dim ArrayChannel
ArrayChannel = GetCaCheChannelInfo("Channel", ChannelId, ChannelField)
If Easp.IsN(ArrayChannel) Then
    CmsAdmin.JscriptMsg "不存在的频道！", "", "Error", "null"
Else
    ChannelName = ArrayChannel(0)
    BriefName = ArrayChannel(1)
    TabName = ArrayChannel(2)
End If
'=============================================================================
Dim Action
'=============================================================================
Action = Easp.Get("action")
Select Case Action
    Case "pageload"
        Call PageLoad()
    Case "chk"
        Call ChkData()
    Case "delall"
        Call DelAll()
    Case Else
        Call PageLoad()
End Select
CmsAdmin.LoadFooter()
Set CmsAdmin = Nothing

Sub PageLoad()
    ChkChannelAdminLevel ChannelId, "show"
    '=====================================================================
    ' 搜索
    Dim Keywords
    Keywords = Trim(Easp.Get("Keywords:s"))
%>
<div class="navigation">频道管理 &gt; <%=ChannelName%> &gt; 评论管理</div>
<div class="tools_box">
  <div class="tools_bar">
    <ul>
      <li><a href="javascript:void(0);" onclick="checkAll(this);" class="tools_btn"><span><b class="all">全选</b></span></a></li>
      <li><a href="javascript:void(0);" onclick="return ExePostBack('确定要批量删除吗？','myform','?action=delall&ChannelId=<%=ChannelId%>');" class="tools_btn"><span><b class="delete">批量删除</b></span></a></li>
      <li><a href="javascript:void(0);" onclick="return ExePostBack('确定要批量审核吗？','myform','?action=chk&ChannelId=<%=ChannelId%>');" class="tools_btn"><span><b class="send">批量审核</b></span></a></li>
      <li><a href="Admin.Index.Asp" class="tools_btn"><span><b class="refresh">刷新列表</b></span></a></li>
    </ul>
  </div>
  <div class="select_box">
    <form id="searchType" action="" method="get">
      <input type="hidden" name="ChannelId" value="<%=ChannelId%>" />
      <input name="Keywords" type="text" id="Keywords" class="txtInput w200" autocomplete="off" value="<%=Keywords%>" />
      <input type="submit" value="搜索" class="btnSearch" />
    </form>
  </div>
</div>
<form id="myform" action="?action=chk&ChannelId=<%=ChannelId%>" method="post">
  <table width="100%" border="0" cellspacing="0" cellpadding="0" class="msgtable">
    <tr>
      <th width="5%">选择</th>
      <th width="35%" align="left">信息标题</th>
      <th width="15%" align="left">留言人</th>
      <th width="10%">状态</th>
      <th width="10%">回复状态</th>
      <th width="15%">时间</th>
      <th width="10%">操作</th>
    </tr>
    <%
    Dim ShowPage, oRs, PageNum, ArrayList, i, oSQL, TempWhere
    ShowPage = ""
    PageNum = 20
    '============================ search
    TempWhere = ""
    If Not Easp.IsN(Keywords) Then
        TempWhere = TempWhere & " And a.Info Like '%"& Keywords &"%' "
    End If
    '============================ page
    Easp.db.PageSize = PageNum
    Easp.db.SetPager "default", "<span class=""disableds"">总记录数:{recordcount},每页:{pagesize},页次:{pageindex}/{pagecount}</span> {first}{prev}{list}{next}{last}{jump}", Array("first:首　页", "last:尾　页", "prev:上一页", "next:下一页", "list:*")
    oSQL = "Select a.Id,b.Title,a.UserName,a.IsChk,a.IsReply,a.AddTime,a.DataId From ["& TablePrefix & "Comment] a "
    oSQL = oSQL & " Left Join ["& TabName & "] b On a.DataId = b.Id "
    oSQL = oSQL & " Where ChannelId = "& ChannelId &" " & TempWhere
    oSQL = oSQL & " Order By a.Id desc "
    Set oRs = Easp.db.GPR("1:p", oSQL)
    If Easp.IsN(oRs) Then
        Easp.C(oRs)
    Else
        ShowPage = Easp.db.GetPager("default")
        ArrayList = oRs.GetRows(PageNum)
    End If
    Easp.C oRs
    If IsArray(ArrayList) Then
        For i = 0 To UBound(ArrayList, 2)
    %>
    <tr align="center">
      <td><input type="checkbox" name="chkId" value="<%=ArrayList(0,i)%>" /></td>
      <td align="left"><a href="javascript:parent.f_addTab('ChannelId_<%=ChannelId%>','<%=ChannelName%>','info/Admin.Index.asp?ChannelId=<%=ChannelId%>&DataId=<%=ArrayList(6,i)%>')"><%=ArrayList(1,i)%></a></td>
      <td align="left"><%=ArrayList(2,i)%></td>
      <td><%=Easp.IIF(ArrayList(3,i) = 1,"已审核",CmsFun.ShowColor("未审核","red"))%></td>
      <td><%=Easp.IIF(ArrayList(4,i) = 1,"已回复",CmsFun.ShowColor("未回复","blue"))%></td>
      <td><%=CmsFun.TimeToString(ArrayList(5,i),"yyyy-mm-dd")%></td>
      <td><a href="Admin.Reply.Asp?ChannelId=<%=ChannelId%>&id=<%=ArrayList(0,i)%>">回复</a></td>
    </tr>
    <%
        Next
    End If
    %>
  </table>
  <div class="line15"> </div>
  <div class="page_box">
    <div class="flickr right"><%=ShowPage%></div>
  </div>
</form>
<%
End Sub

Sub ChkData()
    ChkChannelAdminLevel ChannelId, "edit"
    '=====================================================================
    Dim chkId
    chkId = Replace(Easp.Post("chkId:s"), ", ", ",")
    If Easp.IsN(chkId) Then
        CmsAdmin.JscriptMsg "对不起，请选中您要操作的记录！", "back", "Error", "null"
    End If
    Easp.db.UR TablePrefix & "Comment", " Id in("& chkId &") ", Array("IsChk:1")
    CmsAdmin.JscriptMsg "批量审核成功！", ToUrl, "Success", "null"
End Sub

Sub DelAll()
    ChkChannelAdminLevel ChannelId, "del"
    '=====================================================================
    Dim chkId, ResultVal
    chkId = Easp.Post("chkId:s")
    If Easp.IsN(chkId) Then
        CmsAdmin.JscriptMsg "对不起，请选中您要操作的记录！", "back", "Error", "null"
    Else
        ResultVal = Easp.db.DR(TablePrefix & "Comment", "Id:" & chkId)
        If ResultVal <> 0 Then
            CmsAdmin.JscriptMsg "批量删除成功！", ToUrl, "Success", "null"
        End If
    End If
End Sub
%>
