<?php
	session_start();
	header("Content-type:text/html;charset=gb2312");
	//判断是否登录系统		
	if($_SESSION["main_viploginedsk"]!="1" |$_SESSION["main_vipnosk"]=="")
	{
		//没有登录开始启动登录
		require_once("logina.php");	
	}
	//判断是否有默认分店,如果有则直接进入默认分店界面
	$strlocalchainno=trim($_REQUEST['hotelno']);
	if(strlen($strlocalchainno)>0)
	{
		$_SESSION["main_defhotelcode"]=$strlocalchainno;
	}		
?>

<!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>
	
	<link rel="stylesheet" href="css/mycss.css"> 
	<script src="jsp4/jquery.js"></script>
	<!--<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">
	
	<!--<script language="JavaScript"> 
		//不允许进行后退
		javascript:window.history.forward(0); 
	</script>-->
	
</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");	//只加载一次
			
/*
		//得到当前会员的消费金额信息
		$strselvipno=$_SESSION["main_vipnosk"];
		$selvipusedsum=0;
		$selvipliftsum=0;
		$selvipintegval=0;
		$selvippswd="";
		
		$sql = sprintf("Select a.Sub_State,b.VIP_UsedSum,b.VIP_LiftSum,b.VIP_IntegVal,b.VIP_State,a.sub_pswd From VIP_Item a,VIP_Main b Where a.VIP_No=b.VIP_No And a.Sub_No='%s'",$strselvipno);
	
		$result = querySql($sql);
		if($row = fetch_array($result))
		{
			//如果有会员号
			$selvipusedsum=$row['VIP_UsedSum'];
			$selvipliftsum=$row['VIP_LiftSum'];
			$selvipintegval=$row['VIP_IntegVal'];	
			
			$selvippswd=trim($row['sub_pswd']);
			
			$_SESSION["main_vipstate"]=$row['Sub_State'];
			$_SESSION["main_vipVIPState"]=$row['VIP_State'];
		}
		freeResult($result);
		closeDb();
		
		//清空预订的天数信息
		$_SESSION["main_order_checkinday"]="";
		$_SESSION["main_order_checkoutday"]="";
		$_SESSION["main_order_siteddays"]="";
	*/
?>
	
<body leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0">		
<section data-role="page" id="billpage1">
	<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="30" align="center"></td>
				<td height="45" align="center" valign="middle">
	                <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 height="45" width="30" valign="middle"></td>
		  	</tr>
		</table>
	</header>
		
	<article data-role="none">
		<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#66FFFF">
			<tr>
				<td height="3" width="8"></td>
				<td height="3" align="left"></td>
				<td height="3" width="8"></td>
			</tr>
			
			<?php
				$strblistno="0";
				$strorderno="";
				$strchainname="";
				$strroomtype="";
				$fltroomprice=0;
				$checkintime="";
				$checkouttime="";
				$intcheckdays=0;
				$preprice=0;
				$strroomno='';
				
				$billstatecolor="fff";
				$strorderstate='已入住';
				
				$strwxudid=trim($_SESSION["main_wxudid"]);
				if(strlen($strwxudid)==0)
				{
					$strwxudid="NO";
				}
				
				//$strwxudid='';	//2016-07-22测试用，正式用时屏蔽此条
								
				//预订0,入住1,取消2,完成3 Convert(varchar(10),getdate(),120),
				$sql=sprintf("select c.Chain_Name,a.ListNo,a.Order_No,a.Room_No,a.Room_Type,a.RoomPrice,convert(varchar(16),a.SelectRoomTime,120)as SelectRoomTime,
							convert(varchar(16),a.Cancel_Date,120)as Cancel_Date,a.Sited_Days,a.Sited_TimeFlag from tr_order_room_list a,tr_order_inform b,chain_infor c
							where a.Order_No=b.Order_No and b.order_state<2 and a.room_billstate=2 and (a.wxid='%s' or a.wxid='ty112233445566778899ty') and c.chain_no=b.chain_no",$strwxudid);
							
				$result = querySql($sql);
											
				while($row = fetch_array($result))
				{
					$strblistno=$row['ListNo'];
					$strorderno=$row['Order_No'];
					$strchainname=$row['Chain_Name'];
					$strroomtype=$row['Room_Type'];
					$strroomno=$row['Room_No'];
					$fltroomprice=$row['RoomPrice'];
					$checkintime=$row['SelectRoomTime'];
					$checkouttime=$row['Cancel_Date'];
					$intcheckdays= $row['Sited_Days'];
										
					//生成单据金额
					$billvalue=$fltroomprice * $intcheckdays;

					$sql1=sprintf("Select sum(PayFor_Value) as price from TR_Consume_List where Order_No='%s'", $strorderno);
					 
					$result1 = querySql($sql1);
					
					$row1 = fetch_array($result1);
					//已付款
					$preprice = $row1['price'];
			?>
			<tr>
				<td width="8"></td>
				<td align="left">
					<div onClick="window.location = 'roomview.php?blno=<?php echo $strblistno; ?>';" style="width:100%;height:132px;border-radius:5px;border-top:1px solid #F2E2E2;border-bottom:1px solid #F2E2E2;border-left:1px solid #F2E2E2;border-right:1px solid #F2E2E2;">
						<table style="border-radius:5px" width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#<?php echo $billstatecolor;?>">
							<tr>
								<td height="4" width="15"></td>
								<td height="4" align="left"></td>
								<td height="4" width="85"></td>
								<td height="4" 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">
									<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>
								</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;">房号&nbsp;&nbsp;&nbsp;<?php echo $strroomno;?></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="95" align="center">
									<span style="color: #00753A;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:15px;">
									<?php if(number_format($preprice,0)>0){ ?>
										已付:<?php echo "￥".number_format($preprice,0);?>
									<?php }?>
									</span>
								</td>
								<td height="20" width="15">
									
								</td>
							</tr>
							
							<tr>
								<td height="20" width="15"></td>
								<td height="20" align="left" colspan="2" 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="15"></td>
							</tr>
							
							<tr>
								<td height="15" width="15"></td>
								<td height="15" align="left" colspan="2" valign="middle">
									<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;">系统单号：<?php echo $strorderno;?></span>
									
								</td>
								<td height="15" width="15"></td>
							</tr>
							
							<tr>
								<td height="5" width="15"></td>
								<td height="5" align="left"></td>
								<td height="5" width="85"></td>
								<td height="5" width="15"></td>
							</tr>
																					
						</table>
					</div>
				</td>
				<td width="8"></td>
			</tr>
			
			<tr>
				<td height="3" width="8"></td>
				<td height="3" align="left"></td>
				<td height="3" width="8"></td>
			</tr>
			<?php 
				}
				//释放数据库
				freeResult($result);
				closeDb();
				
				$strButEnabled = 'ui-state-disabled';
				
				if(strlen($strwxudid)>10)
				{
					$strButEnabled = '';	
				}
			?>
			<tr>
				<td height="30" width="8"></td>
				<td height="30" align="left">
					<a class="ui-btn ui-corner-all <?php echo $strButEnabled;?>" style="color:#A6A600;" target="_blank" href="roomwx.php">申请住房关联</a>
				</td>
				<td height="30" width="8"></td>
			</tr>
			
		</table>
				
	</article>
	
	<footer data-role="footer" data-position="fixed" data-tap-toggle="false" style="border-top:0px solid #F2E2E2;border-bottom:1px solid #F2E2E2;border-left:1px solid #F2E2E2;border-right:1px solid #F2E2E2;">
		<table width="100%" height="10" border="0" cellpadding="0" cellspacing="0">
			<tr height="100%" valign="top">
				<td width="25%">					
					<a class="ui-btn ui-icon-home ui-btn-icon-top" data-transition="slide" href="index2.php" data-direction="reverse" style="width:100%;height:10px;margin:0px auto 0px auto;color:#666666">主页</a>
				</td>
				<td width="25%">								
					<a class="ui-btn ui-icon-navigation ui-btn-icon-top" data-transition="slide" target="_blank" href="index.php" data-direction="reverse" style="width:100%;height:10px;margin:0px auto 0px auto;color:#666666">酒店预订</a>
				</td>
				<td width="25%">
					<a class="ui-btn ui-icon-bullets ui-btn-icon-top" data-transition="slide" target="_blank" href="orderlist.php" style="width:100%;height:10px;margin:0px auto 0px auto;color:#666666">我的订单</a>
				</td>
				<td width="25%">
					<a class="ui-btn ui-icon-tag ui-btn-icon-top" data-transition="slide" href="#" style="width:100%;height:10px;margin:0px auto 0px auto;color:#666666">我的住房</a>
				</td>
			</tr>
		</table>						
	</footer>
</section>

</body>
	
</html>