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

    File:         alg_shwo_locatie.asp
    Description:  show de details van een locatie
    Parameters:   loc_key

*/ %>
<!-- #include file="../Shared/common.inc" -->
<!-- #include file="../Shared/iface.inc" -->
<!-- #include file="../Shared/plaatsselector.inc" -->
<!-- #include file="alg_flexkenmerk.inc" -->
<!-- #include file="alg.inc" -->

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

var ins_score_enabled = S("ins_score_enabled") == 1;
var loc_key  = getQParamInt("loc_key");
var onrgoedlvl = "L";
var this_alg = alg.func_enabled(loc_key, onrgoedlvl);
user.auth_required_or_abort(this_alg.readman || this_alg.readuse);

var sql = "SELECT *"
        + "  FROM alg_locatie"
        + " WHERE alg_locatie_key = " + loc_key;
var oRs = Oracle.Execute(sql);
var loc_code         = oRs("alg_locatie_code").Value;
var loc_naam         = oRs("alg_locatie_omschrijving").Value;
var bez_adres        = oRs("alg_locatie_adres").Value;
var bez_postc        = oRs("alg_locatie_postcode").Value;
var bez_plaats       = oRs("alg_locatie_plaats").Value
var bez_land         = oRs("alg_locatie_land").Value;
var loc_vw           = oRs("alg_locatie_verantw").Value;
var loc_vwtel        = oRs("alg_locatie_verantw_tel").Value;
var loc_x            = oRs("alg_locatie_x").Value;
var loc_y            = oRs("alg_locatie_y").Value;
var loc_mail         = oRs("alg_locatie_email").Value;
var loc_image        = oRs("alg_locatie_image").Value;
var loc_score1       = oRs("alg_locatie_mjb_score1").Value;
var loc_volgnr       = oRs("alg_locatie_volgnr").Value;
var pst_adres        = oRs("alg_locatie_post_adres").Value;
var pst_postc        = oRs("alg_locatie_post_postcode").Value;
var pst_adres        = oRs("alg_locatie_post_adres").Value;
var pst_plaats       = oRs("alg_locatie_post_plaats").Value;
var pst_land         = oRs("alg_locatie_post_land").Value;
var loc_deleted      = oRs("alg_locatie_verwijder").Value != null;
var vervaldatum      = oRs("alg_locatie_vervaldatum").Value;
var dienstniveau_key = oRs("mld_dienstniveau_key").Value;
oRs.Close();
%>
<html>
  <head>
<%  FCLTHeader.Generate(); %>
    <script  type="text/javascript" >
      $(function()
      {
        $('textarea').resize(function () { FcltMgr.resized(window) } );
        $('textarea').autogrow();
      });

      function loc_change()
      {
          if (FcltMgr.startEdit(window))
              window.location.href = "alg_edit_locatie.asp?loc_key=<%=loc_key%>"
      }

      function loc_delete()
      {
        FcltMgr.confirm(L("lcl_alg_del_txt_locatie"), function() {
            var data = {
                key: <%=loc_key%>,
                level: "L"
            };
            <% protectRequest.dataToken("data"); %>
            $.post("alg_delete.asp",
                data,
                FcltCallbackClose,
                "json");
        });
      }
    </script>
  </head>

  <body class="showmode">
  <% SUBFRAME_START(); %>
<%  var buttons = [];

    if (!loc_deleted)
    {
      if (this_alg.writeman || this_alg.writeuse)
        buttons.push({title: L("lcl_change"), action: "loc_change()",  icon: "fa-fclt-edit"});
    }

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

    IFRAMER_HEADER(L("lcl_alg_locatie_frame"), buttons);
    if (loc_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("algLoc1", L("lcl_location"), {icon: "fa-location-arrow"});
        FCLTplaatsselector(-1,
                           { locatiekey: loc_key,
                             startlevel: 1, //District
                             eindlevel: 2, // Locatie
                             readonly: true });

        ROFIELDTR("fld", L("lcl_estate_locatie_man_code"), loc_code);
        ROFIELDTR("fld", L("lcl_prs_address_bezoek_adres"), bez_adres, {suppressEmpty: true});
        ROFIELDTR("fld", L("lcl_prs_address_bezoek_postcode"), bez_postc, {suppressEmpty: true});
        ROFIELDTR("fld", L("lcl_prs_address_bezoek_plaats"), bez_plaats, {suppressEmpty: true});
        ROFIELDTR("fld", L("lcl_prs_address_bezoek_land"), bez_land, {suppressEmpty: true});
        ROFIELDTR("fld", L("lcl_geoxcoord"), loc_x, {suppressEmpty: true});
        ROFIELDTR("fld", L("lcl_geoycoord"), loc_y, {suppressEmpty: true});
        BLOCK_END();


        BLOCK_START("algloc2", L("lcl_fac_adres_postblock"), {icon: "fa-envelope-open"});
        ROFIELDTR("fld", L("lcl_prs_address_post_adres"), pst_adres, {suppressEmpty: true});
        ROFIELDTR("fld", L("lcl_prs_address_post_postcode"), pst_postc, {suppressEmpty: true});
        ROFIELDTR("fld", L("lcl_prs_address_post_plaats"), pst_plaats, {suppressEmpty: true});
        ROFIELDTR("fld", L("lcl_prs_address_post_land"), pst_land, {suppressEmpty: true});
        BLOCK_END();

        BLOCK_START("facFM", L("lcl_operations_block"), {icon: "fa-users-cog"});
        ROFIELDTR("fld", L("lcl_alg_locatie_volgnr"), loc_volgnr, {suppressEmpty: true});
        var fldcls = "fld";
        if (vervaldatum <= new Date())
            fldcls += " expired2";
        ROFIELDTR(fldcls, L("lcl_alg_vervaldatum"), toDateString(vervaldatum), {suppressEmpty: true});
        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();
        }
        ROFIELDTR("fld", L("lcl_estate_locatie_man_verantw"), loc_vw, {suppressEmpty: true});
        ROFIELDTR("fld", L("lcl_estate_locatie_man_verantw_tel"), loc_vwtel, {type: "telefoon", suppressEmpty: true});
        ROFIELDTR("fld", L("lcl_alg_locatie_email"), loc_mail, { suppressEmpty: true, type: "email" });
        FILEPICKERTR("loc_image", L("lcl_alg_locatie_image"), loc_image, { "key": loc_key, "module": "ALGPHL", "readonly": true });
        if (ins_score_enabled)
          ROFIELDTR("fld", L("lcl_alg_locatie_mjb_score1"), loc_score1, {suppressEmpty: true});

        BLOCK_END();

        generateFlexKenmerkBlock ({onrgoed_key    : loc_key,
                                  onrgoed_niveau : onrgoedlvl,
                                  reado          : true,
                                  this_alg       : this_alg });

%>
      </form>
    <% SUBFRAME_END(); %>
  </body>
</html>
<% ASPPAGE_END(); %>
