<?php
	session_start();
	header("Content-type:text/html;charset=gb2312");
	//判断是否登录系统		
	if($_SESSION["main_viplogined"]!="1" |$_SESSION["main_vipno"]=="")
	{
		//没有登录开始启动登录
		header('location:login.php?stext=');
		exit;
	}
?>
<!DOCTYPE html>
<html>
<head>
	<meta charset="gb2312">	
	<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
	<meta name="apple-mobile-web-app-capable" content="1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="format-detection" content="telephone=0">
	<meta name="apple-touch-fullscreen" content="1">

	<title>微信会员</title>

	<script src="jsp4/jquery.js"></script>
	<link rel="stylesheet" href="css/mycss.css"> 
	
	<!--<link rel="stylesheet" href="jsp5/jquery.mobile-1.4.5.min.css">-->
	<!--<script src="jsp4/jquery.mobile-1.4.3.min.js"></script>-->
	<script src="jsp5/jquery.mobile-1.4.5.min.js"></script>
	<link rel="stylesheet" href="jsp5/jquery.mobile-1.4.5.min.css">
	
</head>

<script>	
	//隐藏维信右上角菜单
	function onBridgeReady(){
		WeixinJSBridge.call('hideOptionMenu');
	}

	if (typeof WeixinJSBridge == "undefined")
	{
		if( document.addEventListener )
		{
			document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
		}
		else if (document.attachEvent)
		{
			document.attachEvent('WeixinJSBridgeReady', onBridgeReady); 
			document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
		}
	}
	else
	{
		onBridgeReady();
	}
</script>

<?php
	require_once("db/db.php");	
	require_once("common/common.php");
	require_once("../Wx.Config.php");	//只加载一次
	
?>

<body leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0">
<!--第一个页面的内容实现---------------------------->
<section data-role="page" id="hispage1">
	<header data-role="header" data-position="fixed" data-tap-toggle="false">
		<header data-role="header" data-position="fixed" data-tap-toggle="false" style="border-top-width:0px;border-bottom-width:0px;">
		<table width="100%" height="45" border="0" cellpadding="0" cellspacing="0" bgcolor="<?php echo WxMainConfig::colHeadBkColorBook;?>">
			<tr>
				<td height="45" width="35" align="right" valign="middle">
					<a href="vipmain.php" target="_blank"data-iconpos="notext">
						<div style="width:30;height:26px; ">
							<img src="images\back.png" width="12" height="21" border="0" style="margin-top:3px;">
						</div>
                    </a>
				</td>
				<td height="45" width="10"></td>
				<td height="45" align="left">
					<!--<a href="vipmain.php" target="_blank" >-->
					<div style="padding-top:2px;">
						<table width="100%" height="45" border="0" cellpadding="0" cellspacing="0">
							<tr>
								<td align="center">
									<span id="MsgTxt" style="color:<?php echo WxMainConfig::colHeadTextColorBook;?>;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:19px;text-shadow:none;">历史订单</span>
								</td>
								<td width="50"></td> <!--align="center"-->
							</tr>
						</table>
					</div><!--</a>-->
				</td>
			</tr>
			<tr>
				<td height="1" colspan="3" bgcolor="#F2E2E2"></td>
			</tr>
			<tr>
				<td height="35" colspan="3" bgcolor="#fff">
					<table width="100%" height="37" border="0" cellpadding="0" cellspacing="0">
						<tr>
							<td width="10%" height="35" align="center"></td>
							<td width="35%" height="35" align="center">
								<div onClick="window.location = 'hisorder1.php';">
									<table width="100%" height="37" border="0" cellpadding="0" cellspacing="0">
										<tr><td align="center">
											<span style="color: #000000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:15px;">三个月内</span>
										</tr></td>
									</table>
								</div>
							</td>
							<td width="10%" height="35" align="center"></td>
							<td width="35%" height="35" align="center">
								
									<table width="100%" height="37" border="0" cellpadding="0" cellspacing="0">
										<tr><td align="center">
											<span style="color: #BBBB00;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:15px;">三个月前</span>
										</tr></td>
									</table>
								
							</td>
							<td width="10%" height="35" align="center"></td>
						</tr>
						<tr>
							<td width="10%" height="2" align="center"></td>
							<td width="35%" height="2" align="center"></td>
							<td width="10%" height="2" align="center"></td>
							<td width="35%" height="2" align="center" bgcolor="#BBBB00"></td>
							<td width="10%" height="2" align="center"></td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
	</header>
	
	<article data-role="none">
		<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#66FFFF">
			<tr>
				<td height="2" width="8"></td>
				<td height="2" align="left"></td>
				<td height="2" width="8"></td>
			</tr>
			
			<?php
				$strorderno="";
				$strchainname="";
				$strroomtype="";
				$introomcount=0;
				$fltroomprice=0;
				$checkintime="";
				$checkouttime="";
				$willtime="";
				$intorderstate=0;
				$strorderstate="";
								
				$billstatecolor="F6F6F6";
				
				//预订0,入住1,取消2,完成3 Convert(varchar(10),getdate(),120),
				$sql=sprintf("Select b.Chain_Name,a.Order_No,c.Room_Type,c.Room_Count,c.RoomPrice,Convert(varchar(10),a.CheckInTime,120)as checkintime,
						Convert(varchar(10),a.CheckOutTime,120)as checkouttime,Convert(varchar(5),a.WillTime,24)as willtime,a.Order_State,a.CheckDays
						From TR_Order_Inform a,Chain_Infor b,TR_Book_RoomType c WHERE b.Chain_No=a.Chain_No AND c.Order_No=a.Order_No 
						AND a.VIP_SubNo='%s' And a.Order_State<>2 And a.Book_Type='APP预订' AND a.CheckInTime<=DATEADD(month,-3,GETDATE()) ORDER BY a.Order_No DESC",$_SESSION["main_vipno"]);

				$result = querySql($sql);
											
				while($row = fetch_array($result))
				{
					$strorderno=$row['Order_No'];
					$strchainname=$row['Chain_Name'];
					$strroomtype=$row['Room_Type'];
					$introomcount=$row['Room_Count'];
					$fltroomprice=$row['RoomPrice'];
					$checkintime=$row['checkintime'];
					$checkouttime=$row['checkouttime'];
					$willtime=$row['willtime'];
					$intorderstate=$row['Order_State'];
					$intcheckdays= $row['CheckDays'];
					
					$billstatecolor="ffffff";
					if($intorderstate==1){
						$strorderstate="入住";
						//$billstatecolor="33FFCC";
					}
					elseif($intorderstate==2){
						$strorderstate="取消";
						//$billstatecolor="FFFFFF";
					}
					elseif($intorderstate==3){
						$strorderstate="完成";
						//$billstatecolor="33FFCC";
					}
					else {
						$strorderstate="预订";
						//$billstatecolor="66FFFF";
					}
					
					//生成单据金额
					$billvalue=$fltroomprice * $introomcount * $intcheckdays;
			?>
			<tr>
				<td width="8"></td>
				<td align="left">
					<div onClick="window.location = 'orderview.php?tbno=<?php echo $strorderno;?>&doid=2';" style="width:100%;height:126px;border-radius:4px;border-top:1px solid #F2E2E2;border-bottom:1px solid #F2E2E2;border-left:1px solid #F2E2E2;border-right:1px solid #F2E2E2;">
						<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#<?php echo $billstatecolor;?>">
							<tr>
								<td height="2" width="15"></td>
								<td height="2" align="left"></td>
								<td height="2" width="85"></td>
								<td height="2" width="15"></td>
							</tr>
														
							<tr>
								<td height="30" width="15"></td>
								<td height="30" align="left" valign="middle">
									<table width="100%" border="0" cellpadding="0" cellspacing="0">
										<tr>
											<td width="30"><IMG src="images/room.png" border=0></td>
											<td><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:15px;"><?php echo $strchainname;?></span></td>
										</tr>
									</table>
								</td>
								<td height="30" width="85" align="center">
									<?php if($intbillstate>0) { ?>
										<span style="color: #009900;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:15px;">&nbsp;&nbsp;已<?php echo $strorderstate;?></span>
									<?php } else { ?>
										<span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:15px;">&nbsp;&nbsp;<?php echo $strorderstate;?></span>
									<?php } ?>
								</td>
								
								<td height="30" width="15"></td>
							</tr>
							
							<tr>
								<td height="1" width="15"></td>
								<td height="1" align="left" bgcolor="#F2E2E2"></td>
								<td height="1" width="85" bgcolor="#F2E2E2"></td>
								<td height="1" width="15"></td>
							</tr>
			
							<tr>
								<td height="30" width="15"></td>
								<td height="30" align="left" valign="middle">
									<span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:15px;"><?php echo $strroomtype;?>&nbsp;&nbsp;&nbsp;<?php echo number_format($introomcount,0).' 间';?></span>
								</td>
								<td height="30" width="85" align="center">
									<span style="color: #00753A;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:15px;"><?php echo "￥".number_format($billvalue,0);?></span>
								</td>
								<td height="30" width="15"></td>
							</tr>
										
							<tr>
								<td height="20" width="15"></td>
								<td height="20" align="left" valign="middle">
									<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;">入住时间：<?php echo $checkintime;?></span>
								</td>
								<td height="20" width="85" align="left"></td>
								<td height="20" width="15"></td>
							</tr>
							
							<tr>
								<td height="20" width="15"></td>
								<td height="20" align="left" valign="middle">
									<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;">预离时间：<?php echo $checkouttime;?></span>
								</td>
								<td height="20" width="85"></td>
								<td height="20" width="15"></td>
							</tr>
							
							<tr>
								<td height="20" width="15"></td>
								<td height="20" colspan="2" align="left" valign="middle">
									<table width="100%" height="10" border="0" cellpadding="0" cellspacing="0">
										<tr>
											<td height="20">
												<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;">保留时间：<?php echo $willtime;?></span>
											</td>
											<td width="130">
												<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:11px;">单号:<?php echo $strorderno;?></span>
											</td>
										</tr>
									</table>
								</td>
								<td height="20" width="15"></td>
							</tr>
							
							<tr>
								<td height="3" width="15"></td>
								<td height="3" align="left"></td>
								<td height="3" width="85"></td>
								<td height="3" width="15"></td>
							</tr>
							
						</table>
					</div>
				</td>
				<td width="8"></td>
			</tr>
			
			<tr>
				<td height="5" width="8"></td>
				<td height="5" align="left"></td>
				<td height="5" width="8"></td>
			</tr>
			<?php 
				}
				//释放数据库
				freeResult($result);
				closeDb();
			?>
									
		</table>
				
	</article>
</section>

</body>
	
</html>