<!-- #include file="../conn.asp" -->
<!-- #include file="../const.asp" -->

<%call chksunzom()

if instr(quanxs,"x3t")<=0 then call sunzomqx()

chk=requestA("chk")
bbid=requestA("id")
bblx=chk0(requestA("bblx"))

mxid1=chk0(requestA("mxid1"))

ysshu=chk0(requestA("ysshu")):yfshu=chk0(requestA("yfshu"))
ssshu=chk0(requestA("ssshu")):sfshu=chk0(requestA("sfshu"))
for a=0 to ysshu-1
ysxxs=ysxxs&"[#]"&requestA("ysmx"&a+1&"")&"|"&replace(requestA("yszd"&a+1&"")," ","")
next

for b=0 to yfshu-1
yfxxs=yfxxs&"[#]"&requestA("yfmx"&b+1&"")&"|"&replace(requestA("yfzd"&b+1&"")," ","")
next

for c=0 to ssshu-1
ssxxs=ssxxs&"[#]"&requestA("ssmx"&c+1&"")&"|"&replace(requestA("sszd"&c+1&"")," ","")
next

for d=0 to sfshu-1
sfxxs=sfxxs&"[#]"&requestA("sfmx"&d+1&"")&"|"&replace(requestA("sfzd"&d+1&"")," ","")
next



if chk="addok" then

if bblx=1 then
'Response.Write (""&ysxxs&"<br>"&yfxxs&"<br>"&ssxxs&"<br>"&sfxxs&""):Response.end
sql="insert into SZ_bb(bblx,bbname,ysxx,yfxx,ssxx,sfxx) values("&bblx&",'"&requestA("bbname")&"','"&ysxxs&"','"&yfxxs&"','"&ssxxs&"','"&sfxxs&"')"
conn.execute(sql)
elseif bblx=2 then
'Response.Write ("mxid,bbname,bdxs,bbpx,bbpx,bbzt<br>"""&mxid1&",'"&requestA("bbname")&"','"&chk0(requestA("bdxs"))&"',"&chk0(requestA("bbpx"))&","&chk0(requestA("bbzt"))&""""):Response.end
bdxs=replace(requestA("bdxs")," ","")
sql="insert into SZ_bb(mxid,bbname,bdxs,bbpx,bbzt) values("&mxid1&",'"&requestA("bbname")&"','"&bdxs&"',"&chk0(requestA("bbpx"))&","&chk0(requestA("bbzt"))&")"
conn.execute(sql)
end if

Response.Write ("<Script> if (confirm('增加成功,继续添加吗?')) { location.href='bbgl.asp?chk=add&cdcla="&cdcla&"';} else{location.href='bb.asp';}</script>")
end if

if chk="editok" then
bdxs=replace(requestA("bdxs")," ","")
sql="update sz_bb set bbname='"&requestA("bbname")&"',bblx="&bblx&",ysxx='"&ysxxs&"',yfxx='"&yfxxs&"',ssxx='"&ssxxs&"',sfxx='"&sfxxs&"' where id="&bbid&""
conn.execute(sql)
Response.Write "<script language='javascript'>alert('修改成功!');window.location.href='bb.asp';</script>":Response.end
end if
if mxid1>0 and chk<>"edit" then chk="add"

if bblx=1 or bblx=0 then bbname="利润统计":bblx=1
if bblx=2 then bbname="单项报表"
%> 
<html>
<head>
<title><%=dianming%> - 报表管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../images/sunzom.css" rel="stylesheet" type="text/css">

<script language='JavaScript' src='../inc/jquery.js'></script>
<script type="text/javascript" src="/inc/ctoe.js"></script>
<script language="javascript">
function check()
{
if (document.form1.bbname.value==""||document.form1.bdxs.value=="")
{
alert("有*号的必须填写！");
return false;
}
}

function gbcount(message)
{
document.all("mxml").value = getPinyin(message);
document.all("mxdat").value = getPinyin(message);
}
</script>
</HEAD>
<BODY>
<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center">
  <tr> 
    <td><input onclick="location.href='bb.asp'" value="报表首页"  type=button name="moren" style="float: right">选择报表类型：<input onclick="location.href='?bblx=1'" value="利润统计"  type=button name="moren">&nbsp; <input onclick="location.href='?bblx=2'" value="单项报表"  type=button name="moren">
   </td>
  </tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#C4D8ED">
<tr>
<td><img src="../images/r_1.gif" alt="" /></td>
<td width="100%" background="../images/r_0.gif">
  <table cellpadding="0" cellspacing="0" width="100%">
    <tr>
      <td> &nbsp;添加[<%=bbname%>]报表属性</td>
	  <td align="right"></td>
    </tr>
  </table>
</td>
<td><img src="../images/r_2.gif" alt="" /></td>
</tr>
<tr>
<td></td>
<td>
<%
if chk="" or chk="edit" then
if chk="edit" then
sql="select * from sz_bb where id="&bbid&""  
set rs1 =server.createobject("ADODB.RecordSet")	
rs1.open sql,conn,1,3
if not rs1.eof then
bbname=rs1("bbname"):mxid1=rs1("mxid"):bbzt=rs1("bbzt"):bbpx=rs1("bbpx"):bdxs=rs1("bdxs")
end if
rs1.close:set rs1=nothing
chklx="editok"
else
chklx="addok"
bbzt=1
end if
end if
%>
<div align="center">
<table cellpadding="4" cellspacing="0" border="1" width="100%" bordercolor="#666666" bgcolor="#FFFFFF" style="border-collapse: collapse">
  <form method="POST" action="?chk=<%=chklx%>&bblx=<%=bblx%>&mxid1=<%=mxid1%>&id=<%=bbid%>" name="form1">
		<input type="hidden" name="photo" value="<%=deskphoto%>">
        <input type="hidden" name="hid1" value="ok">
		<tr>
    <td align="center" colspan="2">
    
	<input type="text" name="bbname" style="width:140;height:24; text-align:center" value="<%=bbname%>" size="30"></td>
  </tr>  

		<tr>
    <td align="right">
    
选择【应收<span lang="zh-cn">】数据模型</td>
    <td>选择【应付】数据模型</td>
  </tr>  

		<tr>
    <td align="right">
    
<%
sql="select * from sz_mx where mxname like '%应收%' order by id desc" 
set rsxiao =server.createobject("ADODB.RecordSet")	
rsxiao.open sql,conn,1,3
if not rsxiao.eof then
i=0
do while not rsxiao.eof
i=i+1
bids=chk0(rsxiao("bid")):mxids=rsxiao("id"):mxnames=rsxiao("xmname")
if bids>0 then gxname=cdatx("mxname","SZ_mx","where id="&bids&"")
Response.Write "<input type=""checkbox"" name=""ysmx"&i&""" value="""&mxids&"""><b>["&gxname&"]"&mxnames&"</b><br>"

sql="select * from SZ_zd where ChannelID="&mxids&" and ShowOnForm=1 order by OrderID desc,id asc"
set rsc2=conn.execute(sql)
if not rsc2.bof then
do while not rsc2.eof
id2=chk0(rsc2("id"))
bdTitle=rsc2("Title"):bdname=rsc2("FieldName")
Response.Write "<input type=""checkbox"" name=""yszd"&i&""" value="""&bdname&""""
if instr(bdTitle,"金额")>0 or  instr(bdTitle,"合计")>0 then Response.Write " checked "
Response.Write ">"&bdTitle&"&nbsp; "
rsc2.movenext
loop
end if
rsc2.close:set rsc2=nothing
Response.Write "<hr>"
rsxiao.movenext
loop
end if
rsxiao.close:set rsxiao=nothing

%>应收总额<input type="hidden" name="ysshu" value="<%=i%>">
</td>
    <td><%
sql="select * from sz_mx where mxname like '%应付%' order by id desc" 
set rsxiao =server.createobject("ADODB.RecordSet")	
rsxiao.open sql,conn,1,3
if not rsxiao.eof then
i1=0
do while not rsxiao.eof
i1=i1+1
bids=chk0(rsxiao("bid")):mxids=rsxiao("id"):mxnames=rsxiao("xmname")
if bids>0 then gxname=cdatx("mxname","SZ_mx","where id="&bids&"")
Response.Write "<input type=""checkbox"" name=""yfmx"&i1&""" value="""&mxids&"""><b>["&gxname&"]"&mxnames&"</b><br>"

sql="select * from SZ_zd where ChannelID="&mxids&" and ShowOnForm=1 order by OrderID desc,id asc"
set rsc2=conn.execute(sql)
if not rsc2.bof then
do while not rsc2.eof
id2=chk0(rsc2("id"))
bdTitle=rsc2("Title"):bdname=rsc2("FieldName")
Response.Write "<input type=""checkbox"" name=""yfzd"&i1&""" value="""&bdname&""""
if instr(bdTitle,"金额")>0 or  instr(bdTitle,"合计")>0 then Response.Write " checked "
Response.Write ">"&bdTitle&"&nbsp; "
rsc2.movenext
loop
end if
rsc2.close:set rsc2=nothing
Response.Write "<hr>"
rsxiao.movenext
loop
end if
rsxiao.close:set rsxiao=nothing

%>应付总额<input type="hidden" name="yfshu" value="<%=i1%>"></td>
  </tr>  

<tr>
    <td align="right">
    
<%
sql="select * from sz_mx where mxname like '%实收%' order by id desc" 
set rsxiao =server.createobject("ADODB.RecordSet")	
rsxiao.open sql,conn,1,3
if not rsxiao.eof then
i2=0
do while not rsxiao.eof
i2=i2+1
bids=chk0(rsxiao("bid")):mxids=rsxiao("id"):mxnames=rsxiao("xmname")
if bids>0 then gxname=cdatx("mxname","SZ_mx","where id="&bids&"")
Response.Write "<input type=""checkbox"" name=""ssmx"&i2&""" value="""&mxids&"""><b>["&gxname&"]"&mxnames&"</b><br>"

sql="select * from SZ_zd where ChannelID="&mxids&" and ShowOnForm=1 order by OrderID desc,id asc"
set rsc2=conn.execute(sql)
if not rsc2.bof then
do while not rsc2.eof
id2=chk0(rsc2("id"))
bdTitle=rsc2("Title"):bdname=rsc2("FieldName")
Response.Write "<input type=""checkbox"" name=""sszd"&i2&""" value="""&bdname&""""
if instr(bdTitle,"金额")>0 or instr(bdTitle,"合计")>0 then Response.Write " checked "
Response.Write ">"&bdTitle&"&nbsp; "
rsc2.movenext
loop
end if
rsc2.close:set rsc2=nothing
Response.Write "<hr>"
rsxiao.movenext
loop
end if
rsxiao.close:set rsxiao=nothing

%>实收总额<input type="hidden" name="ssshu" value="<%=i2%>">
</td>
    <td><%
sql="select * from sz_mx where mxname like '%实付%' order by id desc" 
set rsxiao =server.createobject("ADODB.RecordSet")	
rsxiao.open sql,conn,1,3
if not rsxiao.eof then
i3=0
do while not rsxiao.eof
i3=i3+1
bids=chk0(rsxiao("bid")):mxids=rsxiao("id"):mxnames=rsxiao("xmname")
if bids>0 then gxname=cdatx("mxname","SZ_mx","where id="&bids&"")
Response.Write "<input type=""checkbox"" name=""sfmx"&i3&""" value="""&mxids&"""><b>["&gxname&"]"&mxnames&"</b><br>"

sql="select * from SZ_zd where ChannelID="&mxids&" and ShowOnForm=1 order by OrderID desc,id asc"
set rsc2=conn.execute(sql)
if not rsc2.bof then
do while not rsc2.eof
id2=chk0(rsc2("id"))
bdTitle=rsc2("Title"):bdname=rsc2("FieldName")
Response.Write "<input type=""checkbox"" name=""sfzd"&i3&""" value="""&bdname&""""
if instr(bdTitle,"金额")>0 or instr(bdTitle,"合计")>0 then Response.Write " checked "
Response.Write ">"&bdTitle&"&nbsp; "
rsc2.movenext
loop
end if
rsc2.close:set rsc2=nothing
Response.Write "<hr>"
rsxiao.movenext
loop
end if
rsxiao.close:set rsxiao=nothing

%>实付总额<input type="hidden" name="sfshu" value="<%=i3%>"></td>
  </tr>

  <tr>
    <td align="center" colspan="2">营业利润=应收总额-应付总额；实际利润=实收总额-实付总额</td>
  </tr>
  <tr>
    <td colspan="2" align="center">
        <input name="submit" type="submit" value=" 确 认 " onClick="return check()"  class="button"></td>
  </tr>
</table></div>
</form>
</td>
<td></td>
</tr>
<tr>
<td><img src="../images/r_4.gif" alt="" /></td>
<td></td>
<td><img src="../images/r_3.gif" alt="" /></td>
</tr>
</table>
</body>
</html>