<?php
	session_start();
	ini_set('session.gc_maxlifetime', 99999999); //设置时间 永不过期
	
	$intFristLoadPage=$_REQUEST['flpid'];
	
	//判断是否登录系统
	if($_SESSION['main_wx_userlogined']!="1" | $_SESSION['main_wx_userno']=="")
	{
		//没有登录开始启动登录
		header('location:..\loginwx.php?rset=0');
		exit;
	}
	
	require_once("db/db.php");	
	require_once("common/common.php");
	$userno=trim($_SESSION['main_wx_userno']);
	
	//加载登陆用户的资料信息
	if($intFristLoadPage>0)
	{
		//登录成功
		$_SESSION['ChainCount_ydtpos'] ="1";
		$_SESSION['ChainNo_ydtpos'] = "";  
		$_SESSION['ChainName_ydtpos'] = "";  
		$_SESSION['userno_ydtpos'] = $userno;  
		$_SESSION['pswd_ydtpos'] = $pswd;
		$_SESSION['logintime_ydtpos'] = time();
		$_SESSION['loginflag_ydtpos'] ="1";
		
		$_SESSION['hotelday_ydtpos'] ="";
		$_SESSION['updatetime_ydtpos'] ="";
		$_SESSION['updatestate_ydtpos'] ="";
		
		$intRowCount=0;
		//得到该用户可以访问的分店信息
		$sql=sprintf("SELECT TOP 2 a.Chain_No,a.Chain_Name,a.Web_State,convert(varchar(19),a.Web_Date,120)AS WebTime,convert(varchar(10),a.HotelDate,120) AS HotelDay
			FROM Chain_Infor a,dbo.TRF_AppGetChainFromUser('%s') b WHERE a.Chain_No=b.Chain_No;",$userno);
			
		$result = querySql($sql);
		
		while($row = fetch_array($result))
		{
			if($intRowCount==0)
			{
				$_SESSION['ChainNo_ydtpos'] = $row['Chain_No'];  
				$_SESSION['ChainName_ydtpos'] = $row['Chain_Name']; 
				
				$_SESSION['hotelday_ydtpos'] = $row['HotelDay'];
				$_SESSION['updatetime_ydtpos'] = $row['WebTime'];
											
				$intWebState=$row['Web_State'];
				$swebstate="";
				switch($intWebState)
				{
					case 1:
						$swebstate="传输";
						break;
					case 2:
						$swebstate="完成";
						break;
					case 3:
						$swebstate="错误";
						break;
					default:
						$swebstate="停止";
						break;
				}
				
				$_SESSION['updatestate_ydtpos'] =$swebstate; 
			}
			
			$intRowCount=$intRowCount +1;
		}
		
				
		//判断是否有多条记录
		if($intRowCount>1)
		{
			$_SESSION['ChainCount_ydtpos'] ="2";
		}
		else
		{
			$_SESSION['ChainCount_ydtpos'] ="1";
		}
			
		freeResult($result);
	}
		
	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">

	<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>
	<link rel="stylesheet" href="css/mycss.css"> 
	
	<script>
		//清空登录信息资料
		var ddt=<?php echo $_SESSION["main_defusernoflag_ydtpos"]; ?>;
		if(ddt=="1")
		{	ddt=<?php echo $_SESSION["main_defuserno_ydtpos"]; ?>;
			localStorage["main_defuserno_ydtpos"]=ddt;
		}
	</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();
	}
	
	function bmtSelNewChain()
	{	
		window.location="getchain.php";
	};
</script>

<?php
		require_once("db/db.php");	
		require_once("common/common.php");
		
		$strchainnoget=trim($_REQUEST['selno']);
		$strwebhotelday=trim($_REQUEST['htday']);	//营业日期
		$strDeptListNo=trim($_REQUEST['seldpt']);	//当前部门ListNo
		$strDeptName='';
		$strChainNo='';
		$strChainName='';
		$strnewhotelday="2010-01-01";
		
		if($strDeptListNo=="**")
		{
			$strDeptListNo="";
			$_SESSION['ChainDepartName_ydtpos'] = "";
			$_SESSION['ChainDepartListNo_ydtpos'] = "";
		}
		
		if(strlen($strchainnoget)<1)
		{
			$strnewchainno=$_SESSION['ChainNo_ydtpos'];
		}
		else
		{
			$strnewchainno=$strchainnoget;
		}
		
		if(strlen($strDeptListNo)>0)
		{
			//如果有部门流水号传入
			$sql=sprintf("SELECT a.ListNo,a.DepartName,b.Chain_No,b.Chain_Name,convert(varchar(10),dateadd(day,-1,GetDate()),120)AS hotelday FROM TCP_Depart_Inform a,Chain_Infor b WHERE b.Chain_No=a.Chain_No And a.ListNo=%s",$strDeptListNo);
		
			$result = querySql($sql);
			if($row = fetch_array($result))
			{
				$strDeptListNo = $row['ListNo'];
				$strDeptName = $row['DepartName'];
				$strChainNo = $row['Chain_No'];
				$strChainName = $row['Chain_Name'];
				
				$strnewhotelday = $row['hotelday'];
				
				$_SESSION['ChainDepartName_ydtpos'] = $strDeptName;
				$_SESSION['ChainDepartListNo_ydtpos'] = $strDeptListNo;
				$_SESSION['ChainNo_ydtpos'] = $strChainNo;  
				$_SESSION['ChainName_ydtpos'] = $strChainName; 
			}
			freeResult($result);	//释放数据库
		}
		else
		{
			$intNextFlag=0;
			
			if(strlen($strchainnoget)>0)
			{
				if($strchainnoget==trim($_SESSION['ChainNo_ydtpos']))
				{
					$intNextFlag=1;
				}
				else
				{
					//分店号不同
					$_SESSION['ChainDepartListNo_ydtpos']="";
					$_SESSION['ChainDepartName_ydtpos']="";
					$_SESSION['ChainNo_ydtpos']="";
					$_SESSION['ChainName_ydtpos']="";
					
					$strDeptListNo = trim($_SESSION['ChainDepartListNo_ydtpos']);
					$strDeptName = trim($_SESSION['ChainDepartName_ydtpos']);
					$strChainNo = trim($_SESSION['ChainNo_ydtpos']);
					$strChainName = trim($_SESSION['ChainName_ydtpos']);
				
					$sql=sprintf("SELECT Chain_No,Chain_Name,convert(varchar(10),dateadd(day,-1,GetDate()),120)AS hotelday FROM Chain_Infor WHERE Chain_No='%s'",$strchainnoget);
					$result = querySql($sql);
					if($row = fetch_array($result))
					{
						$strChainNo = $row['Chain_No'];
						$strChainName = $row['Chain_Name'];
						
						$strnewhotelday = $row['hotelday'];
						
						$_SESSION['ChainNo_ydtpos'] = $strChainNo;  
						$_SESSION['ChainName_ydtpos'] = $strChainName; 
					}
					freeResult($result);	//释放数据库
				}
			}
			else
			{
				$intNextFlag=1;
			}
			
			if($intNextFlag>0)
			{
				$strDeptListNo = trim($_SESSION['ChainDepartListNo_ydtpos']);
				$strDeptName = trim($_SESSION['ChainDepartName_ydtpos']);
				$strChainNo = trim($_SESSION['ChainNo_ydtpos']);
				$strChainName = trim($_SESSION['ChainName_ydtpos']);
				
				$sql=sprintf("SELECT convert(varchar(10),dateadd(day,-1,GetDate()),120)AS hotelday");
				$result = querySql($sql);
				if($row = fetch_array($result))
				{
					$strnewhotelday = $row['hotelday'];
				}
				freeResult($result);	//释放数据库
			}
		}
				
				
		//如果部门为空则获取部门的第一个部门
		if(strlen($strDeptListNo)<1)
		{
			$sql=sprintf("SELECT top 1 a.ListNo,a.DepartName,b.Chain_No,b.Chain_Name,convert(varchar(10),dateadd(day,-1,GetDate()),120)AS hotelday FROM TCP_Depart_Inform a,Chain_Infor b WHERE b.Chain_No=a.Chain_No And b.Chain_No='%s' order by a.ListNo ASC",$strnewchainno);
			$result = querySql($sql);
			if($row = fetch_array($result))
			{
				$strDeptListNo = $row['ListNo'];
				$strDeptName = $row['DepartName'];
				$strChainNo = $row['Chain_No'];
				$strChainName = $row['Chain_Name'];
				
				$strnewhotelday = $row['hotelday'];
				
				$_SESSION['ChainDepartName_ydtpos'] = $strDeptName;
				$_SESSION['ChainDepartListNo_ydtpos'] = $strDeptListNo;
				$_SESSION['ChainNo_ydtpos'] = $strChainNo;  
				$_SESSION['ChainName_ydtpos'] = $strChainName; 
			}
			freeResult($result);	//释放数据库
			
			if(strlen($strDeptListNo)<1)
			{
				$sql=sprintf("SELECT Chain_No,Chain_Name,convert(varchar(10),dateadd(day,-1,GetDate()),120)AS hotelday FROM Chain_Infor WHERE Chain_No='%s'",$strnewchainno);
				$result = querySql($sql);
				if($row = fetch_array($result))
				{
					$strChainNo = $row['Chain_No'];
					$strChainName = $row['Chain_Name'];
					
					$strnewhotelday = $row['hotelday'];
					
					$_SESSION['ChainNo_ydtpos'] = $strChainNo;  
					$_SESSION['ChainName_ydtpos'] = $strChainName; 
				}
				freeResult($result);	//释放数据库
			}
		}

		if(strlen($strwebhotelday)==10)
		{
			//有传入的日期
			$strnewhotelday=$strwebhotelday;
		}

		//营业日期
		$strHotelDayTemp=$strnewhotelday;
		
		//$strHotelDayTemp="2014-12-11";
		
		$_SESSION['HotelDate_ydtpos']= $strHotelDayTemp;  
		$strHotelMonthDay=substr($strHotelDayTemp,0,7);
		
		//得到主要最新的营业数据信息		
		$intBillCountDay=0;		//单据数量
		$intBillCountMonth=0;	//本月累计
		
		$intManCountDay=0;		//人数
		$intManCountMonth=0;	//
		
		$fltScoreValDay=0;		//消费金额
		$fltScoreValMonth=0;
		
		$fltServiceDay=0;		//服务费
		$fltServiceMonth=0;	
		
		$fltRateValDay=0;		//折扣金额
		$fltRateValMonth=0;
		
		$fltZheHouValDay=0;		//折扣后金额
		$fltZheHouValMonth=0;	
		
		$fltAllBillValDay=0;	//整单折扣
		$fltAllBillValMonth=0;
		
		$fltFactValDay=0;		//实收金额
		$fltFactValMonth=0;		
		
		if(strlen($strDeptListNo)<1)
		{
			$strDeptListNo="0";
		}
		
		//1.当日金额
		if(strlen($strDeptListNo)>0)
		{
			$sql=sprintf("SELECT Count(a.Bill_No)AS BillCount,SUM(a.ManCount)AS ManCount,Sum(a.ItemValue)AS SumValue,Sum(a.ShouldValue)AS SumValueZH,Sum(a.AllBillRate)AS SumAllBillRate,
					Sum(a.FactValue)AS SumPayFor FROM TCP_Bill_Inform a,TCP_Depart_Inform b 
					Where a.DListNo=b.ListNo And a.BillState=2 And a.ReckonTime>='%s' And a.ReckonTime<='%s 23:59:59' AND b.ListNo=%s",$strHotelDayTemp,$strHotelDayTemp,$strDeptListNo);
					//Where a.DListNo=b.ListNo And a.BillState=2 And a.ReckonTime>='2019-01-01' And a.ReckonTime<='%s 23:59:59' AND b.ListNo=%s",$strHotelDayTemp,$strDeptListNo);
						
			$result = querySql($sql);		
			$row = fetch_array($result);
			$intBillCountDay = $row['BillCount'];		//单据数量
			$intManCountDay = $row['ManCount'];			//人数
			$fltScoreValDay = $row['SumValue'];			//消费金额折扣前
			$fltScoreZKHDay = $row['SumValueZH'];		//消费金额折扣后
			$fltAllBillValDay = $row['SumAllBillRate'];	//整单折扣
			$fltFactValDay = $row['SumPayFor'];			//实收金额
			//释放数据库
			freeResult($result);
		}

		//closeDb();
		
		$fltRateValDay = round($fltScoreValDay - $fltFactValDay - $fltAllBillValDay, 1);  //折扣金额 =消费总额 - 实收金额 - 整单折扣
        $fltZheHouValDay= round($fltScoreValDay - $fltRateValDay, 1);   //折后金额 =消费总额 - 折扣金额
		
		//2.本月金额
		if(strlen($strDeptListNo)>0)
		{
			$sql=sprintf("SELECT Count(a.Bill_No)AS BillCount,SUM(a.ManCount)AS ManCount,Sum(a.ItemValue)AS SumValue,Sum(a.ShouldValue)AS SumValueZH,Sum(a.AllBillRate)AS SumAllBillRate,
				Sum(a.FactValue)AS SumPayFor FROM TCP_Bill_Inform a,TCP_Depart_Inform b 
				Where a.DListNo=b.ListNo And a.BillState=2 And a.ReckonTime>='%s-01' And a.ReckonTime<='%s 23:59:59' AND b.ListNo=%s",$strHotelMonthDay,$strHotelDayTemp,$strDeptListNo);
				//Where a.DListNo=b.ListNo And a.BillState=2 And a.ReckonTime>='2019-01-01' And a.ReckonTime<='%s 23:59:59' AND b.ListNo=%s",$strHotelDayTemp,$strDeptListNo);
		
			$result = querySql($sql);		
			$row = fetch_array($result);
			$intBillCountMonth = $row['BillCount'];			//单据数量
			$intManCountMonth = $row['ManCount'];			//人数
			$fltScoreValMonth = $row['SumValue'];			//消费金额折扣前
			$fltScoreZKHMonth = $row['SumValueZH'];			//消费金额折扣后
			$fltAllBillValMonth = $row['SumAllBillRate'];	//整单折扣
			$fltFactValMonth = $row['SumPayFor'];			//实收金额
			//释放数据库
			freeResult($result);
		}
		closeDb();
		
		$fltRateValMonth = round($fltScoreValMonth - $fltFactValMonth - $fltAllBillValMonth, 1);  //折扣金额 =消费总额 - 实收金额 - 整单折扣
        $fltZheHouValMonth= round($fltScoreValMonth - fltRateValMonth, 1);   //折后金额 =消费总额 - 折扣金额
		
		
		//3.开始显示数据
	?>
	
<body leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0">
<!--第一个页面的内容实现---------------------------->
<section data-role="page" id="page1">
	<header data-role="header" data-position="fixed" data-tap-toggle="false">
		<table width="100%" height="45" border="0" cellpadding="0" cellspacing="0">
		   <tr>
			<td height="45" width="45" align="right">
				<a href="..\indexm.php?rset=0" data-transition="flip" target="_blank" data-role="button" data-icon="home" data-iconpos="notext">
			</td>
			<td height="45" align="center" valign="middle">
	                <span onClick="bmtSelNewChain();" id="MsgTxt" style="color:#000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:19px;text-shadow:none;"><?php echo $strChainName;?></span>
					<img onClick="bmtSelNewChain();" src="images\icon_up2.png" width="15" height="10" border="0" style="margin-top:5px;">
            </td>
			<td height="45" width="45" align="left">
				<a href="getdepart.php?sldpart=<?php echo $strDeptListNo;?>" data-role="button" data-icon="bars" data-iconpos="notext" data-direction="reverse"></a>
			</td>
		  </tr>
		</table>
	</header>
			
	<article data-role="none">
		<table width="100%" height="50" border="0" cellpadding="0" cellspacing="0">
			<tr>
				<td height="10" width="20"></td>
				<td height="10" width="120" align="left"></td>
				<td height="10" align="right"></td>
				<td height="10" width="20"></td>
			</tr>
			<!--
			<tr>
				<td height="20" width="20"></td>
				<td height="20" colspan="2" align="center"><font size="5"><?php echo $_SESSION['ChainDepartName_ydtpos'];?></font></td>
				<td height="20" width="20"></td>
			</tr>
			<tr>
				<td height="5" width="20"></td>
				<td height="5" width="120" align="left"></td>
				<td height="5" align="right"></td>
				<td height="5" width="20"></td>
			</tr>
			-->
			<tr>
				<td height="25" width="20"></td>
				<td height="25" width="140" align="left"><font size="5">营业收入</font></td>
				<td height="25" align="right"><font size="5">￥<?php echo number_format($fltFactValDay,1); ?></font><font size="2">(元)</font></td>
				<td height="25" width="20"></td>
			</tr>
					
			<tr>
				<td height="25" width="20"></td>
				<td height="25" width="140" align="left" color="#F2E2E2"><font size="3">本月累计</font></td>
				<td height="25" align="right"><font size="3">￥<?php echo number_format($fltFactValMonth,1); ?></font><font size="2">(元)</font></td>
				<td height="25" width="20"></td>
			</tr>
			
			<tr>
				<td height="8" width="20"></td>
				<td height="8" width="120" align="left"></td>
				<td height="8" align="right"></td>
				<td height="8" width="20"></td>
			</tr>
		</table>
		<?php 
			//开始得到付款方式统计信息
			$strPayForType="";	//付款方式
			$fltPayValDay=0;
			$fltPayValMonth=0;
			$fltPaySumDay=0;
			$fltPaySumMonth=0;
			
			if(strlen($strDeptListNo)>0)
			{
				$sql=sprintf("SELECT PayForType,SUM(PayForVal)AS SumPayFor,SUM(PayForValM)AS SumPayForM FROM (
						SELECT b.PayForType,SUM(b.PayForVal)AS PayForVal,0 AS PayForValM
						FROM TCP_Bill_Inform a,TCP_Bill_PayFor b 
						WHERE b.Bill_No=a.Bill_No And a.BillState=2 And a.ReckonTime>='%s' And a.ReckonTime<='%s 23:59:59' AND a.DListNo=%s
						GROUP BY b.PayForType UNION

						SELECT b.PayForType,0 AS PayForVal,SUM(b.PayForVal) AS PayForValM
						FROM TCP_Bill_Inform a,TCP_Bill_PayFor b 
						WHERE b.Bill_No=a.Bill_No And a.BillState=2 And a.ReckonTime>='%s-01' And a.ReckonTime<='%s 23:59:59' AND a.DListNo=%s
						GROUP BY b.PayForType) t GROUP BY t.PayForType ORDER BY t.PayForType ASC",$strHotelDayTemp,$strHotelDayTemp,$strDeptListNo,$strHotelMonthDay,$strHotelDayTemp,$strDeptListNo);


				$result = querySql($sql);
				while($row = fetch_array($result))
				{
					$strPayForType=$row['PayForType'];
					$fltPayValDay=$row['SumPayFor'];
					$fltPayValMonth=$row['SumPayForM'];
			?>
				<table width="100%" height="30" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
					<tr bgcolor="#F2E2E2">
						<td height="1" width="20"></td>
						<td height="1" width="120" align="left"></td>
						<td height="1" align="right"></td>
						<td height="1" width="20"></td>
					</tr>
					
					<tr>
						<td height="5" width="20"></td>
						<td height="5" width="120" align="left"></td>
						<td height="5" align="right"></td>
						<td height="5" width="20"></td>
					</tr>
				
					<tr>
						<td height="20" width="20"></td>
						<td height="20" width="120" align="left"><font size="4"><?php echo $strPayForType;?></font></td>
						<td height="20" align="right"><font size="4"><?php echo number_format($fltPayValDay,1);?></font><font size="2">(元)</font></td>
						<td height="20" width="20"></td>
					</tr>
							
					<tr>
						<td height="20" width="20"></td>
						<td height="20" width="130" align="left" color="#F2E2E2"><font size="2.5">本月累计</font></td>
						<td height="20" align="right"><font size="2.5"><?php echo number_format($fltPayValMonth,1);?></font><font size="2">(元)</font></td>
						<td height="20" width="20"></td>
					</tr>
					
					<tr>
						<td height="5" width="20"></td>
						<td height="5" width="120" align="left"></td>
						<td height="5" align="right"></td>
						<td height="5" width="20"></td>
					</tr>
					
					
				</table>
			<?php
					
					//生成合计
					$fltPaySumDay=$fltPaySumDay + $fltPayValDay;
					$fltPaySumMonth=$fltPaySumMonth + $fltPayValMonth;
				}			
			//释放数据库
			freeResult($result);
		}
		//closeDb();
		
		?>
		<table width="100%" height="1" border="0" cellpadding="0" cellspacing="0" bgcolor="#F5F5FA">
			<tr bgcolor="#F2E2E2">
				<td height="1" width="20"></td>
				<td height="1" width="120" align="left"></td>
				<td height="1" align="right"></td>
				<td height="1" width="20"></td>
			</tr>
			
			<tr>
				<td height="45" width="20"></td>
				<td height="45" colspan="2" align="center">
					<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
						<tr><td height="5" width="100" align="center" valign="middle"></td></tr>
						<?php if(strlen($strDeptName)>0) { ?>
							<tr>
								<td height="30" width="100" align="center" valign="middle">
									<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:17px;">部门：<?php echo $strDeptName;?></span>
								</td>
							</tr>
							<tr><td height="1" width="100" bgcolor="#F2E2E2"></td></tr>
						<?php } ?>
						
						<tr>
							<td height="40" width="100" align="center" valign="middle">
								
								<div onClick="window.location.href='getday.php?htday=<?php echo $strnewhotelday;?>';" >
									<table width="190" height="100%" border="0" cellpadding="0" cellspacing="0">
										<tr>
											<td width="160" align="right" valign="middle">
												<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:17px;">营业日:&nbsp;&nbsp;<?php echo $strnewhotelday;?></span>
											</td>
											<td width="5" width="10"></td>
											<td width="25" align="left" valign="middle">
												<div style="padding-top: 3px;"><IMG src="images/arrow.png" border=0></div>
											</td>
											
											
										</tr>
									</table>
								</div>
							</td>
						</tr>
						
					</table>
				</td>
				<td height="45" width="20"></td>
			</tr>
			<tr bgcolor="#F2E2E2">
				<td height="1" width="20"></td>
				<td height="1" width="120" align="left"></td>
				<td height="1" align="right"></td>
				<td height="1" width="20"></td>
			</tr>
		</table>
							
		<table width="100%" height="10" border="0" cellpadding="0" cellspacing="0">
			<tr>
				<td align="center"><img src="submealimg.php?HotelDate=<?php echo $strHotelDayTemp;?>&ChainNo=<?php echo $strnewchainno;?>&DepartName=<?php echo $strDeptName;?>&DepListNo=<?php echo $strDeptListNo;?>"></td>
			</tr>
		</table>		
		
		<table width="100%" height="30" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
			<tr bgcolor="#F2E2E2">
				<td height="1" width="20"></td>
				<td height="1" width="120" align="left"></td>
				<td height="1" align="right"></td>
				<td height="1" width="20"></td>
			</tr>
			
			<tr>
				<td height="5" width="20"></td>
				<td height="5" width="120" align="left"></td>
				<td height="5" align="right"></td>
				<td height="5" width="20"></td>
			</tr>
			
			<tr>
				<td height="20" width="20"></td>
				<td height="20" width="120" align="left"><font size="4">单据数量</font></td>
				<td height="20" align="right"><font size="4"><?php echo number_format($intBillCountDay); ?></font><font size="2">(张)</font></td>
				<td height="20" width="20"></td>
			</tr>
					
			<tr>
				<td height="20" width="20"></td>
				<td height="20" width="130" align="left" color="#F2E2E2"><font size="2.5">本月累计</font></td>
				<td height="20" align="right"><font size="2.5"><?php echo number_format($intBillCountMonth); ?></font><font size="2">(张)</font></td>
				<td height="20" width="20"></td>
			</tr>
			
			<tr>
				<td height="5" width="20"></td>
				<td height="5" width="120" align="left"></td>
				<td height="5" align="right"></td>
				<td height="5" width="20"></td>
			</tr>
		</table>
		
		<table width="100%" height="30" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
			<tr bgcolor="#F2E2E2">
				<td height="1" width="20"></td>
				<td height="1" width="120" align="left"></td>
				<td height="1" align="right"></td>
				<td height="1" width="20"></td>
			</tr>
			
			<tr>
				<td height="5" width="20"></td>
				<td height="5" width="120" align="left"></td>
				<td height="5" align="right"></td>
				<td height="5" width="20"></td>
			</tr>

			<tr>
				<td height="20" width="20"></td>
				<td height="20" width="120" align="left"><font size="4">宾客人数</font></td>
				<td height="20" align="right"><font size="4"><?php echo number_format($intManCountDay); ?></font><font size="2">(位)</font></td>
				<td height="20" width="20"></td>
			</tr>
					
			<tr>
				<td height="20" width="20"></td>
				<td height="20" width="130" align="left" color="#F2E2E2"><font size="2.5">本月累计</font></td>
				<td height="20" align="right"><font size="2.5"><?php echo number_format($intManCountMonth); ?></font><font size="2">(位)</font></td>
				<td height="20" width="20"></td>
			</tr>
			
			<tr>
				<td height="5" width="20"></td>
				<td height="5" width="120" align="left"></td>
				<td height="5" align="right"></td>
				<td height="5" width="20"></td>
			</tr>
		</table>
		
		<table width="100%" height="30" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
			<tr bgcolor="#F2E2E2">
				<td height="1" width="20"></td>
				<td height="1" width="120" align="left"></td>
				<td height="1" align="right"></td>
				<td height="1" width="20"></td>
			</tr>
			
			<tr>
				<td height="5" width="20"></td>
				<td height="5" width="120" align="left"></td>
				<td height="5" align="right"></td>
				<td height="5" width="20"></td>
			</tr>
		
			<tr>
				<td height="20" width="20"></td>
				<td height="20" width="120" align="left"><font size="4">消费金额</font></td>
				<td height="20" align="right"><font size="4"><?php echo number_format($fltScoreValDay);?></font><font size="2">(元)</font></td>
				<td height="20" width="20"></td>
			</tr>
					
			<tr>
				<td height="20" width="20"></td>
				<td height="20" width="130" align="left" color="#F2E2E2"><font size="2.5">本月累计</font></td>
				<td height="20" align="right"><font size="2.5"><?php echo number_format($fltScoreValMonth);?></font><font size="2">(元)</font></td>
				<td height="20" width="20"></td>
			</tr>
			
			<tr>
				<td height="5" width="20"></td>
				<td height="5" width="120" align="left"></td>
				<td height="5" align="right"></td>
				<td height="5" width="20"></td>
			</tr>
		</table>

		
		<table width="100%" height="30" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
			<tr bgcolor="#F2E2E2">
				<td height="1" width="20"></td>
				<td height="1" width="120" align="left"></td>
				<td height="1" align="right"></td>
				<td height="1" width="20"></td>
			</tr>
			
			<tr>
				<td height="5" width="20"></td>
				<td height="5" width="120" align="left"></td>
				<td height="5" align="right"></td>
				<td height="5" width="20"></td>
			</tr>
		
			<tr>
				<td height="20" width="20"></td>
				<td height="20" width="120" align="left"><font size="4">折扣金额</font></td>
				<td height="20" align="right"><font size="4"><?php echo number_format($fltRateValDay,1);?></font><font size="2">(元)</font></td>
				<td height="20" width="20"></td>
			</tr>
					
			<tr>
				<td height="20" width="20"></td>
				<td height="20" width="130" align="left" color="#F2E2E2"><font size="2.5">本月累计</font></td>
				<td height="20" align="right"><font size="2.5"><?php echo number_format($fltRateValMonth,1);?></font><font size="2">(元)</font></td>
				<td height="20" width="20"></td>
			</tr>
			
			<tr>
				<td height="5" width="20"></td>
				<td height="5" width="120" align="left"></td>
				<td height="5" align="right"></td>
				<td height="5" width="20"></td>
			</tr>
			
		</table>
		
		<table width="100%" height="30" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
			<tr bgcolor="#F2E2E2">
				<td height="1" width="20"></td>
				<td height="1" width="120" align="left"></td>
				<td height="1" align="right"></td>
				<td height="1" width="20"></td>
			</tr>
			
			<tr>
				<td height="5" width="20"></td>
				<td height="5" width="120" align="left"></td>
				<td height="5" align="right"></td>
				<td height="5" width="20"></td>
			</tr>
		
			<tr>
				<td height="20" width="20"></td>
				<td height="20" width="120" align="left"><font size="4">折后金额</font></td>
				<td height="20" align="right"><font size="4"><?php echo number_format($fltZheHouValDay,1);?></font><font size="2">(元)</font></td>
				<td height="20" width="20"></td>
			</tr>
					
			<tr>
				<td height="20" width="20"></td>
				<td height="20" width="130" align="left" color="#F2E2E2"><font size="2.5">本月累计</font></td>
				<td height="20" align="right"><font size="2.5"><?php echo number_format($fltZheHouValMonth,1);?></font><font size="2">(元)</font></td>
				<td height="20" width="20"></td>
			</tr>
			
			<tr>
				<td height="5" width="20"></td>
				<td height="5" width="120" align="left"></td>
				<td height="5" align="right"></td>
				<td height="5" width="20"></td>
			</tr>
		</table>

		<table width="100%" height="30" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
			<tr bgcolor="#F2E2E2">
				<td height="1" width="20"></td>
				<td height="1" width="120" align="left"></td>
				<td height="1" align="right"></td>
				<td height="1" width="20"></td>
			</tr>
			
			<tr>
				<td height="5" width="20"></td>
				<td height="5" width="120" align="left"></td>
				<td height="5" align="right"></td>
				<td height="5" width="20"></td>
			</tr>
		
			<tr>
				<td height="20" width="20"></td>
				<td height="20" width="120" align="left"><font size="4">整单折扣</font></td>
				<td height="20" align="right"><font size="4"><?php echo number_format($fltAllBillValDay,1);?></font><font size="2">(元)</font></td>
				<td height="20" width="20"></td>
			</tr>
					
			<tr>
				<td height="20" width="20"></td>
				<td height="20" width="130" align="left" color="#F2E2E2"><font size="2.5">本月累计</font></td>
				<td height="20" align="right"><font size="2.5"><?php echo number_format($fltAllBillValMonth,1);?></font><font size="2">(元)</font></td>
				<td height="20" width="20"></td>
			</tr>
			
			<tr>
				<td height="5" width="20"></td>
				<td height="5" width="120" align="left"></td>
				<td height="5" align="right"></td>
				<td height="5" width="20"></td>
			</tr>
		</table>

		<table width="100%" height="30" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
			<tr bgcolor="#F2E2E2">
				<td height="1" width="20"></td>
				<td height="1" width="120" align="left"></td>
				<td height="1" align="right"></td>
				<td height="1" width="20"></td>
			</tr>
			
			<tr>
				<td height="5" width="20"></td>
				<td height="5" width="120" align="left"></td>
				<td height="5" align="right"></td>
				<td height="5" width="20"></td>
			</tr>
		
			<tr>
				<td height="20" width="20"></td>
				<td height="20" width="120" align="left"><font size="4">实收金额</font></td>
				<td height="20" align="right"><font size="4"><?php echo number_format($fltFactValDay,1);?></font><font size="2">(元)</font></td>
				<td height="20" width="20"></td>
			</tr>
					
			<tr>
				<td height="20" width="20"></td>
				<td height="20" width="130" align="left" color="#F2E2E2"><font size="2.5">本月累计</font></td>
				<td height="20" align="right"><font size="2.5"><?php echo number_format($fltFactValMonth,1);?></font><font size="2">(元)</font></td>
				<td height="20" width="20"></td>
			</tr>
			
			<tr>
				<td height="5" width="20"></td>
				<td height="5" width="120" align="left"></td>
				<td height="5" align="right"></td>
				<td height="5" width="20"></td>
			</tr>
			
			<tr bgcolor="#F2E2E2">
				<td height="1" width="20"></td>
				<td height="1" width="120" align="left"></td>
				<td height="1" align="right"></td>
				<td height="1" width="20"></td>
			</tr>
		</table>
	
						
		<table width="100%" height="20" border="0" cellpadding="0" cellspacing="0">
			<tr>
				<td height="10" width="20"></td>
				<td height="10"  align="center"></td>
				<td height="10" width="20"></td>
			</tr>
		</table>
				
	</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:0px solid #F2E2E2;">
		<table width="100%" height="40" border="0" cellpadding="0" cellspacing="0">
			<tr>
				<td height="50" width="25%">
					<a class="ui-btn ui-icon-grid ui-btn-icon-top" target="_parent" href="#" rel="external" style="width:100%;height:10px;margin:0px auto 0px auto;color:#666666;background-color:#F3F4EC;">营业报告</a>
				</td>
				<td height="50" width="25%">
					<a class="ui-btn ui-icon-bullets ui-btn-icon-top" target="_parent" href="#page2" rel="external" style="width:100%;height:10px;margin:0px auto 0px auto;">结账明细表</a>
				</td>
				<td height="50" width="25%">
					<a class="ui-btn ui-icon-calendar ui-btn-icon-top" target="_parent" href="#page3" rel="external" style="width:100%;height:10px;margin:0px auto 0px auto;">营业汇总表</a>
				</td>
				<td height="50" width="25%">
					<a class="ui-btn ui-icon-refresh ui-btn-icon-top" target="_parent" href="indexref.php?pid=1" rel="external" style="width:100%;height:10px;margin:0px auto 0px auto;">刷新数据</a>
				</td>
			</tr>
		</table>
	</footer>
	
</section>




<section data-role="page" id="page2">
	<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" align="center">营业结账明细表</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
			
				$introwid=0;
				$strtableno="";
				$strmealtype="";
				$intmancount=0;
				$billdate="";
				$reckondate="";
				$fltconsumesum=0;	//消费金额
				$fltconsumeser=0;	//服务费
				$fltconsumeall=0;	//消费总额
				$flthaverateval=0;	//折后金额Consum_Should
				$fltratevalue=0;	//折扣金额 计算
				$fltallbillrate=0;	//整单折扣
				$fltfactpayfor=0;	//实收金额
				$strpayfortype="";	//付款说明
				
				$fltsumval1=0;
				$fltsumval2=0;
				$fltsumval3=0;

				$sql=sprintf("SELECT TableNo,RunName,ManCount,Convert(varchar(16),TradeTime,120)as BillDate,Convert(varchar(16),ReckonTime,120)as ReckoningDate,
								ItemValue,ShouldValue,AllBillRate,FactValue,PrintTemp 
							FROM TCP_Bill_Inform WHERE BillState=2 And ReckonTime>='%s' AND ReckonTime<='%s 23:59:59' AND DListNo=%s
							ORDER BY ReckonTime ASC",$strHotelDayTemp,$strHotelDayTemp,$strDeptListNo);

				$result = querySql($sql);
											
				while($row = fetch_array($result))
				{
					$introwid=$introwid +1;
					$strtableno=$row['TableNo'];
					$strmealtype=$row['RunName'];
					$intmancount=$row['ManCount'];
					$billdate=$row['BillDate'];
					$reckondate=$row['ReckoningDate'];
					$fltconsumesum=$row['ItemValue'];	//消费金额
					$fltconsumeser=0;					//服务费
					$fltconsumeall=$row['ItemValue'];	//消费总额
					$flthaverateval=$row['ShouldValue'];			//折后金额Consum_Should
					$fltratevalue=$fltconsumeall - $flthaverateval;	//折扣金额 计算
					$fltallbillrate=$row['AllBillRate'];	//整单折扣
					$fltfactpayfor=$row['FactValue'];		//实收金额
					$strpayfortype=$row['PrintTemp'];		//付款说明
										
					$fltsumval1 = $fltsumval1 + $fltconsumesum;
					$fltsumval2 = $fltsumval2 + $fltratevalue;
					$fltsumval3 = $fltsumval3 + $fltfactpayfor;
			?>
			<tr>
				<td width="8"></td>
				<td align="left">
					<div style="width:100%;height:150px;border-radius:4px;border-top:1px solid #F2E2E2;border-bottom:1px solid #F2E2E2;border-left:1px solid #F2E2E2;border-right:1px solid #F2E2E2;">
						<table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-radius:5px;" bgcolor="#ffffff">
							<tr>
								<td height="5" width="15"></td>
								<td height="5" align="left"></td>
								<td height="5" width="85"></td>
								<td height="5" width="15"></td>
							</tr>
														
							<tr>
								<td height="30" width="15"></td>
								<td height="30" colspan="2" align="left" valign="middle">
									<table width="100%" border="0" cellpadding="0" cellspacing="0">
										<tr>
											<td width="25"><IMG src="images/item.png" border=0></td>
											<td widht="110"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:15px;"><?php echo $introwid;?>.台号:&nbsp;<?php echo $strtableno;?></span></td>
											<td width="90"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:15px;">人数:&nbsp;<?php echo $intmancount;?></span></td>
											<td align="right"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:15px;"><?php echo $strmealtype;?></span></td>
										</tr>
									</table>
								</td>				
								<td height="30" width="15"></td>
							</tr>
							
							<tr>
								<td height="1" width="15"></td>
								<td height="1" align="left" bgcolor="#F2E2E2"></td>
								<td height="1" width="85" bgcolor="#F2E2E2"></td>
								<td height="1" width="15"></td>
							</tr>
							
							<tr><td height="4" colspan="4"></td></tr>
														
							<tr>
								<td height="20" width="15"></td>
								<td height="20" align="left" colspan="2" valign="middle">
									<table width="100%" height="10" border="0" cellpadding="0" cellspacing="0">
										<tr>
											<td height="20">
												<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;">开单：<?php echo $billdate;?></span>
											</td>
											<td width="130">
												<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;">折扣金额：<?php echo number_format($fltratevalue,1);?></span>
											</td>
										</tr>
									</table>
								</td>
								<td height="20" width="15"></td>
							</tr>
							
							<tr>
								<td height="20" width="15"></td>
								<td height="20" align="left" colspan="2" valign="middle">
									<table width="100%" height="10" border="0" cellpadding="0" cellspacing="0">
										<tr>
											<td height="20">
												<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;">结账：<?php echo $reckondate;?></span>
											</td>
											<td width="130">
												<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;">整单折扣：<?php echo number_format($fltallbillrate,1);?></span>
											</td>
										</tr>
									</table>
								</td>
								<td height="20" width="15"></td>
							</tr>
							
							<tr>
								<td height="20" width="15"></td>
								<td height="20" align="left" colspan="2" valign="middle">
									<table width="100%" height="10" border="0" cellpadding="0" cellspacing="0">
										<tr>
											<td width="90" height="20">
												<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;">消费额：<?php echo number_format($fltconsumesum,1);?></span>
											</td>
											<td width="100">
												<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;">+ 服务费：<?php echo number_format($fltconsumeser,1);?></span>
											</td>
											<td>
												<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;">= 消费总额：<?php echo number_format($fltconsumeall,1);?></span>
											</td>
										</tr>
									</table>
								</td>
								<td height="20" width="15"></td>
							</tr>
							
							<tr>
								<td height="20" width="15"></td>
								<td height="20" align="left" colspan="2" valign="middle">
									<table width="100%" height="10" border="0" cellpadding="0" cellspacing="0">
										<tr>
											<td width="90" height="20">
												<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;"></span>
											</td>
											<td width="100">
												<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;">&nbsp;- 折扣额：<?php echo number_format($fltratevalue,1);?></span>
											</td>
											<td>
												<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;">= 实收金额：<?php echo number_format($fltfactpayfor,1);?></span>
											</td>
										</tr>
									</table>
								</td>
								<td height="20" width="15"></td>
							</tr>
							
							<tr>
								<td height="20" width="15"></td>
								<td height="20" align="left" colspan="2" valign="middle">
									<table width="100%" height="10" border="0" cellpadding="0" cellspacing="0">
										<tr>
											<td width="90" height="20">
												<span style="color: #999999;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;">付款说明：<?php echo $strpayfortype;?></span>
											</td>
										</tr>
									</table>
								</td>
								<td height="20" width="15"></td>
							</tr>
							
							<tr>
								<td height="5" width="15"></td>
								<td height="5" align="left"></td>
								<td height="5" width="85"></td>
								<td height="5" width="15"></td>
							</tr>
							
						</table>
					</div>
				</td>
				<td width="8"></td>
			</tr>
			
			<tr>
				<td height="5" width="8"></td>
				<td height="5" align="left"></td>
				<td height="5" width="8"></td>
			</tr>
			<?php 
				}
				//释放数据库
				freeResult($result);
				closeDb();
				
				//添加合计行
				
				if($introwid>0)
				{
			?>
	
			<tr>
				<td height="5" width="8"></td>
				<td height="5" align="left">
					<div style="width:100%;height:54px;border-radius:4px;border-top:1px solid #F2E2E2;border-bottom:1px solid #F2E2E2;border-left:1px solid #F2E2E2;border-right:1px solid #F2E2E2;">
						<table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-radius:5px;" bgcolor="#ffffff">
							<tr>
								<td height="5" width="15"></td>
								<td height="5" align="left"></td>
								<td height="5" width="85"></td>
								<td height="5" width="15"></td>
							</tr>
														
							<tr>
								<td height="30" width="15"></td>
								<td height="30" colspan="2" align="left" valign="middle">
									<table width="100%" border="0" cellpadding="0" cellspacing="0">
										<tr>
											<td width="15"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:15px;">∑</span></td>
											<td><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:15px;">&nbsp;消费总额：<?php echo number_format($fltsumval1,1);?> - 折扣额：<?php echo number_format($fltsumval2,1);?></span></td>
										</tr>
										<tr>
											<td width="15"></td>
											<td><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:15px;">&nbsp;= 实收金额：<?php echo number_format($fltsumval3,1);?></span></td>
										</tr>
									</table>
								</td>				
								<td height="30" width="15"></td>
							</tr>
							
														
							<tr>
								<td height="5" width="15"></td>
								<td height="5" align="left"></td>
								<td height="5" width="85"></td>
								<td height="5" width="15"></td>
							</tr>
							
						</table>
					</div>
				</td>
				<td height="5" width="8"></td>
			</tr>
			
			<tr>
				<td height="5" width="8"></td>
				<td height="5" align="left"></td>
				<td height="5" width="8"></td>
			</tr>
			<?php } ?>
		</table>		
						
	</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:0px solid #F2E2E2;">
		<table width="100%" height="40" border="0" cellpadding="0" cellspacing="0">
			<tr>
				<td height="50" width="25%">
					<a class="ui-btn ui-icon-grid ui-btn-icon-top" target="_parent" href="#page1" rel="external" style="width:100%;height:10px;margin:0px auto 0px auto;">营业报告</a>
				</td>
				<td height="50" width="25%">
					<a class="ui-btn ui-icon-bullets ui-btn-icon-top" target="_parent" href="#" rel="external" style="width:100%;height:10px;margin:0px auto 0px auto;color:#666666;background-color:#F3F4EC;">结账明细表</a>
				</td>
				<td height="50" width="25%">
					<a class="ui-btn ui-icon-calendar ui-btn-icon-top" target="_parent" href="#page3" rel="external" style="width:100%;height:10px;margin:0px auto 0px auto;">营业汇总表</a>
				</td>
				<td height="50" width="25%">
					<a class="ui-btn ui-icon-refresh ui-btn-icon-top" target="_parent" href="indexref.php?pid=1" rel="external" style="width:100%;height:10px;margin:0px auto 0px auto;">刷新数据</a>
				</td>
			</tr>
		</table>
	</footer>
	
</section>




<section data-role="page" id="page3">
	<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" align="center">营业汇总表</td>
		  </tr>
		</table>
	</header>
			
	<article data-role="none">
		<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
			<tr>
				<td height="4" width="5"></td>
				<td height="4" align="left"></td>
				<td height="4" width="7"></td>
			</tr>
			
			<tr>
				<td width="5"></td>
				<td align="left" >
					<div style="width:100%;border-radius:5px;border-top:1px solid #F2E2E2;border-bottom:1px solid #F2E2E2;border-left:1px solid #F2E2E2;border-right:1px solid #F2E2E2;">
						<table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-radius:5px;" bgcolor="#ffffff">
							<tr bgcolor="#F0F0F0">
								<td height="5" width="5"></td>
								<td height="5" align="left"></td>
								<td height="5" width="85"></td>
								<td height="5" width="5"></td>
							</tr>
														
							<tr bgcolor="#F0F0F0">
								<td height="30" width="5"></td>
								<td height="30" colspan="2" align="left" valign="middle">
									<table width="100%" border="0" cellpadding="0" cellspacing="0">
										<tr>
											<td widht="42%"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:13px;">①&nbsp;项目类型统计</span></td>
											<td width="20%" align="right"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:13px;">折扣前</span></td>
											<td width="18%" align="right"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:13px;">折扣额</span></td>
											<td width="20%" align="right"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:13px;">折后金额</span></td>
										</tr>
									</table>
								</td>				
								<td height="30" width="5"></td>
							</tr>
							
							<tr>
								<td height="1" width="5"></td>
								<td height="1" align="left" bgcolor="#F2E2E2"></td>
								<td height="1" width="85" bgcolor="#F2E2E2"></td>
								<td height="1" width="5"></td>
							</tr>
							
							<?php
			
								$introwid=0;
								$stritemtype="";
								$fltsubzkqval=0;
								$fltsubzkval=0;
								$fltsubzkhval=0;
								
								$fltsumzkqval=0;
								$fltsumzkval=0;
								$fltsumzkhval=0;

								$sql=sprintf("SELECT c.TypeName,SUM(b.ItemPrice * b.ItemCount)AS SumZQVal,SUM(b.ItemPrice * b.ItemCount * b.ItemRate * 0.01)AS SumZHVal
											FROM TCP_Bill_Inform a,TCP_Bill_Item b,TCP_Item_Type c
											WHERE a.BillState=2 And b.Bill_No=a.Bill_No And a.ReckonTime>='%s' AND a.ReckonTime<='%s 23:59:59' AND a.DListNo=%s And c.DListNo=%s
											And c.ListNo=b.TypeListNo GROUP BY c.TypeName ORDER BY c.TypeName ASC",$strHotelDayTemp,$strHotelDayTemp,$strDeptListNo,$strDeptListNo);
											
								$result = querySql($sql);
															
								while($row = fetch_array($result))
								{
									$introwid=$introwid+1;
									$stritemtype=$row['TypeName'];
									$fltsubzkqval=$row['SumZQVal'];
									$fltsubzkhval=$row['SumZHVal'];
									$fltsubzkval=$fltsubzkqval-$fltsubzkhval;	//折扣金额
																		
									$fltsumzkqval = $fltsumzkqval + $fltsubzkqval;
									$fltsumzkval = $fltsumzkval + $fltsubzkval;
									$fltsumzkhval = $fltsumzkhval + $fltsubzkhval;
									
									if($introwid>1)
									{
							?>	
							<tr>
								<td height="1" width="5"></td>
								<td height="1" colspan="2" bgcolor="#F0F0F0"></td>
								<td height="1" width="5"></td>
							</tr>
							<?php } ?>
							
							<tr>
								<td height="30" width="5"></td>
								<td height="30" colspan="2" align="left" valign="middle">
									<table width="100%" border="0" cellpadding="0" cellspacing="0">
										<tr>
											<td widht="42%"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;">&nbsp;&nbsp;&nbsp;<?php echo $stritemtype;?></span></td>
											<td width="20%" align="right" ><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;"><?php echo number_format($fltsubzkqval,1);?></span></td>
											<td width="18%" align="right"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;"><?php echo number_format($fltsubzkval,1);?></span></td>
											<td width="20%" align="right"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;"><?php echo number_format($fltsubzkhval,1);?></span></td>
										</tr>
									</table>
								</td>				
								<td height="30" width="5"></td>
							</tr>
														
							<?php 
								}
								//释放数据库
								freeResult($result);
								closeDb();
								if($introwid>0)
								{
							?>	
							<tr>
								<td height="1" width="5" bgcolor="#F2E2E2"></td>
								<td height="1" colspan="2" bgcolor="#F2E2E2"></td>
								<td height="1" width="5" bgcolor="#F2E2E2"></td>
							</tr>
							<?php } ?>
							
							<tr bgcolor="#FDFAF2">
								<td height="30" width="5"></td>
								<td height="30" colspan="2" align="left" valign="middle">
									<table width="100%" border="0" cellpadding="0" cellspacing="0">
										<tr>
											<td widht="42%"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:13px;">&nbsp;&nbsp;∑合计</span></td>
											<td width="20%" align="right" ><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:13px;"><?php echo number_format($fltsumzkqval,1);?></span></td>
											<td width="18%" align="right"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:13px;"><?php echo number_format($fltsumzkval,1);?></span></td>
											<td width="20%" align="right"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:13px;"><?php echo number_format($fltsumzkhval,1);?></span></td>
										</tr>
									</table>
								</td>				
								<td height="30" width="5"></td>
							</tr>
														
						</table>
					</div>
				</td>
				<td width="7"></td>
			</tr>
			
			<tr>
				<td height="7" width="5"></td>
				<td height="7" align="left"></td>
				<td height="7" width="7"></td>
			</tr>
			
			<tr>
				<td width="5"></td>
				<td align="left" >
					<div style="width:100%;border-radius:5px;border-top:1px solid #F2E2E2;border-bottom:1px solid #F2E2E2;border-left:1px solid #F2E2E2;border-right:1px solid #F2E2E2;">
						<table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-radius:5px;" bgcolor="#ffffff">
							<tr bgcolor="#F0F0F0">
								<td height="5" width="5"></td>
								<td height="5" align="left"></td>
								<td height="5" width="85"></td>
								<td height="5" width="5"></td>
							</tr>
														
							<tr bgcolor="#F0F0F0">
								<td height="30" width="5"></td>
								<td height="30" colspan="2" align="left" valign="middle">
									<table width="100%" border="0" cellpadding="0" cellspacing="0">
										<tr>
											<td widht="42%"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:13px;">②&nbsp;项目明细统计</span></td>
											<td width="20%" align="right"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:13px;">折扣前</span></td>
											<td width="18%" align="right"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:13px;">折扣额</span></td>
											<td width="20%" align="right"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:13px;">折后金额</span></td>
										</tr>
									</table>
								</td>				
								<td height="30" width="5"></td>
							</tr>
							
							<tr>
								<td height="1" width="5"></td>
								<td height="1" align="left" bgcolor="#F2E2E2"></td>
								<td height="1" width="85" bgcolor="#F2E2E2"></td>
								<td height="1" width="5"></td>
							</tr>
							
							<?php
							
								$introwid=0;
								$stritemtype="";
								$fltsubzkqval=0;
								$fltsubzkval=0;
								$fltsubzkhval=0;
								
								$fltsumzkqval=0;
								$fltsumzkval=0;
								$fltsumzkhval=0;
								
								$sql=sprintf("SELECT b.ItemName,SUM(b.ItemPrice * b.ItemCount)AS SumZQVal,SUM(b.ItemPrice * b.ItemCount * b.ItemRate * 0.01)AS SumZHVal
										FROM TCP_Bill_Inform a,TCP_Bill_Item b
										WHERE a.BillState=2 And b.Bill_No=a.Bill_No And a.ReckonTime>='%s' AND a.ReckonTime<='%s 23:59:59' AND a.DListNo=%s
										GROUP BY b.ItemName ORDER BY b.ItemName ASC",$strHotelDayTemp,$strHotelDayTemp,$strDeptListNo);

								$result = querySql($sql);
															
								while($row = fetch_array($result))
								{
									$introwid=$introwid+1;
									$stritemtype=$row['ItemName'];
									$fltsubzkqval=$row['SumZQVal'];
									$fltsubzkhval=$row['SumZHVal'];
									$fltsubzkval=$fltsubzkqval-$fltsubzkhval;	//折扣金额
																		
									$fltsumzkqval = $fltsumzkqval + $fltsubzkqval;
									$fltsumzkval = $fltsumzkval + $fltsubzkval;
									$fltsumzkhval = $fltsumzkhval + $fltsubzkhval;
									
									if($introwid>1)
									{
							?>	
							<tr>
								<td height="1" width="5"></td>
								<td height="1" colspan="2" bgcolor="#F0F0F0"></td>
								<td height="1" width="5"></td>
							</tr>
							<?php } ?>
							
							<tr>
								<td height="30" width="5"></td>
								<td height="30" colspan="2" align="left" valign="middle">
									<table width="100%" border="0" cellpadding="0" cellspacing="0">
										<tr>
											<td widht="42%"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;">&nbsp;&nbsp;&nbsp;<?php echo $stritemtype;?></span></td>
											<td width="20%" align="right" ><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;"><?php echo number_format($fltsubzkqval,1);?></span></td>
											<td width="18%" align="right"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;"><?php echo number_format($fltsubzkval,1);?></span></td>
											<td width="20%" align="right"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;"><?php echo number_format($fltsubzkhval,1);?></span></td>
										</tr>
									</table>
								</td>				
								<td height="30" width="5"></td>
							</tr>
														
							<?php 
								}
								//释放数据库
								freeResult($result);
								closeDb();
								if($introwid>0)
								{
							?>	
							<tr>
								<td height="1" width="5" bgcolor="#F2E2E2"></td>
								<td height="1" colspan="2" bgcolor="#F2E2E2"></td>
								<td height="1" width="5" bgcolor="#F2E2E2"></td>
							</tr>
							<?php } ?>
							
							<tr bgcolor="#FDFAF2">
								<td height="30" width="5"></td>
								<td height="30" colspan="2" align="left" valign="middle">
									<table width="100%" border="0" cellpadding="0" cellspacing="0">
										<tr>
											<td widht="42%"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:13px;">&nbsp;&nbsp;∑合计</span></td>
											<td width="20%" align="right" ><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:13px;"><?php echo number_format($fltsumzkqval,1);?></span></td>
											<td width="18%" align="right"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:13px;"><?php echo number_format($fltsumzkval,1);?></span></td>
											<td width="20%" align="right"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:13px;"><?php echo number_format($fltsumzkhval,1);?></span></td>
										</tr>
									</table>
								</td>				
								<td height="30" width="5"></td>
							</tr>
														
						</table>
					</div>
				</td>
				<td width="7"></td>
			</tr>
			
			<tr>
				<td height="7" width="5"></td>
				<td height="7" align="left"></td>
				<td height="7" width="7"></td>
			</tr>
			<?php
				//计算项目金额
				//$fltScoreValDay		//消费基恩1
				//$fltRateValDay 		//折扣金额2
				//$fltZheHouValDay 	//折后金额3
				//$fltServiceDay 		//服务费4
				$fltsub3shouldval=$fltZheHouValDay + $fltServiceDay;	//应收金额5
				//$fltAllBillValDay 	//整单折扣6
				//$fltFactValDay 		//实收金额7
				
				//生成占比
				$fltsub3zb1=0;
				$fltsub3zb2=0;
				$fltsub3zb3=0;
				$fltsub3zb4=0;
				$fltsub3zb5=0;
				$fltsub3zb6=0;
				
				if($fltScoreValDay<>0)
					$fltsub3zb1=round($fltRateValDay * 100/$fltScoreValDay,1);
				if($fltScoreValDay<>0)
					$fltsub3zb2=round($fltZheHouValDay * 100/$fltScoreValDay,1);
				if($fltScoreValDay<>0)
					$fltsub3zb3=round($fltServiceDay * 100/$fltScoreValDay,1);
				if($fltScoreValDay<>0)
					$fltsub3zb4=round($fltsub3shouldval * 100/$fltScoreValDay,1);
				if($fltScoreValDay<>0)
					$fltsub3zb5=round($fltAllBillValDay * 100/$fltScoreValDay,1);
				if($fltScoreValDay<>0)
					$fltsub3zb6=round($fltFactValDay * 100/$fltScoreValDay,1);
				
			?>
			<tr>
				<td width="5"></td>
				<td align="left" >
					<div style="width:100%;border-radius:5px;border-top:1px solid #F2E2E2;border-bottom:1px solid #F2E2E2;border-left:1px solid #F2E2E2;border-right:1px solid #F2E2E2;">
						<table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-radius:5px;" bgcolor="#ffffff">
							<tr bgcolor="#F0F0F0">
								<td height="5" width="5"></td>
								<td height="5" align="left"></td>
								<td height="5" width="85"></td>
								<td height="5" width="5"></td>
							</tr>
														
							<tr bgcolor="#F0F0F0">
								<td height="30" width="5"></td>
								<td height="30" colspan="2" align="left" valign="middle">
									<table width="100%" border="0" cellpadding="0" cellspacing="0">
										<tr>
											<td widht="52%"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:13px;">③&nbsp;营业汇总统计</span></td>
											<td width="28%" align="right"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:13px;">项目金额</span></td>
											<td width="20%" align="right"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:13px;">占总额%</span></td>
										</tr>
									</table>
								</td>				
								<td height="30" width="5"></td>
							</tr>
							
							<tr>
								<td height="1" width="5"></td>
								<td height="1" align="left" bgcolor="#F2E2E2"></td>
								<td height="1" width="85" bgcolor="#F2E2E2"></td>
								<td height="1" width="5"></td>
							</tr>
														
							<tr>
								<td height="30" width="5"></td>
								<td height="30" colspan="2" align="left" valign="middle">
									<table width="100%" border="0" cellpadding="0" cellspacing="0">
										<tr>
											<td widht="52%"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;">&nbsp;&nbsp;&nbsp;销售总额（1）</span></td>
											<td width="28%" align="right" ><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;"><?php echo number_format($fltScoreValDay,1);?></span></td>
											<td width="20%" align="right"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;">100%</span></td>
										</tr>
									</table>
								</td>				
								<td height="30" width="5"></td>
							</tr>
							
							<tr>
								<td height="1" width="5"></td>
								<td height="1" colspan="2" bgcolor="#F0F0F0"></td>
								<td height="1" width="5"></td>
							</tr>
							
							<tr>
								<td height="30" width="5"></td>
								<td height="30" colspan="2" align="left" valign="middle">
									<table width="100%" border="0" cellpadding="0" cellspacing="0">
										<tr>
											<td widht="52%"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;">&nbsp;&nbsp;&nbsp;折扣金额（2）</span></td>
											<td width="28%" align="right" ><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;"><?php echo number_format($fltRateValDay,1);?></span></td>
											<td width="20%" align="right"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;"><?php echo number_format($fltsub3zb1,1);?>%</span></td>
										</tr>
									</table>
								</td>				
								<td height="30" width="5"></td>
							</tr>
							
							<tr>
								<td height="1" width="5"></td>
								<td height="1" colspan="2" bgcolor="#F0F0F0"></td>
								<td height="1" width="5"></td>
							</tr>
							
							<tr>
								<td height="30" width="5"></td>
								<td height="30" colspan="2" align="left" valign="middle">
									<table width="100%" border="0" cellpadding="0" cellspacing="0">
										<tr>
											<td widht="52%"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;">&nbsp;&nbsp;&nbsp;折后金额（3）=（1）-（2）</span></td>
											<td width="28%" align="right" ><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;"><?php echo number_format($fltZheHouValDay,1);?></span></td>
											<td width="20%" align="right"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;"><?php echo number_format($fltsub3zb2,1);?>%</span></td>
										</tr>
									</table>
								</td>				
								<td height="30" width="5"></td>
							</tr>
							
							<tr>
								<td height="1" width="5"></td>
								<td height="1" colspan="2" bgcolor="#F0F0F0"></td>
								<td height="1" width="5"></td>
							</tr>
							
							<tr>
								<td height="30" width="5"></td>
								<td height="30" colspan="2" align="left" valign="middle">
									<table width="100%" border="0" cellpadding="0" cellspacing="0">
										<tr>
											<td widht="52%"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;">&nbsp;&nbsp;&nbsp;服务费（4）</span></td>
											<td width="28%" align="right" ><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;"><?php echo number_format($fltServiceDay,1);?></span></td>
											<td width="20%" align="right"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;"><?php echo number_format($fltsub3zb3,1);?>%</span></td>
										</tr>
									</table>
								</td>				
								<td height="30" width="5"></td>
							</tr>
							
							<tr>
								<td height="1" width="5"></td>
								<td height="1" colspan="2" bgcolor="#F0F0F0"></td>
								<td height="1" width="5"></td>
							</tr>
							
							<tr>
								<td height="30" width="5"></td>
								<td height="30" colspan="2" align="left" valign="middle">
									<table width="100%" border="0" cellpadding="0" cellspacing="0">
										<tr>
											<td widht="52%"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;">&nbsp;&nbsp;&nbsp;应收金额（5）=（3）+（4）</span></td>
											<td width="28%" align="right" ><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;"><?php echo number_format($fltsub3shouldval,1);?></span></td>
											<td width="20%" align="right"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;"><?php echo number_format($fltsub3zb4,1);?>%</span></td>
										</tr>
									</table>
								</td>				
								<td height="30" width="5"></td>
							</tr>
							
							<tr>
								<td height="1" width="5"></td>
								<td height="1" colspan="2" bgcolor="#F0F0F0"></td>
								<td height="1" width="5"></td>
							</tr>
							
							<tr>
								<td height="30" width="5"></td>
								<td height="30" colspan="2" align="left" valign="middle">
									<table width="100%" border="0" cellpadding="0" cellspacing="0">
										<tr>
											<td widht="52%"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;">&nbsp;&nbsp;&nbsp;整单折扣（6）</span></td>
											<td width="28%" align="right" ><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;"><?php echo number_format($fltAllBillValDay,1);?></span></td>
											<td width="20%" align="right"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;"><?php echo number_format($fltsub3zb5,1);?>%</span></td>
										</tr>
									</table>
								</td>				
								<td height="30" width="5"></td>
							</tr>
							
							<tr>
								<td height="1" width="5"></td>
								<td height="1" colspan="2" bgcolor="#F0F0F0"></td>
								<td height="1" width="5"></td>
							</tr>
							
							<tr>
								<td height="30" width="5"></td>
								<td height="30" colspan="2" align="left" valign="middle">
									<table width="100%" border="0" cellpadding="0" cellspacing="0">
										<tr>
											<td widht="52%"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;">&nbsp;&nbsp;&nbsp;实收金额（7）=（5）-（6）</span></td>
											<td width="28%" align="right" ><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;"><?php echo number_format($fltFactValDay,1);?></span></td>
											<td width="20%" align="right"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;"><?php echo number_format($fltsub3zb6,1);?>%</span></td>
										</tr>
									</table>
								</td>				
								<td height="30" width="5"></td>
							</tr>
																					
						</table>
					</div>
				</td>
				<td width="7"></td>
			</tr>
			
			<tr>
				<td height="7" width="5"></td>
				<td height="7" align="left"></td>
				<td height="7" width="7"></td>
			</tr>
			
			<tr>
				<td width="5"></td>
				<td align="left" >
					<div style="width:100%;border-radius:5px;border-top:1px solid #F2E2E2;border-bottom:1px solid #F2E2E2;border-left:1px solid #F2E2E2;border-right:1px solid #F2E2E2;">
						<table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-radius:5px;" bgcolor="#ffffff">
							<tr bgcolor="#F0F0F0">
								<td height="5" width="5"></td>
								<td height="5" align="left"></td>
								<td height="5" width="85"></td>
								<td height="5" width="5"></td>
							</tr>
														
							<tr bgcolor="#F0F0F0">
								<td height="30" width="5"></td>
								<td height="30" colspan="2" align="left" valign="middle">
									<table width="100%" border="0" cellpadding="0" cellspacing="0">
										<tr>
											<td widht="70%"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:13px;">④&nbsp;收款方式统计</span></td>
											<td width="30%" align="right"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:13px;">收款金额</span></td>
										</tr>
									</table>
								</td>				
								<td height="30" width="5"></td>
							</tr>
							
							<tr>
								<td height="1" width="5"></td>
								<td height="1" align="left" bgcolor="#F2E2E2"></td>
								<td height="1" width="85" bgcolor="#F2E2E2"></td>
								<td height="1" width="5"></td>
							</tr>
							
							<?php
																							
								$introwid=0;
								$stritemtype="";
								$fltpayval=0;
								$fltpaysumval=0;
								
								$sql=sprintf("SELECT b.PayForType,SUM(b.PayForVal)AS SumPayVal FROM TCP_Bill_Inform a,TCP_Bill_PayFor b
										WHERE a.BillState=2 And b.Bill_No=a.Bill_No And a.ReckonTime>='%s' AND a.ReckonTime<='%s 23:59:59' AND a.DListNo=%s
										GROUP BY b.PayForType ORDER BY b.PayForType ASC",$strHotelDayTemp,$strHotelDayTemp,$strDeptListNo);

								$result = querySql($sql);
															
								while($row = fetch_array($result))
								{
									$introwid=$introwid+1;
									$stritemtype=$row['PayForType'];
									$fltpayval=$row['SumPayVal'];
									
									$fltpaysumval = $fltpaysumval + $fltpayval;
									
									if($introwid>1)
									{
							?>	
							<tr>
								<td height="1" width="5"></td>
								<td height="1" colspan="2" bgcolor="#F0F0F0"></td>
								<td height="1" width="5"></td>
							</tr>
							<?php } ?>
							
							<tr>
								<td height="30" width="5"></td>
								<td height="30" colspan="2" align="left" valign="middle">
									<table width="100%" border="0" cellpadding="0" cellspacing="0">
										<tr>
											<td widht="70%"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;">&nbsp;&nbsp;&nbsp;<?php echo $stritemtype;?></span></td>
											<td width="30%" align="right"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;"><?php echo number_format($fltpayval,1);?></span></td>
										</tr>
									</table>
								</td>				
								<td height="30" width="5"></td>
							</tr>
														
							<?php 
								}
								//释放数据库
								freeResult($result);
								closeDb();
								
								if($introwid>0)
								{
							?>	
							<tr>
								<td height="1" width="5" bgcolor="#F2E2E2"></td>
								<td height="1" colspan="2" bgcolor="#F2E2E2"></td>
								<td height="1" width="5" bgcolor="#F2E2E2"></td>
							</tr>
							<?php } ?>
							
							<tr bgcolor="#FDFAF2">
								<td height="30" width="5"></td>
								<td height="30" colspan="2" align="left" valign="middle">
									<table width="100%" border="0" cellpadding="0" cellspacing="0">
										<tr>
											<td widht="70%"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:13px;">&nbsp;&nbsp;∑合计</span></td>
											<td width="30%" align="right"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:13px;"><?php echo number_format($fltpaysumval,1);?></span></td>
										</tr>
									</table>
								</td>				
								<td height="30" width="5"></td>
							</tr>
														
						</table>
					</div>
				</td>
				<td width="7"></td>
			</tr>
			
			<tr>
				<td height="7" width="5"></td>
				<td height="7" align="left"></td>
				<td height="7" width="7"></td>
			</tr>
			
			<tr>
				<td width="5"></td>
				<td align="left" >
					<div style="width:100%;border-radius:5px;border-top:1px solid #F2E2E2;border-bottom:1px solid #F2E2E2;border-left:1px solid #F2E2E2;border-right:1px solid #F2E2E2;">
						<table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-radius:5px;" bgcolor="#ffffff">
							<tr bgcolor="#F0F0F0">
								<td height="5" width="5"></td>
								<td height="5" align="left"></td>
								<td height="5" width="85"></td>
								<td height="5" width="5"></td>
							</tr>
														
							<tr bgcolor="#F0F0F0">
								<td height="30" width="5"></td>
								<td height="30" colspan="2" align="left" valign="middle">
									<table width="100%" border="0" cellpadding="0" cellspacing="0">
										<tr>
											<td widht="40%"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:13px;">⑤&nbsp;营业班次统计</span></td>
											<td width="17%" align="right"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:13px;">单据数</span></td>
											<td width="17%" align="right"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:13px;">人数</span></td>
											<td width="26%" align="right"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:13px;">实收金额</span></td>
										</tr>
									</table>
								</td>				
								<td height="30" width="5"></td>
							</tr>
							
							<tr>
								<td height="1" width="5"></td>
								<td height="1" align="left" bgcolor="#F2E2E2"></td>
								<td height="1" width="85" bgcolor="#F2E2E2"></td>
								<td height="1" width="5"></td>
							</tr>
							
							<?php
																							
								$introwid=0;
								$stritemtype="";
								$fltsubval=0;
								$intsubcount1=0;
								$intsubcount2=0;
								
								$fltsumval=0;
								$intsumcount1=0;
								$intsumcount2=0;

								$sql=sprintf("SELECT RunName,SUM(FactValue)AS SumVal,SUM(ManCount)AS SumMan,Count(Bill_No)AS BillCount 
										FROM TCP_Bill_Inform WHERE BillState=2 And ReckonTime>='%s' AND ReckonTime<='%s 23:59:59' AND DListNo=%s
										GROUP BY RunName ORDER BY RunName ASC",$strHotelDayTemp,$strHotelDayTemp,$strDeptListNo);

								$result = querySql($sql);
															
								while($row = fetch_array($result))
								{
									$introwid=$introwid+1;
									$stritemtype=$row['RunName'];
									$fltsubval=$row['SumVal'];
									$intsubcount1=$row['BillCount'];
									$intsubcount2=$row['SumMan'];
									
									$fltsumval = $fltsumval + $fltsubval;
									$intsumcount1 = $intsumcount1 + $intsubcount1;
									$intsumcount2 = $intsumcount2 + $intsubcount1;
									
									if($introwid>1)
									{
							?>	
							<tr>
								<td height="1" width="5"></td>
								<td height="1" colspan="2" bgcolor="#F0F0F0"></td>
								<td height="1" width="5"></td>
							</tr>
							<?php } ?>
							
							<tr>
								<td height="30" width="5"></td>
								<td height="30" colspan="2" align="left" valign="middle">
									<table width="100%" border="0" cellpadding="0" cellspacing="0">
										<tr>
											<td widht="40%"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;">&nbsp;&nbsp;&nbsp;<?php echo $stritemtype;?></span></td>
											<td width="17%" align="right"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;"><?php echo number_format($intsubcount1,0);?>&nbsp;</span></td>
											<td width="17%" align="right"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;"><?php echo number_format($intsubcount2,0);?>&nbsp;</span></td>
											<td width="26%" align="right"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:13px;"><?php echo number_format($fltsubval,1);?></span></td>
										</tr>
									</table>
								</td>				
								<td height="30" width="5"></td>
							</tr>
														
							<?php 
								}
								//释放数据库
								freeResult($result);
								closeDb();
								
								if($introwid>0)
								{
							?>	
							<tr>
								<td height="1" width="5" bgcolor="#F2E2E2"></td>
								<td height="1" colspan="2" bgcolor="#F2E2E2"></td>
								<td height="1" width="5" bgcolor="#F2E2E2"></td>
							</tr>
							<?php } ?>
							<tr bgcolor="#FDFAF2">
								<td height="30" width="5"></td>
								<td height="30" colspan="2" align="left" valign="middle">
									<table width="100%" border="0" cellpadding="0" cellspacing="0">
										<tr>
											<td widht="40%"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:13px;">&nbsp;&nbsp;∑合计</span></td>
											<td width="17%" align="right"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:13px;"><?php echo number_format($intsumcount1,0);?>&nbsp;</span></td>
											<td width="17%" align="right"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:13px;"><?php echo number_format($intsumcount2,0);?>&nbsp;</span></td>
											<td width="26%" align="right"><span style="color: #666666;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:13px;"><?php echo number_format($fltsumval,1);?></span></td>
										</tr>
									</table>
								</td>				
								<td height="30" width="5"></td>
							</tr>
														
						</table>
					</div>
				</td>
				<td width="7"></td>
			</tr>
			
						
			<tr>
				<td height="5" width="5"></td>
				<td height="5" align="left"></td>
				<td height="5" width="7"></td>
			</tr>

		</table>	
						
	</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:0px solid #F2E2E2;">
		<table width="100%" height="40" border="0" cellpadding="0" cellspacing="0">
			<tr>
				<td height="50" width="25%">
					<a class="ui-btn ui-icon-grid ui-btn-icon-top" target="_parent" href="#page1" rel="external" style="width:100%;height:10px;margin:0px auto 0px auto;">营业报告</a>
				</td>
				<td height="50" width="25%">
					<a class="ui-btn ui-icon-bullets ui-btn-icon-top" target="_parent" href="#page2" rel="external" style="width:100%;height:10px;margin:0px auto 0px auto;">结账明细表</a>
				</td>
				<td height="50" width="25%">
					<a class="ui-btn ui-icon-calendar ui-btn-icon-top" target="_parent" href="#" rel="external" style="width:100%;height:10px;margin:0px auto 0px auto;color:#666666;background-color:#F3F4EC;">营业汇总表</a>
				</td>
				<td height="50" width="25%">
					<a class="ui-btn ui-icon-refresh ui-btn-icon-top" target="_parent" href="indexref.php?pid=1" rel="external" style="width:100%;height:10px;margin:0px auto 0px auto;">刷新数据</a>
				</td>
			</tr>
		</table>
	</footer>
	
</section>


<!--选择分店的部分代码---------------------------->
<section data-role="page" id="pagechain">
	<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="50" align="right"><a href="#page1" data-transition="flip" data-role="button" data-icon="carat-l" data-iconpos="notext"></td>
			<td height="35" align="center"><?php echo $strnewchainname;?></td>
			<td height="35" width="20" ></td>
		  </tr>
		</table>
	</header>
	<article data-role="content">
		<ul data-role="listview" data-inset="true">    
		 <?php
		 
			$selchainno="";
			$selchainname="";
		 
			$userno=$_SESSION['userno_ydtpos'];
					
			$sql=sprintf("SELECT Chain_No,Chain_Name FROM dbo.TRF_AppGetChainFromUser('%s');",$userno);
			$result = querySql($sql);
										
			while($row = fetch_array($result))
			{
				$selchainno = $row['Chain_No'];  
				$selchainname = $row['Chain_Name'];
				
		?>
			<li>
				<a class="ui-btn ui-corner-all ui-shadow ui-btn-inline" href="index.php?selno=<?php echo $selchainno;?>&seldpt=**" target="_blank data-transition="flip">
				<?php echo $selchainname;?><span class="ui-li-count">
				<?php echo $selchainno;?></span></a>
			</li> 
		<?php
			}
			//释放数据库
			freeResult($result);
			closeDb();
		 ?>
		  
		</ul> 
	</article>
	
</section>

</body>
	
</html>