<?php
	session_start();
	ini_set('session.gc_maxlifetime', 99999999); //设置时间 永不过期
	//判断是否登录系统		
	if($_SESSION['main_wx_userlogined']!="1" | $_SESSION['main_wx_userno']=="")
	{
		//没有登录开始启动登录
		header('location:..\loginwx.php?rset=0');
		exit;
	}
	
	header("Content-type: text/html; charset=gb2312"); 
?>
<!DOCTYPE html>
<html>
<head>
	<meta charset="gb2312">	
	<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
	<meta name="apple-mobile-web-app-capable" content="1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="format-detection" content="telephone=0">
	<meta name="apple-touch-fullscreen" content="1">
	
	<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">
<?php 
		require_once("db/db.php");	
		require_once("common/common.php");
	
		$chainno=$_SESSION["ChainNofw"];
		$roomno=$_REQUEST["rmid"];
?>
<!--选择楼层的部分代码---------------------------->
<section data-role="page" id="pageItemList">
	<header data-role="header" data-position="fixed" data-tap-toggle="false">
		<table width="100%" height="40" border="0" cellpadding="0" cellspacing="0">
			<tr>
				<td height="40" width="45" align="right">
					<a href="roominform.php?rmid=<?php echo $roomno;?>" data-role="button" data-icon="carat-l" data-iconpos="notext" data-direction="reverse" rel="external"></a>
				</td>
				<td height="40" align="center">商品明细</td>
				<td height="40" width="40" ></td>
			</tr>
		</table>
	</header>
	
	
	<article data-role="content">
		<ul data-role="listview" data-inset="false">    
		 <?php
							
			$intRowID=0;
			$strItemNo="";
			$strItemName="";
			$fltItemPrice=0;
			
			$sql=sprintf("Select a.OrderNo,a.Item_BarCode,a.Item_No,a.Item_Name,a.Item_Spell,a.Item_Unite,a.Item_Price,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 b.SysFlag=0 AND a.Enabled=1 Order By a.OrderNo ASC",$chainno);
			$result = querySql($sql);
										
			while($row = fetch_array($result))
			{
				$intRowID=$intRowID + 1;
				$strItemNo = $row['Item_No']; 
				$strItemName = $row['Item_Name']; 
				$fltItemPrice = $row['Item_Price']; 
		?>
			<li>
				<!--
				<a class="ui-btn ui-corner-all ui-shadow ui-btn-inline" href="index.php?roomstate=&floorid=<?php echo $strSelFloorID;?>" target="_blank" data-transition="flip" >
					<?php echo $intRowID;?>.<?php echo $strItemName;?><span class="ui-li-count">价格<?php echo $fltItemPrice;?></span>
				</a>
				-->
				
				<a class="ui-btn ui-corner-all ui-shadow ui-btn-inline" href="#popupParis<?php echo $intRowID;?>" data-rel="popup" data-position-to="window" data-transition="fade" style="text-decoration:none">
					<?php echo $intRowID;?>.<?php echo $strItemName;?><span class="ui-li-count">价格<?php echo $fltItemPrice;?></span>
				</a>
				
				<div data-role="popup" id="popupParis<?php echo $intRowID;?>" data-overlay-theme="b" data-theme="b" data-corners="false">
					<a href="#" data-rel="back" class="ui-btn ui-corner-all ui-shadow ui-btn-a ui-icon-delete ui-btn-icon-notext ui-btn-right">Close</a>
					<table width="280" height="265" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
						<tr><td height ="5" colspan="3" align="center"></td></tr>
						<tr><td height ="40" colspan="3" align="center"><span style="color: #808000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:18px;text-shadow:none;">房间商品入账</span></td></tr>
						<tr><td height ="1" colspan="3" align="center" bgcolor="#F2E2E2"></td></tr>
						<tr><td height ="4" colspan="3" align="center"></td></tr>
						<tr>
							<td height ="30" width="10"></td>
							<td height ="30">
								<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;">项目：</span>
								<span style="color: #808000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;"><?php echo $strItemName;?></span>
							</td>
							<td height ="30" width="10"></td>
						</tr>
						
						<tr>
							<td height ="30" width="10"></td>
							<td height ="30">
								<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;">请选择入账数量</span>
							</td>
							<td height ="30" width="10"></td>
						</tr>
						
						<tr><td height ="10" colspan="3" align="center"></td></tr>
						
						<tr>
							<td height ="90" width="10"></td>
							<td height ="90" valign="top">
								<table width="100%" height="60" border="0" cellpadding="0" cellspacing="0">
									<tr>
										<td height="60" width="65" align="right">
											<div id="SubCode" onClick="gbClick(2,<?php echo $intRowID;?>,'')" style="width:55px;height:50px;text-align:center;line-height:50px;background-color:#E7E7E7;margin-left:0px;border-radius:5px;">
												<span style="color: #000;font-size:28px;text-shadow:none;">←</span>
												<input id="RowTXT<?php echo $intRowID;?>" type="hidden" value="1">
											</div>
										</td>
										<td height="60" align="center">
											<div id="shuDiv<?php echo $intRowID;?>" style="width:70px;height:40px;text-align:center;padding-top:10px;border:1px solid #ddd;">
												<span style="color: #000;font-size:24px;text-shadow:none;">1</span>
											</div>
										</td>
										<td height="60" width="65" align="right">
											<div id="AddCode" onClick="gbClick(1,<?php echo $intRowID;?>,'')" style="width:55px;height:50px;text-align:center;line-height:50px;background-color:#E7E7E7;margin-right:10px;border-radius:5px;">
											<span style="color: #000;font-size:28px;text-shadow:none;">→</span>
											</div>
										</td>
									</tr>
								</table>
							</td>
							<td height ="90" width="10"></td>
						</tr>
						
						<tr>
							<td height ="40" width="10"></td>
							<td height ="40" align="center">
								<div onClick="gbClick(3,<?php echo $intRowID;?>,'<?php echo $strItemNo;?>')" style="width:94%;height:40px;">
									<img id="commodity_account" src="images/save.png" style="height:38px;width:100%;" />
								</div>
							</td>
							<td height ="40" width="10"></td>
						</tr>
						
						<tr><td height ="15" colspan="3" align="center"></td></tr>
					
					</table>
				</div>
								
			</li> 
		<?php
			}
			//释放数据库
			freeResult($result);
			closeDb();
		 ?>
		  
		</ul> 
		
	<script type="text/javascript">
		//var intNowCount;
		//intNowCount=1;
		
		function gbClick(id,rowid,itmid)
		{
			var intSelCount;			
			var oTextbox1=document.getElementById("RowTXT"+rowid);
			intSelCount=oTextbox1.value;
			//alert(oTextbox1.value);
			//return;
			if(id==1)
			{
				//增加商品数量 
				intSelCount++;
				if(intSelCount>99){
					intSelCount = 1;
				}
				$("#shuDiv"+rowid).html('<span style="color: #000;font-size:24px;text-shadow:none;">' + intSelCount +'</span>');
				oTextbox1.value=intSelCount;
			}
			else if(id==2)
			{
				//减少商品数量
				intSelCount--;
				if(intSelCount<=0){
					intSelCount = 1;
				}
				$("#shuDiv"+rowid).html('<span style="color: #000;font-size:24px;text-shadow:none;">' + intSelCount +'</span>');
				oTextbox1.value=intSelCount;
			}
			else if(id==3)
			{
				//保存入账
				//用ajax的“同步方式”调用一般处理程序
				$.ajax({
					url: "saveitemtoroom.php?rmid=<?php echo $roomno;?>" + "&itmno=" + itmid + "&selnum=" + intSelCount,
					async: false,//改为同步方式
					type: "POST",
					//data: {doid:4, rmid: "<?php echo $roomno;?>" },
					success: function (RetData) 
					{
						strret = RetData;
					}
				});
									
				if(strret==1)
				{
					var urlroom='roominform.php?rmid=<?php echo $roomno;?>';
					window.location.href=urlroom;
					//alert("商品入账成功!");
				}
				else
				{
					alert("商品入账失败!");
				}
			}
		}
		
	</script>
	</article>						
		
</section>

</body>
</html>
