<%@page contentType="text/html; charset=UTF-8"%>
<%@include file="/inc/init.jsp"%>
<%@include file="/inc/checklogin.jsp"%>
<%
	GetPageCommon gc=new GetPageCommon();
	int orderid=pu.getInt("orderid");
	String kdid = pu.getString("kdid");
	String kd_type = pu.getString("kd_type","ems");
	if(StringUtil.isFine(kdid)){
	GetPage gp=new GetPage();
	Random rd = new Random();
	String url = "http://www.kuaidi100.com/query?type="+kd_type+"&postid="
			+ kdid + "&id=1&valicode=&temp=" + rd.nextDouble();
	String content = gp.get(url, "UTF-8");
	if(!StringUtil.isFine(content)){
		content=gc.getContent(url,"UTF-8");
	}
	ArrayList<String> list = new ArrayList<String>();
	ArrayList<String> list2 = new ArrayList<String>();
	list = gc.getPatternStrs(content, "\"time\":\"(.*?)\",", 1);
	list2 = gc.getPatternStrs(content, "context\":\"(.*?)\",", 1);
%>
<!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=utf-8" />
		<title>快递进度</title>
	</head>

	<body style="font-size:12px">
		<table width="800" align="center" cellpadding="1" cellspacing="1"
			bgcolor="#CCCCCC" class="table1">
			<tr>
				<td width="28%" height="30" align="center" bgcolor="#FFFFFF">
					<strong>时间：</strong>
				</td>
				<td width="72%" height="30" bgcolor="#FFFFFF">
					<strong>地点：</strong>
				</td>
			</tr>
			<%for (int i = 0; i < list.size(); i++) {
			%>
			<tr>
				<td width="28%" height="30" align="center" bgcolor="#FFFFFF">
					<%=list.get(i) %>
				</td>
				<td width="72%" height="30" bgcolor="#FFFFFF">
					&nbsp;<%=list2.get(i)%></td>
					<%
					if(i==0){//更新最新快递状态
						Order_list_db oldb=new Order_list_db();
						oldb.update(orderid,"retain6",list2.get(0));
					}
					%>
			</tr>
			<%}
			if(list.size()==0){
			%>
			<tr>
				<td height="30" colspan="2" align="center" bgcolor="#FFFFFF">
				您的快递单号暂时没有查询结果！
				<br />
				请核对快递公司名称和快递单号是否正确：
				</td>
			</tr>
			<%}else{ %>
			<tr>
				<td height="30" colspan="2" align="center" bgcolor="#FFFFFF">
				&nbsp;
				<table width="100%" border="0" cellspacing="1" cellpadding="1" bgcolor="#CCCCCC">
					<tr>
						<td height="10" colspan="4" bgcolor="#FFFFFF"></td>
					</tr>
					<tr>
						<td bgcolor="#FFFFFF"><%=pu.getString("orderid")%></td>
						<td bgcolor="#FFFFFF"><%=pu.getStringByPage("contact") %></td>
						<td bgcolor="#FFFFFF"><%=pu.getStringByPage("address") %></td>
						<td bgcolor="#FFFFFF"><%=pu.getStringByPage("phone") %></td>
					</tr>
				</table></td>
			</tr>
			<%}%>
		</table>
	</body>
</html>
<%
}else{
%>
<script language="javascript">
alert('请确保已经填写订单号，点击确定将关闭窗口');
window.close();
</script>
<%}%>