<%@language = "javascript" %>
<% /*

     $Revision$
     $Id$

     File:               fac_setenv.asp
     Description:        Sets the configuration to one of ATAP
     Parameters:         env = O|T|A|P
     Globals:            --
     Result:             Environment set, confirmed to screen
     Context:            Direct by URL
     Note:               Requires WEB_FACTAB authorization
*/ %>

<!-- #include file="../Shared/common.inc" -->

<%
var autfunction = "WEB_FACTAB";
var authparams = user.checkAutorisation(autfunction);
%>
<html>
  <head>
<%  FCLTHeader.Generate() %>
  </head>
  <body>
<%  newenv = getQParamSafe('env', 'X');
    if (newenv != 'O' && newenv != 'T' && newenv != 'A' && newenv != 'P')
      newenv = 'X';

    oRs = Oracle.Execute("SELECT COALESCE(fac_version_otap, 'not set') FROM fac_version");
    oldenv = oRs(0).value;

    if (newenv != 'X')
    {
      oRs = Oracle.Execute("UPDATE fac_version SET fac_version_otap = " + safe.quoted_sql(newenv));
%>    <script type="text/javascript">
        FcltMgr.alert("Facilitor environment set to <%=newenv%> (was <%=safe.jsstring(oldenv)%>)");
      </script>
<%  }
    else
    { %>
      <script type="text/javascript">
        FcltMgr.alert("Facilitor environment is <%=safe.jsstring(oldenv)%>");
      </script>
<%  } %>
  </body>
</html>
<% ASPPAGE_END(); %>
