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

    File:         alg_show_ruimte.asp
    Description:  details van een ruimte
    Parameters:   room_key

    Context:
    Note:

*/ %>
<!-- #include file="../Shared/common.inc" -->
<!-- #include file="../Shared/iface.inc" -->
<!-- #include file="../Shared/selector.inc" -->
<!-- #include file="../Shared/plaatsselector.inc" -->
<!-- #include file="alg_flexkenmerk.inc" -->
<!-- #include file="../API2/api2.inc" -->
<!-- #include file="../API2/model_rooms.inc" -->
<!-- #include file="../Shared/json2.js" -->

<%
FCLTHeader.Requires({ plugins:["jQuery"],
                      js: [] })

var room_key = getQParamInt("room_key");

var room_params = { filter: { id: room_key
                            , scope: "fe"
                            , show_deleted: true // Ook indien verwijderd ophalen.
                            },
                    include: ["cadcontours"]
                  };
var rooms = new model_rooms(room_key, room_params);

var room_data    = rooms.data
var this_alg     = room_params.func_enabled;                   // room_params bevat nu ook waarden die in API2 zijn bepaald.
var room_deleted = !!room_data.deleted;

if (!room_data.cadcontours.length)
    room_data.cadcontours = [{}];

%>

<html>
  <head>
<%  FCLTHeader.Generate(); %>
    <script  type="text/javascript" >
        function room_change()
        {
            if (FcltMgr.startEdit(window))
                window.location.href = "alg_edit_ruimte.asp?room_key=<%=room_key%>"
        }
        function room_delete()
        {
            if (confirm(L("lcl_alg_del_txt_ruimte")))
            {
                var data = { room_action: "D" };
                <% protectRequest.dataToken("data"); %>
                $.post($("form[name=u2]")[0].action,
                       data,
                       FcltCallbackClose,
                       "json");
            }
        }
        function openFG()
        {
            var url = '../cad/ShowRoom.asp?rKey=' + <%=room_key%>;
            FcltMgr.openModalDetail(url, { titel: L("lcl_prs_wp_fgraph" ) + ": <%=safe.jsstring(room_data.name) %>"});
        }
    </script>
  </head>

  <body id="showbody">
<%  var buttons = [];
    if (!room_deleted)
    {
      if (this_alg.writeman || this_alg.writeuse)
        buttons.push({title: L("lcl_change"), action:"room_change()", icon: "wijzigen.png" });

      var xfunc = user.func_enabled2("CAD", { isOptional: true });
      if (xfunc && xfunc.canRead("WEB_CADUSE"))
        buttons.push({title: L("lcl_prs_wp_fgraph"), action:"openFG()", icon: "zone.png" });
      if (this_alg.writeman) // RUIMAN nodig
        buttons.push({title: L("lcl_delete"), action:"room_delete()", icon: "delete.png" });
    }

    IFRAMER_HEADER(L("lcl_alg_ruimte_frame"), buttons);
%>
    <div id="show">
<%
      if (room_deleted)
      {
%>      <div class="alg_deleted"><%=L("lcl_record_is_deleted")%></div><%
      }
%>
      <form name=u2
            action="alg_edit_ruimte_save.asp?room_key=<%=room_data.id%>"
            onSubmit="return false">
<%
        BLOCK_START("algLoc1", "");

          FCLTplaatsselector(-1, {
                            ruimtekey: room_key,
                            startlevel: 2, //Locatie
                            eindlevel: 4, //Verdieping
                            moreinfo: true,
                            readonly: true });

          var params = { infoPointer: { Url: "appl/shared/status_info.asp?room_key=" + room_key + "&urole=bo",
                                        Title: L("lcl_status_details") + " " + room_data.name
                                      }
                       }

          ROFIELDTR("fldshort", L("lcl_estate_ruimte_man_nr"),    room_data.name, params);
          ROFIELDTR("fld",      L("lcl_estate_ruimte_man_descr"), room_data.description);
          ROFIELDTR("fld",      L("lcl_estate_ruimte_man_sort"), (room_data.roomtype ?     room_data.roomtype.name : ""),     {suppressEmpty:true});
          ROFIELDTR("fld",      L("lcl_mld_dienst_niveau"),      (room_data.servicelevel ? room_data.servicelevel.name : ""), {suppressEmpty:true});

        BLOCK_END();
        BLOCK_START("algLoc2", "");

          ROFIELDTR("fldshort",     L("lcl_estate_ruimte_bruto_vloeropp"), room_data.grossarea, {suppressEmpty:true});
          if (room_data.grossarea != room_data.cadcontours[0].cadarea)
              ROFIELDTR("fldshort", L("lcl_estate_ruimte_getekendopp"),    room_data.cadcontours[0].cadarea,   {suppressEmpty:true});
          ROFIELDTR("fldshort",     L("lcl_estate_ruimte_opp_alt1"),       room_data.area1,     {suppressEmpty:true});
          if (room_data.area1 != room_data.cadcontours[0].cadalt1)
              ROFIELDTR("fldshort", L("lcl_fg_tek_room_opp_g_alt1"),       room_data.cadcontours[0].cadalt1,   {suppressEmpty:true});
          ROFIELDTR("fldshort",     L("lcl_estate_ruimte_opp_alt2"),       room_data.area2,     {suppressEmpty:true});
          if (room_data.area2 != room_data.cadcontours[0].cadalt2)
              ROFIELDTR("fldshort", L("lcl_fg_tek_room_opp_g_alt2"),       room_data.cadcontours[0].cadalt2,   {suppressEmpty:true});
          ROFIELDTR("fldshort",     L("lcl_estate_ruimte_man_omtrek"),     room_data.perimeter, {suppressEmpty:true});
          ROFIELDTR("fldshort",     L("lcl_estate_ruimte_man_inhoud"),     room_data.volume,    {suppressEmpty:true});
          ROFIELDTR("fld",          L("lcl_estate_ruimte_man_opmerk"),     room_data.remark,    {suppressEmpty:true});

          ROFIELDTR("fld", L("lcl_estate_gebouw_beginuur"), toTimeString(room_data.openfrom),   {suppressEmpty:true});
          ROFIELDTR("fld", L("lcl_estate_gebouw_einduur"),  toTimeString(room_data.opento),     {suppressEmpty:true});

          switch (room_data.workdays)
          {
              case 0:  werkdagentekst = L("lcl_No"); break;
              case 1:  werkdagentekst = L("lcl_Yes"); break;
              default: werkdagentekst = L("lcl_alg_ruimte_volgens_gebouw");
          }
          ROFIELDTR("fld", L("lcl_estate_gebouw_werkdagen"), werkdagentekst);

        BLOCK_END();

        generateFlexKenmerkBlock ({
            onrgoed_key    : room_key,
            onrgoed_niveau : rooms.defaults.onrgoedlvl,
            reado          : true,
            flexcolumns    : S("alg_flexcolumns"),
            this_alg       : this_alg
            });
%>
      </form>
    </div>
  </body>
</html>
