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

    File:         alg_edit_verdieping.asp
    Description:  wijzigen of toevoegen verdieping
    Parameters:   flr_key

    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="alg.inc" -->

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

var flr_key  = getQParamInt("flr_key", -1);
var bld_key
var loc_key

var onrgoedlvl = "V";
var this_alg = alg.func_enabled(flr_key, onrgoedlvl);
user.auth_required_or_abort(this_alg.writeman || (flr_key>0&&this_alg.writeuse));

if (flr_key > 0)
{
    sql = " select * "
        + "  FROM ALG_VERDIEPING "
        + "       WHERE alg_verdieping_key = " + flr_key;

    oRs = Oracle.Execute(sql);

    var flr_omschr = oRs("ALG_VERDIEPING_OMSCHRIJVING").value;
    var flr_volgnr = oRs("ALG_VERDIEPING_VOLGNR").value;
    var flr_code   = oRs("ALG_VERDIEPING_CODE").value;
    var dienstniveau  = oRs("mld_dienstniveau_key").value;
    oRs.Close();
}
%>

<html>
<head>
<%
   FCLTHeader.Generate();
%>
<script>
    function alg_submit()
    {
        document.activeElement.blur(); // trigger laatste onChanges
        if (!validateForm("u2"))
            return false;

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

<body id="editbody">
<%
  var buttons =  [ {title: L("lcl_submit"), action:"alg_submit()", icon: "opslaan.png" },
                   {title: L("lcl_cancel"), action:"alg_cancel()", icon: "undo.png" } ];
  IFRAMER_HEADER(L("lcl_alg_verdieping_frame"), buttons);
%>
<div id="edit">
<form name="u2"
      action="alg_edit_verdieping_save.asp?urole=bo&flr_key=<%=flr_key%>"
      method="post"
      target="hidFrameSubmit"
      onSubmit="alg_submit();">
<%
if (this_alg.writeman)
    manRWFIELD = RWFIELDTR;
else
    manRWFIELD = function (a,b,c,d,e) { ROFIELDTR(b,c,d,e) }; // als geen USE of <self> dan zijn er veel readonly

BLOCK_START("algLoc1", "");
      FCLTplaatsselector(this_alg.authparams("WEB_ALGMAN").ALGwritelevel, {
              locatiekey: loc_key,
              gebouwkey: bld_key,
              verdiepingkey: flr_key,
              startlevel: 2, //locatie
              eindlevel: 3, // gebouw
              readonly: (flr_key > 0),
              required: true });

  manRWFIELD("flr_omschr", "fld",      L("lcl_estate_verdieping_man_descr"),  flr_omschr, {required: true, maxlength: 30});
  manRWFIELD("flr_code",   "fld",      L("lcl_estate_verdieping_man_code"),   flr_code, {required: true, maxlength: 10});
  manRWFIELD("flr_volgnr", "fldshort", L("lcl_estate_verdieping_man_volgnr"), flr_volgnr, {required: true, maxlength: 3});

  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"),
                 initKey: dienstniveau,
                 emptyOption: "",
                 readonly: !this_alg.writeuse
              });

BLOCK_END();

BLOCK_START("algLoc2", "");
if (flr_key > 0)
{
  var calcopp = alg.calc_algm2(flr_key, onrgoedlvl); 
  ROFIELDTR("fld", L("lcl_estate_ruimte_bruto_vloeropp") + L("lcl_estate_calc_vloeropp"), calcopp.oppbruto, {suppressEmpty: true});
  ROFIELDTR("fld", L("lcl_estate_ruimte_opp_alt1") + L("lcl_estate_calc_vloeropp"), calcopp.oppalt1, {suppressEmpty: true});
  ROFIELDTR("fld", L("lcl_estate_ruimte_opp_alt2") + L("lcl_estate_calc_vloeropp"), calcopp.oppalt2, {suppressEmpty: true});
}  
BLOCK_END();

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

IFACE.FORM_END();
%>
</form>
<iframe src="../Shared/empty.html" name="hidFrameSubmit" style="display:none"></iframe>
</div>
</body>
</html>
