<!--#include virtual="/show/adminhead.asp"-->
<!--#include file="adminleft.asp"-->
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link rel="stylesheet" href="/kindeditor/themes/default/default.css" />
<script charset="utf-8" src="/kindeditor/kindeditor.js"></script>
<script charset="utf-8" src="/kindeditor/lang/zh-CN.js"></script>
<title><%=webname%>-编辑商品</title>
<%
call logquanxian("c2",1)
%>


<DIV>

			 
<%
Const stringmodarr = "0123456789"
dim randarr2,strlength
strlength = Len(stringmodarr)
Randomize timer
For i = 1 To 4 
randarr2 = randarr2&Mid(stringmodarr,Int(Rnd * strlength + 1),1)  
Next 
get_timeh=timer()*100
get_timeh=right("00"&get_timeh,2)
get_timeh=replace(get_timeh,".","0")
randarr = Right((year(Now())),2)&Right(("00"&Month(Now())),2)&Right(("00"&Day(Now())),2)&Right(("00"&hour(Now())),2)&Right(("00"&minute(Now())),2)&Right(("00"&second(Now())),2)&get_timeh&randarr2

set rs2=server.CreateObject("adodb.recordset")
set rsid=server.CreateObject("adodb.recordset")

act=SafeRequest("act")

if act="adddaishou" then
	id=SafeRequest("id")
		
	rs.open "select * from aygood where aygoodid="&clng(id)&"",conn,1,1
	if rs.bof and rs.eof then PopErr("未找到此商品")

		sql2="select * from aygood where isptdx=1 and ptdxyid="&id&""
		rs2.open sql2,conn,1,3
		if not(rs2.bof and rs2.eof) then PopErr("该商品已经存在代售系统")
		rs2.addnew
		
		ptdxsign=""
		ptdxsign=rs("aygoodid")&rs("aygoodsuoyouid")&rs("aygoodfl")&rs("ayjiage")&rs("aygooddlid")
		
		rs2("aygoodsuoyouid")=rs("aygoodsuoyouid")
		rs2("aygoodfl")=rs("aygoodfl")
		rs2("aygoodname")=trim(rs("aygoodname"))
		rs2("ayjiage")=rs("ayjiage")
		rs2("aychenben")=rs("aychenben")
		rs2("ayyujing")=rs("ayyujing")
		rs2("ayyujingmail")=rs("ayyujingmail")
		rs2("ayyujingmss")=rs("ayyujingmss")
		rs2("ayyujingtel")=rs("ayyujingtel")
		rs2("ayjujingwx")=rs("ayjujingwx")
		rs2("ayshoukatz")=rs("ayshoukatz")
		rs2("ayshmiaoshu")=rs("ayshmiaoshu")
		rs2("aygoodzhuangtai")="1"
		rs2("goodxx")=rs("goodxx")
		rs2("goodbuyxx")=rs("goodbuyxx")
		rs2("shoukamail")=rs("shoukamail")
		rs2("shoukatel")=rs("shoukatel")
		rs2("shouikawx")=rs("shouikawx")
		rs2("kahaoname")=rs("kahaoname")
		rs2("kaminame")=rs("kaminame")
		rs2("aygoodsx")="100"
		rs2("aypifayes")="0"
		rs2("ayxiangou")="0"
		rs2("ayyouhuiyes")="0"	
		rs2("ayzhifu")="0"
		rs2("ayshurl")=weburl
		rs2("ayshqq")=fuwuqq
		rs2("ayisbankpay")="1"
		rs2("ayisalipay")="1"
		rs2("ayistenpay")="1"
		rs2("ayissaopay")="1"
		rs2("ayisqqpay")="1"
		rs2("ayggodispass")="0"
		rs2("aygoodiskucun")="0"
		rs2("aygooddlid")="0"
		rs2("aygoodisydl")="1"
		rs2("aygiska")="0"
		rs2("aygismka")="0"
		rs2("aysjjiage")="0"
		rs2("aysjgid")="0"
		rs2("aygoodtodaili")="0"
		rs2("buylx")="0"
		rs2("issjsuo")="0"
		rs2("aygsumid")=randarr
		rs2("isptdx")="1"
		rs2("ptdxyfid")=rs("aygoodfl")
		rs2("ptdxyid")=id
		rs2.update
		rs2.close
		
		'获取id 加入MD5
		sqlid="select top 1 * from aygood where isptdx=1 and aygoodsuoyouid="&rs("aygoodsuoyouid")&" and ptdxyid="&id&" order by aygoodid desc" 
		rsid.open sqlid,conn,1,3
		rsid("aygoodmd5")=md5d(rsid("aygoodid"))
		rsid("aygdlmd5url")=md5user(rsid("aygoodid"))
		rsid("ptdxsign")=md5(ptdxsign)
		rsid.update
		rsid.close
	
	rs.close

	call logadd(request.Cookies("aynameid"),"管理-商品加入代售成功"&id,0,0)
	call PopErr("商品加入代售成功")

end if


if act="sj" then
id=SafeRequest("id")
sql="select * from aygood where aygoodid="&clng(id)&"" 
rs.open sql,conn,1,3
if rs.bof and rs.eof then
rs.close
PopErr("未找到此商品")
else
rs("issjsuo")=0
rs("aygoodzhuangtai")=0
rs.update
rs.close
call logadd(request.Cookies("aynameid"),"管理-商品上架成功"&id,0,0)
response.Redirect("admingoodlist.asp")
end if
end if

if act="xj" then
id=SafeRequest("id")
sql="select * from aygood where aygoodid="&clng(id)&"" 
rs.open sql,conn,1,3
if rs.bof and rs.eof then
rs.close
PopErr("未找到此商品")
else
rs("issjsuo")=1
rs("aygoodzhuangtai")=1
rs.update
rs.close
call logadd(request.Cookies("aynameid"),"管理-商品下架成功"&id,0,0)
response.Redirect("admingoodlist.asp")
end if
end if


if act="edit" then
call lognamecode()
id=SafeRequestform("id")
uid=SafeRequestform("uid")

mingcheng=trim(SafeRequestform("mingcheng"))
ayshmiaoshu=trim(SafeRequestform("ayshmiaoshu"))
ayshurl=trim(SafeRequestform("ayshurl"))
ayshqq=trim(SafeRequestform("ayshqq"))
ptdxtitle=trim(SafeRequestform("ptdxtitle"))
content1=trim(SafeRequestform("content1"))
content2=trim(SafeRequestform("content2"))
pic1=SafeRequestform("pic1")
ayxlz=SafeRequestform("ayxlz")

sql="select * from aygood where aygoodid="&clng(id)&"" 
rs.open sql,conn,1,3
	if rs.bof and rs.eof then
	rs.close
	PopErr("未找到此商品")
	else


	rs("aygoodname")=mingcheng  
	  
	if ayshmiaoshu<>"" then 
	rs("ayshmiaoshu")=ayshmiaoshu
	else
	rs("ayshmiaoshu")=" "
	end if
	
	if ayshurl<>"" then 
	rs("ayshurl")=ayshurl
	else
	rs("ayshurl")=" "
	end if
	
	if ayshqq<>"" then 
	rs("ayshqq")=ayshqq
	else
	rs("ayshqq")=0
	end if
	
	rs("ptdxtitle")=ptdxtitle
	
	if trim(content1)<>"" then rs("goodxx")=content1
	if trim(content2)<>"" then rs("goodbuyxx")=content2
	
	if trim(pic1)<>"" then 	rs("ptdxpic")=trim(pic1)
	
	rs.update
	rs.close
	


	rs.open "select top 1 ayxlgid,ayxlz from ayxiaoliang where ayxlgid="&clng(id)&"",conn,1,3	
	if not(rs.bof and rs.eof) then
	rs("ayxlz")=ayxlz
	rs.update
	else
	rs.addnew
	rs("ayxlgid")=id
	rs("ayxlz")=ayxlz
	rs.update
	end if
	rs.close
	
	
	call logadd(request.Cookies("aynameid"),"管理-商品修改成功"&mingcheng,0,0)
	call PopErr2("商品修改成功","admingoodlist.asp?uid="&uid&"")
	end if

end if


id=SafeRequest("id")
uid=SafeRequest("uid")
if id="" then call PopErr("获取参数错误")
sql="select * from aygood where aygoodid="&id&"" 
rs.open sql,conn,1,3
if rs.bof and rs.eof then
rs.close
call PopErr("未找到商品")
end if
%>
<DIV id=main1200> 
<%call webleft()%>
<DIV id=main_right>
<DIV id=main_right_content>
<STYLE>.apply_style {
	POSITION: absolute
}
.right_title A {
	LINE-HEIGHT: 27px; WIDTH: 126px; DISPLAY: inline-block; BACKGROUND: url(<%=ossurl%>images/bg22.gif) no-repeat; HEIGHT: 27px
}
.right_title A.current {
	BACKGROUND: url(<%=ossurl%>images/main_right_title_bg.gif) no-repeat; COLOR: #fff; FONT-WEIGHT: bold
}
.table_style_1 TD {
	HEIGHT: 38px
}
.table_style_home_info TD {
	PADDING-BOTTOM: 0px; PADDING-LEFT: 10px; PADDING-RIGHT: 0px; HEIGHT: 30px; PADDING-TOP: 0px
}
</STYLE>

<DIV class=right_titleadmin>&nbsp;&nbsp;编辑商品<a style="color:#F30" href="?act=adddaishou&id=<%=id%>">【加入平台代售系统】</a></DIV>
<DIV class=main>

<form action="?act=edit" method="post" name="form" id="form">
  <table width="99%" border="0" align="center" cellpadding="0" cellspacing="0" class="table_style_a1">
      <tr>
      <td colspan="2" align="left"><span style="font-weight: bold">&nbsp;&nbsp;<span style="color: #FF0000">商品主要信息：(必填项)</span></span></td>
      </tr>
    <tr>
      <td width="80" align="center"><span style="color: #FF0000">商品名称：</span></td>
      <td><input name="mingcheng" type="text" id="mingcheng" value="<%=server.HTMLEncode(trim(rs("aygoodname")))%>" size="55" maxlength="25">
        <input name="uid" type="hidden" id="id" value="<%=uid%>"><input name="id" type="hidden" id="id" value="<%=id%>"></td>
    </tr>
		    <%if clng(rs("aygooddlid"))=0 then%>
<%end if%>
    <tr> 
      <td align="center">商品描述：</td>
      <td><input name="ayshmiaoshu" type="text" id="ayshmiaoshu" value="<%if isnull(trim(rs("ayshmiaoshu")))=true or trim(rs("ayshmiaoshu"))="" then response.Write" ":else:response.Write server.HTMLEncode(trim(rs("ayshmiaoshu"))):end if%>" size="55" maxlength="30">
        </td>
    </tr>

    <tr>
      <td align="center">商品网址：</td>
      <td><input name="ayshurl" type="text" id="ayshurl" value="<%if isnull(trim(rs("ayshurl")))=true or trim(rs("ayshurl"))="" then response.Write" ":else:response.Write server.HTMLEncode(trim(rs("ayshurl"))):end if%>" size="55" maxlength="40">
       </td>
    </tr>
    <tr>
      <td align="center">商户QQ：</td>
      <td><input name="ayshqq" type="text" id="ayshqq" value="<%if trim(rs("ayshqq"))<>0 then response.Write trim(rs("ayshqq"))%>" maxlength="12">
       </td>
    </tr>
    <tr>
      <td align="center">代售标签：</td>
      <td><input name="ptdxtitle" type="text" id="ptdxtitle" value="<%if isnull(trim(rs("ptdxtitle")))=true or trim(rs("ptdxtitle"))="" then response.Write" ":else:response.Write server.HTMLEncode(trim(rs("ptdxtitle"))):end if%>" maxlength="50" size="55">(以半角逗号分隔)
       </td>
    </tr>
    <tr>
      <td align="center">代售销量：</td>
      <td><input name="ayxlz" type="text" id="ayxlz" value="<%=goodbuysum(rs("aygoodid"))%>">
       </td>
    </tr>
                            			<script>
                                        KindEditor.ready(function(K) {
                                            var uploadbutton1 = K.uploadbutton({
                                                button : K('#uploadButton1')[0],
                                                fieldName : 'imgFile',
                                                url : '/kindeditor/asp/upload_daishou.asp?dir=image',
                                                afterUpload : function(data) { 
                                                    if (data.error === 0) {
                                                        var url = K.formatUrl(data.url, '');
                                                        urlcon=url.replace("/kindeditor/asp/../../","/"); 
                                                        K('#picurl1').val(urlcon);
                                                        con1.innerHTML='<a href='+urlcon+' target=_blank><img src='+urlcon+' width=120 height=120/></a>';
														con2.innerHTML='';
                                                    } else {
                                                        alert(data.message);
                                                    }
                                                },
                                                afterError : function(str) {
                                                    alert('自定义错误信息: ' + str);
                                                }
                                            });
                                            uploadbutton1.fileBox.change(function(e) {
                                                uploadbutton1.submit();
                                            });
                                        });
                                    </script>
    <tr>
      <td align="center">代售图片：</td>
      <td>
	  <input type="button" id="uploadButton1" value="上传图片" />(宽260*高200)
      <input name="pic1" type="hidden" id="picurl1" value="" readonly="readonly" /> 
      <input name="ptdxpic" type="hidden" value="<%=trim(rs("ptdxpic"))%>" size="30" maxlength="50">
      <span id="con1"></span><span id="con2"><%if trim(rs("ptdxpic"))<>"" and isnull(trim(rs("ptdxpic")))=false then response.Write"<img src="&trim(rs("ptdxpic"))&" width=120 height=120/>"%></span>
       </td>
    </tr>
<script>
        var editor;
        KindEditor.ready(function(K) {
                editor = K.create('#editor_id', 
				{
				width : '950px',
				height : '300px',
				uploadJson : '/kindeditor/asp/json_good.asp',
				fileManagerJson : '/kindeditor/asp/json_file_good.asp',
				allowFileManager : false,  //图片空间
				fillDescAfterUploadImage : true,  //图片上传后编辑
				items:[
						'undo', 'redo', '|', 'justifyleft', 'justifycenter', 'justifyright', 'fontname', 'fontsize', 'forecolor', 'hilitecolor',
						'bold', 'italic', '|', 'underline', 'strikethrough', 'image',
						'table', 'hr', 'emoticons', 'link', 'unlink', 'lineheight'
					  ]
                });
        });
		
                                    var editor;
                                    KindEditor.ready(function(K) {
                                            editor = K.create('#editor_id2', 
                                            {
                                            width : '950px',
                                            height : '300px',
                                            uploadJson : '/kindeditor/asp/json_good.asp',
                                            fileManagerJson : '/kindeditor/asp/json_file_good.asp',
                                            allowFileManager : false,  //图片空间
                                            fillDescAfterUploadImage : true,  //图片上传后编辑
                                            items:[
                                                    'undo', 'redo', '|', 'justifyleft', 'justifycenter', 'justifyright', 'fontname', 'fontsize', 'forecolor', 'hilitecolor',
                                                    'bold', 'italic', '|', 'underline', 'strikethrough', 'image',
                                                    'table', 'hr', 'emoticons', 'link', 'unlink', 'lineheight', 'source'
                                                  ]
                                            });
                                    });
</script>
    
    <tr>
      <td align="center"><span title="该说明显示在商品购买页面">购买说明：</span><br></td>
      <td>
	  <%
	  if trim(rs("goodxx"))<>"" and isnull(trim(rs("goodxx")))=false then 
	  goodxx=rs("goodxx")
	  else
	  goodxx=" "
	  end if
	  
	  %>
      <textarea id="editor_id" name="content1"><%=Server.HtmlEncode(goodxx)%></textarea>
	</td>
    </tr>
    <tr>
      <td align="center"><span title="该说明显示在商品购买页面">使用说明：</span><br></td>
      <td>
	  <%
      if trim(rs("goodbuyxx"))<>"" and isnull(trim(rs("goodbuyxx")))=false then 
      goodbuyxx=rs("goodbuyxx")
      else
      goodbuyxx=" "
      end if
      %>
      <textarea id="editor_id2" name="content2"><%=Server.HtmlEncode(goodbuyxx)%></textarea>
	</td>
    </tr>
    <tr>
      <td colspan="2" align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" name="Submit" value=" 确 认 修 改 " style="cursor:pointer"  class="butbaocun">
        </td>
    </tr> 
  </table>
</form>
</DIV>
 

</DIV></DIV>
<DIV class=clear></DIV></DIV>
</DIV>
<SCRIPT>
$(function(){
$('.left_title').each(function(){
   $(this).click(function(){
	   var index=$('.left_title').index(this);
	   if($(this).next().hasClass('hide_m')){
		   $(this).next().removeClass('hide_m');
           $(this).next().show();		 
		   $(this).find('img').attr('src','<%=ossurl%>images/expansion.gif');
		   $.cookie('m_index_'+index,'',{expires:0});
	   } else {
	       $(this).next().hide();
		   $(this).next().addClass('hide_m');
		   $(this).find('img').attr('src','<%=ossurl%>images/shrank.gif');		   
		   $.cookie('m_index_'+index,'none',{expires:365});
	   }
   })
})

$('.left_title').each(function(){
	var index=$('.left_title').index(this);
    $(this).next().css('display',$.cookie('m_index_'+index) ? $.cookie('m_index_'+index) : '');
	if($.cookie('m_index_'+index)){
	    $(this).next().addClass('hide_m');
	}
	$(this).find('img').attr('src',$.cookie('m_index_'+index) ? '<%=ossurl%>images/shrank.gif' : '<%=ossurl%>images/expansion.gif');
})
})

</SCRIPT>


<!--#include virtual="/show/footadmin.asp"-->

