<?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>

	<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">
	<link rel="stylesheet" href="jsp4/jquery.mobile.datepicker.css">
	
	<script src="jsp4/jquery.ui.datepicker.js"></script>
	<script id="mobile-datepicker" src="jsp4/jquery.mobile.datepicker.js"></script>
	
	<script language="JavaScript"> 
		//不允许进行后退
		javascript:window.history.forward(0); 
	</script>
	
		<script>
		//禁止页面上下滑动,整个页面都不能滑动了
		document.addEventListener('touchmove', function(e) {
			e.preventDefault();
		});
	</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");	//只加载一次
	
	$strblistno=trim($_REQUEST['blid']);	//订单号
	
	$sql=sprintf("SELECT Order_No,Room_No,Room_Type,RoomPrice,Room_BillState,Convert(varchar(10),SelectRoomTime,120)as checkintime,
				Convert(varchar(10),Cancel_Date,120)as checkouttime ,Sited_Days,Sited_TimeFlag,Man_Name,
				DATEPART(weekday,SelectRoomTime)AS weekday1,DATEPART(weekday,Cancel_Date) AS weekday2
				FROM TR_Order_Room_List WHERE ListNo=%s",$strblistno);
					
	$result = querySql($sql);
	$row = fetch_array($result);
	
	$strorderno = trim($row['Order_No']);
	$strroomno = trim($row['Room_No']);	
	$strroomtype = trim($row['Room_Type']);
	$fltroomprice = $row['RoomPrice'];
	$intbillstate = $row['Room_BillState'];
	$intsiteddays = $row['Sited_Days'];				//住房天数
	
	$strcheckintime = $row['checkintime'];
	$strcheckouttime = $row['checkouttime'];
	$inttimeroom = $row['Sited_TimeFlag'];

	$strmanname = $row['Man_Name'];				
	
	$intweekday1 = $row['weekday1'];
	$intweekday2 = $row['weekday2'];
	
	//释放数据库
	freeResult($result);
		
	//单据客房状态:0预排,1预订,2入住,3退房,4取消
	$strorderstate="预订单";
	if($intbillstate==1)
		$strorderstate="预订房";
	elseif($intbillstate==2)
		$strorderstate="住客房";
	elseif($intbillstate==3)
		$strorderstate="已退房";
	elseif($intbillstate==4)
		$strorderstate="已取消";
		
	//3.获取友情提醒信息
	$strRoomNextText='';
	
	$sql=sprintf("SELECT RoomNexAddText FROM TR_MobileParam;");
	$result = querySql($sql);
	if($row = fetch_array($result))
	{
		$strRoomNextText = trim($row['RoomNexAddText']);
	}
	//释放数据库
	freeResult($result);	
	
	//关闭数据库
	closeDb();	
	
	$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="星期六";
?>

<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="6" width="15"></td>
				<td height="6" align="left"></td>
				<td height="6" width="15"></td>
			</tr>
			
			
			<tr>
				<td height="5" width="15"></td>
				<td height="15" align="left">
					<table width="100%" border="0" cellpadding="0" cellspacing="0">
                    	<tr>
							<td height="30" width="50">
								<span style="color: #808000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:16px;">姓名</span>
							</td>
							<td height="30">
								<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="30" width="50">
								<span style="color: #808000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:16px;">入住</span>
							</td>
							<td height="30">
								<span style="color: #570057;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:16px;"><?php echo $strcheckintime;?></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="30" width="50" rowspan="2">
								<span style="color: #808000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:18px;"><?php echo $intsiteddays;?>晚</span>
							</td>
						</tr>
						
						<tr>
							<td height="30" width="50">
								<span style="color: #808000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:16px;">离店</span>
							</td>
							<td height="30">
								<span style="color: #570057;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:16px;"><?php echo $strcheckouttime;?></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>
						
					</table>
				</td>
				<td height="5" width="15"></td>
			</tr>
			
			<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"></td>
				<td height="1" align="left" bgcolor="#F2E2E2"></td>
				<td height="1" width="15"></td>
			</tr>
			
			<tr>
				<td height="5" width="15"></td>
				<td height="5" align="left"></td>
				<td height="5" width="15"></td>
			</tr>
			
			<tr>
				<td height="5" width="15"></td>
				<td height="15" align="left">
					<table width="100%" border="0" cellpadding="0" cellspacing="0">
						<tr>
							<td height="30" width="50">
								<span style="color: #808000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:16px;">房号</span>
							</td>
							<td height="30">
								<span style="color: #570057;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:18px;"><?php echo $strroomno;?></span>
							</td>
						</tr>
						
						<tr>
							<td height="30" width="50">
								<span style="color: #808000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:16px;">房价</span>
							</td>
							<td height="30" colspan="2">
								<span style="color: #570057;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:18px;"><?php echo "  ￥".number_format($fltroomprice);?></span>
								<span style="color: #808000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:14px;">&nbsp;&nbsp;&nbsp;每晚房价</span>
							</td>
						</tr>
											
					</table>
				</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>
			
			
			<!---显示续住操作信息--->			
			<tr>
				<td height="40" width="15"></td>
				<td height="40" align="left">
					<table width="100%" border="0" cellpadding="0" cellspacing="0">
                        <tr><td height="1" bgcolor="#F2E2E2" colspan="2"></td></tr>
                        <tr><td height="5" colspan="2"></td></tr>
						<tr>
							<td height="45" width="50">
								<span style="color: #808000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:16px;">续住</span>
							</td>
							<td height="45" align="left">
								<span style="color: #570057;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:18px;">
									<select id="mycombo1" name="mycombo2" data-inline="true" data-mini="true" onChange="comSelChanged()">										
										<?php  
											$intfreecount=8;
                                            $intindex=1;
                                            while($intindex<=$intfreecount)
                                            {
                                      	?>
                                        		<option value="<?php echo number_format($intindex);?>"><?php echo number_format($intindex).' 天';?>&nbsp;&nbsp;&nbsp;</option>
                                       	<?php
                                        		$intindex=$intindex+1;
                                          	}
                                   		?>
                                  	</select>
                            	</span>
							</td>
						</tr>
                        
                        <tr>
							<td height="45" width="50">
								<span style="color: #808000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:16px;">金额</span>
							</td>
							<td height="45" align="left">
                            	<table width="100%" border="0" cellpadding="0" cellspacing="0">
                                	<tr>
                                    	<td height="45" width="60" valign="middle">
                                        	<label id="label1" style=" padding-top:5px;color: #808000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:18px;"><?php echo "  ￥".number_format($fltroomprice);?></label>
                                        </td>
                                       	<td height="45">
	                                        <span style="color: #CCB2B4;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:12px;">&nbsp;&nbsp;&nbsp;本次续住需要支付的金额</span>
                                        </td>
                                    </tr>
                                </table>
							</td>
						</tr>																	
					</table>
                    
				</td>
				<td height="40" 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>
			
			<?php if($intorderstate<1) {?>
				<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>
			<?php }?>
						
                        
                        
                        
			<!--显示温馨提示内容-->
			<?php if(strlen($strRoomNextText)>0) 
					{ 
			?>
				<tr>
					<td height="5" width="15"></td>
					<td height="5" align="left"></td>
					<td height="5" width="15"></td>
				</tr>
				
				<tr>
					<td height="15" width="15"></td>
					<td height="15" align="left">
						<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:12px;"><?php echo $strRoomNextText;?></span>
					</td>
					<td height="15" width="15"></td>
				</tr>
				
				<tr>
					<td height="10" width="15"></td>
					<td height="10" align="left"></td>
					<td height="10" 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>
			<?php } ?>

              
                
            <tr>
				<td height="10" width="15"></td>
				<td height="10" align="left"></td>
				<td height="10" width="15"></td>
			</tr>

            
            
            <tr>
				<td height="20" width="15"></td>
				<td height="20" align="left">
                	<table width="100%" border="0" cellpadding="0" cellspacing="0">
						<tr>
                            <td width="48%">
                                    <div onClick="window.location = 'roomview.php?blno=<?php echo $strblistno; ?>';" 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 width="4%"></td>
                            <td width="48%">
                                    <div onClick="butNextClick()" 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="20" width="15"></td>
			</tr>
            
            			
			<tr>
				<td height="10" width="15"></td>
				<td height="10" align="left"></td>
				<td height="10" 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>
		</table>
			
	</article>
    
    <script type="text/javascript">
		function comSelChanged()
		{
			var fltroomprice = <?php echo $fltroomprice;?>;
			var strnextdays = $("#mycombo1").val();
			var fltnewval = strnextdays * fltroomprice;
			$("#label1").text("  ￥" + fltnewval.toString());
		}
		
		function butNextClick()
		{
			//得到付款金额
			var fltroomprice = <?php echo $fltroomprice;?>;	//每晚房价
			var strnextdays = $("#mycombo1").val();			//要续住的天数
			var fltnewval = strnextdays * fltroomprice;			//生成本次续住要扣款的金额

			var strpayurl = 'xzpaysel.php?price=' + fltnewval.toString() + '&blid=<?php echo $strblistno;?>' + '&xzday=' + strnextdays.toString();

			window.location = strpayurl;

		}
	</script>
</section>

</body>
	
</html>