<?php
	session_start();
	ini_set('session.gc_maxlifetime', 99999999); //设置时间 永不过期
	//判断是否登录系统		
	if($_SESSION['main_wx_userlogined']!="1" | $_SESSION['main_wx_userno']=="")
	{
		//没有登录开始启动登录
		header('location:..\loginwx.php?rset=0');
		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="jsp4/jquery.mobile-1.4.3.min.css">
	<script src="jsp4/jquery.js"></script>
	<script src="jsp4/jquery.mobile-1.4.3.min.js"></script>
	<link rel="stylesheet" href="css/mycss.css"> 
	<!--<script language="JavaScript"> 
		//不允许进行后退
		javascript:window.history.forward(0); 
	</script>-->
	
	<script>
		var intTimerID1;
		//定期巡检
		intTimerID1=setTimeout("GetCancelRoomMsg()",6000);
		
		function GetCancelRoomMsg()
		{
			//alert("2222");
			clearInterval(intTimerID1);
			
			//3.判断是否有退房请求	
			var strret;
			//用ajax的“同步方式”调用一般处理程序
			$.ajax({
				url: "getcancelroom.php",
				async: false,//改为同步方式
				type: "POST",
				//data: {doid:1, rmid: "strRoomNo" },
				success: function (RetData) 
				{
					strret = RetData;
				}
			});

			if(strret>0)
			{
				//alert(strret);
				//发出声音提示
				playMusic();
			}
			intTimerID1=setTimeout("GetCancelRoomMsg()",5000);						

		};		

		function playMusic() 
		{
			var player = $("#audio1")[0]; /*jquery对象转换成js对象*/
			//if (player.paused)
			//{ /*如果已经暂停*/
				player.play(); /*播放*/
			//}
			//else 
			//{
			//	player.pause();/*暂停*/
			//}
		}

	</script>
	
	<audio id="audio1" controls="controls">
		<source src="6.wav" type="audio/mpeg"/>
	</audio>
</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>

<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">
		<table width="100%" height="45" border="0" cellpadding="0" cellspacing="0" >
			<tr>
				<td height="45" width="20"></td>
				<td height="45" align="center">
					<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:18px;text-shadow:none;">查房请求记录</span>
				</td>
				<td height="45" width="20"></td>
			</tr>
		</table>
	</header>
	
	<article data-role="none">
		<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#66FFFF">
			<tr>
				<td height="4" width="8"></td>
				<td height="4" align="left"></td>
				<td height="4" width="8"></td>
			</tr>
			
			<?php
				require_once("db/db.php");	
				require_once("common/common.php");
				
				$lngRowID=0;
				$sql=sprintf("SELECT a.ListNo,a.RoomNo,CONVERT(varchar(19), a.TradeTime, 120) as TradeTime,CONVERT(varchar(19), a.SendTime, 120) as SendTime,
							a.SendCount,a.SendType,a.SendID 
						FROM TR_RoomCancelList a,TR_Order_Inform b,TR_Order_Room_List c 
						WHERE a.BListNo=c.ListNo AND a.ViewFlag=0 AND b.Order_No=c.Order_No 
							AND (b.Order_State=0 OR b.Order_State=1) AND c.Room_BillState=2 
							AND b.Chain_No='%s' AND a.SendTime>DATEADD(minute,-30,GETDATE()) ORDER BY a.SendTime DESC",$_SESSION["ChainNofw"]);
								
				$result = querySql($sql);
											
				while($row = fetch_array($result))
				{
					$lngRowID=$lngRowID+1;
					$strTradeTime=$row['TradeTime'];
					$strSendTime=$row['SendTime'];
					$strRoomNo=$row['RoomNo'];
					$intSendCount=$row['SendCount'];
					$strListNo=$row['ListNo'];
			?>
			<tr>
				<td width="8"></td>
				<td align="left">
					<a data-transition="slide" href="#ShowRoomInput<?php echo $lngRowID;?>" data-rel="popup" data-position-to="window" style="width:100%;height:10px;margin:0px auto 0px auto;color:#666666;text-decoration: none;">
					<div style="background-color:#FFFFFF;box-shadow:1px 1px 4px #DFCFCF;">
						<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFF">
							<tr>
								<td height="3" width="15"></td>
								<td height="3" align="left"></td>
								<td height="3" width="85"></td>
								<td height="3" width="15"></td>
							</tr>
														
							<tr>
								<td height="25" width="15"></td>
								<td height="25" align="left" valign="middle">
									<span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:15px;"><?php echo $lngRowID;?>. 房号：</span>
									<span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-weight:bold;font-size:15px;"><?php echo $strRoomNo;?></span>
								</td>
								<td height="25" width="100" align="left">
									<span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:15px;">次数：<?php echo $intSendCount;?></span>
								</td>
								
								<td height="25" 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="22" width="15"></td>
								<td height="22" align="left" valign="middle" colspan="2">
									<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;">最近申请时间：<?php echo $strSendTime;?></span>
								</td>
								<td height="22" width="15"></td>
							</tr>
							
							<tr>
								<td height="22" width="15"></td>
								<td height="22" align="left" valign="middle" colspan="2">
									<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;">首次提交时间：<?php echo $strTradeTime;?></span>
								</td>
								<td height="22" width="15"></td>
							</tr>
																					
							<tr>
								<td height="2" width="15"></td>
								<td height="2" align="left"></td>
								<td height="2" width="85"></td>
								<td height="2" width="15"></td>
							</tr>
							
						</table>
					</div>
					</a>    
					
					
					
					<!-- 以下是点击项目弹出的详细信息界面 -->
                                  	<div data-role="popup" id="ShowRoomInput<?php echo $lngRowID;?>" 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="280" height="155" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
                                            <tr><td height ="2" colspan="3" align="center"></td></tr>
                                            <tr><td height ="35" colspan="3" align="center"><span style="color: #808000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:18px;text-shadow:none;"><?php echo $strRoomNo.'  退房消息'; ?></span></td></tr>
                                            <tr><td height ="1" colspan="3" align="center" bgcolor="#F2E2E2"></td></tr>
                                            <tr><td height ="10" colspan="3" align="center"></td></tr>
                                                                                        
                                             <tr>
                                                <td height ="18" width="10"></td>
                                                <td height ="18" align="center">
													<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;">最近一次申请时间</span>
                                                </td>
                                                <td height ="18" width="10"></td>
                                            </tr>
                                            
											<tr>
                                                <td height ="18" width="10"></td>
                                                <td height ="18" align="center">
													<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;"><?php echo $strSendTime;?></span>
                                                </td>
                                                <td height ="18" width="10"></td>
                                            </tr>											

                                            
                                            <tr><td height ="10" colspan="3" align="center"></td></tr>
                                                                        
                                            <tr>
                                                <td height ="40" width="10"></td>
                                                <td height ="40" align="center">
                                                    <div data-rel="back" onClick="bmtSetItemHadView(<?php echo $strListNo;?>,'<?php echo $strRoomNo;?>')" style="border-radius:5px;width:80%; height:38px; 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 ="40" width="10"></td>
                                            </tr>
                                            
                                            <tr><td height ="15" colspan="3" align="center"></td></tr>
                                        
                                        </table>
                                    </div>
                                    <!----------------------------------------------------->
					
					
					
				</td>
				<td width="8"></td>
			</tr>
			
			<tr>
				<td height="6" width="8"></td>
				<td height="6" align="left"></td>
				<td height="6" width="8"></td>
			</tr>
			<?php 
				}
				//释放数据库
				freeResult($result);
				closeDb();
			?>
									
		</table>
		
		<script type="text/javascript">
				
			//相应提交按钮事件处理部分
			function bmtSetItemHadView(sellistno,strroomno)//,myboxid)
			{			
				//开始保存项目到购物车中
				var strret;
				//用ajax的“同步方式”调用一般处理程序
				$.ajax({
					url: "savemsgview.php?selitno=" + sellistno ,
					async: false,//改为同步方式
					type: "POST",
					//data: {doid:1, rmid: "strRoomNo" },
					success: function (RetData) 
					{
						strret = RetData;
					}
				});

				//alert(strret);
				if(strret==1)
				{
					//关闭弹出窗口
					//var $myd = $("#ShowRoomInput" + myboxid);
					//$myd.popup('close');
					window.location="roominform.php?rmid=" + strroomno;
				}
											
			};
			
		</script>
		
	</article>
	
	<footer data-role="footer" data-position="fixed" data-tap-toggle="false" style="border-top:0px solid #F2E2E2;border-bottom:0px 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="50%">					
					<a class="ui-btn ui-icon-carat-l ui-btn-icon-top" target="_parent" href="indexref.php" style="width:100%;height:10px;margin:0px auto 0px auto;color:#666666">
					<span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:12px;text-shadow:none;">返回首页</span>
					</a>
				</td>
				<td width="50%">					
					<a class="ui-btn ui-icon-refresh ui-btn-icon-top" target="_parent" href="checkoutlistref.php" style="width:100%;height:10px;margin:0px auto 0px auto;color:#666666">
					<span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:12px;text-shadow:none;">刷新数据</span>
					</a>
				</td>
			</tr>
		</table>						
	</footer>
</section>

</body>
	
</html>