<?php
//====== 打印输出 ======
require "common.php";
$x=Req("x");$n=Req("n");$u=Req("u");
$s=Qra(Qry("Select Ak From ".$pre."admin Where Ah=0 And Si=".$n." And ID=".$u));
if(!$s||md5($s["Ak"])!=Req("s"))die("连接超时，请重登录！");
switch($x){
	case "sp1"://打印测试
	$a=explode("|",Req("a"));$b=["none","block"];
	echo '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style>#dyyl{width:'.($a[5]*1-10).'mm;margin:0mm;line-height:'.$a[7].'px;font-family:宋体;font-size:'.$a[6].'px;}#dyyl div{font-family:宋体;font-size:'.$a[6].'px;}.dyrl div{float:right;width:32px;text-align:right;}</style></head><body><div id="dyyl"><img src="images/'.$n.'/p.jpg" style="width:'.($a[5]*1-10).'mm;display:'.$b[$a[16]].';"><div id="dyt1" style="text-align:center;font-size:'.$a[9].'px;line-height:'.($a[9]*1+8).'px;">'.$a[8].'</div><div style="float:left;">单号：8888<br>桌号：8</div><div style="float:right;">下单员：88<br>收银员：8</div><div style="clear:both;"></div>下单时间：2018-1-1 12:00:00<br>结账时间：2018-1-1 13:00:00<div class="dyrl"><div>数量</div><div>单价</div>品名</div><hr><div class="dyrl"><div>1</div><div>88</div>油焖大虾</div><div class="dyrl"><div>1</div><div>18</div>鱼香肉丝</div><div class="dyrl"><div>1</div><div>18</div>宫保鸡丁</div><div class="dyrl"><div>1</div><div>12</div>麻辣豆腐</div><div class="dyrl"><div>4</div><div>5</div>青岛啤酒</div><hr><div style="text-align:left;">合计： 156 元<br>折扣： 限时九折 会员九折<br>实收： <span style="font-size:18px;font-family:黑体;">126</span> 元[现金支付]</div><div id="dyt2" style="text-align:center;clear:both;font-size:'.$a[11].'px;line-height:'.($a[11]*1+8).'px;">'.$a[10].'</div></div></body></html>';
	break;

	case "sp2"://打印测试
	$a=explode("|",Req("a"));$b=["none","block"];
	echo '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body><div style="width:'.($a[12]*1-10).'mm;margin:0mm;line-height:'.$a[14].'px;font-family:宋体;font-size:'.$a[13].'px;">点菜单　　序号：101<br>单号：1001　桌号：1号桌<br>时间：2018-1-1 12:30:00<br><span style="font-size:'.$a[15].'px;">油焖大虾 × 1</span><br>微辣，<hr><div style="height:30px;"></div>退菜单　　序号：102<br>单号：1002　桌号：2号桌<br>时间：2018-1-1 12:35:00<br><span style="font-size:'.$a[15].'px;">[退]牛肉火锅 × 1</span><br>麻辣，<hr></div></body></html>';
	break;

	case "spb"://点单打印
	$a=Req("a");$c="";
	$f=Dec(Qrs(Qry("Select Sc From ".$pre."shop Where Si=".$n)));
	$q=Qry("Select Fm,Fc,Fn From ".$pre."ofood Where Si=".$n." And Fr<2 And Fo=".$a);
	while($r=Qra($q))$c.='<div class="dyrl"><div>'.($r["Fm"]/100).'</div><div style="width:14px;">'.$r["Fc"].'</div>'.$r["Fn"].'</div>';
	$r=Qra(Qry("Select ID,Ot,O1,O4,Ox,Od,Oe,Pm,Pd,Pc,Ps,Pt,Ob From ".$pre."order Where Si=".$n." And ID=".$a));
	$b=["现金","刷卡","微信","支付宝","会员卡"];$e=["none","block"];
	$d=[Qrs(Qry("Select Tn From ".$pre."table Where Si=".$n." And ID=".$r["Ot"])),"快餐","外卖"][$r["Ox"]];
	echo '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style>#dyyl{width:'.($f["p"][5]*1-10).'mm;margin:0mm;line-height:'.$f["p"][7].'px;font-family:宋体;font-size:'.$f["p"][6].'px;}#dyyl div{font-family:宋体;font-size:'.$f["p"][6].'px;}.dyrl div{float:right;width:32px;text-align:right;}</style></head><body><div id="dyyl"><div id="dyt1" style="text-align:center;font-size:'.$f["p"][9].'px;line-height:'.($f["p"][9]*1+8).'px;">'.$f["p"][8].'</div><div style="float:left;">单号：'.$r["ID"].'<br>桌号：'.$d.'</div><div style="float:right;">服务员：'.$r["O1"].'<br>收银员：'.$r["O4"].'</div><div style="clear:both;"></div>下单时间：'.$r["Od"].'<br>结账时间：'.$r["Oe"].'<div class="dyrl"><div>单价</div><div>数量</div>品名</div><hr>'.$c.'<hr><div style="text-align:left;word-break:break-all;">餐费：'.($r["Pm"]/100).' 元　优惠：'.($r["Pd"]/100).' 元<br>抵扣：'.($r["Pc"]/100).' 元　实收：'.($r["Ps"]/100).' 元<br>支付方式：'.$b[$r["Pt"]].'<br>备注：'.explode("|",$r["Ob"])[0].'</div><div id="dyt2" style="text-align:center;clear:both;font-size:'.$f["p"][11].'px;line-height:'.($f["p"][11]*1+8).'px;">'.$f["p"][10].'</div>';
	if($r["Ps"]==0)echo '<div style="text-align:center;"><img src="qrcode.php?u='.urlencode($cfg["Aw"]).'guest1%2Ephp%3Fi%3D'.$n.'%26t%3D'.substr(md5($n.$r["Ot"]),0,8).'" width="120" height="120"><br>请用微信或支付宝扫码自助支付</div>';
	if($f["p"][16]*1==1)echo '<div style="text-align:center;"><img src="qrcode.php?u='.urlencode($cfg["Aw"]).'guest2%2Ephp%3Fi%3D'.$n.'" width="120" height="120"><br>请保留好此小票，以后即可扫描<br>上面二维码直接点餐叫外卖哦~~</div></div>';
	Qry("Update ".$pre."order Set Os=6 Where Si=".$n." And (Os=12 Or Os=4) And Ot=0 And ID=".$a);
	break;

	case "spd"://厨房打印
	$a=Req("a");
	$f=Dec(Qrs(Qry("Select Sc From ".$pre."shop Where Si=".$n)));
	$r=Qra(Qry("Select Fo,Fc,Fn,Ft,Fb,Fd From ".$pre."ofood Where Si=".$n." And Fr<2 And ID=".$a));
	$b=Qra(Qry("Select Ox,Ob From ".$pre."order Where Si=".$n." And ID=".$r["Fo"]));
	$d=[Qrs(Qry("Select Tn From ".$pre."table Where Si=".$n." And ID=".$r["Ft"])),"快餐","外卖"][$b["Ox"]];
	echo '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body><div style="width:'.($f["p"][12]*1-10).'mm;margin:0mm;line-height:'.$f["p"][14].'px;font-family:宋体;font-size:'.$f["p"][13].'px;">厨房单　序号：'.$a.'<br>单号：'.$r["Fo"].'　桌号：'.$d.'<br>时间：'.$r["Fd"].'<div style="font-size:'.$f["p"][15].'px;line-height:'.($f["p"][15]*1+8).'px;">'.$r["Fn"].' × '.$r["Fc"].'</div>'.$r["Fb"].'</div></body></html>';
	break;

	case "spt"://退单打印
	$a=Req("a");
	$h=explode("|",Qrs(Qry("Select Np From ".$pre."shop Where Mi=".$n)));
	$r=Qra(Qry("Select Oi,Cs,Cn,Ti,Bz,Dt From ".$pre."ofood Where Mi=".$n." And ID=".$a));
	$d=explode("[",Qrs(Qry("Select Nm From ".$pre."table Where Mi=".$n." And ID=".$r[3])));
	echo '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body><div style="width:'.($h[7]*1-10).'mm;margin:0mm;line-height:'.$h[9].'px;font-family:宋体;font-size:'.$h[8].'px;">退菜单　序号：'.$a.'<br>单号：'.$r[0].'　桌号：'.$d[0].'<div style="font-size:'.$h[10].'px;line-height:'.($h[10]*1+8).'px;">[退]'.$r[2].' × '.$r[1].'</div>时间：'.date("Y-m-d H:i:s").'</div></body></html>';
	break;

	case "spu"://排队打印
	$f=Dec(Qrs(Qry("Select Sc From ".$pre."shop Where Si=".$n)));
	$d=Dec(file_get_contents("images/".$n."/d.txt"));$c=$d["ph"][count($d["ph"])-1];
	echo '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body><div style="width:'.($f["p"][5]*1-10).'mm;margin:0mm;line-height:'.$f["p"][7].'px;font-family:宋体;font-size:'.$f["p"][6].'px;"><div style="text-align:center;font-size:'.$f["p"][9].'px;line-height:'.($f["p"][9]*1+8).'px;">'.$f["p"][8].' - 排号</div><div style="text-align:center;font-size:48px;line-height:80px;">'.$c[0].'</div>共 '.$c[1].' 位，前面还有 '.(count($d["ph"])-1).' 组客人等待<br>时间：'.$c[2].'<br><br>排队等待时间可以扫描下面二维码关注排队进度，浏览本店特色餐品并预点餐品哟~~~<div style="text-align:center;"><img src="qrcode.php?u='.urlencode($cfg["Aw"].'guest3.php?i='.$n.'&n='.$c[0]).'" width="120" height="120"></div></div></body></html>';
	break;

	case "spc"://会充打印
	$f=Dec(Qrs(Qry("Select Sc From ".$pre."shop Where Si=".$n)));
	$r=Qra(Qry("Select Gc,Gu,Gm,Gn,Gd From ".$pre."expend Where ID=".Req("a")));
	echo '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body><div style="width:'.($f["p"][5]*1-10).'mm;margin:0mm;line-height:'.$f["p"][7].'px;font-family:宋体;font-size:'.$f["p"][6].'px;"><div style="text-align:center;font-size:'.$f["p"][9].'px;line-height:'.($f["p"][9]*1+8).'px;">'.$f["p"][8].' - 充值</div><br>会员卡号：'.$r["Gc"].'<br>实付金额：'.($r["Gm"]/100).' 元<br>充值金额：'.($r["Gn"]/100).' 元<br>当前余额：'.(Qrs(Qry("Select Us From ".$pre."user Where Uc='".$r["Gc"]."'"))/100).' 元<br>充值时间：'.$r["Gd"].'<br>操作员工：'.$n.'-'.explode("-",$r["Gu"])[1].'<div style="text-align:center;font-size:'.$f["p"][11].'px;line-height:'.($f["p"][11]*1+8).'px;">'.$f["p"][10].'</div></div></body></html>';
	break;

	case "ucl"://会员记录
	$a=Req("a");$q=Qry("Select Un,Us,Ux From ".$pre."user Where Uc='".$a."'");
	if(Qrc($q)==0)die();$r=Qra($q);
	echo '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>会员卡充值及消费查询</title></head><style>.d{width:1000px;margin:auto;height:30px;line-height:30px;border-bottom:1px solid #CCC;}.d1{float:left;width:100px;text-align:center;}.d2{float:left;width:200px;text-align:center;}</style><body style="margin:0px;padding:0px;text-align:center;font-size:14px;font-family:Consolas,微软雅黑;"><div style="margin:10px auto;font-size:20px;">会员卡充值及消费查询</div><div style="width:1000px;line-height:30px;border-bottom:2px solid #999;margin:5px auto;">会员卡号：'.$a.'　　会员名称：'.$r["Un"].'　　当前余额：'.($r["Us"]/100).'元　　累计消费：'.($r["Ux"]/100).'元</div><div class="d"><div class="d1">序号</div><div class="d2">卡号</div><div class="d1">单号</div><div class="d1">实付金额</div><div class="d1">充值/消费金额</div><div class="d2">发生时间</div><div class="d2">店铺ID-员工ID</div></div>';
	$q=Qry("Select Gc,Go,Gu,Gm,Gn,Gd From ".$pre."expend Where Gc='".$a."'");$i=1;
	while($r=Qra($q)){
		echo '<div class="d"><div class="d1">'.$i.'</div><div class="d2">'.$r["Gc"].'</div><div class="d1">'.$r["Go"].'</div><div class="d1">'.($r["Gm"]/100).'</div><div class="d1">'.($r["Gn"]/100).'</div><div class="d2">'.$r["Gd"].'</div><div class="d2">'.$r["Gu"].'</div></div>';
		$i=$i+1;
	}
	echo '</body></html>';
	break;

	case "rpt"://统计报表
	$a=Req("a");$b=Req("b");$c=Req("c");
	$a=date("Y-m-d",strtotime(Req("a")));$b=date("Y-m-d",strtotime("+1 Day",strtotime(Req("b"))));
	$r=Qra(Qry("Select Sn,Sc From ".$pre."shop Where Si=".$n));$d=Dec($r["Sc"]);
	$s='<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>'.$r["Sn"].'[ID:'.$n.'] - 统计报表</title><style>.a{height:30px;line-height:30px;border-bottom:1px dashed #CCC;}.a1{float:left;width:100px;}.a2{float:left;width:200px;}.a3{float:left;width:300px;}.a4{float:left;width:400px;}.a5{float:left;width:500px;}.a8{float:left;width:80px;}.b{width:1200px;background-color:#EEE;font-size:16px;font-weight:bold;line-height:30px;margin:20px auto 0px auto;clear:both;}a{text-decoration:none;color:#09F;}</style><script>document.write(\'<script src="'.$d["p"][0].'CLodopfuncs.js"></sc\'+\'ript>\');function dp(n,m){var o=getCLodop();if(typeof(o.VERSION)==\'undefined\'){alert(\'未安装打印控件！\');return;}o.PRINT_INIT(\'Print:\'+n);o.SET_PRINTER_INDEX(\''.$d["p"][3].'\');o.SET_PRINT_PAGESIZE(3,'.($d["p"][5]*10).',48,\'CreateCustomPage\');o.ADD_PRINT_HTM(0,0,'.($d["p"][6]*10).',500,\'URL:output.php?x=\'+(m?\'spc\':\'spb\')+\'&n='.$n.'&u='.$u.'&s='.Req("s").'&a=\'+n);o.PRINT();}</script></head><body style="text-align:center;font-size:14px;font-family:Consolas,微软雅黑;"><div style="width:1200px;margin:20px auto;"><div style="font-size:20px;">'.$r["Sn"].' - 统计报表　['.$a.' - '.(date("Y-m-d",strtotime("-1 Day",strtotime($b)))).']</div><div class="b"><a name="dd"></a>点单详情</div>';
	$s.='<div class="a"><div class="a8">单号</div><div class="a1">桌号</div><div class="a2">下单时间</div><div class="a8">应付</div><div class="a8">优惠</div><div class="a8">抵扣</div><div class="a8">实收</div><div class="a1">结账时间</div><div class="a8">方式</div><div class="a8">服务员</div><div class="a8">收银员</div><div class="a8">备注</div><div class="a8">打单</div></div>';
	$q=Qry("Select * From ".$pre."order Where Si=".$n." And Ps>0 And Od>'".$a."' And Od<'".$b."' Order By ID Desc");
	$t='';$j=2;
	while($r=Qra($q)){
		$h=($r["Ot"]==0?($r["Ox"]==1?"快餐":"外卖"):Qrs(Qry("Select Tn From ".$pre."table Where Si=".$n." And ID=".$r["Ot"])));
		$s.='<div class="a"><div class="a8">'.$r["ID"].'</div><div class="a1">'.$h.'</div><div class="a2">'.$r["Od"].'</div><div class="a8">'.($r["Pm"]/100).'</div><div class="a8">'.($r["Pd"]/100).'</div><div class="a8">'.($r["Pc"]/100).'</div><div class="a8">'.($r["Ps"]/100).'</div><div class="a1">'.substr($r["Oe"],-8).'</div><div class="a8">'.['现金','刷卡','微信','支付宝','会员卡'][$r["Pt"]].'</div><div class="a8">'.$r["O1"].'</div><div class="a8">'.$r["O4"].'</div><div class="a8"><a href="javascript:void();" onclick="alert(\''.str_replace("<br>","\\n",explode("|",$r["Ob"])[0]).'\');">备注</a></div><div class="a8"><a href="javascript:void(0);" onclick="dp('.$r["ID"].');">打单</a></div></div>';$j++;
	}
	$s.='<div class="b"><a name="dc"></a>点菜详情</div><div class="a"><div class="a1">单号</div><div class="a2">桌号</div><div class="a2">菜品</div><div class="a1">价格</div><div class="a1">数量</div><div class="a1">点单</div><div class="a1">厨师</div><div class="a1">传菜</div><div class="a2">下单时间</div></div>';
	$q=Qry("Select * From ".$pre."ofood Where Si=".$n." And Fr=0 And Fd>'".$a."' And Fd<'".$b."' Order By ID Desc");$j=2;
	while($r=Qra($q)){
		$h=($r["Ft"]==0?(Qrs(Qry("Select Os From ".$pre."order Where Si=".$n." And ID=".$r["Fo"]))==1?"快餐":"外卖"):Qrs(Qry("Select Tn From ".$pre."table Where Si=".$n." And ID=".$r["Ft"])));
		$s.='<div class="a"><div class="a1">'.$r["Fo"].'</div><div class="a2">'.$h.'</div><div class="a2">'.$r["Fn"].'</div><div class="a1">'.($r["Fm"]/100).'</div><div class="a1">'.$r["Fc"].'</div><div class="a1">'.$r["F1"].'</div><div class="a1">'.$r["F2"].'</div><div class="a1">'.$r["F3"].'</div><div class="a2">'.$r["Fd"].'</div></div>';$j++;
	}
	$s.='<div class="b"><a name="cz"></a>充值详情</div><div class="a"><div class="a2">卡号</div><div class="a1">单号</div><div class="a3">员工</div><div class="a1">实付金额</div><div class="a1">充值/消费金额</div><div class="a3">时间</div><div class="a1">打单</div></div>';
	$q=Qry("Select * From ".$pre."expend Where Si=".$n." And Gd>'".$a."' And Gd<'".$b."' Order By ID Desc");$j=2;
	while($r=Qra($q)){
		$s.='<div class="a"><div class="a2">'.$r["Gc"].'</div><div class="a1">'.$r["Go"].'</div><div class="a3">'.$r["Gu"].'</div><div class="a1">'.($r["Gm"]/100).'</div><div class="a1">'.($r["Gn"]/100).'</div><div class="a3">'.$r["Gd"].'</div><div class="a1"><a href="javascript:void(0);" onclick="if('.$r["Gm"].'>0)dp('.$r["ID"].',1);">打单</a></div></div>';$j++;
	}
	$s.='<div class="b"><a name="td"></a>退单详情</div><div class="a"><div class="a1">单号</div><div class="a2">桌号</div><div class="a3">菜品</div><div class="a1">价格</div><div class="a1">数量</div><div class="a1">点单</div><div class="a1">厨师</div><div class="a1">传菜</div><div class="a1">备注</div></div>';
	$q=Qry("Select * From ".$pre."ofood Where Si=".$n." And Fr=2 And Fd>'".$a."' And Fd<'".$b."' Order By ID Desc");$j=2;
	while($r=Qra($q)){
		$h=($r["Ft"]==0?(Qrs(Qry("Select Ox From ".$pre."order Where Si=".$n." And ID=".$r["Fo"]))==1?"快餐":"外卖"):Qrs(Qry("Select Tn From ".$pre."table Where Si=".$n." And ID=".$r["Ft"])));
		$s.='<div class="a"><div class="a1">'.$r["Fo"].'</div><div class="a2">'.$h.'</div><div class="a3">'.$r["Fn"].'</div><div class="a1">'.($r["Fm"]/100).'</div><div class="a1">'.$r["Fc"].'</div><div class="a1">'.$r["F1"].'</div><div class="a1">'.$r["F2"].'</div><div class="a1">'.$r["F3"].'</div><div class="a1">'.$r["Fb"].'</div></div>';$j++;
	}
	$s.='<div class="b"><a name="cp"></a>菜品详情</div><div class="a"><div class="a3">菜品</div><div class="a1">销量</div><div class="a3">菜品</div><div class="a1">销量</div><div class="a3">菜品</div><div class="a1">销量</div></div><div class="a">';
	$q=Qry("Select ID,Dn From ".$pre."foods Where Si=".$n." And Dh=0 Order By ID Asc");
	$i=0;$j=2;
	while($r=Qra($q)){
		if($i%3==0)$s.='<div class="a">';
		$e=Qrs(Qry("Select Sum(Fc) From ".$pre."ofood Where Si=".$n." And Fi=".$r["ID"]." And Fd>'".$a."' And Fd<'".$b."'"));
		$s.='<div class="a3">'.$r["Dn"].'</div><div class="a1">'.($e?$e:0).'</div>';
		if($i%3==2)$s.="</div>";
		$i=$i+1;$j++;
	}
	if($i%3!=2)$s.="</div>";
	$s.='<div class="b"><a name="yg"></a>员工详情</div><div class="a"><div class="a8">点单</div><div class="a8">单数</div><div class="a8">金额</div><div class="a8">收银</div><div class="a8">单数</div><div class="a8">金额</div><div class="a8">厨师</div><div class="a8">单数</div><div class="a8">金额</div><div class="a8">内送</div><div class="a8">单数</div><div class="a8">金额</div><div class="a8">外送</div><div class="a8">单数</div><div class="a8">金额</div></div><div style="float:left;width:240px;">';
	$q=Qry("Select ID,An From ".$pre."admin Where Si=".$n." And Ah=0 And Ar Like '%A%'");$j=11;
	while($r=Qra($q)){
		$e=Qra(Qry("Select Count(ID) As N,Sum(Ps) As M From ".$pre."order Where Si=".$n." And O1=".$r["ID"]." And Od>'".$a."' And Od<'".$b."'"));
		$s.='<div class="a"><div class="a8">'.$r["An"].'</div><div class="a8">'.$e["N"].'</div><div class="a8">'.($e["M"]?$e["M"]/100:0).'</div></div>';$j++;
	}
	$s.='</div><div style="float:left;width:240px;">';
	$q=Qry("Select ID,An From ".$pre."admin Where Si=".$n." And Ah=0 And Ar Like '%B%'");
	while($r=Qra($q)){
		$e=Qra(Qry("Select Count(ID) As N,Sum(Ps) As M From ".$pre."order Where Si=".$n." And O4=".$r["ID"]." And Od>'".$a."' And Od<'".$b."'"));
		$s.='<div class="a"><div class="a8">'.$r["An"].'</div><div class="a8">'.$e["N"].'</div><div class="a8">'.($e["M"]?$e["M"]/100:0).'</div></div>';$j++;
	}
	$s.='</div><div style="float:left;width:240px;">';
	$q=Qry("Select ID,An From ".$pre."admin Where Si=".$n." And Ah=0 And Ar Like '%C%'");
	while($r=Qra($q)){
		$e=Qra(Qry("Select Count(ID) As N,Sum(Fm) As M From ".$pre."ofood Where Si=".$n." And F2=".$r["ID"]." And Fd>'".$a."' And Fd<'".$b."'"));
		$s.='<div class="a"><div class="a8">'.$r["An"].'</div><div class="a8">'.$e["N"].'</div><div class="a8">'.($e["M"]?$e["M"]/100:0).'</div></div>';$j++;
	}
	$s.='</div><div style="float:left;width:240px;">';
	$q=Qry("Select ID,An From ".$pre."admin Where Si=".$n." And Ah=0 And Ar Like '%D%'");
	while($r=Qra($q)){
		$e=Qra(Qry("Select Count(ID) As N,Sum(Fm) As M From ".$pre."ofood Where Si=".$n." And F3=".$r["ID"]." And Fd>'".$a."' And Fd<'".$b."'"));
		$s.='<div class="a"><div class="a8">'.$r["An"].'</div><div class="a8">'.$e["N"].'</div><div class="a8">'.($e["M"]?$e["M"]/100:0).'</div></div>';$j++;
	}
	$s.='</div><div style="float:left;width:240px;">';
	$q=Qry("Select ID,An From ".$pre."admin Where Si=".$n." And Ah=0 And Ar Like '%E%'");
	while($r=Qra($q)){
		$e=Qra(Qry("Select Count(ID) As N,Sum(Hm) As M From ".$pre."osend Where Si=".$n." And Hu=".$r["ID"]." And Hd>'".$a."' And Hd<'".$b."'"));
		$s.='<div class="a"><div class="a8">'.$r["An"].'</div><div class="a8">'.$e["N"].'</div><div class="a8">'.($e["M"]?$e["M"]/100:0).'</div></div>';$j++;
	}
	$s.='</div></div><div style="clear:both;line-height:30px;">Created At '.date("Y-m-d H:i:s",time()).'</div></body></html>';
	echo $s;
	break;

	case "ewm"://二维码
	$s=Qrs(Qry("Select Sn From ".$pre."shop Where Si=".$n));
	echo '<html><head><title>二维码</title><style>a{color:#09F;text-decoration:none;}.a{float:left;width:281px;text-align:center;margin:10px;}img{cursor:pointer;}</style></head><body style="font-size:14px;"><div>提示：若更换了服务器、域名、网站目录，此二维码需重新生成！！</div><div class="a"><img src="qrcode.php?u='.urlencode($cfg["Aw"]).'index%2Ephp%3Fi%3D'.$n.'" width="231" height="231" onclick="window.open(\'qrcode.php?u='.urlencode($cfg["Aw"]).'index%2Ephp%3Fi%3D'.$n.'&o='.$s.'-店员管理\');"><br><a href="'.$cfg["Aw"].'index.php?i='.$n.'">店员管理二维码</a></div><div class="a"><img src="qrcode.php?url='.urlencode($cfg["Aw"]).'guest2%2Ephp%3Fi%3D'.$n.'" width="231" height="231" onclick="window.open(\'qrcode.php?u='.urlencode($cfg["Aw"]).'guest2%2Ephp%3Fi%3D'.$n.'&o='.$s.'-快餐外卖\');"><br><a href="'.$cfg["Aw"].'guest2.php?i='.$n.'">快餐外卖二维码</a></div>';
	$q=Qry("Select ID,Tn From ".$pre."table Where Si=".$n." And Th=0 Order By ID Asc");
	while($r=Qra($q)){
		echo '<div class="a"><img src="qrcode.php?u='.urlencode($cfg["Aw"]).'guest1%2Ephp%3Fi%3D'.$n.'%26t%3D'.substr(md5($n.$r["ID"]),0,8).'" width="231" height="231" onclick="window.open(\'qrcode.php?u='.urlencode($cfg["Aw"]).'guest1%2Ephp%3Fi%3D'.$n.'%26t%3D'.substr(md5($n.$r["ID"]),0,8).'&o='.$s.'-'.$r["Tn"].'\');"><br><a href="'.$cfg["Aw"].'guest1.php?i='.$n.'&t='.substr(md5($n.$r["ID"]),0,8).'">'.$r["Tn"].'（正餐模式）</a></div>';
	}
	echo '</body></html>';
	break;

	default:
}
?>