<?php
	session_start();
	require_once("../Wx.Config.php");	//只加载一次
	
	$strItemNo=trim($_REQUEST['itmno']);
	
	//得到购物车号
	$strdefcartid = trim($_SESSION["main_defcarttempid"]);
	$strselDListNo=trim($_SESSION["main_posChainDListNo"]);
	
	$strIndexPage = trim($_SESSION["main_defPageIndex"]);
	if(strlen($strIndexPage)<1)
	{
		$strIndexPage = "index.php";
	}
?>

<!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">

	<title>微信点单</title>
	
	<link rel="stylesheet" href="css/mycss.css"> 
	<script src="jsp4/jquery.js"></script>
	<!--<link rel="stylesheet" href="jsp5/jquery.mobile-1.4.5.min.css">-->
	<!--<script src="jsp4/jquery.mobile-1.4.3.min.js"></script>-->
	<script src="jsp5/jquery.mobile-1.4.5.min.js"></script>
	<link rel="stylesheet" href="jsp5/jquery.mobile-1.4.5.min.css">
	
	
	<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
	  
    
	<script language="JavaScript"> 
		//不允许进行后退
		javascript:window.history.forward(0); 
	</script>
	
</head>

<?php

	
	//加载系统参数信息
	require_once("db/db.php");	
	require_once("common/common.php");
	
	//得到当前部门名称
	$intWXIngegPayFlag=0;
	
	$sql = sprintf("SELECT wxintegprice FROM TCP_Depart_Inform Where ListNo=%s",$strselDListNo);
	$result = querySql($sql);
	
	if($row = fetch_array($result))
	{
		$intWXIngegPayFlag = $row['wxintegprice'];
	}
	freeResult($result);	//释放数据库
	
	
	$fltintegralcashrate = 0;
	if($intWXIngegPayFlag>0)
	{
		$sql=sprintf("SELECT IntegralCashRate from VIP_Config");
		$result = querySql($sql);
		
		if($row = fetch_array($result))
		{
			$fltintegralcashrate = $row['IntegralCashRate'];
		}
		freeResult($result);	//释放数据库
	}
	
	//得到当前购物车数量
	$strCartCount = '';
	$sql=sprintf("SELECT SUM(Item_Count)AS SumCount FROM WX_Temp_List Where CartTempID='%s' And DListNo=%s",$strdefcartid,$strselDListNo);

	$result = querySql($sql);
	if($row = fetch_array($result))
	{
		$strCartCount  = $row['SumCount'];
	}
	freeResult($result);	//释放数据库
	
	//得到项目信息
	$strItemName = '';
	$strItemUnite = '';
	$strItemPrice='';
	$strItemInteg='';
	$strRemarks ='';
	$strItemImg='';
	
	//$strItemNo
	if(strlen($strItemNo)>0)
	{
		$sql = sprintf("SELECT a.ItemNo,a.ItemName,a.ItemUnite,a.ItemPrice,a.Remarks,a.wximage,b.TypeName
					FROM TCP_Item_List a,TCP_Item_Type b Where a.TypeListNo=b.ListNo And a.wxmall>0 And b.DListNo=%s And a.ItemNo='%s'",$strselDListNo,$strItemNo);
					
		$result = querySql($sql);
		if($row = fetch_array($result))
		{
			$strItemName = $row['ItemName'];
			$strItemUnite = $row['ItemUnite'];
			$fltprice = $row['ItemPrice'];
			$strRemarks = trim($row['Remarks']);
			$strItemImg= trim($row['wximage']);
							
			//处理数据转换和显示
			$fltintegralval =  round($fltprice * $fltintegralcashrate,0);
				
			$strItemPrice =  number_format($fltprice,1);
			$strItemInteg =  number_format($fltintegralval,0);
			$strItemPrice = str_replace(',','',$strItemPrice);
			$strItemInteg = str_replace(',','',$strItemInteg);
					
			if(strlen($strItemUnite)>0)
				$strItemUnite ='/'.$strItemUnite;
			
			if(strlen($strItemImg)>0)
				$strItemImg = 'mall_images/'.$strItemImg ;
				
			
		}
		freeResult($result);	//释放数据库
	}
	
	$intNumLeft = 4;
	if($strCartCount=='')
	{
		$strCartImg='images/cart1.png';
	}
	else
	{
		$strCartImg='images/cart2.png';

		
		if($strCartCount>9)
		{
			$intNumLeft=0;
		}
	}
	
	$intItemImgHeight = 240;
	$intItemSubImgHeight = 180;
?>

<body leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0">		
<!--第一个页面的内容实现---------------------------->
<section data-role="page" id="page1">	

	<article data-role="none">
		<div style="width:100%;height:<?php echo $intItemImgHeight;?>px;align:center;">       
			<img width="100%" style="height:<?php echo $intItemImgHeight;?>px;" border="0" src="<?php echo $strItemImg;?>"/>
		</div> 
		
		<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#fff">
			<tr><td height="1" colspan="3" bgcolor="#F4EFEF"></td></tr>
			<tr><td height="4" colspan="3"></td></tr>
			
            <tr>
				<td height="15" width="10"></td>
				<td height="15" align="left">
					<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:14px;"><?php echo $strItemName;?></span>
				</td>
				<td height="15" width="10"></td>
			</tr>
				
            <tr><td height="5" colspan="3"></td></tr>
			<tr><td height="1" colspan="3" bgcolor="#F4EFEF"></td></tr>
			<tr><td height="5" colspan="3"></td></tr>
   
			<tr>
				<td height="6" width="10"></td>
				<td height="6" align="left">
					<?php if($intWXIngegPayFlag>0) { ?>
						<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
							<tr>
								<td width="54%" height="100%">
									<span style="color: #996600;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:14px;">￥<?php echo $strItemPrice; ?></span> 
								</td>
								
								<td width="13" height="100%">
									<?php if($strItemInteg>0) {?>
									<img src="images\jfimg.png" width="12" height="15" border="0" style="margin-top:3px;">
									<?php } ?>
								</td>
								<td height="100%" align="left">
									<?php if($strItemInteg>0) {?>
									<span style="color: #996600;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:14px;"><?php echo $strItemInteg; ?></span> 
									<?php } ?>
								</td>
							</tr>
						</table>
					<?php } else { ?>
						<span style="color: #996600;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:14px;">￥<?php echo $strItemPrice; ?></span> 
					<?php } ?>
				</td>
				<td height="6" width="10"></td>
			</tr>
			
			<tr><td height="5" colspan="3"></td></tr>
			<tr><td height="1" colspan="3" bgcolor="#F4EFEF"></td></tr>
			<tr><td height="5" colspan="3"></td></tr>
			
			<?php if(strlen($strRemarks)>0) { ?>
			<tr>
				<td height="8" width="10"></td>
				<td height="8" align="left">
					<span style="color: #B99698;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:12px;"><?php echo $strRemarks;?></span>
				</td>
				<td height="8" width="10"></td>
			</tr>
			
			<tr><td height="5" colspan="3"></td></tr>
			<tr><td height="1" colspan="3" bgcolor="#F4EFEF"></td></tr>
			<tr><td height="5" colspan="3"></td></tr>
			<?php } ?>
			<tr>
				<td height="6" width="10"></td>
				<td height="6" align="left"></td>
				<td height="6" width="10"></td>
			</tr>
		</table>
		
		<script type="text/javascript">
				
			//相应提交按钮事件处理部分
			function bmtSelItem(strItemNo)
			{	
				window.location="itemview.php?itmno=" + strItemNo;										
			}
			
			function bmtSelIType(strtypeid)
			{	
				window.location="index.php?itmtyid=" + strtypeid;										
			}
		
		</script>
		
		<script>
			//禁止页面上下滑动,整个页面都不能滑动了
			document.addEventListener('touchmove', function(e) {
				e.preventDefault();
			});
		</script>
	</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:0px solid #F2E2E2;border-right:1px solid #F2E2E2;">
		<table width="100%" height="55" border="0" cellpadding="0" cellspacing="0" bgcolor="<?php echo WxMainConfig::colHeadBkColor;?>">
			<tr><td height="1" colspan="4" bgcolor="#F4EFEF"></td></tr>
			<tr height="100%" valign="top">
				<td width="15" height="46" align="left" valign="middle"></td>
				<td width="80" valign="middle">					
					<div onClick="bmtRetrunHome()" style="width:80px; height:27px; border-radius:6px;border-top:1px solid #F0E1B3;border-bottom:1px solid #F0E1B3;border-left:1px solid #F0E1B3;border-right:1px solid #F0E1B3;padding-top:3px;" align="center">
						<span style="color: #F0E1B3;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;text-shadow:none;">返回首页</span>
					</div>
				</td>
				
				<td valign="middle" align="center">
					<div onClick="bmtSaveToTempTable('<?php echo $strItemNo;?>')" style="width:70%; height:27px; border-radius:6px; border-top:1px solid #fff;border-bottom:1px solid #fff;border-left:1px solid #fff;border-right:1px solid #fff;padding-top:3px;" align="center">
						<span style="color: #fff;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;text-shadow:none;">加入已点单</span>
					</div>
				</td>
				<td width="60" height="46" align="left" valign="middle">
					<div onClick="bmtGoToCart()" id="MyCart" width="45" height="45" style="width:45px; height:45px; background-image:url(<?php echo $strCartImg;?>);">
						<div id="MyNumDiv" style="width:45px;height:45px;padding-top:3px;padding-left:<?php echo $intNumLeft;?>px;">
							<span id="spansumg" style="color:#fff;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:15px;text-shadow:none; margin-left:10px;"><?php echo $strCartCount;?></span> 
						</div>
					</div>
				</td>
			</tr>
		</table>						
	</footer>
    

	<script type="text/javascript">
			
			function bmtRetrunHome()
			{	
				window.location="<?php echo $strIndexPage;?>";
			}
			
			function bmtGoToCart()
			{	
				window.location="cartlist.php";
			}
			
			//相应提交按钮事件处理部分
			function bmtSaveToTempTable(selitemno)
			{			
				//开始保存项目到购物车中
				var strret;
				//用ajax的“同步方式”调用一般处理程序
				$.ajax({
					url: "savetotemp.php?selitno=" + selitemno ,
					async: false,//改为同步方式
					type: "POST",
					//data: {doid:1, rmid: "strRoomNo" },
					success: function (RetData) 
					{
						strret = RetData;
					}
				});

				//alert(strret);
				if(strret==1)
				{
					window.location="cartlist.php";
				}
											
			}
			
		</script>
		
	
</section>

</body>
	
</html>