<?php
	session_start();
	require_once("db/db.php");	
	require_once("common/common.php");
	ini_set('session.gc_maxlifetime', 99999999); //设置时间 永不过期
	//判断是否登录系统		
	if($_SESSION['main_wx_userlogined']!="1" | $_SESSION['main_wx_userno']=="")
	{
		//没有登录开始启动登录
		header('location:..\loginwx.php?rset=0');
		exit;
	}
	
?>
<!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">
	
	<Meta http-equiv="Page-Enter" Content="blendTrans(Duration=0.5)"> 
	<Meta http-equiv="Page-Exit" Content="blendTrans(Duration=0.5)">
	
	<title><?php echo $_SESSION['ChainName']?></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"> 
	<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>
	
</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="pagepayfor1">		
	
	<header data-role="header" data-position="fixed" data-tap-toggle="false">
		<table width="100%" height="35" border="0" cellpadding="0" cellspacing="0" bgcolor="<?php echo WxMainConfig::colHeadBkColor;?>">	   
			<tr>
				<td height="46" width="50" align="center" valign="middle">
					<div onClick="bmtReturnPage()" style="width:40;height:45px; ">
						<img src="images\back.png" width="12" height="21" border="0" style="margin-top:12px;">
					</div>
				</td>
				<td height="46" align="center">
					<span style="color:#fff ;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:18px;text-shadow:none;">临时锁房</span>
				</td>
				<td height="46" width="50" align="right"></td>
			</tr>		  
			
		</table>
	</header>
	
	
	<article data-role="none" >
		<table width="100%" height="1" border="0" cellpadding="0" cellspacing="0">
			
			<?php			
					$strRoomNo=trim($_REQUEST["romid"]);
					$chainno=$_SESSION["ChainNo"];
					
					
					$strCanCheckInFlag=trim($_REQUEST["blnckin"]);
					
					$strroomstate='';
					$strRemarks='';
						
					$intKeepFlag=0;
					//开始去房间状态数量
					$sql=sprintf("SELECT a.Keep_Flag,a.Keep_Mark,a.Room_State,a.Dirty_Flag FROM TR_Room_Inform a,TR_Room_Type b 
									WHERE a.TypeListNo=b.ListNo AND b.Chain_No='%s' AND a.Room_No='%s'",$chainno,$strRoomNo);

					$result = querySql($sql);		
					if($row = fetch_array($result))
					{
						//得到每一条的记录信息
						$intKeepFlag=$row['Keep_Flag'];
						$strRemarks=$row['Keep_Mark'];
						
						$introomstate=$row['Room_State'];
						$intDirty=$row['Dirty_Flag'];
					
						$strroomstate='';
						//状态:0空房,1预订房,2在住房,3钟点房,4自用房,5退客房,6维修房,7锁房
												
						//生成状态颜色
						switch($introomstate)
						{
								case 0:
									$strroomstate="空净房";
									break;
								case 5:
									$strroomstate="退客房";
									break;
								case 6:
									$strroomstate="维修房";
									break;
								case 1:
									$strroomstate="预订房";
									break;
								case 2:
									if($intDirty==1)
									{
										$strroomstate="住脏房";
									}
									else
									{
										$strroomstate="住客房";
									}
									break;
								case 3:
									$strroomstate="钟点房";
									break;
								default:
									if($introomstate==5)
									{
										$strroomstate="免费房";
									}
									if($introomstate==7)
									{
										$strroomstate="锁房";
									}
									else
									{
										$strroomstate="其他";
									}
									break;
							}
					}
					//释放数据库
					freeResult($result);
					closeDb();
						
					if($intKeepFlag<1)
					{
						$strRemarks='';
					}
				?>
				
			<tr><td height="10" colspan="4"></td></tr>
			
			<tr>
				<td height="35" width="30" ></td>
				<td height="35" width="60" align="right">
					<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;">房号：</span>
				</td>
				<td height="35" align="left">
					<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;"><?php echo $strRoomNo;?></span>
				</td>
				
				<td height="35" width="40" ></td>
			</tr>
			
			<tr>
				<td height="35" width="30" ></td>
				<td height="35" width="60" align="right">
					<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;">状态：</span>
				</td>
				<td height="35" align="left">
					<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;"><?php echo $strroomstate;?></span>
				</td>
				
				<td height="35" width="40" ></td>
			</tr>
			
			<tr>
				<td height="35" width="30" ></td>
				<td height="35" width="60" align="right">
					<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;">说明：</span>
				</td>
				<td height="35" align="left">
					<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;">
						<input id="mytext1" name="mytext1" value='<?php echo $strRemarks;?>' type="text" placeholder="请输入锁房信息" autocomplete="off"/>
						
					</span>
				</td>
				
				
				<td height="35" width="40" ></td>
			</tr>
			
			
			<tr><td height="40" colspan="4"></td></tr>
			
			<?php if($strCanCheckInFlag=='1') {?>
			<tr>
				<td height="35" width="30" ></td>
				<td height="35" colspan="2" align="center">
					<?php if($intKeepFlag>0) {?>
					<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
						<tr>
							<td height="35" width="47%" align="right" >
								<div onClick="bmtSaveRoomLock(2)" style="border-radius:5px;width:90%; height:38px; 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>
							
							<td height="35" width="6%"></td>
							
							<td height="35" width="47%" align="center" >
								<div onClick="bmtSaveRoomLock(1)" style="border-radius:5px;width:90%; 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>
						</tr>
					</table>
					<?php } else {?>
						<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
							<tr>
								<td height="35" width="10%"></td>
								
								<td height="35" width="90%">
									<div onClick="bmtSaveRoomLock(1)" style="border-radius:5px;width:96%; 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>
							</tr>
						</table>
					<?php } ?>
				</td>
				
				<td height="35" width="40" ></td>
			</tr>
			<?php }  else { ?>
			<tr>
				<td height="35" width="30" ></td>
				<td height="35" colspan="2" align="center">
					<?php if($intKeepFlag>0) {?>
					<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
						<tr>
							<td height="35" width="47%" align="right" >
								<div style="border-radius:5px;width:90%; height:38px; background-color:#d6e3e7;">
									<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
										<tr><td width="100%" height="100%" align="center">
											<span style="color:#8e8e8e ;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;">解除锁房</span>
										</td></tr>
									</table>
								</div>
							</td>
							
							<td height="35" width="6%"></td>
							
							<td height="35" width="47%" align="center" >
								<div style="border-radius:5px;width:90%; height:38px; background-color:#d6e3e7;">
									<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
										<tr><td width="100%" height="100%" align="center">
											<span style="color:#8e8e8e ;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;">保存锁房</span>
										</td></tr>
									</table>
								</div>
							</td>
						</tr>
					</table>
					<?php } else {?>
						<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
							<tr>
								<td height="35" width="10%"></td>
								
								<td height="35" width="90%">
									<div style="border-radius:5px;width:96%; height:38px; background-color:#d6e3e7;">
										<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
											<tr><td width="100%" height="100%" align="center">
												<span style="color:#8e8e8e ;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;">保存锁房</span>
											</td></tr>
										</table>
									</div>
								</td>
							</tr>
						</table>
					<?php } ?>
				</td>
				
				<td height="35" width="40" ></td>
			</tr>
			<?php } ?>
			
			
			
			
		</table>
		
		
	</article>
		
	
	<script type="text/javascript">

			
		function bmtReturnPage()
		{	
			window.location.href='repRoomView.php';
		};
		
		//1=保存锁房，2=解除锁房
		function bmtSaveRoomLock(intDoID)
		{
			var strchainno='<?php echo $chainno;?>';
			var strroomno='<?php echo $strRoomNo;?>';
			var strRemarks=$("#mytext1").val();
			
			//开始提交PHP页面执行数据库操作流程
			var strurl="rmroomlocksave.php?rmdoid=" + intDoID + "&chainno=" + strchainno + "&romid=" + strroomno + "&remark=" + strRemarks;
			var strret="";
			//用ajax的“同步方式”调用一般处理程序
			$.ajax({
					url: strurl ,
					async: false,//改为同步方式
					type: "POST",
					//data: {doid:1, rmid: "strRoomNo" },
					success: function (RetData) 
					{
						strret = RetData;
					}
			});
				
			//alert(strret);
				
			if(strret.length>2)
			{
				var strSubHead =strret.substr(0,3);
			
				if(strSubHead=="*1*")
				{
					//得到新的数量值
					strurl="repRoomView.php";
					window.location=strurl;
				}
			}
			
		};

		
		 	
	</script>
		
		
</section>

</body>
</html>
