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

    File:               alg_edit_verdieping_multi.asp
    Description:        Multi editten van verdiepingen
    Parameters:         key

    Context:            alg_verdieping_search_list.asp
    Note:               De minimale multi-edit velden

*/ %>
<!-- #include file="../Shared/common.inc" -->
<!-- #include file="../Shared/iface.inc" -->
<!-- #include file="../Shared/calendar.inc" -->
<!-- #include file="../Shared/selector.inc" -->
<!-- #include file="../Shared/save2db.inc" -->
<!-- #include file="../Shared/kenmerk_common.inc" -->
<!-- #include file="../API2/api2.inc" -->
<!-- #include file="./alg_flexkenmerk.inc" -->
<!-- #include file="alg.inc" -->

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

var flr_key_arr = getQParamIntArray("flr_keys");
var warning = "";
var result = {};
var tobeedited = 0;
var ingesloten = [];
// Bepaal de verdiepingen in de selectie die
// ook echt gewijzigd kunnen of mogen worden.
var onrgoedlvl = "V";
for (var i = 0; i < flr_key_arr.length; i++)
{
  var this_alg = alg.func_enabled(flr_key_arr[i], onrgoedlvl);
  if (this_alg.writeman || this_alg.writeuse)
  {
    ingesloten.push(flr_key_arr[i]);
    tobeedited++;
    var last_this_alg = this_alg; // deze gebruiken we voor rechtencontrole. Niet 100% zuiver maar goed genoeg
  }
}

user.auth_required_or_abort(ingesloten.length); // We klagen niet over enkele wel en enkele niet
%>

<html>
  <head>
<%  FCLTHeader.Generate(); %>
    <script type="text/javascript">
        function alg_submit()
        {   // Invoer van velden wordt realtime gevalideerd.
            $.post($("form[name=u2]")[0].action,
                   $("[name=u2]").serialize(),
                   FcltCallbackAndThenAlways(alg_submit_callback),
                   "json");
            return true; // disable button
        }

        function alg_submit_callback(json)
        {
            iface.button.enable("btn_alg_submit");
            if (json.success)
                FcltMgr.closeDetail(window, json);
        }

        function alg_cancel()
        {
            FcltMgr.closeDetail(window, { cancel: true } );
        }
    </script>
  </head>

  <body class="fclt-modal" id="mod_algmultiedit">
  <% MODAL_START(); %>
    <form name="u2" action="alg_edit_verdieping_multi_save.asp?flr_keys=<%=ingesloten.join(",")%>" method="post">
<%
      MODAL_BLOCK_START("algflr1", L("lcl_floor"), { icon: "fa-layer-group" });

        sql = "SELECT mld_dienstniveau_key"
            + "     , " + lcl.xsqla("mld_dienstniveau_omschr", "mld_dienstniveau_key")
            + "  FROM mld_dienstniveau"
            + " ORDER BY UPPER(" + lcl.xsql("mld_dienstniveau_omschr", "mld_dienstniveau_key") + ")";
        FCLTselector("dienstniveau",
                   sql,
                   { label: L("lcl_mld_dienst_niveau"),
                     emptyOption: "",
                     initEmpty: true,
                     readonly: !this_alg.writeuse
                   });

      MODAL_BLOCK_END();

      generateFlexKenmerkBlock({
          onrgoed_niveau: "V",
          onrgoed_key: -1,
          this_alg: last_this_alg,
          reado: false,
          multi: true
        });

%>
      <script type="text/javascript">
        $(function()
          {
            init_multi();
          });
      </script>
<%
      var buttons =  [];
      buttons.push({title: L("lcl_submit"), action:"alg_submit()", singlepress: true, id: "btn_edit_submit", importance: 1, icon: "fa-fclt-save"});
      buttons.push({title: L("lcl_cancel"),  action:"alg_cancel()", importance: 3, icon: "fa-fclt-cancel"});
      SIMPLE_BLOCK_START();
      CreateButtons(buttons);
      SIMPLE_BLOCK_END();
      IFACE.FORM_END();
%>
    </form>
    <% MODAL_END(); %>
  </body>
</html>
<% ASPPAGE_END(); %>
