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

    File:           fac_show_faq.asp
    Description:    show detailed information of an faq

    Parameters:     faq_key

    Context:
    Note:

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

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

// Autorisatie controle komt als we level weten

var faq_key = getQParamInt("faq_key");
var asWidget = getQParamInt("asWidget", 0);

var this_faq = fac.func_enabled_faq(faq_key); // Wat heb ik zoal aan rechten op deze specifieke kennisbankitem.

user.auth_required_or_abort(this_faq.canReadAny);

var sql = "SELECT fac_faq_question"
        + "     , fac_faq_answer"
        + "     , fac_faq_answer2"
        + "     , fac_faq_source"
        + "     , fac_faq_url"
        + "     , fac_faq_level"
        + "     , fac_faq_datum"
        + "     , fac_faq_wijzigdatum"
        + "     , fac_faq_vervaldatum"
        + "     , fac_faq_lang"
        + "     , fac_functie_key"
        + "     , fac_faq_hint"
        + "     , fac_faq_displaymode"
        + "     , prs_perslid_key"
        + "     , faq_ins_discipline_key"
        + "  FROM fac_faq f"
        + " WHERE fac_faq_key = " + faq_key;
var oRs = Oracle.Execute(sql);
if (oRs.Eof)
    shared.record_not_found("<!--" + faq_key + "-->");

var question = oRs("fac_faq_question").Value;
var answer = oRs("fac_faq_answer").Value;
var answer2 = oRs("fac_faq_answer2").Value;
var source = oRs("fac_faq_source").Value;
var url = oRs("fac_faq_url").Value;
var level = oRs("fac_faq_level").Value;
var perslidkey = oRs("prs_perslid_key").Value;
var datum = oRs("fac_faq_datum").Value;
var wijzigdatum = oRs("fac_faq_wijzigdatum").Value;
var vervaldatum = oRs("fac_faq_vervaldatum").Value;
var lang = oRs("fac_faq_lang").Value;
var functie_key = oRs("fac_functie_key").Value;
var hint = oRs("fac_faq_hint").Value;
var displaymode = oRs("fac_faq_displaymode").value;
var disc_key = oRs("faq_ins_discipline_key").Value;

oRs.close();

var isProf = this_faq.canFOwrite || this_faq.canBOwrite;

%>

<html>
  <head>
<%
    FCLTHeader.Generate();
%>
    <script type="text/javascript">

      function CopyToClipboard(ta)
      {
        ta.focus();
        ta.select();
        CopiedTxt = document.selection.createRange();
        CopiedTxt.execCommand("Copy");
        ta.select();
      }


      function faq_change()
      {
        if (FcltMgr.startEdit(window))
          window.location.href = "fac_edit_faq.asp?faq_key=<%=faq_key%>";
      }

      function faq_delete()
      {
        FcltMgr.confirm(L("lcl_R_U_sure"), function() {
            var data = {
                faq_key: <%=faq_key%>
            };
            <% protectRequest.dataToken("data"); %>
            $.post("faq_delete.asp",
                data,
                FcltCallbackClose,
                "json");
        });
      }

      function show_answer2()
      {
        $(".faqantwoord").toggle().promise().then(() => {
          FcltMgr.resized();
        });
      }

      $(function()
      {
        $('textarea').resize(function () { FcltMgr.resized(window) } );
        $('textarea').autogrow();
      });

    </script>
  </head>

  <body class="showmode">
<%
    SUBFRAME_START();
    var buttons = [];

    if (this_faq.canChange)
    {
      buttons.push({title: L("lcl_change"), action: "faq_change()", icon: "fa-fclt-edit"});
      buttons.push({title: L("lcl_delete"), action: "faq_delete()", icon: "fa-trash-alt"});
    }

    if (!asWidget)
      IFRAMER_HEADER(L("lcl_faq_kennisitem"), buttons);
%>
<%
        BLOCK_START("mldFaqedit", asWidget ? question : L("lcl_faq_item"), { wide: true, icon: asWidget ? "fa-lightbulb-on" : "fa-book" });
          if (asWidget)
          {
            ROTEXTAREATR("fldtxt", "", answer, {faqlink: true, mldlink: true, cntlink: true, "file_params": { "module": "FAQA", "key": faq_key }});
            if (answer2 && answer2 != "")
            {
              AFIELDTR("fld", "", "javascript:show_answer2()", L("lcl_faq_answer2"));
              ROTEXTAREATR("fldtxt faqantwoord", "", answer2, {faqlink: true, mldlink: true, cntlink: true, "file_params": { "module": "FAQB", "key": faq_key }});
            }
          }
          else
          {
            ROFIELDTR("fld", L("lcl_faq_kennisbank_nr"), faq_key);
            FCLTdisciplineselector("fac_disc",
                                   "sgDisc",
                                   { label: L("faq_discipline"),
                                     disc_key: disc_key,
                                     module: "FAQ",
                                     perslidKey: user_key,
                                     autfunctionKey: -1, // Als ik het kennisitem mag zien, dan altijd de discipline tonen, ook al heb ik er geen rechten op.
                                     autRW: "R",
                                     readonly: true
                                  });
            ROTEXTAREATR("fldtxt", L("lcl_faq_question"),  question,   {id: "fac_question", html: "rows='3' maxlength='4000'"});
            // PF: Aangepast. Zo kon je geen html formatting toepassen, dan maar niet meer die gekke kopieeroptie
            ROTEXTAREATR("fldtxt", L("lcl_faq_answer"), answer, { faqlink: true, "file_params": { "module": "FAQA", "key": faq_key }});
            ROTEXTAREATR("fldtxt", L("lcl_faq_answer2"), answer2, {faqlink: true, suppressEmpty: true, "file_params": { "module": "FAQB", "key": faq_key }});
            if (isProf)
            {
              ROTEXTAREATR("fldtxt", L("lcl_faq_hint"), hint, { faqlink: true, suppressEmpty: true } );
            }
            ROFIELDTR("fld truncate", L("lcl_faq_link"), url, { infoPointer: {Url: url, Title: L("lcl_faq_item"), NewWindow: true}, suppressEmpty: true});
          }
        BLOCK_END();

        if (!asWidget && isProf)
        {
            BLOCK_START("FaqViz", L("lcl_faq_itemviz"),  { icon: "fa-eye"} );
%>
                <tr>
                  <td class="label"><label><%=L("lcl_faq_level")%></label></td>
                  <td>
                    <input type="checkbox" class="fldcheck" name="faqVisibleZ" id="faqVisibleZ" value="1" <%=(level & 1) == 1? "CHECKED" : ""%> disabled>
                    <label for="faqVisibleZ"><%=L("lcl_faq_level1")%></label>
                    <br>
                    <input type="checkbox" class="fldcheck" name="faqVisibleP" id="faqVisibleP" value="1" <%=(level & 2) == 2? "CHECKED" : ""%> disabled>
                    <label for="faqVisibleP"><%=L("lcl_faq_level2")%></label>
                  </td>
                </tr>
<%
                if ((displaymode & 3) > 0)  // handmatige suppressEmpty
                {
%>
                <tr>
                  <td class="label faq_displaymode"><label><%=L("lcl_faq_displaymode_mld")%></label></td>
                  <td>
                    <input type="checkbox" class="fldFaqScreenM" name="faqScreenM" id="faqScreenM" value="1" <%=(displaymode & 1) == 1? "CHECKED" : ""%> disabled>
                    <label for="faqScreenM"><%=L("lcl_faq_display_screen")%></label>
                    <br>
                    <input type="checkbox" class="fldFaqPopupM" name="faqPopupM" id="faqPopupM" value="1" <%=(displaymode & 2) == 2? "CHECKED" : ""%> disabled>
                    <label for="faqPopupM"><%=L("lcl_faq_display_popup")%></label>
                    <br>
                  </td>
                </tr>
<%
            }
            if ((displaymode & 12) > 0)  // handmatige suppressEmpty
            {
%>
                <tr>
                  <td class="label faq_displaymode"><label><%=L("lcl_faq_displaymode_opdr")%></label></td>
                  <td>
                    <input type="checkbox" class="fldFaqScreenO" name="faqScreenO" id="faqScreenO" value="1" <%=(displaymode & 4) == 4? "CHECKED" : ""%> disabled>
                    <label for="faqScreenO"><%=L("lcl_faq_display_screen")%></label>
                    <br>
                    <input type="checkbox" class="fldFaqPopupO" name="faqPopupO" id="faqPopupO" value="1" <%=(displaymode & 8) == 8? "CHECKED" : ""%> disabled>
                    <label for="faqPopupO"><%=L("lcl_faq_display_popup")%></label>
                    <br>
                  </td>
                </tr>
<%
            }
            if ((displaymode & 48) > 0)  // handmatige suppressEmpty
            {
%>
                <tr>
                  <td class="label faq_displaymode"><label><%=L("lcl_faq_displaymode_afspr")%></label></td>
                  <td>
                    <input type="checkbox" class="fldFaqScreenO" name="faqScreenO" id="faqScreenO" value="1" <%=(displaymode & 16) == 16? "CHECKED" : ""%> disabled>
                    <label for="faqScreenO"><%=L("lcl_faq_display_screen")%></label>
                    <br>
                    <input type="checkbox" class="fldFaqPopupO" name="faqPopupO" id="faqPopupO" value="1" <%=(displaymode & 32) == 32? "CHECKED" : ""%> disabled>
                    <label for="faqPopupO"><%=L("lcl_faq_display_popup")%></label>
                    <br>
                  </td>
                </tr>
<%
            }
            BLOCK_END();
            BLOCK_START("FaqAdm", L("lcl_faq_itemadm"),  { icon: "fa-tag"} );
                ROFIELDTR("fld",          L("lcl_faq_datum"),  toDateString(datum));
                ROFIELDTR("fld",          L("lcl_faq_vervaldatum"),  toDateString(vervaldatum), { suppressEmpty: true});
                ROFIELDTR("fld",          L("lcl_faq_bron"),        source,     { suppressEmpty: true});
                FCLTpersoonselector("sgPers",
                                    "sgPers",
                                    { perslidKey: perslidkey,
                                      label: L("lcl_faq_ingevoerd"),
                                      moreinfo: true,
                                      readonly: true
                                    });
                ROFIELDTR("fld",          L("lcl_faq_wijzigdatum"),  toDateTimeString(wijzigdatum), { suppressEmpty: true});
                ROFIELDTR("fld",          L("lcl_faq_lang"),   lang, {suppressEmpty: true});
                <!-- Extra autorisatie functies -->
                var sql = "SELECT fac_functie_key, lcl.l(fac_functie_omschrijving, 1) || ' (' || fac_functie_code || ')' FROM fac_functie WHERE fac_functie_key=" + functie_key;
                FCLTselector("fac_functie",
                             sql,
                             { initKey: functie_key,
                               label: L("lcl_usrrap_functie"),
                               trclass:"primsearch",
                               multi: false,
                               readonly: true,
                               suppressEmpty: true,
                               emptyOption: L("lcl_all")
                             });
            BLOCK_END();
        }

        if (!asWidget)
            generateFlexKenmerkCode ({ faq_key: faq_key,
                                       disc_key: disc_key,
                                       reado  : true
                                    });
%>
<% SUBFRAME_END(); %>
  </body>
</html>
<% ASPPAGE_END(); %>
