<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%option explicit%>
<!--#include file="../Conn.asp"-->
<!--#include file="TaskConfig.asp"-->
<!--#include file="../HSK_Cls/HSK.MemberCls.asp"-->
<%
Dim KSCls
Set KSCls = New TaskBinDing
KSCls.Run()
Set KSCls = Nothing

Class TaskBinDing
	Private KS,KSUser
	Private ComeUrl,LoginTF,Action,Tid,ID,NameType,Title,TaskID
	Private Sub Class_Initialize()
		Set KS=New PublicCls
		Set KSUser = New UserCls
	End Sub
	Private Sub Class_Terminate()
		Set KS=Nothing
		Set KSUser=Nothing
		Call CloseConn()
	End Sub

	Public Sub Run()
		ComeUrl=Request.ServerVariables("HTTP_REFERER")
		LoginTF=Cbool(KSUser.UserLoginChecked)
		IF LoginTF=false  Then
		  GCls.ComeUrl=ComeUrl	'GCls.GetUrl()
		  Response.Redirect("/user/login/")
		  Exit Sub
		End If

	'================= Action 动作、ID 判断START =================================
	Action = KS.CheckXSS(KS.R(KS.S("Action")))
	ID = KS.ChkClng(KS.CheckXSS(KS.R(KS.S("ID"))))
	Tid= KS.CheckXSS(KS.R(KS.S("TID")))
	TaskID= KS.CheckXSS(KS.R(KS.S("TaskID")))
	Title= KS.CheckXSS(KS.LoseHtml(KS.R(KS.S("Title"))))
	NameType = KS.ChkClng(KS.CheckXSS(KS.R(KS.S("NameType"))))
	IF (Action<>"PingJia" And Action<>"DoSave") Or ID = 0 Or KS.IsNul(Tid) Or NameType = 0 Then
		KS.Die "参数有误，请重新打开！如果是登录超时，请重新登录！谢谢！"
	End IF
	%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>给对方评价</title>
<link href="/style/css/task.css" type="text/css" rel="stylesheet"/>
<script type="text/javascript" src="/style/js/common_def.js"></script>
<style type="text/css">
body {background:#ffffff url(/style/images/body_bg.gif) repeat-x 0 0;}
.binding {}
.binding td { color:#20537A; font-size:12px; line-height:22px;
}
.binding .err { color:blue; font-size:12px; line-height:22px;
}
.binding .orange { color:#FF5500; font-size:14px; line-height:22px; font-weight:bold;
}
</style>
</head>
<body>
<%
	Select Case Action
		Case "PingJia"	Call Mainlist()
		Case "DoSave"	Call DoSave()
	End Select
%>
</body>
</html>
<%
End Sub

Sub Mainlist()
IF NameType =1 Then		'NameType =1 为发布方  NameType =2 为接手方
	IF Conn.Execute("Select Top 1 ID From KS_U_sxyrw Where Inputer='" & KSUser.UserName & "' And (KS_BuyUserName IS NOT Null) And KS_Status=5 And ID=" & ID).Eof Then KS.Die "<div class=""border"">抱歉！您只能评价自己发布的已完成要求任务!</div>"
Else
	IF Conn.Execute("Select Top 1 ID From KS_U_sxyrw Where KS_BuyUserName='" & KSUser.UserName & "' And KS_Status=5 And ID=" & ID).Eof Then KS.Die "<div class=""border"">抱歉！您只能评价自己接手的已完成要求任务!</div>"
End IF

Dim Rs
Set Rs = Conn.Execute("Select Top 1 ID From PingJia Where (UserName = '"& KSUser.UserName &"') And NameType=" & NameType & " And TaskID='" & ID &"'")
If Not Rs.Eof Then
	KS.Die "<div class=""border"">抱歉！该任务您已经评价了!</div>"
End If
Set Rs = Nothing
%>
<!-- 列表 start -->
<script type="text/javascript">
function CheckPingJia(){
if (DataLength(myform.Content.value) > 200) {
        alert('评价内容不能超过200个字。');myform.Content.focus();
        return false;
    }
return true;
}
</script>
<table align="center" width="100%" border="0" cellspacing="8" cellpadding="0" class="binding">
<form action="?Action=DoSave" method="post" name="myform" id="myform" onSubmit="return CheckPingJia();">
  <tr>
    <td height="35" class="orange">请给该任务的<%If NameType =1 Then Response.Write "接手人" Else Response.Write "发布人"%>满意度评价：</td>
  </tr>
  <tr>
    <td height="6" align="center"></td>
  </tr>
  <tr>
    <td height="35" align="center">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
     <td height="30" align="center">
     <label><input type="radio" name="PingJia" id="PingJia" value='1' checked="checked" />好评</label>
     <img src="/style/images/emot/haoping.gif" align="absmiddle" />&nbsp; &nbsp; &nbsp; 
     <label><input type="radio" name="PingJia" id="PingJia" value='2' />中评</label>
     <img src="/style/images/emot/zhongping.gif" align="absmiddle" />&nbsp; &nbsp; &nbsp; 
     <label><input type="radio" name="PingJia" id="PingJia" value='3' />差评</label>
     <img src="/style/images/emot/chaping.gif" align="absmiddle" /></td>
    </tr>
    </table>
    </td>
  </tr>
  <tr>
    <td height="80" align="center"><textarea name="Content" rows="4" cols="40" style="width:300px; height:60px;"></textarea>
      <br />
      好评内容，可适当给对方填写好评内容</td>
  </tr>
  <tr>
    <td height="60" align="center"><p>
      <input type="image" name="Save" src="/style/images/ConfirmButton.gif" />
        <input type="hidden" name="ID" id="ID" value="<%=ID%>" /><input type="hidden" name="TaskID" id="TaskID" value="<%=TaskID%>" /><input type="hidden" name="Tid" id="Tid" value="<%=Tid%>" /><input type="hidden" name="Title" id="Title" value="<%=Title%>" /><input type="hidden" name="NameType" id="NameType" value="<%=NameType%>" />
      </p></td>
  </tr>
  <tr>
    <td align="center"><p>提示：你的评价将会影响对方以后接手任务或发布任务的信用，请慎重给对方评价！没有特别情况请给好评。</p></td>
  </tr>
</form>
</table>
<%
End Sub

Sub DoSave()
	Dim RS,Content,PingJia,PingJiaFiled,FriendName
	Content = KS.CheckXSS(KS.LoseHtml(KS.R(KS.S("Content"))))
	PingJia = KS.ChkClng(KS.CheckXSS(KS.R(KS.S("PingJia"))))
	IF (Action="DoSave") And ID <> 0 And Not KS.IsNul(Tid) And NameType <> 0 And PingJia <>0 Then
	
	IF NameType =1 Then
		Set RS = Conn.Execute("Select Top 1 ID,KS_BuyUserName From KS_U_sxyrw Where Inputer='" & KSUser.UserName & "' And (KS_BuyUserName IS NOT Null) And KS_Status=5 And ID=" & ID)
		IF Not RS.Eof Then
			FriendName = RS("KS_BuyUserName")
		Else
			KS.Die "<div class=""border"">抱歉！您只能评价自己发布的已完成要求任务!</div>"
		End IF
		Set RS = Nothing
	Else
		Set RS = Conn.Execute("Select Top 1 ID,Inputer From KS_U_sxyrw Where KS_BuyUserName='" & KSUser.UserName & "' And KS_Status=5 And ID=" & ID)
		IF Not RS.Eof Then
			FriendName = RS("Inputer")
		Else
			KS.Die "<div class=""border"">抱歉！您只能评价自己接手的已完成要求任务!</div>"
		End IF
		Set RS = Nothing
	End IF

	Set RS=Server.CreateObject("ADODB.RECORDSET")
	RS.Open "Select top 1 * From PingJia Where (UserName = '"& KSUser.UserName &"') And NameType=" & NameType & " And TaskID='" & ID & "'",Conn,1,2
	'RS.Open "Select top 1 * From PingJia Where (UserName <> '"& KSUser.UserName &"')",Conn,1,2
		If RS.Eof And RS.Bof Then
			 RS.AddNew
			 RS("NameType")=NameType
			 RS("UserName")=KSUser.UserName
			 RS("FriendName") = FriendName
			 RS("TID")=TID
			 RS("TaskID")=TaskID
			 IF NOT KS.IsNul(Title) Then RS("Title")=Title
			 IF NOT KS.IsNul(Content) Then RS("Content")=Content
			 IF PingJia =1 Then
				RS("HaoPing") = 1
				PingJiaFiled = "KS_HaoPing = KS_HaoPing + 1"
			 ElseIF PingJia =2 Then
				RS("ZhongPing") = 1
				PingJiaFiled = "KS_ZhongPing = KS_ZhongPing + 1"
			 ElseIF PingJia =3 Then
				RS("ChaPing") = 1
				PingJiaFiled = "KS_ChaPing = KS_ChaPing + 1"
			 End IF
			 RS("AddDate")= Now()
			 RS("IP")=KS.GetIP()
			 RS.Update
			 RS.Close
			 Set RS=Nothing
			 
			 IF NameType = 1 Then
			 	Conn.Execute("UPDate KS_U_sxyrw Set KS_CreditDate=" & SqlNowString & " Where Inputer = '"& KSUser.UserName &"' And  KS_Status=5 And ID=" & ID)
			 ElseIF NameType = 2 Then
			 	Conn.Execute("UPDate KS_U_sxyrw Set KS_BuyCreditDate=" & SqlNowString & " Where KS_BuyUserName = '"& KSUser.UserName &"' And KS_Status=5 And ID=" & ID)
				If Split(Score_System_FinishScore,"|")(0) = 1 Then
					Dim Score
					If KS.ChkClng(KSUser.GroupID) <> UserGroupVipID Then
						Score = Split(Score_System_FinishScore,"|")(1)
					Else
						Score = Split(Score_System_FinishScore,"|")(2)	'VIP得2点积分
					End IF
					Call KS.ScoreInOrOut(KSUser.UserName,1,Score,"系统","完成任务获得"& Score &"点积分,任务编号："& TaskID,0,0)
				End If
			 End IF

			 Conn.Execute("UPDate KS_User Set " & PingJiaFiled & " Where UserName = '"& FriendName &"'")
			 	 
			 KS.Echo "<script>alert('评价成功！感谢您的评价！');parent.location.reload();parent.closeWindow();</script>"
		Else
			RS.Close
			Set RS=Nothing
			KS.Echo "<div class=""border"">抱歉！该任务已经评价了，不能重复评价!</div>"
		End IF
	Else
		KS.Echo "<div class=""border"">抱歉！提交的参数的误，如果确定该任务还没评价，请与管理员联系!</div>"
	End IF
End Sub

End Class
%>