<!--#include file="User_CommonCode.asp"-->
<!--#include file="../inc/function.asp"-->
<%
If CheckUserLogined() = False Then
    Call CloseConn
    Response.Redirect "User_Login.asp"
End If
%>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title><%=SiteName & " >> 会员中心"%></title>
<link href='../Skin/DefaultSkin.css' rel='stylesheet' type='text/css'>
</head>
<body leftmargin=0 topmargin=0>
<!--#include file="top.asp"-->
<!-- ********网页中部代码开始******** -->
<table width="756" border="0" align="center" cellpadding="0" cellspacing="0" class="user_border">
  <tr>
    <td valign="top">
      <table width="100%" border="0" cellpadding="5" cellspacing="0" class="user_box">
        <tr>
          <td class="user_righttitle"><img src="Images/point2.gif" align="absmiddle">
          <%
                Response.Write "您现在的位置：<a href='../'>" & SiteName & "</a> >> <a href='Index.asp'>会员中心</a> >> 被投诉记录"
          %></td>
        </tr>
        <tr>
          <td height="200" valign='top'>
            <% Call Main() %>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<!--#include file="bottom.asp"-->
</body>
</html>
<% Call CloseConn %>
<!--用户页面开始-->

<%
Private MaxPerPage, CurrentPage, totalPut
Private strFileName, ScriptName, ClientName, ShortedForm
Private SearchType, Keyword, strField, OrderType

Private IncludeTax, TaxRate


Public Sub Main()

    FoundErr = False
    ErrMsg = ""

    ComeUrl = Trim(Request.ServerVariables("HTTP_REFERER"))
    ScriptName = Trim(Request.ServerVariables("SCRIPT_NAME"))
    strInstallDir = GetScriptPath(ScriptName, 1)
    Site_Sn = Replace(Replace(LCase(Request.ServerVariables("SERVER_NAME") & strInstallDir), "/", ""), ".", "")
    
  
    Dim rsClient
    Set rsClient = Conn.Execute("select ClientName,ShortedForm from PE_Client where ClientID=" & ClientID & "")
    If rsClient.BOF And rsClient.EOF Then
        ClientName = ""
        ShortedForm = ""
    Else
        ClientName = rsClient(0)
        ShortedForm = rsClient(1)
    End If
    rsClient.Close
    Set rsClient = Nothing

    MaxPerPage = PE_CLng(Trim(Request("MaxPerPage")))
    Keyword = Trim(Request("keyword"))
    strField = Trim(Request("Field"))
    SearchType = Trim(Request("SearchType"))
    Action = Trim(Request("Action"))

    
    If MaxPerPage <= 0 Then MaxPerPage = 20
    If Keyword <> "" Then
        Keyword = ReplaceBadChar(Keyword)
    End If
    If SearchType = "" Then
        SearchType = 0
    Else
        SearchType = PE_CLng(SearchType)
    End If
    OrderType = PE_CLng(Trim(Request("OrderType")))
    strFileName = "User_Complain.asp?Field=" & strField & "&Keyword=" & Keyword
    If Request("page") <> "" Then
        CurrentPage = CInt(Request("page"))
    Else
        CurrentPage = 1
    End If
  
    'Response.Write ShowJS_Main("订单")
    Response.Write "<br>"
    
    Response.Write "<table width='100%' border='0' cellpadding='2' cellspacing='1' class='border'>"
    Response.Write "  <tr align='center' class='title'>"
    Response.Write "    <td width='120'>投诉时间</td>" & vbCrLf
    Response.Write "    <td width='60' align='center'>客户名称</td>" & vbCrLf
    Response.Write "    <td width='80' align='center'>投诉类型</td>" & vbCrLf
    Response.Write "    <td>主题</td>" & vbCrLf
    Response.Write "    <td width='60' align='center'>紧急程度</td>" & vbCrLf
    Response.Write "    <td width='60' align='center'>记录状态</td>" & vbCrLf
'    Response.Write "    <td width='60' align='center'>处理人</td>" & vbCrLf
'    Response.Write "    <td width='60' align='center'>处理时间</td>" & vbCrLf
'    Response.Write "    <td width='60' align='center'>处理结果</td>" & vbCrLf
'    Response.Write "    <td width='60' align='center'>回访人</td>" & vbCrLf
'    Response.Write "    <td width='60' align='center'>回访时间</td>" & vbCrLf
'    Response.Write "    <td width='60' align='center'>客户评分</td>" & vbCrLf
    Response.Write "  </tr>"
    
    Dim rsComplain, sqlComplain, TotalIncome, TotalPayout, arrComplainType, arrMagnitudeOfExigence, arrStatus
    arrComplainType = Split(GetArrFromDictionary("PE_ComplainItem", "ComplainType"), "$$$")
    arrMagnitudeOfExigence = Split(GetArrFromDictionary("PE_ComplainItem", "MagnitudeOfExigence"), "$$$")
    arrStatus = Array("未处理", "处理中", "已处理", "已回访")
    sqlComplain = "select S.*,C.ShortedForm from PE_ComplainItem S inner join PE_Client C on S.ClientID=C.ClientID where S.Defendant='" & UserName & "' order by S.ItemID desc"
    Set rsComplain = Server.CreateObject("Adodb.RecordSet")
    rsComplain.Open sqlComplain, Conn, 1, 1
    If rsComplain.BOF And rsComplain.EOF Then
        totalPut = 0
        Response.Write "<tr class='tdbg' height='50'><td colspan='20' align='center'>没有任何被投诉记录！</td></tr>"
    Else
        totalPut = rsComplain.RecordCount
        If CurrentPage < 1 Then
            CurrentPage = 1
        End If
        If (CurrentPage - 1) * MaxPerPage > totalPut Then
            If (totalPut Mod MaxPerPage) = 0 Then
                CurrentPage = totalPut \ MaxPerPage
            Else
                CurrentPage = totalPut \ MaxPerPage + 1
            End If
        End If
        If CurrentPage > 1 Then
            If (CurrentPage - 1) * MaxPerPage < totalPut Then
                rsComplain.Move (CurrentPage - 1) * MaxPerPage
            Else
                CurrentPage = 1
            End If
        End If
    
        Dim i
        i = 0
        Do While Not rsComplain.EOF

            Response.Write "  <tr class='tdbg' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"">" & vbCrLf
            Response.Write "    <td width='120'>" & rsComplain("DateAndTime") & "</td>" & vbCrLf
            Response.Write "    <td width='60' align='center'>" & rsComplain("ShortedForm") & "</td>" & vbCrLf
            Response.Write "    <td width='80' align='center'>" & GetArrItem(arrComplainType, rsComplain("ComplainType")) & "</td>" & vbCrLf
            Response.Write "    <td>" & rsComplain("Title") & "</td>" & vbCrLf
            Response.Write "    <td width='60' align='center'>" & GetArrItem(arrMagnitudeOfExigence, rsComplain("MagnitudeOfExigence")) & "</td>" & vbCrLf
            Response.Write "    <td width='60' align='center'>" & GetArrItem(arrStatus, rsComplain("Status")) & "</td>" & vbCrLf
'            Response.Write "    <td width='60' align='center'>" & rsComplain("Processor") & "</td>" & vbCrLf
'            Response.Write "    <td width='60' align='center'>" & rsComplain("EndTime") & "</td>" & vbCrLf
'            Response.Write "    <td width='60' align='center'>" & rsComplain("Result") & "</td>" & vbCrLf
'            Response.Write "    <td width='60' align='center'>" & rsComplain("ConfirmCaller") & "</td>" & vbCrLf
'            Response.Write "    <td width='60' align='center'>" & rsComplain("EndTime") & "</td>" & vbCrLf
'            Response.Write "    <td width='60' align='center'>" & String(PE_Clng(rsComplain("ConfirmStar")),"★") & "</td>" & vbCrLf
            Response.Write "    </td>" & vbCrLf
            Response.Write "  </tr>" & vbCrLf
            i = i + 1
            If i >= MaxPerPage Then Exit Do
            rsComplain.MoveNext
        Loop
    End If
    rsComplain.Close
    Set rsComplain = Nothing

    Response.Write "  </tr>"
    Response.Write "</table>"
    Response.Write ShowPage("User_Complain.asp", totalPut, MaxPerPage, CurrentPage, True, True, "条投诉记录", True)

    If FoundErr = True Then
        Response.Write WriteErrMsg(ErrMsg, ComeUrl)
    End If
    Call CloseConn

End Sub


Private Function GetArrFromDictionary(strTableName, strFieldName)
    Dim rsDictionary
    Set rsDictionary = Conn.Execute("select FieldValue from PE_Dictionary where TableName='" & strTableName & "' and FieldName='" & strFieldName & "'")
    If rsDictionary.BOF And rsDictionary.EOF Then
        GetArrFromDictionary = ""
    Else
        GetArrFromDictionary = rsDictionary(0)
    End If
    Set rsDictionary = Nothing
End Function
%>