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

    File:           alg_locatie.asp
    Description:

    Parameters:

    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);

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

  var loc_name = oRs("alg_locatie_code").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>
<%
    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"),
                                initHeight: "450px",
                                FcltClose: "algClose" } );
                                
    if (loc_key > -1)
    {
      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 page1="../cnt/cnt_search_list.asp?embedded=1&tiny=1&collapsed=1&urole=" + curole + "&ffutu=1&fact=1&frap=1&fopz=1&sact=1&loc_key=" + loc_key
          IFRAMER("cntFrame", page1, { initHeight: "450px" } );
      }
    }                                  
%>
  </body>
</html>
