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

    File:           prs_edit_perslid.asp
    Description:    edit or add persons
    Parameters:     prs_key (required)

    Context:
    Note:           De meeste kenmerken mag je alleen bewerken als de WEB_PRSMAN hebt
                    Sommige echter ook als je WEB_PRSUSE hebt.
                    OSLOGIN mag alleen als je WEB_PRSSYS hebt.
                    Tenslotte mag je als je PROFIL hebt voor jezelf hetzelfde als PRSUSE

*/ %>
<!-- #include file="../Shared/common.inc" -->
<!-- #include file="../Shared/iface.inc" -->
<!-- #include file="../Shared/persoonselector.inc" -->
<!-- #include file="../Shared/selector.inc" -->
<!-- #include file="../Shared/afdelingselector.inc" -->
<!-- #include file="../Shared/kostenplaatsselector.inc" -->
<!-- #include file="../Shared/functieselector.inc" -->
<!-- #include file="../Shared/timezoneselector.inc" -->
<!-- #include file="../Shared/adresselector.inc" -->
<!-- #include file="../Shared/calendar.inc"-->
<!-- #include file="../API2/api2.inc" -->
<!-- #include file="prs_flexkenmerk.inc" -->
<!-- #include file="prs.inc"-->

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

var prs_key  = getQParamInt("prs_key", -1);

var prsauthparams = prs.checkAutorisation(prs_key);
user.auth_required_or_abort(prsauthparams.writeman || prsauthparams.writeuse || prsauthparams.writeself);

var authparamsUSEMAN = user.checkAutorisation(["WEB_PRSUSE", "WEB_PRSMAN"], true);

if (prs_key > 0)
    var thisUser = new Perslid(prs_key); // geeft ook handige informatie

var startEmpty = 1;
var endEmpty = 1;

//   if (!alg.canWriteRuimte(room_key, authparams.mALGreadlevel))
//     user.auth_required_or_abort(false);
var prs_flags  = 0;
if (prs_key > -1)
{
  sql = "SELECT p.prs_perslid_key, "
      + "       prs_srtperslid_key, "
      + "       p.prs_afdeling_key, "
      + "       p.prs_kostenplaats_key, "
      + "       prs_perslid_naam, "
      + "       prs_perslid_geslacht, "
      + "       prs_perslid_voorletters, "
      + "       prs_perslid_voornaam, "
      + "       prs_perslid_titel, "
      + "       prs_perslid_initialen, "
      + "       prs_perslid_nr, "
      + "       prs_perslid_dienstverband, "
      + "       prs_perslid_opp, "
      + "       p.mld_adres_key, "
      + "       prs_perslid_uurloon, "
      + "       prs_perslid_telefoonnr, "
      + "       prs_perslid_lang, "
      + "       prs_perslid_oslogin, "
      + "       prs_perslid_oslogin2, "
      + "       prs_perslid_opmerking, "
      + "       prs_perslid_apikey, "
      + "       prs_perslid_systeemadres, "
      + "       prs_perslid_flags, "
      + "       prs_perslid_loglevel, "
      + "       prs_perslid_errorhandling, "
      + "       prs_perslid_ingangsdatum, "
      + "       prs_perslid_einddatum, "
      + "       d.prs_bedrijf_key, "
      + "       prs_perslid_tussenvoegsel, "
      + "       fac_profiel_key, "
      + "       prs_perslid_email, "
      + "       prs_perslid_timezone, "
      + "       prs_perslid_lcid, "
      + "       prs_perslid_mobiel, "
      + "       prs_perslid_ingids, "
      + "       prs_perslid_visibility, "
      + "       prs_perslid_inactief, "
      + "       p.prs_perslid_key_verantw"
      + "  FROM prs_perslid p, "
      + "       prs_afdeling d "
      + " WHERE p.prs_perslid_key = " + prs_key
      + "   AND p.prs_afdeling_key = d.prs_afdeling_key "
      + "   AND p.prs_perslid_verwijder IS NULL";

  oRs = Oracle.Execute(sql);
  if (!oRs.eof) {
    var prs_srtkey = oRs("prs_srtperslid_key").value;
    var prs_afdkey = oRs("prs_afdeling_key").value;
    var prs_kplkey = oRs("prs_kostenplaats_key").Value;
    var prs_naam   = oRs("prs_perslid_naam").value;
    var prs_vltr   = oRs("prs_perslid_voorletters").value;
    var prs_vrnaam = oRs("prs_perslid_voornaam").value;
    var prs_titel  = oRs("prs_perslid_titel").value;
    var prs_ini    = oRs("prs_perslid_initialen").value;
    var prs_nr     = oRs("prs_perslid_nr").value;
    var prs_dnst   = oRs("prs_perslid_dienstverband").value;
    var prs_opp    = oRs("prs_perslid_opp").value;
    var mld_adrkey = oRs("mld_adres_key").value;
    var prs_uurln  = oRs("prs_perslid_uurloon").value;
    var prs_telnr  = oRs("prs_perslid_telefoonnr").value;
    var prs_lang   = oRs("prs_perslid_lang").value;
    var prs_oslog  = oRs("prs_perslid_oslogin").value;
    var prs_oslog2 = oRs("prs_perslid_oslogin2").value;
    var prs_opm    = oRs("prs_perslid_opmerking").value;
    var prs_apikey = oRs("prs_perslid_apikey").value;
    var prs_ingdat = oRs("prs_perslid_ingangsdatum").value;
    var prs_systeem= oRs("prs_perslid_systeemadres").value;
    var prs_flags  = oRs("prs_perslid_flags").value;
    var prs_loglevel= oRs("prs_perslid_loglevel").value;
    var prs_errorhandling= oRs("prs_perslid_errorhandling").value;
    var prs_enddat = oRs("prs_perslid_einddatum").value;
    var prs_bdrkey = oRs("prs_bedrijf_key").value;
    var prs_geslacht = oRs("prs_perslid_geslacht").value;
    var prs_tussen = oRs("prs_perslid_tussenvoegsel").value;
    var fac_prkey  = oRs("fac_profiel_key").value;
    var prs_email  = oRs("prs_perslid_email").value;
    var prs_tz     = oRs("prs_perslid_timezone").value;
    var prs_lcid   = oRs("prs_perslid_lcid").value;
    var prs_mobiel = oRs("prs_perslid_mobiel").value;
    var prs_bdrkey = oRs("prs_bedrijf_key").value;
    var ingids     = oRs("prs_perslid_ingids").value == 1;
    var visibility = oRs("prs_perslid_visibility").value;
    var prs_inactief_datum = (oRs("prs_perslid_inactief").Value != null ? new Date(oRs("prs_perslid_inactief").Value) : null);
    var verantw_key = oRs("prs_perslid_key_verantw").value;
  } else {
      shared.record_not_found("<!--"+prs_key+"-->");
  }
  oRs.Close();

  if (prs_ingdat != null)
  {
    prs_ingdat = new Date(prs_ingdat);
    startEmpty = 0;
  }

  if (prs_enddat != null)
  {
    prs_enddat = new Date(prs_enddat);
    endEmpty = 0;
  }
}
else // nieuw
{
    ingids = true;
    var prs_srtkey = getQParamInt("prs_srtkey", -1);
}
%>
<html>
  <head>
<%
    FCLTHeader.Generate();
    // TODO: moet hier niet prs.checkAutorisation gebruikt worden?
    //       Die is er beter tegen bestand dat prs_key misschien null is?
    var xfunc = user.func_enabled("*", null, null, prs_key>0?prs_key:null);
%>
    <script type="text/javascript">
      async function prs_submit()
      {
          if (!await validateForm("u2"))
              return false;
          $.post($("form[name=u2]")[0].action, $("[name=u2]").serialize(), FcltCallbackClose, "json");
      }

      function prs_cancel()
      {
          FcltMgr.closeDetail(window, { cancel: true } );
      }

      function prs_perslid_apikey()
      {
        var url = "../../appl/prs/prs_perslid_apikey.asp?prs_key=<%=prs_key%>";
        FcltMgr.openModalDetail(url, L("lcl_prs_apiuser"), {callback: FcltCallbackRefresh});
      }

<% if (prs_key > 0) { %>
      function edit_werklocatie()
      {
          FcltMgr.openModalDetail("../../appl/prs/prs_move_huidigewerkplek.asp?prs_key=<%=prs_key%>");
      }

      function edit_photo(img)
      {
          var url = "<%=protectQS.create("../../appl/shared/BijlagenForm.asp?module=SML&key="+prs_key)%>";
          FcltMgr.openModalDetail(url, L("lcl_prs_upload_foto"),
                      { callback: FcltMgr.reload } );
      }

<% } %>
    </script>
  </head>

  <body class="editmode">
<%
    SUBFRAME_START();
    var buttons =  [ {title: L("lcl_submit"), action:"prs_submit()", icon: "fa-fclt-save" },
                     {title: L("lcl_cancel"), action:"prs_cancel()", icon: "fa-fclt-cancel" }];

    IFRAMER_HEADER(L("lcl_prs_persoon_frame"), buttons);
%>
<form name="u2"
      action="prs_edit_perslid_save.asp?prs_key=<%=prs_key%>"
      method="post"
      target="hidFrameSubmit"
      onSubmit="prs_submit();">
<%
// 4i uitstapjes naar werkplekken en verplichtingen zijn als direct frame in prs_perslid.asp gerealiseerd
if (prsauthparams.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

if ((prsauthparams.writeself || prsauthparams.writeuse) && S("prs_telefoonnr_aut_use")==1) // dan mag USE er ook een paar
    useRWFIELD = RWFIELDTR;
else
    useRWFIELD = manRWFIELD

var btns = [];
if (prs_key > 0)
{
    // Fast check to see if we have anything to do with geographics, else do nothing at all
    var sql= "SELECT 1 FROM alg_locatie WHERE alg_locatie_verwijder IS NULL AND (alg_locatie_vervaldatum > SYSDATE OR alg_locatie_vervaldatum IS NULL) AND ROWNUM = 1";
    var oRs = Oracle.Execute(sql);
    var anygeo = !oRs.eof;
    oRs.close();

    if ((prsauthparams.writeself || prsauthparams.writeuse) && anygeo)
        btns.push({icon: "fa-fclt-edit", title: L("lcl_prs_work_location"), action: "edit_werklocatie()", importance: 2});
}

BLOCK_START("prsPerslid", L("lcl_prs_basisblok"), {buttons: btns, icon: "fa-id-card-alt"});
  if (prs_key > 0) // Fotoblokje alleen bij bestaande records
  {
      Response.write("<tr>"
                    +"  <td style='text-align: right'></td>"
                    +"  <td class='profile'>"
                    +"    <span class='wrapper-span'>"
                    +"      <img id='photo' alt='" + safe.htmlattr(L("fac_profiel")) + " " + safe.htmlattr(L("lcl_photos")) + "' style='cursor: pointer' class='profile' "
                    +           (prsauthparams.writeuse ? "onclick='edit_photo(this)'" : "") + " src='" + safe.htmlattr(thisUser.photoinfo().photopaththumb) + "'>"
                    +       (prsauthparams.writeuse ? "<span class='image-edit' title='" + L("lcl_change") + "' onclick='edit_photo(this)'>" + I("fa-fclt-edit") + "</span>" : "")
                    +"    </span>"
                    +"  </td>"
                    +"</tr>");
  }
  manRWFIELD("prs_naam",  "fld",          L("lcl_prs_person_achternaam"),        prs_naam, {required: true, maxlength: 60});
  var sql = "SELECT  0, "+safe.quoted_sql(L("lcl_prs_person_geslachtV"))+" FROM DUAL UNION ALL"
          + " SELECT 1, "+safe.quoted_sql(L("lcl_prs_person_geslachtM"))+" FROM DUAL UNION ALL"
          + " SELECT 9, "+safe.quoted_sql(L("lcl_prs_person_geslachtX"))+" FROM DUAL";
  FCLTselector("prs_geslacht", sql,
               { label: L("lcl_prs_person_geslacht"),
                 initKey: prs_key > -1? prs_geslacht : null, // Bij een nieuwe melding dan moet de eerste ("Onbekend") genomen worden.
                 emptyKey: "",
                 emptyOption: L("lcl_prs_person_geslachtO"),
                 readonly: !prsauthparams.writeman,
                 suppressEmpty: true
              });

  manRWFIELD("prs_tussen","fldshort",     L("lcl_prs_person_tussen"),      prs_tussen, {maxlength: 15, suppressEmpty: true});
  manRWFIELD("prs_vltr",  "fldshort",     L("lcl_prs_person_voorletters"), prs_vltr, {maxlength: 15, suppressEmpty: true});
  manRWFIELD("prs_vrnaam","fld",          L("lcl_prs_person_voornaam"),    prs_vrnaam, {maxlength: 30, suppressEmpty: true});
  manRWFIELD("prs_titel", "fldshort",     L("lcl_prs_person_title"),       prs_titel, {maxlength: 15, suppressEmpty: true});
  manRWFIELD("prs_ini",   "fldshort",     L("lcl_prs_person_initials"),    prs_ini, {maxlength: 10, suppressEmpty: true});

  if (S("prs_hide_fixed_fields") == 0 )
  {
      useRWFIELD("prs_telnr",  "fld",     L("lcl_prs_person_phone"),       prs_telnr, {maxlength: 20, suppressEmpty: true});
      useRWFIELD("prs_mobiel", "fld",     L("lcl_prs_person_mobile"),      prs_mobiel, {maxlength: 20, suppressEmpty: true});
      manRWFIELD("prs_email",  "fld",     L("lcl_prs_person_email"),       prs_email, {maxlength: 200, suppressEmpty: true});
  }

  var sql = "SELECT  0, "+safe.quoted_sql(L("lcl_prs_perslid_visibility0"))+" FROM DUAL UNION ALL"
          + " SELECT 1, "+safe.quoted_sql(L("lcl_prs_perslid_visibility1"))+" FROM DUAL";
  FCLTselector("prs_visibility", sql,
               { label: L("lcl_prs_person_visibility"),
                 initKey: visibility,
                 readonly: !(prsauthparams.writeself || prsauthparams.writeuse)
              });
  // logingegevens
  if (prsauthparams.writesys || (S("prs_mgt_edit_login") && xfunc.canWrite("WEB_FACMGT")))
  {
      // usernames van core-personen mag alleen FACFAC eventueel wijzigen
      // vraag me zelfs af of je die uberhaupt moet tonen, maar toe maar
      if (prs_oslog && (prs_flags&32)==32 && !user.has("WEB_FACFAC"))
      {
          ROFIELDTR("fld", L("lcl_prs_person_login"), prs_oslog, {suppressEmpty: true});
          ROFIELDTR("fld", L("lcl_prs_person_login2"), prs_oslog2, {suppressEmpty: true});
      }
      else
      {
          RWFIELDTR("prs_oslog",  "fld",     L("lcl_prs_person_login"),       prs_oslog, {maxlength: 256});
          RWFIELDTR("prs_oslog2",  "fld",    L("lcl_prs_person_login2"),      prs_oslog2, {maxlength: 256});
      }
  }
  if (prs_key > -1) {
    ROFIELDTR("fld", L("prs_perslid_inactief"), toDateTimeString(prs_inactief_datum), {suppressEmpty: true});
  }
  if (prsauthparams.writesys)
    RWTEXTAREATR("prs_opm",  "fldtxt", L("lcl_prs_person_opmerking"), prs_opm, {maxlength: 320});
  else
    ROTEXTAREATR("fld", L("lcl_prs_person_opmerking"), prs_opm);
  if (prs_key > 0)
  {
    var thisPrs = prs.prs_perslid(prs_key, { withWL: true }); // geeft ook alle informatie
    var wl = thisPrs.werklocatie.alg_locatie_key ? thisPrs.werklocatie.aanduiding : "";

    if (!prsauthparams.writeself&& !prsauthparams.writeuse)
      ROFIELDTR("fld", L("lcl_prs_work_location"), wl, {suppressEmpty: true});
  }
BLOCK_END();

if (prs_key > 0 && prsauthparams.writesys)
{
  BLOCK_START("prsTech", L("lcl_prs_techblok"), {icon: "fa-cogs"});
      var rwparams = { datatype: "button",
                        html: "onclick='prs_perslid_apikey()'",
                        endicon: "fa-hand-point-left",
                        trid: "tr_prs_gen_apikey"
                      };
      RWFIELDTR("prs_apikey_button", "button", L("lcl_prs_apiuser"), L("lcl_prs_generate_apikey"), rwparams);
      ROFIELDTR("fld", "", prs_apikey, {readonly: true, maxlength: 64, trhidden: prs_apikey == null});
      CHECKBOXTR(L("prs_perslid_errorhandling"), "flderrorhandling", "prs_errorhandling", prs_errorhandling );
      if (prsauthparams.writetab)
      {
          // documentatie prs_perslid_flags in appl/shared/user.inc
          // Zou graag een listbox hebben, maar er kunnen meerdere bits gecombineerd worden
          RWFIELDTR("prs_systeemadres", "fld", L("lcl_prs_systeemadres"),prs_systeem, {maxlength: 200});
          // EenVan een coresysteemuser (&32) mag de flags niet aanpassen, nooit.
          if ((prs_flags&32)==32)
              ROFIELDTR("fld", L("lcl_prs_flags"), L("lcl_prs_flags_undeletable"));
          else
          {
              //RWFIELDTR("prs_flags",    "fld", L("lcl_prs_flagscode"),   prs_flags,  {required: true, datatype: "number", readonly: true });
              %>
                <input type="hidden" name="prs_flags" id="prs_flags" value="<%= prs_flags %>"
              <%
              /*** Bit-constants ***/
              var FLAGS = {
                SYSTEM:          1 << 0,  // 1
                UNAPPROVED:      1 << 1,  // 2
                GROUPED:         1 << 2,  // 4
                BLOCKED:         1 << 3,  // 8
                API2_WRITEONLY:  1 << 4  // 16
                //UNDELETABLE:     1 << 5   // 32
              };
              function hasFlag(value, bit) { return (value & bit) === bit; }
              // 2) Jullie eigen checkbox-rijen (RWCHECKBOXTR) per bit
              //    Let vooral op de unieke "pname" (ID) — die gebruiken we in JS om te mappen naar de bitwaarde.
              RWCHECKBOXTR("flag_system", "", L("lcl_prs_flags_system"), hasFlag(prs_flags, FLAGS.SYSTEM), {});
              RWCHECKBOXTR("flag_unapproved", "", L("lcl_prs_flags_unapproved"), hasFlag(prs_flags, FLAGS.UNAPPROVED), {});
              RWCHECKBOXTR("flag_grouped", "", L("lcl_prs_flags_grouped"), hasFlag(prs_flags, FLAGS.GROUPED), {});
              //RWCHECKBOXTR("flag_blocked", "", L("lcl_prs_flags_blocked"), hasFlag(prs_flags, FLAGS.BLOCKED), {});
              //RWCHECKBOXTR("flag_api2writeonly", "", L("lcl_prs_flags_api2writeonly"), hasFlag(prs_flags, FLAGS.API2_WRITEONLY), {});
              %>

              <!-- 3) Klein JS: zet aangevinkte checkboxes om naar een decimale bitmask in het hidden veld -->
              <script type="text/javascript">
              (function(){
                // Map checkbox-ID => bitwaarde
                var BITMAP = {
                  "flag_system":        <%= FLAGS.SYSTEM %>,
                  "flag_unapproved":    <%= FLAGS.UNAPPROVED %>,
                  "flag_grouped":       <%= FLAGS.GROUPED %>,
                  "flag_blocked":       <%= FLAGS.BLOCKED %>,
                  "flag_api2writeonly": <%= FLAGS.API2_WRITEONLY %>
                };

                function recalc() {
                  var v = 0, id, el;
                  for (id in BITMAP) {
                    if (!Object.prototype.hasOwnProperty.call(BITMAP, id)) continue;
                    el = document.getElementById(id);
                    if (el && el.checked) v |= BITMAP[id];
                  }
                  var hidden = document.getElementById("prs_flags");
                  if (hidden) hidden.value = String(v);
                }

                // Bind aan wijzigingen + vóór submit
                for (var id in BITMAP) {
                  if (!Object.prototype.hasOwnProperty.call(BITMAP, id)) continue;
                  var el = document.getElementById(id);
                  if (el) el.addEventListener("change", recalc);
                }
                var form = document.getElementByName("u2");
                if (form) form.addEventListener("submit", recalc);

                // Initiele sync (als prs_flags != 0)
                recalc();
              })();
              </script>
              <%
          }
      }
      if (user.has("WEB_FACFAC"))
      {
          CHECKBOXTR(L("prs_perslid_loglevel"), "fldloglevel", "prs_loglevel", prs_loglevel );
      }
  BLOCK_END();
}

BLOCK_START("prsPerslid2", L("lcl_prs_organisatieblok"), {icon: "fa-address-card"});
    if (prsauthparams.writeuse)
      CHECKBOXTR(L("lcl_prs_in_guide"), "fld", "ingids", ingids);
    manRWFIELD("prs_nr",  "fld", L("lcl_prs_person_nr"),        prs_nr, {suppressEmpty: true});

    FCLTafdelingselector("prs_afdkey",
                         "prs_afdkey",
                        { departmentKey: prs_afdkey,
                          label: L("lcl_prs_organisatie"),
                          autlevel: prsauthparams.PRSreadlevel, // Was voorheen niet aanwezig
                          readonly: !prsauthparams.writeman,
                          required: true
                       });

    FCLTfunctieselector("prs_srtkey", "prs_srtkey" ,
                            {label: L("lcl_prs_person_function"),
                             srtperslidKey: prs_srtkey,
                             emptyOption: "",
                             readonly: !prsauthparams.writeman,
                             required: true
                            });

    if (authparamsUSEMAN)
      FCLTpersoonselector("prs_verantwkey",
                          "prs_verantwkey",
                          { label: L("lcl_prs_person_verantw"),
                            perslidKey: verantw_key,
                            autlevel: authparamsUSEMAN.PRSwritelevel // Personen scope op basis van de PRSUSE/PRSMAN rechten.
                          });

    FCLTkostenplaatsselector("prs_kplkey",
                             "prs_kplkey",
                             user_key,
                             { label: L("prs_kostenplaats"),
                               kostenplaatsKey: prs_kplkey,
                               filtercode: "A", // Laat alle kostenplaatsen zien, negeer mandatering.
                               readonly: !prsauthparams.writeman,
                               suppressEmpty: !prsauthparams.writeman // als readonly
                             });

    manRWFIELD("prs_opp",  "fldshort", L("lcl_prs_person_opp"),           prs_opp, {maxlength: 10, datatype: "float", suppressEmpty: true});
    manRWFIELD("prs_dnst", "fldshort", L("lcl_prs_person_dienstverband"), prs_dnst, {maxlength: 5, datatype: "float", suppressEmpty: true});

    if (S("prs_perslid_datums") == 1)
    {
        FCLTcalendar( "prs_ingdat",
                    { label  : L("lcl_prs_person_ingangsdatum"),
                      datum  : prs_ingdat,
                      readonly: !prsauthparams.writeman,
                      required: true
                    });


        FCLTcalendar( "prs_enddat",
                    { label  : L("lcl_prs_person_einddatum"),
                      datum  : prs_enddat,
                      readonly: !prsauthparams.writeman,
                      initEmpty: endEmpty
                    });
    }

    sql = "SELECT   fac_profiel_key, "
        + "         fac_profiel_omschrijving "
        + "    FROM fac_profiel "
        + "ORDER BY 2 "

    FCLTselector("fac_prkey", sql,
                { label: L("lcl_prs_profile"),
                  initKey: fac_prkey,
                  emptyOption: "",
                  suppressEmpty: true,
                  readonly: !prsauthparams.writeman
               });
    FCLTadresselector("mld_adrkey", "sgAdres",
                {
                   label: L("lcl_delivery_address"),
                   adresKey:  mld_adrkey,
                   emptyOption: "",
                   filtercode: "A",
                   suppressEmpty: true,
                   readonly: !prsauthparams.writeman
                }) ;

if (S("prs_hide_fixed_fields") == 0 ) {
    manRWFIELD("prs_uurln", "fldshort", L("lcl_prs_person_uurloon"), prs_uurln, {suppressEmpty: true, maxlength: 8, datatype: "currency"});
}
BLOCK_END();

BLOCK_START("prsRegion", L("lcl_prs_regionalblok"), {icon: "fa-globe-stand"});
    if (S("language_toggles").length > 1)
    {
        var sql = "";
        for (var i=0; i<S("language_toggles").length; i++)
        {
            sql += (i>0 ? " UNION " : "") + "SELECT "+safe.quoted_sql(S("language_toggles")[i])+","+safe.quoted_sql(S("language_toggles")[i])+" FROM DUAL";
        }
        FCLTselector("prs_lang", sql,
                   { label: L("lcl_lcl_taal"),
                     initKey: prs_lang,
                     emptyOption: ""
                   });
    }

    sql = api2.splitLOV2sql(L("lcl_prs_person_lcidLOV"));
    FCLTselector("prs_lcid", sql,
              { label: L("lcl_prs_person_lcid"),
                initKey: prs_lcid,
                emptyKey: '',
                emptyOption: ''
              });
    FCLTtimezoneselector("prs_tz", { initVal: prs_tz });

BLOCK_END();

// ============================= NOTIFICATIES ========================================
// Kan de gebruiker uberhaubt *iets* overrulen? Zo nee dan ook geen vinkjes tonen
var notis = prs.check4notis();

if (prs_key > 0 && (prs_key == user_key || prsauthparams.writesys || prsauthparams.writeman) && notis.canany  )
{
  BLOCK_START("prsNoti", L("lcl_noti_prsvoorkeur"), { icon: "fa-bell-on"} );
    CHECKBOXTR(L("lcl_noti_niks"), "fldfacnoti", "noti0", thisUser.noti_niks());
    if (notis.can1) CHECKBOXTR(L("lcl_noti_portal"), "fldfacnoti", "noti1", thisUser.noti_portal());
    if (notis.can2) CHECKBOXTR(L("lcl_noti_email"),  "fldfacnoti", "noti2", thisUser.noti_email());
    if (notis.can4) CHECKBOXTR(L("lcl_noti_sms"),    "fldfacnoti", "noti4", thisUser.noti_sms());
    if (notis.can8) CHECKBOXTR(L("lcl_noti_popup"),  "fldfacnoti", "noti8", thisUser.noti_popup());
  BLOCK_END();
}

%><div id='prsFlex' class='prsFlex'></div><%
  generateFlexKenmerkCode ({
     link_key       : prs_key,
     srt_key        : prs_srtkey,
     niveau         : "P",
     reado          : false,
     prsauthparams  : prsauthparams
});
IFACE.FORM_END();
%>
</form>
<% SUBFRAME_END(); %>
<iframe src="../Shared/empty.html" name="hidFrameSubmit" style="display:none"></iframe>
</body>
</html>
<% ASPPAGE_END(); %>
