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

    File:           alg_locatie.asp
    Description:

    Parameters:     key
                    cnt_full

    Context:
    Note:

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

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

var loc_key = getQParamInt("key", -1);
var cnt_full = getQParamInt("cnt_full", 1);

if (loc_key > 0)
{
  sql = "SELECT alg_locatie_code, alg_locatie_x, alg_locatie_y "
      + "  FROM alg_locatie "
      + " WHERE alg_locatie_key = " + loc_key;
  oRs = Oracle.Execute(sql);

  var loc_name = oRs("alg_locatie_code").value;
  var loc_x = oRs("alg_locatie_x").value;
  var loc_y = oRs("alg_locatie_y").value;
}
else
{
  var loc_name = "";
}

%>

<html>
  <head>
<%  FCLTHeader.Generate(); %>
    <script  type="text/javascript" >
      FcltMgr.setTitle(L("lcl_location")+" "+ "<%=safe.jsstring(loc_name)%>", {hot: false});
<%    if (loc_key == -1) { %>FcltMgr.startEdit(window);<% } %>
      function algClose(params)
      {
          <% if (loc_key == -1)
             { %>
               if (params.cancel)
               {
                   FcltMgr.closeDetail(window, params );
                   return true;
               }
               if (!params.keepForm)
                   window.location.href = "alg_locatie.asp?verynew=1&key=" + params.loc_key;
          <% } else { /* Bestaande locatie bewerkt, switch naar show-mode */ %>
              if (params.close)
              {
                FcltMgr.closeDetail(window, { close: true})
              }
              if (!params.keepForm)
                  $("#algframe")[0].src = "alg_show_locatie.asp?loc_key=<%=loc_key%>";
          <% } %>
      }
    </script>
  </head>
  <body>
  <% PAGE_START(); %>
<%
    if (loc_key == -1)
      var page="alg_edit_locatie.asp"; // Maak een nieuw
    else
      var page="alg_show_locatie.asp";
    page += "?loc_key=" + loc_key;

    IFRAMER("algframe", page, { title: L("lcl_alg_locatie_frame"),
                                FcltClose: "algClose" } );

    if (loc_key > -1)
    {
      var urole = "bo";
      var page0 = "../alg/alg_gebouw_search_list.asp?urole="
                + urole +"&locatiekey="+loc_key
                + "&rst_filters=1";

      IFRAMER("alggebouwframe", page0, { icon: "fa-list"} );
      var page1 = "../alg/alg_terreinsector_search_list.asp?urole=" + urole +"&locatiekey="+loc_key;
      IFRAMER("algterreinframe", page1, { icon: "fa-list"} );

      var authparamsCNTUSE = user.checkAutorisation("WEB_CNTUSE", true);
      var authparamsCNTMAN = user.checkAutorisation("WEB_CNTMAN", true);
      var curole = "bo";

      if (!authparamsCNTMAN && authparamsCNTUSE)
        curole = "fe";

      if (authparamsCNTMAN || authparamsCNTUSE)
      {
          var page2 = "../cnt/cnt_search_list.asp?embedded=1&tiny=1&urole=" + curole
                    + "&ffutu=1&fact=1&frap=1&fopz=1&sact=1&loc_key=" + loc_key
                    + "&rst_filters=1"
                    + "&cnt_full="+cnt_full;
          IFRAMER("cntlistframe", page2, { icon: "fa-list" } );
      }

      if (S("alg_fg_remote_maps") != "" && loc_x && loc_y)
      {
        var page4 = "../cad/ShowGoogleMap.asp?loc_key=" + loc_key;
        IFRAMER("mapsframe", page4, { title: L("lcl_maps"), icon: "fa-map-marker-alt" } );
      }
      // tracking naar subframe :-)
      var autfunction = ["WEB_ALGUSE", "WEB_ALGMAN"];
      var authparams = user.checkAutorisation(autfunction, true);
      if (authparams && authparams.ALGreadlevel <= 2 && authparams.PRSreadlevel < 9)
      {
        page5 = protectQS.create("../shared/status_info.asp?loc_key=" + loc_key);
        IFRAMER("alghistoryframe", page5, { icon: "fa-list", title: L("lcl_tracking")} );
      }

      page6 = "alg_show_note2.asp?alg_key=" + loc_key + "&alg_typ=L";
      IFRAMER("algnoteframe", page6, { refreshOnClose: true, sidebar: true } ); // sidebar heeft geen icon/title nodig

    }
%>
<% PAGE_END(); %>
  </body>
</html>
<% ASPPAGE_END(); %>
