<%@ page contentType="text/html;charset=gb2312" %>
<%@ page import="com.gx.webpage.framework.util.inoutformat.DataBean" %>
<%@ page import="com.gx.webpage.engine.pagedesigndbengine.factory.PageDesignDbEngineFactory"%>
<%@ page import="com.gx.webpage.engine.pagedesigndbengine.valueobject.*"%>
<%
    boolean isSave = false;
    boolean isError = false;
    String infStr = "";
    String uuid = DataBean.getStr(request, "uuid");
    String type = DataBean.getStr(request, "type");
    FormsModel fm = null;
    try{
        fm = PageDesignDbEngineFactory.getInstance().getPageDbEngineApi().findForms(uuid,request);
        if(request.getMethod().equalsIgnoreCase("POST")){
            boolean needDb = false;
					  if(type.equals("1")){
							needDb = true;
            }
            isSave = true;
            int intPublish = DataBean.getInt(request, "publish");
            if(intPublish==FormsModel.STATUS_PUBLISHED){
                isError = !PageDesignDbEngineFactory.getInstance().getPageDbEngineApi().publishForm(fm.getTblId(),needDb,request);
                if(!isError)
                {
                    infStr = "发布成功.";
                }
            }else{
                isError = !PageDesignDbEngineFactory.getInstance().getPageDbEngineApi().unPublishForm(fm.getTblId(),needDb,request);
                if(!isError)
                {
                    infStr = "取消发布成功.";
                }
            }
					}else if(type.equals("2")){
					}
    }catch(Exception err){
        isError = true;
        infStr = DataBean.getErrStr(err);
    }
%>
<head>
    <meta http-equiv="Content-Language" content="zh-cn">
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="./../../webpage/common/css/common.css" rel="StyleSheet"  type="text/css" />
<script language="javascript" src="./../../webpage/common/engine/constant.js"></script>
<script language="javascript">
<!--
    function btn_toList(){
        window.navigate("formsList.jsp");
    }
    function btn_publish()
    {
        formsAdd.submit();
    }
    function btn_back()
    {
        window.history.back();
    }
//-->
</script>
    <title>发布/取消发布业务对象</title>
</head>
<body class="main">
<div align="center">
<h3 align="center">发布/取消发布业务对象</h3>
<%if(!isError){
    if(isSave){
%>
    <p align=center><%=infStr%>．
    <p align=center>
    <input class="butAction" type="button" name="toList" value=" 返回业务对象列表 " onclick="btn_toList();">
<%}else{%>
<form id="formsAdd" name="formsAdd" method="POST">
<table class="content">
    <tr>
        <td width=30%>业务对象名称</td><td><%=DataBean.getStr(fm.getTblName())%>&nbsp;</td>
    </tr>
    <tr>
        <td>存储名称</td><td><%=DataBean.getStr(fm.getTblId())%>&nbsp;</td>
    </tr>
    <tr>
        <td>检测表数据权限</td>
        <td><%= fm.getTableAclCap()%></td>
    </tr>
    <tr>
        <td>发布状态</td><td><%=fm.getPublishCap()%></td>
    </tr>
    <tr>
        <td>业务对象描述</td><td><%=DataBean.getStr(fm.getDescription())%>&nbsp;</td>
    </tr>
</table>
<table class="buttable2">
<tr>
<%
    if(fm.getStatus() == FormsModel.STATUS_PUBLISHED){
%>
    <input type="hidden" name="publish" value=<%=FormsModel.STATUS_TEST%>>
    <td width=50% align=center><input class="butAction" type="button" name="add" value="取消发布" onclick="btn_publish();">
<%
    }else{
%>
    <input type="hidden" name="publish" value=<%=FormsModel.STATUS_PUBLISHED%>>
    <td width=50% align=center><input class="butAction" type="button" name="add" value="发　　布" onclick="btn_publish();">
<%
    }
%>
    <td width=50% align=center><input class="butAction" type="button" name="toList" value="返回业务对象列表" onclick="btn_toList();">
</tr>
</table>
</form>
<%}}else{%>
<p align=center>发布/取消发布失败．
<p align=center><%= infStr%>
<table class="buttable2">
<tr>
    <td width=50% align=center><input class="butAction" type="button" name="add" value="后　　退" onclick="btn_back();">
    <td width=50% align=center><input class="butAction" type="button" name="toList" value="返回业务对象列表" onclick="btn_toList();">
</tr>
</table>
<%}%>
</div>
</body>
</html>
