<!--#include file="../../../inc/cms_admin.asp" -->
<%
dim SID, AID,A_SID,A_LID, A_PID, A_Order, A_Type, A_Name, A_URL, A_Level, A_AddTime, A_Title, A_Key, A_Desc, A_Path, A_Template, C_Template, A_Folder, C_Folder, A_FileName, C_FileName, A_OnOff, A_TID, A_GroupID, A_Content,A_pic,A_picsUrl,A_picsName,A_Visits,A_editTime
dim sql,A_EnName,usertype,table,col,colval,idval,id,customStr

dim act : act=getForm("act","get")
dim stype : stype=getForm("stype","get")
dim postion : postion=getForm("postion","get")
table=getForm("table","both")
col=getForm("col","both")
colval=getForm("colval","both")
idval=getForm("idval","both")
id=isnum(getForm("id","both"))

Select case act	
	case "setcol"	:	dbconn("update "&table&" set "&col&"="&colval&"  where  "&id&"="&idval&"")	
	case "edit" 	: editAbout
	case "del" 		: 	dbconn "delete from [dbpre]about where AID = ("&id&")"	
	case "delall"	:	dbconn("delete from [dbpre]about  where A_SID=0 or A_SID not in (select SID from [dbpre]sort where S_Type='about')")	:	aspgo("about_list.asp")
	case "saveid"	:	saveid
End Select

Sub saveid
	dim colid		:	colid=getForm("colid","both")
	dim colname		:	colname=getForm("colname","both")
	dim colval		:	colval=getForm("colval","both")
	dim sql1 		:	sql1="update [dbpre]about Set "&colname&"='"&colval&"' Where AID="&colid
	dim sql2 		:	sql2="update [dbpre]about Set "&colname&"="&colval&" Where AID="&colid	
	dbconn(sql1)	:	if err then dbconn(sql2)
End Sub

Sub updateid
	Dim ids			:	ids=getForm("id","both")
	Dim title		:	title=getForm("title","both")
	Dim entitle  	: 	entitle=getForm("entitle","both")   
	Dim aboutOrders	:	aboutOrders=getForm("Order","both")	
	sql="update [dbpre]About Set A_Name='"&trim(title)&"',A_EnName='"&trim(entitle)&"',A_Order='"&trim(aboutOrders)&"' Where AID="&trim(ids)
	dbconn(sql)
	layermsg("保存成功")
End Sub	


Sub getabout
dim rs,id
	 SID=getForm("SID","get")
	 Aid=getForm("AID","get")
	if not isnul(SID) then		
		sql ="select * from [dbpre]about where A_SID="&SID
		set rs = conn.exec(sql,"r1")
	elseif not isnul(Aid) then	
		sql ="select * from [dbpre]about where AID="&Aid
		set rs = conn.exec(sql,"r1")		
	else
		alertgo "没有这条记录","-1"
	end if 
	if rs.eof then 
			alertgo "没有这条记录","-1"
		else
			AID=rs("AID")
			A_SID=rs("A_SID")
			A_LID=rs("A_LID")
			A_Order=rs("A_Order")
			A_Name=rs("A_name")
			A_EnName=rs("A_EnName")
			A_AddTime=rs("A_AddTime")
			A_editTime=rs("A_editTime")
			A_Key=rs("A_Key")
			A_Desc=rs("A_Desc")
			A_OnOff=rs("A_OnOff")
			A_Content=decode(rs("A_Content"))
			A_pic=rs("A_pic")
			A_picsUrl=rs("A_picsUrl")
			A_picsName=rs("A_picsName")
			A_Visits=rs("A_Visits")
		end if
	rs.close : set rs=nothing
End Sub


Sub editAbout	
	AID=getForm("AID", "get")	
	A_Order=getForm("A_Order", "post")	
	A_Name=getForm("A_Name", "post")
	A_EnName=getForm("A_EnName", "post")
	A_content=encode(request.form("A_content"))
	A_pic=getForm("pic", "post")
	A_picsUrl=getForm("picsUrl", "post")
	A_picsName=getForm("picsName", "post")
	A_Key=getForm("A_Key", "post")	
	A_Desc=getForm("A_Desc", "post")	
	if isnul(A_Key) then A_Key=autokeys(A_Name)
	if isnul(A_Desc) then A_Desc=leftStr(drophtml(request.form("A_content")),255)
	A_AddTime=getForm("A_AddTime", "post")
	A_editTime=getForm("A_editTime", "post")
	if isnul(A_AddTime) then A_AddTime=now()	
	A_LID=cint(zset.lid)		
	if isnul(A_Name) then alertgo "分类名称不能为空","-1"	
	dim rs,customStr
	set rs=dbsqlr1("select custom,customClass from [dbpre]content_custom where customType ='about'")	
	Do While not rs.Eof 	
		if rs(1)=1 then 
		customStr=customStr&","&rs(0)&"="&isnum(getForm(rs(0),"post"))& ""
		elseif rs(1)=3 then 
		customStr=customStr&","&rs(0)&"='"&encode(request.form(rs(0)))& "'"
		elseif rs(1)=10 then 
		if not isnul(getForm(rs(0),"post")) then customStr=customStr&","&rs(0)&"='"&getForm(rs(0),"post")&"'"
		else
		customStr=customStr&","&rs(0)&"='"&getForm(rs(0),"post")&"'"
		end if
	rs.MoveNext
	Loop
	closers rs
	sql= "update [dbpre]About set A_Order="&A_Order&",  A_LID="&A_LID&", A_Name='"&A_Name&"', A_EnName='"&A_EnName&"', A_Key='"&A_Key&"', A_Desc='"&A_Desc&"', A_AddTime ='"&A_AddTime&"',A_editTime ='"&sqltime&"', A_content ='"&A_content&"', A_pic ='"&A_pic&"', A_picsUrl ='"&A_picsUrl&"',A_picsName ='"&A_picsName&"'"&customStr&"  where AID="&AID
	
	dbconn(sql)	
	if err then
	 die sql
	 else
	layermsg("保存成功")
	end if
End Sub	

function getCustom(AID)	
		Dim rs,CustomFields,rs1,i,CustomNames,splitValue,checkstr,selectstr,valstr,topstr,endstr,filetype,fileview,filescript
		CustomFields=""		
		Set rs=dbsqlr1("select CustomName,Custom,customValues,customOptions,customClass,customplace from [dbpre]Content_custom where Customtype ='about' order by CustomOrder asc,CustomID desc")		
		if not rs.eof then topstr= "<div class='col-sm-12'><div class='ibox float-e-margins'> <a class='collapse-link'><div class='ibox-title'><h5>自定义参数</h5><div class='ibox-tools'><i class='fa fa-chevron-up'></i> </div></div></a><div class='ibox-content'>"  	
		if not rs.eof then endstr= "</div></div></div>"		
		Do While not rs.Eof 			
			if AID=0 then 	
				valstr=rs(2)
			 else 
				valstr=dbselect("[dbpre]about",""&rs(1)&"","AID="&AID&"")
			end if
				select case rs(4)
				case 0,1	
				getCustom= getCustom&"<div class='form-group'>"&vbcrlf& _	
                     "<label class='col-sm-1 control-label'>"&rs(0)&"</label>"&vbcrlf& _	
                     "<div class='col-sm-3'><input name='"&rs(1)&"' id='"&rs(1)&"' type='text' class='form-control' placeholder='"&rs(5)&"' value='"&valstr&"'>"&vbcrlf& _	
                     "</div> </div>"&vbcrlf
				case 2
				getCustom= getCustom&"<div class='form-group'>"&vbcrlf& _	
					"<label class='col-sm-1 control-label'>"&rs(0)&"</label>"&vbcrlf& _	
					"<div class='col-sm-8'> <textarea class='textarea form-control'   name='"&rs(1)&"' id='"&rs(1)&"'  placeholder='"&rs(5)&"'>"&valstr&"</textarea>"&vbcrlf& _	
					"</div></div>"&vbcrlf
				case 3
				getCustom= getCustom&"<div class='form-group'>"&vbcrlf& _	
					"<label class='col-sm-1 control-label'>"&rs(0)&"</label>"&vbcrlf& _	
					"<div class='col-sm-8'> <textarea class='textarea textarea-editor'   name='"&rs(1)&"' id='"&rs(1)&"'>"&decode(valstr)&"</textarea>"&vbcrlf& _	
					"</div></div> <script>var $cmsEditor = new UE.getEditor('"&rs(1)&"');</script>"&vbcrlf
				case 4,5,6
					if ifstrin(rs(3),",") then
					getCustom= getCustom&"<div class='form-group'><label class='col-sm-1 control-label'>"&rs(0)&"</label>"&vbcrlf	
					if rs(4)=6 then getCustom= getCustom&"<div class='col-sm-3'><select name='"&rs(1)&"' id='"&rs(1)&"' class='form-control'>" else getCustom= getCustom&"<div class='col-sm-8'>"
					splitValue=split(rs(3),",")
						for i=0 to ubound(splitValue)
						if ifstrin(valstr,splitValue(i)) then
						  checkstr="checked"
						  selectstr="selected"
						  else 
						  checkstr=""
						  selectstr=""
						end if
						if rs(4)=4	then getCustom= getCustom& "<div class='radio radio-inline'><input type=""radio"" id='"&rs(1)&i&"' name='"&rs(1)&"' "&checkstr&" value='"&splitValue(i)&"'/><label for='"&rs(1)&i&"'>"&splitValue(i)&"</label></div>"&vbcrlf
						if rs(4)=5	then getCustom= getCustom& "<div class='checkbox radio-inline'><input type=""checkbox"" id='"&rs(1)&i&"' name='"&rs(1)&"' "&checkstr&" value='"&splitValue(i)&"'/><label for='"&rs(1)&i&"'>"&splitValue(i)&"</label></div>"&vbcrlf
						if rs(4)=6	then getCustom= getCustom& " <option value='"&splitValue(i)&"' "&selectstr&">"&splitValue(i)&"</option>"
						next
					if rs(4)=6 then getCustom= getCustom&" </select>"
					getCustom=  getCustom&"</div></div>"&vbcrlf
					end if
				case 7,8,9
				if rs(4)=7 then	filetype="file"		:	filescript="<script>$(function(){fileuploader("""&rs(1)&"_upload"",""file"",""about"","""&rs(1)&""","""")}) </script>"
				if rs(4)=8 then	filetype="pic"		:  	filescript="<script>$(function(){fileuploader("""&rs(1)&"_upload"",""image"",""about"","""&rs(1)&""","""")}) </script>" :	fileview=" <div class='col-sm-1'><img src='"&valstr&"' height='30' id='img_"&rs(1)&"'></div>"	
				if rs(4)=9 then	filetype="video"	:	filescript="<script>$(function(){fileuploader("""&rs(1)&"_upload"",""video"",""about"","""&rs(1)&""","""")}) </script>"
				getCustom= getCustom&"<div class='form-group'>"&vbcrlf& _	
						 "<label class='col-sm-2 control-label'>"&rs(0)&"</label>"&vbcrlf& _	
						  "<div class='col-sm-7'><input id='"&rs(1)&"' name='"&rs(1)&"' class='form-control' value='"&valstr&"'/></div>"&vbcrlf& _	
						 "<div class='col-sm-2'><div id='"&rs(1)&"_upload'>上传</div></div>"&fileview&" </div>"&vbcrlf& _	
						 filescript&vbcrlf
				case 10			
				getCustom= getCustom&"<div class='form-group'>"&vbcrlf& _	
                     "<label class='col-sm-2 control-label'>"&rs(0)&"</label>"&vbcrlf& _	
					  "<div class='col-sm-4'><div class='input-group'>"&vbcrlf& _	
                  		"<input type='text' id='"&rs(1)&"' class='form-control time'  name='"&rs(1)&"'  placeholder='"&rs(5)&"'  value='"&valstr&"'>"&vbcrlf& _	
                  		"<span class='input-group-addon'>  <i class='fa fa-calendar'></i></span> </div></div></div>"&vbcrlf& _	
						"<script> $('#"&rs(1)&"').jeDate({"&rs(3)&"})</script>"&vbcrlf
				end select
			rs.MoveNext
		Loop
		getCustom=topstr&getCustom&endstr
End function
%>