<?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;
	}
	
	
	$strRBListNo=trim($_REQUEST["blistno"]);
	$chainno=$_SESSION["ChainNo"];
	
	if(strlen($strRBListNo)<1)
	{
		$strRBListNo='0';
	}
	
	//1.获取单据资料信息
	$strorderno='';
	$strroomno='';
	$strmanname="";
	$strcustomtype='';
	$strtradetime='2010-01-01';
	$strtrademan=trim($_SESSION['username']);
	
	$strordervipno="";
	$strordercustomno="";
	$strvipname="";
	$strcustomname="";
	$strRoomPrice=0;
	$strcheckintime='';
	$strcheckouttime='';
	$strroomtype='';
	
	$sql=sprintf("SELECT a.Order_No,b.ListNo,b.Man_Name,a.Custom_Type,a.Vip_SubNo,a.Custom_No,Convert(varchar(16),b.SelectRoomTime,120)As CheckInTime,Convert(varchar(16),b.Cancel_Date,120)As CheckOutTime,
					b.RoomPrice,b.Room_No,b.Room_Type
					FROM TR_Order_Inform a,TR_Order_Room_List b WHERE a.Order_No=b.Order_No And b.ListNo=%s And a.Order_State<2 And b.Room_BillState=2",$strRBListNo);

	$result = querySql($sql);		
	if($row = fetch_array($result))
	{
		$strRBListNo=$row['ListNo'];		
		$strorderno=$row['Order_No'];
		$strroomno=$row['Room_No'];
		$strmanname=$row['Man_Name'];
		$strcheckintime=$row['CheckInTime'];
		$strcheckouttime=$row['CheckOutTime'];
		$strcustomtype=$row['Custom_Type'];
		$strordervipno=trim($row['Vip_SubNo']);
		$strordercustomno=trim($row['Custom_No']);
		$strtradetime=$row['ServerTime'];
		$strRoomPrice=$row['RoomPrice'];
		$strRoomPrice=$strRoomPrice+0;
		$strroomtype=$row['Room_Type'];
		
	}
	//释放数据库
	freeResult($result);
		
?>

<!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">
	<script src="jsp4/myform.js"></script>
	<!--<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>-->

 
	<style>
	  header {
		position: fixed;
		top: 0;
		width: 100%;
		background-color: #f8f9fa;
		z-index: 1000;
	  }
	  footer {
		position: fixed;
		bottom: 0;
		width: 100%;
		background-color: #f8f9fa;
		z-index: 1000;
	  }
	  body {
		padding-top: 50px; /* 根据header的高度调整 */
		padding-bottom: 50px; /* 根据footer的高度调整 */
	  }
	  
	  input::placeholder {
			color: #c8c8c8; /* 设置占位符文本颜色为灰色 */
		}
		
	.grid-container {
		  display: grid;
		  grid-template-columns: repeat(3, 1fr); /* 创建三列，每列等宽 */
		  gap: 4px; /* 设置列与列之间的间隔 */
		}
	.span-item1 {
		width: 60px; /* 设置每列的宽度 */
		text-align: left;
	}
	.span-item2 {
		width: 160px; /* 设置每列的宽度 */
		text-align: left;
	}
	.span-item3 {
		width: 60px; /* 设置每列的宽度 */
		text-align: right;
	}
		
	</style>

	
</head>

<script type="text/javascript">
	
	var intNowSelRoomListNo=0;	//当前选择的项目流水号

	function bmtReturnPage()
	{	
		window.location.href='rmroomorder.php?rmid=<?php echo $strroomno;?>#roomlist';
	};
	
</script>
	
<body leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0">

<section data-role="page" id="pagepayfor1" style="background-color:#fff;">		
	<header data-role="header" data-position="fixed" data-tap-toggle="false" style="border-top-width:0px;border-bottom-width:0px;bkc">
        <table width="100%" height="45" border="0" cellpadding="0" cellspacing="0" >
		   	<tr bgcolor="<?php echo WxMainConfig::colHeadBkColor;?>">
				<td height="45" 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="45" align="center" valign="middle">
	                <span style="color:#fff ;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:18px;text-shadow:none;"><?php echo $strroomno.'-换房';?></span>
               	</td>
				
				<td height="45" width="94" align="left" valign="middle">
					<div onClick="bmtSaveRoomItem();" style="border:1px solid #fff; border-radius:14px;width:78px; height:26px; background-color:<?php echo WxMainConfig::colHeadBkColor;?>;">
						<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
							<td height="100%" width="30" align="center" valign="middle">
								<img src="images\icon_save.png" width="14" height="13" border="0" style="margin-top:5px;margin-left:9px;">
							</td>
							<td height="100%" width="6" align="center" valign="middle"></td>
							<td height="100%" align="left" valign="middle">
								<span style="color:#fff ;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;text-shadow:none;">保存</span>
							</td>
						</table>
					</div>
				</td>
		  	</tr>
			
			<tr bgcolor="<?php echo WxMainConfig::colHeadBkColor;?>">
				<td colspan="4" height="15">
					<div style="background:#fff;width:100%;height:18px;padding-top:0px;margin-top:0px; border-radius: 15px 15px 0px 0px;">

					</div>
				</td>
		  	</tr>
		</table>
		
	</header>
		
	<article data-role="none" >
		<table width="100%" height="1" border="0" cellpadding="0" cellspacing="0" bgcolor="#fff">
			
			<tr><td height="6" colspan="5"></td></tr>

			<tr>
				<td height="35" width="30" ></td>
				<td height="35" colspan="3" align="left">
					<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;font-weight: bold;">住客信息</span>
				</td>
				<td height="35" width="30" ></td>
			</tr>
			
			<tr><td height="1" width="30" ></td><td height="1" colspan="3" bgcolor="#F3F3F3"></td><td height="1" width="30" ></td></tr>
			
			<tr>
				<td height="35" width="30" ></td>
				<td height="35" width="60" align="left">
					<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;">名称：</span>
				</td>
				<td height="35" colspan="2" align="left">
					<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;"><?php echo $strmanname;?></span>
				</td>
				<td height="35" width="30" ></td>
			</tr>
			
			<tr><td height="1" width="30" ></td><td height="1" colspan="3" bgcolor="#F3F3F3"></td><td height="1" width="30" ></td></tr>
			
			<tr>
				<td height="35" width="30" ></td>
				<td height="35" width="60" align="left">
					<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;">入住：</span>
				</td>
				<td height="35" colspan="2" align="left">
					<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;"><?php echo $strcheckintime;?></span>
				</td>
				<td height="35" width="30" ></td>
			</tr>
			
			<tr><td height="1" width="30" ></td><td height="1" colspan="3" bgcolor="#F3F3F3"></td><td height="1" width="30" ></td></tr>
			
			<tr>
				<td height="35" width="30" ></td>
				<td height="35" width="60" align="left">
					<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;">预离：</span>
				</td>
				<td height="35" colspan="2" align="left">
					<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;"><?php echo $strcheckouttime;?></span>
				</td>
				<td height="35" width="30" ></td>
			</tr>
			
			<tr><td height="1" width="30" ></td><td height="1" colspan="3" bgcolor="#F3F3F3"></td><td height="1" width="30" ></td></tr>
			
			
			<tr><td height="15" colspan="5"></td></tr>

			<tr>
				<td height="35" width="30" ></td>
				<td height="35" colspan="3" align="left">
					<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;font-weight: bold;">原住房信息</span>
				</td>
				<td height="35" width="30" ></td>
			</tr>
			
			<tr><td height="1" width="30" ></td><td height="1" colspan="3" bgcolor="#F3F3F3"></td><td height="1" width="30" ></td></tr>
			
			<tr>
				<td height="35" width="30" ></td>
				<td height="35" width="60" align="left">
					<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;font-weight: bold;"><?php echo $strroomno;?></span>
				</td>
				<td height="35" width="100" align="right">
					<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;">房价：￥<?php echo $strRoomPrice;?></span>
				</td>
				<td height="35" width="30" ></td>
			</tr>
			
			<tr><td height="1" width="30" ></td><td height="1" colspan="3" bgcolor="#F3F3F3"></td><td height="1" width="30" ></td></tr>
			
			
			<tr>
				<td height="35" width="30" ></td>
				<td height="35" width="60" align="left">
					<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;">房型：</span>
				</td>
				<td height="35" colspan="2" align="left">
					<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;"><?php echo $strroomtype;?></span>
				</td>
				<td height="35" width="30" ></td>
			</tr>
			
			<tr><td height="1" width="30" ></td><td height="1" colspan="3" bgcolor="#F3F3F3"></td><td height="1" width="30" ></td></tr>
			
			
			<tr><td height="15" colspan="5"></td></tr>

			<tr>
				<td height="35" width="30" ></td>
				<td height="35" colspan="3" align="left">
					<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;font-weight: bold;">目标住房信息</span>
				</td>
				<td height="35" width="30" ></td>
			</tr>
			
			<tr><td height="1" width="30" ></td><td height="1" colspan="3" bgcolor="#F3F3F3"></td><td height="1" width="30" ></td></tr>
			
			<tr>
				<td height="35" width="30" ></td>
				<td height="35" width="60" align="left">
					<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 id="labNewRoomNo" style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;font-weight: bold;"></span>
				</td>
				<td height="35" width="100" align="right">
					<div id="openModalBtn"  style="border-radius:5px;width:80px; height:27px; background:linear-gradient(225deg, #379ffb 45%, #24d7ff 100%);">
						<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:14px;text-shadow:none;">选择房号</span>
							</td></tr>
						</table>
					</div>
				</td>
				<td height="35" width="30" ></td>
			</tr>
			
			<tr><td height="1" width="30" ></td><td height="1" colspan="3" bgcolor="#F3F3F3"></td><td height="1" width="30" ></td></tr>
			
			
			<tr>
				<td height="35" width="30" ></td>
				<td height="35" width="60" align="left">
					<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;">房型：</span>
				</td>
				<td height="35" colspan="2" align="left">
					<span id="labNewRoomType" style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;"></span>
				</td>
				<td height="35" width="30" ></td>
			</tr>
			
			<tr><td height="1" width="30" ></td><td height="1" colspan="3" bgcolor="#F3F3F3"></td><td height="1" width="30" ></td></tr>
			
			
			<tr>
				<td height="35" width="30" ></td>
				<td height="35" width="60" align="left">
					<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:15px;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:15px;">
						<input id="mytext1" name="mytext1" value='' type="number" placeholder="实际销售价" data-mini="true"  autocomplete="off"  style="border: none;width:92%;height:28px;"/>
					</span>
				</td>
				<td height="35" width="100" align="right">
					<span id="labNewRoomPriceMS" style="color: #626262;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;"></span>
				</td>
			</tr>
			
			<tr><td height="1" width="30" ></td><td height="1" colspan="3" bgcolor="#F3F3F3"></td><td height="1" width="30" ></td></tr>
			
			
			
			<tr>
				<td height="35" width="30" ></td>
				<td height="35" width="60" align="left">
					<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:15px;text-shadow:none;">说明：</span>
				</td>
				<td height="35" colspan="2" align="left">
					<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:15px;">
						<input id="mytext2" name="mytext2" value='' type="text" placeholder="备注说明" data-mini="true"  autocomplete="off"  style="border: none;width:99%;height:28px;"/>
					</span>
				</td>
			</tr>
			
			<tr><td height="1" width="30" ></td><td height="1" colspan="3" bgcolor="#F3F3F3"></td><td height="1" width="30" ></td></tr>
			
			

			
			
			
	<!-- 弹出窗体结构 -->
    <div id="modalOverlay" class="modal-overlay">
        <div id="modalContent" class="modal-content">
            <div class="modal-header">
                <span style="color: #fff;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;font-weight: bold;">空净房信息</span>
                <button id="closeModalBtn" class="close-btn"><i class="fas fa-times">X</i></button>
            </div>
            <div class="modal-body">
				<div class="grid-container" style="height:35px;width:100%;border-bottom: 1px solid #deecfb; padding-top:6px;">
					<span class="span-item1" style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:15px;text-shadow:none;font-weight: bold;">房号</span>
					<span class="span-item2" style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:15px;text-shadow:none;font-weight: bold;">房型</span>
					<span class="span-item3" style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:15px;text-shadow:none;font-weight: bold;">房价</span>
				</div>
				<?php							
					$intRowID=0;
					$strSubRListNo=0;
					$strSubRoomNo="";
					$strSubRoomType="";
					$fltSubRoomPrice=0;
					$fltSubRoomPriceMS=0;
					
					$sql=sprintf("SELECT a.ListNo,a.Room_No,b.Room_Type,b.Room_Price,b.Room_PriceS FROM TR_Room_Inform a,TR_Room_Type b WHERE a.TypeListNo=b.ListNo 
								And b.Chain_No='%s' And a.Room_State=0 And a.Dirty_Flag=0 ORDER BY a.Room_No ASC",$chainno);
					$result = querySql($sql);
												
					while($row = fetch_array($result))
					{
						$intRowID=$intRowID + 1;
						$strSubRListNo = $row['ListNo']; 
						$strSubRoomNo = $row['Room_No']; 
						$strSubRoomType = $row['Room_Type']; 
						$fltSubRoomPrice = $row['Room_PriceS']; 
						$fltSubRoomPriceMS = $row['Room_Price']; 
						
						$fltSubRoomPrice=$fltSubRoomPrice+0;
						$fltSubRoomPriceMS=$fltSubRoomPriceMS+0;
						
						$colTextColor='#000';
						if($strSubRoomType==$strroomtype) 
						{ 
							$colTextColor='#5762f7';
						}
				?>
				<div class="grid-container" onClick="bntSelectItem(<?php echo $strSubRListNo;?>,'<?php echo $strSubRoomNo;?>','<?php echo $strSubRoomType;?>',<?php echo $fltSubRoomPrice;?>,<?php echo $fltSubRoomPriceMS;?>)" style="height:35px;width:100%;border-bottom: 1px solid #deecfb; padding-top:6px;">
					<span class="span-item1" style="color: <?php echo $colTextColor; ?>;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:15px;text-shadow:none;font-weight: bold;"><?php echo $strSubRoomNo;?></span>
					<span class="span-item2" style="color: <?php echo $colTextColor; ?>;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:15px;text-shadow:none;"><?php echo $strSubRoomType;?></span>
					<span class="span-item3" style="color: <?php echo $colTextColor; ?>;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:15px;text-shadow:none;"><?php echo $fltSubRoomPrice;?></span>
				</div>
				
				<?php
					}
					//释放数据库
					freeResult($result);
					closeDb();
				?>
                
            </div>
			<!--
            <div class="modal-footer">
                <button class="btn-secondary" id="exportBtn">
                    <i class="fas fa-download"> 导出数据
                </button>
                <button class="btn-primary">
                    <i class="fas fa-plus"></i> 添加员工
                </button>
            </div>
			-->
        </div>
    </div>
			
			
			
			<tr><td height="2" colspan="5"></td></tr>
			
			
		</table>
				
	</article>
		
	
	<script type="text/javascript">
		
		//选择一个项目
		function bntSelectItem(lngRListNo,strRoomNo,strRoomType,fltItemPrice,fltItemPriceMS)
		{	
			intNowSelRoomListNo=lngRListNo;	//记录后，点保存时用到
			
			var labSpan1=document.getElementById("labNewRoomNo");
			var labSpan2=document.getElementById("labNewRoomType");
			var labSpan3=document.getElementById("labNewRoomPriceMS");
						
			labSpan1.textContent=strRoomNo;
			labSpan2.textContent=strRoomType;
			labSpan3.textContent='门市价:￥' + fltItemPriceMS;
			
			var fltOldPrice=<?php echo $strRoomPrice;?>;
			var strOldRoomType='<?php echo $strroomtype;?>';
			
			//判断是否更换了房型
			if(strRoomType==strOldRoomType)
			{
				document.getElementById('mytext1').value = fltOldPrice;
			}
			else
			{
				document.getElementById('mytext1').value = fltItemPrice;
			}
						
			//关闭界面
			$('#closeModalBtn').click();
			
			document.getElementById("mytext1").focus();
		};
						
		//保存账目
		function bmtSaveRoomItem()
		{
			var strNewRoomPrice=$("#mytext1").val();
			var strRoomText=$("#mytext2").val();
			
			strRoomText=strRoomText.trim();

			if(strNewRoomPrice.length<1)
			{
				strNewRoomPrice=0;
			}
			var strNewRoomPrice=strNewRoomPrice*1;

			var labSpan1=document.getElementById("labNewRoomNo");						
			var strRoomNo1='<?php echo $strroomno;?>';
			var strRoomNo2=labSpan1.textContent;
			
			if(strRoomNo1==strRoomNo2)
			{
				alert("换房前后房号不能一样！");
				return;
			}
			
			
			//var strmsg=strRoomNo1 + '->' + strRoomNo2;
			//alert(strmsg);
			//return;
			
			//将数据封包成JSON
			const jsondata = {
					chainno: '<?php echo $chainno;?>',
					rblistno: <?php echo $strRBListNo;?>,
					rmlistno: intNowSelRoomListNo,
					newprice: strNewRoomPrice,
					changetxt: strRoomText
					};
					
			//用ajax的“同步方式”调用一般处理程序
			var strret='';
			$.ajax({
					url: "rmroomchangesave.php",
					async: false,//改为同步方式
					type: "POST",
					data: jsondata,
					success: function (RetData) 
					{
						strret = RetData;
					}
				});
			
			//alert(strret);
				
			if(strret.length>2)
			{
				var strSubHead =strret.substr(0,3);
			
				if(strSubHead=="*1*")
				{
					//成功
					//window.location.href='repRoomView.php';
					window.location.href='rmroomorder.php?rmid=' + strRoomNo2 + '#roomlist';
				}
				else if(strSubHead=="*2*")
				{
					//该客房为非在住状态，不能继续换房!
					alert("该客房为非在住状态，不能继续换房!");
				}
				else if(strSubHead=="*3*")
				{
					alert("目标房间已被占用，不能继续换房!");
				}
				else
				{
					alert("保存换房操作失败!");
				}
			}
			
			
		};
		
	</script>
		
		
</section>

</body>
</html>
