<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
Dim NCheck:NCheck=true
%>
<!--#include file="cgi/Config.asp"-->
<%
set j=server.CreateObject("johnnyJia.johnnyJia2")
Dim rs
Dim eStr:eStr=""
Dim act
act=request("act")

select case act
	case "del"
	gid=request("gid")
	if mobj.testreg(gid,"^\d{1,10}$") then
	mobj.cexe "update  b2conline_goods set g_is_delete=1 where g_id="&gid
	end if

end select


Dim page:page=request("page")
Dim word:word=mobj.CheckBadstr(request("word"))
Dim qudao:qudao=request("qudao")
if not mobj.testreg(qudao,"^(\w|-){36}$") then qudao=""
If not mobj.testreg(page,"^\d{1,10}$") Then page=1
Dim dinggouma:dinggouma=request("dinggouma")
If not mobj.testreg(dinggouma,"^\d{1,3}$") Then dinggouma=0
dinggouma=cint(dinggouma)
page=abs(cint(page))
if page=0 then page=1
Dim pages:pages=7
DIm pageSql:pageSql="select count(0) as rcount from  b2c_order_info   "
listSqlFilter=" b2c_goods.g_guid= b2c_order_info.p_id and b2c_order_info.p_qid = b2c_goods.g_qudao and b2c_qudao.q_sn=b2c_goods.g_qudao "

if word<>"" then listSqlFilter=listSqlFilter&" and (b2c_order_info.consignee like '%"&word&"%' or b2c_order_info.mobile like '%"&word&"%')"
if qudao<>"" then listSqlFilter=listSqlFilter&" and b2c_qudao.q_sn='"&qudao&"' "
Dim allcounts


Dim order_status,shipping_status,pay_status,order_id,isdel
order_status=request("order_status")
shipping_status=request("shipping_status")
pay_status=request("pay_status")
order_id=request("order_id")
isdel=request("isdel")
if not mobj.testreg(order_status,"^\d{1,2}$") then order_status=""
if not mobj.testreg(shipping_status,"^\d{1,2}$") then shipping_status=""
if not mobj.testreg(pay_status,"^\d{1,2}$") then pay_status=""
if not mobj.testreg(order_id,"^\d{1,12}$") then order_id=""
if not mobj.testreg(isdel,"^[1]$") then isdel=""

if order_status<>"" then listSqlFilter=listSqlFilter&" and b2c_order_info.isdel=0 and b2c_order_info.order_status="&order_status
if shipping_status<>"" then listSqlFilter=listSqlFilter&" and b2c_order_info.shipping_status="&shipping_status
if pay_status<>"" then listSqlFilter=listSqlFilter&" and b2c_order_info.pay_status="&pay_status
if order_id<>"" then listSqlFilter=listSqlFilter&" and b2c_order_info.order_id="&order_id
if isdel<>"" then 
	listSqlFilter=listSqlFilter&" and b2c_order_info.isdel=1"
else
	listSqlFilter=listSqlFilter&" and b2c_order_info.isdel=0"
end if
if dinggouma>0 then listSqlFilter=listSqlFilter&" and b2c_order_info.dinggouma="&dinggouma
qstime=request("qstime")
qetime=request("qetime")
if not isdate(qstime) then qstime=""
if not isdate(qetime) then qetime=""
if qstime<>"" then listSqlFilter=listSqlFilter&" and b2c_order_info.add_time>='"&qstime&" 00:00:00' "
if qetime<>"" then listSqlFilter=listSqlFilter&" and b2c_order_info.add_time<='"&qetime&" 23:59:59' "



pStr="admin_order_list.asp?page=$page$&qstime="&qstime&"&qetime="&qetime&"&word="&server.URLEncode(word)&"&order_status="&order_status&"&shipping_status="&shipping_status&"&pay_status="&pay_status&"&isdel="&isdel&"&qudao="&qudao&"&dinggouma="&dinggouma
 listSql="select b2c_order_info.order_id,b2c_order_info.order_status,b2c_order_info.shipping_status,b2c_order_info.pay_status,b2c_order_info.consignee,b2c_order_info.address,b2c_order_info.zipcode,b2c_order_info.tel,b2c_order_info.mobile,b2c_order_info.goods_amount,b2c_order_info.add_time,b2c_order_info.p_count,b2c_order_info.userip,b2c_order_info.lailu,b2c_order_info.dinggouma,b2c_order_info.isdel,b2c_order_info.deltype,b2c_goods.g_id,b2c_goods.g_name,b2c_qudao.q_name from b2c_order_info,b2c_goods,b2c_qudao where  "&listSqlFilter&" order by b2c_order_info.order_id desc"

Dim G_Sql:G_Sql="EXEC	[dbo].[Johnny_Pagination]  @Tables = N'b2c_order_info,b2c_goods,b2c_qudao', @PrimaryKey = N'b2c_order_info.order_guid',@CurrentPage = 1,@PageSize =3,@Filter=N'b2c_goods.g_guid= b2c_order_info.p_id and b2c_order_info.p_qid = b2c_goods.g_qudao and b2c_qudao.q_sn=b2c_goods.g_qudao',@Fields = N'b2c_order_info.order_id,b2c_order_info.order_status,b2c_order_info.shipping_status,b2c_order_info.pay_status,b2c_order_info.consignee,b2c_order_info.address,b2c_order_info.zipcode,b2c_order_info.tel,b2c_order_info.mobile,b2c_order_info.goods_amount,b2c_order_info.add_time,b2c_order_info.p_count,b2c_order_info.userip,b2c_order_info.lailu,b2c_order_info.dinggouma,b2c_goods.g_id,b2c_goods.g_name,b2c_qudao.q_name ',@Sort =N'b2c_order_info.add_time desc'"
'response.Write listSql
'response.End()
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
<title>管理页面</title>
<meta http-equiv="Expires" Content="0"/>
<meta http-equiv="Cache-Control" Content="no-cache"/>
<meta http-equiv="Pragma" Content="no-cache"/>
<link href="/images/skin_1/style.css" type="text/css" rel="stylesheet"/>
<script language=javascript type="text/javascript" src="/calendar/calendar.js"></script>
<script language=javascript type="text/javascript" src="/js/jquery-1.7.1.min.js"></script>
<link rel="stylesheet" type="text/css" href="easyui/themes/default/easyui.css">  
<link rel="stylesheet" type="text/css" href="easyui/themes/icon.css">  
<script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>
<script language=javascript type="text/javascript" src="/js/comm.js"></script>

<script language="javascript">
function cleardate(){
	  $("#qstime").val("");
	  $("#qetime").val("");
		
}

function uiMessg(s){
	$.messager.show({showType:"slide",msg:s,timeout:3000,title:"操作完成提示"});
}
</script>
<style type="text/css">
.pageSelect{
	padding:3px;
	font-size:13px;
	border: 1px solid #999;
}
</style>
<base target="_self"/>
</head>
<body class="htmlbody">

<table class="table1" cellspacing="1" cellpadding="3" align="center" border="0">
	<tr>
		<td class="tableline linetitle" width="200" align="left">订单管理</td>
		<td class="tableline" width="*" align="right"><a href="admin_order_index.asp">订单首页</a>
			 - <a href="admin_order_list.asp?order_status=0">最新订单</a>
			 - <a href="admin_order_list.asp">全部订单</a>
			 - <a href="admin_order_list.asp?order_status=1&shipping_status=0">等待发货</a>
			 - <a href="admin_order_list.asp?order_status=1&shipping_status=1">已发货</a>
			 - <a href="admin_order_list.asp?order_status=1&pay_status=2">成功订单</a>
			
		</td>
	</tr>
</table>

<table id="tablehovered" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder"><tr>
	<td class="tablerow1" colspan="8"><form name="search_form" id="search_form" method="get" action="admin_order_list.asp">
		
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
		  <tr>
		    <td width="60">关键词:</td>
		    <td width="130"><input name="word" type="text" class="alingmid" id="searchwordbox" style="width:120px;" value="<%=word%>"  /></td>
		    <td width="130"><select name="qudao" class="alingmid">
			<option value="" >所有产品渠道</option>
            <%
			mobj.crs rs
			rs.open "select q_sn,q_name from b2c_qudao",dstr,1,1
			do while not rs.eof
			%>
            <option value="<%=rs("q_sn")%>" <%if qudao=rs("q_sn") then response.Write("selected='selected'")%>><%=rs("q_name")%></option>
            <%
			rs.movenext
			loop
			mobj.drs rs
			%>
			
		</select></td>
		    <td width="60">订购码:</td>
		    <td width="80"><label>
		      <input name="dinggouma" type="text" id="dinggouma" style="width:60px;" value="<%=dinggouma%>" />
	        </label></td>
		    <td width="70">开始日期:</td>
		    <td width="90"><input type=text value="<%=qstime%>" id="qstime" AutoComplete="off"  name=qstime onclick="event.cancelBubble=true;javascript:showCalendar('qstime',true,'qstime','','','','','','','','text','Price');"  style="width:80px;"></td>
		    <td width="70">结束日期:</td>
		    <td width="150"><input type=text value="<%=qetime%>" name=qetime id="qetime" AutoComplete="off" onclick="event.cancelBubble=true; javascript:showCalendar('qetime',true,'qetime','','','','','','','','text','Price');"  style="width:80px;">(<a href="javascript:cleardate();">清空日期</a>)</td>
		    <td align="left"><input type="submit" value="开始搜索" name="search_submit" class="button alingmid" /></td>
	      </tr>
		  </table>
	</form>
	</td>
</tr>
<tr>
  <th width="4%" noWrap="noWrap">序号</th>
	<th width="9%" noWrap="noWrap">订单编号</th>
	<th width="21%">媒体/渠道/产品(数量)</th>
	<th width="16%" noWrap="noWrap">收货人</th>
    <th width="7%" noWrap="noWrap">总金额</th>
	<th width="15%" noWrap="noWrap">订单状态</th>
	<th width="12%" noWrap="noWrap">下单时间/IP</th>
	<th width="16%" noWrap="noWrap">操作</th>
	
  </tr>
<style>
.tablerow2{ color:#000000; background-color:#ffffff;}</style>
<form name="selform" method="post" action="admin_setting.asp?ChannelID=1">
<input type="hidden" name="action" value="batch">
<%

Dim kkk:kkk=1
Dim lindex:lindex=1
mobj.crs rs
rs.open listSql,dStr,1,1
							If rs.eof and rs.bof Then
								rs.close
								set rs=nothing							
								allPages=1
								allcounts=0
							else
								allcounts=rs.recordcount
								allPages=fix(allcounts/pages)
								If (allcounts mod pages >0) and allcounts>pages then allPages=allPages+1
								If allPages=0 then allPages=1
								rs.pagesize=pages
								rs.absolutepage=page
								do while not rs.eof  and  pages>0

%>
<tr align="center" id="list<%=rs("order_id")%>">
<td class="tablerow<%=kkk%> hovered" noWrap="noWrap"><%=lindex%></td>
	<td class="tablerow<%=kkk%> hovered"><%=rs("order_id")%></td>
	<td class="tablerow<%=kkk%> hovered" align="left"><font style="color:#090"><%=rs("lailu")%> - (订购码:<%=rs("dinggouma")%>)</font><br /><span style="color:#0000ff;"><%=rs("q_name")%></span><br /> <%=rs("g_name")%> - （数量:<%=rs("p_count")%>）
	
	</td>
	<td align="left"  class="tablerow<%=kkk%> hovered"><%=rs("consignee")%><br /><%if rs("mobile")<>"" then response.Write("手机："&rs("mobile"))%><%if rs("tel")<>"" then response.Write("<br />电话："&rs("tel"))%></td>
	<td class="tablerow<%=kkk%> hovered" >￥:<%=rs("goods_amount")%></td>
	<td class="tablerow<%=kkk%> hovered"  title=""><%
	if rs("isdel")=1 then
		response.Write("取消<br />") 
		response.Write(xmlobj.GetTxt(server.MapPath("/xml/calcel.xml"),rs("deltype")))
	else
	
	
	select case rs("order_status")
		case 0
			response.Write("<font color='#FF0000'>新订单</font>")
		case 1
			response.Write("<font color='#0600FF'>已确认</font>")
		case 2
			response.Write("<font color='#666666'>已取消</font>")
		case 3
			response.Write("<font>已取消</font>")
		case 4
			response.Write("<font color='#FFEA00'>已退货</font>")
		case else
		
	end select
	%><br /><%
	
	select case rs("shipping_status")
		case 0
			response.Write("<font color='#FF0000'>未发货</font>")
		case 1
			response.Write("<font color='#0600FF'>已发货</font>")
		case 2
			response.Write("<font color='#666666'>已收货</font>")
		case 3
			response.Write("<font color='FFEA00'>配货中</font>")
		
		case else
		
	end select
	%><br /><%
	
	select case rs("pay_status")
		case 0
			response.Write("<font color='#FF0000'>未结款</font>")
		case 1
			response.Write("<font color='#0600FF'>部分付款</font>")
		case 2
			response.Write("<font color='#0EBF05'>已结款</font>")
		
		
		case else
		
	end select
	
	end if%></td>
	<td class="tablerow<%=kkk%> hovered" noWrap="noWrap"><%=rs("add_time")%><br /><%=rs("userip")%></td>
	<td class="tablerow<%=kkk%> hovered" noWrap="noWrap"><a href="javascript:showorder(<%=rs("order_id")%>);">查看订单</a><br />	  
	  <a href="javascript:deleteorder(<%=rs("order_id")%>);">取消订单</a></td>
	
	</tr>
<%
lindex=lindex+1
if kkk=2 then kkk=0	
kkk=kkk+1
pages=pages-1
rs.movenext
loop
mobj.drs rs
end if%>
<tr>
	<td class="tablerow1" colspan="8">&nbsp;</td>
</tr>
</form>
<tr>
	<td class="tablerow2" align="right" colspan="8" id="NextPageText"><div style="float:left;"></div>
	<var class="morePage"><b>总数：<%=allcounts%></b><b><%=allPages%></b><code><a href="<%=replace(pStr,"$page$","1")%>"> <  首页</a><%=mObj.PageListActive(page,allPages,pStr)%><a href="<%=replace(pStr,"$page$",allPages)%>">末页  > </a></code></var></td>
</tr>
</table>
<div id="act_dialog" style="width:450px; height:150px; background-color:#FFF; display:none;">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="50%" height="110" align="center" valign="middle"><input name="orderid" id="orderid" type="hidden" value="" /><label>
        <select name="select" id="cancelType" class="pageSelect">
          <option value="1">虚假订单</option>
          <option value="7">重复订单</option>
          <option value="2">客户要求取消</option>
          <option value="3">暂时缺货</option>
          <option value="4">快递无法达到</option>
          <option value="5">其他原因</option>
          <option value="6">测试订单</option>
        </select>
      </label></td>
      <td align="left" valign="middle"><a id="cancelButton" class="easyui-linkbutton" href="javascript:void(0)">确定取消该订单</a></td>
    </tr>
  </table>
</div>
<div id="order_detail" style="width:1000px; height:580px; display:none;">

</div>
<script type="text/javascript">
var orderid=0;
function showorder(id){
	orderid=id;
	$("#order_detail").show();
	$('#order_detail').window({  
		width:1000,  
		height:580,
		top:80,
		
		title: '订单编号:'+id,
		modal:true,
		closable:true,
		shadow:false,
		collapsible:false,
		minimizable:false,
		maximizable:false,
		
		href:'admin_order_view_ajax.asp?id='+id,  
		onLoad:function(){  
			//alert(document.body.scrollTop);
			
           // return { 'x': x, 'y': y };
		},
		onClose:function(){$("#order_detail").hide();}
	});   
}


function deleteorder(id){
	orderid=id;
	$("#act_dialog").show();
	$("#orderid").val(id);
		$( "#act_dialog" ).dialog({
		border:true,
		noheader:false,
		modal:true,
		closable:true,
		title:"订单编号："+orderid+",请选择取消原因",
		onClose:function(){$( "#act_dialog" ).hide();},
		shadow:false
		
		
	});
	
	
	
	

}

$(function(){  
	$('#cancelButton').bind('click', function(){  
		//s
		
		$.getJSON("act.asp?act=delorder&id="+orderid+"&c="+$("#cancelType").val(),function(json){		
			if(json.s==1){
				
				$("#list"+orderid).remove();
				
				$( "#act_dialog" ).dialog("close");
				$('#order_detail').window("close");
				uiMessg("此订单已经成功取消!");
				
				}
			else{alert(json.m);}
		});		
	
		//e
	}); 
	
	
});  
function saveNote(){
	if($("#guanliyuanbeizhu").val()==""){alert("请输入内容");$("#guanliyuanbeizhu").focus();return;}
	//s
		
		$.getJSON("act.asp?act=savenote&id="+orderid+"&s="+escape($("#guanliyuanbeizhu").val()),function(json){		
			if(json.s==1){			
				
				uiMessg("备注成功保存!");
				
				}
			else{alert(json.m);}
		});		
	
		//e	
}
</script>
<!--#include file="end.asp"-->
</body></html>
