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

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


    Context:
    Note:

*/ %>
<!-- #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 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 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 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 dienstniveau = oRs("mld_dienstniveau_key").value;
oRs.Close();
%>
<html>
  <head>
<%  FCLTHeader.Generate(); %>
    <script  type="text/javascript" >
      jQuery(document).ready(function() {
           $('textarea').resize(function () { FcltMgr.resized(window) } );
           $('textarea').autogrow();
      });

      function alg_showphotos()
      {
        FcltMgr.openDetail("appl/shared/show_foto.asp?urole=bo&loc_key=<%=loc_key%>", "<%=L("lcl_photos")%>");
      }

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

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

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

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

        ROFIELDTR("fld", L("lcl_estate_locatie_man_code"), loc_code, {suppressEmpty: true});
        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});
        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();
        }
        ROFIELDTR("fld", L("lcl_geoxcoord"), loc_x, {suppressEmpty: true});
        ROFIELDTR("fld", L("lcl_geoycoord"), loc_y, {suppressEmpty: true});

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

        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});
        ROFIELDTR("fld", L("lcl_estate_locatie_man_verantw"), loc_vw, {suppressEmpty: true});
        ROFIELDTR("fld", L("lcl_estate_locatie_man_verantw_tel"), loc_vwtel, {suppressEmpty: true});
        AFIELDTR('fldmailto details', L("lcl_noti_email"), "mailto:" + loc_mail, loc_mail, { suppressEmpty: true });

        BLOCK_END();

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

%>
      </form>
    </div>
  </body>
</html>
