<%@language = "javascript" %>
<% /*
    $Revision$
    $Id$

    File:           appl/fac/about.asp
    Description:    Info about license, usercount etc.
    Parameters:
    Context:        Manual call
    Note:           WEB_PRSSYS authorization is required

*/
%>
<!--#include file="../Shared/common.inc"-->
<!--#include file="../Shared/iface.inc"-->
<%
var autfunction = "WEB_PRSSYS";
var authparams = user.checkAutorisation(autfunction);
%>
<html>
<head><%
FCLTHeader.Title(L("lcl_facilitor_appl")+" "+L("lcl_about"));
FCLTHeader.Generate(); %>
</head>
<body id="aboutbody">
<%
  var sql = "SELECT fac.getsetting ('licensed_fe_users'), fac.getsetting ('licensed_key_users') FROM DUAL";
  var oRs = Oracle.Execute(sql);
  var licensed_fe_users = oRs(0).Value||0;
  var licensed_key_users = oRs(1).Value||0;
  oRs.Close();

  sql = "SELECT COALESCE(fac_version_otap, 'P') otap, "
        + "       fac.getdbversion() dbversion,"
        + "       fac_version_cust, "
        + "       fac_version_schema "
        + "  FROM fac_version";
  oRs = Oracle.Execute(sql);
  var otap = oRs("otap").value;
  var dbversion = oRs("dbversion").value;
  var schemaversion = oRs("fac_version_schema").Value;
  var facilitorversion = FCLTVersion + "@" + dbversion;
  oRs.Close();

   sql = "SELECT tijdstip, "
           + "all_users,"
           + "fe_users,"
           + "key_users,"
           + "xdfe_users,"
           + "xdkey_users,"
           + "recent_login"
           + " FROM fac_v_lcrap_fe_vs_key";
    // yields only one record
    oRs = Oracle.Execute(sql);

    BLOCK_START("aboutInfo", L("lcl_facilitor_appl")+' '+facilitorversion+' '+oRs("tijdstip").value);

    // users
    ROFIELDTR("fld", L("lcl_key_users"), L("lcl_usrs_licensed")+": "+licensed_key_users+" \n"+ L("lcl_usrs_actual")+": "+ oRs("key_users").value
              + (oRs("key_users").value>licensed_key_users ? " \n"+L("lcl_keyactualexceedslicensed").format(oRs("key_users").value-licensed_key_users) : ""));
    ROFIELDTR("fld", L("lcl_fe_users"), L("lcl_usrs_licensed")+": "+licensed_fe_users+" \n"+ L("lcl_usrs_actual")+": "  + oRs("fe_users").value
              + (oRs("fe_users").value>licensed_fe_users ? " \n"+L("lcl_feactualexceedslicensed").format(oRs("fe_users").value-licensed_fe_users): ""));
    oRs.Close();

    // an approximation of the modules used.
    // UDR is a pseudosubmodule from FAC
    // FAQ is not a pseudosubmodule from FAC, but is formally enabled by a setting, as is Mobile
    sql = "SELECT m.fac_module_remark, fac_module_name, COUNT (fac_groep_key)"
       + "   FROM fac_groeprechten gr, fac_functie f, fac_module m"
       +  " WHERE gr.fac_functie_key = f.fac_functie_key"
       + "    AND (fac_gebruiker_alg_level_write < 9 OR fac_gebruiker_prs_level_write < 9)"
       + "    AND f.fac_functie_module = m.fac_module_name"
       + "    AND f.fac_functie_module NOT IN ('FAC', 'FAQ', 'UDR')"
       + "    AND NOT EXISTS"
       + "           (SELECT ''"
       + "              FROM fac_groeprechten gr1, fac_functie f1"
       + "             WHERE     gr1.fac_functie_key = f1.fac_functie_key"
       + "                   AND f1.fac_functie_code IN ('WEB_FACFAC', 'WEB_PRSSYS')"
       + "                   AND gr1.fac_groep_key = gr.fac_groep_key)"
       + "  GROUP BY fac_module_name, m.fac_module_remark"
       + " UNION"
       + " SELECT m.fac_module_remark, fac_module_name, 1"
       + "   FROM fac_module m"
       + "  WHERE fac.getsetting ('faq_enabled') = 1 AND m.fac_module_name = 'FAQ' "
       + " UNION"
       + " SELECT m.fac_module_remark, fac_module_name, 1"
       + "   FROM fac_module m"
       + "  WHERE fac.getsetting ('fac_usrrap_mode') = 1 AND m.fac_module_name = 'UDR' "
       + " UNION"
       + " SELECT m.fac_module_remark, fac_module_name, 1"
       + "   FROM fac_module m"
       + "  WHERE fac.getsetting ('mobile_enabled') = 1 AND m.fac_module_name = 'PDA' "
       + " ORDER BY 1";
    oRs = Oracle.Execute(sql);
    var i = 1;;
    while (!oRs.eof) {
        ROFIELDTR("fld", (i==1 ? L("lcl_modules_inuse") : ""),  i + ". " + L(oRs("fac_module_remark").value) + " [" + oRs("fac_module_name").value + "]");
        i += 1;
        oRs.moveNext();
    }

    oRs.Close();
    BLOCK_END();
%>
<p class="aboutfooter"><%=L("lcl_about_footer")%></p>

</body>
</html>