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

    File:           cad_thema_select.asp
    Description:    Kies een thema voor een plattegrond (ruimte/object, actueel, niet draggable)
    Parameters      verdieping_key, default de evt huidige verdieping
                    optioneel thema_key of themai_key (dan skipt deze direct door naar plattegrond)

    Note:           We kiezen hier puur alleen het thema in thema_key of themai_key.
                    Daarna gaan we naar plattegrond.asp

*/ %>

<% REGISTERMENU_Disable = true; %>
<!-- #include file="../Shared/common.inc" -->
<!-- #include file="./resultset_table.inc" -->
<!-- #include file="./mobile.inc" -->
<!-- #include file="./iface.inc" -->
<%
var qrc = getQParamInt("qrc", 0) != 0;
var verdieping_key = getQParamInt("verdieping_key", user.alg_verdieping_key({withcurrent:true}));  // transitonly
var thema_key = getQParamInt("thema_key", -1);
var themai_key = getQParamInt("themai_key", -1);

var transitParam = buildTransitParam(["verdieping_key", "ruimte_key"] );

if (thema_key > -1 || themai_key > -1)  // Dan hebben we al een thema en valt hier niks toe te voegen
{
    Server.Transfer("plattegrond.asp");
}

var scenario_key=0;
%>
<html>
  <head>
<% FCLTMHeader.Generate({title:  L("lcl_fg_thema") }); %>
 </head>
 <body>
<%
  var header_title = L("lcl_fg_thema") ;

  PAGE_START({id: "page-1-"+verdieping_key});
  HEADER({title: header_title, back:!qrc, home: !qrc });
  CONTENT_START();

  function fncolLink(oRs)
  {
      var nurl = "plattegrond.asp?"+ (oRs("cad_thema_key").Value  ? "thema_key="  + oRs("cad_thema_key").Value  : "")
                                   + (oRs("cad_themai_key").Value ? "themai_key=" + oRs("cad_themai_key").Value : "")
                                   + transitParam;
      return nurl;
  };

  if (thema_key < 0)
  {
      sql = "SELECT 1, CAD_THEMA_KEY, NULL CAD_THEMAI_KEY, fac_functie_key, "
           + (S("fg_ins_symbols") ? safe.quoted_sql(L("lcl_room"))+"||'-'||" : "") + lcl.xsqla('cad_thema_omschrijving', 'cad_thema_key')
           + "  FROM CAD_THEMA "
           + " WHERE BITAND(CAD_THEMA_TYPE, 1) = 1" // binnen
           + " AND BITAND(CAD_THEMA_TYPE, 4) = 0"    // actueel, niet project
           + " AND BITAND(CAD_THEMA_TYPE, 24) = 0"   // ruimtes
           + " AND BITAND(CAD_THEMA_TYPE, 128) = 0";  // de draggables maar niet

       if (S("fg_ins_symbols"))
       {
          sql += " UNION ALL "
                + "SELECT 2, NULL, CAD_THEMA_KEY CAD_THEMAI_KEY, fac_functie_key, "
                + safe.quoted_sql(L("lcl_shared_object"))+"||'-'||" + lcl.xsqla('cad_thema_omschrijving', 'cad_thema_key')
                + "  FROM CAD_THEMA "
                + " WHERE BITAND(CAD_THEMA_TYPE, 1) = 1" // binnen
                + " AND BITAND(CAD_THEMA_TYPE, 4) = 0"    // actueel, niet project
                + " AND BITAND(CAD_THEMA_TYPE, 24) = 16"  // symbolen
                + " AND BITAND(CAD_THEMA_TYPE, 128) = 0"  // de draggables maar niet
       }
       sql += " AND (FAC_FUNCTIE_KEY IS NULL"
            + "     OR FAC_FUNCTIE_KEY IN "
            + "                (SELECT FAC_FUNCTIE_KEY FROM fac_v_webgebruiker"
            + "                  WHERE prs_perslid_key = " + user_key + "))";
       sql += " ORDER BY 1,5";


      var rst = new ResultsetTable({ sql: sql
                                   , keyColumn: "CAD_THEMA_KEY"
                                   , linkColumn: fncolLink
                                   , headerColumn: "cad_thema_omschrijving"
                                   , ID: "thematable"
                                   , showAll: true
                                   , noSearch: true
                                   , emptySetString: L("lcl_empty")
                                   });
      var cnt = rst.processResultset();
  }

  CONTENT_END();
  FOOTER();
  PAGE_END();
PDA_PAGE_END(); %>
	</body>
</html>
<% ASPPAGE_END(); %>
