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

    File:         alg_edit_locatie.asp
    Description:  edit locatie gegevens
    Parameters:   loc_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","kenmerk"], js: []})

var loc_key  = getQParamInt("loc_key", -1);
var dis_key

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

if (loc_key > 0)
{
    sql = " select * "
        + "  FROM ALG_LOCATIE "
        + " WHERE alg_locatie_key = " + loc_key;

    oRs = Oracle.Execute(sql);

    var loc_omsch  = oRs("alg_locatie_omschrijving").value;
    var loc_code   = oRs("alg_locatie_code").value;
    var bez_adres  = oRs("alg_locatie_adres").value;
    var bez_postc  = oRs("alg_locatie_postcode").value;
    var bez_plaats = oRs("alg_locatie_plaats").value
    var bez_land   = oRs("alg_locatie_land").value;
    var loc_vw     = oRs("alg_locatie_verantw").value;
    var loc_vwtel  = oRs("alg_locatie_verantw_tel").value;
    var loc_x      = oRs("alg_locatie_x").value;
    var loc_y      = oRs("alg_locatie_y").value;
    var loc_mail   = oRs("alg_locatie_email").value;
    var pst_adres  = oRs("alg_locatie_post_adres").value;
    var pst_postc  = oRs("alg_locatie_post_postcode").value;
    var pst_adres  = oRs("alg_locatie_post_adres").value;
    var pst_plaats = oRs("alg_locatie_post_plaats").value;
    var pst_land   = oRs("alg_locatie_post_land").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_locatie_frame"), buttons);
%>
<div id="edit">
<form name="u2"
      action="alg_edit_locatie_save.asp?loc_key=<%=loc_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", "&nbsp;");
      FCLTplaatsselector(this_alg.authparams("WEB_ALGMAN").ALGwritelevel, {
          districtkey: dis_key,
          locatiekey: loc_key,
          startlevel: 1, //District
          eindlevel: 1, // District
          readonly: !this_alg.writeman,
          required: true });

manRWFIELD("loc_omsch",  "fld",          L("lcl_estate_locatie_man_descr"),        loc_omsch, {required: true, maxlength: 60});
manRWFIELD("loc_code",  "fld",          L("lcl_estate_locatie_man_code"),        loc_code, {required: true, maxlength: 10});
manRWFIELD("bez_adres",  "fld",          L("lcl_prs_address_bezoek_adres"),        bez_adres, {maxlength: 50});
manRWFIELD("bez_postc",  "fld",          L("lcl_prs_address_bezoek_postcode"),        bez_postc, {maxlength: 12});
manRWFIELD("bez_plaats",  "fld",          L("lcl_prs_address_bezoek_plaats"),        bez_plaats, {maxlength: 30});
manRWFIELD("bez_land",  "fld",          L("lcl_prs_address_bezoek_land"),        bez_land, {maxlength: 30});

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

manRWFIELD("loc_x",  "fld",          L("lcl_geoxcoord"),        loc_x, {maxlength: 25});
manRWFIELD("loc_y",  "fld",          L("lcl_geoycoord"),        loc_y, {maxlength: 25});

BLOCK_END();
BLOCK_START("algLoc2", "&nbsp;");

manRWFIELD("pst_adres",  "fld",          L("lcl_prs_address_post_adres"),        pst_adres, {maxlength: 50});
manRWFIELD("pst_postc",  "fld",          L("lcl_prs_address_post_postcode"),        pst_postc, {maxlength: 12});
manRWFIELD("pst_plaats",  "fld",          L("lcl_prs_address_post_plaats"),        pst_plaats, {maxlength: 30});
manRWFIELD("pst_land",  "fld",          L("lcl_prs_address_post_land"),        pst_land, {maxlength: 30});
manRWFIELD("loc_vw",  "fld",          L("lcl_estate_locatie_man_verantw"),        loc_vw, {maxlength: 30});
manRWFIELD("loc_vwtel",  "fld",          L("lcl_estate_locatie_man_verantw_tel"),        loc_vwtel, {maxlength: 15});
manRWFIELD("loc_mail",  "fld",          L("lcl_noti_email"),        loc_mail, {maxlength: 200});

BLOCK_END();

generateFlexKenmerkBlock ({
     onrgoed_key    : loc_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>
