<?php
//====== 餐厅设置 ======
require "common.php";
$m=file_get_contents("php://input");if($m==""||Req("act")=="index")$m='{"act":"idx"}';$m=Dec($m,true);
if($m["act"]!="idx"){
	$r=Qra(Qry("Select Ar From ".$pre."admin Where Ah=0 And ID=".$m["uid"]." And Si=".$m["nid"]." And Ak='".$m["sid"]."'"));
	if(!$r||$m["sid"]=="")die('{"msg":"连接超时，请重登录！"}');
	if(strpos($r["Ar"],"S")===false)die('{"msg":"无此权限！"}');
	$nid=$m["nid"];
}
switch($m["act"]){
	case "cfg"://设置读取
	$p=["msg"=>"ok","St"=>[],"Sb"=>[],"Sd"=>[],"Sf"=>[],"Sk"=>""];
	$r=Qra(Qry("Select Sn,Sc,Sh From ".$pre."shop Where Si=".$nid));
	$p["Sc"]=Dec($r["Sc"]);$p["Sn"]=$r["Sn"];$p["Sh"]=$r["Sh"];$p["vid"]=md5($m["sid"]);
	$q=Qry("Select ID,Tn,Tr,Tc From ".$pre."table Where Th=0 And Si=".$nid." Order By Tr Asc");
	while($r=Qra($q))$p["St"][]=$r;
	$q=Qry("Select ID,Bn,Br,Bs,Bp,Bh From ".$pre."class Where Si=".$nid." Order By Br Asc");
	while($r=Qra($q))$p["Sb"][]=$r;
	$q=Qry("Select ID,Dn,Dc,Ds,Di,Dm,Dr,Dk,Dt,Dv,Da,Db,D1,D2,Dh From ".$pre."foods Where Dh<2 And Si=".$nid." Order By Dr Asc");
	while($r=Qra($q))$p["Sd"][]=$r;
	$q=Qry("Select ID,An,Au,Ap,Aw,Am,Ar,Ad,A0,A1,Ak From ".$pre."admin Where Ah=0 And Si=".$nid." Order By ID Asc");
	while($r=Qra($q))$p["Sf"][]=$r;
	$q=Qry("Select ID,Kn,Kc,Ku,Ks,Kw From ".$pre."stock Where Kh=0 And Si=".$nid);
	while($r=Qra($q))$p["Sk"][]=$r;
	echo Enc($p);
	break;

	case "scv"://基本保存
	Qry("Update ".$pre."shop Set Sc='".Enc($m["Sc"])."',Sh=".$m["Sh"]." Where Si=".$nid);
	echo '{"msg":"ok"}';
	break;

	case "stv";//餐桌保存
	if($m["ID"]*1==0){Qry("Insert Into ".$pre."table (Si,Tn,Tr,Tc,Tu,Ts,Ti,Tm,Ta,Th) Values (".$nid.",'".$m["Tn"]."',".$m["Tr"].",".$m["Tc"].",0,0,0,0,0,0)");
	}else Qry("Update ".$pre."table Set Tn='".$m["Tn"]."',Tr=".$m["Tr"].",Tc=".$m["Tc"]." Where Si=".$nid." And ID=".$m["ID"]);
	echo '{"msg":"ok"}';
	break;

	case "std"://餐桌删除
	Qry("Update ".$pre."table Set Th=1 Where Si=".$nid." And ID=".$m["ID"]);
	echo '{"msg":"ok"}';
	break;

	case "sbv"://类别保存
	if($m["ID"]*1==0){Qry("Insert Into ".$pre."class (Si,Bn,Br,Bh,Bs,Bp) Values (".$nid.",'".$m["Bn"]."',".$m["Br"].",".$m["Bh"].",0,".$m["Bp"].")");
	}else Qry("Update ".$pre."class Set Bn='".$m["Bn"]."',Br=".$m["Br"].",Bh=".$m["Bh"].",Bp=".$m["Bp"]." Where Si=".$nid." And ID=".$m["ID"]);
	echo '{"msg":"ok"}';
	break;
	
	case "sbd"://类别删除
	Qry("Delete From ".$pre."class Where Bs=0 And Si=".$nid." And ID=".$m["ID"]);
	echo '{"msg":"ok"}';
	break;

	case "sbf"://类别修复
	Qry("Update ".$pre."class Set Bp=0 Where Si=".$nid);
	echo '{"msg":"ok"}';
	break;

	case "sdv"://菜品保存
	$r=Qra(Qry("Select Dc,Di From ".$pre."foods Where Si=".$nid." And ID=".$m["ID"]));
	$p=isset($r["Di"])?$r["Di"]:0;if(substr($m["Di"],0,23)=="data:image/jpeg;base64,")$p=1;
	if($r){
		Qry("Update ".$pre."class Set Bs=Bs-1 Where Si=".$nid." And ID In (0".$r["Dc"]."0)");
		Qry("Update ".$pre."foods Set Dn='".$m["Dn"]."',Dc='".$m["Dc"]."',Ds='".$m["Ds"]."',Di=".$p.",Dm=".$m["Dm"].",Dr=".$m["Dr"].",Dk='".$m["Dk"]."',Dt='".$m["Dt"]."',Dv='".$m["Dv"]."',Da='".$m["Da"]."',Db='".$m["Db"]."',D1=".$m["D1"].",D2=".$m["D2"].",Dh=".$m["Dh"]." Where Si=".$nid." And ID=".$m["ID"]);
	}else{
		Qry("Insert Into ".$pre."foods (Si,Dn,Dc,Ds,Di,Dm,Dr,Dk,Dt,Dv,Da,Db,D1,D2,Dh) Values (".$nid.",'".$m["Dn"]."','".$m["Dc"]."','".$m["Ds"]."',".$p.",".$m["Dm"].",".$m["Dr"].",'".$m["Dk"]."','".$m["Dt"]."','".$m["Dv"]."','".$m["Da"]."','".$m["Db"]."',".$m["D1"].",".$m["D2"].",".$m["Dh"].")");
		$m["ID"]=Qri();
	}
	Qry("Update ".$pre."class Set Bs=Bs+1 Where Si=".$nid." And ID In (0".$m["Dc"]."0)");
	if(substr($m["Di"],0,23)=="data:image/jpeg;base64,")file_put_contents("images/".$nid."/c".$m["ID"].".jpg",base64_decode(substr($m["Di"],23)));
	echo '{"msg":"ok"}';
	break;

	case "sdd"://菜品删除
	if(file_exists("images/".$nid."/c".$m["ID"].".jpg"))unlink("images/".$nid."/c".$m["ID"].".jpg");
	$b=Qrs(Qry("Select Dc From ".$pre."foods Where Si=".$nid." And ID=".$m["ID"]));
	Qry("Update ".$pre."class Set Bs=Bs-1 Where Si=".$nid." And ID In (0".$b."0)");
	Qry("Update ".$pre."foods Set Dh=2,Dc=',0,' Where Si=".$nid." And ID=".$m["ID"]);
	echo '{"msg":"ok"}';
	break;

	case "skv"://库存保存
	if($m["ID"]*1==0){Qry("Insert Into ".$pre."stock (Si,Kn,Kc,Ku,Ks,Kw,Kh) Values (".$nid.",'".$m["Kn"]."','".$m["Kc"]."','".$m["Ku"]."',".$m["Ks"].",".$m["Kw"].",0)");
	}else Qry("Update ".$pre."stock Set Kn='".$m["Kn"]."',Kc='".$m["Kc"]."',Ku='".$m["Ku"]."',Ks=".$m["Ks"].",Kw=".$m["Kw"]." Where Si=".$nid." And ID=".$m["ID"]);
	echo '{"msg":"ok"}';
	break;

	case "skd"://库存删除
	Qry("Update ".$pre."stock Set Kh=1 Where Si=".$nid." And ID=".$m["ID"]);
	echo '{"msg":"ok"}';
	break;

	case "skh"://库存进货
	if(file_exists("images/".$nid."/k.txt")){$f=Dec(file_get_contents("images/".$nid."/k.txt"));}else $f=["msg"=>"ok"];
	if(!isset($f["Sk"]))$f["Sk"]=[];$f["Sk"][date("YmdHis")]=$m["Sk"];file_put_contents("images/".$nid."/k.txt",Enc($f));
	for($i=0;$i<count($m["Sk"]);$i++)Qry("Update ".$pre."stock Set Ks=Ks+".($m["Sk"][$i][3]*$m["Sk"][$i][5])." Where Si=".$nid." And ID=".$m["Sk"][$i][0]);
	echo '{"msg":"ok"}';
	break;

	case "sfv"://员工保存
	$b=md5($m["Ap"]);
	if($m["ID"]*1==0){
		if(Qrc(Qry("Select ID From ".$pre."admin Where Si=".$nid." And Au='".$m["Au"]."'"))>0)die('{"msg":"员工用户名重复！"}');
		Qry("Insert Into ".$pre."admin (Si,An,Au,Ap,Aw,Am,Ar,Ad,A0,A1,Ak,Ah) Values (".$nid.",'".$m["An"]."','".$m["Au"]."','".$b."','".$m["Aw"]."','".$m["Am"]."','".$m["Ar"]."',Now(),0,0,'',0)");
	}else{
		$c=Qrs(Qry("Select Ap From ".$pre."admin Where Si=".$nid." And ID=".$m["ID"]));
		Qry("Update ".$pre."admin Set An='".$m["An"]."',Au='".$m["Au"]."',Ap='".($c==$m["Ap"]?$m["Ap"]:$b)."',Aw='".$m["Aw"]."',Am='".$m["Am"]."',Ar='".$m["Ar"]."' Where ID=".$m["ID"]);
	}
	echo '{"msg":"ok"}';
	break;

	case "sfd"://员工删除
	Qry("Update ".$pre."admin Set Ak='',Ah=1 Where Si=".$nid." And ID=".$m["ID"]);
	echo '{"msg":"ok"}';
	break;

	case "sfx"://员工下线
	if($m["ID"]>-1){Qry("Update ".$pre."admin Set Ak='' Where Mi=".$nid." And ID=".$m["ID"]);}else Qry("Update ".$pre."admin Set Ak='' Where Si=".$nid);
	echo '{"msg":"ok"}';
	break;

	case "sfr"://员工更新
	$a=0;
	$b=Qrs(Qry("Select Ar From ".$pre."admin Where Si=".$nid." And ID=".$m["ID"]));
	if(strpos($b,"A")>-1){
		$q=Qry("Select A.Fc,B.D1 From ".$pre."ofood As A,".$pre."foods As B Where A.Si=".$nid." And B.ID=A.Fi And A.F1=".$m["ID"]);
		while($r=Qra($q))$a+=$r["Fc"]*$r["D1"];
	}
	if(strpos($b,"C")>-1){
		$q=Qry("Select A.Fc,B.D2 From ".$pre."ofood As A,".$pre."foods As B Where A.Si=".$nid." And B.ID=A.Fi And A.F2=".$m["ID"]);
		while($r=Qra($q))$a+=$r["Fc"]*$r["D2"];
	}
	if(strpos($b,"E")>-1)$a+=Qrs(Qry("Select Sum(Hm) From ".$pre."osend Where Si=".$nid." And Hs=3 And Hu=".$m["ID"]))*1;
	Qry("Update ".$pre."admin Set A0=".$a."-A1 Where Si=".$nid." And ID=".$m["ID"]);
	echo '{"msg":"ok"}';
	break;

	case "sfe"://员工结算
	Qry("Update ".$pre."admin Set A1=A1+A0,A0=0 Where Si=".$nid." And ID=".$m["ID"]);
	Qry("Update ".$pre."osend Set Hs=4 Where Si=".$nid." And Hs=3 And Hu=".$m["ID"]);
	echo '{"msg":"ok"}';
	break;

	case "spe"://打印默认
	Qry("Update ".$pre."shop Set Dv='".$m["Dv"]."' Where Si=".$nid);
	echo '{"msg":"ok"}';
	break;

	default:
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>餐厅设置</title>
<style type="text/css">
html,body {margin:0px;padding:0px;font-size:14px;font-family:Consolas,微软雅黑;}
a:link,a:visited {color:#09F;text-decoration:none;}
a:hover,a:active {color:#F00;text_decoration:underline;}
input[type=text],input[type=date],input[type=number],input[type=password],textarea,select {padding:3px;font-size:14px;font-family:Consolas,微软雅黑;resize:none;}
#msk {position:fixed;left:0px;top:0px;background-color:#000;opacity:0.2;z-index:9;display:none;}
#tip {position:fixed;background-color:#000;color:#FFF;padding:5px 10px;box-shadow:2px 2px 2px #666;border-radius:3px;z-index:99;display:none;}
#cfn {position:fixed;background-color:#FFF;padding:20px;width:320px;border:1px solid #CCC;line-height:24px;box-shadow:2px 2px 2px #666;display:none;z-index:98;}
.fld {position:fixed;background-color:#FFF;border:1px double #CCC;box-shadow:0px 0px 5px #999;display:none;}
.flt {line-height:40px;text-align:center;font-weight:bold;background-color:#F6F6F6;font-size:16px;}
.flb {padding:10px 20px;line-height:36px;}
.flk {background-color:#F3F9FF;padding:0px 10px;line-height:28px;text-align:right;}
.btn {display:inline-block;line-height:28px;color:#FFF;background-color:#09F;box-shadow:2px 2px 3px #CCC;padding:0px 10px;cursor:pointer;border-radius:5px;}
.bn0 {display:inline-block;line-height:24px;margin:8px 0px 0px 8px;padding:0px 6px;border:1px solid #CCC;text-align:center;cursor:pointer;}
.bn1 {display:inline-block;line-height:24px;margin:8px 0px 0px 8px;padding:0px 6px;border:1px solid #CCC;background-color:#09F;color:#FFF;text-align:center;cursor:pointer;}
.bnc {float:right;width:24px;line-height:24px;border:1px solid #CCC;text-align:center;cursor:pointer;margin:7px;font-size:20px;}
.pgs {width:1200px;line-height:28px;margin:auto;text-align:center;padding:4px;}
.pg0 {display:inline-block;line-height:26px;border:1px solid #CCC;width:26px;margin:0px 5px;cursor:pointer;color:#09F;}
.pg1 {display:inline-block;line-height:28px;background-color:#09F;width:28px;margin:0px 5px;cursor:pointer;color:#FFF;}
/*----------------------------------------------------------------*/
.dn0 {line-height:40px;font-size:16px;text-align:center;margin-top:2px;border-bottom:1px solid #CCC;background-color:#F3F3F3;cursor:pointer;}
.dn1 {line-height:40px;font-size:16px;text-align:center;margin-top:2px;border-bottom:1px solid #CCC;background-color:#09F;color:#FFF;}
.dmb {font-size:14px;line-height:32px;display:none;}.dmt a,.dmt span{font-size:14px;}
.dmt {font-size:20px;border-bottom:1px solid #09F;line-height:50px;}
.stl {float:left;width:200px;text-align:center;background-color:#F3F9FF;line-height:40px;border:1px solid #CCC;margin:5px;cursor:pointer;}
.sb0 {text-align:left;padding:4px 10px;background-color:#DEF;line-height:30px;margin:2px;cursor:pointer;}
.sb1 {text-align:left;padding:4px 10px;background-color:#09F;color:#FFF;line-height:30px;margin:2px;cursor:pointer;}
.sbe {width:14px;height:14px;font-size:11px;font-family:Tahoma;line-height:14px;text-align:center;color:#000;display:inline-block;}
.sdl {float:left;width:270px;line-height:20px;height:60px;background-color:#F3F9FF;border:1px solid #9CF;margin:5px;padding:5px;cursor:pointer;}
.sdi {float:left;width:90px;height:60px;margin-right:5px;}
.sd0 {display:inline-block;line-height:28px;border:1px dashed #09F;font-size:12px;background-color:#09F;color:#FFF;margin:3px 7px;padding:0px 5px;text-align:center;cursor:pointer;}
.sd1 {display:inline-block;line-height:28px;border:1px dashed #09F;font-size:12px;background-color:#F9FCFF;margin:3px 7px;padding:0px 5px;text-align:center;cursor:pointer;}
.sdk {float:left;width:192px;border:1px solid #CCC;background-color:#F3F9FF;line-height:32px;height:32px;margin:5px;padding:0px 10px;cursor:pointer;}
.skl {clear:both;border-bottom:1px dashed #999;line-height:32px;font-size:16px;margin:15px 0px 0px 5px;}
.sk0 {width:240px;float:left;border:1px solid #CCC;background-color:#FF9900;line-height:32px;height:32px;margin:5px;padding:0px 10px;cursor:pointer;color:#FFF;}
.sk1 {width:240px;float:left;border:1px solid #CCC;background-color:#F3F9FF;line-height:32px;height:32px;margin:5px;padding:0px 10px;cursor:pointer;}
.skr {float:right;width:60px;text-align:right;}
#Lkh div {float:left;font-size:12px;border-bottom:1px dashed #CCC;line-height:30px;height:30px;width:110px;text-align:center;}
#Lkh div input[type=text] {font-size:12px;width:60px;text-align:center;}
.sfl {background-color:#F3F9FF;margin:5px 0px;line-height:40px;height:40px;border:1px solid #CCC;}
.sfi {float:left;width:100px;text-align:center;}
</style>
<script type="text/javascript">
function $(o){return document.getElementById(o);}function $$(o){return document.getElementsByName(o);}
function xml(u,p,f){var x;try{x=new ActiveXObject('Msxml2.XMLHTTP');}catch(e){try{x=new ActiveXObject('Microsoft.XMLHTTP');}catch(f){x=false;}}if(!x&&typeof XMLHttpRequest!='undefined'){x=new XMLHttpRequest();}if(!x){alt('创建XHR对象失败！');return;}x.open(p?'Post':'Get',u,true);x.setRequestHeader('Content-Type','application/json;');x.onreadystatechange=function(){if(x.readyState==4&&x.status==200){try{var s=JSON.parse(x.responseText.replace(/\&\#32;/gi,' ').replace(/\&\#34;/gi,'&quot;').replace(/\&\#37;/gi,'%').replace(/\&\#39;/gi,'\''));if(s.msg!='ok'){alt(s.msg);return;}}catch(e){alt('响应JSON解析错误！\n'+x.responseText+'\n'+e);return;}f(s);}};x.send(p?JSON.stringify(p):null);}
function rnd(n,c){var s='';for(var i=0;i<(n||16);i++)s+='1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM'.substr(Math.floor((c?10:62)*Math.random()),1);return s;}
function num(n){var o=event.srcElement;if(o.tagName=='INPUT'&&(o.type=='text'||o.type=='number')){if(!n)n=0;var v=parseFloat(o.value);if(!v)v=0;v=Math.round(v*Math.pow(10,n))/Math.pow(10,n);o.value=v;}}
function sck(n,v){var d=new Date();d.setTime(d.getTime()+1080000000);document.cookie=n+'='+encodeURI(v)+'; expires='+d.toGMTString();}
function gck(n){var c=document.cookie.split("; ");for(var i=0;i<c.length;i++){var t=c[i].split("=");if(t[0]==n)return decodeURI(t[1]);}return '';}
function css(n){for(var i=0;i<document.styleSheets.length;i++){var r=document.styleSheets[i].cssRules?document.styleSheets[i].cssRules:document.styleSheets[i].rules;for(var j=0;j<r.length;j++){if(r[j].selectorText==n)return r[j].style;}}}
function psz(o,s){var w=o.width;var h=o.height;if(w<h){h=h*s/w;w=s;}else{w=s*w/h;h=s;}o.width=w;o.height=h;o.style.margin=(s-h)/2+'px '+(s-w)/2+'px';}
function bsz(o,w,h){w=parseInt(w);h=parseInt(h)-4;var s=w>h?w:h;psz(o,s);}
function fio(m,n,o){if(o&&o!=1){o=o.split(',');for(var i=0;i<o.length;i++)$(o[i]).style.display='none';}o=o?1:0;$(m).style.display='block';if(o)msk.style.display='block';var c=Math.round(parseFloat($(m).style.opacity||(n>0?0:1))*100)/100;c+=0.1*n;if(c<=1&&c>0){$(m).style.opacity=c;if(o)msk.style.opacity=c/5;$(m).style.left=(pw-parseInt($(m).offsetWidth))/2+'px';$(m).style.top=(ph-parseInt($(m).offsetHeight))/2+20-c*20+'px';setTimeout('fio(\''+m+'\','+n+','+o+')',20);}if(c==0){$(m).style.display='none';if(o)msk.style.display='none';}}
function alt(n){tip.innerText=n;if(tip.style.display=='block')return;fio('tip',1);setTimeout(function(){fio('tip',-1);},2000);}
function cfm(n,s,c){var m=msk.style.display=='block'?false:1;msk.style.zIndex=97;cfn.innerHTML=n.replace(/\n/gi,'<br>')+'<div style="text-align:right;"><br><span id="cfc" class="bn0">取消</span>　<span id="cfs" class="bn1">确定</span></div>';cfc.addEventListener('click',function(){fio('cfn',-1,m);msk.style.zIndex=9;if(c)c();});cfs.addEventListener('click',function(){fio('cfn',-1,m);msk.style.zIndex=9;s();});fio('cfn',1,m);}
function pgs(c,t,f){c=c||1;var s='<div class="pgs">分页： <span class="pg'+(c==1?1:0)+'" onclick="'+f.replace('{{id}}',1)+'">1</span>';if(c-5>1)s+='...';for(var i=c-4;i<c+5;i++){if(i>1&&i<t)s+='<span class="pg'+(i==c?1:0)+'" onclick="'+f.replace('{{id}}',i)+'">'+i+'</span>';}if(c+5<t)s+='...';if(t>1)s+='<span class="pg'+(c==t?1:0)+'" onclick="'+f.replace('{{id}}',t)+'">'+t+'</span>';return s+' <input type="text" style="width:32px;text-align:center;" onkeyup="num();if(event.keyCode==13)'+f.replace('{{id}}','this.value')+';"></div>';}
/*----------------------------------------------------------------*/
var uri='system.php';
var url='<?php echo $cfg["Aw"];?>';
var nid='<?php echo Req("nid");?>';
var uid='<?php echo Req("uid");?>';
var sid='<?php echo Req("sid");?>';
var pid=rnd();
var pw,ph,Sc,Sb,Sd,St,Sk,Sf,Sh,Sl,tid,vid;
function rsz(){pw=parseInt(document.documentElement.clientWidth);ph=parseInt(document.documentElement.clientHeight);msk.style.width=pw+'px';msk.style.height=ph+'px';Dn.style.height=ph-60+'px';Dm.style.width=pw-180+'px';Dm.style.height=ph-60+'px';Ld.style.width=pw-356+'px';css('.sfi').width=(pw-200)/7+'px';setTimeout('rsz()',500);}
function jsn(x){return {act:x,uid:uid,nid:nid,sid:sid,rnd:rnd(6)};}
//读取设置
function cfg(n){xml(uri,jsn('cfg'),function(r){document.title=r.Sn+' - 餐厅设置';Sn.innerText=r.Sn+' - 餐厅设置';Sc=r.Sc;Sf=r.Sf;Sk=r.Sk;St=r.St;Sb=r.Sb;Sd=r.Sd;vid=r.vid;Sh=r.Sh*1;var o=document.createElement('script');o.src=Sc.p[0]+'CLodopfuncs.js';document.body.appendChild(o);setTimeout('nav('+n+')',300);
});}
//功能导航
function nav(n){for(var i=0;i<7;i++){$('Dn'+i).className='dn0';$('Dm'+i).style.display='none';}$('Dn'+n).className='dn1';$('Dm'+n).style.display='block';eval(['shc()','sht()','shb(0)','shk()','shf()','shz()','shp()'][n]);}
//基本设置
function shc(){Sc_i.innerText=nid;Sc_n.innerText=Sn.innerText;Sc_h.checked=Sh==1;Sc_0.options[Sc.i[0]].selected=true;Sc_1.options[Sc.i[1]].selected=true;Sc_2.options[Sc.i[2]].selected=true;for(var i=3;i<17;i++)$('Sc_'+i).value=Sc.i[i].replace(/\&quot;/gi,'"');}
function scv(){var t=[];for(var i=0;i<17;i++)t[i]=$('Sc_'+i).value;var p=jsn('scv');p.Sc=Sc;p.Sc.i=t;p.Sh=Sc_h.checked?1:0;xml(uri,p,function(r){alt('基本设置保存成功！');cfg(0);});}
//餐桌设置
function sht(){var s='';for(var i=0;i<St.length;i++)s+='<div class="stl" onclick="sti('+i+');">'+St[i].Tn+'['+St[i].Tc+'人座]</div>';Lt.innerHTML=s;}
function sti(n){var s=n<0?{ID:0,Tn:(St.length+1)+'号桌',Tr:St.length+1,Tc:4}:St[n];St_ID.value=s.ID;St_Tn.value=s.Tn;St_Tr.value=s.Tr;St_Tc.value=s.Tc;fio('Ft',1,1);}
function stv(){var p=jsn('stv');p.ID=St_ID.value;p.Tn=St_Tn.value;p.Tr=St_Tr.value;p.Tc=St_Tc.value;xml(uri,p,function(r){fio('Ft',-1,1);cfg(1);});}
function std(){if(St_ID.value*1==0)return;cfm('确认删除？',function(){var p=jsn('std');p.ID=St_ID.value;xml(uri,p,function(r){fio('Ft',-1,1);cfg(1);});});}
//菜类设置
function shb(n){var s='';for(var i=0;i<Sb.length;i++){if(Sb[i].Bp*1==n)s+='<div id="Lb_i'+Sb[i].ID+'" class="sb0" onclick="shb('+Sb[i].ID+');" ondblclick="sbi('+Sb[i].ID+');"><span id="de'+Sb[i].ID+'" class="sbe">&gt;</span>'+Sb[i].Bn+'('+Sb[i].Bs+')'+((Sb[i].Bh*1==1)?'H':'')+'</div><div id="Lb_'+Sb[i].ID+'" style="margin-left:10px;"></div>';}$('Lb_'+n).innerHTML=$('Lb_'+n).innerHTML==''?s:(n>0?'':s);if(n>0)$('de'+n).style.transform='rotate('+($('Lb_'+n).innerHTML==''?0:90)+'deg)';shd(n);}
function sbi(n){var s={ID:0,Bn:'',Br:Sb.length+1,Bh:0};for(var i=0;i<Sb.length;i++){if(Sb[i].ID*1==n)s=Sb[i];}Sb_ID.value=s.ID;Sb_Bn.value=s.Bn;Sb_Br.value=s.Br;Sb_Bh.checked=s.Bh*1==1;var c='<select id="Sb_Bp"><option value="0">一级大类</option>';for(var i=0;i<Sb.length;i++)c+='<option value="'+Sb[i].ID+'"'+(Sb[i].ID*1==s.Bp*1?' selected':'')+'>'+Sb[i].Bn+'</option>';Sb_Bs.innerHTML=c+'</select>';fio('Fb',1,1);}
function sbv(){var p=jsn('sbv');p.ID=Sb_ID.value;p.Bn=Sb_Bn.value==''?'未命名':Sb_Bn.value;p.Br=Sb_Br.value;p.Bh=Sb_Bh.checked?1:0;p.Bp=Sb_Bp.value;xml(uri,p,function(r){fio('Fb',-1,1);cfg(2);});}
function sbd(){if(Sb_ID.value*1==0)return;cfm('确认删除？\n删除菜类时该分类下应无菜品！',function(){var p=jsn('sbd');p.ID=Sb_ID.value;xml(uri,p,function(r){fio('Fb',-1,1);cfg(2);});});}
function sbf(){cfm('例如您已设置B为A的子类，不慎又同时设置了A为B的子类，则会出错，两个分类都将无法显示！\n修复后会将所有分类都设置为一级大类！确认继续修复？',function(){xml(uri,jsn('sbf'),function(r){cfg(2);});});}
//菜单设置
function shd(n){if(n>0){for(var i=0;i<Sb.length;i++){if($('Lb_i'+Sb[i].ID))$('Lb_i'+Sb[i].ID).className='sb0';}$('Lb_i'+n).className='sb1';}var s='';for(var i=0;i<Sd.length;i++){if(Sd[i].Dc.indexOf(','+n+',')>-1)s+='<div class="sdl" onclick="sdi('+i+');"><div class="sdi"><img src="images/'+(Sd[i].Di*1==1?(nid+'/c'+Sd[i].ID+'.jpg?'+pid):'none.jpg')+'" width="90" height="60"></div>'+Sd[i].Dn+(Sd[i].Dh*1==1?'[H]':'')+'<br>售价：'+Sd[i].Dm/100+' 元</div>';}Ld.innerHTML=s;}
function sdi(n){if(Sb.length==0){alt('请先建立菜类！');return;}var s=n<0?{ID:0,Dn:'',Dc:',',Ds:'',Di:0,Dm:'',Dr:Sd.length+1,Dk:'',Dt:'0',Dv:Sc.p[4],Da:'0',Db:'',D1:0,D2:0,Dh:0}:Sd[n];var c='';for(var i=0;i<Sb.length;i++)c+=' <input type="checkbox" name="Sd_Dc" value="'+Sb[i].ID+'"'+(s.Dc.indexOf(','+Sb[i].ID+',')>-1?' checked':'')+'> '+Sb[i].Bn;Sd_c.innerHTML=c;Sd_Di.src=s.Di*1==0?'images/none.jpg':('images/'+nid+'/c'+s.ID+'.jpg?'+pid);Sd_ID.value=s.ID;Sd_Dn.value=s.Dn;Sd_Ds.value=s.Ds;Sd_Dr.value=s.Dr;Sd_Dm.value=s.Dm==''?'':(s.Dm/100);Sd_Dh.checked=s.Dh*1==1;Sd_Dt.value=s.Dt;Sd_D1.value=s.D1/100;Sd_D2.value=s.D2/100;Sd_v.innerHTML=spc('Sd_Dv',s[13]);Sd_Da.value=s.Da;var t='';var m=s.Da.split(',');for(var i=0;i<Sf.length;i++){if(Sf[i].Ar.indexOf('C')>-1)t+=' <input type="checkbox" name="Sd_Da" value="'+Sf[i].ID+'"'+((s.Da+',A').indexOf(','+Sf[i].ID+',')>-1?'checked':'')+'> '+Sf[i].An;}Sd_a.innerHTML=t;sde(1);fio('Fd',1,1);}
function sdu(){var r=new FileReader();r.readAsDataURL(document.getElementById('Sd_u').files[0]);r.onload=function(e){var c=document.createElement('canvas');var v=c.getContext('2d');var d=this.result;if(d.substr(0,23)!='data:image/jpeg;base64,'){alt('请选择JPG格式图片文件！');return;}var m=new Image();m.src=d;m.onload=function(){var w=m.width;var h=m.height;if(w<h){h=h*480/w;w=480;}else{w=w*480/h;h=480;}c.width=w;c.height=h;v.drawImage(m,0,0,w,h);Sd_Di.src=c.toDataURL('image/jpeg');};Fd_u.innerHTML='<input type="file" id="Sd_u" onchange="sdu();">';};}
function sdv(){var o=$$('Sd_Dc');var m=',';for(var i=0;i<o.length;i++){if(o[i].checked)m+=o[i].value+',';}var o=$$('Sd_Da');var n='0';for(var i=0;i<o.length;i++){if(o[i].checked)n+=','+o[i].value;}var p=jsn('sdv');p.ID=Sd_ID.value;p.Dn=Sd_Dn.value==''?'未命名':Sd_Dn.value;p.Dc=m==','?(','+Sb[0].ID+','):m;p.Ds=Sd_Ds.value;p.Di=Sd_Di.src;p.Dm=Sd_Dm.value*100;p.Dr=Sd_Dr.value;p.Dk=Sd_Dk.value;p.Dt=Sd_Dt.value;p.Dv=Sd_Dv.value;p.Da=n;p.Db=Sd_Db.value;p.D1=Sd_D1.value*100;p.D2=Sd_D2.value*100;p.Dh=Sd_Dt.checked?1:0;xml(uri,p,function(r){fio('Fd',-1,1);cfg(2);if(Sd_Di.src.substr(0,23)=='data:image/jpeg;base64,')pid=rnd();});}
function sdd(){if(Sd_ID.value*1==0)return;cfm('确认删除？',function(){var p=jsn('sdd');p.ID=Sd_ID.value;xml(uri,p,function(r){fio('Fd',-1,1);cfg(2);});});}
//菜品套餐
function sdt(){var s='';for(var i=0;i<Sd.length;i++){if(Sd[i].Dt=='0'&&Sd[i].ID*1!=Sd_ID.value*1)s+='<span class="sk'+((Sd_Dt.value+',').indexOf(','+Sd[i].ID+',')>0?0:1)+'" onclick="sdc('+Sd[i].ID+');">'+Sd[i].Dn+'</span>';}Ld_e.innerHTML=s;fio('Fe',1);}
function sdc(n){var o=event.srcElement;var s=Sd_Dt.value+',';if(o.className=='sk1'){o.className='sk0';Sd_Dt.value=s+n;}else{o.className='sk1';s=s.replace(','+n+',',',');Sd_Dt.value=s.substr(0,s.length-1);}}
function sde(n){var t=Sd_Dt.value.split(',');var s='';for(var j=1;j<t.length;j++){for(var i=0;i<Sd.length;i++){if(Sd[i].ID*1==t[j]*1&&t[j]*1!=Sd_ID.value*1)s+=','+Sd[i].Dn;}}Sd_t.innerText=s.substr(1);if(!n)fio('Fe',-1);}
//菜品原料
function sdk(){var t=Sd_Db.value.split(',');var s='';for(var i=1;i<t.length;i++){t[i]=t[i].split('=');s+='<div class="sdk">'+sdm(t[i][0],i)+'　<input type="text" id="Sd_c'+i+'" size="3" value="'+t[i][1]+'" onblur="num();sdn();sdk();"> <a href="javascr'+'ipt:void(0);" onclick="Sd_c'+i+'.value=0;sdn();sdk();">×</a></div>';}Ld_x.innerHTML=s;Sd_x.value=t.length;fio('Fx',1);}
function sdm(m,n){var s='<select id="Sd_s'+n+'" style="width:110px;">';for(var i=0;i<Sk.length;i++){s+='<option value="'+Sk[i].ID+'"'+(m==Sk[i].ID?' selected':'')+'>'+Sk[i].Kn+'</option>';}return s+'</select>';}
function sdn(n){var s='';for(var i=1;i<Sd_x.value*1;i++){if($('Sd_c'+i).value!='0')s+=','+$('Sd_s'+i).value+'='+$('Sd_c'+i).value;}Sd_Db.value=s;if(n)fio('Fx',-1);}
//库存设置
function shk(){var s='';var j='';for(var i=0;i<Sk.length;i++){if(Sk[i].Kc!=j){s+='<div class="skl">'+Sk[i].Kc+'</div>';j=Sk[i].Kc;}s+='<div class="sk'+(Sk[i].Ks*1<=Sk[i].Kw*1?0:1)+'" onclick="ski('+i+');"><div class="skr">'+Sk[i].Ku+'</div><div class="skr">'+Sk[i].Ks.replace(/(\d)(?=(?:\d{3})+$)/g,'$1,')+'</div>'+Sk[i].Kn+'</div>';}Lk.innerHTML=s;}
function ski(n){var s=n<0?{ID:0,Kn:'品名',Kc:'类别',Ku:'克',Ks:0,Kw:0}:Sk[n];for(var i in s)$('Sk_'+i).value=s[i];
fio('Fk',1,1);}
function skv(){var p=jsn('skv');p.ID=Sk_ID.value;p.Kn=Sk_Kn.value;p.Kc=Sk_Kc.value;p.Ku=Sk_Ku.value;p.Ks=Sk_Ks.value;p.Kw=Sk_Kw.value;xml(uri,p,function(r){fio('Fk',-1,1);cfg(3);});}
function skd(){if(Sk_ID.value*1==0)return;cfm('确认删除？',function(){var p=jsn('skd');p.ID=SK_ID.value;xml(uri,p,function(r){fio('Fk',-1,1);cfg(3);});});}
function skj(){Sk_m.style.display='block';Sk_n.style.display='none';Sk_v.style.display='';var s='<div>品名</div><div>单位</div><div>规格</div><div>数量</div><div>单价</div><div>小计</div>';for(var i=0;i<Sk.length;i++)s+='<div>'+Sk[i].Kn+'</div><div><input type="text" id="Sk_u'+i+'" value="斤"></div><div><input type="text" id="Sk_e'+i+'" value="500"> '+Sk[i].Ku+'</div><div><input type="text" id="Sk_q'+i+'" value="0" onblur="num();ske();"></div><div><input type="text" id="Sk_p'+i+'" value="0" onblur="num(2);ske();"></div><div id="Sk_t'+i+'">0</div>';Lkh.innerHTML=s;ske();fio('Fh',1,1);}
function ske(){var k=0;for(var i=0;i<Sk.length;i++){var j=Math.round($('Sk_q'+i).value*$('Sk_p'+i).value*100);$('Sk_t'+i).innerText=j/100;k+=j;}Sk_t.innerText=k/100;}
function skh(){ske();var t=[];var s='';var j=1;for(var i=0;i<Sk.length;i++){if($('Sk_q'+i).value*1!=0)t.push([Sk[i].ID,Sk[i].Kn,$('Sk_u'+i).value,$('Sk_e'+i).value,Sk[i].Ku,$('Sk_q'+i).value,$('Sk_p'+i).value]);}var p=jsn('skh');p.Sk=t;if(t.length==0)return;xml(uri,p,function(r){fio('Fh',-1,1);cfg(3);});}
function skr(){xml('images/'+nid+'/k.txt?'+rnd(),null,function(r){Sl=r.Sk;var s='';for(var i in Sl)s='<a href="javascript:void(0);" onclick="skt(\''+i+'\')">'+i+'</a>　'+s;Lkh.innerHTML='';Sk_n.innerHTML=s==''?'没有进货记录':s;Sk_n.style.display='block';Sk_m.style.display='none';Sk_v.style.display='none';fio('Fh',1,1);});}
function skt(n){var t=Sl[n];var c=0;var s='';for(var i=0;i<t.length;i++){var k=Math.round(t[i][5]*t[i][6]*100)/100;s+='<div>'+t[i][1]+'</div><div>'+t[i][2]+'</div><div>'+t[i][3]+t[i][4]+'</div><div>'+t[i][5]+'</div><div>'+t[i][6]+'</div><div>'+k+'</div>';c+=k*100;}Lkh.innerHTML='<div>品名</div><div>单位</div><div>规格</div><div>数量</div><div>单价</div><div>小计</div>'+s;Sk_t.innerText=c/100;}
//员工设置
function shf(){var s='';for(var i=0;i<Sf.length;i++)s+='<div class="sfl"><div class="sfi">'+Sf[i].ID+'</div><div class="sfi"><img src="images/icon.png" width="20" height="20" align="absmiddle"'+(Sf[i].Ak==''?(' style="filter:grayscale(100%);filter:gray;"'):'')+'> <a href="javascri'+'pt:void(0);" onclick="sfi('+i+');">'+Sf[i].An+'</a></div><div class="sfi">'+Sf[i].Au+'</div><div class="sfi">'+Sf[i].Ar+'</div><div class="sfi">'+(Sf[i].A1/100)+'</div><div class="sfi">'+(Sf[i].A0/100)+'</div><div class="sfi"><a href="javascr'+'ipt:void(0);" onclick="sfr('+Sf[i].ID+');">更新</a> | <a href="javascr'+'ipt:void(0);" onclick="sfe('+Sf[i].ID+');">结算</a></div></div>';Lf.innerHTML=s;}
function sfi(n){var s=n<0?{ID:0,An:'员工'+(Sf.length+1),Au:'u'+rnd(4,1),Ap:rnd(8),Aw:'',Am:'',Ar:'AB',Ad:''}:Sf[n];var c='';var d=['A','B','C','D','E','F','S'];for(var i=0;i<7;i++)c+=' <input type="checkbox" name="Sf_Ar" value="'+d[i]+'"'+(s.Ar.indexOf(d[i])>-1?' checked':'')+'> '+['点单','收银','厨师','内送','外送','前台','系统'][i];Sf_Ai.innerHTML=c;Sf_ID.value=s.ID;Sf_An.value=s.An;Sf_Au.value=s.Au;Sf_Ap.value=s.Ap;Sf_Am.value=s.Am;Sf_Aw.value=s.Aw;Sf_Ad.innerText=s.Ad;fio('Ff',1,1);}
function sfv(){var o=$$('Sf_Ar');var m='';for(var i=0;i<o.length;i++){if(o[i].checked)m+=o[i].value;}var n=Sf_Ap.value;if(m.indexOf('S')>-1&&!(!/[^0-9a-f]+/.test(n)&&n.length==32)){if(!(/[0-9]+/.test(n)&&/[a-z]+/.test(n)&&/[A-Z]+/.test(n)&&n.length>7)){alt('具有系统管理权限的用户密码必需包含大小写英文字母及数字且不少于8位！');return;}}var p=jsn('sfv');p.ID=Sf_ID.value;p.An=Sf_An.value;p.Au=Sf_Au.value;p.Aw=Sf_Aw.value,p.Ap=Sf_Ap.value;p.Am=Sf_Am.value;p.Ar=m;xml(uri,p,function(r){fio('Ff',-1,'Fw');cfg(4);});}
function sfd(){if(Sf_ID.value*1==0)return;cfm('确认删除？',function(){var p=jsn('sfd');p.ID=Sf_ID.value;xml(uri,p,function(r){fio('Ff',-1,'Fw');cfg(4);});});}
function sfx(n){cfm('确认将'+(n<0?'所有':'此')+'员工下线？',function(){var p=jsn('sfx');p.ID=n;xml(uri,p,function(r){fio('Ff',-1,'Fw');cfg(4);});});}
function sfw(){var r=rnd(8);fio('Fw',1);Sf_w.innerHTML='<img src="qrcode.php?u='+encodeURI(url)+'openid%2Ephp%3Fx%3Dr%26r%3D'+r+'" width="231" height="231"><br>微信扫描二维码获取OpenID';tid=setTimeout('sfb(\''+r+'\')',3000);}
function sfb(s){xml(url+'openid.php?x=c&r='+s,false,function(r){if(r.woi!=''){Sf_Aw.value=r.woi;alt('获取OpenID成功！');fio('Fw',-1);}else tid=setTimeout('sfb(\''+s+'\')',3000);});}
function sfr(n){var p=jsn('sfr');p.ID=n;xml(uri,p,function(r){alt('员工[ID:'+n+']提成数据已更新！');cfg(4);});}
function sfe(n){cfm('确认结算？',function(){var p=jsn('sfe');p.ID=n;xml(uri,p,function(r){alt('员工[ID:'+n+']提成结算已完成！');cfg(4);});});}
//折扣设置
function shz(){Sc_Z0.value=Sc.c[0][0];Sc_Z1.value=Sc.c[0][1];Sc_Z2.value=Sc.c[0][2];Sc_Z3.value=Sc.c[0][3];Sc_Z4.value=Sc.c[0][4];var s='';for(var i=1;i<Sc.c[1].length+1;i++){var t=Sc.c[1][i-1];s+='折扣'+i+'： <input type="text" id="Sc_Zm'+i+'" value="'+t[0]+'"> 满 <input type="text" id="Sc_Zn'+i+'" style="width:40px;" value="'+t[1]+'" onblur="num(2);"> 元 打/减 <input type="text" style="width:40px;" id="Sc_Zv'+i+'" value="'+t[2]+'" onblur="num(2);"> 折/元　[<a href="javascr'+'ipt:void(0);" onclick="cfm(\'确认删除？\',function(){Sc_Zm'+i+'.value=\'\';szv();});">删除</a>]<br>'}Lz.innerHTML='自定义折扣：<br>'+s;Sc_Zm0.value='';Sc_Zn0.value='';Sc_Zv0.value='';}
function szv(){var s=[[Sc_Z0.value*1,Sc_Z1.value*1,Sc_Z2.value*1,Sc_Z3.value*1,Sc_Z4.value*1],[]];for(var i=0;i<Sc.c[1].length+1;i++){if($('Sc_Zm'+i).value!=''&&$('Sc_Zn'+i).value!=''&&$('Sc_Zv'+i).value!='')s[1].push([$('Sc_Zm'+i).value,$('Sc_Zn'+i).value*1,$('Sc_Zv'+i).value*1]);}var p=jsn('scv');p.Sc=Sc;p.Sc.c=s;p.Sh=Sh;xml(uri,p,function(r){alt('折扣设置保存成功！');cfg(5);});}
//打印设置
function shp(){var o=spr();if(!o)alt('打印服务器参数设置错误或C-Lodop云打印服务未安装及启动。');Sc_p1.value=Sc.p[1];Sc_p2.value=Sc.p[2];Sc_p.innerHTML='前台打印机： '+spc('Sc_p3',Sc.p[3],1)+'<br>默认打印机： '+spc('Sc_p4',Sc.p[4],1);Sc_p0.value=Sc.p[0];for(var i=5;i<16;i++)$('Sc_p'+i).value=Sc.p[i];Sc_p16.checked=Sc.p[16]*1==1?true:false;}
function spv(){var s=[];for(var i=0;i<16;i++)s[i]=$('Sc_p'+i).value;s[16]=Sc_p16.checked?1:0;var p=jsn('scv');p.Sc=Sc;p.Sc.p=s;p.Sh=Sh;xml(uri,p,function(r){alt('打印设置保存成功！');cfg(6);});}
function spe(){var p=jsn('spe');p.Dv=Sc_p4.value;xml(uri,p,function(r){alt('设置默认打印机成功！');});}
function spr(){var o;try{o=getCLodop();}catch(e){return false;};o.SET_LICENSES(Sc.p[1],Sc.p[2],'','');return o;}
function spc(m,n,d){var s='<select id="'+m+'">';if(d)s+='<option value="0">系统默认打印机</option>';var o=spr();if(!o){return s+'</select>';}for(var i=0;i<o.GET_PRINTER_COUNT();i++)s+='<option value="'+o.GET_PRINTER_NAME(i)+'"'+(o.GET_PRINTER_NAME(i)==n?' selected':'')+'>'+o.GET_PRINTER_NAME(i)+'</option>';s+='</select>';return s;}
function spt(m,n,w){var o=spr();if(!o){alt('打印服务器参数设置错误或C-Lodop云打印服务未安装及启动。');return;}var s=[];for(var i=5;i<16;i++)s[i]=$('Sc_p'+i).value;s[16]=Sc_p16.checked?1:0;o.PRINT_INIT('Print:'+sid);o.SET_PRINTER_INDEX($(n).value);o.SET_PRINT_PAGESIZE(3,$(w).value*10,0,'CreateCustomPage');o.ADD_PRINT_HTM(0,0,0,500,'URL:output.php?x='+m+'&n='+nid+'&u='+uid+'&s='+vid+'&a='+encodeURI(s.join('|')))+'&'+rnd(6);o.PREVIEW();}
</script>
</head>
<body onLoad="rsz();cfg(0);">
<div id="msk"></div><div id="tip"></div><div id="cfn"></div>
<div style="height:60px;background-color:#333;">
  <div style="float:left;margin:6px;"><img src="images/icon.png" align="absmiddle" width="48" height="48"></div>
  <div style="float:left;font-size:24px;color:#6CF;line-height:60px;" id="Sn"></div>
  <div style="float:right;margin:18px 20px 0px 0px;color:#000;background-color:#FFF;border:2px solid #CCC;width:48px;line-height:24px;text-align:center;display:inline-block;font-weight:bold;cursor:pointer;" onClick="cfm('确认关闭？',function(){window.close();});">关闭</div>
</div>
<div id="Dn" style="float:left;width:149px;border-right:1px solid #CCC;">
  <div id="Dn0" class="dn1" onClick="nav(0);">基本设置</div>
  <div id="Dn1" class="dn0" onClick="nav(1);">餐桌设置</div>
  <div id="Dn2" class="dn0" onClick="nav(2);">菜品设置</div>
  <div id="Dn3" class="dn0" onClick="nav(3);">库存设置</div>
  <div id="Dn4" class="dn0" onClick="nav(4);">员工设置</div>
  <div id="Dn5" class="dn0" onClick="nav(5);">折扣设置</div>
  <div id="Dn6" class="dn0" onClick="nav(6);">打印设置</div>
  <div class="dn0" onClick="window.open('output.php?x=ewm&n='+nid+'&u='+uid+'&s='+vid);">二维码</div>
</div>
<div id="Dm" style="float:right;padding:0px 10px;overflow:auto;">
  <div id="Dm0" class="dmb">
    <div class="dmt">基本设置</div>
    店铺ＩＤ： <span id="Sc_i"></span>　餐厅名称： <span id="Sc_n"></span><br>
    厨房接单模式： <select id="Sc_0"><option value="0">手机网络</option><option value="1">小票流转</option></select>　<span>手机网络模式厨师使用手机接单传菜，如不习惯，请选择传统小票流转模式。</span><br>
    自动接单打单： <select id="Sc_1"><option value="0">自动打单</option><option value="1">手动打单</option></select>　<span>开启后不经服务员确认即自动接收点单并打印小票，手动需服务员确认提交。</span><br>
    入座开台模式： <select id="Sc_2"><option value="0">人工开台</option><option value="1">自动开台</option></select>　<span>顾客扫码后是否进入点餐，自动模式直接进入，人工模式需服务员确认开台。</span><br>
    外卖接单时间： <input type="text" size="6" id="Sc_3"> <span>如：填写7-21表示从早7点至晚9点，临时不接单填写24-0</span>　超过 <input type="text" id="Sc_4" size="3" onBlur="num(3);"> 公里不接单<br>
    外卖送餐费用： 首 <input type="text" style="width:30px;" id="Sc_5" onBlur="num(3);"> 公里 <input type="text" style="width:30px;" id="Sc_6" onBlur="num(2);"> 元　每公里 <input type="text" style="width:30px;" id="Sc_7" onBlur="num(2);"> 元　订单满 <input type="text" style="width:30px;" id="Sc_8" onBlur="num(2);"> 元送餐　满 <input type="text" style="width:30px;" id="Sc_9" onBlur="num(2);"> 元免送餐费<br>
    排队叫号语音： <input type="text" id="Sc_10" size="50" placeholder="如：请{{id}}号顾客到餐厅就餐"> 需包含{{id}}标记<br>
    取餐叫号语音： <input type="text" id="Sc_11" size="50" placeholder="如：请{{id}}号顾客到前台取餐"> 需包含{{id}}标记<br>
    收款成功语音： <input type="text" id="Sc_12" size="50" placeholder="如：收款成功，金额：{{id}}元"> 需包含{{id}}标记<br>
    厨房通知语音： <input type="text" id="Sc_13" size="50" placeholder="如：来新单了，{{i1}}{{i2}}份"> 需包含{{i1}},{{i2}}标记<br>
    外卖通知语音： <input type="text" id="Sc_14" size="50" placeholder="如：来新单了，送至{{i1}}，运费{{i2}}元"> 需包含{{i1}},{{i2}}标记<br>
    宣传语跑马灯： <input type="text"  id="Sc_15"size="50" placeholder="如：<a href=&quot;http://www.abc.com/ad.htm&quot;>广告语</a>"> <a href="javascript:void(0);" onClick="tp2.style.display=tp2.style.display=='none'?'block':'none';">？</a><br>
    宣传图弹屏图： <input type="text" size="50" id="Sc_16" placeholder="如：<img on src=&quot;images/ad.gif&quot;>"> 图片大小320*480<br><span id="tp2" style="display:none;">跑马灯可使用纯文字或HTML语法，点击后转向其他网页写法：&lt;a href="http://www.abc.com/ad.htm"&gt;广告语&lt;/a&gt;<br>点击后显示弹屏图写法：&lt;a href="#" onclick="AD.style.display='block';"&gt;广告语&lt;/a&gt;<br>弹屏图请使用HTML语法，点击后关闭写法：&lt;img src="images/ad.gif" onclick="AD.style.display='none';"&gt;<br>点击后转向其他网页写法：&lt;img src="images/ad.gif" onclick="location.href='http://www.abc.com/ad.htm';"&gt;<br>HTML中添加 on 标记则进入后自动弹出弹屏图，如：&lt;img on src=...&gt;不添加 on 标记则不会自动弹出。<br></span>
    <input type="checkbox" id="Sc_h"> 暂停歇业　 <span class="btn" onClick="scv();">保　存</span>
  </div>
  <div id="Dm1" class="dmb">
    <div class="dmt">餐桌设置　　<span class="btn" onClick="sti(-1);">增加餐桌</span></div>
    <div id="Lt"></div>
  </div>
  <div id="Dm2" class="dmb">
    <div class="dmt">菜品设置　　<span class="btn" onClick="sbi(0);">增加类别</span>　<span class="btn" onClick="sdi(-1);">增加菜品</span>　<span style="font-size:12px;">双击类别进行编辑 [<a href="javascript:void(0);" onClick="sbf();">修复类别</a>]</span></div>
    <div id="Lb_0" style="float:left;width:150px;"></div>
    <div id="Ld" style="float:left;"></div>
  </div>
  <div id="Dm3" class="dmb">
    <div class="dmt">库存设置　　<span class="btn" onClick="ski(-1);">增加品种</span>　<span class="btn" onClick="skj();">库存进货</span>　<span class="btn" onClick="skr();">进货记录</span></div>
    <div id="Lk"></div>
  </div>
  <div id="Dm4" class="dmb">
    <div class="dmt">员工设置　　<span class="btn" onClick="sfi(-1);">增加员工</span>　<span style="font-size:12px;">[<a href="javascript:void(0);" onClick="sfx(-1);">强制所有员工下线</a>]　权限：A=点单，B=收银，C=厨师，D=内送，E=外送，F=前台，S=系统。计算员工提成请点更新，点结算将提成金额归零。</span></div>
    <div class="sfl"><div class="sfi">ID</div><div class="sfi">用户名</div><div class="sfi">名称</div><div class="sfi">权限</div><div class="sfi">提成已结</div><div class="sfi">提成未结</div><div class="sfi">提成操作</div></div>
    <div id="Lf"></div>
  </div>
  <div id="Dm5" class="dmb">
    <div class="dmt">折扣设置</div>
    固定折扣：固定折扣在结账时根据选择的付款方式自动使用。<br>
    现金 <input type="text" style="width:40px;" id="Sc_Z0" onBlur="num(2);">　刷卡 <input type="text" style="width:40px;" id="Sc_Z1" onBlur="num(2);">　微信 <input type="text" style="width:40px;" id="Sc_Z2" onBlur="num(2);">　支付宝 <input type="text" style="width:40px;" id="Sc_Z3" onBlur="num(2);">　会员卡 <input type="text" style="width:40px;" id="Sc_Z4" onBlur="num(2);"><br>&nbsp;
    <div id="Lz"></div>
    折扣+： <input type="text" id="Sc_Zm0"> 满 <input type="text" style="width:40px;" id="Sc_Zn0" onBlur="num(2);"> 元 打/减 <input type="text" style="width:40px;" id="Sc_Zv0" onBlur="num(2);"> 折/元<br>说明：后面折扣率大于1为满减模式，小于1为折扣模式。<br>例如：满百减五分别填写100和5，限时九折则填写1和0.9。<br>应用自定义折扣只能由服务员发起，自助结账无法应用自定义折扣。<br>　　　　 <span class="btn" onClick="szv();">保　存</span>
  </div>
  <div id="Dm6" class="dmb">
    <div class="dmt">打印设置</div>
    本系统使用第三方Lodop打印控件，请下载安装<a href="http://lodop.net/download.html" target="_blank" style="font-size:12px;">C-Lodop（扩展版）</a>，及<a href="http://www.c-lodop.com/Lodop_Lic.html" target="_blank">注册</a>。<br>
    打印服务器： <input type="text" id="Sc_p0" size="44" placeholder="如：http://192.168.0.222:8000/" onBlur="if(!spr()){Sc.p[0]=this.value;var o=document.createElement('script');o.src=Sc.p[0]+'CLodopfuncs.js';document.body.appendChild(o);setTimeout('shp()',300);}"><br>公司注册名： <input type="text" id="Sc_p1" size="16" placeholder="可选注册">　注册码： <input type="text" id="Sc_p2" size="16" placeholder="可选注册"><br><span id="Sc_p"></span><span><br>　　　　　　 [<a href="javascript:void(0);" onClick="spe();">设置所有菜品使用默认打印机</a>]</span><br>
    <strong>顾客小票</strong>　<span class="bn1" onClick="spt('sp1','Sc_p3','Sc_p5');">测试</span><br>纸张宽度： <input type="text" size="2" id="Sc_p5" onBlur="num();"> mm　字体大小： <input type="text" size="2" id="Sc_p6" onBlur="num();"> px　行间距： <input type="text" size="2" id="Sc_p7" onBlur="num();"> px<br>顶部文字： <input type="text" id="Sc_p8" size="32"> 大小： <input type="text" size="2" id="Sc_p9" onBlur="num();"> px<br>底部文字： <input type="text" id="Sc_p10" size="32"> 大小： <input type="text" size="2" id="Sc_p11" onBlur="num();"> px<br>底部图片： <input type="checkbox" id="Sc_p16"> 打印外卖点餐二维码<br>
    <strong>厨房小票</strong>　<span class="bn1" onClick="spt('sp2','Sc_p4','Sc_p12');">测试</span><br>纸张宽度： <input type="text" size="2" id="Sc_p12" onBlur="num();"> mm　字体大小： <input type="text" size="2" id="Sc_p13" onBlur="num();"> px　行间距： <input type="text" size="2" id="Sc_p14" onBlur="num();"> px<br>菜名大小： <input type="text" size="2" id="Sc_p15" onBlur="num();"> px<br>　　　　　 <span class="btn" onClick="spv();">保　存</span>
  </div>
</div>

<div id="Ft" class="fld" style="z-index:11;">
  <div class="flt"><div class="bnc" onClick="fio('Ft',-1,1);">×</div>餐桌设置<input type="hidden" id="St_ID"></div>
  <div class="flb">名称： <input type="text" id="St_Tn"><br>排序： <input type="text" id="St_Tr" size="3" onBlur="num();">　座位数： <input type="text" id="St_Tc" size="3" onBlur="num();"></div>
  <div class="flk"><span class="bn0" onClick="std();">删　除</span>　<span class="bn1" onClick="stv();">保　存</span></div>
</div>
<div id="Fb" class="fld" style="z-index:12;">
  <div class="flt"><div class="bnc" onClick="fio('Fb',-1,1);">×</div>菜类设置<input type="hidden" id="Sb_ID"></div>
  <div class="flb">分类名称： <input type="text" id="Sb_Bn"><br>分类排序： <input type="text" size="3" id="Sb_Br" onBlur="num();">　<input type="checkbox" id="Sb_Bh"> 隐藏<br>所属父类： <span id="Sb_Bs"></span></div>
  <div class="flk"><span class="bn0" onClick="sbd();">删　除</span>　<span class="bn1" onClick="sbv();">保　存</span></div>
</div>
<div id="Fd" class="fld" style="z-index:13;width:720px;height:428px;">
  <div class="flt"><div class="bnc" onClick="fio('Fd',-1,1);">×</div>菜品设置<input type="hidden" id="Sd_ID"><input type="hidden" id="Sd_Dt"><input type="hidden" id="Sd_Da"><input type="hidden" id="Sd_Db"></div>
  <div class="flb" style="height:328px;overflow:auto;">菜品名称： <input type="text" style="width:240px;" id="Sd_Dn" title="菜名应不超过8个字符，否则可能导致页面布局错乱">　售价： <input type="text" id="Sd_Dm" style="width:60px;" onBlur="num(2);"> 元　提成： <input type="text" id="Sd_D1" style="width:24px;" onBlur="num(2);" title="服务员提成金额"> <input type="text" id="Sd_D2" style="width:24px;" onBlur="num(2);" title="厨师提成金额"> 元　<br>所属分类： <span id="Sd_c" style="font-size:12px;"></span><br>菜品描述： <input type="text" id="Sd_Ds" style="width:540px;"><br>菜品口味： <input type="text" id="Sd_Dk" style="width:240px;"> <span style="font-size:12px;">如“不辣,微辣,麻辣”或“常温,加冰”等，半角“,”分隔</span><br><a href="javascript:void(0);" onClick="sdt();">菜品套餐</a>： <span id="Sd_t" style="font-size:12px;"></span><br>菜品图片： <img id="Sd_Di" src="images/none.png" width="90" height="60" align="absmiddle"> [<a href="javascript:void(0);" onClick="Sd_u.click();">上传</a>]　　　　<input type="checkbox" id="Sd_Dh"> 隐藏　排序： <input type="text" style="width:30px;" id="Sd_Dr" onBlur="num();">　[<a href="javascript:void(0);" onClick="sdk();">原料消耗设置</a>]<br>接单厨师： <span id="Sd_a"></span><br>厨房打单： <span id="Sd_v"></span></div>
  <div class="flk"><span class="bn0" onClick="sdd();">删　除</span>　<span class="bn1" onClick="sdv();">保　存</span></div></div>
  <div id="Fd_u" style="display:none;"><input type="file" id="Sd_u" onChange="sdu();"></div>
</div>
<div id="Fe" class="fld" style="z-index:14;width:720px;height:428px;">
  <div class="flt"><div class="bnc" onClick="fio('Fe',-1);">×</div>菜品套餐设置</div>
  <div class="flb" style="height:328px;overflow:auto;" id="Ld_e"></div>
  <div class="flk"><span class="bn0" onClick="Sd_Dt.value='0';sde();">清　空</span>　<span class="bn1" onClick="sde();">确　定</span></div>
</div>
<div id="Fx" class="fld" style="z-index:15;width:720px;height:428px;">
  <div class="flt"><div class="bnc" onClick="fio('Fx',-1);">×</div>库存消耗设置<input type="hidden" id="Sd_x"></div>
  <div class="flb" style="height:328px;overflow:auto;" id="Ld_x"></div>
  <div class="flk"><span class="bn1" onClick="sdn();Sd_Db.value+=',=0';sdk();">添　加</span>　<span class="bn1" onClick="sdn(1);">确　定</span></div>
</div>
<div id="Fk" class="fld" style="z-index:16;">
  <div class="flt"><div class="bnc" onClick="fio('Fk',-1,1);">×</div>库存设置<input type="hidden" id="Sk_ID"></div>
  <div class="flb">品　名： <input type="text" style="width:160px;" id="Sk_Kn">　类别： <input type="text" style="width:60px;" id="Sk_Kc"><br>单　位： <input type="text" style="width:40px;" id="Sk_Ku"> <span style="font-size:12px;">库存数量强制整数，请用小的单位如：克、毫升等</span><br>当前库存量： <input type="text" style="width:80px;" id="Sk_Ks" onBlur="num();">　预警库存值： <input type="text" style="width:80px;" id="Sk_Kw" onBlur="num();"></div>
  <div class="flk"><span class="bn0" onClick="skd();">删　除</span>　<span class="bn1" onClick="skv();">保　存</span></div>
</div>
<div id="Fh" class="fld" style="z-index:17;">
  <div class="flt"><div class="bnc" onClick="fio('Fh',-1,1);">×</div>库存进货</div>
  <div id="Lkh" class="flb" style="width:680px;height:450px;overflow:auto;"></div>
  <div id="Sk_m" style="font-size:12px;height:54px;padding:0px 10px;line-height:18px;">示例：大米进货单位为袋，每袋10kg，则单位填写袋，规格填写10000克，数量为5袋，单价为每袋50元；<br>　　　猪肉进货单位为斤，每斤为500克，则单位填写斤，规格填写500克，数量10斤，每斤8元；<br>　　　某调料进货单位为克，则单位填写克，规格填写1克，进货数量20克，每克12元。</div>
  <div id="Sk_n" style="font-size:12px;height:54px;width:680px;overflow:auto;padding:0px 10px;display:none;"></div>
  <div class="flk">合计： <span id="Sk_t"></span> 元　<span id="Sk_v"><span class="btn" onClick="skh();">保　存</span></span></div>
</div>
<div id="Ff" class="fld" style="z-index:18;">
  <div class="flt"><div class="bnc" onClick="fio('Ff',-1,'Fw');clearTimeout(tid);">×</div>员工设置<input type="hidden" id="Sf_ID"></div>
  <div class="flb">员工姓名： <input type="text" id="Sf_An">　手机： <input type="text" id="Sf_Am"><br>登录名称： <input type="text" id="Sf_Au">　密码： <input type="text" id="Sf_Ap"> <a href="javascript:void(0);" onClick="Sf_Ap.value=rnd(8);">随机</a><br><a href="javascript:void(0);" onClick="sfw();">绑定微信</a>： <input type="text" id="Sf_Aw">　登录： <span id="Sf_Ad"></span> [<a href="javascript:void(0);" onClick="sfx(Sf_ID.value);">下线</a>]<br>员工权限：<span id="Sf_Ai"></span></div>
  <div class="flk"><span class="bn0" onClick="sfd();">删　除</span>　<span class="bn1" onClick="sfv();">保　存</span></div>
</div>
<div id="Fw" class="fld" style="z-index:19;">
  <div class="flt"><div class="bnc" onClick="fio('Fw',-1);clearTimeout(tid);">×</div>员工绑定微信</div>
  <div class="flb" style="text-align:center;" id="Sf_w"></div>
</div>
</body>
</html>
<?php
}
?>