<?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;
	
	$sql=sprintf("SELECT a.Order_No,b.ListNo,b.Man_Name,a.Custom_Type,a.Vip_SubNo,a.Custom_No,Convert(varchar(16),GetDate(),120)As ServerTime,b.RoomPrice,b.Room_No
						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'];
		$strcustomtype=$row['Custom_Type'];
		$strordervipno=trim($row['Vip_SubNo']);
		$strordercustomno=trim($row['Custom_No']);
		$strtradetime=$row['ServerTime'];
		$strRoomPrice=$row['RoomPrice'];
		$strRoomPrice=$strRoomPrice+0;
	}
	//释放数据库
	freeResult($result);
	
	//2.判断是否有会员和协议客户
	if(strlen($strordervipno)>0)
	{
		$sql=sprintf("SELECT Sub_Name FROM VIP_Item WHERE Sub_No='%s'",$strordervipno);
		$result = querySql($sql);
		if($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);
		if($row = fetch_array($result))
		{
			$strcustomname=$row['CustomName'];
			$strordercustomno=$strordercustomno."|".$strcustomname;
		}
		freeResult($result);
	}
	
	//判断是否有入账的权限
	$intCanSaveItemFlag=0;
	$intCanSavePayFlag=0;
	
?>

<!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: 140px; /* 设置每列的宽度 */
		text-align: left;
	}
	.span-item2 {
		width: 70px; /* 设置每列的宽度 */
		text-align: center;
	}
	.span-item3 {
		width: 70px; /* 设置每列的宽度 */
		text-align: right;
	}
		
	</style>

	
</head>

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

	function bmtReturnPage()
	{	
		window.location.href='rmroomorder.php?rmid=<?php echo $strroomno;?>';
	};
	
</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: #570057;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif;font-size:16px;">
						<select id="mycombo1" name="mycombo1" data-mini="true" style="color: #000; background-color:#fff; border: none; width:95%;height:28px;">
							<option value=" "> &nbsp;</option>
							<?php
								$strItemName='';
								$sql=sprintf("SELECT Item_Name,OrderNo FROM TR_Basic_Item WHERE (Chain_No='%s' OR Chain_No='') 
											AND (Item_Type='付款方式' AND Item_Name<>'会员卡' AND Item_Name<>'挂账' AND Item_Name<>'扫码支付') ORDER BY Item_Type ASC,OrderNo ASC,Item_Name ASC",$chainno);
								$result = querySql($sql);
										
								while($row = fetch_array($result))
								{
									$strItemName = $row['Item_Name']; 
							?>
							<option value="<?php echo $strItemName;?>"><?php echo $strItemName;?>&nbsp;</option>
							<?php 
								}
								//释放数据库
								freeResult($result);
								closeDb();
							?>
						</select>
					</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;">
						<input class="custom-class" id="mytext1" name="mytext1" value='' type="number" placeholder="收款金额" style="border: none;width:95%;height:28px;"/>
					</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;">
						<input id="mytext2" name="mytext2" value='' type="text" placeholder="收款备注说明" data-mini="true" autocomplete="off" style="border: none;width:95%;height:28px;"/>
					</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="labItemName" style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;"></span>
				</td>
				<td height="35" width="80" 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" align="left">
					<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;">
						<input id="mytext3" name="mytext3" value='' type="number" placeholder="项目单价" data-mini="true" autocomplete="off" style="border: none;width:95%;height:28px;"/>
					</span>
				</td>
				<td height="35" width="80" align="left">
					<span id="labItemUnite"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:16px;text-shadow:none;">数量：</span>
				</td>
				<td height="35" colspan="2" align="left">
					<table width="100%" height="45" border="0" cellpadding="0" cellspacing="0">
						<tr>
							<td height="38" width="50" align="right">
								<div id="SubCode" onClick="gbClick(2)" style="width:50px;height:36px;text-align:center;line-height:36px;background-color:#E7E7E7;margin-left:0px;border-radius:5px;">
									<span style="color: #000;font-size:20px;text-shadow:none;">←</span>
								</div>
							</td>
							<td height="38" width="70" align="center">
								<div style="width:60px;height:33px;text-align:center;padding-top:4px;border:1px solid #F3F3F3;">
									<span id="labItemCount" style="color: #000;font-size:18px;text-shadow:none;">0</span>
								</div>
							</td>
							<td height="38" width="50" align="right">
								<div id="AddCode" onClick="gbClick(1)" style="width:50px;height:36px;text-align:center;line-height:36px;background-color:#E7E7E7;margin-right:10px;border-radius:5px;">
									<span style="color: #000;font-size:20px;text-shadow:none;">→</span>
								</div>
							</td>
							<td height="38" align="right">
								<div id="ClearCode" onClick="gbClick(3)" style="width:58px;height:36px;text-align:center;line-height:36px;background-color:#E7E7E7;margin-right:1px;border-radius:5px;">
									<span style="color: #000;font-size:16px;text-shadow:none;">清零</span>
								</div>
							</td>
						</tr>
					</table>
				</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;">
						<span id="labItemValue" style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;"></span>
					</span>
				</td>
				<td height="35" width="80" align="left">
					<span id="labItemNo"style="color: #fff;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: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;">
						<input id="mytext4" name="mytext4" value='' type="text" placeholder="消费入账说明" data-mini="true" autocomplete="off" style="border: none;width:95%;height:28px;"/>
					</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>
			

			
			
			
<!-- 弹出窗体结构 -->
    <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;
					$strItemNo="";
					$strItemName="";
					$fltItemPrice=0;
					$strItemUnite='';
					$intSysFlag=0;
					$intSysOld=0;
					$strItemType='';
					$strItemTypeOld='';
					
					$sql=sprintf("Select a.ListNo,a.OrderNo,a.Item_No,a.Item_Name,a.Item_Unite,a.Item_Price,b.SysFlag,b.Item_Type
							From TR_Item_List a,TR_Item_Type b WHERE a.TypeListNo=b.ListNo AND (b.Chain_No='%s' OR b.Chain_No='') 
							And a.DisGood=0 AND a.Enabled=1 Order By b.SysFlag ASC,b.Item_Type ASC,a.OrderNo ASC",$chainno);
					$result = querySql($sql);
												
					while($row = fetch_array($result))
					{
						$intRowID=$intRowID + 1;
						$strIListNo = $row['ListNo']; 
						$strItemNo = $row['Item_No']; 
						$strItemName = $row['Item_Name']; 
						$fltItemPrice = $row['Item_Price']; 
						$strItemUnite = $row['Item_Unite']; 
						$strItemType = $row['Item_Type']; 
						
						$intSysFlag = $row['SysFlag']; 
						
						if($intSysFlag<>$intSysOld)
						{
							//如果是系统类
				?>
				<div style="height:42px;width:100%;border-bottom: 1px solid #deecfb; padding-top:18px;">
					<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;font-weight: bold;">系统类</span>
				</div>
				<?php
							$intSysOld=$intSysFlag;
							$strItemTypeOld=$strItemType;
						}
						else
						{
							if($strItemTypeOld<>$strItemType AND $intSysOld<1)
							{
				?>
				<div style="height:45px;width:100%;border-bottom: 1px solid #deecfb; padding-top:18px;">
					<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;font-weight: bold;"><?php echo $strItemType;?></span>
				</div>
				<?php
							}
						}
						$strItemTypeOld=$strItemType;
				?>
				<div class="grid-container" onClick="bntSelectItem(<?php echo $strIListNo;?>,'<?php echo $strItemNo;?>','<?php echo $strItemName;?>','<?php echo $strItemUnite;?>',<?php echo $fltItemPrice;?>)" 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;"><?php echo $intRowID.'.'.$strItemName;?></span>
					<span class="span-item2" style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:15px;text-shadow:none;"><?php echo $strItemUnite;?></span>
					<span class="span-item3" style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:15px;text-shadow:none;"><?php echo $fltItemPrice;?></span>
				</div>
				
				<?php
					}
					//释放数据库
					freeResult($result);
					closeDb();
				?>
                
            </div>
			
        </div>
    </div>
			
			
			
			
			<tr><td height="35" colspan="5"></td></tr>
			
			<tr>
				<td height="30" width="30" ></td>
				<td height="30" 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="30" 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="4" colspan="5"></td></tr>
			
			<tr>
				<td height="25" width="30" ></td>
				<td height="25" colspan="3" align="left">
					<span style="color: #585858;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:14px;">1.收款方式和金额同时存在才保存“收款信息”</span>
				</td>
				<td height="25" width="30" ></td>
			</tr>
			
			<tr>
				<td height="25" width="30" ></td>
				<td height="25" colspan="3" align="left">
					<span style="color: #585858;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:14px;">2.项目和数量同时存在才保存“消费信息”</span>
				</td>
				<td height="25" width="30" ></td>
			</tr>
			
			<tr><td height="2" colspan="5"></td></tr>
			
			
		</table>
				
	</article>
		
	
	<script type="text/javascript">
		
		//选择一个项目
		function bntSelectItem(lngIListNo,strItemNo,strItemName,strItemUnite,fltItemPrice)
		{	
			intNowSelItemListNo=lngIListNo;	//记录后，点保存时用到
			
			var labSpan1=document.getElementById("labItemName");
			var labSpan2=document.getElementById("labItemUnite");
			var labSpan3=document.getElementById("labItemCount");
			var labSpan4=document.getElementById("labItemValue");
			var labSpan5=document.getElementById("labItemNo");
			
			labSpan1.textContent=strItemName;
			labSpan2.textContent='/'+strItemUnite;
			labSpan5.textContent=strItemNo;
			
			document.getElementById('mytext3').value = fltItemPrice;
			
			funTyRefItemText();	//刷新金额
			
			//关闭界面
			$('#closeModalBtn').click();
			
		};
		
		//刷新新金额
		function funTyRefItemText()
		{
			var labSpan1=document.getElementById("labItemCount");
			var labSpan2=document.getElementById("labItemValue");
			
			//得到数量
			var fltItemCount=labSpan1.textContent;
			if(fltItemCount.length<1)
			{
				fltItemCount=0;
			}
			
			//单价
			var fltItemPrice=$("#mytext3").val();
			if(fltItemPrice.length<1)
			{
				fltItemPrice=0;
			}
			
			//计算金额
			var fltNewValue=fltItemCount*fltItemPrice;
			labSpan2.textContent=fltNewValue;
		};
		
		function gbClick(id)
		{
			var intSelCount;
			var labSpan1=document.getElementById("labItemCount");	//显示天数的标签
			intSelCount=labSpan1.textContent;
			//alert(oTextbox1.value);
			//return;
			if(id==1)
			{
				//增加 
				intSelCount++;
				if(intSelCount>999){
					intSelCount = 1000;
				}
				
				labSpan1.textContent=intSelCount;
				
				funTyRefItemText();	//刷新金额
			}
			else if(id==2)
			{
				//减少商品数量
				intSelCount--;
				if(intSelCount<=-999){
					intSelCount = -1000;
				}
				
				labSpan1.textContent=intSelCount;
				
				funTyRefItemText();	//刷新金额
			}
			else if(id==3)
			{
				//减少商品数量
				intSelCount=0;
				
				labSpan1.textContent=intSelCount;
				
				funTyRefItemText();	//刷新金额
			}
		};
		
		
		//保存账目
		function bmtSaveRoomItem()
		{
			var strPayType=$("#mycombo1").val();
			var strPayValue=$("#mytext1").val();
			var strPayText=$("#mytext2").val();
			
			strPayType=strPayType.trim();

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

			//得到消费项目
			var labSpan1=document.getElementById("labItemName");
			var labSpan2=document.getElementById("labItemCount");
			var labSpan3=document.getElementById("labItemValue");
			var labSpan4=document.getElementById("labItemNo");
			
			var strItemNo=labSpan4.textContent;
			var strItemName=labSpan1.textContent;
			var intItemCount=labSpan2.textContent;
			var strItemText=$("#mytext4").val();
			
			strItemNo=strItemNo.trim();
			strItemName=strItemName.trim();
			intItemCount=intItemCount.trim();
			strItemText=strItemText.trim();
			
			if(intItemCount.length<1)
			{
				intItemCount=0;
			}
		
			var intPayOk=0;
			var intScoreOK=0;
			//1付款，2消费，3付款和消费		
			if(strPayType.length>0 && fltPayValue!=0)
			{
				//将数据封包成JSON
				const jsondata = {
						rblistno: <?php echo $strRBListNo;?>,
						paytype: strPayType,
						payval: strPayValue,
						paytxt: strPayText
						};
					
				//用ajax的“同步方式”调用一般处理程序
				$.ajax({
						url: "rmroomorderitemsave1.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*")
					{
						intPayOk=1;
					}
					else
					{
						alert("保存收款入账失败!");
					}
				}
			}
			else
			{
				intPayOk=2;
			}
			
			
			//消费入账
			if(strItemName.length>0 && intItemCount!=0)
			{
				//将数据封包成JSON
				const jsondata = {
						rmid: '<?php echo $strroomno;?>',
						itmno: strItemNo,
						selnum: intItemCount,
						itmtxt: strItemText,
						};
						
				//用ajax的“同步方式”调用一般处理程序
				$.ajax({
						url: "rmroomorderitemsave2.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*")
					{
						intScoreOK=1;
					}
					else
					{
						alert("保存消费入账失败!");
					}
				}
			}
			else
			{
				intScoreOK=2;
			}
			
			if(intScoreOK>1 && intPayOk>1)
			{
				//都没有选择则不处理
				return;
			}
			
			if(intPayOk>0 && intScoreOK>0)
			{
				bmtReturnPage();
			}
			
		};
	</script>
		
		
</section>

</body>
</html>
