<?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>客房云点通</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">

<section data-role="page" id="pagepayfor1">		
	<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>
	
	<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="index.php" data-role="button" data-icon="carat-l" data-iconpos="notext" rel="external"></a>
				</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">
								<input type="text" id="dtp1" name="dtp1" readonly= "true" value="<?php echo $datday1;?>" data-role="date">
							</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">
								<input type="text" id="dtp2" name="dtp2" readonly= "true" value="<?php echo $datday2;?>" data-role="date">
							</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="10" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFF">
			
			<tr><td height="1" colspan="3" bgcolor="#fff"></td></tr>
			
			<tr>
				<td width="5" ></td>
				<td height="25">
					<?php				
						$chainno=$_SESSION["ChainNo"];
						
						$rowid=0;
						
						$tradetime="";
						$username="";
						$paycash=0;
						$paycredit=0;
						$payvip=0;
						$payhang=0;
						$paydyq=0;
						$payother=0;
						$paysum=0;
						
						$paycashsum=0;
						$paycreditsum=0;
						$payvipsum=0;
						$payhangsum=0;
						$paydyqsum=0;
						$payothersum=0;
						$paysumsum=0;
						
						$PayUpWX=0;
						$PayUpALI=0;
						$PayUpSM=0;
						
						//开始去房间状态数量
						$sql=sprintf("SELECT ListNo,convert(varchar(16),TradeTime,120)AS TradeTime,TradeMan,
								PayUp_Cash,PayUp_Credit,PayUp_VIP,PayUp_Hang,PayUp_Ticket,PayUp_Other,PayUp_Sum,PayUp_WX,PayUp_ALI,PayUp_SM
								FROM TR_PayUp_List WHERE Chain_No='%s' AND TradeTime>='%s' AND TradeTime<='%s 23:59:59'
								ORDER BY TradeTime DESC",$chainno,$datday1,$datday2);
						
						$result = querySql($sql);		
						while($row = fetch_array($result))
						{
							//得到每一条的记录信息
							$tradetime=$row['TradeTime'];
							$username=$row['TradeMan'];
							$paycash=$row['PayUp_Cash'];
							$paycredit=$row['PayUp_Credit'];
							$payvip=$row['PayUp_VIP'];
							$payhang=$row['PayUp_Hang'];
							$paydyq=$row['PayUp_Ticket'];
							$payother=$row['PayUp_Other'];
							$paysum=$row['PayUp_Sum'];
							
							$PayUpWX=$row['PayUp_WX'];
							$PayUpALI=$row['PayUp_ALI'];
							$PayUpSM=$row['PayUp_SM'];
							
							$rowid=$rowid+1;
							
							$paycashsum=$paycashsum+$paycash;
							$paycreditsum=$paycreditsum+$paycredit;
							$payvipsum=$payvipsum+$payvip;
							$payhangsum=$payhangsum+$payhang;
							$paydyqsum=$paydyqsum+$paydyq;
							$payothersum=$payothersum+$payother;
							$paysumsum=$paysumsum+$paysum;
							
							$PayUpWXsum=$PayUpWXsum + $PayUpWX;
							$PayUpALIsum=$PayUpALIsum + $PayUpALI;
							$PayUpSMsum=$PayUpSMsum + $PayUpSM;
					?>
					
					<div data-role="none" class="STYLEM2">
						<table width="100%" height="25" border="0" cellpadding="0" cellspacing="0" bgcolor="#F6F2F2">
							<tr>
								<td width="5"></td>
								<td width="120" align="left"><span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;text-shadow:none;"><?php echo $tradetime;?></span></td>
								<td width="95" align="left"><span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;text-shadow:none;"><?php echo $username;?></span></td>
								<td align="left"><span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;text-shadow:none;">合计 <?php echo number_format($paysum,1);?></span></td>
							</tr>
						</table>
					</div>
					<div data-role="none" class="STYLEM35">
						<table width="100%" height="50" border="0" cellpadding="0" cellspacing="0">
							<tr>
								<td width="5"></td>
								<td width="120" align="left">现金 <?php echo number_format($paycash,1);?></td>
								<td width="95" align="left">信用卡 <?php echo number_format($paycredit,1);?></td>
								<td align="left">抵用券 <?php echo number_format($paydyq,1);?></td>
							</tr>
							<tr>
								<td width="5"></td>
								<td width="120" align="left">微信 <?php echo number_format($PayUpWX,1);?> </td>
								<td width="95" align="left">支付宝 <?php echo number_format($PayUpALI,1);?></td>
								<td align="left">扫码支付 <?php echo number_format($PayUpSM,1);?></td>
							</tr>
							<tr>
								<td width="5"></td>
								<td width="120" align="left">挂账 <?php echo number_format($payhang,1);?> </td>
								<td width="95" align="left">会员卡 <?php echo number_format($payvip,1);?></td>
								<td align="left">其他 <?php echo number_format($payother+$paylkl,1);?></td>
							</tr>
						</table>
					</div>
							
					
					<?php
						}
						//释放数据库
						freeResult($result);
						closeDb();
					?>
				</td>
				<td width="5" ></td>
			</tr>
			
		</table>
		
	</article>
	
	<footer data-role="footer" data-position="fixed">
		<?php
			if($rowid>0)
			{	//添加合计行===========================================================================================================
		?>
		<table width="100%" height="10" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFF">
			<tr height="28" bgcolor="#F6F2F2">
				<td width="10"></td>
				<td align="left">
					<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:14px;text-shadow:none;">总计 <?php echo number_format($paysumsum,1);?></span>
				</td>
			</tr>
			<tr height="28" bgcolor="#fff">
				<td height="28" colspan="2">
					<table width="100%" height="36" border="0" cellpadding="0" cellspacing="0">
						<tr>
							<td width="2%"></td>
							<td width="33%" align="left"><span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:12px;text-shadow:none;">现金 <?php echo number_format($paycashsum,1);?> </span></td>
							<td width="33%" align="left"><span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:12px;text-shadow:none;">信用卡 <?php echo number_format($paycreditsum,1);?></span></td>
							<td width="32%" align="left"><span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:12px;text-shadow:none;">抵用券 <?php echo number_format($paydyqsum,1);?></span></td>
						</tr>
						<tr>
							<td width="2%"></td>
							<td width="33%" align="left"><span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:12px;text-shadow:none;">微信 <?php echo number_format($PayUpWXsum,1);?></span> </td>
							<td width="33%" align="left"><span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:12px;text-shadow:none;">支付宝 <?php echo number_format($PayUpALIsum,1);?></span></td>
							<td width="32%" align="left"><span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:12px;text-shadow:none;">扫码支付 <?php echo number_format($PayUpSMsum,1);?></span></td>
						</tr>
						<tr>
							<td width="2%"></td>
							<td width="33%" align="left"><span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:12px;text-shadow:none;">挂账 <?php echo number_format($payhangsum,1);?> </span></td>
							<td width="33%" align="left"><span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:12px;text-shadow:none;">会员卡 <?php echo number_format($payvipsum,1);?></span></td>
							<td width="32%" align="left"><span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:12px;text-shadow:none;">其他 <?php echo number_format($payothersum+$paylklsum,1);?></span></td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
		 	
		<?php
			}
			else
			{
		?>
		<table width="100%" height="1" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
			<tr><td height="1"></td></tr>
		</table>
		<?php
			}
			//=====================================================================================================================
		?>
		
		<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='payforlist.php?datday1=' + strday1 + '&datday2=' + strday2;
			}
			
		 	
		</script>
		
	</footer>
	
	<script tyle="text/javascript"> 
		//处理点击事件进入相应的页面
		function gbClick(id)
		{ 
			switch (id)
			{
				case -1:	//返回
					parent.window.location.href='index.php';
					//window.location.href="repRoomView.php?roomstate=*";
					break;
				case 0:	//刷新
					//parent.window.location.href='index.php';
					window.location.href="payforlist.php?datday1=" + $dp.$('dtp1').value + "&datday2=" + $dp.$('dtp2').value;
					break;
			}
		}
			
	</script> 
	
</section>

</body>
</html>
