<%temp_customer_manage_grade_edit_handle=site.object_p%>
<!-- object[<%=site.object_p%>]::temp_customer_manage_grade_edit_handle -->
<%
If request.Form("pact_ok") <> "ok" Then
	site.Error.info = "请先同意相关的注册条款！"
	site.Error.location = "back"
	site.error.err()
End If

site.object(site.object_p).rs.open "select * from jins_customer_sort where sort_id=" & request.Form("sort_id") & " ", conn, 1, 1
'/////////////检查用户等级
If site.temp.customer.info.sort_grade >= site.object(site.object_p).rs("sort_grade") Then
	site.Error.info = "请不要升级到比您当前用户等级更低的用户类型！"
	site.Error.location = "back"
	site.error.err()
End If
'/////////////检查用户
if not conn.execute("select customer_id from jins_customer_list where customer_reg_name='?_"&site.temp.customer.info.reg_name&"' and sort_id="&request.form("sort_id")&" ").eof then
	site.Error.info = "请不要重复提交升级请求！"
	site.Error.location = "back"
	site.error.err()
End If
'/////////////检查积分
If site.temp.customer.info.count_rest < site.object(site.object_p).rs("sort_count") Then
	site.Error.info = "您的积分不够，无法完成升级！"
	site.Error.location = "back"
	site.error.err()
End If
'////////////检查注册用户ip
Set rs_ip = conn.execute("select ip_num from jins_customer_reg_ip where ip_address='" & request.ServerVariables("REMOTE_ADDR") & "' and  sort_id=" & site.object(site.object_p).rs("sort_id") & " ")
If Not rs_ip.EOF Then
	If rs_ip("ip_num") >= site.object(site.object_p).rs("sort_limit_ip") Then
		site.Error.info = "升级失败！" & site.object(site.object_p).rs("sort_description") & "类型的用户同一ip地址只能注册" & site.object(site.object_p).rs("sort_limit_ip") & "个用户！"
		site.Error.location = "back"
		site.error.err()
	End If
End If
Set rs_ip = Nothing
'////////////检查注册用户数量
If site.object(site.object_p).rs("sort_limit_customers") <= conn.execute("select count(customer_reg_name) from jins_customer_list where sort_id=" & site.object(site.object_p).rs("sort_id") & " ")(0) Then
	site.Error.info = site.object(site.object_p).rs("sort_description") & "类型的用户数量已经超过限制，请以后再升级！"
	site.Error.location = "back"
	site.error.err()
End If
'////////////是否需要审核
If site.object(site.object_p).rs("sort_update_admin") = 1 Then

	conn.execute("insert into jins_customer_list (customer_reg_name,customer_reg_admin,sort_id) values ('?_"&site.temp.customer.info.reg_name&"',0,"&site.object(site.object_p).rs("sort_id")&") ")

	site.Error.info = "提交升级请求成功！请等待管理员审核您的升级请求！"
	site.Error.location = "back"
	site.error.suc()
End If
'////////////升级sort_id
If Not site.temp.customer.info.EditInfo(site.temp.customer.info.reg_name, "sort_id=" & site.object(site.object_p).rs("sort_id")&",customer_reg_property=''") Then
	site.Error.info = "系统出现意外错误，无法完成升级！"
	site.Error.location = "back"
	site.error.suc()
End If
'////////////
site.object(site.object_p).rs.Close
Set site.object(site.object_p).rs = Nothing
site.Error.info = "系统已经更改您的用户类型，请点击下一步继续更改您的注册资料以完成升级！"
site.Error.location = "temp.asp?tr=customer|manage|info"
site.Error.suc()
%>