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

    File:           alg_show_verdieping.asp
    Status:
    Description:
    Parameters:

    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="alg.inc" -->

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

var flr_key  = getQParamInt("flr_key");
var onrgoedlvl = "V";
var this_alg = alg.func_enabled(flr_key, onrgoedlvl);
user.auth_required_or_abort(this_alg.readman || this_alg.readuse);

var sql = " SELECT alg_verdieping_omschrijving"
        + "      , alg_verdieping_volgnr"
        + "      , alg_verdieping_code"
        + "      , alg_verdieping_verwijder"
        + "      , mld_dienstniveau_key"
        + "      , alg_verdieping_dwgz"
        + "   FROM alg_verdieping "
        + "  WHERE alg_verdieping_key = " + flr_key;
var oRs = Oracle.Execute(sql);
var flr_omschr = oRs("alg_verdieping_omschrijving").Value;
var flr_volgnr = oRs("alg_verdieping_volgnr").Value;
var flr_code   = oRs("alg_verdieping_code").Value;
var flr_deleted = oRs("alg_verdieping_verwijder").Value != null;
var flr_dwgz = oRs("alg_verdieping_dwgz").Value;
var dienstniveau_key = oRs("mld_dienstniveau_key").Value;
oRs.Close();
%>

<html>
  <head>
<%  FCLTHeader.Generate(); %>
    <script type="text/javascript">
      function flr_change()
      {
        if (FcltMgr.startEdit(window))
          window.location.href = "alg_edit_verdieping.asp?flr_key=<%=flr_key%>&embedded=1"
      }

      function flr_delete()
      {
        FcltMgr.confirm(L("lcl_alg_del_txt_verdieping"), function() {
            var data = {
                key: <%=flr_key%>,
                level: "V"
            };
            <% protectRequest.dataToken("data"); %>
            $.post("alg_delete.asp",
                data,
                FcltCallbackClose,
                "json");
        });
      }
      function openFG()
      {
          var url = '../cad/ShowRoom.asp?vKey=' + <%=flr_key%>;
          FcltMgr.openModalDetail(url, { titel: L("lcl_prs_wp_fgraph" ) + ": <%=safe.jsstring(flr_omschr) %>"});
      }
      function openEvictionPlan()
      {
          var url = 'appl/cad/EvictionPlan.asp?floor_key=' + <%=flr_key%>;
          FcltMgr.openDetail(url, { titel: L("lcl_eviction_plan_h" ) + ": <%=safe.jsstring(flr_omschr) %>"});
      }
    </script>
  </head>

  <body class="showmode">
  <% SUBFRAME_START(); %>
<%  var buttons = [];
    if (!flr_deleted)
    {
      if (this_alg.writeman || this_alg.writeuse)
        buttons.push({title: L("lcl_change"), action:"flr_change()", icon: "fa-fclt-edit" });
      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: "fa-map-marker" });
        var pathName = S("flexfilespath") + "/cad/vlucht/" + "V" + flr_key;
        var fso = new ActiveXObject("Scripting.FileSystemObject");
        if (fso.FolderExists(pathName)) {
          buttons.push({title: L("lcl_eviction_plan_h"), action:"openEvictionPlan()", icon: "fa-ufo-beam" });
        }

      }
      if (this_alg.writeman) // ALGMAN nodig
        buttons.push({title: L("lcl_delete"), action:"flr_delete()", icon: "fa-trash-alt" });
    }

    IFRAMER_HEADER(L("lcl_alg_verdieping_frame"), buttons);
%>
<%    if (flr_deleted)
      {
        SIMPLE_BLOCK_START();
%>      <div class="alg_deleted"><%=L("lcl_record_is_deleted")%></div><%
        SIMPLE_BLOCK_END();
      }
%>
      <form name=u2 onSubmit="return false;">
<%      BLOCK_START("algflr1", L("lcl_floor"), {icon: "fa-layer-group"});
        FCLTplaatsselector(-1, {
                            verdiepingkey: flr_key,
                            startlevel: 2, //locatie
                            eindlevel: 4, // Verdieping (klikt naar zichzelf door, verbeterpuntje)
                            moreinfo: true,
                            readonly: true });

        ROFIELDTR("fld", L("lcl_estate_verdieping_man_code"), flr_code);
        ROFIELDTR("fld", L("lcl_estate_verdieping_man_volgnr"), flr_volgnr);
        if (dienstniveau_key)
        {
            sql  = "SELECT   mld_dienstniveau_key, "
                 + lcl.xsqla("mld_dienstniveau_omschr", "mld_dienstniveau_key")
                 + "    FROM mld_dienstniveau "
                 + "   WHERE mld_dienstniveau_key = " + dienstniveau_key;
            oRs = Oracle.Execute(sql);
            ROFIELDTR("fld", L("lcl_mld_dienst_niveau"), oRs("mld_dienstniveau_omschr").Value);
            oRs.Close();
        }
        BLOCK_END();

        BLOCK_START("algflr2", L("lcl_alg_gebouw_fysiek"), {icon: "fa-ruler-combined"});
          var calcopp = alg.calc_algm2(flr_key, onrgoedlvl);
          ROFIELDTR("fld", L("lcl_estate_verdieping_bruto_vloeropp") + L("lcl_estate_calc_vloeropp"), calcopp.oppfloor, {suppressEmpty: true, datatype: "float"});
          ROFIELDTR("fld", L("lcl_estate_verdieping_netto_vloeropp") + L("lcl_estate_calc_vloeropp"), calcopp.opprooms, {suppressEmpty: true, datatype: "float"});
          ROFIELDTR("fld", L("lcl_estate_ruimte_opp_alt1") + L("lcl_estate_calc_vloeropp"), calcopp.oppalt1, {suppressEmpty: true, datatype: "float"});
          ROFIELDTR("fld", L("lcl_estate_ruimte_opp_alt2") + L("lcl_estate_calc_vloeropp"), calcopp.oppalt2, {suppressEmpty: true, datatype: "float"});
          ROFIELDTR("fld", L("lcl_estate_verdieping_man_dwgz"), safe.displayfloat(flr_dwgz, 3, true), {suppressEmpty: true});
        BLOCK_END();

        generateFlexKenmerkBlock ({
           onrgoed_key    : flr_key,
           onrgoed_niveau : onrgoedlvl,
           reado          : true,
           this_alg       : this_alg
        });
%>
      </form>
    <% SUBFRAME_END(); %>
  </body>
</html>
<% ASPPAGE_END(); %>
