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

    File:         alg_show_gebouw.asp
    Description:  show gebouw details
    Parameters:   bld_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="../Shared/persoonselector.inc" -->
<!-- #include file="alg_flexkenmerk.inc" -->
<!-- #include file="alg.inc" -->

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

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

var sql = " SELECT * "
        + "   FROM alg_gebouw "
        + "  WHERE alg_gebouw_key = " + bld_key;
var oRs = Oracle.Execute(sql);
var bld_srtkey  = oRs("alg_srtgebouw_key").Value;
var bld_naam    = oRs("alg_gebouw_naam").Value;
var bld_code    = oRs("alg_gebouw_code").Value;
var bld_descr   = oRs("alg_gebouw_omschrijving").Value;
var bld_maak    = oRs("alg_gebouw_aanmaak").Value;
var bld_email  = oRs("alg_gebouw_email").Value;
var bld_teken   = oRs("alg_gebouw_getekend").Value;
var bld_opp     = oRs("alg_gebouw_bruto_vloeropp").Value;
var bld_omtrek  = oRs("alg_gebouw_omtrek").Value;
var bld_inhoud  = oRs("alg_gebouw_inhoud").Value;
var bld_opmerk  = oRs("alg_gebouw_opmerking").Value;
var mld_adres   = oRs("mld_adres_key").Value;
var prs_kstpl   = oRs("prs_kostenplaats_key").Value;
var bld_ordrnr  = oRs("alg_gebouw_ordernr").Value;
var bld_dwgx    = oRs("alg_gebouw_dwgx").Value;
var bld_dwgy    = oRs("alg_gebouw_dwgy").Value;
var bld_x       = oRs("alg_gebouw_x").Value;
var bld_y       = oRs("alg_gebouw_y").Value;
var bld_bez     = oRs("alg_gebouw_bez").Value;
var bld_deleted = oRs("alg_gebouw_verwijder").Value != null;
var dienstniveau = oRs("mld_dienstniveau_key").Value;
var beginuur   = oRs("alg_gebouw_beginuur").Value;
var einduur    = oRs("alg_gebouw_einduur").Value;
var werkdagen  = oRs("alg_gebouw_werkdagen").Value;
var verantw    = oRs("prs_perslid_key_verantw").Value;
oRs.Close();
%>

<html>
  <head>
<%  FCLTHeader.Generate(); %>
    <script  type="text/javascript" >
      function bld_change()
      {
        if (FcltMgr.startEdit(window))
          window.location.href = "alg_edit_gebouw.asp?bld_key=<%=bld_key%>"
      }
      function bld_delete()
      {
        if (confirm(L("lcl_alg_del_txt_gebouw")))
        {
          var data = { key: <%=bld_key%>,
                       level: "G"
                     };
          <% protectRequest.dataToken("data"); %>
          $.post("alg_delete.asp",
                 data,
                 FcltCallbackClose,
                 "json");
        }
      }
<%  if (S("alg_fg_remote_maps") != "" && bld_x && bld_y) { %>
      function openMaps(bldKey)
      {
          fwnd = window.open('../cad/ShowGoogleMap.asp?bld_key=' + bldKey, 'FGShow',
                             "width=640, height=480, directories=no, location=no, menubar=no,"
                           + "resizable=yes, status=no, titlebar=yes, toolbar=no");
          fwnd.focus()
          return;
      }
<%  } %>
    </script>
  </head>

  <body id="showbody">
<%  var buttons = [];

    if (S("alg_fg_remote_maps") != "" && bld_x && bld_y) {
         buttons.push({title: L("lcl_maps"), action:"openMaps("+bld_key+")", icon: "map.png" });
    }

    if (!bld_deleted)
    {
      if (this_alg.writeman || this_alg.writeuse)
        buttons.push({title: L("lcl_change"), action:"bld_change()", icon: "wijzigen.png" });
      if (this_alg.writeman) // ALGMAN nodig
        buttons.push({title: L("lcl_delete"), action:"bld_delete()", icon: "delete.png" });
    }

    IFRAMER_HEADER(L("lcl_alg_gebouw_frame"), buttons);
%>
    <div id="show">
<%    if (bld_deleted)
      {
%>      <div class="alg_deleted"><%=L("lcl_record_is_deleted")%></div><%
      }
%>
    <div id="show">
      <form name=u2 onSubmit="return false;">
<%      BLOCK_START("algLoc1", "&nbsp;");
        FCLTplaatsselector(-1,
                           { gebouwkey: bld_key,
                             startlevel: 2, //Locatie
                             eindlevel: 3, // Gebouw
                             readonly: true
                           });
        sql = "SELECT alg_srtgebouw_key"
            + "     , " + lcl.xsqla('alg_srtgebouw_omschrijving', 'alg_srtgebouw_key')
            + "  FROM alg_srtgebouw"
            + " WHERE alg_srtgebouw_verwijder IS NULL"
            + " ORDER BY alg_srtgebouw_upper"
        FCLTselector("bld_srtkey",
                     sql,
                     { label: L("lcl_estate_gebouw_srtgebouw"),
                       initKey: bld_srtkey,
                       emptyOption: "",
                       readonly: true
                     });
        ROFIELDTR("fld", L("lcl_estate_gebouw_man_code"), bld_code, {suppressEmpty:true});
        ROFIELDTR("fld", L("lcl_estate_gebouw_man_opmerk"), bld_opmerk, {suppressEmpty:true});
        sql = "SELECT prs_kostenplaats_key"
            + "     , k.prs_kostenplaats_nr || ' ' || k.prs_kostenplaats_omschrijving"
            + "  FROM prs_kostenplaats k"
            + " WHERE k.prs_kostenplaats_module = 'ALG'"
            + " ORDER BY prs_kostenplaats_upper";
        FCLTselector("prs_kstpl",
                     sql,
                     { label: L("lcl_prs_dept_kosten"),
                       initKey: prs_kstpl,
                       emptyOption: "",
                       readonly: true
                     });
        ROFIELDTR("fld", L("lcl_estate_gebouw_ordernr"), bld_ordrnr, {suppressEmpty:true});
        if (dienstniveau)
        {
          sql = "SELECT mld_dienstniveau_key"
              + "     , " + lcl.xsqla("mld_dienstniveau_omschr", "mld_dienstniveau_key")
              + "  FROM mld_dienstniveau"
              + " WHERE mld_dienstniveau_key = " + dienstniveau;
          oRs = Oracle.Execute(sql);
          ROFIELDTR("fld", L("lcl_mld_dienst_niveau"), oRs("mld_dienstniveau_omschr").value);
          oRs.Close();
        }
        FCLTpersoonselector("verantw",
                            "sgVerantw",
                            { perslidKey: verantw,
                              label: L("lcl_alg_verantw"),
                              readonly: true,
                              suppressEmpty: true,
                              moreinfo: this_alg.readman
                            });
        AFIELDTR('fldmailto details', L("lcl_alg_gebouw_email"), "mailto:" + bld_email, bld_email, { suppressEmpty: true });
        BLOCK_END();

        BLOCK_START("algLoc2", "&nbsp;");
        var calcopp = alg.calc_algm2(bld_key, onrgoedlvl);
        ROFIELDTR("fld", L("lcl_estate_ruimte_bruto_vloeropp") + L("lcl_estate_calc_vloeropp"), calcopp.oppbruto, {suppressEmpty: true});
        ROFIELDTR("fld", L("lcl_estate_ruimte_opp_alt1") + L("lcl_estate_calc_vloeropp"), calcopp.oppalt1, {suppressEmpty: true});
        ROFIELDTR("fld", L("lcl_estate_ruimte_opp_alt2") + L("lcl_estate_calc_vloeropp"), calcopp.oppalt2, {suppressEmpty: true});

        ROFIELDTR("fld", L("lcl_estate_gebouw_man_bruto_vloeropp"), bld_opp, {suppressEmpty: true});
        ROFIELDTR("fld", L("lcl_estate_gebouw_man_omtrek"), bld_omtrek, {suppressEmpty: true});
        ROFIELDTR("fld", L("lcl_estate_gebouw_man_inhoud"), bld_inhoud, {suppressEmpty: true});
        sql = "SELECT mld_adres_key"
            + "     , mld_adres_naam"
            + "  FROM mld_v_afleveradres"
            + " ORDER BY mld_adres_naam";
        FCLTselector("del_address",
                     sql,
                     {  label: L("lcl_delivery_address"),
                        initKey: mld_adres,
                        emptyOption: "",
                        readonly: true
                     });
        ROFIELDTR("fld", L("lcl_geoxcoord"), bld_x, {suppressEmpty:true});
        ROFIELDTR("fld", L("lcl_geoycoord"), bld_y, {suppressEmpty:true});
        ROCHECKBOXTR("fldalgbez", L("lcl_estate_gebouw_bez"), bld_bez==1);
        ROFIELDTR("fld", L("lcl_estate_gebouw_beginuur"), toTimeString(beginuur), {suppressEmpty:true} );
        ROFIELDTR("fld", L("lcl_estate_gebouw_einduur"), toTimeString(einduur), {suppressEmpty:true} );
        ROCHECKBOXTR("fldalgwerk", L("lcl_estate_gebouw_werkdagen"), werkdagen==1);
        BLOCK_END();

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