<%@ language="javascript"%>
<% /*
     $Revision$
     $Id$
*/%>
<!-- #include file="../Shared/common.inc"-->
<!-- #include file="../Shared/resultset_table_v2.inc" -->

<%
var outputmode = getQParamInt("outputmode", 0);
var showall = getQParamInt("showall", 0) == 1;

var sql = "";
var highlight_arr = getQParamIntArray("highlight", []); // Comma-separated room_key_list (terrains). Optional
var floorKey = getQParamInt("vKey", "");

if (floorKey != "")
{
  sql = " SELECT g.alg_terreinsector_key"
      + ", g.alg_locatie_key"
      + ", l.alg_locatie_omschrijving"
      + ", g.alg_terreinsector_naam"
      + ", g.alg_terreinsector_omschrijving"
      + ", g.alg_terreinsector_code"
      + ", g.alg_terreinsector_oppervlak"
      + ", g.alg_terreinsector_omtrek"
      + ", g.alg_srtterreinsector_key"
      + ", " + lcl.xsqla('s.alg_srtterreinsec_omschrijving', 's.alg_srtterreinsector_key')
      + ", '<'"
      + " FROM alg_v_aanwezigterreinsector g"
      + ", alg_locatie l"
      + ", alg_srtterreinsector s"
      + " WHERE l.alg_locatie_key(+) = g.alg_locatie_key"
      + " AND l.alg_locatie_key = "
      + " (SELECT g.alg_locatie_key"
      + " FROM alg_gebouw g"
      + ", alg_verdieping v"
      + " WHERE g.alg_gebouw_key = v.alg_gebouw_key"
      + " AND v.alg_verdieping_key = " + floorKey + ")"
      + " AND s.alg_srtterreinsector_key(+) = g.alg_srtterreinsector_key"
      + (highlight_arr.length > 0 && highlight_arr.join(",").indexOf("-1") == -1
        ? " AND g.alg_terreinsector_key IN (" + highlight_arr.join(",") + ") "
        : "")
      + " AND g.alg_terreinsector_verwijder IS NULL"
      + " ORDER BY g.alg_terreinsector_naam";
}
else
{
  sql = "SELECT * FROM DUAL WHERE 1 = 0";
}
%>
<html>
  <head>
<%  FCLTHeader.Generate(); %>
    <script type="text/javascript">
      function onClickRuimteAlternatief(room_key)
      {
        sl = parent.document.getElementById("rooms");
        if (sl.selectedIndex == -1 || sl.options[sl.selectedIndex].value != room_key)
        {
          for (i = 0; i < sl.length; i++)
            {
            if (sl.options[i].value == room_key)
            {
              sl.selectedIndex = i;
              parent.OnRoomChanged(sl);
            }
          }
        }
      }

      function onClickRuimte(room_key)
      {
        return; // Toch maar niet, ruimte.asp werkt niet helemaal goed buiten zijn context

        fwnd = window.open('../alg/ruimte.asp?mode=ReadOnly&Key='+room_key, 'FGShowRoom',
                "width=960,height=640,directories=no,location=no,menubar=no,"
                + "resizable=yes,status=no,titlebar=yes,toolbar=no");
        fwnd.focus();
      }
    </script>
</head>

<body class="tabpage">
<%
      var rst = new ResultsetTable({ keyColumn: "alg_terreinsector_key",
                                     sql: sql,
                                     ID: "workTable",
                                     title: L("lcl_fg_verhuizing"),
                                     outputmode: outputmode,
                                     showAll: showall
                                   });

      rst.addColumn(new Column({caption: L("lcl_estate_terreinsector_man_code"), content: "alg_terreinsector_naam"}));
      rst.addColumn(new Column({caption: L("lcl_estate_terreinsector_man_name"), content: "alg_terreinsector_omschrijving"}));
      rst.addColumn(new Column({caption: L("lcl_estate_terreinsector_man_sort"), content: "alg_srtterreinsec_omschrijving"}));
      rst.addColumn(new Column({caption: L("lcl_estate_terreinsector_man_oppervlak"), content: "alg_terreinsector_oppervlak", datatype: "float"}));
      rst.addColumn(new Column({caption: L("lcl_estate_terreinsector_man_omtrek"), content: "alg_terreinsector_omtrek", datatype: "float"}));

      var cnt = rst.processResultset();
%>
  </body>
</html>

