<?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;
	}
	
	$datday1=$_REQUEST["datday1"];
	$datday2=$_REQUEST["datday2"];
	
	//echo $datday1."**".$datday2;;
	
	if($datday1=="" | $datday2=="")
	{
		//设置默认日期
		$strtemp=getdate();
		$strtemp1=date("Y-m-d",strtotime("-20 day"));
		//$strtemp1=date('Y-m-d',$strtemp - 1*24*60*60);
		$datday1= $strtemp1;//[year]."-".sprintf("%02d",$strtemp1[mon])."-".sprintf("%02d",$strtemp1[mday]);
		$datday2= $strtemp[year]."-".sprintf("%02d",$strtemp[mon])."-".sprintf("%02d",$strtemp[mday]);
	}
	//echo $datday1."+++".$datday2."**".$strtemp1;
?>
<!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"> 
	<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>
	
</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="pagepayfor1">		
	
	<header data-role="header" data-position="fixed" data-tap-toggle="false">
		<table width="100%" height="35" border="0" cellpadding="0" cellspacing="0">	   
			<tr>
				<td height="35" width="45" align="right">
					<a href="../indexm.php?rset=0" data-role="button" data-icon="home" data-iconpos="notext" rel="external"></a>
				</td>
				<td height="35" width="6" align="right"></td>
				<td height="35" align="left" colspan="2">
					<table width="100%" height="10" border="0" cellpadding="0" cellspacing="0">
						<tr>
							<td width="10" align="left"></td>
							<td width="90" align="left"  class="STYLEM2">
								<span style="color:#000 ;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:14px;text-shadow:none;">
								<input type="text" id="dtp1" name="dtp1" readonly= "true" value="<?php echo $datday1;?>" data-role="date">
								</span>
							</td>
							
							<td width="20" align="center" ><span style="color:#000 ;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:14px;text-shadow:none;">至</span></td>
							
							<td width="90" align="left"  class="STYLEM2">
								<span style="color:#000 ;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:14px;text-shadow:none;">
								<input type="text" id="dtp2" name="dtp2" readonly= "true" value="<?php echo $datday2;?>" data-role="date">
								</span>
							</td>
							<td width="5" align="center"></td>
							<td width="80" align="left"  class="STYLEM2">
								<div id="bmtSendOk" onClick="OnSendFindClick()" style="border-radius:3px; width:70px; height:28px; background-color:#D7AA28;opacity:0.9;">
									<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 align="left">&nbsp;</td>
						</tr>
					</table>
					
					
				</td>
			</tr>		  
			
		</table>
	</header>
	
	
	<article data-role="none" style="background-color:#fff" >
		<table width="100%" height="1" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFF">
			
			<tr>
				<td height="1" width="6" ></td>
				<td height="1">
					<?php				
						$chainno=$_SESSION["ChainNo"];
						
						$intRowID=0;
						
						$strSubNo='';
						$strVipName='';
						$strVipType='';
						$strChainNo='';
						$strTradeTime='';
						$fltPayForVal=0;
						$fltPayFreeVal=0;
						$strPayType='';
						$strRemarks='';
						$strUserName='';
						$strTakePlace='';
						
						$strVipNoName='';
						
						//开始去房间状态数量
						$sql=sprintf("Select a.Sub_No,b.VIP_Name,b.VIP_Type,b.Chain_No,convert(varchar(16),a.Trade_Date,120)AS Trade_Date,
								a.PayFor_Val,a.PayFree_Val,a.PayMent_Type,a.Remarks,a.User_Name,a.Take_Place
								From VIP_Consume_List a,VIP_Main b Where a.VIP_No = b.VIP_No And (a.PayFor_Val <> 0 OR a.PayFree_Val<>0)
								And a.Chain_No='%s' And a.Trade_Date>='%s' And a.Trade_Date<='%s 23:59:59' 
								Order By a.Trade_Date DESC",$chainno,$datday1,$datday2);

						$result = querySql($sql);		
						while($row = fetch_array($result))
						{
							$intRowID = $intRowID + 1;
							//得到每一条的记录信息
							$strSubNo=$row['Sub_No'];
							$strVipName=$row['VIP_Name'];
							$strVipType=$row['VIP_Type'];
							$strChainNo=$row['Chain_No'];
							$strTradeTime=$row['Trade_Date'];
							$fltPayForVal=$row['PayFor_Val'];
							$fltPayFreeVal=$row['PayFree_Val'];
							$strPayType=$row['PayMent_Type'];
							$strRemarks=$row['Remarks'];
							$strUserName=$row['User_Name'];
							$strTakePlace=$row['Take_Place'];
						
							if(strlen($strVipName)>0)
							{
								$strVipNoName=$strSubNo.'|'.$strVipName;
							}
							else
							{
								$strVipNoName=$strSubNo;
							}
							
					?>
					
					<div data-role="none" class="STYLEM2">
						<table width="100%" height="30" cellpadding="0" cellspacing="0" style="border-left: 1px solid #F6F2F2;border-right: 1px solid #F6F2F2;">
							<tr bgcolor="#F6F2F2">
								<td height="30" width="6"></td>
								<td height="30" width="110" align="left">
									<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:12px;text-shadow:none;"><?php echo $strTradeTime;?></span>
								</td>
								
								<td height="30" width="120" align="right">
									<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:12px;text-shadow:none;"><?php echo $strVipNoName;?></span>
								</td>
								
								<td height="30" align="right">
									<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:12px;text-shadow:none;"><?php echo $strVipType;?></span>
								</td>
								<td height="30" width="6"></td>
							</tr>
							
							<tr>
								<td height="25" width="6"></td>
								<td height="25" width="110" align="left">
									<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:12px;text-shadow:none;">方式：<?php echo $strPayType;?></span>
								</td>
								
								<td height="25" width="120" align="right">
									<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:12px;text-shadow:none;">充值:￥<?php echo number_format($fltPayForVal,1);?></span>
								</td>
								
								<td height="25" align="right">
									<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:12px;text-shadow:none;">赠送:￥<?php echo number_format($fltPayFreeVal,1);?></span>
								</td>
								<td height="25" width="6"></td>
							</tr>
							
							<tr>
								<td height="25" width="6"></td>
								<td height="25" width="110" align="left">
									<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:12px;text-shadow:none;">部门：<?php echo $strTakePlace;?></span>
								</td>
								
								<td height="25" width="120" align="right">
									<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:12px;text-shadow:none;">交易地:<?php echo $strChainNo;?></span>
								</td>
								
								<td height="25" align="right">
									<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:12px;text-shadow:none;"><?php echo $strUserName;?></span>
								</td>
								<td height="25" width="6"></td>
							</tr>
							
							<tr>
								<td height="25" width="6"></td>
								<td height="25" colspan="3" align="left">
									<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:12px;text-shadow:none;">备注：<?php echo $strRemarks;?></span>
								</td>
								<td height="25" width="6"></td>
							</tr>
							
							
							
							<tr bgcolor="#F6F2F2"><td height="1" colspan="5" align="center"></tr>
							
						</table>
						
						<table width="100%" height="8" border="0"  cellpadding="0" cellspacing="0">
							<tr><td height="8"></td></tr>
						</table>
					</div>
							
					<?php
						}
						//释放数据库
						freeResult($result);
					?>
					

					<div data-role="none" class="STYLEM2">
						<table width="100%" height="30" border="0" cellpadding="0" cellspacing="0"  style="border-left: 1px solid #F6F2F2;border-right: 1px solid #F6F2F2;">
							<tr bgcolor="#f5efe8">
								<td height="30" width="6"></td>
								<td height="30" width="100" align="left">
									<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;text-shadow:none;">充值方式</span>
								</td>
								
								<td height="30" width="120" align="right">
									<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;text-shadow:none;">充值金额</span>
								</td>
								
								<td height="30" align="right">
									<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;text-shadow:none;">赠送金额</span>
								</td>
								<td height="30" width="6"></td>
							</tr>
							
					<?php
						$intRowID=0;
						
						$strPayType='';
						$fltPayForVal=0;
						$fltPayFreeVal=0;
						
						$fltPayForSum=0;
						$fltPayFreeSum=0;
						
						$sql=sprintf("Select a.PayMent_Type,Sum(a.PayFor_Val)As SumPayForVal,Sum(a.PayFree_Val)As SumPayFreeVal
							From VIP_Consume_List a,VIP_Main b Where a.VIP_No = b.VIP_No And (a.PayFor_Val <> 0 Or a.PayFree_Val <> 0)
							And a.Chain_No='%s' And a.Trade_Date>='%s' And a.Trade_Date<='%s 23:59:59' 
							Group By a.PayMent_Type",$chainno,$datday1,$datday2);
						
						$result = querySql($sql);		
						while($row = fetch_array($result))
						{
							$intRowID = $intRowID + 1;
							//得到每一条的记录信息
							$strPayType=$row['PayMent_Type'];
							$fltPayForVal=$row['SumPayForVal'];
							$fltPayFreeVal=$row['SumPayFreeVal'];
							
							$fltPayForSum=$fltPayForSum + $fltPayForVal;
							$fltPayFreeSum=$fltPayFreeSum + $fltPayFreeVal;
					?>
						
							<tr>
								<td height="30" width="6"></td>
								<td height="30" width="100" align="left">
									<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;text-shadow:none;"><?php echo $strPayType;?></span>
								</td>
								
								<td height="30" width="120" align="right">
									<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;text-shadow:none;">￥<?php echo number_format($fltPayForVal,1);?></span>
								</td>
								
								<td height="30" align="right">
									<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;text-shadow:none;">￥<?php echo number_format($fltPayFreeVal,1);?></span>
								</td>
								<td height="30" width="6"></td>
							</tr>
						
					<?php
						}
						freeResult($result);
						closeDb();
					?>
					
							<tr bgcolor="#fbf9f9">
								<td height="30" width="6"></td>
								<td height="30" width="100" align="left">
									<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;text-shadow:none;">合计：</span>
								</td>
								
								<td height="30" width="120" align="right">
									<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;text-shadow:none;">￥<?php echo number_format($fltPayForSum,1);?></span>
								</td>
								
								<td height="30" align="right">
									<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;text-shadow:none;">￥<?php echo number_format($fltPayFreeSum,1);?></span>
								</td>
								<td height="30" width="6"></td>
							</tr>
							
							
							<tr bgcolor="#F6F2F2"><td height="1" colspan="5" align="center"></tr>
						</table>
						
						<table width="100%" height="4" border="0"  cellpadding="0" cellspacing="0">
							<tr><td height="4"></td></tr>
						</table>
					</div>
					
				</td>
				<td height="1" width="6" ></td>
			</tr>
			
		</table>
		
		
	</article>
	
	
	
	<script type="text/javascript">
		//相应查询按钮的事件
		function OnSendFindClick()
		{
			var strday1 = $("#dtp1").val();
			var strday2 = $("#dtp2").val();
			if(strday1=="")
			{	
				$("#dtp1").focus();
				return;
			}
			if(strday2=="")
			{	
				$("#dtp2").focus();
				return;
			}
			parent.window.location.href='reppayforvip.php?datday1=' + strday1 + '&datday2=' + strday2;
		};
		 	
	</script>
		
		
</section>

</body>
</html>
