<?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 http-equiv="Content-Type" content="text/html; 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">
	
	<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");	//只加载一次
	
	$strroomtypeid=$_REQUEST['romtype'];				//入住房型ID
	$strret=trim($_REQUEST['stext']);
	
	$strselchainno=$_SESSION["main_order_chainno"];
	
	$strDayTemp1=$_SESSION["main_order_checkinday"];	//入住日期
	$strDayTemp2=$_SESSION["main_order_checkoutday"];	//入住日期
	$strDays=$_SESSION["main_order_siteddays"];			//天数
	
	$strDayTemp1=trim($strDayTemp1);
	$strDayTemp2=trim($strDayTemp2);
	$strweekday1="";
	$strweekday2="";
	
	//查询可用房数和房价
	$sql=sprintf("SELECT b.Room_Type,b.RoomPriceS,b.VIPPrice,b.RoomCount,DATEPART(weekday,'%s')AS weekday1,DATEPART(weekday,'%s') AS weekday2 FROM TR_Room_Type a,dbo.TRF_RoomTypeFreeCountVIP('%s','%s','%s','%s') b 
					WHERE a.Chain_No='%s'AND a.Room_Type=b.Room_Type and b.RoomCount>0 AND a.ListNo=%s",$strDayTemp1,$strDayTemp2,
					$strselchainno,$_SESSION["main_vipno"],$strDayTemp1,$strDayTemp2,$strselchainno,$strroomtypeid);

	$result = querySql($sql);
	$row = fetch_array($result);
	$strroomtype = trim($row['Room_Type']);
	$intweekday1 = $row['weekday1'];
	$intweekday2 = $row['weekday2'];
	
	$fltroomprice=$row['RoomPriceS'];
	$fltvipprice=$row['VIPPrice'];
	$intfreecount=$row['RoomCount'];
	
	//释放数据库
	freeResult($result);
	//关闭数据库
	closeDb();	
	
	if($fltvipprice==0)
		$fltvipprice=$fltroomprice;
	
	$fltroomprice=$fltvipprice;	//有效房价
		
	//------------------------------------//
	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="星期六";
	
	
	//如果有提交保存的错误 stext
	$pstext='';
	if($strret=='1')
		$pstext='无此会员或已注销！';
	elseif($strret=='2')
		$pstext='酒店信息不正确';
	elseif($strret=='3')
		$pstext='可用房数不足';
	elseif($strret=='4')
		$pstext='保存订单失败';			
?>

<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="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:16px;"><?php echo $strDayTemp1;?></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:16px;"><?php echo $strDays;?>晚</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 $strDayTemp2;?></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:18px;">
									<select id="mycombo1" name="mycombo1" data-inline="true" data-mini="true">	
										<option value="<?php echo '18:00';?>"><?php echo '18:00';?>&nbsp;&nbsp;&nbsp;</option>
										<option value="<?php echo '18:30';?>"><?php echo '18:30';?>&nbsp;&nbsp;&nbsp;</option>
										<option value="<?php echo '19:00';?>"><?php echo '19:00';?>&nbsp;&nbsp;&nbsp;</option>
										<option value="<?php echo '19:30';?>"><?php echo '19:30';?>&nbsp;&nbsp;&nbsp;</option>
										<option value="<?php echo '20:00';?>"><?php echo '20:00';?>&nbsp;&nbsp;&nbsp;</option>
										<option value="<?php echo '20:30';?>"><?php echo '20:30';?>&nbsp;&nbsp;&nbsp;</option>
										<option value="<?php echo '21:00';?>"><?php echo '21:00';?>&nbsp;&nbsp;&nbsp;</option>
									</select>
								</span>
							</td>
							<td height="35" width="50"></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="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 $strroomtype;?></span>
							</td>
							<td height="35" width="80">
								<span style="color: #570057;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:18px;">
										<select id="mycombo2" name="mycombo2" data-inline="true" data-mini="true">										
											<?php  
												$intindex=1;
												while($intindex<=$intfreecount)
												{
											?>
												<option value="<?php echo number_format($intindex);?>"><?php echo number_format($intindex).'间';?>&nbsp;</option>
											<?php
													$intindex=$intindex+1;
												}
											?>
										</select>
								</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:13px;">&nbsp;&nbsp;&nbsp;每晚房价</span>
							</td>
						</tr>
											
					</table>
				</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="40" width="15"></td>
				<td height="40" align="left">
					<table width="100%" border="0" cellpadding="0" cellspacing="0">
						<tr>
							<td height="40" width="70">
								<span style="color: #808000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:16px;">入住人</span>
							</td>
							<td height="40">
								<input id="mytext1" name="mytext1" value='<?php echo $_SESSION["main_vipname"];?>' type="text" placeholder="请输入姓名 *" autocomplete="off" data-mini="true"/>
							</td>
						</tr>
						
						<tr>
							<td height="40" width="70">
								<span style="color: #808000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:16px;">手机号</span>
							</td>
							<td height="40" colspan="2">
								<input id="mytext2" name="mytext2" value='<?php echo $_SESSION["main_viptelno"];?>' type="text" placeholder="请输入手机号 *" autocomplete="off" data-mini="true"/>
							</td>
						</tr>
						
						<tr>
							<td height="40" width="70">
								<span style="color: #808000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:16px;">其他要求</span>
							</td>
							<td height="40" colspan="2">
								<input id="mytext3" name="mytext3" value='' type="text" placeholder="例:有窗/无烟" autocomplete="off" data-mini="true"/>
							</td>
						</tr>
						
					</table>
				</td>
				<td height="40" 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" bgcolor="#F2E2E2"></td>
				<td height="1" align="left" bgcolor="#F2E2E2"></td>
				<td height="1" width="15" bgcolor="#F2E2E2"></td>
			</tr>
			
			<!--================================-->
						
			<?php if(strlen($pstext)>0) {?>
				<tr>
					<td height="10" width="15"></td>
					<td height="10" align="left"></td>
					<td height="10" width="15"></td>
				</tr>
				
				<tr>
					<td height="15" width="15"></td>
					<td height="15" align="left">
						<span style="color: #000000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:15px;"><?php echo $pstext;?>，不能预订！</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="20" width="15"></td>
				<td height="20" align="left">
					<table width="100%" border="0" cellpadding="0" cellspacing="0">
						<tr>
							<td width="47%">
								<a href="hotelsel.php?chidno=<?php echo $_SESSION["main_order_chainno"];?>&chsel=<?php echo $_SESSION["main_defhotelsel"];?>" data-transition="slide" style="color:#A6A600;" target="_blank" data-role="button">上一步</a>
							</td>
							<td width="6%"></td>
							<td width="47%">
								<span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:14px;">
									<a class="ui-btn ui-corner-all" style="color:#A6A600;" id="cmd_save" data-role="button">下一步</a>
								</span>
							</td>
						</tr>
					</table>	
				</td>
				<td height="20" width="15"></td>
			</tr>
			
			<tr>
				<td height="6" width="15"></td>
				<td height="6" align="left"></td>
				<td height="6" 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>
		
		<script type="text/javascript">
			$("#cmd_save").click(
				function()
		 		{				
					var strroomtype='<?php echo $strroomtypeid;?>';
					var strroomprice='<?php echo $fltroomprice;?>';
					var strcount=$("#mycombo2").val();
					var strmanname=$("#mytext1").val();	//姓名
					var strmantelno=$("#mytext2").val();	//电话
					var strkeeptime=$("#mycombo1").val();
					var strtext=$("#mytext3").val();	//说明
					
					var intNextFlag=0;
					
					if(strmanname.length==0)
					{
						intNextFlag=1;
						alert("请输入姓名！");
					}
					
					if(intNextFlag==0){
						if(strmantelno.length==0)
						{
							intNextFlag=1;
							alert("请输入手机号码！");
						}
					}
					
					if(intNextFlag==0){
						if(strcount.length==0)
						{
							intNextFlag=1;
							alert("请选择订房数！");
						}
					}
					
					if(intNextFlag==0){
						if(strcount=="0")
						{
							intNextFlag=1;
							alert("请选择订房数！");
						}
					}
					
					if(intNextFlag==0)
					{	//提交保存订单
						strmanname=strmanname.replace("'", "");
						strmantelno=strmantelno.replace("'", "");
						strtext=strtext.replace("'", "");
						strtext=strtext.replace("&", "");
						
						if(strkeeptime.length<5)
							strkeeptime="18:00";
												
						//setCookie('bmanname',strmanname);
						//var strurl="ordersave.php?romtype=" + strroomtype + "&rmcount=" + strcount + "&rmprice=" + strroomprice + "&rmname=" + strmanname + "&rmtelno=" + strmantelno + "&rmkptime=" + strkeeptime + "&rmtxt=" + strtext;
						var strurl="ordera.php?romtype=" + strroomtype + "&rmcount=" + strcount + "&rmprice=" + strroomprice + "&rmname=" + strmanname + "&rmtelno=" + strmantelno + "&rmkptime=" + strkeeptime + "&rmtxt=" + strtext;
						
						//alert(strurl);
						window.location.href=strurl;
					}
				}
			);
		</script>
	</article>
</section>

</body>
	
</html>