<!--#include file="Admin_Common.asp"-->
<!--#include file="Admin_CommonCode_CRM.asp"-->
<%
'**************************************************************
' Software name: PowerEasy SiteWeaver
' Web: http://www.powereasy.net
' Copyright (C) 2005－2008 佛山市动易网络科技有限公司 版权所有
'**************************************************************

Const NeedCheckComeUrl = True   '是否需要检查外部访问

Const PurviewLevel = 2      '0--不检查，1--超级管理员，2--普通管理员
Const PurviewLevel_Channel = 0   '0--不检查，1--频道管理员，2--栏目总编，3--栏目管理员
Const PurviewLevel_Others = ""   '其他权限

Dim arrComplainType, arrComplainMode, arrMagnitudeOfExigence, arrStatus, arrConfirmScore

'检查管理员操作权限
If AdminPurview > 1 Then
    arrPurview(0) = CheckPurview_Other(AdminPurview_Others, "Complain_View")
    arrPurview(1) = CheckPurview_Other(AdminPurview_Others, "Complain_Add")
    arrPurview(2) = CheckPurview_Other(AdminPurview_Others, "Complain_ModifyOwn")
    arrPurview(3) = CheckPurview_Other(AdminPurview_Others, "Complain_ModifyAll")
    arrPurview(4) = CheckPurview_Other(AdminPurview_Others, "Complain_Del")
    arrPurview(5) = CheckPurview_Other(AdminPurview_Others, "Call_View")
    arrPurview(6) = CheckPurview_Other(AdminPurview_Others, "Call_Add")
    arrPurview(7) = CheckPurview_Other(AdminPurview_Others, "Call_ModifyOwn")
    arrPurview(8) = CheckPurview_Other(AdminPurview_Others, "Call_ModifyAll")
    arrPurview(9) = CheckPurview_Other(AdminPurview_Others, "Service_Add")
    arrPurview(10) = CheckPurview_Other(AdminPurview_Others, "Service_ModifyOwn")
    arrPurview(11) = CheckPurview_Other(AdminPurview_Others, "Service_ModifyAll")

    For PurviewIndex = 0 To 4
        If arrPurview(PurviewIndex) = True Then
            PurviewPassed = True
            Exit For
        End If
    Next
    If PurviewPassed = False Then
        Response.Write "<br><p align='center'><font color='red' style='font-size:9pt'>对不起，你没有此项操作的权限。</font></p>"
        Call WriteEntry(6, AdminName, "越权操作")
        Response.End
    End If
End If

Response.Write "<html>" & vbCrLf
Response.Write "<head>" & vbCrLf
Response.Write "<title>客户投诉管理</title>" & vbCrLf
Response.Write "<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>" & vbCrLf
Response.Write "<link rel='stylesheet' href='Admin_Style.css'>" & vbCrLf
Response.Write "</head>" & vbCrLf
Response.Write "<body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'>" & vbCrLf
Response.Write "<table width='100%'  border='0' cellpadding='2' cellspacing='1' class='border'>" & vbCrLf
Call ShowPageTitle("客 户 投 诉 管 理", 10224)
Response.Write "  <tr class='tdbg'>" & vbCrLf
Response.Write "  <form name='form1' action='Admin_Complain.asp' method='get'>"
Response.Write "    <td>快速查找：" & vbCrLf
Response.Write "      <select name='SearchType' onChange='javascript:submit()'>" & vbCrLf
Response.Write "        <option " & OptionValue(SearchType, 0) & ">全部记录</option>" & vbCrLf
Response.Write "        <option " & OptionValue(SearchType, 1) & ">10天内的记录</option>" & vbCrLf
Response.Write "        <option " & OptionValue(SearchType, 2) & ">1个月内的记录</option>" & vbCrLf
Response.Write "        </select>&nbsp;&nbsp;&nbsp;&nbsp;" & vbCrLf
Response.Write "    <a href='Admin_Complain.asp'>客户投诉管理首页</a> | <a href='Admin_Complain.asp?Action=Add'>添加投诉记录</a></td>" & vbCrLf
Response.Write "  </form>" & vbCrLf
Response.Write "<form name='form2' method='post' action='Admin_Complain.asp'>" & vbCrLf
Response.Write "    <td>高级查询：" & vbCrLf
Response.Write "      <select name='Field' id='Field'>" & vbCrLf
Response.Write "        <option value='ClientName'>客户名称</option>" & vbCrLf
Response.Write "        <option value='ClientID'>客户ID</option>" & vbCrLf
Response.Write "        <option value='ComplainTime'>投诉时间</option>" & vbCrLf
Response.Write "      </select>" & vbCrLf
Response.Write "      <input name='Keyword' type='text' id='Keyword' size='20' maxlength='30'>" & vbCrLf
Response.Write "      <input type='submit' name='Submit2' value=' 查 询 '>" & vbCrLf
Response.Write "      <input name='SearchType' type='hidden' id='SearchType' value='10'>" & vbCrLf
Response.Write "    </td>" & vbCrLf
Response.Write "</form>" & vbCrLf
Response.Write "  </tr>" & vbCrLf
Response.Write "</table>" & vbCrLf

arrComplainType = GetArrFromDictionary("PE_ComplainItem", "ComplainType")
arrComplainMode = GetArrFromDictionary("PE_ComplainItem", "ComplainMode")
arrMagnitudeOfExigence = GetArrFromDictionary("PE_ComplainItem", "MagnitudeOfExigence")
arrStatus = Array("未处理", "处理中", "已处理", "已回访")
arrConfirmScore = GetArrFromDictionary("PE_ServiceItem", "ConfirmScore")

Select Case Action
Case "Add"
    Call add
Case "Modify"
    Call Modify
Case "SaveAdd", "SaveModify"
    Call SaveComplain
Case "SaveProcess"
    Call SaveProcess
Case "SaveConfirm"
    Call SaveConfirm
Case "Show", "Confirm", "Process"
    Call Show
Case "Del"
    Call Del
Case Else
    Call main
End Select
If FoundErr = True Then
    Call WriteErrMsg(ErrMsg, ComeUrl)
End If
Response.Write "</body></html>"
Call CloseConn


Sub main()
    strFileName = "Admin_Complain.asp?SearchType=" & SearchType & "&Field=" & strField & "&keyword=" & Keyword
    
    Call ShowJS_Main("记录")
    
    
    Response.Write "<br><table width='100%'><tr><td align='left'>您现在的位置：<a href='Admin_Complain.asp'>投诉管理</a>&nbsp;&gt;&gt;&nbsp;"

    Dim sql, Querysql
    Select Case SearchType
    Case 1, 2, 10
        sql = "select S.*,C.ShortedForm from PE_ComplainItem S inner join PE_Client C on S.ClientID=C.ClientID"
    Case Else
        sql = "select top " & MaxPerPage & " " & " S.*,C.ShortedForm from PE_ComplainItem S inner join PE_Client C on S.ClientID=C.ClientID"
    End Select

    Querysql = Querysql & " where 1=1 "
    Select Case SearchType
    Case 0
        Response.Write "所有投诉记录"
    Case 1
        Querysql = Querysql & " and datediff(" & PE_DatePart_D & ",S.DateAndTime," & PE_Now & ")<10"
        Response.Write "10天内的记录"
    Case 2
        Querysql = Querysql & " and datediff(" & PE_DatePart_D & ",S.DateAndTime," & PE_Now & ")<30"
        Response.Write "一个月内的记录"
    Case 10
        If Keyword = "" Then
            Response.Write "所有记录"
        Else
            Select Case strField
            Case "ClientID"
                If IsNumeric(Keyword) = False Then
                    FoundErr = True
                    ErrMsg = ErrMsg & "<li>客户ID必须是整数</li>"
                Else
                    Querysql = Querysql & " and S.ClientID=" & PE_CLng(Keyword)
                    Response.Write "客户ID等于<font color=red> " & PE_CLng(Keyword) & " </font>的客户"
                End If
            Case "ClientName"
                Querysql = Querysql & " and C.ClientName like '%" & Keyword & "%'"
                Response.Write "名称中含有“ <font color=red>" & Keyword & "</font> ”的客户"
            Case "ComplainTime"
                If IsDate(Keyword) = True Then
                    Querysql = Querysql & " and DateDiff(" & PE_DatePart_D & ",S.DateAndTime,'" & Keyword & "')=0 "
                    Response.Write "<font color=red>" & Year(Keyword) & "-" & Month(Keyword) & "-" & Day(Keyword) & "</font> 投诉的记录"
                Else
                    FoundErr = True
                    ErrMsg = ErrMsg & "<li>查询的投诉时间格式不正确！</li>"
                End If
            Case Else
                Querysql = Querysql & " and C.ClientName like '%" & Keyword & "%'"
                Response.Write "名称中含有“ <font color=red>" & Keyword & "</font> ”的客户"
            End Select
        End If
    End Select
    
    If SearchType = 10 Then
        TotalPut = PE_CLng(Conn.Execute("select Count(*) from PE_ComplainItem S inner join PE_Client C on S.ClientID=C.ClientID " & Querysql)(0))
    Else
        TotalPut = PE_CLng(Conn.Execute("select Count(*) from PE_ComplainItem S " & Querysql)(0))
    End If
    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
        Querysql = Querysql & " and ItemID < (select min(ItemID) from (select top " & ((CurrentPage - 1) * MaxPerPage) & " ItemID from PE_ComplainItem S " & Querysql & " order by ItemID desc) as QueryClient) "
    End If
    sql = sql & Querysql & " order by ItemID desc"


    Response.Write "</td></tr></table>"
    If FoundErr = True Then Exit Sub
    
    Response.Write "<table width='100%'  border='0' cellpadding='2' cellspacing='1' class='border'>" & vbCrLf
    Response.Write "  <tr align='center' class='title'>" & vbCrLf
    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 "    <td width='90' align='center'>操作</td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Dim rsComplain, i
    Set rsComplain = Conn.Execute(sql)
    If rsComplain.BOF And rsComplain.EOF Then
        Response.Write "<tr><td colspan='20' height='50' align='center' class='tdbg'>没有任何投诉记录！</td></tr>"
    Else
        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'><a href='Admin_Client.asp?Action=Show&InfoType=6&ClientID=" & rsComplain("ClientID") & "'>" & rsComplain("ShortedForm") & "</a></td>" & vbCrLf
            Response.Write "    <td width='80' align='center'>" & GetArrItem(arrComplainType, rsComplain("ComplainType")) & "</td>" & vbCrLf
            Response.Write "    <td><a href='Admin_Complain.asp?Action=Show&ItemID=" & rsComplain("ItemID") & "'>" & rsComplain("Title") & "</a></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 width='90' align='center'>"
            If AdminPurview = 1 Or arrPurview(3) = True Or (arrPurview(2) = True And rsComplain("FirstReceiver") = AdminName) Then
                Response.Write "<a href='Admin_Complain.asp?Action=Modify&ItemID=" & rsComplain("ItemID") & "'>修改</a> "
            End If
            If AdminPurview = 1 Or arrPurview(4) = True Then
                Response.Write "<a href='Admin_Complain.asp?Action=Del&ItemID=" & rsComplain("ItemID") & "' onclick=""return confirm('确实要删除此投诉记录吗？');"">删除</a>"
            End If
            Response.Write "    </td>" & vbCrLf
            Response.Write "  </tr>" & vbCrLf
            i = i + 1
            If i >= MaxPerPage Then Exit Do
            rsComplain.MoveNext
        Loop
    End If
    Set rsComplain = Nothing
    Response.Write "</table>" & vbCrLf

    If TotalPut > 0 Then
        Response.Write ShowPage(strFileName, TotalPut, MaxPerPage, CurrentPage, True, True, "条记录", True)
    End If

End Sub
Sub ShowJS_Check()
    Response.Write "<script type='text/javascript' language='javascript'>" & vbCrLf
    Response.Write "function SelectClient(){" & vbCrLf
    Response.Write "    var arr=showModalDialog('Admin_SourceList.asp?TypeSelect=ClientList','','dialogWidth:600px; dialogHeight:450px; help: no; scroll: yes; status: no');" & vbCrLf
    Response.Write "    if (arr != null){" & vbCrLf
    Response.Write "        var ss=arr.split('$$$');" & vbCrLf
    Response.Write "        document.myform.ClientName.value=ss[0];" & vbCrLf
    Response.Write "        document.myform.ClientID.value=ss[1];" & vbCrLf
    Response.Write "        makeRequest('Admin_GetContacter.asp?ClientID='+ss[1]);" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "function SelectDefendant(){" & vbCrLf
    Response.Write "    var arr=showModalDialog('Admin_SourceList.asp?TypeSelect=AgentList&DefaultValue='+document.myform.Defendant.value,'','dialogWidth:600px; dialogHeight:450px; help: no; scroll: yes; status: no');" & vbCrLf
    Response.Write "    if (arr != null){" & vbCrLf
    Response.Write "        document.myform.Defendant.value=arr;" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "function SelectReceiver(){" & vbCrLf
    Response.Write "    var arr=showModalDialog('Admin_SourceList.asp?TypeSelect=AdminList&DefaultValue='+document.myform.FirstReceiver.value,'','dialogWidth:600px; dialogHeight:450px; help: no; scroll: yes; status: no');" & vbCrLf
    Response.Write "    if (arr != null){" & vbCrLf
    Response.Write "        document.myform.FirstReceiver.value=arr;" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "function SelectProcessor(){" & vbCrLf
    Response.Write "    var arr=showModalDialog('Admin_SourceList.asp?TypeSelect=AdminList&DefaultValue='+document.myform.Processor.value,'','dialogWidth:600px; dialogHeight:450px; help: no; scroll: yes; status: no');" & vbCrLf
    Response.Write "    if (arr != null){" & vbCrLf
    Response.Write "        document.myform.Processor.value=arr;" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "function SelectOwner(){" & vbCrLf
    Response.Write "    var arr=showModalDialog('Admin_SourceList.asp?TypeSelect=AdminList&DefaultValue='+document.myform.CurrentOwner.value,'','dialogWidth:600px; dialogHeight:450px; help: no; scroll: yes; status: no');" & vbCrLf
    Response.Write "    if (arr != null){" & vbCrLf
    Response.Write "        document.myform.CurrentOwner.value=arr;" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "}" & vbCrLf

    Response.Write "var http_request = false;" & vbCrLf
    Response.Write "function makeRequest(url) {" & vbCrLf
    Response.Write "  http_request = false;" & vbCrLf
    Response.Write "  if (window.XMLHttpRequest) { // Mozilla, Safari,..." & vbCrLf
    Response.Write "    http_request = new XMLHttpRequest();" & vbCrLf
    Response.Write "    if (http_request.overrideMimeType) {" & vbCrLf
    Response.Write "      http_request.overrideMimeType('text/xml');" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "  } else if (window.ActiveXObject) { // IE" & vbCrLf
    Response.Write "    try {" & vbCrLf
    Response.Write "      http_request = new ActiveXObject('Msxml2.XMLHTTP');" & vbCrLf
    Response.Write "    } catch (e) {" & vbCrLf
    Response.Write "      try {" & vbCrLf
    Response.Write "        http_request = new ActiveXObject('Microsoft.XMLHTTP');" & vbCrLf
    Response.Write "      } catch (e) {}" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "  }" & vbCrLf
    Response.Write "  if (!http_request) {" & vbCrLf
    Response.Write "    alert('Giving up :( Cannot create an XMLHTTP instance');" & vbCrLf
    Response.Write "    return false;" & vbCrLf
    Response.Write "  }" & vbCrLf
    Response.Write "  http_request.onreadystatechange = GetContacter;" & vbCrLf
    Response.Write "  http_request.open('GET', url, true);" & vbCrLf
    Response.Write "  http_request.send(null);" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "function GetContacter() {" & vbCrLf
    Response.Write "  if (http_request.readyState == 4) {" & vbCrLf
    Response.Write "    if (http_request.status == 200) {" & vbCrLf
    Response.Write "      document.getElementById('ContacterList').innerHTML=http_request.responseText;" & vbCrLf
'   Response.Write "      alert(http_request.responseText);" & vbCrlf
    Response.Write "    } else {" & vbCrLf
    Response.Write "      alert('There was a problem with the request.');" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "  }" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "</script>" & vbCrLf
End Sub

Sub add()
    If AdminPurview > 1 And arrPurview(1) = False Then
        Response.Write "<br><p align='center'><font color='red' style='font-size:9pt'>对不起，你没有此项操作的权限。</font></p>"
        Call WriteEntry(6, AdminName, "越权操作")
        Exit Sub
    End If

    Call ShowJS_Check
    Dim ClientID, ContacterID
    ClientID = PE_CLng(Trim(Request("ClientID")))
    ContacterID = PE_CLng(Trim(Request("ContacterID")))
    
    Response.Write "<form name='myform' method='post' action='Admin_Complain.asp'>" & vbCrLf
    Response.Write "  <table width='100%'  border='0' cellpadding='2' cellspacing='1' class='border'>" & vbCrLf
    Response.Write "    <tr class='title' align='center'>" & vbCrLf
    Response.Write "      <td colspan='2'><strong>添 加 客 户 投 诉 记 录</strong></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right' class='tdbg5'>投诉时间：</td>" & vbCrLf
    Response.Write "      <td><input name='DateAndTime' type='text' id='DateAndTime' value='" & Now() & "' size='30' maxlength='30'></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td width='15%' align='right' class='tdbg5'>投诉主题：</td>" & vbCrLf
    Response.Write "      <td width='85%'><input name='Title' type='text' id='Title' size='50' maxlength='50'></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right' class='tdbg5'>投诉客户：</td>" & vbCrLf
    Response.Write "      <td><input name='ClientName' type='text' id='ClientName' ReadOnly size='50' maxlength='200' ReadOnley value='" & GetClientName(ClientID) & "'>" & vbCrLf
    Response.Write "      <input type='button' name='Submit' value='...' onclick='SelectClient();'>" & vbCrLf
    Response.Write "      <input name='ClientID' type='hidden' id='ClientID' value='" & ClientID & "'></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right' class='tdbg5'>客户方联系人：</td>" & vbCrLf
    Response.Write "      <td><span id='ContacterList'><select name='ContacterID'>" & GetContacterOption(ClientID, ContacterID) & "</select></span></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right' class='tdbg5'>投诉类型：</td>" & vbCrLf
    Response.Write "      <td><select name='ComplainType' id='ComplainType'>" & Array2Option(arrComplainType, 0) & "</select></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right' class='tdbg5'>投诉方式：</td>" & vbCrLf
    Response.Write "      <td><select name='ComplainMode' id='ComplainMode'>" & Array2Option(arrComplainMode, 0) & "</select></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right' class='tdbg5'>紧急程度：</td>" & vbCrLf
    Response.Write "      <td><select name='MagnitudeOfExigence' id='MagnitudeOfExigence'>" & Array2Option(arrMagnitudeOfExigence, 0) & "</select></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right' class='tdbg5'>被投诉对象：</td>" & vbCrLf
    Response.Write "      <td><input name='Defendant' type='text' id='Defendant' size='30'>" & vbCrLf
    Response.Write "      <input type='button' name='Submit' value='...' onclick='SelectDefendant();'>"
    Response.Write "</td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right' class='tdbg5'>投诉内容：</td>" & vbCrLf
    Response.Write "      <td><textarea name='Content' cols='40' rows='5' id='Content'></textarea></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right' class='tdbg5'>接待人：</td>" & vbCrLf
    Response.Write "      <td><input name='FirstReceiver' type='text' id='FirstReceiver' size='50' value='" & AdminName & "' >" & vbCrLf
    If AdminPurview = 1 Then
        Response.Write "      <input type='button' name='Submit' value='...' onclick='SelectReceiver();'>"
    End If
    Response.Write "</td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right' class='tdbg5'>转交给谁处理：</td>" & vbCrLf
    Response.Write "      <td><input name='CurrentOwner' type='text' id='CurrentOwner' size='50' value='' ReadOnley>" & vbCrLf
    If AdminPurview = 1 Then
        Response.Write "      <input type='button' name='Submit' value='...' onclick='SelectOwner();'>"
    End If
    Response.Write "</td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right' class='tdbg5'>备注：</td>" & vbCrLf
    Response.Write "      <td><textarea name='Remark' cols='40' rows='4' id='Remark'></textarea></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr align='center'>" & vbCrLf
    Response.Write "      <td height='40' colspan='2' class='tdbg'><input type='hidden' name='Action' value='SaveAdd'><input type='submit' name='Submit' value='保存投诉记录'></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "  </table>" & vbCrLf
    Response.Write "</form>" & vbCrLf
End Sub

Sub Modify()
    If AdminPurview > 1 And arrPurview(2) = False And arrPurview(3) = False Then
        Response.Write "<br><p align='center'><font color='red' style='font-size:9pt'>对不起，你没有此项操作的权限。</font></p>"
        Call WriteEntry(6, AdminName, "越权操作")
        Exit Sub
    End If

    Call ShowJS_Check

    Dim ItemID, rsComplain
    ItemID = PE_CLng(Trim(Request("ItemID")))
    If ItemID <= 0 Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请指定要修改的投诉记录的ID！</li>"
    End If
    
    Set rsComplain = Conn.Execute("select * from PE_ComplainItem where ItemID=" & ItemID & "")
    If rsComplain.BOF And rsComplain.EOF Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>找不到指定的投诉记录！</li>"
        rsComplain.Close
        Set rsComplain = Nothing
        Exit Sub
    End If
    If rsComplain("FirstReceiver") <> AdminName And AdminPurview > 1 And arrPurview(3) = False Then
        Response.Write "<br><p align='center'><font color='red' style='font-size:9pt'>对不起，你没有此项操作的权限。</font></p>"
        Call WriteEntry(6, AdminName, "越权操作")
        rsComplain.Close
        Set rsComplain = Nothing
        Exit Sub
    End If

    Response.Write "<form name='myform' method='post' action='Admin_Complain.asp'>" & vbCrLf
    Response.Write "  <table width='100%'  border='0' cellpadding='2' cellspacing='1' class='border'>" & vbCrLf
    Response.Write "    <tr class='title' align='center'>" & vbCrLf
    Response.Write "      <td colspan='2'><strong>修 改 客 户 投 诉 记 录</strong></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right' class='tdbg5'>投诉时间：</td>" & vbCrLf
    Response.Write "      <td><input name='DateAndTime' type='text' id='DateAndTime' value='" & rsComplain("DateAndTime") & "' size='30' maxlength='30'></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td width='15%' align='right' class='tdbg5'>投诉主题：</td>" & vbCrLf
    Response.Write "      <td width='85%'><input name='Title' type='text' id='Title' size='50' maxlength='50' value='" & rsComplain("Title") & "'></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right' class='tdbg5'>投诉客户：</td>" & vbCrLf
    Response.Write "      <td><input name='ClientName' type='text' id='ClientName' ReadOnly size='50' maxlength='200' ReadOnley value='" & GetClientName(rsComplain("ClientID")) & "'>" & vbCrLf
    Response.Write "      <input type='button' name='Submit' value='...' onclick='SelectClient();'>" & vbCrLf
    Response.Write "      <input name='ClientID' type='hidden' id='ClientID' value='" & rsComplain("ClientID") & "'></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right' class='tdbg5'>客户方联系人：</td>" & vbCrLf
    Response.Write "      <td><span id='ContacterList'><select name='ContacterID'>" & GetContacterOption(rsComplain("ClientID"), rsComplain("ContacterID")) & "</select></span></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right' class='tdbg5'>投诉类型：</td>" & vbCrLf
    Response.Write "      <td><select name='ComplainType' id='ComplainType'>" & Array2Option(arrComplainType, rsComplain("ComplainType")) & "</select></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right' class='tdbg5'>投诉方式：</td>" & vbCrLf
    Response.Write "      <td><select name='ComplainMode' id='ComplainMode'>" & Array2Option(arrComplainMode, rsComplain("ComplainMode")) & "</select></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right' class='tdbg5'>紧急程度：</td>" & vbCrLf
    Response.Write "      <td><select name='MagnitudeOfExigence' id='MagnitudeOfExigence'>" & Array2Option(arrMagnitudeOfExigence, rsComplain("MagnitudeOfExigence")) & "</select></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right' class='tdbg5'>被投诉对象：</td>" & vbCrLf
    Response.Write "      <td><input name='Defendant' type='text' id='Defendant' size='30' value='" & rsComplain("Defendant") & "'>" & vbCrLf
    Response.Write "      <input type='button' name='Submit' value='...' onclick='SelectDefendant();'>"
    Response.Write "</td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right' class='tdbg5'>投诉内容：</td>" & vbCrLf
    Response.Write "      <td><textarea name='Content' cols='40' rows='5' id='Content'>" & rsComplain("Content") & "</textarea></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right' class='tdbg5'>接待人：</td>" & vbCrLf
    Response.Write "      <td><input name='FirstReceiver' type='text' id='FirstReceiver' size='50' value='" & rsComplain("FirstReceiver") & "' ReadOnley>" & vbCrLf
    If AdminPurview = 1 Then
        Response.Write "      <input type='button' name='Submit' value='...' onclick='SelectReceiver();'>"
    End If
    Response.Write "</td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right' class='tdbg5'>当前责任人：</td>" & vbCrLf
    Response.Write "      <td><input name='CurrentOwner' type='text' id='CurrentOwner' size='50' value='" & rsComplain("CurrentOwner") & "' ReadOnley>" & vbCrLf
    If AdminPurview = 1 Then
        Response.Write "      <input type='button' name='Submit' value='...' onclick='SelectOwner();'>"
    End If
    Response.Write "</td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right' class='tdbg5'>备注：</td>" & vbCrLf
    Response.Write "      <td><textarea name='Remark' cols='40' rows='4' id='Remark'>" & rsComplain("Remark") & "</textarea></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr align='center'>" & vbCrLf
    Response.Write "      <td height='40' colspan='2' class='tdbg'><input type='hidden' name='ItemID' value='" & ItemID & "'><input type='hidden' name='Action' value='SaveModify'><input type='submit' name='Submit' value='保存投诉记录'></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "  </table>" & vbCrLf
    Response.Write "</form>" & vbCrLf
    rsComplain.Close
    Set rsComplain = Nothing
End Sub

Sub Show()
    Dim ItemID, rsComplain
    ItemID = PE_CLng(Trim(Request("ItemID")))
    If ItemID <= 0 Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请指定要修改的投诉记录的ID！</li>"
    End If
    
    Set rsComplain = Conn.Execute("select * from PE_ComplainItem where ItemID=" & ItemID & "")
    If rsComplain.BOF And rsComplain.EOF Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>找不到指定的投诉记录！</li>"
        rsComplain.Close
        Set rsComplain = Nothing
        Exit Sub
    End If

    Response.Write "<script language='javascript'>" & vbCrLf
    Response.Write "var tID=0;" & vbCrLf
    Response.Write "function ShowTabs(ID){" & vbCrLf
    Response.Write "  if(ID!=tID){" & vbCrLf
    Response.Write "    TabTitle[tID].className='title5';" & vbCrLf
    Response.Write "    TabTitle[ID].className='title6';" & vbCrLf
    Response.Write "    Tabs[tID].style.display='none';" & vbCrLf
    Response.Write "    Tabs[ID].style.display='';" & vbCrLf
    Response.Write "    tID=ID;" & vbCrLf
    Response.Write "  }" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "</script>" & vbCrLf

    Response.Write "<br><table width='100%'><tr><td align='left'>您现在的位置：<a href='Admin_Complain.asp'>投诉管理</a>&nbsp;&gt;&gt;&nbsp;查看投诉记录</td></tr></table>"
    Response.Write "<br><table  width='100%' border='0' align='center' cellpadding='0' cellspacing='0'>" & vbCrLf
    Response.Write "        <tr align='center' height='24'>" & vbCrLf
    Response.Write "            <td id='TabTitle' class='title6' onclick='ShowTabs(0)'>投诉信息</td>" & vbCrLf
    Response.Write "            <td id='TabTitle' class='title5' onclick='ShowTabs(1)'>处理信息</td>" & vbCrLf
    Response.Write "            <td id='TabTitle' class='title5' onclick='ShowTabs(2)'>回访信息</td>" & vbCrLf
    Response.Write "            <td>&nbsp;</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "</table>" & vbCrLf

    Response.Write "<table width='100%'  border='0' cellpadding='5' cellspacing='1' class='border'><tr class='tdbg'><td height='100' valign='top'>"
    Response.Write "  <table width='95%' align='center' cellpadding='2' cellspacing='1' bgcolor='#FFFFFF'>" & vbCrLf
    Response.Write "    <tbody id='Tabs'>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td width='15%'  align='right' class='tdbg5'>投诉时间：</td>" & vbCrLf
    Response.Write "      <td width='35%'>" & rsComplain("DateAndTime") & "</td>" & vbCrLf
    Response.Write "      <td width='15%' align='right' class='tdbg5'>投诉主题：</td>" & vbCrLf
    Response.Write "      <td width='35%'>" & rsComplain("Title") & "</td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right' class='tdbg5'>投诉客户：</td>" & vbCrLf
    Response.Write "      <td><a href='Admin_Client.asp?Action=Show&InfoType=6&ClientID=" & rsComplain("ClientID") & "'>" & GetClientName(rsComplain("ClientID")) & "</a></td>" & vbCrLf
    Response.Write "      <td align='right' class='tdbg5'>客户方联系人：</td>" & vbCrLf
    Response.Write "      <td><a href='Admin_Contacter.asp?Action=Show&ContacterID=" & rsComplain("ContacterID") & "'>" & GetContacterName(rsComplain("ContacterID")) & "</a></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right' class='tdbg5'>投诉类型：</td>" & vbCrLf
    Response.Write "      <td>" & GetArrItem(arrComplainType, rsComplain("ComplainType")) & "</td>" & vbCrLf
    Response.Write "      <td align='right' class='tdbg5'>投诉方式：</td>" & vbCrLf
    Response.Write "      <td>" & GetArrItem(arrComplainMode, rsComplain("ComplainMode")) & "</td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right' class='tdbg5'>紧急程度：</td>" & vbCrLf
    Response.Write "      <td>" & GetArrItem(arrMagnitudeOfExigence, rsComplain("MagnitudeOfExigence")) & "</td>" & vbCrLf
    Response.Write "      <td align='right' class='tdbg5'></td>" & vbCrLf
    Response.Write "      <td></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right' class='tdbg5'>接待人：</td>" & vbCrLf
    Response.Write "      <td>" & rsComplain("FirstReceiver") & "</td>" & vbCrLf
    Response.Write "      <td align='right' class='tdbg5'>当前责任人：</td>" & vbCrLf
    Response.Write "      <td>" & rsComplain("CurrentOwner") & "</td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right' class='tdbg5'>投诉内容：</td>" & vbCrLf
    Response.Write "      <td>" & PE_HTMLEncode(rsComplain("Content")) & "</td>" & vbCrLf
    Response.Write "      <td align='right' class='tdbg5'>备注：</td>" & vbCrLf
    Response.Write "      <td>" & PE_HTMLEncode(rsComplain("Remark")) & "</td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    </tbody>" & vbCrLf

    Response.Write "    <tbody id='Tabs' style='display:none'>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td width='15%' align='right' class='tdbg5'>处理结束时间：</td>" & vbCrLf
    Response.Write "      <td width='35%'>" & rsComplain("EndTime") & "</td>" & vbCrLf
    Response.Write "      <td width='15%' align='right' class='tdbg5'>处理人员：</td>" & vbCrLf
    Response.Write "      <td width='35%'>" & rsComplain("Processor") & "</td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td width='15%' align='right' class='tdbg5'>处理过程：</td>" & vbCrLf
    Response.Write "      <td width='35%'>" & rsComplain("Process") & "</td>" & vbCrLf
    Response.Write "      <td width='15%' align='right' class='tdbg5'>处理结果：</td>" & vbCrLf
    Response.Write "      <td width='35%'>" & rsComplain("Result") & "</td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right' class='tdbg5'>客户反馈：</td>" & vbCrLf
    Response.Write "      <td>" & PE_HTMLEncode(rsComplain("Feedback")) & "</td>" & vbCrLf
    Response.Write "      <td align='right' class='tdbg5'></td>" & vbCrLf
    Response.Write "      <td></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    </tbody>" & vbCrLf

    Response.Write "    <tbody id='Tabs' style='display:none'>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td width='15%' align='right' class='tdbg5'>回访时间：</td>" & vbCrLf
    Response.Write "      <td width='35%'>" & rsComplain("EndTime") & "</td>" & vbCrLf
    Response.Write "      <td width='15%' align='right' class='tdbg5'>回访人员：</td>" & vbCrLf
    Response.Write "      <td width='35%'>" & rsComplain("ConfirmCaller") & "</td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right' class='tdbg5'>客户评价：</td>" & vbCrLf
    Response.Write "      <td>" & GetArrItem(arrConfirmScore, rsComplain("ConfirmScore")) & "</td>" & vbCrLf
    Response.Write "      <td align='right' class='tdbg5'>客户反馈：</td>" & vbCrLf
    Response.Write "      <td>" & PE_HTMLEncode(rsComplain("ConfirmFeedback")) & "</td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    </tbody>" & vbCrLf
    Response.Write "  </table>" & vbCrLf
    Response.Write "</td></tr></table>" & vbCrLf

    Select Case Action
    Case "Show"
        Response.Write "<table id='table1' width='100%' height='40'><tr align='center'><td>"
        If rsComplain("ConfirmCaller") = "" Then
            If rsComplain("Processor") = "" Then
                If AdminPurview = 1 Or arrPurview(3) = True Or (arrPurview(2) = True And rsComplain("FirstReceiver") = AdminName) Then
                    Response.Write "<input type='button' name='modify' value='修改投诉记录' onclick=""window.location.href='Admin_Complain.asp?Action=Modify&ItemID=" & ItemID & "';""> "
                End If
                If AdminPurview = 1 Or arrPurview(9) = True Then
                    Response.Write "<input type='button' name='modify' value='添加处理记录' onclick=""window.location.href='Admin_Complain.asp?Action=Process&ItemID=" & ItemID & "';"">"
                End If
            Else
                If AdminPurview = 1 Or arrPurview(11) = True Or (arrPurview(10) = True And rsComplain("Processor") = AdminName) Then
                    Response.Write "<input type='button' name='modify' value='修改处理记录' onclick=""window.location.href='Admin_Complain.asp?Action=Process&ItemID=" & ItemID & "';"">"
                End If
                If AdminPurview = 1 Or arrPurview(6) = True Then
                    Response.Write "<input type='button' name='modify' value='添加回访记录' onclick=""window.location.href='Admin_Complain.asp?Action=Confirm&ItemID=" & ItemID & "';"">"
                End If
            End If
        Else
            If AdminPurview = 1 Or arrPurview(8) = True Or (arrPurview(7) = True And rsComplain("ConfirmCaller") = AdminName) Then
                Response.Write "<input type='button' name='modify' value='修改回访记录' onclick=""window.location.href='Admin_Complain.asp?Action=Confirm&ItemID=" & ItemID & "';"">"
            End If
        End If
        Response.Write "</td></tr></table>"
    Case "Process"
        Dim Processor, EndDate, EndTime
        If rsComplain("ConfirmCaller") & "" = "" Then
            Processor = AdminName
        Else
            Processor = rsComplain("ConfirmCaller")
        End If
        If IsDate(rsComplain("EndTime")) Then
            EndDate = FormatDateTime(rsComplain("EndTime"), 2)
            EndTime = Hour(rsComplain("EndTime")) & ":" & Right("0" & Minute(rsComplain("EndTime")), 2) & ":" & Right("0" & Second(rsComplain("EndTime")), 2)
        Else
            EndDate = Date
            EndTime = Time()
        End If
        Response.Write "<form name='myform' method='post' action='Admin_Complain.asp'>" & vbCrLf
        Response.Write "<table  width='100%' border='0' align='center' cellpadding='0' cellspacing='0'>" & vbCrLf
        Response.Write "  <tr align='center' height='24'>" & vbCrLf
        Response.Write "    <td class='title6'>处理信息</td>" & vbCrLf
        Response.Write "    <td>&nbsp;</td>" & vbCrLf
        Response.Write "  </tr>" & vbCrLf
        Response.Write "</table>" & vbCrLf
        Response.Write "<table width='100%'  border='0' cellpadding='5' cellspacing='1' class='border'><tr class='tdbg'><td height='100' valign='top'>"
        Response.Write "  <table width='95%' align='center' cellpadding='2' cellspacing='1' bgcolor='#FFFFFF'>" & vbCrLf
        Response.Write "    <tr class='tdbg'>" & vbCrLf
        Response.Write "      <td width='15%' align='right' class='tdbg5'>处理结束时间：</td>" & vbCrLf
        Response.Write "      <td width='35%'><input name='EndDate' type='text' id='EndDate' value='" & EndDate & "'>"
        Response.Write "        <input name='EndTime' type='text' id='EndTime' value='" & EndTime & "' size='10' maxlength='10'></td>" & vbCrLf
        Response.Write "      <td width='15%' align='right' class='tdbg5'>处理人员：</td>" & vbCrLf
        Response.Write "      <td width='35%'><input name='Processor' type='text' id='Processor' value='" & Processor & "'></td>" & vbCrLf
        Response.Write "    </tr>" & vbCrLf
        Response.Write "    <tr class='tdbg'>" & vbCrLf
        Response.Write "      <td align='right' class='tdbg5'>处理过程：</td>" & vbCrLf
        Response.Write "      <td><textarea name='Process' cols='30' rows='4' id='Process'>" & rsComplain("Process") & "</textarea></td>" & vbCrLf
        Response.Write "      <td align='right' class='tdbg5'>处理结果：</td>" & vbCrLf
        Response.Write "      <td><input name='Result' type='text' id='Result' value='" & rsComplain("Result") & "'></td>" & vbCrLf
        Response.Write "    </tr>" & vbCrLf
        Response.Write "    <tr class='tdbg'>" & vbCrLf
        Response.Write "      <td align='right' class='tdbg5'>客户反馈：</td>" & vbCrLf
        Response.Write "      <td><textarea name='Feedback' cols='30' rows='4' id='Feedback'>" & rsComplain("Feedback") & "</textarea></td>" & vbCrLf
        Response.Write "      <td align='right' class='tdbg5'></td>" & vbCrLf
        Response.Write "      <td></td>" & vbCrLf
        Response.Write "    </tr>" & vbCrLf
        Response.Write "  </table>" & vbCrLf
        Response.Write "  <Input TYPE='hidden' Name='Status' value='2'>" & vbCrLf
        Response.Write "  <p align='center'><input type='hidden' name='ItemID' value='" & ItemID & "'><input type='hidden' name='Action' value='SaveProcess'><input type='submit' name='Submit' value='保存处理记录'></p>" & vbCrLf
        Response.Write "</td></tr></table>" & vbCrLf
        Response.Write "</form>"

    Case "Confirm"
        Dim ConfirmCaller, ConfirmDate, ConfirmTime
        If rsComplain("ConfirmCaller") & "" = "" Then
            ConfirmCaller = AdminName
        Else
            ConfirmCaller = rsComplain("ConfirmCaller")
        End If
        If IsDate(rsComplain("ConfirmTime")) Then
            ConfirmDate = FormatDateTime(rsComplain("ConfirmTime"), 2)
            ConfirmTime = Hour(rsComplain("ConfirmTime")) & ":" & Right("0" & Minute(rsComplain("ConfirmTime")), 2) & ":" & Right("0" & Second(rsComplain("ConfirmTime")), 2)
        Else
            ConfirmDate = Date
            ConfirmTime = Time()
        End If
        Response.Write "<form name='myform' method='post' action='Admin_Complain.asp'>" & vbCrLf
        Response.Write "<table  width='100%' border='0' align='center' cellpadding='0' cellspacing='0'>" & vbCrLf
        Response.Write "  <tr align='center' height='24'>" & vbCrLf
        Response.Write "    <td class='title6' onclick='ShowTabs(0)'>回访信息</td>" & vbCrLf
        Response.Write "    <td>&nbsp;</td>" & vbCrLf
        Response.Write "  </tr>" & vbCrLf
        Response.Write "</table>" & vbCrLf
        Response.Write "<table width='100%'  border='0' cellpadding='5' cellspacing='1' class='border'><tr class='tdbg'><td height='100' valign='top'>"
        Response.Write "  <table width='95%' align='center' cellpadding='2' cellspacing='1' bgcolor='#FFFFFF'>" & vbCrLf
        Response.Write "    <tr class='tdbg'>" & vbCrLf
        Response.Write "      <td width='15%' align='right' class='tdbg5'>回访时间：</td>" & vbCrLf
        Response.Write "      <td width='35%'><input name='ConfirmDate' type='text' id='ConfirmDate' value='" & ConfirmDate & "'>"
        Response.Write "        <input name='ConfirmTime' type='text' id='ConfirmTime' value='" & ConfirmTime & "' size='10' maxlength='10'></td>" & vbCrLf
        Response.Write "      <td width='15%' align='right' class='tdbg5'>回访人员：</td>" & vbCrLf
        Response.Write "      <td width='35%'><input name='ConfirmCaller' type='text' id='ConfirmCaller' value='" & ConfirmCaller & "'></td>" & vbCrLf
        Response.Write "    </tr>" & vbCrLf
        Response.Write "    <tr class='tdbg'>" & vbCrLf
        Response.Write "      <td align='right' class='tdbg5'>客户评价：</td>" & vbCrLf
        Response.Write "      <td><select name='ConfirmScore' id='ConfirmScore'>" & Array2Option(arrConfirmScore, rsComplain("ConfirmScore")) & "</select></td>" & vbCrLf
        Response.Write "      <td align='right' class='tdbg5'>客户反馈：</td>" & vbCrLf
        Response.Write "      <td><textarea name='ConfirmFeedback' cols='30' rows='4' id='ConfirmFeedback'>" & rsComplain("ConfirmFeedback") & "</textarea></td>" & vbCrLf
        Response.Write "    </tr>" & vbCrLf
        Response.Write "  </table>" & vbCrLf
        Response.Write "  <Input TYPE='hidden' Name='Status' value='3'>" & vbCrLf
        Response.Write "  <p align='center'><input type='hidden' name='ItemID' value='" & ItemID & "'><input type='hidden' name='Action' value='SaveConfirm'><input type='submit' name='Submit' value='保存回访记录'></p>" & vbCrLf
        Response.Write "</td></tr></table>" & vbCrLf
        Response.Write "</form>"
    End Select
    rsComplain.Close
    Set rsComplain = Nothing
End Sub

Sub SaveComplain()
    Dim rsComplain, sqlComplain
    Dim ItemID, ClientID, ContacterID, ComplainType, ComplainMode, DateAndTime, Title, Content, MagnitudeOfExigence, FirstReceiver, CurrentOwner, Remark, Status, Defendant
    ItemID = PE_CLng(Trim(Request("ItemID")))
    ClientID = PE_CLng(Trim(Request("ClientID")))
    ContacterID = PE_CLng(Trim(Request("ContacterID")))
    ComplainType = PE_CLng(Trim(Request("ComplainType")))
    ComplainMode = PE_CLng(Trim(Request("ComplainMode")))
    DateAndTime = PE_CDate(Trim(Request("DateAndTime")))
    Title = Trim(Request("Title"))
    Content = Trim(Request("Content"))
    MagnitudeOfExigence = PE_CLng(Trim(Request("MagnitudeOfExigence")))
    Defendant = Trim(Request("Defendant"))
    FirstReceiver = Trim(Request("FirstReceiver"))
    CurrentOwner = Trim(Request("CurrentOwner"))
    Remark = Trim(Request("Remark"))
    
    If ClientID <= 0 Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请输入对应客户</li>"
    End If
    If Title = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请输入投诉主题</li>"
    End If
    If Not IsDate(DateAndTime) Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>投诉日期的格式不对</li>"
    End If
    If FirstReceiver = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请输入接待人</li>"
    End If
        
    If Action = "SaveAdd" Then
        If AdminPurview > 1 And arrPurview(1) = False Then
            Response.Write "<br><p align='center'><font color='red' style='font-size:9pt'>对不起，你没有此项操作的权限。</font></p>"
            Call WriteEntry(6, AdminName, "越权操作")
            Exit Sub
        End If
        sqlComplain = "select top 1 * from PE_ComplainItem"
    Else
        If AdminPurview > 1 And arrPurview(2) = False And arrPurview(3) = False Then
            Response.Write "<br><p align='center'><font color='red' style='font-size:9pt'>对不起，你没有此项操作的权限。</font></p>"
            Call WriteEntry(6, AdminName, "越权操作")
            Exit Sub
        End If
        If ItemID <= 0 Then
            FoundErr = True
            ErrMsg = ErrMsg & "<li>请指定ItemID！</li>"
        Else
            sqlComplain = "select * from PE_ComplainItem where ItemID=" & ItemID
        End If
    End If
    
    If FoundErr = True Then Exit Sub
    
    Set rsComplain = Server.CreateObject("adodb.recordset")
    rsComplain.Open sqlComplain, Conn, 1, 3
    If Action = "SaveAdd" Then
        rsComplain.AddNew
        rsComplain("Status") = 0
    End If
    rsComplain("ClientID") = ClientID
    rsComplain("ContacterID") = ContacterID
    rsComplain("ComplainType") = ComplainType
    rsComplain("ComplainMode") = ComplainMode
    rsComplain("DateAndTime") = DateAndTime
    rsComplain("Title") = Title
    rsComplain("Defendant") = Defendant
    rsComplain("Content") = Content
    rsComplain("MagnitudeOfExigence") = MagnitudeOfExigence
    rsComplain("FirstReceiver") = FirstReceiver
    rsComplain("CurrentOwner") = CurrentOwner
    rsComplain("Remark") = Remark
    rsComplain("Process") = ""
    rsComplain("Processor") = ""
    rsComplain("Result") = ""
    rsComplain("Feedback") = ""
    rsComplain("ConfirmCaller") = ""
    rsComplain("ConfirmScore") = -1
    rsComplain("ConfirmFeedback") = ""
    rsComplain.Update
    rsComplain.Close
    Set rsComplain = Nothing
    Call main
End Sub

Sub SaveProcess()
    Dim rsComplain, sqlComplain
    Dim ItemID, EndDate, EndTime, Processor, Process, Result, Feedback, Status
    ItemID = PE_CLng(Trim(Request("ItemID")))
    EndDate = Trim(Request("EndDate"))
    EndTime = Trim(Request("EndTime"))
    Processor = Trim(Request("Processor"))
    Process = Trim(Request("Process"))
    Result = Trim(Request("Result"))
    Feedback = Trim(Request("Feedback"))
    Status = PE_CLng(Trim(Request("Status")))
    
    If ItemID <= 0 Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请指定ItemID</li>"
    End If
    If Not IsDate(EndDate) Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>回访日期的格式不对</li>"
    End If
    If Not IsDate(EndTime) Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>回访时间的格式不对</li>"
    End If
        
    If FoundErr = True Then Exit Sub
    
    sqlComplain = "select * from PE_ComplainItem where ItemID=" & ItemID
    Set rsComplain = Server.CreateObject("adodb.recordset")
    rsComplain.Open sqlComplain, Conn, 1, 3
    If Not (rsComplain.BOF And rsComplain.EOF) Then
        rsComplain("EndTime") = PE_CDate(EndDate & " " & EndTime)
        rsComplain("Processor") = Processor
        rsComplain("Process") = Process
        rsComplain("Result") = Result
        rsComplain("Feedback") = Feedback
        rsComplain("Status") = Status
        rsComplain.Update
    End If
    rsComplain.Close
    Set rsComplain = Nothing
    Call main
End Sub

Sub SaveConfirm()
    Dim rsComplain, sqlComplain
    Dim ItemID, ConfirmDate, ConfirmTime, ConfirmCaller, ConfirmScore, ConfirmFeedback, Status
    ItemID = PE_CLng(Trim(Request("ItemID")))
    ConfirmDate = Trim(Request("ConfirmDate"))
    ConfirmTime = Trim(Request("ConfirmTime"))
    ConfirmCaller = Trim(Request("ConfirmCaller"))
    ConfirmScore = PE_CLng(Trim(Request("ConfirmScore")))
    ConfirmFeedback = Trim(Request("ConfirmFeedback"))
    Status = PE_CLng(Trim(Request("Status")))
    If ItemID <= 0 Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请指定ItemID</li>"
    End If
    If Not IsDate(ConfirmDate) Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>回访日期的格式不对</li>"
    End If
    If Not IsDate(ConfirmTime) Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>回访时间的格式不对</li>"
    End If
        
    If FoundErr = True Then Exit Sub
    
    sqlComplain = "select * from PE_ComplainItem where ItemID=" & ItemID
    Set rsComplain = Server.CreateObject("adodb.recordset")
    rsComplain.Open sqlComplain, Conn, 1, 3
    If Not (rsComplain.BOF And rsComplain.EOF) Then
        rsComplain("ConfirmTime") = PE_CDate(ConfirmDate & " " & ConfirmTime)
        rsComplain("ConfirmCaller") = ConfirmCaller
        rsComplain("ConfirmScore") = ConfirmScore
        rsComplain("ConfirmFeedback") = ConfirmFeedback
        rsComplain("Status") = Status
        rsComplain.Update
    End If
    rsComplain.Close
    Set rsComplain = Nothing
    Call main
End Sub

Sub Del()
    If AdminPurview > 1 And arrPurview(4) = False Then
        Response.Write "<br><p align='center'><font color='red' style='font-size:9pt'>对不起，你没有此项操作的权限。</font></p>"
        Call WriteEntry(6, AdminName, "越权操作")
        Exit Sub
    End If

    Dim ItemID
    ItemID = Trim(Request("ItemID"))
    If IsValidID(ItemID) = False Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请指定正确的ItemID！</li>"
        Exit Sub
    End If
    Dim rsComplain, sqlComplain, iTemp
    iTemp = 0
    sqlComplain = "select * from PE_ComplainItem where ItemID in (" & ItemID & ")"
    Set rsComplain = Server.CreateObject("adodb.recordset")
    rsComplain.Open sqlComplain, Conn, 1, 3
    Do While Not rsComplain.EOF
        rsComplain.Delete
        rsComplain.Update
        iTemp = iTemp + 1
        rsComplain.MoveNext
    Loop
    rsComplain.Close
    Set rsComplain = Nothing
    Call WriteSuccessMsg("删除投诉记录成功！共删除了 " & iTemp & " 条记录。", "Admin_Complain.asp")
End Sub
%>
