<?php
	session_start();
	//判断是否登录系统		
	if($_SESSION["main_viplogined"]!="1" |$_SESSION["main_vipno"]=="")
	{
		//没有登录开始启动登录
		header('location:login.php?stext=');
		exit;
	}
	header("Content-type:text/html;charset=gb2312");
?>
<!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"> 
    <link rel="stylesheet" href="jsp5/jquery.mobile-1.4.5.min.css">
    
	<script src="jsp5/jquery.js"></script>
  	<script src="jsp5/jquery.mobile-1.4.5.min.js"></script>
    <script src="jsp5/jquery-1.8.3.min.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 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>

	<script>
		//禁止页面上下滑动,整个页面都不能滑动了
		document.addEventListener('touchmove', function(e) {
			e.preventDefault();
		});
	</script>
		
<?php
	require_once("db/db.php");	
	require_once("common/common.php");
	require_once("../Wx.Config.php");	//只加载一次
	
	$strret=trim($_REQUEST['stext']);
	$strorderno=trim($_REQUEST['tbno']);	//订单号
	
	//得到该订单的订房数量和房型以及已选房数量
		
	$strdoid=trim($_REQUEST['doid']);		//1是历史订单,否则我的订单
	
	$strsitedchainno='';
	$intCheckInServerDay=0;		//判断入住日期和当前服务器日期是否一致
	
	$sql=sprintf("SELECT Convert(varchar(10),a.CheckInTime,120)as checkintime,Convert(varchar(10),a.CheckOutTime,120)as checkouttime,
					b.Room_Type,b.Room_Count,a.CheckDays,Convert(varchar(5),a.WillTime,8)as willtime,a.Chain_No,
					a.Order_State,DATEPART(weekday,a.CheckInTime)AS weekday1,DATEPART(weekday,a.CheckOutTime) AS weekday2 FROM TR_Order_Inform a,
					TR_Book_RoomType b WHERE a.Order_No=b.Order_No AND a.Order_No='%s';",$strorderno);
				
	$result = querySql($sql);
	$row = fetch_array($result);

	$strcheckinday = $row['checkintime'];			//入住时间
	$strcheckoutday = $row['checkouttime'];			//离店日期
	$intcheckdays = $row['CheckDays'];				//住房天数
	$strwilltime = $row['willtime'];				//保留时间
	$strroomtype = $row['Room_Type'];				//房型
	$introomcount = $row['Room_Count'];				//订房数
	$strsitedchainno = $row['Chain_No'];			//入住分店
	
	//$intweekday1 = $row['weekday1'];
	//$intweekday2 = $row['weekday2'];
	$strremarks = $row['Remarks'];
	$intorderstate = $row['Order_State'];		//预订0,入住1,取消2,完成3
	
	$fltallval=$introomcount * $fltroomprice;
	
	//释放数据库
	freeResult($result);	
	//关闭数据库
	//closeDb();	
				
	//得到已选房数量	
	$introomselcount=0;	//已选房数量
	$sql=sprintf("SELECT COUNT(ListNo)AS SelCount FROM TR_Order_Room_List WHERE Order_No='%s'",$strorderno);
	$result = querySql($sql);
	$row = fetch_array($result);
	$introomselcount = trim($row['SelCount']);
	
	freeResult($result);
								
	//关闭数据库
	closeDb();	
	
	//本次可以选择房间数
	$intNowCanSelCount = $introomcount - $introomselcount;
	
		//2.判断入住日期是否为当天
?>

<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" 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="#ffffff">
			<tr>
				<td height="4" width="15"></td>
				<td height="4" align="left"></td>
				<td height="4" width="15"></td>
			</tr>
			
            <?php
				//1.获取预定单信息
				$sql=sprintf("SELECT Convert(varchar(10),a.CheckInTime,120)as checkintime,Convert(varchar(10),a.CheckOutTime,120)as checkouttime,
					a.WillTime,b.Room_Type,b.Room_Count,b.RoomPrice,a.Custom_Name,a.CheckDays,Convert(varchar(5),a.WillTime,8)as willtime,a.Order_State,
					DATEPART(weekday,a.CheckInTime)AS weekday1,DATEPART(weekday,a.CheckOutTime) AS weekday2 FROM TR_Order_Inform a,
					TR_Book_RoomType b WHERE a.Order_No=b.Order_No AND a.Order_No='%s';",$strorderno);
					
				$result = querySql($sql);
				$row = fetch_array($result);
				
				$strcheckinday = $row['checkintime'];			//入住时间
				$strcheckoutday = $row['checkouttime'];			//离店日期
				$intcheckdays = $row['CheckDays'];				//住房天数
				$strwilltime = $row['willtime'];				//保留时间
				$strroomtype = $row['Room_Type'];				//房型
				$introomcount = $row['Room_Count'];				//订房数
				$fltroomprice = $row['RoomPrice'];				//房价
				$strmanname = $row['Custom_Name'];				//联系人
				$intweekday1 = $row['weekday1'];
				$intweekday2 = $row['weekday2'];
				$intorderstate = $row['Order_State'];		//预订0,入住1,取消2,完成3
								
				freeResult($result);	//释放数据库
								
				$strorderstate="预订单";
				if($intorderstate==1)
					$strorderstate="已入住";
				elseif($intorderstate==2)
					$strorderstate="已取消";
				elseif($intorderstate==3)
					$strorderstate="已完成";
				
				$strweekday1="";
				$strweekday2="";
				//------------------------------------//
				if($intweekday1==1)
					$strweekday1="星期日";
				elseif($intweekday1==2)
					$strweekday1="星期一";
				elseif($intweekday1==3)
					$strweekday1="星期二";
				elseif($intweekday1==4)
					$strweekday1="星期三";
				elseif($intweekday1==5)
					$strweekday1="星期四";
				elseif($intweekday1==6)
					$strweekday1="星期五";
				elseif($intweekday1==7)
					$strweekday1="星期六";
				
				if($intweekday2==1)
					$strweekday2="星期日";
				elseif($intweekday2==2)
					$strweekday2="星期一";
				elseif($intweekday2==3)
					$strweekday2="星期二";
				elseif($intweekday2==4)
					$strweekday2="星期三";
				elseif($intweekday2==5)
					$strweekday2="星期四";
				elseif($intweekday2==6)
					$strweekday2="星期五";
				elseif($intweekday2==7)
					$strweekday2="星期六";
		
				//2.获取友情提醒信息
				$strSelRoomText='';	//选房后入住前的友情提醒信息
				
				$sql=sprintf("SELECT SelRoomText FROM TR_MobileParam;");
				$result = querySql($sql);
				if($row = fetch_array($result))
				{
					$strSelRoomText = trim($row['SelRoomText']);
				}
				//释放数据库
				freeResult($result);	
	
				//3.显示订单信息
			?>
            
            <tr>
				<td height="5" width="15"></td>
				<td height="15" align="left">
					<table width="100%" border="0" cellpadding="0" cellspacing="0">
                    	<tr>
							<td height="35" width="50">
								<span style="color: #808000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:16px;">姓名</span>
							</td>
							<td height="35">
								<span style="color: #570057;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:16px;"><?php echo $strmanname;?></span>
							</td>
						</tr>
						<tr>
							<td height="35" width="50">
								<span style="color: #808000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:16px;">入住</span>
							</td>
							<td height="35">
								<span style="color: #570057;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:16px;"><?php echo $strcheckinday;?></span>
								<span style="color: #570057;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:16px;">&nbsp;&nbsp;<?php echo $strweekday1;?></span>
							</td>
							<td height="35" width="50" rowspan="2">
								<span style="color: #808000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:18px;"><?php echo $intcheckdays;?>晚</span>
							</td>
						</tr>
						
						<tr>
							<td height="35" width="50">
								<span style="color: #808000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:16px;">离店</span>
							</td>
							<td height="35">
								<span style="color: #570057;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:16px;"><?php echo $strcheckoutday;?></span>
								<span style="color: #570057;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:16px;">&nbsp;&nbsp;<?php echo $strweekday2;?></span>
							</td>
						</tr>
						
						<tr>
							<td height="35" width="50">
								<span style="color: #808000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:16px;">保留</span>
							</td>
							<td height="35">
								<span style="color: #570057;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:16px;"><?php echo $strwilltime;?></span>
							</td>
							<td height="35" width="50"></td>
						</tr>	
					</table>
				</td>
				<td height="5" width="15"></td>
			</tr>
             
            <!--单元块分割线条   BEGIN ---------->
            <tr>
				<td height="5" width="15"></td>
				<td height="5" align="left"></td>
				<td height="5" width="15"></td>
			</tr>
			
			<tr>
				<td height="1" width="15" bgcolor="#F2E2E2"></td>
				<td height="1" align="left" bgcolor="#F2E2E2"></td>
				<td height="1" width="15" bgcolor="#F2E2E2"></td>
			</tr>
			
			<tr>
				<td height="5" width="15" bgcolor="#66FFFF"></td>
				<td height="5" align="left" bgcolor="#66FFFF"></td>
				<td height="5" width="15" bgcolor="#66FFFF"></td>
			</tr>
			
			<tr>
				<td height="1" width="15" bgcolor="#F2E2E2"></td>
				<td height="1" align="left" bgcolor="#F2E2E2"></td>
				<td height="1" width="15" bgcolor="#F2E2E2"></td>
			</tr>
			<!--单元块分割线条   END ---------->
                                      
            <!--用来显示已选房的信息-->
            <tr>
				<td height="40" width="15"></td>
				<td height="40" align="left">
					<table width="100%" border="0" cellpadding="0" cellspacing="0">
						<tr>
							<td  height="35" width="100%">
								<span style="color: #000000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:15px;">已选房&nbsp;</span>
								<span style="color: #808000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:12px;">共<?php echo $introomcount;?>间/已选<?php echo $introomselcount;?>间</span>
							</td>
						</tr>
                        
                        <!--以下显示已选房的列表-->
                        <?php     
						    $strRoomNo='';
							$intBillState=0;
							$strBListNo='';
							$strBillState='';
							$intRoomIndex=0;
							//Room_Type,RoomPrice
                        	$sql=sprintf("SELECT ListNo,Room_No,Room_BillState FROM TR_Order_Room_List WHERE Order_No='%s'",$strorderno);

							$result = querySql($sql);
											
							while($row = fetch_array($result))
							{
								$strRoomNo = $row['Room_No'];
								$intBillState = $row['Room_BillState'];
								$strBListNo = $row['ListNo'];
								//单据客房状态:0预排,1预订,2入住,3退房,4取消
								switch($intBillState)
								{
									case 0:
										$strBillState='已选房';
										break;
									case 1:
										$strBillState='待入住';
										break;
									case 2:
										$strBillState='已入住';
										break;
									case 3:
										$strBillState='已退房';
										break;
									case 4:
										$strBillState='已取消';
										break;
								}
								
								if($intRoomIndex<1)
								{
                    	?>
						<tr><td height="1" width="100%" bgcolor="#F2E2E2"></td></tr>
                        <?php 
								}
						?>
                    	<tr>
							<td height="35" width="100%">
                            	<table width="100%" border="0" cellpadding="0" cellspacing="0">
                                	<tr>
                                    	<td height="35" width="10"></td>
                                        <td height="35">
                                        	<span style="color: #000000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:15px;"><?php echo $strRoomNo;?></span>
                                        </td>
                                       	<td height="35" width="80" align="left">
                                        	<span style="color: #000000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:15px;"><?php echo $strBillState;?></span>
                                        </td>
                                    </tr>
                                </table>
							</td>
						</tr>
                    
                    	<?php 
								$intRoomIndex = $intRoomIndex + 1;
							}
							//释放数据库
							freeResult($result);
							closeDb();
								
							if(strlen($strSelRoomText)>0)
							{
								//如果有已选房信息，则提示选房后的友情提醒内容
						?>
                        <tr><td height="1" width="100%" bgcolor="#F2E2E2"></td></tr>
                        <tr>
							<td height="35" width="100%">
                            	<span style="color: #808000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:12px;"><?php echo $strSelRoomText;?></span>
							</td>
						</tr>
                        <?php 
							}
						?>
                        
					</table>
				</td>
				<td height="40" width="15"></td>
			</tr>
            
            <!--单元块分割线条   BEGIN ---------->
            <tr>
				<td height="5" width="15"></td>
				<td height="5" align="left"></td>
				<td height="5" width="15"></td>
			</tr>
			
			<tr>
				<td height="1" width="15" bgcolor="#F2E2E2"></td>
				<td height="1" align="left" bgcolor="#F2E2E2"></td>
				<td height="1" width="15" bgcolor="#F2E2E2"></td>
			</tr>
			
			<tr>
				<td height="5" width="15" bgcolor="#66FFFF"></td>
				<td height="5" align="left" bgcolor="#66FFFF"></td>
				<td height="5" width="15" bgcolor="#66FFFF"></td>
			</tr>
			
			<tr>
				<td height="1" width="15" bgcolor="#F2E2E2"></td>
				<td height="1" align="left" bgcolor="#F2E2E2"></td>
				<td height="1" width="15" bgcolor="#F2E2E2"></td>
			</tr>
			<!--单元块分割线条   END ---------->
            <tr>
				<td height="20" width="15"></td>
				<td height="20" align="left"></td>
				<td height="20" width="15"></td>
			</tr>
            
            <tr>
				<td height="30" width="15"></td>
				<td height="30" align="left">
                    <table width="100%" height="10" border="0" cellpadding="0" cellspacing="0">
                                                
                        <tr>
                            <td height="100%" width="47%">
                                    <div onClick="window.location = 'orderview.php?tbno=<?php echo $strorderno; ?>&doid=0';" style="border-radius:5px;width:100%; height:45px; background-color:#D7AA28;">
                                        <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
                                            <tr><td width="100%" height="100%" align="center">
                                                <span style="color:#fff ;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;">返 回</span>                            	
                                            </td></tr>
                                        </table>
                                    </div>				
                            </td>
							<td height="100%" width="6%"></td>
                            <td height="100%"  width="47%">
                                    <div onClick="window.location = 'orderroomcheckinsave.php?tbno=<?php echo $strorderno;?>';" style="border-radius:5px;width:100%; height:45px; background-color:#CD0013;">
                                        <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
                                            <tr><td width="100%" height="100%" align="center">
                                                <span style="color:#fff ;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;">确定入住</span>                            	
                                            </td></tr>
                                        </table>
                                    </div>
                            </td>
                        </tr>
                    </table>					
                </td>
				<td height="30" width="15"></td>
			</tr>
            
            <tr>
				<td height="20" width="15"></td>
				<td height="20" align="left"></td>
				<td height="20" width="15" ></td>
			</tr>
            
		</table>
			
	</article>
    
</section>

</body>
	
</html>