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

    File:           alg_show_ruimte.asp
    Status:
    Description:
    Parameters:


    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="../API2/api2.inc" -->
<!-- #include file="../API2/model_regions.inc" -->

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

var regio_key  = getQParamInt("regio_key");

var regio_params = { filter: { id: regio_key
                             , show_deleted: true // Ook indien verwijderd ophalen.
                             }};
var regio_array = model_regions.REST_GET(regio_params);         // Roep de API2 GET aan
var regio_data  = (regio_array[0] ? regio_array[0] : {id: -1}); // GET kan meerdere records opleveren, maar we verwachten hier maar 1.
var this_alg    = regio_params.func_enabled;                    // regio_params bevat nu ook waarden die in API2 zijn bepaald.

var regio_exists = (regio_array.length ? true : false);
var regio_deleted = regio_exists && !!regio_data.deleted;
%>

<html>
  <head>
<%  FCLTHeader.Generate(); %>
    <script  type="text/javascript" >
      function reg_change()
      {
        if (FcltMgr.startEdit(window))
          window.location.href = "alg_edit_regio.asp?regio_key=<%=regio_data.id%>&embedded=1"
      }

      function reg_delete()
      {
        if (confirm(L("lcl_alg_del_txt_regio")))
        {
            var data = { action: "D" };
            <% protectRequest.dataToken("data"); %>
            $.post($("form[name=u2]")[0].action,
                   data,
                   FcltCallbackClose,
                   "json");
        }
      }
    </script>
  </head>

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

    IFRAMER_HEADER(L("lcl_alg_regio_frame"), buttons);
%>
    <div id="show">
<%    if (regio_deleted)
      {
%>      <div class="alg_deleted"><%=L("lcl_record_is_deleted")%></div><%
      }
%>
      <form name=u2
            action="alg_edit_regio_save.asp?regio_key=<%=regio_data.id%>"
            onSubmit="return false">
<%      BLOCK_START("algInfo", "&nbsp;");
        FCLTplaatsselector(-1,
                           { regiokey: regio_data.id,
                             startlevel: 0, // Regio
                             eindlevel: 0, // Regio
                             readonly: true });
        BLOCK_END();
%>
      </form>
    </div>
  </body>
</html>
