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

    File:         alg_show_terreinsector.asp
    Description:  details van een terrein
    Parameters:   ter_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="alg.inc" -->

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

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

var sql = "SELECT ts.alg_locatie_key"
        + "     , ts.alg_terreinsector_omschrijving"
        + "     , ts.alg_terreinsector_code"
        + "     , ts.alg_terreinsector_naam"
        + "     , ts.alg_srtterreinsector_key"
        + "     , (SELECT " + lcl.xsqla('alg_srtterreinsec_omschrijving', 'alg_srtterreinsector_key')
          + "        FROM alg_srtterreinsector sts"
          + "       WHERE sts.alg_srtterreinsector_key = ts.alg_srtterreinsector_key) srtterreinsector_oms"
        + "     , ts.alg_terreinsector_oppervlak"
        + "     , ts.alg_terreinsector_omtrek"
        + "     , ts.alg_terreinsector_aanmaak"
        + "     , ts.alg_terreinsector_omschrijving"
        + "     , ts.alg_terreinsector_ordernr"
        + "     , ts.prs_kostenplaats_key"
        + "     ,(SELECT " + S("prs_kpn_string") + " kpstring"
          + "       FROM prs_kostenplaats k"
          + "      WHERE k.prs_kostenplaats_key = ts.prs_kostenplaats_key) kostenplaats_oms"
        + "     , ts.prs_afdeling_key"
        + "     , (SELECT prs_afdeling_omschrijving"
          + "        FROM prs_afdeling a"
          + "       WHERE a.prs_afdeling_key = ts.prs_afdeling_key) afdeling_oms"
        + "     , ts.alg_terreinsector_verwijder"
        + "  FROM alg_terreinsector ts"
        + " WHERE ts.alg_terreinsector_key = " + ter_key;
var oRs = Oracle.Execute(sql);
var loc_key   = oRs("alg_locatie_key").value;
var ter_oms   = oRs("alg_terreinsector_omschrijving").value;
var ter_code  = oRs("alg_terreinsector_code").value;
var ter_naam  = oRs("alg_terreinsector_naam").value;
var ter_srkey = oRs("alg_srtterreinsector_key").value;
var ter_sroms = oRs("srtterreinsector_oms").value;
var ter_opp   = oRs("alg_terreinsector_oppervlak").value;
var ter_omt   = oRs("alg_terreinsector_omtrek").value;
var ter_aanmk = oRs("alg_terreinsector_aanmaak").value;
var ter_oms   = oRs("alg_terreinsector_omschrijving").value;
var ter_ordnr = oRs("alg_terreinsector_ordernr").value;
var prs_kstn  = oRs("prs_kostenplaats_key").value;
var prs_kstpl = oRs("kostenplaats_oms").value;
var prs_afd   = oRs("afdeling_oms").value;
var ter_deleted = oRs("alg_terreinsector_verwijder").value != null;
oRs.Close();
%>

<html>
  <head>
<%  FCLTHeader.Generate(); %>
    <script  type="text/javascript" >
      jQuery(document).ready(function() {
            $('textarea').resize(function () { FcltMgr.resized(window) } );
            $('textarea').autogrow();
      });

      function ter_change()
      {
          if (FcltMgr.startEdit(window))
              window.location.href = "alg_edit_terreinsector.asp?ter_key=<%=ter_key%>"
      }
      function ter_delete()
      {
          if (confirm(L("lcl_alg_del_txt_terreinsector")))
          {
            var data = { key: <%=ter_key%>,
                         level: "T"
                       };
            <% protectRequest.dataToken("data"); %>
            var ter_key = <%=ter_key%>
            $.post("alg_delete.asp",
                   data,
                   FcltCallbackClose,
                   "json");
          }
      }
    </script>
  </head>

  <body id="showbody">
<%  var buttons = [];
    if (!ter_deleted)
    {
      if (this_alg.writeman || this_alg.writeuse)
        buttons.push({title: L("lcl_change"), action:"ter_change()", icon: "wijzigen.png" });
      if (this_alg.writeman) // ALGMAN nodig
        buttons.push({title: L("lcl_delete"), action:"ter_delete()", icon: "delete.png" });
    }

    IFRAMER_HEADER(L("lcl_alg_terreinsector_frame"), buttons);
%>
    <div id="show">
<%    if (ter_deleted == 1)
      {
%>      <div class="alg_deleted"><%=L("lcl_record_is_deleted")%></div><%
      }
%>
      <form name=u2 onSubmit="return false;">
<%
        BLOCK_START("algInfo", "");
        FCLTplaatsselector(-1,
                           { locatiekey: loc_key,
                             startlevel: 2, // Locatie
                             eindlevel: 2, // Locatie
                             readonly: true
                           });

        ROFIELDTR("fld", L("lcl_estate_terreinsector_man_sort"), ter_sroms, {suppressEmpty: true});
        ROFIELDTR("fld", L("lcl_estate_terreinsector_man_code"), ter_code);
        ROFIELDTR("fld", L("lcl_estate_terreinsector_man_name"), ter_naam);
        ROFIELDTR("fld", L("lcl_prs_dept_kosten"), prs_kstpl, {suppressEmpty: true});
        ROFIELDTR("fld", L("lcl_dep_name_level2"), prs_afd);
        ROFIELDTR("fld", L("lcl_estate_terreinsector_ordernr"), ter_ordnr, {suppressEmpty: true});
        ROFIELDTR("fld", L("lcl_estate_terreinsector_man_oppervlak"), ter_opp, {suppressEmpty: true});
        ROFIELDTR("fld", L("lcl_estate_terreinsector_man_omtrek"), ter_omt, {suppressEmpty: true});

        BLOCK_END();

        generateFlexKenmerkBlock({onrgoed_key    : ter_key,
                                 onrgoed_niveau : onrgoedlvl,
                                 reado          : true,
                                 flexcolumns    : S("alg_flexcolumns"),
                                 this_alg       : this_alg
                                });

%>
      </form>
    </div> <!-- edit -->
  </body>
</html>
