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

    File:           fac_show_bookmark.asp
    Description:    show detailed information of a bookmark

    Parameters:     bkm_id (bookmark id)

    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"],
                           js: ["jquery-ui.js"]
                          })

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

var bkm_id = getQParam("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);
if (oRs.Eof)
    shared.record_not_found();

var bkm_path = oRs("fac_bookmark_path").value;
var bkm_query = oRs("fac_bookmark_query").value;
var bkm_naam = oRs("fac_bookmark_naam").value;
var bkm_aanmaak = oRs("fac_bookmark_aanmaak").value;
var bkm_prskey_auth = oRs("prs_perslid_key_auth").value;
var bkm_unauth_url = oRs("fac_bookmark_unauth_url").value;
var bkm_refresh = oRs("fac_bookmark_refreshtime").value;
var bkm_prskey = oRs("prs_perslid_key").value;
oRs.close();
%>

<html>
  <head>
<%  FCLTHeader.Generate(); %>
    <script type="text/javascript">
      function bkm_print()
      {
        var url = "../fac/fac_print_qrcode.asp?bkm_id=<%=safe.jsstring(bkm_id)%>";
        FcltMgr.openModalDetail(url, L("lcl_fac_qrcode"));
      }

      function bkm_change()
      {
        if (FcltMgr.startEdit(window))
          window.location.href = "fac_edit_bookmark.asp?bkm_id=<%=safe.jsstring(bkm_id)%>";
      }

      function bkm_delete()
      {
        FcltMgr.confirm(L("lcl_R_U_sure"), function() {
            var data = {
                key: "<%=safe.jsstring(bkm_id)%>",
                level: "BM"
            };
            <% protectRequest.dataToken("data"); %>
            $.post("fac_delete.asp",
                data,
                FcltCallbackClose,
                "json");
        });
      }
    </script>
  </head>
  <body class="showmode">
<%  SUBFRAME_START();
    var buttons = [];
    if (authparamsPRSSYS.PRSwritelevel < 9 && authparamsPRSSYS.ALGwritelevel < 9)
    {
      var buttons =  [ {title: L("lcl_change"), action: "bkm_change()", icon: "fa-fclt-edit" },
                       {title: L("lcl_delete"), action: "bkm_delete()", icon: "fa-trash-alt" }
                     ];
    }
    buttons.push({title: L("lcl_fac_print_qrcode"), action: "bkm_print()", icon: "fa-qrcode" });

    IFRAMER_HEADER(L("lcl_fac_bookmark"), buttons);
%>
      <form name="u2" onSubmit="return false;">
<%
        BLOCK_START("facInfo", L("lcl_fac_bookmark"), {icon: "fa-bookmark"});
        ROFIELDTR("fldtxt", L("lcl_fac_bookmarkid"), bkm_id);
        ROFIELDTR("fldtxt", L("lcl_fac_bookmark"), bkm_naam);
        ROFIELDTR("fldtxt", L("lcl_fac_bookmarkpath"), bkm_path);
        ROTEXTAREATR("fldfac_query", L("lcl_fac_bookmarkquery"), String(bkm_query||"").replace(/\&/ig, "\n\t&"));
        FCLTpersoonselector("sgFallback",
                            "sgFallback",
                            { perslidKey: bkm_prskey_auth,
                              label: L("lcl_bkm_prskey_auth"),
                              moreinfo: true,
                              readonly: true
                            });
        ROFIELDTR("fld", L("lcl_bkm_unauth"), bkm_unauth_url);
        ROFIELDTR("fld", L("lcl_bkm_refresh"), bkm_refresh);
        FCLTpersoonselector("sgPers",
                            "sgPers",
                            { perslidKey: bkm_prskey,
                              label: L("lcl_fac_eigenaar"),
                              moreinfo: true,
                              readonly: true
                            });
        ROFIELDTR("flddatetime", L("lcl_fac_bookmarkcreate"), toDateTimeString(bkm_aanmaak));
        BLOCK_END();

        BLOCK_START("apiSample", L("lcl_fac_bookmark")+" "+L("lcl_fac_api_sample"), {icon: "fa-code"});
          var proto = (Request.ServerVariables("SERVER_PORT") == "443")? "https" : "http";
          var sitenoroot = proto + "://" + Request.ServerVariables("SERVER_NAME");
          var site = sitenoroot + rooturl;
          var deep = site + "/?u=" + bkm_id;
          ROFIELDTR("fldtxt",L("lcl_fac_api_sample"), deep);
          var deep = site + "/?fac_id="+customerId+"&u=" + bkm_id;
          ROFIELDTR("fldtxt",L("lcl_fac_api_of"), deep);
        BLOCK_END();
%>
      </form>
      <% SUBFRAME_END(); %>
      <iframe src="../Shared/empty.html" name="hidFrameSubmit" style="display:none"></iframe>
  </body>
</html>
<% ASPPAGE_END(); %>
