<?php
	session_start();
	header("Content-type:text/html;charset=gb2312");
	//判断是否登录系统		
	if($_SESSION["main_viplogined"]!="1" |$_SESSION["main_vipno"]=="")
	{
		//没有登录开始启动登录
		header('location:login.php?stext=');
		exit;
	}
?>
<!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>

	<script src="jsp4/jquery.js"></script>
	<link rel="stylesheet" href="css/mycss.css"> 
	
	<!--<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">
	
</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>

<?php
	require_once("db/db.php");	
	require_once("common/common.php");
	require_once("../Wx.Config.php");	//只加载一次
	
?>

<body leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0">
<!--第一个页面的内容实现---------------------------->
<section data-role="page" id="hispage1">
	<header data-role="header" data-position="fixed" data-tap-toggle="false" style="border-top-width:0px;border-bottom-width:0px;">
		<table width="100%" height="45" border="0" cellpadding="0" cellspacing="0" bgcolor="<?php echo WxMainConfig::colHeadBkColorBook;?>">
			<tr>
				<td height="45" width="35" align="right" valign="middle">
					<a href="vipmain.php" target="_blank"data-iconpos="notext">
						<div style="width:30;height:26px; ">
							<img src="images\back.png" width="12" height="21" border="0" style="margin-top:3px;">
						</div>
                    </a>
				</td>
				<td height="45" width="10"></td>
				<td height="45" align="left">
					<!--<a href="vipmain.php" target="_blank" >-->
						<div style="padding-top:2px;">
						<table width="100%" height="45" border="0" cellpadding="0" cellspacing="0">
							<tr>
								<td align="center">
									<span id="MsgTxt" style="color:<?php echo WxMainConfig::colHeadTextColorBook;?>;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:19px;text-shadow:none;">分销报表</span>
								</td>
								<td width="50"></td> <!--align="center"-->
							</tr>
						</table>
					</div><!--</a>-->
				</td>
			</tr>
			<tr>
				<td height="1" colspan="3" bgcolor="#F2E2E2"></td>
			</tr>
			<tr>
				<td height="35" colspan="3" bgcolor="#fff">
					<table width="100%" height="37" border="0" cellpadding="0" cellspacing="0">
						<tr>
							<td width="5%" height="35" align="center"></td>
							<td width="20%" height="35" align="center">
									<table width="100%" height="37" border="0" cellpadding="0" cellspacing="0">
										<tr><td align="center">
											<span style="color: #BBBB00;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:15px;">下级会员</span>
										</tr></td>
									</table>
							</td>
							<td width="5%" height="35" align="center"></td>
							<td width="25%" height="35" align="center">
								<div onClick="window.location = 'marketrep2.php';">								
									<table width="100%" height="37" border="0" cellpadding="0" cellspacing="0">
										<tr><td align="center">
											<span style="color: #000000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:15px;">未分润</span>
										</tr></td>
									</table>
								</div>
							</td>
							<td width="5%" height="35" align="center"></td>
							<td width="25%" height="35" align="center">
								<!--<a data-transition="slide" target="_blank" href="hisbill2.php">-->
								<div onClick="window.location = 'marketrep3.php';">
									<table width="100%" height="37" border="0" cellpadding="0" cellspacing="0">
										<tr><td align="center">
											<span style="color: #000000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:15px;">已分润</span>
										</tr></td>
									</table>
								</div>
							</td>
							<td width="10%" height="35" align="center"></td>
						</tr>
						<tr>
							<td width="5%" height="2" align="center"></td>
							<td width="25%" height="2" align="center" bgcolor="#BBBB00"></td>
							<td width="5%" height="2" align="center"></td>
							<td width="25%" height="2" align="center"></td>
							<td width="5%" height="2" align="center"></td>
							<td width="25%" height="2" align="center"></td>
							<td width="10%" height="2" align="center"></td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
	</header>
	
	<article data-role="none">
		<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#66FFFF" >
			<tr>
				<td height="4" width="8"></td>
				<td height="4" align="left"></td>
				<td height="4" width="8"></td>
			</tr>
			
			<?php 
				//得到下级会员数量
				$strLowVipCount1 = '0';
				$strLowVipCount2 = '0';
				$strLowVipCount3 = '0';
				
				$strRetValA1 = '0';
				$strRetValA2 = '0';
				$strRetValA3 = '0';
				
				$strRetValB1 = '0';
				$strRetValB2 = '0';
				$strRetValB3 = '0';
				
				$strSelSubNo = trim($_SESSION["main_vipno"]);
				
				$sql=sprintf("select SumCount,dbo.DP_GetLowerSubVIPCount(%s,2) As SumCountB,dbo.DP_GetLowerSubVIPCount('%s',3) AS SumCountC from dbo.DP_GetTopSubVIPALL() where Sub_No='%s'",$strSelSubNo,$strSelSubNo,$strSelSubNo);
				$result = querySql($sql);
											
				if($row = fetch_array($result))
				{
					$strLowVipCount1=$row['SumCount'];
					$strLowVipCount2=$row['SumCountB'];
					$strLowVipCount3=$row['SumCountC'];
				}
				//释放数据库
				freeResult($result);
				
				$sql=sprintf("Select Sum(SumVal1)AS SumVal1,Sum(SumVal2)as SumVal2,Sum(SumVal3) AS SumVal3,Sum(SumValB1)AS SumValB1,Sum(SumValB2)as SumValB2,Sum(SumValB3)As SumValB3 
					From (select 1 AS MYID, Sum(RetValA)As SumVal1,Sum(RetValB)As SumVal2,Sum(RetValC)As SumVal3,0 AS SumValB1,0 AS SumValB2,0 AS SumValB3 from VIP_Market_ReportList Where Sub_No='%s' And (SendFlag=0 Or SendFlag Is Null)
					UNION select 2 AS MYID,0 AS SumVal1,0 AS SumVal2,0 AS SumVal3,Sum(RetValA)As SumValB1,Sum(RetValB)As SumValB2,Sum(RetValC)As SumValB3 from VIP_Market_ReportList Where Sub_No='%s' And SendFlag=1
					) t",$strSelSubNo,$strSelSubNo);
					
				$result = querySql($sql);
											
				if($row = fetch_array($result))
				{
					$strRetValA1=$row['SumVal1'];
					$strRetValA2=$row['SumVal2'];
					$strRetValA3=$row['SumVal3'];
					
					$strRetValB1=$row['SumValB1'];
					$strRetValB2=$row['SumValB2'];
					$strRetValB3=$row['SumValB3'];
				}
				
				//释放数据库
				freeResult($result);
				closeDb();
			?>
			
			<tr>
				<td height="20" width="8"></td>
				<td height="20" align="left" bgcolor="#ffffff">
					<table width="100%" border="0" cellpadding="0" cellspacing="0">
						
						<tr><td height="5" colspan="3"></td></tr>
						
						<tr>
							<td height="30" width="10"></td>
							<td height="30" align="left">
								<span style="color: #6D6D6D;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:14px;text-shadow:none;">一级会员数：<?php echo $strLowVipCount1;?> 位</span>
							</td>
							<td height="30" width="10"></td>
						</tr>
						
						<tr>
							<td height="30" width="10"></td>
							<td height="30" align="left">
								<span style="color: #6D6D6D;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:14px;text-shadow:none;">二级会员数：<?php echo $strLowVipCount2;?> 位</span>
							</td>
							<td height="30" width="10"></td>
						</tr>
						
						<tr>
							<td height="30" width="10"></td>
							<td height="30" align="left">
								<span style="color: #6D6D6D;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:14px;text-shadow:none;">三级会员数：<?php echo $strLowVipCount3;?> 位</span>
							</td>
							<td height="30" width="10"></td>
						</tr>
						
						<tr><td height="5" colspan="3"></td></tr>
					</table>
					
				</td>
				<td height="20" width="8"></td>
			</tr>
			
			<tr>
				<td height="4" width="8"></td>
				<td height="4" align="left"></td>
				<td height="4" width="8"></td>
			</tr>
			
			<tr>
				<td height="20" width="8"></td>
				<td height="20" align="left" bgcolor="#ffffff">
					<table width="100%" border="0" cellpadding="0" cellspacing="0">
						
						<tr><td height="5" colspan="5"></td></tr>
						
						<tr>
							<td height="30" width="10"></td>
							<td height="30" width="65" align="left">
								<span style="color: #6D6D6D;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;text-shadow:none;">一级分润：</span>
							</td>
							<td height="30" width="110" align="left">
								<span style="color: #6D6D6D;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;text-shadow:none;">未分润：<?php echo $strRetValA1;?></span>
							</td>
							<td height="30" align="left" colspan="2">
								<span style="color: #6D6D6D;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;text-shadow:none;">已分润：<?php echo $strRetValB1;?></span>
							</td>
						</tr>
						
						<tr>
							<td height="30" width="10"></td>
							<td height="30" width="65" align="left">
								<span style="color: #6D6D6D;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;text-shadow:none;">二级分润：</span>
							</td>
							<td height="30" width="110" align="left">
								<span style="color: #6D6D6D;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;text-shadow:none;">未分润：<?php echo $strRetValA2;?></span>
							</td>
							<td height="30" align="left" colspan="2">
								<span style="color: #6D6D6D;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;text-shadow:none;">已分润：<?php echo $strRetValB2;?></span>
							</td>
						</tr>
						
						<tr>
							<td height="30" width="10"></td>
							<td height="30" width="65" align="left">
								<span style="color: #6D6D6D;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;text-shadow:none;">三级分润：</span>
							</td>
							<td height="30" width="110" align="left">
								<span style="color: #6D6D6D;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;text-shadow:none;">未分润：<?php echo $strRetValA3;?></span>
							</td>
							<td height="30" align="left" colspan="2">
								<span style="color: #6D6D6D;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;text-shadow:none;">已分润：<?php echo $strRetValB3;?></span>
							</td>
						</tr>
						
						<tr><td height="5" colspan="5"></td></tr>
					</table>
					
				</td>
				<td height="20" width="8"></td>
			</tr>
			
			<tr>
				<td height="4" width="8"></td>
				<td height="4" align="left"></td>
				<td height="4" width="8"></td>
			</tr>
			
			<tr>
				<td height="20" width="8"></td>
				<td height="20" align="left" bgcolor="#ffffff">
					<table width="100%" border="0" cellpadding="0" cellspacing="0">
						<tr><td height="5" colspan="3"></td></tr>
						
						<tr>
							<td height="20" width="10"></td>
							<td height="20" align="left">
								<span style="color: #6D6D6D;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:12px;text-shadow:none;">分润说明：</span>
							</td>
							<td height="20" width="10"></td>
						</tr>
						
						<tr>
							<td height="20" width="10"></td>
							<td height="20" align="left">
								<span style="color: #6D6D6D;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:12px;text-shadow:none;">1.提成收入分润后自动转入到会员账户中.</span>
							</td>
							<td height="20" width="10"></td>
						</tr>
						
						<tr>
							<td height="20" width="10"></td>
							<td height="20" align="left">
								<span style="color: #6D6D6D;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:12px;text-shadow:none;">2.提成明细每月由系统自动生成.</span>
							</td>
							<td height="20" width="10"></td>
						</tr>
						
						<tr><td height="5" colspan="3"></td></tr>
						
					</table>
					
				</td>
				<td height="20" width="8"></td>
			</tr>
			
			<tr>
				<td height="4" width="8"></td>
				<td height="4" align="left"></td>
				<td height="4" width="8"></td>
			</tr>
							
		</table>
				
	</article>
</section>

</body>
	
</html>