<!--#include file="conn.asp"-->
<!--#include file="inc/cookies_check.asp"-->
<!--#include file="inc/Page_cls.asp"-->
<%
'*****************************************
'* 软件名称 乐彼网上开店软件(56770 EShop)
'* 软件开发 http://www.56770.com
'* 版权所有 http://www.56770.com
'* 文件名称 Admin_deliver.asp
'* 最后更新 2013-08-22 by 56770.kingdge
'* 历史更新 2008-6-10 by 56770.WangLei
'*****************************************
admin_flag=",8.6,"
include "lang/"& LangFilePath &"/lang_sys.inc"
include "lang/"& LangFilePath &"/lang_menu.inc"
include "lang/"& LangFilePath &"/lang_deliver.inc"
CurrentId = 5
CurrentUrl = "admin_deliver.asp"
LB_Head()
LB_Menu()
action = request("action")
id = CheckNum(request("id"),0)
%>
<div class="tabmenu mainwidth">
      <ul>
        <li <%If action <> "add" And action<>"add_ok" And action<>"api" And action<>"api_ok" Then response.write(" class=""current""")%>><a href="Admin_deliver.asp"><span><%=Lang_Menu(136)%></span></a></li>
		<%
		if id <> 0 Then
			response.write("<li class=""current""><a href=""#""><span>"& Lang_Deliver(12) &"</span></a></li>") 
		Else
			response.write("<li")
			If action = "add" Then response.write(" class=""current""")
			response.write("><a href=""?action=add""><span>"& Lang_Deliver(11) &"</span></a></li>") 
		End If
		%>
        <li><a href="Admin_deliver_area.asp"><span><%=Lang_Menu(137)%></span></a></li>
		<li <%If action = "api" or action = "api_ok" Then response.write(" class=""current""")%>><a href="Admin_deliver.asp?action=api"><span><%=Lang_Deliver(56)%></span></a></li>
      </ul>
</div>
<%
Response.Write("<div class=""tab-mainbody"">")
Response.Write("<div class=""tab-mainbody2"">")
If Eshop_Lebi_name="" Or instr(","&Eshop_Lebi_flag&",",admin_flag)=0 Then
		adminflag()
Else
		If OutSubmit = 1 Then CheckOutSubmit()
		Select Case action
			   Case "add" : add()
			   Case "add_ok" : add_ok()
			   Case "edit" : edit()
			   Case "del" : del()
			   Case "updatePrice" : updatePrice()
			   Case "api" : api()
			   Case "api_ok" : api_ok()
			   Case Else
					main()
		End Select
End If
Response.Write("</div>")
Response.Write("</div>")
LB_Footer()

Sub add_ok()
        If OnlyRead = 1 Then OnlyReadMessage()
		deliver_name = safereplace(request("deliver_name"& lang))
		deliver_price = CheckNum(request("deliver_price"),0)
		deliver_code = safereplace(request("deliver_code"))
		If deliver_name = "" Then
				response.write"<SCRIPT language=JavaScript>alert('"& Lang_Deliver(1) &"');javascript:history.go(-1)</SCRIPT>"
				response.End
		End If
		Dim isTrue : isTrue = 1
		id = CheckNum(request("id"),0)
		If id <> 0 Then
				set rs=server.CreateObject("adodb.recordset")
				sqlm="select top 1 * from [Lebi_deliver] where id<>"&id&" and deliver_name='"&deliver_name&"'"
				rs.open sqlm,conn,1,1
				If Not rs.eof then
					m_s="·"& Lang_Deliver(2)
					isTrue = 0
				Else
					set rss=server.CreateObject("adodb.recordset")
					rss.open "select * from [Lebi_deliver] where id="& id &"", conn, 1, 3
					For LangT = 1 To TotalLang
							rss("deliver_name" & LanguageTxt(LangT)) = trim(safereplace(request("deliver_name" & LanguageTxt(LangT))))
							rss("deliver_info" & LanguageTxt(LangT)) = safereplace(request("deliver_info" & LanguageTxt(LangT)))
					Next
					rss("deliver_price") = deliver_price
					rss("deliver_code") = deliver_code
					rss.update
					rss.close : Set rss = Nothing
					m_t=Lang_sys(48)
					m_s="·"& Lang_sys(47)
					ManageLog Lang_Deliver(3) &" ["&deliver_name&"]"
				End If
				rs.close : set rs=nothing
		Else
				set rss=server.CreateObject("adodb.recordset")
				rss.open "select * from [Lebi_deliver]", conn, 1, 3
				rss.addnew
				For LangT = 1 To TotalLang
						rss("deliver_name" & LanguageTxt(LangT)) = trim(safereplace(request("deliver_name" & LanguageTxt(LangT))))
						rss("deliver_info" & LanguageTxt(LangT)) = safereplace(request("deliver_info" & LanguageTxt(LangT)))
				Next
				rss("deliver_price") = deliver_price
				rss("deliver_code") = deliver_code
				rss.update
				rss.close : Set rss = Nothing
				m_t=Lang_sys(45)
				m_s="·"& Lang_sys(44)
				ManageLog Lang_Deliver(4) &" ["&deliver_name&"]"
		End If
		m_u="?page="& request("page") &"&keyword="& request("keyword") &"&lang="& request("lang")
		m_time="2"
		Call Up_mes(m_t,m_s,0,m_u,0,0,m_time,isTrue)
		response.End
End Sub

Sub del()
        If OnlyRead = 1 Then OnlyReadMessage()
        del_id= Replace(safereplace(Trim(request("id"))),"，",",")
		If Right(del_id,1) = "," Then del_id = Left(del_id,Len(del_id)-1)
		if del_id="" then
				response.write"<SCRIPT language=JavaScript>alert('"& Lang_sys(41) &"');javascript:history.go(-1)</SCRIPT>"
				response.end
		end if
		conn.execute "delete from [Lebi_deliver] where id in (" & del_id &")"
		ManageLog Lang_Deliver(5) &" ["&id&"]"
		m_t=Lang_sys(43)
		m_s="·"& Lang_sys(42)
		m_u="?page="& request("page") &"&keyword="& request("keyword") &"&pagenum="& request("pagenum") &"&lang="& request("lang")
		m_time="2"
		Call Up_mes(m_t,m_s,0,m_u,0,0,m_time,1)
End Sub

Sub updatePrice
        If OnlyRead = 1 Then OnlyReadMessage()
		id=safereplace(request("id"))
		pPrice=safereplace(request("pPrice"))
		if id="" then
				response.write"<SCRIPT language=JavaScript>alert('"& Lang_sys(70) &"');javascript:history.go(-1)</SCRIPT>"
				response.end
		end If
		Dim idArr:idArr = Split(id,"|||")
		Dim priceArr : priceArr = Split(pPrice,"|||")
		for i=0 to ubound(idArr)
			If IsNumeric(priceArr(i)) And IsNumeric(idArr(i)) then
				  sql="update [Lebi_deliver] set deliver_price = "&priceArr(i)&" where id ="&idArr(i)
				  conn.execute(sql)
			End If
		Next
		ManageLog Lang_Deliver(6)
		m_t=Lang_sys(69)
		m_s="·"& Lang_sys(68)
		m_u="?page="& request("page") &"&keyword="& request("keyword") &"&pagenum="& request("pagenum") &"&lang="& request("lang")
		m_time="2"
		Call Up_mes(m_t,m_s,0,m_u,0,0,m_time,2)
		response.redirect url
End Sub

Sub api_ok
        If OnlyRead = 1 Then OnlyReadMessage()
		api_state = checknum(request("api_state"),0)
		api_key = safereplace(request("api_key"))
		conn.execute("update [Lebi_System] set sys_kuaidi100 = '"& api_state &"|"& api_key &"'")
		ManageLog Lang_Deliver(62)
		CreateConfig()
		m_t=Lang_sys(69)
		m_s="·"& Lang_sys(68)
		m_u="?action=api"
		m_time="2"
		Call Up_mes(m_t,m_s,0,m_u,0,0,m_time,2)
End Sub

Sub main()
		page = CheckNum(request("page"),1)
		pagenum = CheckNum(request("pagenum"),15)
		keyword=safeReplace(request("keyword"))
		lang = safereplace(request("lang"))
		If lang = "" Then lang = LanguageTxt(0)
		Dim ors
		Set ors=new Cls_vbsPage
		Set ors.Conn=conn
		With ors
		.PageSize=pagenum
		.PageName="Page"
		If IsSqlDataBase = 0 Then
				.DbType="AC"
		Else
				.DbType="MSSQL"
		End If
		.RecType=-1
		.Pkey="id"
		.Field="id,deliver_name"& lang &",deliver_price,deliver_info"& lang &",deliver_code"
		.Table="[Lebi_deliver]"
		sql = "1=1"
		if keyword<>"" then sql=sql&" and (deliver_name"& lang &" like '%"&keyword&"%' or deliver_info"& lang &" like '%"&keyword&"%')"
		.Condition=sql
		.OrderBy="id desc"
		End With
		DataCount=ors.RecCount()
		DataList=ors.ResultSet()
%>
<script>
function todel()
{

   var i = 0;
   var chkArr = document.getElementsByTagName("input");
   var page = document.getElementById("page").value;
   var lang = document.getElementById("lang").value;
   var keyword = document.getElementById("keyword").value;
   var pagenum = document.getElementById("pagenum").value;
   var param = "";
   for (i=0;i<chkArr.length;i++)
   if (chkArr[i].checked)
   param+=chkArr[i].value +",";
   if (param.length == 0)
   {
       alert("<%=Lang_sys(41)%>");
   }else{
       if(window.confirm("<%=Lang_sys(64)%>")){
           location="?action=del&id="+param+"&keyword="+escape(keyword)+"&lang="+lang+"&pagenum="+pagenum+"&page="+page;
       }else return;
   }
}
</script>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="classtable-top">
<tbody>
<form name="form" action="?" method="get">
<tr>
<td height="30" align="left" class="classhead">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<select name="lang">
<option value="" selected>┌ <%=Lang_sys(67)%></option>
<%For LangT = 1 To TotalLang%>
<option value="<%= LanguageTxt(LangT) %>"<%=judge2(LanguageTxt(LangT),Lang)%>>├ <%= LanguageName(LangT) %></option>
<%Next%>
</select></td>
<td style="padding-left:5px;"><input name="keyword" type="text" value="<%=keyword%>" class="form_query" size="15"><input name="Submit" type="submit" value="" title="<%=Lang_sys(25)%>" align="absmiddle" class="btn_query"><input type="hidden" name="pagenum" value="<%= pagenum %>">
</td>
</tr>
</table>
</td>
</form>
<td align="right" class="classhead">
<%=QuickMenu("Admin_flag.asp|"& Lang_Menu(136) &"","Admin_deliver_area.asp|"& Lang_Menu(137) &"")%>
</td>
</tr>
</tbody>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="classtable" class="classtable2">
<tr>
<td align="left" colspan="2" class="classhead" height="30">
 <input type="image" src="lang/<%=LangFilePath%>/images/bt_app.gif" title=" <%=Lang_sys(1)%> " onclick="location.href='javascript:toUpdateDeliverPrice();';return false;" align="absmiddle">
 <input type="image" border="0" title=" <%=Lang_sys(15)%> " onclick="location.href='javascript:todel();';return false;" src="lang/<%=LangFilePath%>/images/bt_delete.gif" align="absmiddle">
 <input type="hidden" name="page" id="page" value=<%=page%>>
 <input type="hidden" name="keyword" id="keyword" value="<%=keyword%>">
 <input type="hidden" name="lang" id="lang" value="<%=lang%>">
 <input type="hidden" name="pagenum" id="pagenum" value="<%= pagenum %>">
</td>
<td height="30" class="classhead" align="right" colspan="4"><%=ors.ShowPageHead(page)%></td>
</tr>
<tr>
<td width="5%" height="30" class="classtop" title="<%=Lang_sys(4)%>" style="cursor:pointer;" onclick="location.href='javascript:selectall();';return false;"><%=Lang_sys(50)%></td>
<td width="15%" class="classtop"><%=Lang_Deliver(7)%></td>
<td width="15%" class="classtop"><%=Lang_Deliver(55)%></td>
<td width="15%" class="classtop"><%=Lang_Deliver(8)%></td>
<td width="40%" class="classtop"><%=Lang_Deliver(9)%></td>
<td width="10%" class="classtop"><%=Lang_Deliver(10)%></td>
</tr>
<%
If DataCount >0 Then
		For i = 0 To Ubound(DataList,2)
%>
<tr class="classrow">
<td height="30" class="classrow"><input name="id" type="checkbox" value="<%=DataList(0,i)%>"><input name="e_id" type="hidden" value="<%=DataList(0,i)%>"></td>
<td class="classrow"><%=DataList(1,i)%></td>
<td class="classrow"><%=DataList(4,i)%></td>
<td class="classrow"><INPUT TYPE="text" name="d_price" style="width:50px" value="<%=DataList(2,i)%>" onkeyup="value=value.replace(/[^\d\.]/g,'');" maxlength=10 class="form"></td>
<td class="classrow"><%=DataList(3,i)%>&nbsp;</td>
<td class="classrow" width="10%"><a href="?action=add&id=<%=DataList(0,i)%>"><img src="images/icon_edit.gif" title=" <%=Lang_sys(51)%> " border="0"></a> </td>
</tr>
<%
        Next
End If
%>
<tr>
	<td height="30" class="classfooter" colspan="2"><%=GetPageNum(15,pagenum)%></td>
	<td height="30" class="classfooter" align="right" colspan="4"><%=ors.ShowPageFoot(page)%></td>
</tr>
<tr>
<td colspan="6" class="classfaq">
  <div class="faq_main">
  <p class="faq_title"><%=Lang_sys(49)%></p>
  <%=Lang_Deliver(17)%>
  </div>
</td>
</tr>
</tbody>
</table>
<script>tdshow("classtable");</script>
<%
End Sub

Sub add()
	id = CheckNum(request("id"),0)
	If id <> 0 Then
		set rs=server.CreateObject("adodb.recordset")
		sqlm="select top 1 * from [Lebi_deliver] where id="&id&""
		rs.open sqlm,conn,1,1
	End If
	%>
	<table width="100%" border="0" cellspacing="0" cellpadding="0" class="classtable">
	<form name="form3" method="post" action="?" onSubmit="return CheckForm();">
	<tr>
	<td align="left" colspan="2" class="classhead" height="30">
	 <input name="S1" type="image" src="lang/<%=LangFilePath%>/images/bt_app.gif" value=" <%=Lang_sys(1)%> " align="absmiddle">&nbsp;<input type="image" src="lang/<%=LangFilePath%>/images/bt_res.gif" border="0" title=" <%=Lang_sys(2)%> " onclick="reset();return false;" align="absmiddle">
	 <input type="hidden" name="page" value=<%=page%>>
	 <input type="hidden" name="keyword" value="<%=keyword%>">
	 <input type="hidden" name="lang" value="<%=lang%>">
	 <input type="hidden" name="id" value="<%=id%>">
	 <input type="hidden" name="action" value="add_ok">
	 <a href="edit"></a>
	</td>
	</tr>
	<tr>
	<td height="30" class="classtop" colspan="2"><%
	if id <> 0 Then
			response.write Lang_Deliver(12)
	Else
			response.write Lang_Deliver(11)
	End If
	%></td>
	</tr>
	<tr>
	<td class="classbg" colspan="2">
	<ul id="tablist">
	   <%For LangT = 1 To TotalLang%>
	   <li<%If LangT = 1 Then response.write(" class=""selected""") End If%>><a rel="tcontent<%= LangT %>" style="CURSOR:hand;"><%= LanguageName(LangT) %></a></li>
	   <%Next%>
	</ul>
	<div id="tabcontentcontainer">
	<%For LangT = 1 To TotalLang%>
	   <div id="tcontent<%= LangT %>" class="tabcontent">
	   <table cellspacing="0" cellpadding="4" width="100%" border="0" id="classtable_<%= LangT %>">
		<tr class="classrow">
		<td width="15%" height="30" class="classrow"><%=Lang_Deliver(13)%></td>
		<td class="classrow">
		<input type="text" name="deliver_name<%= LanguageTxt(LangT) %>" class="form" value="<%If id<>0 Then response.write rs("deliver_name" & LanguageTxt(LangT))%>" size="25"> <img src="images/help.gif" align="absmiddle" onmouseover="showhintinfo(this,0,0,'','<%=Lang_Deliver(20)%>','50','up');" onmouseout="hidehintinfo();" /></td>
		</tr>
		<tr class="classrow">
		<td height="30" class="classrow"><%=Lang_Deliver(14)%></td>
		<td class="classrow" rowspan="2">
		<textarea name="deliver_info<%= LanguageTxt(LangT) %>" cols="66" rows="3" class=html><%If id<>0 Then response.write rs("deliver_info" & LanguageTxt(LangT))%></textarea></td>
		</tr>
		</table>
		</div>
		<script>tdshow("classtable_<%= LangT %>");</script>
	<%Next%>
	</div>
	<script>showtabcontent("tablist")</script>
	<ul id="tablistmain">
	   <li class="selected"><a rel=""><%=Lang_sys(66)%></a></li>
	</ul>
	<div id="tabcontentcontainer">
	<table cellspacing="0" cellpadding="4" width="100%" border="0" id="classtable_a">
		<tr class="classrow">
		<td width="15%" height="30" class="classrow"><%=Lang_Deliver(15)%></td>
		<td class="classrow">
		<input type="text" name="deliver_price" class="form" size="10" value="<%If id<>0 Then response.write rs("deliver_price")%>" onkeyup="value=value.replace(/[^\d\.]/g,'');"></td>
		</tr>
		<tr class="classrow">
		<td width="15%" height="30" class="classrow"><%=Lang_Deliver(53)%></td>
		<td class="classrow">
		<input type="text" name="deliver_code" class="form" size="25" value="<%If id<>0 Then response.write rs("deliver_code")%>"> <a href="http://code.google.com/p/kuaidi-api/wiki/Open_API_API_URL?ts=1343800936&updated=Open_API_API_URL" target="_blank"><%=Lang_Deliver(54)%></a></td>
		</tr>
		</table>
		</div>
		<script>tdshow("classtable_a");</script>
	</td>
	</tr>
	<tr>
	<td class="classfooter" height="30" align="left" colspan="2">
	<input name="submit" type="image" src="lang/<%=LangFilePath%>/images/bt_app.gif" value=" <%=Lang_sys(1)%> " align="absmiddle">&nbsp;<input type="image" src="lang/<%=LangFilePath%>/images/bt_res.gif" border="0" title=" <%=Lang_sys(2)%> " onclick="reset();return false;" align="absmiddle">
	</td>
	</tr>
	</form>
	</table>
	<SCRIPT LANGUAGE="JavaScript">
	<!--
	function CheckForm()
	{
		if(form3.deliver_name<%=lang%>.value=="")
		{
			alert("<%=Lang_Deliver(18)%>");
			form3.deliver_name<%=lang%>.focus();
			return false;
		}
		if(form3.deliver_price.value=="")
		{
			alert("<%=Lang_Deliver(19)%>");
			form3.deliver_price.focus();
			return false;
		}
		return true;
	}
	//-->
	</SCRIPT>
	<%
End Sub

Sub api()
	set rs = conn.execute("select top 1 sys_kuaidi100 from [Lebi_system]")
	%>
	<table width="100%" border="0" cellspacing="0" cellpadding="0" class="classtable" id="config">
	<form name="form3" method="post" action="?" onSubmit="return CheckForm();">
	<tr>
	<td align="left" colspan="2" class="classhead" height="30">
	 <input name="S1" type="image" src="lang/<%=LangFilePath%>/images/bt_app.gif" value=" <%=Lang_sys(1)%> " align="absmiddle">&nbsp;<input type="image" src="lang/<%=LangFilePath%>/images/bt_res.gif" border="0" title=" <%=Lang_sys(2)%> " onclick="reset();return false;" align="absmiddle">
	 <input type="hidden" name="action" value="api_ok">
	 <a href="edit"></a>
	</td>
	</tr>
	<tr>
	<td height="30" class="classtop" colspan="2"><%=Lang_Deliver(56)%></td>
	</tr>
	<tr class="classrow">
		<td width="15%" height="30" class="classrow"><%=Lang_Deliver(57)%></td>
		<td class="classrow">
		<input type="radio" value="0" <%=judge(Split(rs(0),"|")(0),"0")%> name="api_state"> <%=Lang_Deliver(58)%>
		<input type="radio" value="1" <%=judge(Split(rs(0),"|")(0),"1")%> name="api_state"> <%=Lang_Deliver(59)%></td>
	</tr>
	<tr class="classrow">
		<td width="15%" height="30" class="classrow"><%=Lang_Deliver(60)%></td>
		<td class="classrow">
		<input type="text" name="api_key" class="form" size="25" value="<%=Split(rs(0),"|")(1)%>"> <a href="http://www.kuaidi100.com/openapi/api_4_02.shtml" target="_blank"><%=Lang_Deliver(61)%></a></td>
	</tr>
	<tr>
	<td class="classfooter" height="30" align="left" colspan="2">
	<input name="submit" type="image" src="lang/<%=LangFilePath%>/images/bt_app.gif" value=" <%=Lang_sys(1)%> " align="absmiddle">&nbsp;<input type="image" src="lang/<%=LangFilePath%>/images/bt_res.gif" border="0" title=" <%=Lang_sys(2)%> " onclick="reset();return false;" align="absmiddle">
	</td>
	</tr>
	</form>
	</table>
	<script>tdshow("config");</script>
	<%
End Sub
%>