<!--#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_invoice.asp
'* 最后更新 2012-06-28 by 56770.kingdge
'*****************************************
Dim admin_flag
admin_flag=",1.9,"
include "lang/"& LangFilePath &"/lang_sys.inc"
include "lang/"& LangFilePath &"/lang_menu.inc"
include "lang/"& LangFilePath &"/lang_invoice.inc"
CurrentId = 2
CurrentUrl = "admin_invoice.asp"
LB_Head()
LB_Menu()
action = request("action")
%>
<div class="tabmenu mainwidth">
      <ul>
        <li <%If action <> "add" Then Response.Write("class=""current""") End If%>><a href="admin_invoice.asp"><span><%=Lang_Menu(101)%></span></a></li>
        <li <%If action = "add" Then Response.Write("class=""current""") End If%>><a href="?action=add"><span><%=Lang_Invoice(16)%></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 request("action")
			   Case "del" : del()
			   Case "add" : add()
			   Case "add_ok" : add_ok()
			   Case "edit" : edit()
			   Case "edit_ok" : edit_ok()
			   Case Else
					main()
		End Select
End If
Response.Write("</div>")
Response.Write("</div>")
LB_Footer()

Sub del()
        If OnlyRead = 1 Then OnlyReadMessage()
		id=safereplace(request("id"))
		if 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_Invoice] where i_id in("&id&")")
		ManageLog Lang_Invoice(1) &" ["&id&"]"
		m_u = "?page="& request("page") &"&pagenum="& request("pagenum") &"&state="& request("state") &"&keyword="& request("keyword") &"&DateFrom="& request("DateFrom") &"&DateTo="& request("DateTo")
		Call Up_mes(Lang_sys(43),"·"& Lang_sys(42),0,m_u,0,0,2,1)
End Sub

Sub add_ok()
		If OnlyRead = 1 Then OnlyReadMessage()
		order_number = safereplace(request("order_number"))
		fapiao_money = CheckNum(request("fapiao_money"),0)
		fapiao_company = safereplace(request("fapiao_company"))
		fapiao_adds = safereplace(request("fapiao_adds"))
		fapiao_zip = safereplace(request("fapiao_zip"))
		user_id = safereplace(request("user_id"))
		user_name = safereplace(request("user_name"))
		i_state = CheckNum(request("i_state"),0)
		Set rs = server.createobject("adodb.recordset")
		rs.open "select user_id,from_name from [Lebi_Orders] where order_number = '"& order_number &"'",conn,1,3
		If Not rs.eof Then
				If user_id = "" Then user_id = rs(0)
				If user_name = "" Then user_name = rs(1)
		End If
		rs.close : Set rs = Nothing
		Set rs = server.createobject("adodb.recordset")
		rs.open "select * from [Lebi_Invoice] where i_order_number = '"& order_number &"' And i_order_number <> '000000000000'",conn,1,3
		If Not rs.eof Then
				Call Up_mes(Lang_sys(46),"·"& Lang_Invoice(2),0,"javascript:history.back();",0,0,2,0)
		Else
				rs.addnew
				rs("i_company") = fapiao_company
				rs("i_adds") = fapiao_adds
				rs("i_zip") = fapiao_zip
				rs("i_user_id") = user_id
				rs("i_user_name") = user_name
				rs("i_money") = fapiao_money
				rs("i_order_number") = order_number
				rs("i_date") = Date()
				rs("i_state") = i_state
				rs.update
		End If
		rs.close : Set rs = Nothing
		ManageLog Lang_Invoice(3) &" ["& order_number &"]"
		Call Up_mes(Lang_sys(45),"·"& Lang_sys(44),0,"?",0,0,2,1)
End Sub


Sub edit_ok()
        If OnlyRead = 1 Then OnlyReadMessage()
		id = CheckNum(request("id"),0)
		order_number = safereplace(request("order_number"))
		fapiao_money = CheckNum(request("fapiao_money"),0)
		fapiao_company = safereplace(request("fapiao_company"))
		fapiao_adds = safereplace(request("fapiao_adds"))
		fapiao_zip = safereplace(request("fapiao_zip"))
		user_id = safereplace(request("user_id"))
		user_name = safereplace(request("user_name"))
		i_state = CheckNum(request("i_state"),0)
		Set rs = server.createobject("adodb.recordset")
		rs.open "select user_id,from_name from [Lebi_Orders] where order_number = '"& order_number &"'",conn,1,3
		If Not rs.eof Then
				If user_id = "" Then user_id = rs(0)
				If user_name = "" Then user_name = rs(1)
		End If
		rs.close : Set rs = Nothing
		Set rs = server.createobject("adodb.recordset")
		rs.open "select * from [Lebi_Invoice] where i_id = "& id &"",conn,1,3
		If Not rs.eof Then
				rs("i_company") = fapiao_company
				rs("i_adds") = fapiao_adds
				rs("i_zip") = fapiao_zip
				rs("i_user_id") = user_id
				rs("i_user_name") = user_name
				rs("i_money") = fapiao_money
				rs("i_order_number") = order_number
				rs("i_date") = Date()
				rs("i_state") = i_state
				rs.update
		End If
		rs.close : Set rs = Nothing
		ManageLog Lang_Invoice(4) &" ["& order_number &"]"
		Call Up_mes(Lang_sys(48),"·"& Lang_sys(47),0,"?",0,0,2,1)
End Sub

Sub main()
		state = safeReplace(request("state"))
		datefrom = safeReplace(request("datefrom"))
		dateto = safeReplace(request("dateto"))
		keyword = safeReplace(request("keyword"))
		page = checknum(request("page"),1)
		pagenum = CheckNum(request("pagenum"),15)
		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="i_id"
		.Field="i_id,i_order_number,i_user_id,i_user_name,i_company,i_money,i_state,i_date"
		.Table="[Lebi_Invoice]"
		sql = "1=1"
		if keyword<>"" then sql=sql&" and (i_company like '%"&keyword&"%' or i_adds like '%"&keyword&"%' or i_order_number like '%"&keyword&"%' or i_user_name like '%"&keyword&"%' or i_user_id like '%"&keyword&"%')"
		If state<>"" Then sql=sql&" and i_state="& CLng(state)
		If IsSqlDataBase = 1 And datefrom<>"" And dateto<>"" Then sql=sql + " and DateDiff(d,i_date,'"& datefrom &"')<=0 and DateDiff(d,i_date,'"& dateto &"')>=0"
		If IsSqlDataBase = 0 And datefrom<>"" And dateto<>"" Then sql=sql + " and DateDiff('d',i_date,'"& datefrom &"')<=0 and DateDiff('d',i_date,'"& dateto &"')>=0"
		.Condition=sql
		.OrderBy="i_id desc"
		End With
		DataCount=ors.RecCount()
		DataList=ors.ResultSet()
%>
<script language="javascript" src="inc/js/MyCalendar.js"></script>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="classtable-top">
<tbody>
<tr>
<form name="Lebi" method="get" action="?">
<td height="30" align="left" class="classhead">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
	<select name="state">
	<option value="">┌ <%=Lang_Invoice(5)%></option>
	<option value="0"<%If state = "0" Then response.write(" selected") End If%>>├ <%=Lang_Invoice(6)%></option>
	<option value="1"<%If state = "1" Then response.write(" selected") End If%>>├ <%=Lang_Invoice(7)%></option>
	</select>
</td>
<td style="padding-left:5px;"><input type="text" name="dateFrom" value="<%=dateFrom%>" size="12" class="form_calendar" onclick="setday(this)" /> - <input type="text" name="dateTo" value="<%=dateTo%>" size="12" class="form_calendar" onclick="setday(this)" />
</td>
<td style="padding-left:5px;"><input name="keyword" type="text" title="<%=Lang_Invoice(8)%>" 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_Ship.asp|"& Lang_Menu(100) &"","")%>
</td>
</tr>
</tbody>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="classtable" class="classtable2">
<tbody>
<form name="Lebi" method="post" action="?">
<tr>
<td height="30" class="classhead" align="left" colspan="2">
<input type="image" name="Submit" title=" <%=Lang_sys(15)%> " onClick="return confirm('<%=Lang_sys(64)%>')" src="lang/<%=LangFilePath%>/images/bt_delete.gif" align="absmiddle">
<input type="hidden" name="action" value="del">
<input type="hidden" name="page" value="<%=page%>">
<input type="hidden" name="state" value="<%=state%>">
<input type="hidden" name="keyword" value="<%=keyword%>">
<input type="hidden" name="dateFrom" value="<%=dateFrom%>">
<input type="hidden" name="dateTo" value="<%=dateTo%>">
<input type="hidden" name="pagenum" value="<%= pagenum %>">
</td>
<td height="30" class="classhead" align="right" colspan="7"><%=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_Invoice(9)%></td>
     <td width="10%" class="classtop"><%=Lang_Invoice(10)%></td>
	 <td width="10%" class="classtop"><%=Lang_Invoice(11)%></td>
     <td width="25%" class="classtop"><%=Lang_Invoice(12)%></td>
	 <td width="10%" class="classtop"><%=Lang_Invoice(13)%></td>
	 <td width="10%" class="classtop"><%=Lang_Invoice(5)%></td>
	 <td width="10%" class="classtop"><%=Lang_Invoice(14)%></td>
     <td width="10%" class="classtop"><%=Lang_Invoice(15)%></td>
  </tr>
<%
If DataCount >0 Then
		For i = 0 To Ubound(DataList,2)
%>
  <tr class="classrow">
	<td height="30" class="classrow"><input type="checkbox" name="id" value="<%=DataList(0,i)%>"></td>
    <td class="classrow"><a href="?action=edit&id=<%=DataList(0,i)%>"><%=DataList(1,i)%></a></td>
    <td class="classrow"><%=DataList(2,i)%>&nbsp;</td>
	<td class="classrow"><%=DataList(3,i)%>&nbsp;</td>
	<td class="classrow"><%=DataList(4,i)%>&nbsp;</td>
    <td class="classrow"><%=DataList(5,i)%></td>
	<td class="classrow"><%
	Select Case DataList(6,i)
		   Case "1" response.write "<FONT COLOR=red>"& Lang_Invoice(7) &"</FONT>"
		   Case "0" response.write Lang_Invoice(6)
	End Select %></td>
	<td class="classrow"><%=DataList(7,i)%></td>
	<td class="classrow"><a href="?action=edit&id=<%=DataList(0,i)%>"><img src="images/icon_edit.gif" title="<%=Lang_sys(51)%>" border="0"></a></td>
  </tr>
<%
        Next
End If
%>
</form>
<tr>
	<td height="30" class="classfooter" colspan="2"><%=GetPageNum(15,pagenum)%></td>
	<td height="30" class="classfooter" align="right" colspan="7"><%=ors.ShowPageFoot(page)%></td>
</tr>
</tbody>
</table>
<script>tdshow("classtable");</script>
<%
End Sub

sub add()
id = CheckNum(request("id"),0)
Set rs = conn.execute("select order_number,fapiao_company,fapiao_adds,fapiao_zip,from_name,user_id,dis_sum,fei,packing_price,fapiao_money from [lebi_Orders] where id = "& id &"")
If Not rs.eof Then
		order_number = rs(0)
		fapiao_money = Replace(FormatNumber(rs(6) + rs(7) + rs(8) + rs(9),2),",","")
		fapiao_company = rs(1)
		fapiao_adds = rs(2)
		fapiao_zip = rs(3)
		user_name = rs(4)
		user_id = rs(5)
End If
rs.close : Set rs = Nothing
%>
<script language="javascript">
var Lang_Invoice = "<%=Lang_Invoice(28)%>$<%=Lang_Invoice(29)%>$<%=Lang_Invoice(30)%>$<%=Lang_Invoice(31)%>$<%=Lang_Invoice(32)%>";
</script>
<script language="JavaScript" type="text/JavaScript" src="inc/js/invoice.js"></script>
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="classtable" class="classtable">
<form name="add" method="post" action="?" onSubmit="return CheckForm(this);">
<tr>
	<td height="30" align="left" class="classhead"><input name="submit" type="image" src="lang/<%=LangFilePath%>/images/bt_app.gif" value=" <%=Lang_sys(1)%> " title=" <%=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="add_ok"></td>
	<td class="classhead" align="right">
	<%=QuickMenu("","")%>
	</td>
 </tr>
<tr>
    <td class="classtop" height="30" colspan="2"><%=Lang_Invoice(16)%></td>
</tr>
<tr class="classrow">
	<td width="15%" height="30" class="classrow"><%=Lang_Invoice(17)%></td>
	<td width="85%" class="classrow"><input type="text" name="order_number" id="order_number" value="<%= order_number %>" size="40" class="form"> <span id="mes_order_number"><%=Lang_Invoice(25)%></span></td>
</tr>
<tr class="classrow">
	<td height="30" class="classrow"><%=Lang_Invoice(18)%></td>
	<td class="classrow"><input type="text" name="fapiao_money" id="fapiao_money" value="<%= fapiao_money %>" size="10" class="form"> <span id="mes_fapiao_money"><%=Lang_Invoice(26)%></span></td>
</tr>
<tr class="classrow">
	<td height="30" class="classrow"><%=Lang_Invoice(19)%></td>
	<td class="classrow"><input type="text" name="fapiao_company" id="fapiao_company" value="<%= fapiao_company %>" size="40" class="form"> <span id="mes_fapiao_company"><%=Lang_Invoice(26)%></span></td>
</tr>
<tr class="classrow">
	<td height="30" class="classrow"><%=Lang_Invoice(20)%></td>
	<td class="classrow"><input type="text" name="fapiao_adds" id="fapiao_adds" value="<%= fapiao_adds %>" size="40" class="form"> <span id="mes_fapiao_adds"><%=Lang_Invoice(26)%></span></td>
</tr>
<tr class="classrow">
	<td height="30" class="classrow"><%=Lang_Invoice(21)%></td>
	<td class="classrow"><input type="text" name="fapiao_zip" value="<%= fapiao_zip %>" size="10" class="form"> </td>
</tr>
<tr class="classrow">
	<td height="30" class="classrow"><%=Lang_Invoice(22)%></td>
	<td class="classrow"><input type="text" name="user_name" value="<%= user_name %>" size="40" class="form"> </td>
</tr>
<tr class="classrow">
	<td height="30" class="classrow"><%=Lang_Invoice(23)%></td>
	<td class="classrow"><input type="text" name="user_id" value="<%= user_id %>" size="40" class="form"> </td>
</tr>
<tr class="classrow">
	<td height="30" class="classrow"><%=Lang_Invoice(24)%></td>
	<td class="classrow"><input type="radio" name="i_state" value="0"><%=Lang_Invoice(6)%> <input type="radio" name="i_state" value="1" checked><%=Lang_Invoice(7)%></td>
</tr>
<tr class="classfooter">
  <td colspan="2" height="30" align="left" class="classrow"><input name="submit" type="image" src="lang/<%=LangFilePath%>/images/bt_app.gif" value=" <%=Lang_sys(1)%> " title=" <%=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("classtable");</script>
<%
end Sub

sub edit()
id = checknum(request("id"),0)
Set rs = conn.execute("select * from [lebi_Invoice] where i_id = "& id &"")
If Not rs.eof Then
%>
<script language="javascript">
var Lang_Invoice = "<%=Lang_Invoice(28)%>$<%=Lang_Invoice(29)%>$<%=Lang_Invoice(30)%>$<%=Lang_Invoice(31)%>$<%=Lang_Invoice(32)%>";
</script>
<script language="JavaScript" type="text/JavaScript" src="inc/js/invoice.js"></script>
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="classtable" class="classtable">
<form name="add" method="post" action="?" onSubmit="return CheckForm(this);">
<tr>
	<td height="30" align="left" class="classrow"><input name="submit" type="image" src="lang/<%=LangFilePath%>/images/bt_app.gif" value=" <%=Lang_sys(1)%> " title=" <%=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="id" value="<%= id %>"><input type="hidden" name="action" value="edit_ok"></td>
	<td class="classrow" align="right">
	<%=QuickMenu("","")%>
	</td>
 </tr>
<tr>
    <td class="classtop" height="30" colspan="2"><%=Lang_Invoice(27)%></td>
</tr>
<tr class="classrow">
	<td width="15%" height="30" class="classrow"><%=Lang_Invoice(17)%></td>
	<td width="85%" class="classrow"><input type="text" name="order_number" id="order_number" value="<%= rs("i_order_number") %>" size="40" class="form"> <span id="mes_order_number"><%=Lang_Invoice(25)%></span></td>
</tr>
<tr class="classrow">
	<td height="30" class="classrow"><%=Lang_Invoice(18)%></td>
	<td class="classrow"><input type="text" name="fapiao_money" id="fapiao_money" value="<%= rs("i_money") %>" size="10" class="form"> <span id="mes_fapiao_money"><%=Lang_Invoice(26)%></span></td>
</tr>
<tr class="classrow">
	<td height="30" class="classrow"><%=Lang_Invoice(19)%></td>
	<td class="classrow"><input type="text" name="fapiao_company" id="fapiao_company" value="<%= rs("i_company") %>" size="40" class="form"> <span id="mes_fapiao_company"><%=Lang_Invoice(26)%></span></td>
</tr>
<tr class="classrow">
	<td height="30" class="classrow"><%=Lang_Invoice(20)%></td>
	<td class="classrow"><input type="text" name="fapiao_adds" id="fapiao_adds" value="<%= rs("i_adds") %>" size="40" class="form"> <span id="mes_fapiao_adds"><%=Lang_Invoice(26)%></span></td>
</tr>
<tr class="classrow">
	<td height="30" class="classrow"><%=Lang_Invoice(21)%></td>
	<td class="classrow"><input type="text" name="fapiao_zip" value="<%= rs("i_zip") %>" size="10" class="form"> </td>
</tr>
<tr class="classrow">
	<td height="30" class="classrow"><%=Lang_Invoice(22)%></td>
	<td class="classrow"><input type="text" name="user_name" value="<%= rs("i_user_name") %>" size="40" class="form"> </td>
</tr>
<tr class="classrow">
	<td height="30" class="classrow"><%=Lang_Invoice(23)%></td>
	<td class="classrow"><input type="text" name="user_id" size="40" value="<%= rs("i_user_id") %>" class="form"> </td>
</tr>
<tr class="classrow">
	<td height="30" class="classrow"><%=Lang_Invoice(24)%></td>
	<td class="classrow"><input type="radio" name="i_state" value="0" <%=judge(rs("i_state"),0)%>><%=Lang_Invoice(6)%> <input type="radio" name="i_state" value="1" <%=judge(rs("i_state"),1)%>><%=Lang_Invoice(7)%></td>
</tr>
<tr class="classfooter">
  <td colspan="2" height="30" align="left" class="classrow"><input name="submit" type="image" src="lang/<%=LangFilePath%>/images/bt_app.gif" value=" <%=Lang_sys(1)%> " title=" <%=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("classtable");</script>
<%
End If
rs.close : Set rs = Nothing
end Sub
%>