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

	<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 src="jsp5/jquery-1.7.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");
	
	//设置统一语言格式
	//header("Content-type: text/html; charset=gb2312"); 
	$strblistno=trim($_REQUEST['blno']);
	if(strlen($strblistno)==0)
	{
		$strblistno=0;
	}
	$strroomno='';
	$strchainname='';
	$strorderno='';
	$strcheckin='';
	$strcheckout='';
	
	//得到住房信息
	$sql = sprintf("select c.Chain_Name,a.Order_No,a.Room_No,convert(varchar(16),a.SelectRoomTime,120)as SelectRoomTime,
						convert(varchar(16),a.Cancel_Date,120)as Cancel_Date 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 c.chain_no=b.chain_no and a.ListNo=%s",$strblistno);
	$result = querySql($sql);
	$row = fetch_array($result);
	
	$strroomno = trim($row['Room_No']);
	$strchainname = trim($row['Chain_Name']);
	$strorderno = trim($row['Order_No']);
	$strcheckin = trim($row['SelectRoomTime']);
	$strcheckout = trim($row['Cancel_Date']);
	
	freeResult($result);
	
	//3.获取友情提醒信息
	$intCanNexAdd=0;
	
	$sql=sprintf("SELECT intCanNextAdd FROM TR_MobileParam;");
	$result = querySql($sql);
	if($row = fetch_array($result))
	{
		$intCanNexAdd = $row['intCanNextAdd'];
	}
	//释放数据库
	freeResult($result);	
	
	closeDb();	//关闭数据库
	
	$strButXZBkColor='#E3D5D6';
	if($intCanNexAdd>0)
	{
		$strButXZBkColor='#7553D8';
	}		
?>

<body leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0">
<!--第一个页面的内容实现---------------------------->
<section data-role="page" id="roomview1">
	<!--底层图，设置高度为150!-->
	<div style="width:100%;height:170px;z-Index:-2;">
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
			<tr><td height="10" width="%100">
				<img style="width:100%;height:180px;border:0px;" src="images/temp/rvb1.png" />
			</td></tr>
			
		</table>
	</div>
	
	<!--设置按钮执行动作的图标和对象-->
	<div style="width:100%;height:45px;z-Index:-1;">
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
			<tr><td height="10" width="%100" align="center">
				<span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:15px;text-shadow:none;">当前房号&nbsp;&nbsp;<?php echo $strroomno;?></span>
			</td></tr>
			<tr><td height="10" width="%100"></td></tr>
			<tr>
            	<td height="10" width="%100" align="center">
					<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
						<tr>
                        	<td height="80" width="33%" align="right"></td>
                            <td height="80" align="center">
                            	<div id="bmtSendXZ" onClick="bmtSendXZClick()" style="border-radius:38px;width:78px; height:78px; background-color:<?php echo $strButXZBkColor;?>;">
									<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:18px;text-shadow:none;">续 住</span>                            	
                                   		</td></tr>
                                  	</table>
                           		</div>
                            </td>
                            <td height="80" width="33%"></td>
                        </tr>
						
						<tr><td height="15" width="33%" align="right" colspan="3"></td></tr>
						
						<tr>
                        	<td height="80" width="33%" align="right">
								<!--早餐 href="#popupParis1"-->
								
								<a href="#popupParis1" data-rel="popup" data-position-to="window" data-transition="fade" style="text-decoration:none">
									<div style="border-radius:38px;width:78px; height:78px; background-color:#DCD048;">
										<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
											<tr><td width="100%" height="100%" align="center">
												<span style="color:#9B7B1D ;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:18px;text-shadow:none;">早 餐</span>                            	
											</td></tr>
										</table>
									</div>
								</a>
								<div data-role="popup" id="popupParis1" data-overlay-theme="b" data-theme="b" data-corners="false">
									<a href="#" data-rel="back" class="ui-btn ui-corner-all ui-shadow ui-btn-a ui-icon-delete ui-btn-icon-notext ui-btn-right">Close</a>
										
									<table width="270" height="330" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
										<tr><td height ="20" align="center"></td></tr>
										<tr><td height ="40" align="center"><span style="color: #808000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:25px;">早餐识别码</span></td></tr>
										<tr><td height ="270"><img class="popphoto" src="barcode.php?tbno=<?php echo $strblistno;?>&doid=1" style="width:270px;height:270px;max-height:512px;" alt="Paris, France"></td></tr>
									</table>
								</div>
							</td>
							
                            <td height="80" align="center">
													
                            	<div id="cmd_wxopen" style="border-radius:38px;width:78px; height:78px; background-color:#D7AA28;">
									<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
                                    	<tr><td width="100%" height="100%" align="center">
                                        	<span id="LableOpen" style="color:#fff ;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:18px;text-shadow:none;">开 门</span>                            	
                                   		</td></tr>
                                  	</table>
                           		</div>
                            </td>
                            <td height="80" width="33%">
								<div id="bmtSendTF" onClick="bmtSendTFClick()" style="border-radius:38px;width:78px; height:78px; background-color:#9075DF;">
									<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:18px;text-shadow:none;">退 房</span>                            	
                                   		</td></tr>
                                  	</table>
                           		</div>
							</td>
                        </tr>
						
						<tr><td height="15" width="33%" align="right" colspan="3"></td></tr>
						
						<tr>
                        	<td height="80" width="33%" align="right"></td>
                            <td height="80" align="center">
                            	<div id="bmtSendFH" onClick="bmtSendFHClick()" style="border-radius:38px;width:78px; height:78px; background-color:#A1E924;">
									<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
                                    	<tr><td width="100%" height="100%" align="center">
                                        	<span style="color:#9B7B1D ;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:18px;text-shadow:none;">返 回</span>                            	
                                   		</td></tr>
                                  	</table>
                           		</div>
                            </td>
                            <td height="80" width="33%"></td>
                        </tr>
					</table>
					
					                                    

				</td>
         	</tr>
		</table>
	</div>
		
	
	
	<script type="text/javascript">
		
		//相应提交按钮事件处理部分		
		function bmtSendXZClick()
		{
			var intCanNext = <?php echo $intCanNexAdd;?>;
			if(intCanNext>0)
			{
				window.location.href="orderroomaddnext.php?blid=<?php echo $strblistno;?>";	
			}
		}
		
		function bmtSendTFClick()
		{
			window.location.href="roomcancel.php?blid=<?php echo $strblistno;?>";
		}
		
		function bmtSendFHClick()
		{
			window.location.href="roomlist.php";
		}
		
		function bmtSendZCClick()
		{
			var show1 = document.getElementById('popupParis1');
			show1.style.display = 'block';
			
		}
	</script>
	
	<script type="text/javascript">
			var timerid1,timerid2;	//定时器句柄，用来结束定时器是用
			var havesendcmd;
			var cmdtimes=0;
			$("#cmd_wxopen").click(
				function()
				{	
					if(havesendcmd==1)
					{
						//已执行过，再点不执行
						//alert("正在提交开门指令");
					}
					else
					{
						//alert("正在提交开门指令2");
						havesendcmd=1;
						cmdtimes=0;
						
						var img = document.getElementById('cmd_wxopen');
						//开门颜色变成浅色
						img.style.backgroundColor="#F5C575";
						
						//setTimeout(setDefImg(),1000);
						//alert("正在提交开门指令");
						//img.src="images/lock3.png";
						timerid1=setInterval("setDefImg()",2000);
						var blistno="<?php echo $strblistno;?>";						
						//提交开门指令
						//window.location="wxopen.php?blistno=" + blistno;
						//return;
						var strret;
						strret=$.get("wxopen.php?blistno=" + blistno,function(result){});
						
					}
				}
			);
			//cmd_wxbreak
			//cmd_wxroomkz
			//cmd_wxcar
			//cmd_wxlift
			//cmd_wxoserver
			
			//每1秒刷新下指令执行状态
			function setDefImg()
			{	
				//判断执行开门的结果
				var intopendoor=0;
				intopendoor=1;
				
				//SHOW
				var img = document.getElementById('cmd_wxopen');
				if(intopendoor==1)	//已经开门
				{
					//开门颜色变成浅色
					img.style.backgroundColor="#FAF4E4";
					document.getElementById('LableOpen').style.color="#A2801E";
					//设置6秒后自动更改为关门状态
					timerid2=setInterval("setDefImgClosed()",4000);
					
					cmdtimes=13;	//设置为结束
				}
				else
				{
					//img.src="images/lock1.png";
					cmdtimes=cmdtimes+1;
				}							
				
				if(cmdtimes>10)
				{
					clearInterval(timerid1);	//结束定时器 
					//更新指令为已执行，未有发送的指令，可以相应点击
					if(cmdtimes<13)
					{
						havesendcmd=0;
					}
				}
			};
			
			//设置6秒后自动更改为关门状态
			function setDefImgClosed()
			{	
				//还原成原来的图片
				clearInterval(timerid2);	//结束定时器 
				
				var img = document.getElementById('cmd_wxopen');
				//开门颜色变成浅色
				img.style.backgroundColor="#D7AA28";
				document.getElementById('LableOpen').style.color="#fff";
				//更新指令为已执行，未有发送的指令，可以相应点击
				havesendcmd=0;
			};
		</script>
		

</section>

</body>
	
</html>