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

    File:           fac_edit_bookmark.asp
    Description:    show detailed information of an bookmark

    Parameters:     bkm_key

    Context:
    Note:

*/ %>
<!-- #include file="../Shared/common.inc"-->
<!-- #include file="../Shared/iface.inc"-->
<!-- #include file="../Shared/persoonselector.inc" -->
<!-- #include file="../fac/fac.inc" -->

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

// Autorisatie
var authparamsPRSSYS = user.checkAutorisation("WEB_PRSSYS");

var bkm_id = getQParam("bkm_id", "");
var bkm_path ;
var bkm_query;
var bkm_naam;
var bkm_aanmaak;
var bkm_prskey;
var bkm_prskey_auth;
var bkm_unauth_url;
var bkm_refresh

if (bkm_id != "")
{
  var sql = "SELECT fac_bookmark_path"
          + "     , fac_bookmark_query"
          + "     , fac_bookmark_naam"
          + "     , fac_bookmark_aanmaak"
          + "     , prs_perslid_key_auth"
          + "     , fac_bookmark_unauth_url"
          + "     , fac_bookmark_refreshtime"
          + "     , prs_perslid_key"
          + "  FROM fac_bookmark"
          + " WHERE fac_bookmark_id = " + safe.quoted_sql(bkm_id);
  var oRs = Oracle.Execute(sql);

  bkm_path = oRs("fac_bookmark_path").value;
  bkm_query = oRs("fac_bookmark_query").value;
  bkm_naam = oRs("fac_bookmark_naam").value;
  bkm_aanmaak = oRs("fac_bookmark_aanmaak").value;
  bkm_prskey_auth = oRs("prs_perslid_key_auth").value;
  bkm_unauth_url = oRs("fac_bookmark_unauth_url").value;
  bkm_refresh = oRs("fac_bookmark_refreshtime").value;
  bkm_prskey = oRs("prs_perslid_key").value;
  oRs.close();
}
else
{
  bkm_aanmaak = new Date();
  bkm_prskey = user_key;
}
%>

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

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

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

    IFRAMER_HEADER(L("lcl_fac_bookmark"), buttons);
%>
      <form name="u2"
            action="fac_edit_bookmark_save.asp"
            method="post"
            target="hidFrameSubmit">
        <input type=hidden name="bkm_id" value="<%=safe.htmlattr(bkm_id)%>">
<%
        BLOCK_START("facInfo", L("lcl_fac_bookmark"), {icon: "fa-bookmark"});
        ROFIELDTR("fld", L("lcl_fac_bookmarkid"), bkm_id);
        RWFIELDTR("naam", "fld", L("lcl_fac_bookmark"), bkm_naam, { required: true, maxlength: 60 });
        RWFIELDTR("path", "fld", L("lcl_fac_bookmarkpath"), bkm_path, { required: true, maxlength: 1000 });
        RWFIELDTR("query", "fld", L("lcl_fac_bookmarkquery"), bkm_query, { maxlength: 1000 });
        RWFIELDTR("prskey_auth", "fld", L("lcl_bkm_prskey_auth"), bkm_prskey_auth);
        RWFIELDTR("unauth_url", "fld", L("lcl_bkm_unauth"), bkm_unauth_url, { maxlength: 1000 });
        RWFIELDTR("refresh", "fld", L("lcl_bkm_refresh"), bkm_refresh);

        FCLTpersoonselector("perslid_key",
                            "sgPers",
                            { perslidKey: bkm_id != ""? bkm_prskey : user_key,
                              label: L("lcl_fac_eigenaar"),
                              moreinfo: true,
                              readonly: true
                            });
        ROFIELDTR("flddatetime", L("lcl_fac_bookmarkcreate"), toDateTimeString(bkm_aanmaak));
        BLOCK_END();
IFACE.FORM_END();
%>
      </form>
      <% SUBFRAME_END(); %>
      <iframe src="../Shared/empty.html" name="hidFrameSubmit" style="display:none"></iframe>
  </body>
</html>
<% ASPPAGE_END(); %>
