<%guidedisplay=1%>
<!--#include file="admin_start.asp" -->
<!--#include file="../inc/class_image.asp" -->
<%
id=int(request("id"))
if request("action")<>"delete" then
	rs.open"select goods_id,goods_name from jins_goods_list where goods_id="&id&" ",conn,1,1
	if rs.eof then
	   MySys.Error.info = "没有这个商品！"
	   MySys.Error.location = "back"
	   MySys.Error.err()
	End If
	goods_name=rs("goods_name")
	rs.close
end if

set im=MySys.image
select case request("action")
case "add"
    rs.open"select * from jins_goods_pic_list ",conn,1,3
    if request("goods_pic_src")<>"" then
		if request("goods_pic_w")<>"" or request("goods_pic_h")<>""  then
			ims=im.showimage(server.mappath("../"&request("goods_pic_src")),request("goods_pic_w"),request("goods_pic_h"))
			w=ims(0)
			h=ims(1)
		else
			ims=im.showimage(server.mappath("../"&request("goods_pic_src")),90,"")
			w=ims(0)
			h=ims(1)
		end if
	end if
	
	if w="" then w=90
	if h="" then h=90
	
	rs.addnew
	rs("goods_id")=id
	rs("goods_pic_src")=request("goods_pic_src")
	rs("goods_pic_w")=w 
	rs("goods_pic_h")=h
	rs("goods_pic_alt")=request("goods_pic_alt")
	rs.update
	rs.close
	
   Session("FB_EM_1_ACC_uppath")=""
   
   MySys.Error.info = "加入图片成功！"
   MySys.Error.location = "back"
   MySys.Error.suc()
	   
case "delete"

	if request("pic_id")="" then
	   MySys.Error.info = "请选择要删除的图片！"
	   MySys.Error.location = "back"
	   MySys.Error.err()
	End If
	
	set rs_t=conn.execute("select goods_pic_src from jins_goods_pic_list where goods_pic_id="&request("pic_id")&" ")
	if not rs_t.eof then
		filename=rs_t("goods_pic_src")
		conn.execute("delete from jins_goods_pic_list where goods_pic_id="&request("pic_id")&" ")
		if filename<>"" then
			filename="../"&filename
			Set fso = CreateObject("Scripting.FileSystemObject")
			if fso.FileExists(server.mappath(filename)) then fso.deletefile server.mappath(filename),true
			Set fso = nothing
		end if
	end if
	set rs_t=nothing
	
    MySys.Error.info = "删除图片成功！"
    MySys.Error.location = "back"
    MySys.Error.suc()

case "edit"

	Set fso = CreateObject("Scripting.FileSystemObject")
    rs.open"select * from jins_goods_pic_list where goods_id="&id&" ",conn,1,3
	do while not rs.eof 
	
		if request("goods_pic_src_"&rs("goods_pic_id"))<>rs("goods_pic_src") then
			if fso.FileExists(server.mappath("../"&rs("goods_pic_src"))) then fso.deletefile server.mappath("../"&rs("goods_pic_src")),true
			'rs("goods_pic_src")=request("goods_pic_src_"&rs("goods_pic_id"))
		end if
		
		if request("goods_pic_src_"&rs("goods_pic_id"))<>"" then 
			
			if request("goods_pic_w_"&rs("goods_pic_id"))<>"" or request("goods_pic_h_"&rs("goods_pic_id"))<>""  then
				ims=im.showimage(server.mappath("../"&request("goods_pic_src_"&rs("goods_pic_id"))),request("goods_pic_w_"&rs("goods_pic_id")),request("goods_pic_h_"&rs("goods_pic_id")))
				w=ims(0)
				h=ims(1)
			else
				ims=im.showimage(server.mappath("../"&request("goods_pic_src_"&rs("goods_pic_id"))),90,"")
				w=ims(0)
				h=ims(1)
			end if
			
		end if
		
		if w="" then w=90
		if h="" then h=90
		
		rs("goods_pic_src")=request("goods_pic_src_"&rs("goods_pic_id"))
		rs("goods_pic_w")=w 
		rs("goods_pic_h")=h
		rs("goods_pic_alt")=request("goods_pic_alt_"&rs("goods_pic_id"))
		rs.update
		
	rs.movenext
	loop
	rs.close
	Set fso = nothing
	
	Session("FB_EM_1_ACC_uppath")=""

    MySys.Error.info = "图片编辑成功！"
    MySys.Error.location = "back"
    MySys.Error.suc()

end select
set im=nothing

rs.open"select * from jins_goods_pic_list where goods_id="&id&" ",conn,1,1

Session("FB_EM_1_ACC_uppath")="../GOODSPIC/"&id
%>
<body topmargin="10" leftmargin="10" rightmargin="10" bottommargin="10" marginwidth="10" marginheight="10">
<form name=admin_goods_pic method=post action='admin_goods_pic_edit.asp?action=edit&id=<%=id%>'>
<div valign=top>
		<table cellpadding="3" cellspacing="3" width="98%" height="30" align=center style='border:1px solid #ebebeb' >
			
		<%
		do while not rs.eof 
		%>
			<tr align="left" >
				<td height=30 valign="middle" width="1%">
				<img alt='弹开图片说明' onclick="opencat(style_<%=rs("goods_pic_id")%>_open)" style='CURSOR: hand' src="Images/index_search.gif" width="8" height="16" hspace="5" align="absmiddle">
				</td>
				<td  width="59%" align=left >
				<%=left(rs("goods_pic_alt"),40)%>
				</td>
				<td  width="10%" align=left valign=center><a title='点击删除此项！' href='admin_goods_pic_edit.asp?action=delete&pic_id=<%=rs("goods_pic_id")%>'><img border='0' src='Images/delete.gif' align='bottom' alt='点击删除此项！'></a></td>
			</tr>
			<tr id="style_<%=rs("goods_pic_id")%>_open" style="display:none">
			    <td colspan="9" align=center>
				<table cellpadding="3" cellspacing="3" width="98%" height="30" align=center bgcolor='#f7f7f7' style='border:1px dashed #808080;'>
					
					<tr>
					<td  width="15%" align=right valign=center>
					图片地址:
					</td>
						<td  width="85%" align=left >
						<input name=goods_pic_src_<%=rs("goods_pic_id")%> type=text size=40  value="<%=rs("goods_pic_src")%>" >
						<input type="button"  value="从本地上传" onClick="window.open('admin_upload.asp?formname=admin_goods_pic&editname=goods_pic_src_<%=rs("goods_pic_id")%>&filelx=jpg','','status=no,scrollbars=no,top=20,left=110,width=420,height=165')">
						<img style='CURSOR: hand' onclick='javascript:window.open("../"+admin_goods_pic.goods_pic_src_<%=rs("goods_pic_id")%>.value);' border=0 src='images/btn_pre2.gif' align='absbottom' >
						</td>
					</tr>
					
					<tr>
						<td  width="15%" align=right valign=center>
						图片宽度:
						</td>
						<td  width="85%" align=left valign=center>
						<input  name=goods_pic_w_<%=rs("goods_pic_id")%> type=text size=5  value="<%=rs("goods_pic_w")%>" > px
						</td>
					</tr>
					
					<tr>
						<td  width="15%" align=right valign=center>
						图片高度:
						</td>
						<td  width="85%" align=left valign=center>
						<input name=goods_pic_h_<%=rs("goods_pic_id")%> type=text size=5  value="<%=rs("goods_pic_h")%>" > px
						</td>
					</tr>
					
					<tr>
						<td  width="15%" align=right valign=top>
						图片说明:
						</td>
						<td width="85%" align=left valign=top>
						<textarea name="goods_pic_alt_<%=rs("goods_pic_id")%>" cols="55" rows="3"><%=rs("goods_pic_alt")%></textarea>
						</td>
					</tr>
					
				</table>
				
				</td>
			</tr>
			<tr>
			    <td height='1' colspan="9" background='images/dot03.gif'></td>
			</tr>
		<%
		rs.movenext
		loop
		%>	
			<tr align="left" >
				<td height=30 colspan="9"  align="center"  >
					<input type=submit  value="提交编辑" >
					<input type=reset  value="重置" >
				</td>
			</tr>
			
		</table>
</div>
</form>

<form name=admin_goods_pic_add method=post action='admin_goods_pic_edit.asp?action=add&id=<%=id%>'>
<div valign=top>
		<table cellpadding="3" cellspacing="3" width="98%" height="30" align=center style='border:1px solid #ebebeb' >
			
			<tr align="left" >
				<td height=30 valign="middle" width="1%">
				<img alt='弹开图片说明' onclick="opencat(style_add_open)" style='CURSOR: hand' src="Images/index_search.gif" width="8" height="16" hspace="5" align="absmiddle"> 添加新的图片
				</td>
			</tr>
			<tr id="style_add_open" style="display:">
			    <td colspan="9" align=center>
				<table cellpadding="3" cellspacing="3" width="98%" height="30" align=center bgcolor='#f7f7f7' style='border:1px dashed #808080;'>
					
					<tr>
					<td  width="15%" align=right valign=center>
					图片地址:
					</td>
						<td  width="85%" align=left >
						<input name=goods_pic_src type=text size=40  value="" >
						<input type="button"  value="从本地上传" onClick="window.open('admin_upload.asp?formname=admin_goods_pic_add&editname=goods_pic_src&filelx=jpg','','status=no,scrollbars=no,top=20,left=110,width=420,height=165')">
						<img style='CURSOR: hand' onclick='javascript:window.open("../"+admin_goods_pic_add.goods_pic_src.value);' border=0 src='images/btn_pre2.gif' align='absbottom' >
						</td>
					</tr>
					
					<tr>
						<td  width="15%" align=right valign=center>
						图片宽度:
						</td>
						<td  width="85%" align=left valign=center>
						<input  name=goods_pic_w type=text size=5  value="" > 可以不填，上传以后系统会自动读取图片的尺寸！并自动缩略到90*90
						</td>
					</tr>
					
					<tr>
						<td  width="15%" align=right valign=center>
						图片高度:
						</td>
						<td  width="85%" align=left valign=center>
						<input name=goods_pic_h type=text size=5  value="" > 如果您需要显示为其他尺寸，请填入数值！
						</td>
					</tr>
					
					<tr>
						<td  width="15%" align=right valign=top>
						图片说明:
						</td>
						<td width="85%" align=left valign=top>
						<textarea name="goods_pic_alt" cols="55" rows="3"></textarea>
						</td>
					</tr>
					
				</table>
				
				</td>
			</tr>
			<tr>
			    <td height='1' colspan="9" background='images/dot03.gif'></td>
			</tr>
			<tr align="left" >
				<td height=30 colspan="9"  align="center" >
					<input type=submit  value="添加图片" >
					<input type=reset  value="重置" >
				</td>
			</tr>
		</table>
</div>
</form>
<SCRIPT language=javascript>
	function opencat(cat)
	{
 	 	if(cat.style.display=="none"){
     	cat.style.display="";
  		} else {
     	cat.style.display="none"; 
  		}
	}
	function menushow(m,i){
		document.getElementById("menu").innerHTML=m;
		for(var ii=0 ;ii< 5;ii++)
			if (ii==i)
				document.getElementById("m_"+ii).style.display="";
			else
				document.getElementById("m_"+ii).style.display="none";
	}
	
</SCRIPT>

</body>
<!--#include file="admin_end.asp" -->