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

    File:           fac_edit_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/calendar.inc" -->
<!-- #include file="../Shared/persoonselector.inc" -->
<!-- #include file="../Shared/selector.inc" -->
<!-- #include file="faq_flexkenmerk.inc" -->
<!-- #include file="../fac/fac.inc" -->

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

var authparamsFAQFOF = user.checkAutorisation("WEB_FAQFOF", true); // Frontoffice mag items aanmaken en bewerken
var authparamsFAQBOF = user.checkAutorisation("WEB_FAQBOF", true); // Backoffice mag ingevoerde items publiceren (publicatie datum zetten/aanpassen)
var canWriteFAQFOF = authparamsFAQFOF && authparamsFAQFOF.PRSwritelevel < 9 && authparamsFAQFOF.ALGwritelevel < 9;
var canWriteFAQBOF = authparamsFAQBOF && authparamsFAQBOF.PRSwritelevel < 9 && authparamsFAQBOF.ALGwritelevel < 9;
user.auth_required_or_abort(canWriteFAQFOF || canWriteFAQBOF);

var faq_key = getQParamInt("faq_key", -1);
var alg_loc_key = -1;

var level = 3; // default beide
if (faq_key > -1)
{
  var sql = "SELECT fac_faq_question"
          + "     , fac_faq_answer"
          + "     , fac_faq_source"
          + "     , fac_faq_url"
          + "     , fac_faq_level"
          + "     , fac_faq_datum"
          + "     , fac_faq_lang"
          + "     , fac_faq_hint"
          + "     , fac_faq_displaymode"
          + "     , prs_perslid_key"
          + "  FROM fac_faq"
          + " WHERE fac_faq_key = " + faq_key;
  var oRs = Oracle.Execute(sql);

  var question = oRs("fac_faq_question").value;
  var answer = oRs("fac_faq_answer").value;
  var source = oRs("fac_faq_source").value;
  var url = oRs("fac_faq_url").value;
  level = oRs("fac_faq_level").value;
  var perslidkey = oRs("prs_perslid_key").value;
  var datum = oRs("fac_faq_datum").value;
  var lang = oRs("fac_faq_lang").value;
  var hint = oRs("fac_faq_hint").value;
  var displaymode = oRs("fac_faq_displaymode").value;
}
else
{
    if (canWriteFAQBOF)
        datum = new Date();
    var displaymode = 0; // automatisch
}
%>

<html>
  <head>
<%  FCLTHeader.Generate(); %>
    <script type="text/javascript">
      function fac_submit()
      {
        if (!validateForm("u2"))
          return false;
        document.forms.u2.submit();
      }

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


      jQuery(document).ready(function()
                             {
                               $('textarea').resize(function () { FcltMgr.resized(window) } );
                               $('textarea').autogrow();
                             });
    </script>
  </head>

  <body id="editbody">
<%
    var buttons =  [ {title: L("lcl_submit"), action:"fac_submit()", icon: "opslaan.png" },
                     {title: L("lcl_cancel"), action:"fac_cancel()", icon: "undo.png" }];

    IFRAMER_HEADER(L("lcl_faq_kennisitem"), buttons);
%>
    <div id="edit">
      <form name="u2"
            action="fac_edit_faq_save.asp?faq_key=<%=faq_key%>"
            method="post"
            target="hidFrameSubmit"
            onSubmit="job_submit();">
<%
        BLOCK_START("mldFaqedit", L("lcl_faq_item"));
        RWTEXTAREATR("fac_question", "fldtxt required", L("lcl_faq_question"), question, {html: "rows='3' maxlength='4000'"});
        RWTEXTAREATR("fac_answer", "fldtxt required", L("lcl_faq_answer"), answer, {html: "rows='3' maxlength='4000'"});
        RWTEXTAREATR("fac_hint", "fldtxt", L("lcl_faq_hint"), hint);
        BLOCK_END();

        BLOCK_START("mldInfo", L("lcl_faq_itemadm"));
        var sql= "           SELECT 1,  " + safe.quoted_sql(L("lcl_faq_level1")) + " FROM DUAL"
               + " UNION ALL SELECT 2,  " + safe.quoted_sql(L("lcl_faq_level2")) + " FROM DUAL"
               + " UNION ALL SELECT 3,  " + safe.quoted_sql(L("lcl_faq_level3")) + " FROM DUAL"
        FCLTselector("fac_faq_level", sql,
          { initKey: level,
            label: L("lcl_faq_level")
          });

        RWCHECKBOXTR("fac_faq_displaymode", "fldcheck", L("lcl_faq_displaymode"), displaymode);
        RWFIELDTR("fac_bron", "fld", L("lcl_faq_bron"), source);
        RWFIELDTR("fac_url", "fld", L("lcl_faq_link"), url);
        if (!canWriteFAQBOF && datum==null)
            ROFIELDTR("fld", L("lcl_faq_datum"), L("lcl_faq_needaccept"));
        else
            FCLTcalendar( "date_from",
                          { label: L("lcl_faq_datum"),
                            datum: datum!=null?new Date(datum):null,
                            initEmpty: (datum == null),
                            readonly: !canWriteFAQBOF
                          });

        if (S("language_toggles").length > 0)
        {
          var sql = "SELECT '', '', 1 FROM DUAL";
          for (var i = 0; i< S("language_toggles").length; i++)
          {
            sql += (sql != ""? " UNION ": "") + "SELECT " + safe.quoted_sql(S("language_toggles")[i]) + ", " + safe.quoted_sql(S("language_toggles")[i]) + ", 2 FROM DUAL";
          }
          sql += " ORDER BY 3, 2";
          FCLTselector("fac_faq_lang", sql,
                       { initKey: lang,
                         label: L("lcl_faq_lang")
                       });
        }
        BLOCK_END();

        BLOCK_START("faqFlex2", L("lcl_faq_flexblok"));
%>
        <tr>
          <td>
<%          generateFlexKenmerkCode ({ faq_key: faq_key,
                                       reado  : false,
                                       flexcolumns: S("faq_flexcolumns")
                                     }); %>
          </td>
        </tr>
<%
        BLOCK_END();

        IFACE.FORM_END();
%>
      </form>
      <iframe src="../Shared/empty.html" name="hidFrameSubmit" style="display:none"></iframe>
    </div>
  </body>
</html>
