<?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;
	}
	header("Content-type: text/html; charset=gb2312"); 
	
				
				$chainno=$_SESSION["ChainNo"];
				$roomno=$_REQUEST["rmid"];;
				
				$strorderno="";
				$strcustomtype="";
				$strmanname="";
				$strordervipno="";
				$strordercustomno="";
				$strcheckintime="";
				$strselectroomtime="";
				$strcanceldate="";
				$strblistno="0";
				$strvipname="";
				$strcustomname="";
				$strroomtype="";
				
				//开始去房间状态数量
				$sql=sprintf("SELECT a.Order_No,b.ListNo,b.Man_Name,a.Custom_Type,a.Vip_SubNo,a.Custom_No,Convert(varchar(16),a.CheckInTime,120)As CheckInT,
								Convert(varchar(16),b.SelectRoomTime,120)As SelectRoomT,Convert(varchar(16),b.Cancel_Date,120)As CancelRoomT,b.Room_Type
								FROM TR_Order_Inform a,TR_Order_Room_List b WHERE a.Order_No=b.Order_No And a.Chain_No='%s' 
								And a.Order_State=1 And b.Room_BillState=2 And b.Room_No='%s'",$chainno,$roomno);

				$result = querySql($sql);		
				$row = fetch_array($result);
				
				$strblistno=$row['ListNo'];		
				$strorderno=$row['Order_No'];
				$strmanname=$row['Man_Name'];
				$strcustomtype=$row['Custom_Type'];
				$strordervipno=trim($row['Vip_SubNo']);
				$strordercustomno=trim($row['Custom_No']);
				$strcheckintime=$row['CheckInT'];
				$strselectroomtime=$row['SelectRoomT'];
				$strcanceldate=$row['CancelRoomT'];
				$strroomtype=$row['Room_Type'];
				//以下开始显示数据							
				
				//释放数据库
				freeResult($result);
				
				//判断是否有会员和协议客户
				if(strlen($strordervipno)>0)
				{
					$sql=sprintf("SELECT Sub_Name FROM VIP_Item WHERE Sub_No='%s'",$strordervipno);
					$result = querySql($sql);
					$row = fetch_array($result);
					$strvipname=$row['Sub_Name'];
					$strordervipno=$strordervipno."|".$strvipname;
					freeResult($result);
				}
				if(strlen($strordercustomno)>0)
				{
					$sql=sprintf("SELECT CustomName FROM TR_Custom_Inform WHERE Chain_No='%s' And CustomNo='%s'",$chainno,$strordercustomno);
					$result = querySql($sql);
					$row = fetch_array($result);
					$strcustomname=$row['CustomName'];
					$strordercustomno=$strordercustomno."|".$strcustomname;
					freeResult($result);
				}
				//
				$fltSumValue=0;
				$fltSumPayFor=0;
				$fltShouldPay=0;
				
				$sql=sprintf("SELECT SUM(Item_Value)AS SumValue,SUM(PayFor_Value)AS SumPay FROM TR_Consume_List WHERE Order_No='%s'",$strorderno);
				$result = querySql($sql);
				$row = fetch_array($result);
				$fltSumValue=$row['SumValue'];
				$fltSumPayFor=$row['SumPay'];
				freeResult($result);
				
				$fltShouldPay=$fltSumValue-$fltSumPayFor;
				//closeDb();
		
?>
<!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>客房云点通</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>
</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="roomorder">
	<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="45" align="right">
					<a href="repRoomView.php" data-role="button" data-icon="carat-l" data-iconpos="notext" rel="external"></a>
				</td>
				<td height="45" width="30"></td>
				<td height="45" align="center">宾客帐单</td>
				<td height="45" width="90" align="left">
					<div id="bmtSendOk" onClick="bmtSendOkClick()" style="border-radius:3px; width:80px; height:30px; background-color:#D7AA28;opacity:0.5;">
						<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
							<tr><td width="100%" height="100%" align="center">
								<span style="color:#E9DFE0 ;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:14px;text-shadow:none;">退房结帐</span>                            	
							</td></tr>
						</table>
					</div>
				</td>
			</tr>
		</table>
	</header>
	
	<article data-role="none">
		
		<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
			
				
			<tr bgcolor="#fff">
				<td height="35" width="10"></td>
				<td height="35" align="left">
					<table width="100%" border="0" cellpadding="0" cellspacing="0">
						<tr>
							<td height="35" width="55%">
								<span style="color: #000000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:14px;">单号：<?php echo $strorderno;?></span>
							</td>
							<td height="35" width="45%" align="right">
								<span style="color: #000000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:14px;">客源：<?php echo $strcustomtype;?></span>
							</td>
						</tr>
					</table>
				</td>
				<td height="35" width="10"></td>
			</tr>
			
			<tr><td height="1" colspan="3" align="left" bgcolor="#F2E2E2"></td></tr>
			
			<tr>
				<td height="4" width="10"></td>
				<td height="4" align="left"></td>
				<td height="4" width="10"></td>
			</tr>

			<tr>
				<td height="25" width="10"></td>
				<td height="25" align="left">
					<table width="100%" border="0" cellpadding="0" cellspacing="0">
						<tr>
							<td height="20" width="55%">
								<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">宾客：<?php echo $strmanname;?></span>
							</td>
							<td height="20" width="45%" align="left">
								<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">房号：<?php echo $roomno;?></span>
							</td>
						</tr>
						<tr>
							<td height="20" width="55%">
								<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">登记：<?php echo $strcheckintime;?></span>
							</td>
							<td height="20" width="45%" align="left">
								<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">房型：<?php echo $strroomtype;?></span>
							</td>
						</tr>
						<tr>
							<td height="20" width="55%">
								<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">入住：<?php echo $strselectroomtime;?></span>
							</td>
							<td height="20" width="45%" align="left">
								<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">预离：<?php echo $strcanceldate;?></span>
							</td>
						</tr>
						
						<?php 
							if(strlen($strordervipno)>0)
							{
						?>
							<tr>
								<td height="20" colspan="2">
									<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">会员：<?php echo $strordervipno;?></span>
								</td>
							</tr>
						<?php
							}						
						?>
						
						<?php 
							if(strlen($strordercustomno)>0)
							{
						?>
							<tr>
								<td height="20" colspan="2">
									<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">协议：<?php echo $strordercustomno;?></span>
								</td>
							</tr>
						<?php
							}						
						?>
						
						<tr><td height="3" colspan="2" align="left" ></td></tr>
						<tr><td height="1" colspan="2" align="left" bgcolor="#F2E2E2"></td></tr>
						<tr><td height="3" colspan="2" align="left" ></td></tr>
						
						<tr><td height="25" colspan="2" align="left" >
							<table width="100%" border="0" cellpadding="0" cellspacing="0">
								<tr>
									<td height="25" width="30%" align="left">
										<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">消费：<?php echo $fltSumValue;?></span>
									</td>
									<td height="25" align="center">
										<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">已付款：<?php echo $fltSumPayFor;?></span>
									</td>
									<td height="25" width="30%" align="right">
										<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">
										<?php if($fltShouldPay>0)
											{
												echo "应付：￥".$fltShouldPay;
											}else {
												echo "应退：￥".abs($fltShouldPay);
											}
										?>
										</span>
									</td>
								</tr>
							</table>
						</td></tr>
					</table>
				</td>
				<td height="25" width="10"></td>
			</tr>
			
					
			<tr>
				<td height="8" width="10"></td>
				<td height="8" align="left"></td>
				<td height="8" width="10"></td>
			</tr>
			
			<tr><td height="1" align="left" bgcolor="#F2E2E2" colspan="3"></td></tr>
			<tr>
				<td height="25" align="left" colspan="3">
					<table width="100%" border="0" cellpadding="0" cellspacing="0">
						<tr bgcolor="#FBF0F0">
							<td height="30" width="10"></td>
							<td height="30" width="120">
								<span style="color: #B69021;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">项目名称</span>
							</td>
							<td height="30" align="left">
								<span style="color: #B69021;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">付款方式</span>
							</td>
							<td height="30" width="100" align="right">
								<span style="color: #B69021;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">付款金额</span>
							</td>
							<td height="30" width="10"></td>
						</tr>
						<tr><td height="1" colspan="5"  bgcolor="#F2E2E2"></td></tr>
						
						<?php 
							//得到付款明晰信息
							$strItemName="";
							$strPayForType="";
							$fltItemValue=0;
							$fltSumValue=0;
							
							$sql=sprintf("SELECT Item_Name,PayFor_Type,Sum(PayFor_Value)AS SumPayFor FROM TR_Consume_List WHERE Order_No='%s' And PayFor_Value<>0
											GROUP BY Item_Name,PayFor_Type Order By Item_Name ASC,PayFor_Type ASC",$strorderno);

							$result = querySql($sql);		
							while($row = fetch_array($result))
							{	
								$strItemName=$row['Item_Name'];							
								$strPayForType=$row['PayFor_Type'];
								$fltItemValue=$row['SumPayFor'];
								$fltSumValue=$fltSumValue + $fltItemValue;
								
								//以下开始显示数据							
						?>
							<tr>
								<td height="30" width="10"></td>
								<td height="20" width="120">
									<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;"><?php echo $strItemName;?></span>
								</td>
								<td height="20" align="left">
									<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;"><?php echo $strPayForType;?></span>
								</td>
								<td height="20" width="100" align="right">
									<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;"><?php echo $fltItemValue;?></span>
								</td>
								<td height="30" width="10"></td>
							</tr>
						<?php
							}
							//释放数据库
							freeResult($result);
						?>
												
						<tr>
							<td height="1" width="10"></td>
							<td height="1" colspan="3"  bgcolor="#F2E2E2"></td>
							<td height="1" width="10"></td>
						</tr>
						<tr>
							<td height="30" width="10"></td>
							<td height="20" width="120">
								<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">Σ付款合计</span>
							</td>
							<td height="20" align="left">
								<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;"></span>
							</td>
							<td height="20" width="100" align="right">
								<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">￥<?php echo $fltSumValue;?></span>
							</td>
							<td height="30" width="10"></td>
						</tr>
					</table>
				</td>
			</tr>
			
			<tr>
				<td height="4" width="10"></td>
				<td height="4" align="left"></td>
				<td height="4" width="10"></td>
			</tr>
			
			<tr><td height="1" align="left" bgcolor="#F2E2E2" colspan="3"></td></tr>
			
			<tr>
				<td height="25" align="left" colspan="3">
					<table width="100%" border="0" cellpadding="0" cellspacing="0">
						<tr bgcolor="#FBF0F0">
							<td height="30" width="10"></td>
							<td height="30" width="120">
								<span style="color: #B69021;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">项目名称</span>
							</td>
							<td height="30" align="left">
								<span style="color: #B69021;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">项目类型</span>
							</td>
							<td height="30" width="100" align="right">
								<span style="color: #B69021;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">项目金额</span>
							</td>
							<td height="30" width="10"></td>
						</tr>
						<tr><td height="1" colspan="5"  bgcolor="#F2E2E2"></td></tr>
						
						<?php 
							//得到付款明晰信息
							$strItemName="";
							$strPayForType="";
							$fltItemValue=0;
							$fltSumValue=0;
							
							$sql=sprintf("SELECT Item_Type,Item_Name,Sum(Item_Value)AS SumPayFor FROM TR_Consume_List WHERE Order_No='%s' And Item_Value<>0
											GROUP BY Item_Type,Item_Name Order By Item_Type ASC,Item_Name ASC",$strorderno);

							$result = querySql($sql);		
							while($row = fetch_array($result))
							{	
								$strItemName=$row['Item_Name'];							
								$strPayForType=$row['Item_Type'];
								$fltItemValue=$row['SumPayFor'];
								$fltSumValue=$fltSumValue + $fltItemValue;
								
								//以下开始显示数据							
						?>
							<tr>
								<td height="30" width="10"></td>
								<td height="20" width="120">
									<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;"><?php echo $strItemName;?></span>
								</td>
								<td height="20" align="left">
									<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;"><?php echo $strPayForType;?></span>
								</td>
								<td height="20" width="100" align="right">
									<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;"><?php echo $fltItemValue;?></span>
								</td>
								<td height="30" width="10"></td>
							</tr>
						<?php
							}
							//释放数据库
							freeResult($result);
						?>
						
						<tr>
							<td height="1" width="10"></td>
							<td height="1" colspan="3"  bgcolor="#F2E2E2"></td>
							<td height="1" width="10"></td>
						</tr>
						<tr>
							<td height="30" width="10"></td>
							<td height="20" width="120">
								<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">Σ费用合计</span>
							</td>
							<td height="20" align="left">
								<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;"></span>
							</td>
							<td height="20" width="100" align="right">
								<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">￥<?php echo $fltSumValue;?></span>
							</td>
							<td height="30" width="10"></td>
						</tr>
					</table>
				</td>
			</tr>
			
			<tr>
				<td height="5" width="10"></td>
				<td height="5" align="left"></td>
				<td height="5" width="10"></td>
			</tr>
			
			<tr>
				<td height="1" width="10" bgcolor="#F2E2E2"></td>
				<td height="1" align="left" bgcolor="#F2E2E2"></td>
				<td height="1" width="10" bgcolor="#F2E2E2"></td>
			</tr>
			
					
			
			
		</table>
		
		<?php closeDb(); ?>
	</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="33%">					
					<a class="ui-btn ui-icon-bars ui-btn-icon-top" target="_parent" href="#" style="width:100%;height:10px;margin:0px auto 0px auto;color:#301972">宾客帐单</a>
				</td>
				
				<td width="34%">					
					<a class="ui-btn ui-icon-tag ui-btn-icon-top" target="_parent" href="#roomlist" style="width:100%;height:10px;margin:0px auto 0px auto;color:#666666">同行房</a>
				</td>
				
				<td width="33%">					
					<a class="ui-btn ui-icon-bullets ui-btn-icon-top" target="_parent" href="#dubtlist" style="width:100%;height:10px;margin:0px auto 0px auto;color:#666666">帐目明细</a>
				</td>
				
			</tr>
		</table>						
	</footer>
</section>



<section data-role="page" id="roomlist">
	<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="45" align="right">
					<a href="repRoomView.php" data-role="button" data-icon="carat-l" data-iconpos="notext" rel="external"></a>
				</td>
				<td height="45" width="30"></td>
				<td height="45" align="center">同行房信息</td>
				<td height="45" width="90" align="left">
					<div id="bmtSendOk" onClick="bmtSendOkClick()" style="border-radius:3px; width:80px; height:30px; background-color:#D7AA28;opacity:0.5;">
						<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
							<tr><td width="100%" height="100%" align="center">
								<span style="color:#E9DFE0 ;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:14px;text-shadow:none;">退房结帐</span>                            	
							</td></tr>
						</table>
					</div>
				</td>
			</tr>
		</table>
	</header>
	
	<article data-role="none">
		<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
			
			<tr>
				<td height="30" width="10"></td>
				<td height="30" align="left">
					<?php
						$intCheckInCount=0;
						$intCheckOutCount=0;
						
						$sql=sprintf("SELECT SUM(InCount)AS InCount,SUM(OutCount)AS OutCount FROM(
							SELECT COUNT(ListNo)AS InCount,0 AS OutCount FROM TR_Order_Room_List WHERE Order_No='%s' And Room_BillState=2
							UNION SELECT 0 AS InCount,COUNT(ListNo)AS OutCount FROM TR_Order_Room_List WHERE Order_No='%s' And Room_BillState=3)t",$strorderno,$strorderno);
						
						$result = querySql($sql);		
						$row = fetch_array($result);
						
						$intCheckInCount=$row['InCount'];
						$intCheckOutCount=$row['OutCount'];
						freeResult($result);
					?>
					<table width="100%" border="0" cellpadding="0" cellspacing="0">
						<tr>
							<td height="35" width="55%">
								<span style="color: #000000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:14px;">Σ同行关联房</span>
							</td>
							<td height="35" width="45%">
								<span style="color: #000000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:14px;">在住 <?php echo $intCheckInCount;?> 间，已退 <?php echo $intCheckOutCount;?> 间</span>
							</td>
						</tr>
					</table>
				</td>
				<td height="30" width="10"></td>
			</tr>
			
			<tr><td height="1" colspan="3" align="left" bgcolor="#F2E2E2"></td></tr>
			
			<tr>
				<td height="25" align="left" colspan="3">
					<table width="100%" border="0" cellpadding="0" cellspacing="0">
						<tr bgcolor="#FBF0F0">
							<td height="30" width="10"></td>
							<td height="30" width="55">
								<span style="color: #B69021;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">房号</span>
							</td>
							<td height="30" align="left">
								<span style="color: #B69021;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">姓名</span>
							</td>
							<td height="30" width="50" align="left">
								<span style="color: #B69021;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">房价</span>
							</td>
							<td height="30" width="40" align="left">
								<span style="color: #B69021;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">方式</span>
							</td>
							<td height="30" width="40" align="center">
								<span style="color: #B69021;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">天数</span>
							</td>
							<td height="30" width="40" align="right">
								<span style="color: #B69021;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">状态</span>
							</td>
							<td height="30" width="10"></td>
						</tr>
						<tr><td height="1" colspan="8"  bgcolor="#F2E2E2"></td></tr>
						
						<?php 
							//得到付款明晰信息
							$strSelManName="";
							$strselroomno="";
							$strselroomtype="";
							$fltselroomprice=0;
							$strselecttime="";
							$strcanceltime="";
							$intTemp=0;
							$strTemp="";
							$strSelRemarks="";
							$intSelDays=0;
							$strBillState="";
							$strRoomBorrowTemp='';
							
							$sql=sprintf("SELECT Room_No,Man_Name,Room_Type,RoomPrice,Convert(varchar(16),SelectRoomTime,120)As SelectRoomT,
											Convert(varchar(16),Cancel_Date,120)As CancelRoomT,Sited_Days,Sited_LongFlag,Sited_TimeFlag,RoomBorrowTemp,
											Sited_FreeFlag,Remarks,Room_BillState FROM TR_Order_Room_List WHERE Order_No='%s' And (Room_BillState=2 OR Room_BillState=3)",$strorderno);
							$result = querySql($sql);		
							while($row = fetch_array($result))
							{	
								$strSelManName=$row['Man_Name'];
								$strselroomno=$row['Room_No'];
								$strselroomtype=$row['Room_Type'];
								$fltselroomprice=$row['RoomPrice'];
								$strselecttime=$row['SelectRoomT'];
								$strcanceltime=$row['CancelRoomT'];
								$strSelRemarks=trim($row['Remarks']);
								$intSelDays=$row['Sited_Days'];
								
								$strRoomBorrowTemp=trim($row['RoomBorrowTemp']);
								
								$strTemp="日租";
								$intTemp=$row['Sited_LongFlag'];
								if($intTemp>0)
								{
									$strTemp="长包";
								}
								$intTemp=$row['Sited_TimeFlag'];
								if($intTemp>0)
								{
									$strTemp="钟点";
								}
								$intTemp=$row['Sited_FreeFlag'];
								if($intTemp>0)
								{
									$strTemp="免费";
								}
								$strBillState="在住";
								$intTemp=$row['Room_BillState'];
								//0预排,1预订,2入住,3退房,4取消
								if($intTemp==3)
								{
									$strBillState="退房";
								}
								//以下开始显示数据	 						
						?>
							<?php if($strBillState=="退房")
								{
							?>
								<tr bgcolor="#FAF5E6">
							<?php } else { ?>
								<tr>
							<?php
								}
							?>
								<td height="20" width="10"></td>
								<td height="20" width="55">
									<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;"><?php echo $strselroomno;?></span>
								</td>
								<td height="20" align="left">
									<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;"><?php echo $strSelManName;?></span>
								</td>
								<td height="20" width="50" align="left">
									<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;"><?php echo $fltselroomprice;?></span>
								</td>
								<td height="20" width="40" align="left">
									<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;"><?php echo $strTemp;?></span>
								</td>
								<td height="20" width="40" align="center">
									<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;"><?php echo $intSelDays;?></span>
								</td>
								<td height="20" width="40" align="right">
									<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;"><?php echo $strBillState;?></span>
								</td>
								<td height="20" width="10"></td>
							</tr>
							
							<tr>
								<td height="20" width="10"></td>
								<td height="20" colspan="6">
									<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">
									<?php echo "房型：".$strselroomtype;?>
									</span>
								</td>
								<td height="20" width="10"></td>
							</tr>
							
							<!--显示入住时间和天数-->
							<?php if($strBillState=="退房")
								{
							?>
								<tr bgcolor="#FAF5E6">
							<?php } else { ?>
								<tr>
							<?php
								}
							?>
								<td height="20" width="10"></td>
								<td height="20" colspan="6">
									<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">
									<?php echo "抵离：".$strselecttime."&nbsp;&nbsp;至&nbsp;&nbsp;".$strcanceltime;?>
									</span>
								</td>
								<td height="20" width="10"></td>
							</tr>
							
							<?php if(strlen($strSelRemarks)>1)
								{
							?>
									<?php if($strBillState=="退房")
										{
									?>
										<tr bgcolor="#FAF5E6">
									<?php } else { ?>
										<tr>
									<?php
										}
									?>
										<td height="20" width="10"></td>
										<td height="20" colspan="6">
											<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">
											<?php echo "备注：".$strSelRemarks;?>
											</span>
										</td>
										<td height="20" width="10"></td>
									</tr>
							<?php } ?>
							
							<?php if(strlen($strRoomBorrowTemp)>1)
								{
							?>
									<tr>
										<td height="20" width="10"></td>
										<td height="20" colspan="6">
											<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">
											<?php echo "提醒：".$strRoomBorrowTemp;?>
											</span>
										</td>
										<td height="20" width="10"></td>
									</tr>
							<?php } ?>
							
							<tr><td height="3" colspan="8"></td></tr>
							<tr><td height="1" colspan="8"  bgcolor="#F2E2E2"></td></tr>
							<tr><td height="3" colspan="8"></td></tr>
						<?php
							}
							//释放数据库
							freeResult($result);
						?>
						
						
						
					</table>
				</td>
			</tr>
			
			<tr><td height="5" width="5" colspan="3"></td></tr>
			
		</table>
		
		<?php closeDb(); ?>
	</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="33%">					
					<a class="ui-btn ui-icon-bars ui-btn-icon-top" target="_parent" href="#roomorder" style="width:100%;height:10px;margin:0px auto 0px auto;color:#666666">宾客帐单</a>
				</td>
				
				<td width="34%">					
					<a class="ui-btn ui-icon-tag ui-btn-icon-top" target="_parent" href="#" style="width:100%;height:10px;margin:0px auto 0px auto;color:#301972">同行房</a>
				</td>
				
				<td width="33%">					
					<a class="ui-btn ui-icon-bullets ui-btn-icon-top" target="_parent" href="#dubtlist" style="width:100%;height:10px;margin:0px auto 0px auto;color:#666666">帐目明细</a>
				</td>
				
			</tr>
		</table>						
	</footer>
</section>





<section data-role="page" id="dubtlist">
	<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="45" align="right">
					<a href="repRoomView.php" data-role="button" data-icon="carat-l" data-iconpos="notext" rel="external"></a>
				</td>
				<td height="45" width="30"></td>
				<td height="45" align="center">帐目明细</td>
				<td height="45" width="90" align="left">
					<div id="bmtSendOk" onClick="bmtSendOkClick()" style="border-radius:3px; width:80px; height:30px; background-color:#D7AA28;opacity:0.5;">
						<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
							<tr><td width="100%" height="100%" align="center">
								<span style="color:#E9DFE0 ;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:14px;text-shadow:none;">退房结帐</span>                            	
							</td></tr>
						</table>
					</div>
				</td>
			</tr>
		</table>
	</header>
	
	<article data-role="none">
		<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
			
			<tr><td height="1" width="10" colspan="3"></td></tr>
			
			<tr>
				<td height="30" width="5"></td>
				<td height="30" align="left">
					<table width="100%" border="0" cellpadding="0" cellspacing="0">
						<tr>
							<td height="35">
								<span style="color: #000000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:14px;">Σ帐目明细</span>
							</td>
							<td height="35" width="95" align="left">
								<span style="color: #000000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">消费：<?php echo $fltSumValue;?></span>
							</td>
							<td height="35" width="95" align="right">
								<span style="color: #000000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">付款：<?php echo $fltSumPayFor;?></span>
							</td>
							<td height="35" width="4" align="right"></td>
						</tr>
					</table>
				</td>
				<td height="30" width="5"></td>
			</tr>
			
			<tr><td height="1" colspan="3" align="left" bgcolor="#F2E2E2"></td></tr>
						
			<tr>
				<td height="25" align="left" colspan="3">
					<table width="100%" border="0" cellpadding="0" cellspacing="0">
						<tr bgcolor="#FBF0F0">
							<td height="25" width="10"></td>
							<td height="30" width="60">
								<span style="color: #B69021;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">房号</span>
							</td>
							<td height="30" align="left">
								<span style="color: #B69021;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">账目名称</span>
							</td>
							<td height="30" width="70" align="right">
								<span style="color: #B69021;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">费用金额</span>
							</td>
							<td height="30" width="70" align="right">
								<span style="color: #B69021;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">付款金额</span>
							</td>
							<td height="25" width="10"></td>
						</tr>
						<tr><td height="1" colspan="6"  bgcolor="#F2E2E2"></td></tr>
						
						<?php 
							//得到付款明晰信息
							$strSelRoomNo="";
							$strSelTradeTime="";
							$strSelItemName="";
							$fltItemValue=0;
							$fltPayForVal=0;
							$strPayForType="";
							$strSelRemarks="";
							
							$fltSumValue=0;
							$fltSumPayFor=0;
							
							$sql=sprintf("SELECT Room_No,Convert(varchar(16),TradeTime,120)As TradeTime,Item_Name,Item_Value,PayFor_Value,PayFor_Type,Remarks FROM TR_Consume_List
										WHERE Order_No='%s' Order By Room_No ASC,TradeTime ASC",$strorderno);
							
							$result = querySql($sql);		
							while($row = fetch_array($result))
							{	
								$strSelRoomNo=$row['Room_No'];
								$strSelTradeTime=$row['TradeTime'];
								$strSelItemName=$row['Item_Name'];
								$fltItemValue=$row['Item_Value'];
								$fltPayForVal=$row['PayFor_Value'];
								$strPayForType=$row['PayFor_Type'];
								$strSelRemarks=$row['Remarks'];
								
								$fltSumValue=$fltSumValue + $fltItemValue;
								$fltSumPayFor=$fltSumPayFor + $fltPayForVal;
								//以下开始显示数据	 						
						?>
						<!--显示数据信息-->
						<tr>
							<td height="20" width="10"></td>
							<td height="20" width="60">
								<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;"><?php echo $strSelRoomNo;?></span>
							</td>
							<td height="20" align="left">
								<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;"><?php echo $strSelItemName;?></span>
							</td>
							<td height="20" width="70" align="right">
								<?php if($fltItemValue==0) {?>
									<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;"></span>
								<?php } else {?>
									<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;"><?php echo $fltItemValue;?></span>
								<?php } ?>
							</td>
							<td height="20" width="70" align="right">
								<?php if($fltPayForVal==0) {?>
									<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;"></span>
								<?php } else {?>
									<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;"><?php echo $fltPayForVal;?></span>
								<?php } ?>
							</td>
							<td height="20" width="10"></td>
						</tr>
						<!--显示入住时间和天数-->
						<tr>
							<td height="20" width="10"></td>
							<td height="20" colspan="4">
								<table width="100%" border="0" cellpadding="0" cellspacing="0">
									<tr>
										<td height="20" width="180" align="left">
											<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">
												<?php echo "入帐：".$strSelTradeTime;?>
											</span>
										</td>
										<td height="20" align="left">
											<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">
												<?php if($fltPayForVal==0) 
												{ 
													echo "";
												}
												else
												{
													echo "付款方式：".$strPayForType;
												}
												?>												
											</span>
										</td>
									</tr>
								</table>
								
							</td>
							<td height="20" width="10"></td>
						</tr>
						
						<tr>
							<td height="20" width="10"></td>
							<td height="20" colspan="4">
								<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">
									<?php echo "备注：".$strSelRemarks;?>
								</span>								
							</td>
							<td height="20" width="10"></td>
						</tr>
						<tr>
							<td height="1" width="10"></td>
							<td height="1" colspan="4"  bgcolor="#F2E2E2"></td>
							<td height="1" width="10"></td>
						</tr>
						
						<?php
							}
							//释放数据库
							freeResult($result);
						?>
						
						<tr>
							<td height="20" width="10"></td>
							<td height="30" width="60">
								<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;">Σ合计</span>
							</td>
							<td height="30" align="left"></td>
							<td height="30" width="70" align="right">
								<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;"><?php echo $fltSumValue;?></span>
							</td>
							<td height="30" width="70" align="right">
								<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:13px;"><?php echo $fltSumPayFor;?></span>
							</td>
							<td height="20" width="10"></td>
						</tr>
						
						
						
					</table>
				</td>
			</tr>
			
			<tr>
				<td height="5" width="10"></td>
				<td height="5" align="left"></td>
				<td height="5" width="10"></td>
			</tr>
			
			<tr><td height="5" width="5" colspan="3"></td></tr>
			
		</table>
		
		<?php closeDb(); ?>
	</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="33%">					
					<a class="ui-btn ui-icon-bars ui-btn-icon-top" target="_parent" href="#roomorder" style="width:100%;height:10px;margin:0px auto 0px auto;color:#666666">宾客帐单</a>
				</td>
				
				<td width="34%">					
					<a class="ui-btn ui-icon-tag ui-btn-icon-top" target="_parent" href="#roomlist" style="width:100%;height:10px;margin:0px auto 0px auto;color:#666666">同行房</a>
				</td>
				
				<td width="33%">					
					<a class="ui-btn ui-icon-bullets ui-btn-icon-top" target="_parent" href="#" style="width:100%;height:10px;margin:0px auto 0px auto;color:#301972">帐目明细</a>
				</td>
				
			</tr>
		</table>						
	</footer>
</section>





</body>
</html>
