<%@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/calendar.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 ins_score_enabled = S("ins_score_enabled") == 1;
var loc_key  = getQParamInt("loc_key", -1);

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 loc_image  = oRs("alg_locatie_image").Value;
    var loc_volgnr = oRs("alg_locatie_volgnr").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;
    var loc_score1 = oRs("alg_locatie_mjb_score1").Value;
    var vervaldatum = oRs("alg_locatie_vervaldatum").Value != null ? new Date(oRs("alg_locatie_vervaldatum").Value) : null;

    oRs.Close();
}
%>

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

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

<body class="editmode">
<% SUBFRAME_START(); %>
<%
  var buttons =  [ {title: L("lcl_submit"), action:"alg_submit()", icon: "fa-fclt-save" },
                   {title: L("lcl_cancel"), action:"alg_cancel()", icon: "fa-fclt-cancel" } ];
  IFRAMER_HEADER(L("lcl_alg_locatie_frame"), buttons);
%>
<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", L("lcl_location"), {icon: "fa-location-arrow"});

      FCLTplaatsselector(this_alg.authparams("WEB_ALGMAN").ALGwritelevel, {
          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});
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", L("lcl_fac_adres_postblock"), {icon: "fa-envelope-open"});
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});
BLOCK_END();

BLOCK_START("facFM", L("lcl_operations_block"), {icon: "fa-users-cog"});
manRWFIELD("loc_volgnr", "fld", L("lcl_alg_locatie_volgnr"), loc_volgnr, {maxlength: 3});
FCLTcalendar("vervaldatum",
             { datum: vervaldatum,
               initEmpty: vervaldatum==null,
               label: L("lcl_alg_vervaldatum"),
               readonly: !this_alg.writeman
             });

  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_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: 20});
manRWFIELD("loc_mail",   "fld", L("lcl_alg_locatie_email"), loc_mail,   {maxlength: 200});
FILEPICKERTR("loc_image", L("lcl_alg_locatie_image"), loc_image, { "key": loc_key, "module": "ALGPHL", "readonly": !this_alg.writeman });

if (ins_score_enabled)
  ROFIELDTR("fld",          L("lcl_alg_locatie_mjb_score1"), loc_score1, {suppressEmpty: true});

BLOCK_END();

generateFlexKenmerkBlock ({
     onrgoed_key    : loc_key,
     onrgoed_niveau : onrgoedlvl,
     reado          : false,
     this_alg       : this_alg
});
IFACE.FORM_END();
%>
</form>
<iframe src="../Shared/empty.html" name="hidFrameSubmit" style="display:none"></iframe>
<% SUBFRAME_END(); %>
</body>
</html>
<% ASPPAGE_END(); %>
